diff --git a/dlgr/griduniverse/config.txt b/dlgr/griduniverse/config.txt index 1a803f08..33da3b36 100644 --- a/dlgr/griduniverse/config.txt +++ b/dlgr/griduniverse/config.txt @@ -2,8 +2,15 @@ mode = debug auto_recruit = true network = FullyConnected -max_participants = 3 -time_per_round = 30 +max_participants = 1 +num_rounds = 3 +time_per_round = 45 +block_size = 20 +columns = 200 +rows = 100 +window_rows = 20 +window_columns = 20 +use_identicons = true [HIT Configuration] title = Griduniverse diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index f3e1ed98..ed478ad8 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -32,7 +32,7 @@ item_defaults: sprite: "#8a9b0f,#7a6b54" transition_defaults: - visible: never # Can be set to "never", "always", or "seen" for transitions that become + visible: seen # Can be set to "never", "always", or "seen" for transitions that become # visible to a player after they have been executed for the first time actor_end: null actor_start: null @@ -83,7 +83,7 @@ items: item_id: wild_carrot_plant portable: true spawn_rate: 0.15 - item_count: 2 + item_count: 100 sprite: "#E67E22" - crossable: true @@ -92,7 +92,7 @@ items: item_id: stone portable: true spawn_rate: 0.05 - item_count: 5 + item_count: 50 sprite: "#95A5A6" - crossable: true @@ -101,7 +101,7 @@ items: item_id: big_hard_rock portable: false spawn_rate: 0 - item_count: 2 + item_count: 20 sprite: "#7F8C8D" - crossable: true @@ -111,7 +111,7 @@ items: item_id: gooseberry_bush portable: false spawn_rate: 0.1 - item_count: 2 + item_count: 50 sprite: "#8E44AD" - crossable: true @@ -120,7 +120,7 @@ items: item_id: sharp_stone portable: true spawn_rate: 0.05 - item_count: 5 + item_count: 20 sprite: "#BDC3C7" - calories: 5 @@ -130,7 +130,7 @@ items: name: Wild Carrot item_id: wild_carrot portable: true - spawn_rate: 0.1 + spawn_rate: 0 item_count: 0 sprite: "#E67E22" @@ -141,7 +141,7 @@ items: name: Gooseberry item_id: gooseberry portable: true - spawn_rate: 0.1 + spawn_rate: 0 item_count: 0 sprite: "#8E44AD" @@ -179,6 +179,7 @@ transitions: - actor_end: gooseberry actor_start: null last_use: false + visible: never modify_uses: - 0 - -1 @@ -188,6 +189,7 @@ transitions: - actor_end: gooseberry actor_start: null last_use: true + visible: always modify_uses: - 0 - -1 diff --git a/dlgr/griduniverse/static/scripts/demo.js b/dlgr/griduniverse/static/scripts/demo.js index 796fa51e..777a04dc 100755 --- a/dlgr/griduniverse/static/scripts/demo.js +++ b/dlgr/griduniverse/static/scripts/demo.js @@ -246,13 +246,13 @@ Player.prototype.replaceItem = function(item) { if (item && !(item instanceof itemlib.Item)) { item = new itemlib.Item(item.id, item.item_id, item.maturity, item.remaining_uses) } - this.current_item = item; + this.currentItem = item; displayWhatEgoPlayerIsCarrying(item); }; Player.prototype.getTransition = function () { var transition; - var player_item = this.current_item; + var player_item = this.currentItem; var position = this.position; var item_at_pos = gridItems.atPosition(position); var transition_id = (player_item && player_item.itemId || '') + '|' + (item_at_pos && item_at_pos.itemId || ''); @@ -773,7 +773,7 @@ function bindGameKeys(socket) { var ego = players.ego(); var position = ego.position; var item_at_pos = gridItems.atPosition(position); - var player_item = ego.current_item; + var player_item = ego.currentItem; var transition = ego.getTransition(); if (!item_at_pos && !player_item) { // If there's nothing here, we try to plant food GU 1.0 style @@ -812,8 +812,8 @@ function bindGameKeys(socket) { Mousetrap.bind("d", function () { var ego = players.ego(); var position = ego.position; - var current_item = ego.current_item; - if (!current_item || gridItems.atPosition(position)) { + var currentItem = ego.currentItem; + if (!currentItem || gridItems.atPosition(position)) { return; } var msg = { @@ -823,7 +823,7 @@ function bindGameKeys(socket) { }; socket.send(msg); ego.replaceItem(null); - gridItems.add(current_item, position); + gridItems.add(currentItem, position); }); if (settings.mutable_colors) { @@ -1001,6 +1001,7 @@ function renderTransition(transition) { if (! transition) { return ""; } + const transition_visibility = transition.transition.visible; const states = [ transition.transition.actor_start, transition.transition.actor_end, @@ -1012,7 +1013,21 @@ function renderTransition(transition) { (state) => settings.item_config[state] ); - return `✋${aStartItem.name} + ${tStartItem.name} → ✋${aEndItem.name} + ${tEndItem.name}`; + const aStartItemString = `✋${aStartItem ? aStartItem.name : '⬜'}`; + const tStartItemString = tStartItem ? tStartItem.name : '⬜'; + if (transition_visibility == "never") { + return `${aStartItemString} + ${tStartItemString}` + } + + if (transition_visibility == "seen" && !transitionsSeen.has(transition.id)) { + var aEndItemString = "✋❓"; + var tEndItemString = "✋❓"; + } else { + aEndItemString = `✋${aEndItem ? aEndItem.name: '⬜'}`; + tEndItemString = tEndItem ? tEndItem.name: '⬜'; + } + return `${aStartItemString} + ${tStartItemString} → ${aEndItemString} + ${tEndItemString}`; + } /** * If the current player is sharing a grid position with an interactive @@ -1034,7 +1049,12 @@ function updateItemInfoWindow(egoPlayer, gridItems) { } if (! transition) { - $transition.empty(); + // If we're holding an item with calories, indicate that we might want to eat it. + if (egoPlayer.currentItem && egoPlayer.currentItem.calories) { + $transition.html(`✋${egoPlayer.currentItem.name} + 🤤`); + } else { + $transition.empty(); + } } else { $transition.html(renderTransition(transition)); } diff --git a/dlgr/griduniverse/static/scripts/dist/bundle.js b/dlgr/griduniverse/static/scripts/dist/bundle.js index 7524ba79..f2ed1d17 100644 --- a/dlgr/griduniverse/static/scripts/dist/bundle.js +++ b/dlgr/griduniverse/static/scripts/dist/bundle.js @@ -33,6 +33,9 @@ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { @@ -60,7 +63,7 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 8); +/******/ return __webpack_require__(__webpack_require__.s = 16); /******/ }) /************************************************************************/ /******/ ([ @@ -68,187 +71,6 @@ /* 1 */ /***/ (function(module, exports, __webpack_require__) { -var convert = __webpack_require__(10); - -module.exports = function (cstr) { - var m, conv, parts, alpha; - if (m = /^((?:rgb|hs[lv]|cmyk|xyz|lab)a?)\s*\(([^\)]*)\)/.exec(cstr)) { - var name = m[1]; - var base = name.replace(/a$/, ''); - var size = base === 'cmyk' ? 4 : 3; - conv = convert[base]; - - parts = m[2].replace(/^\s+|\s+$/g, '') - .split(/\s*,\s*/) - .map(function (x, i) { - if (/%$/.test(x) && i === size) { - return parseFloat(x) / 100; - } - else if (/%$/.test(x)) { - return parseFloat(x); - } - return parseFloat(x); - }) - ; - if (name === base) parts.push(1); - alpha = parts[size] === undefined ? 1 : parts[size]; - parts = parts.slice(0, size); - - conv[base] = function () { return parts }; - } - else if (/^#[A-Fa-f0-9]+$/.test(cstr)) { - var base = cstr.replace(/^#/,''); - var size = base.length; - conv = convert.rgb; - parts = base.split(size === 3 ? /(.)/ : /(..)/); - parts = parts.filter(Boolean) - .map(function (x) { - if (size === 3) { - return parseInt(x + x, 16); - } - else { - return parseInt(x, 16) - } - }) - ; - alpha = 1; - conv.rgb = function () { return parts }; - if (!parts[0]) parts[0] = 0; - if (!parts[1]) parts[1] = 0; - if (!parts[2]) parts[2] = 0; - } - else { - conv = convert.keyword; - conv.keyword = function () { return cstr }; - parts = cstr; - alpha = 1; - } - - var res = { - rgb: undefined, - hsl: undefined, - hsv: undefined, - cmyk: undefined, - keyword: undefined, - hex: undefined - }; - try { res.rgb = conv.rgb(parts) } catch (e) {} - try { res.hsl = conv.hsl(parts) } catch (e) {} - try { res.hsv = conv.hsv(parts) } catch (e) {} - try { res.cmyk = conv.cmyk(parts) } catch (e) {} - try { res.keyword = conv.keyword(parts) } catch (e) {} - - if (res.rgb) res.hex = '#' + res.rgb.map(function (x) { - var s = x.toString(16); - if (s.length === 1) return '0' + s; - return s; - }).join(''); - - if (res.rgb) res.rgba = res.rgb.concat(alpha); - if (res.hsl) res.hsla = res.hsl.concat(alpha); - if (res.hsv) res.hsva = res.hsv.concat(alpha); - if (res.cmyk) res.cmyka = res.cmyk.concat(alpha); - - return res; -}; - - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/*! - * is-number <https://github.com/jonschlinkert/is-number> - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - - - -var typeOf = __webpack_require__(12); - -module.exports = function isNumber(num) { - var type = typeOf(num); - if (type !== 'number' && type !== 'string') { - return false; - } - var n = +num; - return (n - n + 1) >= 0 && num !== ''; -}; - - -/***/ }), -/* 3 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var strValue = String.prototype.valueOf; -var tryStringObject = function tryStringObject(value) { - try { - strValue.call(value); - return true; - } catch (e) { - return false; - } -}; -var toStr = Object.prototype.toString; -var strClass = '[object String]'; -var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; - -module.exports = function isString(value) { - if (typeof value === 'string') { return true; } - if (typeof value !== 'object') { return false; } - return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; -}; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports) { - - -/** - * isArray - */ - -var isArray = Array.isArray; - -/** - * toString - */ - -var str = Object.prototype.toString; - -/** - * Whether or not the given `val` - * is an array. - * - * example: - * - * isArray([]); - * // > true - * isArray(arguments); - * // > false - * isArray(''); - * // > false - * - * @param {mixed} val - * @return {bool} - */ - -module.exports = isArray || function (val) { - return !! val && '[object Array]' == str.call(val); -}; - - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { - var __WEBPACK_AMD_DEFINE_RESULT__;/* * JavaScript MD5 * https://github.com/blueimp/JavaScript-MD5 @@ -533,166 +355,11 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/* }(this)) /***/ }), -/* 6 */ -/***/ (function(module, exports) { - -module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __webpack_require__) { +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { /* MIT license */ -var cssKeywords = __webpack_require__(6); +var cssKeywords = __webpack_require__(27); // NOTE: conversions should only return primitive values (i.e. arrays, or // values that give correct `typeof` results). @@ -788,41 +455,48 @@ convert.rgb.hsl = function (rgb) { }; convert.rgb.hsv = function (rgb) { - var r = rgb[0]; - var g = rgb[1]; - var b = rgb[2]; - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var delta = max - min; + var rdif; + var gdif; + var bdif; var h; var s; - var v; - - if (max === 0) { - s = 0; - } else { - s = (delta / max * 1000) / 10; - } - - if (max === min) { - h = 0; - } else if (r === max) { - h = (g - b) / delta; - } else if (g === max) { - h = 2 + (b - r) / delta; - } else if (b === max) { - h = 4 + (r - g) / delta; - } - h = Math.min(h * 60, 360); + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var v = Math.max(r, g, b); + var diff = v - Math.min(r, g, b); + var diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2; + }; - if (h < 0) { - h += 360; + if (diff === 0) { + h = s = 0; + } else { + s = diff / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); + + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = (1 / 3) + rdif - bdif; + } else if (b === v) { + h = (2 / 3) + gdif - rdif; + } + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } } - v = ((max / 255) * 1000) / 10; - - return [h, s, v]; + return [ + h * 360, + s * 100, + v * 100 + ]; }; convert.rgb.hwb = function (rgb) { @@ -1555,32718 +1229,34455 @@ convert.rgb.gray = function (rgb) { /***/ }), -/* 8 */ -/***/ (function(module, exports, __webpack_require__) { +/* 3 */ +/***/ (function(module, exports) { -var require;/*global dallinger, require, settings */ -/*jshint esversion: 6 */ -(function (dallinger, require, settings) { +/** + * isArray + */ -var grid = __webpack_require__(9); -var position = __webpack_require__(23); -var Mousetrap = __webpack_require__(25); -var ReconnectingWebSocket = __webpack_require__(26); -var $ = __webpack_require__(27); -var gaussian = __webpack_require__(28); -var Color = __webpack_require__(29); -var Identicon = __webpack_require__(35); -var md5 = __webpack_require__(5); -var itemlib = __webpack_require__ (37); +var isArray = Array.isArray; -function coordsToIdx(x, y, columns) { - return y * columns + x; -} +/** + * toString + */ -function animateColor(color) { - if (settings.background_animation) { - rand = Math.random() * 0.02; - } else { - rand = 0.01; - } - return [ - color[0] * 0.95 + rand, - color[1] * 0.95 + rand, - color[2] * 0.95 + rand - ]; -} +var str = Object.prototype.toString; -function positionsAreEqual(a, b) { - // Items with null positions are never co-located - if (a === null || b === null) { - return false; - } - return a[0] === b[0] && a[1] === b[1]; -} +/** + * Whether or not the given `val` + * is an array. + * + * example: + * + * isArray([]); + * // > true + * isArray(arguments); + * // > false + * isArray(''); + * // > false + * + * @param {mixed} val + * @return {bool} + */ -class Section { - // Represents the currently visible section (window) of the grid +module.exports = isArray || function (val) { + return !! val && '[object Array]' == str.call(val); +}; - constructor(data, left, top) { - this.left = left; - this.top = top; - this.columns = settings.window_columns; - this.rows = settings.window_rows; - this.data = []; - this.textures = []; - // build data array for just this section - for (var j = 0; j < this.rows; j++) { - for (var i = 0; i < this.columns; i++) { - this.data.push(data[this.sectionCoordsToGridIdx(i, j)]); - this.textures.push(0); - } - } - } - gridCoordsToSectionIdx(x, y) { - // Convert grid coordinates to section data array index - return (y - this.top) * this.columns + (x - this.left); - } +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { - sectionCoordsToGridIdx(x, y) { - // Convert section coordinates to grid data array index - return coordsToIdx(this.left + x, this.top + y, settings.columns); - } +"use strict"; +/*! + * is-number <https://github.com/jonschlinkert/is-number> + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ - plot(x, y, color, texture) { - // Set color at position (x, y) in full-grid coordinates. - if (x >= this.left && x < this.left + this.columns) { - if (y >= this.top && y < this.top + this.rows) { - this.data[this.gridCoordsToSectionIdx(x, y)] = color; - if (texture !== undefined ){ - this.textures[this.gridCoordsToSectionIdx(x, y)] = texture; - } - background[coordsToIdx(x, y, settings.columns)] = color; - } - } - } - map(func) { - // For each cell, call func with (x, y, color) to get the new color - for (var j = 0; j < this.rows; j++) { - for (var i = 0; i < this.columns; i++) { - var idx = coordsToIdx(i, j, this.columns); - this.data[idx] = Reflect.apply( - func, this, [this.left + i, this.top + j, this.data[idx]]); - } - } - } -} -var background = [], color; -for (var j = 0; j < settings.rows; j++) { - for (var i = 0; i < settings.columns; i++) { - color = [0, 0, 0]; - for (var k = 0; k < 15; k++) { - color = animateColor(color); - } - background.push(color); - } -} +var typeOf = __webpack_require__(35); -var initialSection = new Section(background, 0, 0); +module.exports = function isNumber(num) { + var type = typeOf(num); -var INVISIBLE_COLOR = [0.66, 0.66, 0.66]; -var CHANNEL = "griduniverse"; -var CONTROL_CHANNEL = "griduniverse_ctrl"; + if (type === 'string') { + if (!num.trim()) return false; + } else if (type !== 'number') { + return false; + } -var pixels = grid(initialSection.data, initialSection.textures, { - rows: settings.window_rows, - columns: settings.window_columns, - size: settings.block_size, - padding: settings.padding, - background: [0.1, 0.1, 0.1], - formatted: true -}); + return (num - num + 1) >= 0; +}; -var mouse = position(pixels.canvas); -var isSpectator = false; -var start = performance.now(); -var gridItems = new itemlib.GridItems(); -var walls = []; -var wall_map = {}; -var transitionsSeen = new Set(); -var rand; +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { -var name2idx = function (name) { - var names = settings.player_color_names; - for (var idx=0; idx < names.length; idx++) { - if (names[idx] === name) { - return idx; - } - } +"use strict"; + + +var strValue = String.prototype.valueOf; +var tryStringObject = function tryStringObject(value) { + try { + strValue.call(value); + return true; + } catch (e) { + return false; + } }; +var toStr = Object.prototype.toString; +var strClass = '[object String]'; +var hasToStringTag = __webpack_require__(32)(); -var color2idx = function (color) { - var colors = settings.player_colors; - var value = color.join(','); - for (var idx=0; idx < colors.length; idx++) { - if (colors[idx].join(',') === value) { - return idx; - } - } +module.exports = function isString(value) { + if (typeof value === 'string') { + return true; + } + if (typeof value !== 'object') { + return false; + } + return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; }; -var color2name = function (color) { - var idx = color2idx(color); - return settings.player_color_names[idx]; -} +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { -var Wall = function (settings) { - if (!(this instanceof Wall)) { - return new Wall(); - } - this.position = settings.position; - this.color = settings.color; - return this; -}; +var convert = __webpack_require__(39); -var Player = function (settings, dimness) { - if (!(this instanceof Player)) { - return new Player(); - } - this.id = settings.id; - this.position = settings.position; - this.positionInSync = true; - this.color = settings.color; - this.motion_auto = settings.motion_auto; - this.motion_direction = settings.motion_direction; - this.motion_speed_limit = settings.motion_speed_limit; - this.motion_timestamp = settings.motion_timestamp; - this.score = settings.score; - this.payoff = settings.payoff; - this.name = settings.name; - this.identity_visible = settings.identity_visible; - this.dimness = dimness; - this.replaceItem(settings.current_item); - return this; +module.exports = function (cstr) { + var m, conv, parts, alpha; + if (m = /^((?:rgb|hs[lv]|cmyk|xyz|lab)a?)\s*\(([^\)]*)\)/.exec(cstr)) { + var name = m[1]; + var base = name.replace(/a$/, ''); + var size = base === 'cmyk' ? 4 : 3; + conv = convert[base]; + + parts = m[2].replace(/^\s+|\s+$/g, '') + .split(/\s*,\s*/) + .map(function (x, i) { + if (/%$/.test(x) && i === size) { + return parseFloat(x) / 100; + } + else if (/%$/.test(x)) { + return parseFloat(x); + } + return parseFloat(x); + }) + ; + if (name === base) parts.push(1); + alpha = parts[size] === undefined ? 1 : parts[size]; + parts = parts.slice(0, size); + + conv[base] = function () { return parts }; + } + else if (/^#[A-Fa-f0-9]+$/.test(cstr)) { + var base = cstr.replace(/^#/,''); + var size = base.length; + conv = convert.rgb; + parts = base.split(size === 3 ? /(.)/ : /(..)/); + parts = parts.filter(Boolean) + .map(function (x) { + if (size === 3) { + return parseInt(x + x, 16); + } + else { + return parseInt(x, 16) + } + }) + ; + alpha = 1; + conv.rgb = function () { return parts }; + if (!parts[0]) parts[0] = 0; + if (!parts[1]) parts[1] = 0; + if (!parts[2]) parts[2] = 0; + } + else { + conv = convert.keyword; + conv.keyword = function () { return cstr }; + parts = cstr; + alpha = 1; + } + + var res = { + rgb: undefined, + hsl: undefined, + hsv: undefined, + cmyk: undefined, + keyword: undefined, + hex: undefined + }; + try { res.rgb = conv.rgb(parts) } catch (e) {} + try { res.hsl = conv.hsl(parts) } catch (e) {} + try { res.hsv = conv.hsv(parts) } catch (e) {} + try { res.cmyk = conv.cmyk(parts) } catch (e) {} + try { res.keyword = conv.keyword(parts) } catch (e) {} + + if (res.rgb) res.hex = '#' + res.rgb.map(function (x) { + var s = x.toString(16); + if (s.length === 1) return '0' + s; + return s; + }).join(''); + + if (res.rgb) res.rgba = res.rgb.concat(alpha); + if (res.hsl) res.hsla = res.hsl.concat(alpha); + if (res.hsv) res.hsva = res.hsv.concat(alpha); + if (res.cmyk) res.cmyka = res.cmyk.concat(alpha); + + return res; }; -Player.prototype.move = function(direction) { - function _isCrossable(position) { - const hasWall = ! _.isUndefined(wall_map[[position[1], position[0]]]); - if (hasWall) { - return false; - } - const itemHere = gridItems.atPosition(position); - return _.isNull(itemHere) || itemHere.crossable; - } +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { - this.motion_direction = direction; +var parse = __webpack_require__(6); +var isnumber = __webpack_require__(4); +var isstring = __webpack_require__(5); +var isarray = __webpack_require__(3); +var convert = __webpack_require__(19); +var layout = __webpack_require__(20); +var texcoord = __webpack_require__(24); +var range = __webpack_require__(23); +var pixdenticon = __webpack_require__(21); +var md5 = __webpack_require__(1); - var ts = performance.now() - start, - waitTime = 1000 / this.motion_speed_limit; +function Pixels(data, textures, opts) { + if (!(this instanceof Pixels)) return new Pixels(data, textures, opts); + var self = this; + opts = opts || {}; + this.opts = opts; + var num_identicons = 100; - if (ts > this.motion_timestamp + waitTime) { - var newPosition = this.position.slice(); + opts.background = opts.background || [ 0.5, 0.5, 0.5 ]; + opts.size = isnumber(opts.size) ? opts.size : 10; + opts.padding = isnumber(opts.padding) ? opts.padding : 2; - switch (direction) { - case "up": - if (this.position[0] > 0) { - newPosition[0] -= 1; - } - break; + if (isstring(opts.background)) + opts.background = parse(opts.background).rgb.map(function(c) { + return c / 255; + }); - case "down": - if (this.position[0] < settings.rows - 1) { - newPosition[0] += 1; - } - break; + if (isarray(data[0]) && data[0].length !== 3) { + opts.rows = data.length; + opts.columns = data[0].length; + } - case "left": - if (this.position[1] > 0) { - newPosition[1] -= 1; - } - break; + if (!opts.rows || !opts.columns) { + opts.rows = opts.columns = Math.round(Math.sqrt(data.length)); + } - case "right": - if (this.position[1] < settings.columns - 1) { - newPosition[1] += 1; - } - break; + var width = opts.columns * opts.size + (opts.columns + 1) * opts.padding; + var height = opts.rows * opts.size + (opts.rows + 1) * opts.padding; - default: - console.log("Direction not recognized."); - } + var canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + if (opts.root) opts.root.appendChild(canvas); - if (_isCrossable(newPosition) && (!players.isPlayerAt(newPosition) || settings.player_overlap)) { - this.position = newPosition; - this.motion_timestamp = ts; - return true; - } - } - return false; -}; + var colors = opts.formatted ? data : convert(data); + var texcoords = texcoord( + opts.rows, + opts.columns, + textures, + num_identicons + ); + var positions = layout( + opts.rows, + opts.columns, + 2 * opts.padding / width, + 2 * opts.size / width, + width / height + ); -Player.prototype.replaceItem = function(item) { - if (item && !(item instanceof itemlib.Item)) { - item = new itemlib.Item(item.id, item.item_id, item.maturity, item.remaining_uses) - } - this.current_item = item; - displayWhatEgoPlayerIsCarrying(item); -}; + var regl = __webpack_require__(40)(canvas); -Player.prototype.getTransition = function () { - var transition; - var player_item = this.current_item; - var position = this.position; - var item_at_pos = gridItems.atPosition(position); - var transition_id = (player_item && player_item.itemId || '') + '|' + (item_at_pos && item_at_pos.itemId || ''); - var last_transition_id = 'last_' + transition_id; - if (item_at_pos && item_at_pos.remaining_uses == 1) { - transition = settings.transition_config[last_transition_id]; - if (transition) { - transition_id = last_transition_id; + var initial_texture = []; + for (row = 0; row < opts.size; row++) { + rowdata = [] + for (col = 0; col < opts.size; col++) { + rowdata.push([255, 255, 255]); } + initial_texture.push(rowdata); } - if (!transition) { - transition = settings.transition_config[transition_id]; - } - if (!transition) { - return null; + var salt = $("#grid").data("identicon-salt"); + for (var i = 0; i < num_identicons; i++) { + texture = new pixdenticon(md5(salt + i), opts.size).render().buffer; + for (row = 0; row < opts.size; row++) { + initial_texture.push(texture[row]); + } } - return {id: transition_id, transition: transition}; -} -var playerSet = (function () { + var texture = regl.texture(initial_texture); - var PlayerSet = function (settings) { - if (!(this instanceof PlayerSet)) { - return new PlayerSet(settings); - } + var squares = regl({ + vert: ` + precision mediump float; + attribute vec2 position; + attribute vec2 texcoords; + attribute vec3 color; + varying vec3 vcolor; + varying vec2 v_texcoords; + void main() { + gl_PointSize = float(${opts.size}); + gl_Position = vec4(position.x, position.y, 0.0, 1.0); + v_texcoords = texcoords; + vcolor = color; + } + `, + frag: ` + precision mediump float; + varying vec3 vcolor; + varying vec2 v_texcoords; + uniform sampler2D vtexture; + void main() { + vec4 texture; + texture = texture2D(vtexture, v_texcoords); + gl_FragColor = texture * vec4(vcolor.r, vcolor.g, vcolor.b, 1.0); + } + `, + attributes: { position: regl.prop("position"), texcoords: regl.prop("texcoords"), color: regl.prop("color")}, + primitive: "triangles", + count: colors.length * 6, + uniforms: { vtexture: texture } + }); - this._players = {}; - this.ego_id = settings.ego_id; - }; + var expanded_colors = []; + for(var i = 0; i < colors.length; ++i){ + for(var n = 0; n < 6; ++n) { + expanded_colors.push(colors[i]); + } + } - PlayerSet.prototype.isPlayerAt = function (position) { - var id, player; + var buffer = { position: regl.buffer(positions), texcoords: regl.buffer(texcoords), color: regl.buffer(expanded_colors)}; - for (id in this._players) { - if (this._players.hasOwnProperty(id)) { - player = this._players[id]; - if (positionsAreEqual(position, player.position)) { - return true; - } - } - } - return false; - }; + var draw = function(positions, texcoords, colors) { + regl.clear({ color: opts.background.concat([ 1 ]) }); + squares({ position: positions, texcoords: texcoords, color: colors }); + }; - PlayerSet.prototype.drawToGrid = function (grid) { - var player, - id, - minScore, - maxScore, - d, - color, - player_color; - if (settings.score_visible) { - minScore = this.minScore(); - maxScore = this.maxScore(); - } + draw(buffer.position, buffer.texcoords, buffer.color); - for (id in this._players) { - if (this._players.hasOwnProperty(id)) { - player = this._players[id]; - /* It's unlikely that auto motion will keep identical pace to server-side auto-motion */ - /* this should be implemented either all on server or all on client */ - if (player.motion_auto) { - player.move(player.motion_direction); - } - if (id === this.ego_id || settings.others_visible) { - player_color = settings.player_colors[name2idx(player.color)]; - if (player.identity_visible) { - color = player_color; - } else { - color = (id === this.ego_id) ? Color.rgb(player_color).desaturate(0.6).rgb().array() : INVISIBLE_COLOR; - } - if (settings.score_visible) { - if (maxScore-minScore > 0) { - d = 0.75 * (1 - (player.score-minScore)/(maxScore-minScore)); - } else { - d = 0.375; - } - color = Color.rgb(player_color).desaturate(d).rgb().array(); - } else { - color = player_color; - } - var texture = 0; - if (settings.use_identicons) { - texture = parseInt(id, 10); - } - grid.plot(player.position[1], player.position[0], color, texture); - if (id === this.ego_id) { - store.set("color", color2name(color)); - } - } - } - } - }; + self._buffer = buffer; + self._draw = draw; + self._formatted = opts.formatted; + self.canvas = canvas; + self.frame = regl.frame; +} - PlayerSet.prototype.nearest = function (row, column) { - var distances = [], - distance, - player, - id; +Pixels.prototype.update = function(data, textures) { + var self = this; + var colors = self._formatted ? data : convert(data); + var expanded_colors = []; - for (id in this._players) { - if (this._players.hasOwnProperty(id)) { - player = this._players[id]; - if (player.hasOwnProperty('position')) { - distance = Math.abs(row - player.position[0]) + Math.abs(column - player.position[1]); - distances.push({"player": player, "distance": distance}); - } - } - } + for(var i = 0; i < colors.length; ++i){ + for(var n = 0; n < 6; ++n) { + expanded_colors.push(colors[i]); + } + } - distances.sort(function (a, b) { - return a.distance - b.distance; - }); + var opts = this.opts; + var num_identicons = 100; - return distances[0].player; - }; + var texcoords = texcoord( + opts.rows, + opts.columns, + textures, + num_identicons + ); - PlayerSet.prototype.ego = function () { - return this.get(this.ego_id); - }; + self._draw(self._buffer.position, self._buffer.texcoords(texcoords), self._buffer.color(expanded_colors)); +}; - PlayerSet.prototype.get = function (id) { - return this._players[id]; - }; +module.exports = Pixels; - PlayerSet.prototype.count = function () { - return Object.keys(this._players).length; - }; - PlayerSet.prototype.update = function (allPlayersData) { - var freshPlayerData, - existingPlayer, - i; +/***/ }), +/* 8 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - for (i = 0; i < allPlayersData.length; i++) { - freshPlayerData = allPlayersData[i]; - existingPlayer = this._players[freshPlayerData.id]; - if (existingPlayer && existingPlayer.id === this.ego_id) { +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/** + * Representation of a game item, which for the moment is limited to a + * simple Food type. + */ - /* Don't override current player motion timestamp */ - freshPlayerData.motion_timestamp = existingPlayer.motion_timestamp; +class Item { + constructor(id, itemId, maturity, remainingUses) { + this.id = id; + this.itemId = itemId; + this.maturity = maturity; + this.remainingUses = remainingUses; - // Only override position from server if tremble is enabled, - // or if we know the Player's position is out of sync with the server. - // Otherwise, the ego player's motion is constantly jittery. - if (settings.motion_tremble_rate === 0 && existingPlayer.positionInSync) { - freshPlayerData.position = existingPlayer.position; - } else { - console.log("Overriding position from server!"); - } - } - var last_dimness = 1; - if (this._players[freshPlayerData.id] !== undefined) { - last_dimness = this._players[freshPlayerData.id].dimness; - } - this._players[freshPlayerData.id] = new Player(freshPlayerData, last_dimness); - } - }; + // XXX Maybe we can avoid this copy of every shared value + // to every instance, but going with it for now. + Object.assign(this, settings.item_config[this.itemId]); + } - PlayerSet.prototype.startScheduledAutosyncOfEgoPosition = function () { - var self = this; - setInterval(function () { - var ego = self.ego(); - if (ego) { - ego.positionInSync = false; - console.log("Scheduled marking of (" + ego.id + ") as out of sync with server."); - } - }, 5000); - }; + /** + * Calculate a color based on sprite definition and maturity + */ + get color() { + let immature, mature; - PlayerSet.prototype.maxScore = function () { - var id, - maxScore = 0; - for (id in this._players) { - if (this._players[id].score > maxScore) { - maxScore = this._players[id].score; - } - } - return maxScore; - }; - - PlayerSet.prototype.minScore = function () { - var id, - minScore = Infinity; - for (id in this._players) { - if (this._players[id].score < minScore) { - minScore = this._players[id].score; - } - } - return minScore; - }; + if (this.sprite.includes(",")) { + [immature, mature] = this.sprite.split(","); + // For now, assume these are hex colors + } else { + immature = mature = this.sprite; + } - PlayerSet.prototype.each = function (callback) { - var i = 0; - for (var id in this._players) { - if (this._players.hasOwnProperty(id)) { - callback(i, this._players[id]); - i++; - } - } - }; + return rgbOnScale( + hexToRgbPercentages(immature), + hexToRgbPercentages(mature), + this.maturity + ); + } +} +/* harmony export (immutable) */ __webpack_exports__["Item"] = Item; - PlayerSet.prototype.group_scores = function () { - var group_scores = {}; - this.each(function (i, player) { - var color_name = player.color; - var cur_score = group_scores[color_name] || 0; - group_scores[color_name] = cur_score + Math.round(player.score); - }); +/** + * Manages Items that sit on the grid. + * + * Items currently being carried by a Player are not included. + * These are instead held by reference in the Play instances, + * (named `current_item`). + */ +class GridItems { + constructor() { + this._itemsByPosition = new Map(); + this._positionsById = new Map(); + } - var group_order = Object.keys(group_scores).sort(function (a, b) { - return group_scores[a] > group_scores[b] ? -1 : (group_scores[a] < group_scores[b] ? 1 : 0); - }); + add(item, position) { + this._itemsByPosition.set(JSON.stringify(position), item); + this._positionsById.set(item.id, JSON.stringify(position)); + } - return group_order.map(function(color_name) { - return {name: color_name, score: group_scores[color_name]}; - }); - }; + atPosition(position) { + const key = JSON.stringify(position); + return this._itemsByPosition.get(key) || null; + } - PlayerSet.prototype.player_scores = function () { - var player_order = []; + positionOf(item) { + if (this._positionsById.has(item.id)) { + return JSON.parse(this._positionsById.get(item.id)); + } - this.each(function(i, player) { - player_order.push({id: player.id, name: player.name, score:player.score}); - }); + return undefined; + } - player_order = player_order.sort(function (a, b) { - return a.score > b.score ? -1 : (a.score < b.score ? 1 : 0); - }); + remove(position) { + const item = this.atPosition(position); - return player_order; - }; + if (item) { + this._itemsByPosition.delete(JSON.stringify(position)); + this._positionsById.delete(item.id); + } + } - return PlayerSet; -}()); + /** + * Retrieve pairs of positions and Item objects (like Python's dict.items()) + * @returns Map.prototype[@@iterator] of[position, Item] pairs + */ + *entries() { + for (const [itemPosition, currentItem] of this._itemsByPosition.entries()) { + yield [JSON.parse(itemPosition), currentItem]; + } + } +} +/* harmony export (immutable) */ __webpack_exports__["GridItems"] = GridItems; -var GUSocket = (function () { - var makeSocket = function (endpoint, channel, tolerance) { - var ws_scheme = (window.location.protocol === "https:") ? 'wss://' : 'ws://', - app_root = ws_scheme + location.host + '/', - socket; - socket = new ReconnectingWebSocket( - app_root + endpoint + "?channel=" + channel + "&tolerance=" + tolerance - ); - socket.debug = true; +function hexToRgbPercentages(hexColor) { + if (hexColor.startsWith("#")) { + hexColor = hexColor.substring(1); + } - return socket; - }; + // Check if the hex color has a valid length (either 3 or 6 characters) + if (hexColor.length !== 3 && hexColor.length !== 6) { + throw new Error( + "Invalid hex color format. It should be either 3 or 6 characters long." + ); + } - var dispatch = function (self, event) { - var marker = self.broadcastChannel + ':'; - if (event.data.indexOf(marker) !== 0) { - console.log( - "Message was not on channel " + self.broadcastChannel + ". Ignoring."); - return; - } - var msg = JSON.parse(event.data.substring(marker.length)); + // If the hex color is 3 characters long, expand it to 6 characters by + // duplicating each character + if (hexColor.length === 3) { + hexColor = hexColor + .split("") + .map((char) => char + char) + .join(""); + } - var callback = self.callbackMap[msg.type]; - if (typeof callback !== 'undefined') { - callback(msg); - } else { - console.log("Unrecognized message type " + msg.type + ' from backend.'); - } - }; + // Convert the hex color to RGB percentage values + const red = parseInt(hexColor.substring(0, 2), 16) / 255; + const green = parseInt(hexColor.substring(2, 4), 16) / 255; + const blue = parseInt(hexColor.substring(4, 6), 16) / 255; - /* - * Public API - */ - var Socket = function (settings) { - if (!(this instanceof Socket)) { - return new Socket(settings); - } + return [red, green, blue]; +} - var self = this, - isOpen = $.Deferred(), - tolerance = typeof(settings.lagTolerance) !== 'undefined' ? settings.lagTolerance : 0.1; +function rgbOnScale(startColor, endColor, percentage) { + const result = []; + for (let i = 0; i < 3; i++) { + result[i] = endColor[i] + percentage * (startColor[i] - endColor[i]); + } - this.broadcastChannel = settings.broadcast; - this.controlChannel = settings.control; - this.callbackMap = settings.callbackMap; + return result; +} - this.socket = makeSocket( - settings.endpoint, this.broadcastChannel, tolerance); +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { - this.socket.onmessage = function (event) { - dispatch(self, event); - }; - }; +/** + * Identicon.js 2.3.1 + * http://github.com/stewartlord/identicon.js + * + * PNGLib required for PNG output + * http://www.xarg.org/download/pnglib.js + * + * Copyright 2017, Stewart Lord + * Released under the BSD license + * http://www.opensource.org/licenses/bsd-license.php + */ - Socket.prototype.open = function () { - var isOpen = $.Deferred(); +(function() { + var PNGlib; + if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + PNGlib = __webpack_require__(22); + } else { + PNGlib = window.PNGlib; + } - this.socket.onopen = function (event) { - isOpen.resolve(); - }; + var Identicon = function(hash, options){ + if (typeof(hash) !== 'string' || hash.length < 15) { + throw 'A hash of at least 15 characters is required.'; + } - return isOpen; - }; + this.defaults = { + background: [240, 240, 240, 255], + margin: 0.08, + size: 64, + saturation: 0.7, + brightness: 0.5, + format: 'png' + }; - Socket.prototype.send = function (data) { - var msg = JSON.stringify(data), - channel = this.controlChannel; + this.options = typeof(options) === 'object' ? options : this.defaults; - console.log("Sending message to the " + channel + " channel: " + msg); - this.socket.send(channel + ':' + msg); - }; + // backward compatibility with old constructor (hash, size, margin) + if (typeof(arguments[1]) === 'number') { this.options.size = arguments[1]; } + if (arguments[2]) { this.options.margin = arguments[2]; } - Socket.prototype.broadcast = function (data) { - var msg = JSON.stringify(data), - channel = this.broadcastChannel; + this.hash = hash + this.background = this.options.background || this.defaults.background; + this.size = this.options.size || this.defaults.size; + this.format = this.options.format || this.defaults.format; + this.margin = this.options.margin !== undefined ? this.options.margin : this.defaults.margin; - console.log("Broadcasting message to the " + channel + " channel: " + msg); - this.socket.send(channel + ':' + msg); + // foreground defaults to last 7 chars as hue at 70% saturation, 50% brightness + var hue = parseInt(this.hash.substr(-7), 16) / 0xfffffff; + var saturation = this.options.saturation || this.defaults.saturation; + var brightness = this.options.brightness || this.defaults.brightness; + this.foreground = this.options.foreground || this.hsl2rgb(hue, saturation, brightness); }; - return Socket; -}()); - -// ego will be updated on page load -var players = playerSet({'ego_id': undefined}); - -pixels.canvas.style.marginLeft = window.innerWidth * 0.03 / 2 + "px"; -pixels.canvas.style.marginTop = window.innerHeight * 0.04 / 2 + "px"; -document.body.style.transition = "0.3s all"; -document.body.style.background = "#ffffff"; + Identicon.prototype = { + background: null, + foreground: null, + hash: null, + margin: null, + size: null, + format: null, -var startTime = performance.now(); + image: function(){ + return this.isSvg() + ? new Svg(this.size, this.foreground, this.background) + : new PNGlib(this.size, this.size, 256); + }, -pixels.frame(function() { - // Update the background. - var ego = players.ego(), - w = getWindowPosition(), - section = new Section(background, w.left, w.top), - dimness, - rescaling, - x, y; + render: function(){ + var image = this.image(), + size = this.size, + baseMargin = Math.floor(size * this.margin), + cell = Math.floor((size - (baseMargin * 2)) / 5), + margin = Math.floor((size - cell * 5) / 2), + bg = image.color.apply(image, this.background), + fg = image.color.apply(image, this.foreground); - // Animate background for each visible cell - section.map(function(x, y, color) { - var newColor = animateColor(color); - background[coordsToIdx(x, y, settings.columns)] = newColor; - return newColor; - }); + // the first 15 characters of the hash control the pixels (even/odd) + // they are drawn down the middle first, then mirrored outwards + var i, color; + for (i = 0; i < 15; i++) { + color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg; + if (i < 5) { + this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image); + } else if (i < 10) { + this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); + this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); + } else if (i < 15) { + this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); + this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); + } + } - for (const [position, item] of gridItems.entries()) { - if (players.isPlayerAt(position)) { - if (!item.interactive) { - // Non-interactive items get consumed immediately - gridItems.remove(position); - } - } else { - section.plot(position[1], position[0], item.color); - } - } + return image; + }, - // Draw the players: - players.drawToGrid(section); + rectangle: function(x, y, w, h, color, image){ + if (this.isSvg()) { + image.rectangles.push({x: x, y: y, w: w, h: h, color: color}); + } else { + var i, j; + for (i = x; i < x + w; i++) { + for (j = y; j < y + h; j++) { + image.buffer[image.index(i, j)] = color; + } + } + } + }, - // Show info about the item the current player - // is sharing a square with: - if (! _.isUndefined(ego)) { - updateItemInfoWindow(ego, gridItems); - } + // adapted from: https://gist.github.com/aemkei/1325937 + hsl2rgb: function(h, s, b){ + h *= 6; + s = [ + b += s *= b < .5 ? b : 1 - b, + b - h % 1 * s * 2, + b -= s *= 2, + b, + b + h % 1 * s, + b + s + ]; - // Add the Gaussian mask. - var elapsedTime = performance.now() - startTime; - var visibilityNow = clamp( - (settings.visibility * elapsedTime) / (1000 * settings.visibility_ramp_time), - 3, - settings.visibility - ); - if (settings.highlightEgo) { - visibilityNow = Math.min(visibilityNow, 4); - } - var g = gaussian(0, Math.pow(visibilityNow, 2)); - rescaling = 1 / g.pdf(0); + return[ + s[ ~~h % 6 ] * 255, // red + s[ (h|16) % 6 ] * 255, // green + s[ (h|8) % 6 ] * 255 // blue + ]; + }, - if (typeof ego !== "undefined") { - x = ego.position[1]; - y = ego.position[0]; - } else { - x = 1e100; - y = 1e100; - } - section.map(function(i, j, color) { - var newColor; - // Draw walls - if (settings.walls_visible) { - color = wall_map[[i,j]] || color; - } - // Add Blur - players.each(function (i, player) { - dimness = g.pdf(distance(y, x, player.position[0], player.position[1])) * rescaling; - player["dimness"] = dimness; - }); - newColor = color; - if (!isSpectator) { - dimness = g.pdf(distance(x, y, i, j)) * rescaling; - newColor = [ - color[0] * dimness, - color[1] * dimness, - color[2] * dimness - ]; - } - return newColor; - }); - pixels.update(section.data, section.textures); -}); + toString: function(raw){ + // backward compatibility with old toString, default to base64 + if (raw) { + return this.render().getDump(); + } else { + return this.render().getBase64(); + } + }, -function clamp(val, min, max) { - return Math.max(min, Math.min(max, val)); -} + isSvg: function(){ + return this.format.match(/svg/i) + } + }; -function distance(x, y, xx, yy) { - return Math.sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y)); -} + var Svg = function(size, foreground, background){ + this.size = size; + this.foreground = this.color.apply(this, foreground); + this.background = this.color.apply(this, background); + this.rectangles = []; + }; -function arraysEqual(arr1, arr2) { - for (var i = arr1.length; i--; ) { - if (arr1[i] !== arr2[i]) { - return false; - } - } - return true; -} + Svg.prototype = { + size: null, + foreground: null, + background: null, + rectangles: null, -function arraySearch(arr, val) { - for (var i = 0; i < arr.length; i++) { - if (arraysEqual(arr[i], val)) { - return i; - } - } - return false; -} + color: function(r, g, b, a){ + var values = [r, g, b].map(Math.round); + values.push((a >= 0) && (a <= 255) ? a/255 : 1); + return 'rgba(' + values.join(',') + ')'; + }, -function getWindowPosition() { - var ego = players.ego(), - w = { - left: 0, - top: 0, - columns: settings.window_columns, - rows: settings.window_rows - }; + getDump: function(){ + var i, + xml, + rect, + fg = this.foreground, + bg = this.background, + stroke = this.size * 0.005; - if (typeof ego !== 'undefined') { - w.left = clamp( - ego.position[1] - Math.floor(settings.window_columns / 2), - 0, settings.columns - settings.window_columns); - w.top = clamp( - ego.position[0] - Math.floor(settings.window_rows / 2), - 0, settings.rows - settings.window_rows); - } - return w; -} + xml = "<svg xmlns='http://www.w3.org/2000/svg'" + + " width='" + this.size + "' height='" + this.size + "'" + + " style='background-color:" + bg + ";'>" + + "<g style='fill:" + fg + "; stroke:" + fg + "; stroke-width:" + stroke + ";'>"; -function bindGameKeys(socket) { - var directions = ["up", "down", "left", "right"], - repeatDelayMS = 1000 / settings.motion_speed_limit, - lastDirection = null, - repeatIntervalId = null, - highlightEgo = false; + for (i = 0; i < this.rectangles.length; i++) { + rect = this.rectangles[i]; + if (rect.color == bg) continue; + xml += "<rect " + + " x='" + rect.x + "'" + + " y='" + rect.y + "'" + + " width='" + rect.w + "'" + + " height='" + rect.h + "'" + + "/>"; + } + xml += "</g></svg>" - function moveInDir(direction) { - var ego = players.ego(); - if (ego.move(direction) ) { - var msg = { - type: "move", - player_id: ego.id, - move: direction, - timestamp: ego.motion_timestamp - }; - socket.send(msg); - } - } + return xml; + }, - directions.forEach(function(direction) { - Mousetrap.bind( - direction, - function(e) { - e.preventDefault(); - if (direction === lastDirection) { - return; - } - - // New direction may be pressed before previous dir key is released - if (repeatIntervalId) { - clearInterval(repeatIntervalId); - } - - moveInDir(direction); // Move once immediately so there's no lag - lastDirection = direction; - repeatIntervalId = setInterval(moveInDir, repeatDelayMS, direction); - }, - 'keydown' - ); - - Mousetrap.bind( - direction, - function(e) { - e.preventDefault(); - if (direction) { - clearInterval(repeatIntervalId); - lastDirection = null; + getBase64: function(){ + return btoa(this.getDump()); } - }, - "keyup" - ); - - }); - - Mousetrap.bind("space", function () { - var msg_type; - var ego = players.ego(); - var position = ego.position; - var item_at_pos = gridItems.atPosition(position); - var player_item = ego.current_item; - var transition = ego.getTransition(); - if (!item_at_pos && !player_item) { - // If there's nothing here, we try to plant food GU 1.0 style - msg_type = "plant_food"; - } else if (transition) { - // Check for a transition between objects. For now we don't do anything - // client-side other checking that it exists. We could optimize display - // updates later - msg_type = "item_transition"; - transitionsSeen.add(transition.id); - } else if (player_item && player_item.calories) { - // If there's nothing here to transition with and we're holding something - // edible, consume it. - msg_type = "item_consume"; - player_item.remainingUses = player_item.remainingUses - 1; - if (player_item.remainingUses < 1) { - ego.replaceItem(null); - } - } else if (!player_item && item_at_pos && item_at_pos.portable) { - // If there's a portable item here and we don't something in hand, pick it up. - msg_type = "item_pick_up"; - gridItems.remove(position); - ego.replaceItem(item_at_pos); - } - if (!msg_type) { - return; - } - var msg = { - type: msg_type, - player_id: ego.id, - position: position }; - socket.send(msg); - }); - Mousetrap.bind("d", function () { - var ego = players.ego(); - var position = ego.position; - var current_item = ego.current_item; - if (!current_item || gridItems.atPosition(position)) { - return; + if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + module.exports = Identicon; + } else { + window.Identicon = Identicon; } - var msg = { - type: "item_drop", - player_id: ego.id, - position: position - }; - socket.send(msg); - ego.replaceItem(null); - gridItems.add(current_item, position); - }); - - if (settings.mutable_colors) { - Mousetrap.bind('c', function () { - var keys = settings.player_color_names, - index = arraySearch(keys, players.ego().color), - nextItem = keys[(index + 1) % keys.length], - msg; - - players.ego().color = nextItem; - msg = { - type: "change_color", - player_id: players.ego().id, - color: players.ego().color - }; - socket.send(msg); - }); - } +})(); - if (settings.identity_signaling) { - Mousetrap.bind("v", function () { - var ego = players.ego(), - msg; +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { - ego.identity_visible = !ego.identity_visible; - msg = { - type: "toggle_visible", - player_id: ego.id, - identity_visible: ego.identity_visible - }; - socket.send(msg); - }); - } +"use strict"; - if (settings.build_walls) { - Mousetrap.bind("w", function () { - var msg = { - type: "build_wall", - player_id: players.ego().id, - position: players.ego().position - }; - socket.send(msg); - }); - } - Mousetrap.bind("h", function () { - settings.highlightEgo = !settings.highlightEgo; - }); -} +var colorString = __webpack_require__(28); +var convert = __webpack_require__(25); -function chatName(player_id) { - var ego = players.ego(), - entry = "<span class='name'>", - id = parseInt(player_id) - 1, - salt = $("#grid").data("identicon-salt"), - fg = settings.player_colors[name2idx(players.get(player_id).color)].concat(1), - bg, - identicon, - name, - options; +var _slice = [].slice; - if (id === ego) { - name = "You"; - } else if (settings.pseudonyms) { - name = players.get(player_id).name; - } else if (player_id % 1 === 0) { - name = "Player " + player_id; - } else { - // Non-integer player_id - return '<span class="name">' + player_id + '</span>'; - } +var skippedModels = [ + // to be honest, I don't really feel like keyword belongs in color convert, but eh. + 'keyword', - fg = fg.map(function(x) { return x * 255; }); - bg = fg.map(function(x) { return (x * 0.66); }); - bg[3] = 255; - options = { - size: 10, - foreground: fg, - background: bg, - format: 'svg' - }; + // gray conflicts with some method names, and has its own method defined. + 'gray', - identicon = new Identicon(md5(salt + id), options).toString(); - if (settings.use_identicons) { - entry = entry + " <img src='data:image/svg+xml;base64," + identicon + "' />"; - } - entry = entry + " " + name + "</span> "; - return entry; -} + // shouldn't really be in color-convert either... + 'hex' +]; -function onChatMessage(msg) { - var entry = chatName(msg.player_id); - if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) { - return; - } - $("#messages").append(($("<li>").text(": " + msg.contents)).prepend(entry)); - $("#chatlog").scrollTop($("#chatlog")[0].scrollHeight); -} +var hashedModelKeys = {}; +Object.keys(convert).forEach(function (model) { + hashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model; +}); -function onColorChanged(msg) { - store.set("color", msg.new_color); - if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) { - return; - } - pushMessage("<span class='name'>Moderator:</span> " + chatName(msg.player_id) + ' changed from team ' + msg.old_color + ' to team ' + msg.new_color + '.'); -} +var limiters = {}; -function onMoveRejected(msg) { - var offendingPlayerId = msg.player_id, - ego = players.ego(); +function Color(obj, model) { + if (!(this instanceof Color)) { + return new Color(obj, model); + } - if (ego && offendingPlayerId === ego.id) { - ego.positionInSync = false; - console.log("Marking your player (" + ego.id + ") as out of sync with server. Should sync on next state update"); - } -} + if (model && model in skippedModels) { + model = null; + } -function onDonationProcessed(msg) { - var donor = players.get(msg.donor_id), - recipient_id = msg.recipient_id, - team_idx, - donor_name, - recipient_name, - donated_points, - received_points, - entry; + if (model && !(model in convert)) { + throw new Error('Unknown model: ' + model); + } - donor_name = chatName(msg.donor_id); + var i; + var channels; - if (recipient_id === 'all') { - recipient_name = '<span class="name">All players</span>'; - } else if (recipient_id.indexOf('group:') === 0) { - team_idx = +recipient_id.substring(6); - recipient_name = 'Everyone in <span class="name">' + settings.player_color_names[team_idx] + '</span>'; - } else { - recipient_name = chatName(recipient_id); - } + if (obj == null) { // eslint-disable-line no-eq-null,eqeqeq + this.model = 'rgb'; + this.color = [0, 0, 0]; + this.valpha = 1; + } else if (obj instanceof Color) { + this.model = obj.model; + this.color = obj.color.slice(); + this.valpha = obj.valpha; + } else if (typeof obj === 'string') { + var result = colorString.get(obj); + if (result === null) { + throw new Error('Unable to parse color from string: ' + obj); + } - if (msg.amount === 1) { - donated_points = msg.amount + ' point.'; - } else { - donated_points = msg.amount + ' points.'; - } + this.model = result.model; + channels = convert[this.model].channels; + this.color = result.value.slice(0, channels); + this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1; + } else if (obj.length) { + this.model = model || 'rgb'; + channels = convert[this.model].channels; + var newArr = _slice.call(obj, 0, channels); + this.color = zeroArray(newArr, channels); + this.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1; + } else if (typeof obj === 'number') { + // this is always RGB - can be converted later on. + obj &= 0xFFFFFF; + this.model = 'rgb'; + this.color = [ + (obj >> 16) & 0xFF, + (obj >> 8) & 0xFF, + obj & 0xFF + ]; + this.valpha = 1; + } else { + this.valpha = 1; - if (msg.received === 1) { - received_points = msg.received + ' point.'; - } else { - received_points = msg.received + ' points.'; - } + var keys = Object.keys(obj); + if ('alpha' in obj) { + keys.splice(keys.indexOf('alpha'), 1); + this.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0; + } - entry = donor_name + " contributed " + donated_points + " " + recipient_name + " received " + received_points; + var hashedKeys = keys.sort().join(''); + if (!(hashedKeys in hashedModelKeys)) { + throw new Error('Unable to parse color from object: ' + JSON.stringify(obj)); + } - $("#messages").append($("<li>").html(entry)); - $("#chatlog").scrollTop($("#chatlog")[0].scrollHeight); - $('#individual-donate, #group-donate').addClass('button-outline'); - $('#donate label').text($('#donate label').data('orig-text')); - settings.donation_type = null; -} + this.model = hashedModelKeys[hashedKeys]; -function updateDonationStatus(donation_is_active) { - // If alternating donation/consumption rounds, announce round type - if (settings.alternate_consumption_donation && (settings.donation_active !== donation_is_active)) { - if (donation_is_active) { - pushMessage("<span class='name'>Moderator:</span> Starting a donation round. Players cannot move, only donate."); - } else { - pushMessage("<span class='name'>Moderator:</span> Starting a consumption round. Players have to consume as much food as possible."); - } - } - // Update donation status - settings.donation_active = donation_is_active; -} + var labels = convert[this.model].labels; + var color = []; + for (i = 0; i < labels.length; i++) { + color.push(obj[labels[i]]); + } + this.color = zeroArray(color); + } -function renderTransition(transition) { - if (! transition) { - return ""; - } - const states = [ - transition.transition.actor_start, - transition.transition.actor_end, - transition.transition.target_start, - transition.transition.target_end - ]; + // perform limitations (clamping, etc.) + if (limiters[this.model]) { + channels = convert[this.model].channels; + for (i = 0; i < channels; i++) { + var limit = limiters[this.model][i]; + if (limit) { + this.color[i] = limit(this.color[i]); + } + } + } - const [aStartItem, aEndItem, tStartItem, tEndItem] = states.map( - (state) => settings.item_config[state] - ); + this.valpha = Math.max(0, Math.min(1, this.valpha)); - return `✋${aStartItem.name} + ${tStartItem.name} → ✋${aEndItem.name} + ${tEndItem.name}`; + if (Object.freeze) { + Object.freeze(this); + } } -/** - * If the current player is sharing a grid position with an interactive - * item, we show information about it on the page. - * - * @param {Player} egoPlayer the current Player - * @param {itemlib.GridItems} gridItems the collection of all Items on the grid - */ -function updateItemInfoWindow(egoPlayer, gridItems) { - const inspectedItem = gridItems.atPosition(egoPlayer.position), - transition = egoPlayer.getTransition(), - $square = $("#location-contents-item"), - $transition = $("#transition-details"); - - if (! inspectedItem) { - $square.empty(); - } else { - $square.html(inspectedItem.name); - } - if (! transition) { - $transition.empty(); - } else { - $transition.html(renderTransition(transition)); - } -} +Color.prototype = { + toString: function () { + return this.string(); + }, -function displayWhatEgoPlayerIsCarrying(item) { - $('#inventory-item').text(item ? item.name : ''); -} + toJSON: function () { + return this[this.model](); + }, -function onGameStateChange(msg) { - var $donationButtons = $('#individual-donate, #group-donate, #public-donate, #ingroup-donate'), - $timeElement = $("#time"), - $loading = $('.grid-loading'), - cur_wall, - ego, - state, - j, - k; + string: function (places) { + var self = this.model in colorString.to ? this : this.rgb(); + self = self.round(typeof places === 'number' ? places : 1); + var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha); + return colorString.to[self.model](args); + }, - performance.mark('state_start'); - if ($loading.is(':visible')) $loading.fadeOut(); + percentString: function (places) { + var self = this.rgb().round(typeof places === 'number' ? places : 1); + var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha); + return colorString.to.rgb.percent(args); + }, - if (settings.paused_game) { - $timeElement.html(0); - return; - } + array: function () { + return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha); + }, - // Update remaining time. - $timeElement.html(Math.max(Math.round(msg.remaining_time), 0)); + object: function () { + var result = {}; + var channels = convert[this.model].channels; + var labels = convert[this.model].labels; - // Update round. - if (settings.num_rounds > 1) { - $("#round").html(msg.round + 1); - } + for (var i = 0; i < channels; i++) { + result[labels[i]] = this.color[i]; + } - // Update players. - state = JSON.parse(msg.grid); - players.update(state.players); - ego = players.ego(); + if (this.valpha !== 1) { + result.alpha = this.valpha; + } - updateDonationStatus(state.donation_active); + return result; + }, - // Update gridItems - if (state.items !== undefined && state.items !== null) { - gridItems = new itemlib.GridItems(); - for (j = 0; j < state.items.length; j++) { + unitArray: function () { + var rgb = this.rgb().color; + rgb[0] /= 255; + rgb[1] /= 255; + rgb[2] /= 255; - gridItems.add( - new itemlib.Item( - state.items[j].id, - state.items[j].item_id, - state.items[j].maturity, - state.items[j].remaining_uses, - ), - state.items[j].position - ); - } - } - // Update walls if they haven't been created yet. - if (state.walls !== undefined && walls.length === 0) { - for (k = 0; k < state.walls.length; k++) { - cur_wall = state.walls[k]; - if (cur_wall instanceof Array) { - cur_wall = { - position: cur_wall, - color: [0.5, 0.5, 0.5] - }; - } - walls.push( - new Wall({ - position: cur_wall.position, - color: cur_wall.color - }) - ); - wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color; - } - } + if (this.valpha !== 1) { + rgb.push(this.valpha); + } - // If new walls have been added, draw them - if (state.walls !== undefined && walls.length < state.walls.length) { - for (k = walls.length; k < state.walls.length; k++) { - cur_wall = state.walls[k]; - walls.push( - new Wall({ - position: cur_wall.position, - color: cur_wall.color - }) - ); - wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color; - } - } + return rgb; + }, - // Update displayed score, set donation info. - if (ego !== undefined) { - $("#score").html(Math.round(ego.score)); - $("#dollars").html(ego.payoff.toFixed(2)); - window.state = msg.grid; - window.ego = ego.id; - if (settings.donation_active && - ego.score >= settings.donation_amount && - players.count() > 1 - ) { - $donationButtons.prop('disabled', false); - } else { - $('#donation-instructions').text(''); - $donationButtons.prop('disabled', true); - } - } -} + unitObject: function () { + var rgb = this.rgb().object(); + rgb.r /= 255; + rgb.g /= 255; + rgb.b /= 255; -function addWall(msg) { - var wall = msg.wall; - if (wall) { - walls.push( - new Wall({ - position: wall.position, - color: wall.color - }) - ); - wall_map[[wall.position[1], wall.position[0]]] = wall.color; - } -} + if (this.valpha !== 1) { + rgb.alpha = this.valpha; + } -function pushMessage(html) { - $("#messages").append(($("<li>").html(html))); - $("#chatlog").scrollTop($("#chatlog")[0].scrollHeight); -} + return rgb; + }, -function displayLeaderboards(msg, callback) { - if (!settings.leaderboard_group && !settings.leaderboard_individual) { - if (callback) { - callback(); - } - return; - } - var i; - if (msg.type === 'new_round') { - pushMessage("<span class='name'>Moderator:</span> the round " + msg.round + ' standings are…'); - } else { - pushMessage("<span class='name'>Moderator:</span> the final standings are …"); - } - if (settings.leaderboard_group) { - if (settings.leaderboard_individual) { - pushMessage('<em>Group</em>'); - } - var group_scores = players.group_scores(); - var rgb_map = function (e) { return Math.round(e * 255); }; - for (i = 0; i < group_scores.length; i++) { - var group = group_scores[i]; - var color = settings.player_colors[name2idx(group.name)].map(rgb_map); - pushMessage('<span class="GroupScore">' + group.score + '</span><span class="GroupIndicator" style="background-color:' + Color.rgb(color).string() +';"></span>'); - } - } - if (settings.leaderboard_individual) { - if (settings.leaderboard_group) { - pushMessage('<em>Individual</em>'); - } - var player_scores = players.player_scores(); - var ego_id = players.ego_id; - for (i = 0; i < player_scores.length; i++) { - var player = player_scores[i]; - var player_name = chatName(player.id); - pushMessage('<span class="PlayerScore">' + Math.round(player.score) + '</span><span class="PlayerName">' + player_name + '</span>'); - } - } - if (settings.leaderboard_time) { - settings.paused_game = true; - setTimeout(function () { - settings.paused_game = false; - if (callback) { - callback(); - } - }, 1000 * settings.leaderboard_time); - } else if (callback) { - callback(); - } -} + round: function (places) { + places = Math.max(places || 0, 0); + return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model); + }, -function gameOverHandler(player_id) { - var callback; - if (!isSpectator) { - callback = function () { - $("#dashboard").hide(); - $("#instructions").hide(); - $("#chat").hide(); - if (player_id) { - window.location.href = "/questionnaire?participant_id=" + player_id; - } - }; - pixels.canvas.style.display = "none"; - } - return function (msg) { - $("#game-over").show(); - return displayLeaderboards(msg, callback); - }; -} + alpha: function (val) { + if (arguments.length) { + return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model); + } -$(document).ready(function() { - var player_id = dallinger.getUrlParameter('participant_id'); - isSpectator = typeof player_id === 'undefined'; - var socketSettings = { - 'endpoint': 'chat', - 'broadcast': CHANNEL, - 'control': CONTROL_CHANNEL, - 'lagTolerance': 0.001, - 'callbackMap': { - 'chat': onChatMessage, - 'donation_processed': onDonationProcessed, - 'color_changed': onColorChanged, - 'state': onGameStateChange, - 'new_round': displayLeaderboards, - 'stop': gameOverHandler(player_id), - 'wall_built': addWall, - 'move_rejection': onMoveRejected - } - }; - var socket = new GUSocket(socketSettings); + return this.valpha; + }, - socket.open().done(function () { - var data = { - type: 'connect', - player_id: isSpectator ? 'spectator' : player_id - }; - socket.send(data); - }); + // rgb + red: getset('rgb', 0, maxfn(255)), + green: getset('rgb', 1, maxfn(255)), + blue: getset('rgb', 2, maxfn(255)), - players.ego_id = player_id; - players.startScheduledAutosyncOfEgoPosition(); - $('#donate label').data('orig-text', $('#donate label').text()); + hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style - setInterval(function () { - var delays = [], - start_marks = performance.getEntriesByName('state_start', 'mark'); - for (var i = 0; i < start_marks.length; i++) { - if (start_marks.length > i + 2) { - delays.push(start_marks[i+1].startTime - start_marks[i].startTime); - } - } - if (delays.length) { - var average_delay = delays.reduce(function(sum, value){ - return sum + value; - }, 0) / delays.length; - console.log('Average delay between state updates: ' + average_delay + 'ms.'); - } - }, 5000); + saturationl: getset('hsl', 1, maxfn(100)), + lightness: getset('hsl', 2, maxfn(100)), - // Append the canvas. - $("#grid").append(pixels.canvas); + saturationv: getset('hsv', 1, maxfn(100)), + value: getset('hsv', 2, maxfn(100)), - // Opt out of the experiment. - $("#opt-out").click(function() { - window.location.href = "/questionnaire?participant_id=" + player_id; - }); + chroma: getset('hcg', 1, maxfn(100)), + gray: getset('hcg', 2, maxfn(100)), - if (isSpectator) { - $(".for-players").hide(); - } + white: getset('hwb', 1, maxfn(100)), + wblack: getset('hwb', 2, maxfn(100)), - // Consent to the experiment. - $("#go-to-experiment").click(function() { - window.location.href = "/exp"; - }); + cyan: getset('cmyk', 0, maxfn(100)), + magenta: getset('cmyk', 1, maxfn(100)), + yellow: getset('cmyk', 2, maxfn(100)), + black: getset('cmyk', 3, maxfn(100)), - // Submit the questionnaire. - $("#submit-questionnaire").click(function() { - dallinger.submitResponses(); - }); + x: getset('xyz', 0, maxfn(100)), + y: getset('xyz', 1, maxfn(100)), + z: getset('xyz', 2, maxfn(100)), - if (settings.show_grid) { - pixels.canvas.style.display = "inline"; - } + l: getset('lab', 0, maxfn(100)), + a: getset('lab', 1), + b: getset('lab', 2), - if (settings.show_chatroom) { - $("#chat form").show(); - } + keyword: function (val) { + if (arguments.length) { + return new Color(val); + } - var donateToClicked = function() { - var w = getWindowPosition(), - row = w.top + pixels2cells(mouse[1]), - column = w.left + pixels2cells(mouse[0]), - recipient = players.nearest(row, column), - donor = players.ego(), - amt = settings.donation_amount, - recipient_id, - msg; + return convert[this.model].keyword(this.color); + }, - if (!settings.donation_active) { - return; - } + hex: function (val) { + if (arguments.length) { + return new Color(val); + } - if (amt > donor.score) { - return; - } + return colorString.to.hex(this.rgb().round().color); + }, - if (settings.donation_type === 'individual') { - recipient_id = recipient.id; - } else if (settings.donation_type === 'group') { - recipient_id = 'group:' + name2idx(recipient.color).toString(); - } else { - return; - } + rgbNumber: function () { + var rgb = this.rgb().color; + return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF); + }, - if (recipient_id !== donor.id) { - msg = { - type: "donation_submitted", - recipient_id: recipient_id, - donor_id: donor.id, - amount: amt - }; - socket.send(msg); - } - }; + luminosity: function () { + // http://www.w3.org/TR/WCAG20/#relativeluminancedef + var rgb = this.rgb().color; - var donateToAll = function() { - var donor = players.ego(), - amt = settings.donation_amount, - msg; + var lum = []; + for (var i = 0; i < rgb.length; i++) { + var chan = rgb[i] / 255; + lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4); + } - msg = { - type: "donation_submitted", - recipient_id: 'all', - donor_id: donor.id, - amount: amt - }; - socket.send(msg); - }; + return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2]; + }, - var donateToInGroup = function () { - var donor = players.ego(), - amt = settings.donation_amount, - recipientId = 'group:' + name2idx(donor.color).toString(), - msg; + contrast: function (color2) { + // http://www.w3.org/TR/WCAG20/#contrast-ratiodef + var lum1 = this.luminosity(); + var lum2 = color2.luminosity(); - msg = { - type: "donation_submitted", - recipient_id: recipientId, - donor_id: donor.id, - amount: amt - }; - socket.send(msg); - }; + if (lum1 > lum2) { + return (lum1 + 0.05) / (lum2 + 0.05); + } - var pixels2cells = function(pix) { - return Math.floor(pix / (settings.block_size + settings.padding)); - }; + return (lum2 + 0.05) / (lum1 + 0.05); + }, - $("form").submit(function() { - var chatmessage = $("#message").val().trim(), - msg; + level: function (color2) { + var contrastRatio = this.contrast(color2); + if (contrastRatio >= 7.1) { + return 'AAA'; + } - if (! chatmessage) { - return false; - } + return (contrastRatio >= 4.5) ? 'AA' : ''; + }, - try { - msg = { - type: 'chat', - contents: chatmessage, - player_id: players.ego().id, - timestamp: performance.now() - start, - broadcast: true - }; - // send directly to all clients - socket.broadcast(msg); - // Also send to the server for logging - socket.send(msg); - } catch(err) { - console.error(err); - } finally { - $("#message").val(""); - return false; - } - }); + isDark: function () { + // YIQ equation from http://24ways.org/2010/calculating-color-contrast + var rgb = this.rgb().color; + var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000; + return yiq < 128; + }, - if (!isSpectator) { - // Main game keys: - bindGameKeys(socket); - // Donation click events: - $(pixels.canvas).click(function (e) { - donateToClicked(); - }); - $('#public-donate').click(donateToAll); - $('#ingroup-donate').click(donateToInGroup); - $('#group-donate').click(function () { - if (settings.donation_group) { - $('#donate label').text('Click on a color'); - settings.donation_type = 'group'; - $(this).prop('disabled', false); - $(this).removeClass('button-outline'); - $('#individual-donate').addClass('button-outline'); - } - }); - $('#individual-donate').click(function () { - if (settings.donation_individual) { - $('#donate label').text('Click on a player'); - settings.donation_type = 'individual'; - $(this).removeClass('button-outline'); - $('#group-donate').addClass('button-outline'); - } - }); - } + isLight: function () { + return !this.isDark(); + }, -}); + negate: function () { + var rgb = this.rgb(); + for (var i = 0; i < 3; i++) { + rgb.color[i] = 255 - rgb.color[i]; + } + return rgb; + }, -}(dallinger, require, window.settings)); + lighten: function (ratio) { + var hsl = this.hsl(); + hsl.color[2] += hsl.color[2] * ratio; + return hsl; + }, + darken: function (ratio) { + var hsl = this.hsl(); + hsl.color[2] -= hsl.color[2] * ratio; + return hsl; + }, -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { + saturate: function (ratio) { + var hsl = this.hsl(); + hsl.color[1] += hsl.color[1] * ratio; + return hsl; + }, -var parse = __webpack_require__(1); -var isnumber = __webpack_require__(2); -var isstring = __webpack_require__(3); -var isarray = __webpack_require__(4); -var convert = __webpack_require__(14); -var layout = __webpack_require__(18); -var texcoord = __webpack_require__(19); -var range = __webpack_require__(20); -var pixdenticon = __webpack_require__(21); -var md5 = __webpack_require__(5); + desaturate: function (ratio) { + var hsl = this.hsl(); + hsl.color[1] -= hsl.color[1] * ratio; + return hsl; + }, -function Pixels(data, textures, opts) { - if (!(this instanceof Pixels)) return new Pixels(data, textures, opts); - var self = this; - opts = opts || {}; - this.opts = opts; - var num_identicons = 100; + whiten: function (ratio) { + var hwb = this.hwb(); + hwb.color[1] += hwb.color[1] * ratio; + return hwb; + }, - opts.background = opts.background || [ 0.5, 0.5, 0.5 ]; - opts.size = isnumber(opts.size) ? opts.size : 10; - opts.padding = isnumber(opts.padding) ? opts.padding : 2; + blacken: function (ratio) { + var hwb = this.hwb(); + hwb.color[2] += hwb.color[2] * ratio; + return hwb; + }, - if (isstring(opts.background)) - opts.background = parse(opts.background).rgb.map(function(c) { - return c / 255; - }); + grayscale: function () { + // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale + var rgb = this.rgb().color; + var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11; + return Color.rgb(val, val, val); + }, - if (isarray(data[0]) && data[0].length !== 3) { - opts.rows = data.length; - opts.columns = data[0].length; - } + fade: function (ratio) { + return this.alpha(this.valpha - (this.valpha * ratio)); + }, - if (!opts.rows || !opts.columns) { - opts.rows = opts.columns = Math.round(Math.sqrt(data.length)); - } + opaquer: function (ratio) { + return this.alpha(this.valpha + (this.valpha * ratio)); + }, - var width = opts.columns * opts.size + (opts.columns + 1) * opts.padding; - var height = opts.rows * opts.size + (opts.rows + 1) * opts.padding; + rotate: function (degrees) { + var hsl = this.hsl(); + var hue = hsl.color[0]; + hue = (hue + degrees) % 360; + hue = hue < 0 ? 360 + hue : hue; + hsl.color[0] = hue; + return hsl; + }, - var canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - if (opts.root) opts.root.appendChild(canvas); + mix: function (mixinColor, weight) { + // ported from sass implementation in C + // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209 + if (!mixinColor || !mixinColor.rgb) { + throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor); + } + var color1 = mixinColor.rgb(); + var color2 = this.rgb(); + var p = weight === undefined ? 0.5 : weight; - var colors = opts.formatted ? data : convert(data); - var texcoords = texcoord( - opts.rows, - opts.columns, - textures, - num_identicons - ); + var w = 2 * p - 1; + var a = color1.alpha() - color2.alpha(); - var positions = layout( - opts.rows, - opts.columns, - 2 * opts.padding / width, - 2 * opts.size / width, - width / height - ); + var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; + var w2 = 1 - w1; - var regl = __webpack_require__(22)(canvas); + return Color.rgb( + w1 * color1.red() + w2 * color2.red(), + w1 * color1.green() + w2 * color2.green(), + w1 * color1.blue() + w2 * color2.blue(), + color1.alpha() * p + color2.alpha() * (1 - p)); + } +}; - var initial_texture = []; - for (row = 0; row < opts.size; row++) { - rowdata = [] - for (col = 0; col < opts.size; col++) { - rowdata.push([255, 255, 255]); - } - initial_texture.push(rowdata); - } - var salt = $("#grid").data("identicon-salt"); - for (var i = 0; i < num_identicons; i++) { - texture = new pixdenticon(md5(salt + i), opts.size).render().buffer; - for (row = 0; row < opts.size; row++) { - initial_texture.push(texture[row]); - } - } +// model conversion methods and static constructors +Object.keys(convert).forEach(function (model) { + if (skippedModels.indexOf(model) !== -1) { + return; + } - var texture = regl.texture(initial_texture); + var channels = convert[model].channels; - var squares = regl({ - vert: ` - precision mediump float; - attribute vec2 position; - attribute vec2 texcoords; - attribute vec3 color; - varying vec3 vcolor; - varying vec2 v_texcoords; - void main() { - gl_PointSize = float(${opts.size}); - gl_Position = vec4(position.x, position.y, 0.0, 1.0); - v_texcoords = texcoords; - vcolor = color; - } - `, - frag: ` - precision mediump float; - varying vec3 vcolor; - varying vec2 v_texcoords; - uniform sampler2D vtexture; - void main() { - vec4 texture; - texture = texture2D(vtexture, v_texcoords); - gl_FragColor = texture * vec4(vcolor.r, vcolor.g, vcolor.b, 1.0); - } - `, - attributes: { position: regl.prop("position"), texcoords: regl.prop("texcoords"), color: regl.prop("color")}, - primitive: "triangles", - count: colors.length * 6, - uniforms: { vtexture: texture } - }); + // conversion methods + Color.prototype[model] = function () { + if (this.model === model) { + return new Color(this); + } - var expanded_colors = []; - for(var i = 0; i < colors.length; ++i){ - for(var n = 0; n < 6; ++n) { - expanded_colors.push(colors[i]); - } - } + if (arguments.length) { + return new Color(arguments, model); + } - var buffer = { position: regl.buffer(positions), texcoords: regl.buffer(texcoords), color: regl.buffer(expanded_colors)}; + var newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha; + return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model); + }; - var draw = function(positions, texcoords, colors) { - regl.clear({ color: opts.background.concat([ 1 ]) }); - squares({ position: positions, texcoords: texcoords, color: colors }); - }; + // 'static' construction methods + Color[model] = function (color) { + if (typeof color === 'number') { + color = zeroArray(_slice.call(arguments), channels); + } + return new Color(color, model); + }; +}); - draw(buffer.position, buffer.texcoords, buffer.color); +function roundTo(num, places) { + return Number(num.toFixed(places)); +} - self._buffer = buffer; - self._draw = draw; - self._formatted = opts.formatted; - self.canvas = canvas; - self.frame = regl.frame; +function roundToPlace(places) { + return function (num) { + return roundTo(num, places); + }; } -Pixels.prototype.update = function(data, textures) { - var self = this; - var colors = self._formatted ? data : convert(data); - var expanded_colors = []; +function getset(model, channel, modifier) { + model = Array.isArray(model) ? model : [model]; - for(var i = 0; i < colors.length; ++i){ - for(var n = 0; n < 6; ++n) { - expanded_colors.push(colors[i]); - } - } + model.forEach(function (m) { + (limiters[m] || (limiters[m] = []))[channel] = modifier; + }); - var opts = this.opts; - var num_identicons = 100; + model = model[0]; - var texcoords = texcoord( - opts.rows, - opts.columns, - textures, - num_identicons - ); + return function (val) { + var result; - self._draw(self._buffer.position, self._buffer.texcoords(texcoords), self._buffer.color(expanded_colors)); -}; + if (arguments.length) { + if (modifier) { + val = modifier(val); + } -module.exports = Pixels; + result = this[model](); + result.color[channel] = val; + return result; + } + result = this[model]().color[channel]; + if (modifier) { + result = modifier(result); + } -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { + return result; + }; +} -var conversions = __webpack_require__(11); +function maxfn(max) { + return function (v) { + return Math.max(0, Math.min(max, v)); + }; +} -var convert = function() { - return new Converter(); +function assertArray(val) { + return Array.isArray(val) ? val : [val]; } -for (var func in conversions) { - // export Raw versions - convert[func + "Raw"] = (function(func) { - // accept array or plain args - return function(arg) { - if (typeof arg == "number") - arg = Array.prototype.slice.call(arguments); - return conversions[func](arg); - } - })(func); +function zeroArray(arr, length) { + for (var i = 0; i < length; i++) { + if (typeof arr[i] !== 'number') { + arr[i] = 0; + } + } - var pair = /(\w+)2(\w+)/.exec(func), - from = pair[1], - to = pair[2]; + return arr; +} - // export rgb2hsl and ["rgb"]["hsl"] - convert[from] = convert[from] || {}; +module.exports = Color; - convert[from][to] = convert[func] = (function(func) { - return function(arg) { - if (typeof arg == "number") - arg = Array.prototype.slice.call(arguments); - - var val = conversions[func](arg); - if (typeof val == "string" || val === undefined) - return val; // keyword - for (var i = 0; i < val.length; i++) - val[i] = Math.round(val[i]); - return val; - } - })(func); -} +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { +(function(exports) { -/* Converter does lazy conversion and caching */ -var Converter = function() { - this.convs = {}; -}; + const generateGaussian = __webpack_require__(30); -/* Either get the values for a space or - set the values for a space, depending on args */ -Converter.prototype.routeSpace = function(space, args) { - var values = args[0]; - if (values === undefined) { - // color.rgb() - return this.getValues(space); - } - // color.rgb(10, 10, 10) - if (typeof values == "number") { - values = Array.prototype.slice.call(args); - } + // Complementary error function + // From Numerical Recipes in C 2e p221 + var erfc = function(x) { + var z = Math.abs(x); + var t = 1 / (1 + z / 2); + var r = t * Math.exp(-z * z - 1.26551223 + t * (1.00002368 + + t * (0.37409196 + t * (0.09678418 + t * (-0.18628806 + + t * (0.27886807 + t * (-1.13520398 + t * (1.48851587 + + t * (-0.82215223 + t * 0.17087277))))))))) + return x >= 0 ? r : 2 - r; + }; - return this.setValues(space, values); -}; - -/* Set the values for a space, invalidating cache */ -Converter.prototype.setValues = function(space, values) { - this.space = space; - this.convs = {}; - this.convs[space] = values; - return this; -}; + // Inverse complementary error function + // From Numerical Recipes 3e p265 + var ierfc = function(x) { + if (x >= 2) { return -100; } + if (x <= 0) { return 100; } -/* Get the values for a space. If there's already - a conversion for the space, fetch it, otherwise - compute it */ -Converter.prototype.getValues = function(space) { - var vals = this.convs[space]; - if (!vals) { - var fspace = this.space, - from = this.convs[fspace]; - vals = convert[fspace][space](from); + var xx = (x < 1) ? x : 2 - x; + var t = Math.sqrt(-2 * Math.log(xx / 2)); - this.convs[space] = vals; - } - return vals; -}; + var r = -0.70711 * ((2.30753 + t * 0.27061) / + (1 + t * (0.99229 + t * 0.04481)) - t); -["rgb", "hsl", "hsv", "cmyk", "keyword"].forEach(function(space) { - Converter.prototype[space] = function(vals) { - return this.routeSpace(space, arguments); - } -}); + for (var j = 0; j < 2; j++) { + var err = erfc(r) - xx; + r += err / (1.12837916709551257 * Math.exp(-(r * r)) - r * err); + } -module.exports = convert; + return (x < 1) ? r : -r; + }; -/***/ }), -/* 11 */ -/***/ (function(module, exports) { + // Models the normal distribution + var Gaussian = function(mean, variance) { + if (variance <= 0) { + throw new Error('Variance must be > 0 (but was ' + variance + ')'); + } + this.mean = mean; + this.variance = variance; + this.standardDeviation = Math.sqrt(variance); + } -/* MIT license */ + // Probability density function + Gaussian.prototype.pdf = function(x) { + var m = this.standardDeviation * Math.sqrt(2 * Math.PI); + var e = Math.exp(-Math.pow(x - this.mean, 2) / (2 * this.variance)); + return e / m; + }; -module.exports = { - rgb2hsl: rgb2hsl, - rgb2hsv: rgb2hsv, - rgb2hwb: rgb2hwb, - rgb2cmyk: rgb2cmyk, - rgb2keyword: rgb2keyword, - rgb2xyz: rgb2xyz, - rgb2lab: rgb2lab, - rgb2lch: rgb2lch, + // Cumulative density function + Gaussian.prototype.cdf = function(x) { + return 0.5 * erfc(-(x - this.mean) / (this.standardDeviation * Math.sqrt(2))); + }; - hsl2rgb: hsl2rgb, - hsl2hsv: hsl2hsv, - hsl2hwb: hsl2hwb, - hsl2cmyk: hsl2cmyk, - hsl2keyword: hsl2keyword, - - hsv2rgb: hsv2rgb, - hsv2hsl: hsv2hsl, - hsv2hwb: hsv2hwb, - hsv2cmyk: hsv2cmyk, - hsv2keyword: hsv2keyword, - - hwb2rgb: hwb2rgb, - hwb2hsl: hwb2hsl, - hwb2hsv: hwb2hsv, - hwb2cmyk: hwb2cmyk, - hwb2keyword: hwb2keyword, - - cmyk2rgb: cmyk2rgb, - cmyk2hsl: cmyk2hsl, - cmyk2hsv: cmyk2hsv, - cmyk2hwb: cmyk2hwb, - cmyk2keyword: cmyk2keyword, - - keyword2rgb: keyword2rgb, - keyword2hsl: keyword2hsl, - keyword2hsv: keyword2hsv, - keyword2hwb: keyword2hwb, - keyword2cmyk: keyword2cmyk, - keyword2lab: keyword2lab, - keyword2xyz: keyword2xyz, + // Percent point function + Gaussian.prototype.ppf = function(x) { + return this.mean - this.standardDeviation * Math.sqrt(2) * ierfc(2 * x); + }; - xyz2rgb: xyz2rgb, - xyz2lab: xyz2lab, - xyz2lch: xyz2lch, + // Product distribution of this and d (scale for constant) + Gaussian.prototype.mul = function(d) { + if (typeof(d) === "number") { + return this.scale(d); + } + var precision = 1 / this.variance; + var dprecision = 1 / d.variance; + return fromPrecisionMean( + precision + dprecision, + precision * this.mean + dprecision * d.mean); + }; - lab2xyz: lab2xyz, - lab2rgb: lab2rgb, - lab2lch: lab2lch, + // Quotient distribution of this and d (scale for constant) + Gaussian.prototype.div = function(d) { + if (typeof(d) === "number") { + return this.scale(1 / d); + } + var precision = 1 / this.variance; + var dprecision = 1 / d.variance; + return fromPrecisionMean( + precision - dprecision, + precision * this.mean - dprecision * d.mean); + }; - lch2lab: lch2lab, - lch2xyz: lch2xyz, - lch2rgb: lch2rgb -} + // Addition of this and d + Gaussian.prototype.add = function(d) { + return gaussian(this.mean + d.mean, this.variance + d.variance); + }; + // Subtraction of this and d + Gaussian.prototype.sub = function(d) { + return gaussian(this.mean - d.mean, this.variance + d.variance); + }; -function rgb2hsl(rgb) { - var r = rgb[0]/255, - g = rgb[1]/255, - b = rgb[2]/255, - min = Math.min(r, g, b), - max = Math.max(r, g, b), - delta = max - min, - h, s, l; + // Scale this by constant c + Gaussian.prototype.scale = function(c) { + return gaussian(this.mean * c, this.variance * c * c); + }; - if (max == min) - h = 0; - else if (r == max) - h = (g - b) / delta; - else if (g == max) - h = 2 + (b - r) / delta; - else if (b == max) - h = 4 + (r - g)/ delta; - h = Math.min(h * 60, 360); + /** + * Generate [num] random samples + * @param {number} num + * @param randFn - an optional function that returns a float between 0 (inclusive) and 1 + * (exclusive). Use this if you want to pass in a random number generator other than + * Math.random(). + * @returns {number[]} + */ + Gaussian.prototype.random = function(num, randFn = null){ + let mean = this.mean; + let std = this.standardDeviation; + return Array(num).fill(0).map(() => { + return generateGaussian(mean,std, randFn) + }) + }; - if (h < 0) - h += 360; + var gaussian = function(mean, variance) { + return new Gaussian(mean, variance); + }; - l = (min + max) / 2; + var fromPrecisionMean = function(precision, precisionmean) { + return gaussian(precisionmean / precision, 1 / precision); + }; - if (max == min) - s = 0; - else if (l <= 0.5) - s = delta / (max + min); - else - s = delta / (2 - max - min); + exports(gaussian); +}) +( true + ? function(e) { module.exports = e; } + // istanbul ignore next + : function(e) { this["gaussian"] = e; }); - return [h, s * 100, l * 100]; -} -function rgb2hsv(rgb) { - var r = rgb[0], - g = rgb[1], - b = rgb[2], - min = Math.min(r, g, b), - max = Math.max(r, g, b), - delta = max - min, - h, s, v; - if (max == 0) - s = 0; - else - s = (delta/max * 1000)/10; +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { - if (max == min) - h = 0; - else if (r == max) - h = (g - b) / delta; - else if (g == max) - h = 2 + (b - r) / delta; - else if (b == max) - h = 4 + (r - g) / delta; +var Emitter = __webpack_require__(37) - h = Math.min(h * 60, 360); +module.exports = attach - if (h < 0) - h += 360; +function attach(element, listener) { + var position = new Emitter - v = ((max / 255) * 1000) / 10; + position[0] = 0 + position[1] = 0 + position.prev = [0, 0] + position.flush = flush + position.dispose = dispose - return [h, s, v]; -} + if (typeof window === 'undefined') { + return position + } -function rgb2hwb(rgb) { - var r = rgb[0], - g = rgb[1], - b = rgb[2], - h = rgb2hsl(rgb)[0], - w = 1/255 * Math.min(r, Math.min(g, b)), - b = 1 - 1/255 * Math.max(r, Math.max(g, b)); + listener = listener || element || window + element = element || document.body + var handler = (element === document.body || element === window + ) ? function(e) { + position.prev[0] = position[0] + position.prev[1] = position[1] + position[0] = e.clientX + position[1] = e.clientY + position.emit('move', e) + } + : function(e) { + position.prev[0] = position[0] + position.prev[1] = position[1] + var bounds = element.getBoundingClientRect() + position[0] = e.clientX - bounds.left + position[1] = e.clientY - bounds.top + position.emit('move', e) + } + listener.addEventListener('mousemove', handler, false) - return [h, w * 100, b * 100]; -} + return position -function rgb2cmyk(rgb) { - var r = rgb[0] / 255, - g = rgb[1] / 255, - b = rgb[2] / 255, - c, m, y, k; + function flush() { + position.prev[0] = position[0] + position.prev[1] = position[1] + } - k = Math.min(1 - r, 1 - g, 1 - b); - c = (1 - r - k) / (1 - k) || 0; - m = (1 - g - k) / (1 - k) || 0; - y = (1 - b - k) / (1 - k) || 0; - return [c * 100, m * 100, y * 100, k * 100]; -} + function dispose() { + position.removeAllListeners('move') + listener.removeEventListener('mousemove', handler) + } -function rgb2keyword(rgb) { - return reverseKeywords[JSON.stringify(rgb)]; } -function rgb2xyz(rgb) { - var r = rgb[0] / 255, - g = rgb[1] / 255, - b = rgb[2] / 255; - - // assume sRGB - r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); - g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); - b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); - - var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); - var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); - var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); - return [x * 100, y *100, z * 100]; -} +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { -function rgb2lab(rgb) { - var xyz = rgb2xyz(rgb), - x = xyz[0], - y = xyz[1], - z = xyz[2], - l, a, b; +var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */ +/** + * Copyright 2012-2017 Craig Campbell + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Mousetrap is a simple keyboard shortcut library for Javascript with + * no external dependencies + * + * @version 1.6.5 + * @url craig.is/killing/mice + */ +(function(window, document, undefined) { - x /= 95.047; - y /= 100; - z /= 108.883; + // Check if mousetrap is used inside browser, if not, return + if (!window) { + return; + } - x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116); - - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); + /** + * mapping of special keycodes to their corresponding keys + * + * everything in this dictionary cannot use keypress events + * so it has to be here to map to the correct keycodes for + * keyup/keydown events + * + * @type {Object} + */ + var _MAP = { + 8: 'backspace', + 9: 'tab', + 13: 'enter', + 16: 'shift', + 17: 'ctrl', + 18: 'alt', + 20: 'capslock', + 27: 'esc', + 32: 'space', + 33: 'pageup', + 34: 'pagedown', + 35: 'end', + 36: 'home', + 37: 'left', + 38: 'up', + 39: 'right', + 40: 'down', + 45: 'ins', + 46: 'del', + 91: 'meta', + 93: 'meta', + 224: 'meta' + }; - return [l, a, b]; -} + /** + * mapping for special characters so they can support + * + * this dictionary is only used incase you want to bind a + * keyup or keydown event to one of these keys + * + * @type {Object} + */ + var _KEYCODE_MAP = { + 106: '*', + 107: '+', + 109: '-', + 110: '.', + 111 : '/', + 186: ';', + 187: '=', + 188: ',', + 189: '-', + 190: '.', + 191: '/', + 192: '`', + 219: '[', + 220: '\\', + 221: ']', + 222: '\'' + }; -function rgb2lch(args) { - return lab2lch(rgb2lab(args)); -} + /** + * this is a mapping of keys that require shift on a US keypad + * back to the non shift equivelents + * + * this is so you can use keyup events with these keys + * + * note that this will only work reliably on US keyboards + * + * @type {Object} + */ + var _SHIFT_MAP = { + '~': '`', + '!': '1', + '@': '2', + '#': '3', + '$': '4', + '%': '5', + '^': '6', + '&': '7', + '*': '8', + '(': '9', + ')': '0', + '_': '-', + '+': '=', + ':': ';', + '\"': '\'', + '<': ',', + '>': '.', + '?': '/', + '|': '\\' + }; -function hsl2rgb(hsl) { - var h = hsl[0] / 360, - s = hsl[1] / 100, - l = hsl[2] / 100, - t1, t2, t3, rgb, val; + /** + * this is a list of special strings you can use to map + * to modifier keys when you specify your keyboard shortcuts + * + * @type {Object} + */ + var _SPECIAL_ALIASES = { + 'option': 'alt', + 'command': 'meta', + 'return': 'enter', + 'escape': 'esc', + 'plus': '+', + 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl' + }; - if (s == 0) { - val = l * 255; - return [val, val, val]; - } + /** + * variable to store the flipped version of _MAP from above + * needed to check if we should use keypress or not when no action + * is specified + * + * @type {Object|undefined} + */ + var _REVERSE_MAP; - if (l < 0.5) - t2 = l * (1 + s); - else - t2 = l + s - l * s; - t1 = 2 * l - t2; + /** + * loop through the f keys, f1 to f19 and add them to the map + * programatically + */ + for (var i = 1; i < 20; ++i) { + _MAP[111 + i] = 'f' + i; + } - rgb = [0, 0, 0]; - for (var i = 0; i < 3; i++) { - t3 = h + 1 / 3 * - (i - 1); - t3 < 0 && t3++; - t3 > 1 && t3--; + /** + * loop through to map numbers on the numeric keypad + */ + for (i = 0; i <= 9; ++i) { - if (6 * t3 < 1) - val = t1 + (t2 - t1) * 6 * t3; - else if (2 * t3 < 1) - val = t2; - else if (3 * t3 < 2) - val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; - else - val = t1; + // This needs to use a string cause otherwise since 0 is falsey + // mousetrap will never fire for numpad 0 pressed as part of a keydown + // event. + // + // @see https://github.com/ccampbell/mousetrap/pull/258 + _MAP[i + 96] = i.toString(); + } - rgb[i] = val * 255; - } + /** + * cross browser add event method + * + * @param {Element|HTMLDocument} object + * @param {string} type + * @param {Function} callback + * @returns void + */ + function _addEvent(object, type, callback) { + if (object.addEventListener) { + object.addEventListener(type, callback, false); + return; + } - return rgb; -} + object.attachEvent('on' + type, callback); + } -function hsl2hsv(hsl) { - var h = hsl[0], - s = hsl[1] / 100, - l = hsl[2] / 100, - sv, v; + /** + * takes the event and returns the key character + * + * @param {Event} e + * @return {string} + */ + function _characterFromEvent(e) { - if(l === 0) { - // no need to do calc on black - // also avoids divide by 0 error - return [0, 0, 0]; - } + // for keypress events we should return the character as is + if (e.type == 'keypress') { + var character = String.fromCharCode(e.which); - l *= 2; - s *= (l <= 1) ? l : 2 - l; - v = (l + s) / 2; - sv = (2 * s) / (l + s); - return [h, sv * 100, v * 100]; -} + // if the shift key is not pressed then it is safe to assume + // that we want the character to be lowercase. this means if + // you accidentally have caps lock on then your key bindings + // will continue to work + // + // the only side effect that might not be desired is if you + // bind something like 'A' cause you want to trigger an + // event when capital A is pressed caps lock will no longer + // trigger the event. shift+a will though. + if (!e.shiftKey) { + character = character.toLowerCase(); + } -function hsl2hwb(args) { - return rgb2hwb(hsl2rgb(args)); -} + return character; + } -function hsl2cmyk(args) { - return rgb2cmyk(hsl2rgb(args)); -} + // for non keypress events the special maps are needed + if (_MAP[e.which]) { + return _MAP[e.which]; + } -function hsl2keyword(args) { - return rgb2keyword(hsl2rgb(args)); -} + if (_KEYCODE_MAP[e.which]) { + return _KEYCODE_MAP[e.which]; + } + // if it is not in the special map -function hsv2rgb(hsv) { - var h = hsv[0] / 60, - s = hsv[1] / 100, - v = hsv[2] / 100, - hi = Math.floor(h) % 6; + // with keydown and keyup events the character seems to always + // come in as an uppercase character whether you are pressing shift + // or not. we should make sure it is always lowercase for comparisons + return String.fromCharCode(e.which).toLowerCase(); + } - var f = h - Math.floor(h), - p = 255 * v * (1 - s), - q = 255 * v * (1 - (s * f)), - t = 255 * v * (1 - (s * (1 - f))), - v = 255 * v; + /** + * checks if two arrays are equal + * + * @param {Array} modifiers1 + * @param {Array} modifiers2 + * @returns {boolean} + */ + function _modifiersMatch(modifiers1, modifiers2) { + return modifiers1.sort().join(',') === modifiers2.sort().join(','); + } - switch(hi) { - case 0: - return [v, t, p]; - case 1: - return [q, v, p]; - case 2: - return [p, v, t]; - case 3: - return [p, q, v]; - case 4: - return [t, p, v]; - case 5: - return [v, p, q]; - } -} + /** + * takes a key event and figures out what the modifiers are + * + * @param {Event} e + * @returns {Array} + */ + function _eventModifiers(e) { + var modifiers = []; -function hsv2hsl(hsv) { - var h = hsv[0], - s = hsv[1] / 100, - v = hsv[2] / 100, - sl, l; + if (e.shiftKey) { + modifiers.push('shift'); + } - l = (2 - s) * v; - sl = s * v; - sl /= (l <= 1) ? l : 2 - l; - sl = sl || 0; - l /= 2; - return [h, sl * 100, l * 100]; -} + if (e.altKey) { + modifiers.push('alt'); + } -function hsv2hwb(args) { - return rgb2hwb(hsv2rgb(args)) -} + if (e.ctrlKey) { + modifiers.push('ctrl'); + } -function hsv2cmyk(args) { - return rgb2cmyk(hsv2rgb(args)); -} + if (e.metaKey) { + modifiers.push('meta'); + } -function hsv2keyword(args) { - return rgb2keyword(hsv2rgb(args)); -} + return modifiers; + } -// http://dev.w3.org/csswg/css-color/#hwb-to-rgb -function hwb2rgb(hwb) { - var h = hwb[0] / 360, - wh = hwb[1] / 100, - bl = hwb[2] / 100, - ratio = wh + bl, - i, v, f, n; + /** + * prevents default for this event + * + * @param {Event} e + * @returns void + */ + function _preventDefault(e) { + if (e.preventDefault) { + e.preventDefault(); + return; + } - // wh + bl cant be > 1 - if (ratio > 1) { - wh /= ratio; - bl /= ratio; - } + e.returnValue = false; + } - i = Math.floor(6 * h); - v = 1 - bl; - f = 6 * h - i; - if ((i & 0x01) != 0) { - f = 1 - f; - } - n = wh + f * (v - wh); // linear interpolation + /** + * stops propogation for this event + * + * @param {Event} e + * @returns void + */ + function _stopPropagation(e) { + if (e.stopPropagation) { + e.stopPropagation(); + return; + } - switch (i) { - default: - case 6: - case 0: r = v; g = n; b = wh; break; - case 1: r = n; g = v; b = wh; break; - case 2: r = wh; g = v; b = n; break; - case 3: r = wh; g = n; b = v; break; - case 4: r = n; g = wh; b = v; break; - case 5: r = v; g = wh; b = n; break; - } + e.cancelBubble = true; + } - return [r * 255, g * 255, b * 255]; -} + /** + * determines if the keycode specified is a modifier key or not + * + * @param {string} key + * @returns {boolean} + */ + function _isModifier(key) { + return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta'; + } -function hwb2hsl(args) { - return rgb2hsl(hwb2rgb(args)); -} + /** + * reverses the map lookup so that we can look for specific keys + * to see what can and can't use keypress + * + * @return {Object} + */ + function _getReverseMap() { + if (!_REVERSE_MAP) { + _REVERSE_MAP = {}; + for (var key in _MAP) { -function hwb2hsv(args) { - return rgb2hsv(hwb2rgb(args)); -} + // pull out the numeric keypad from here cause keypress should + // be able to detect the keys from the character + if (key > 95 && key < 112) { + continue; + } -function hwb2cmyk(args) { - return rgb2cmyk(hwb2rgb(args)); -} + if (_MAP.hasOwnProperty(key)) { + _REVERSE_MAP[_MAP[key]] = key; + } + } + } + return _REVERSE_MAP; + } -function hwb2keyword(args) { - return rgb2keyword(hwb2rgb(args)); -} + /** + * picks the best action based on the key combination + * + * @param {string} key - character for key + * @param {Array} modifiers + * @param {string=} action passed in + */ + function _pickBestAction(key, modifiers, action) { -function cmyk2rgb(cmyk) { - var c = cmyk[0] / 100, - m = cmyk[1] / 100, - y = cmyk[2] / 100, - k = cmyk[3] / 100, - r, g, b; + // if no action was picked in we should try to pick the one + // that we think would work best for this key + if (!action) { + action = _getReverseMap()[key] ? 'keydown' : 'keypress'; + } - r = 1 - Math.min(1, c * (1 - k) + k); - g = 1 - Math.min(1, m * (1 - k) + k); - b = 1 - Math.min(1, y * (1 - k) + k); - return [r * 255, g * 255, b * 255]; -} + // modifier keys don't work as expected with keypress, + // switch to keydown + if (action == 'keypress' && modifiers.length) { + action = 'keydown'; + } -function cmyk2hsl(args) { - return rgb2hsl(cmyk2rgb(args)); -} + return action; + } -function cmyk2hsv(args) { - return rgb2hsv(cmyk2rgb(args)); -} + /** + * Converts from a string key combination to an array + * + * @param {string} combination like "command+shift+l" + * @return {Array} + */ + function _keysFromString(combination) { + if (combination === '+') { + return ['+']; + } -function cmyk2hwb(args) { - return rgb2hwb(cmyk2rgb(args)); -} + combination = combination.replace(/\+{2}/g, '+plus'); + return combination.split('+'); + } -function cmyk2keyword(args) { - return rgb2keyword(cmyk2rgb(args)); -} + /** + * Gets info for a specific key combination + * + * @param {string} combination key combination ("command+s" or "a" or "*") + * @param {string=} action + * @returns {Object} + */ + function _getKeyInfo(combination, action) { + var keys; + var key; + var i; + var modifiers = []; + // take the keys from this pattern and figure out what the actual + // pattern is all about + keys = _keysFromString(combination); -function xyz2rgb(xyz) { - var x = xyz[0] / 100, - y = xyz[1] / 100, - z = xyz[2] / 100, - r, g, b; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; - r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); - g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); - b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); + // normalize key names + if (_SPECIAL_ALIASES[key]) { + key = _SPECIAL_ALIASES[key]; + } - // assume sRGB - r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) - : r = (r * 12.92); - - g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) - : g = (g * 12.92); + // if this is not a keypress event then we should + // be smart about using shift keys + // this will only work for US keyboards however + if (action && action != 'keypress' && _SHIFT_MAP[key]) { + key = _SHIFT_MAP[key]; + modifiers.push('shift'); + } - b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) - : b = (b * 12.92); + // if this key is a modifier then add it to the list of modifiers + if (_isModifier(key)) { + modifiers.push(key); + } + } - r = Math.min(Math.max(0, r), 1); - g = Math.min(Math.max(0, g), 1); - b = Math.min(Math.max(0, b), 1); + // depending on what the key combination is + // we will try to pick the best event for it + action = _pickBestAction(key, modifiers, action); - return [r * 255, g * 255, b * 255]; -} + return { + key: key, + modifiers: modifiers, + action: action + }; + } -function xyz2lab(xyz) { - var x = xyz[0], - y = xyz[1], - z = xyz[2], - l, a, b; + function _belongsTo(element, ancestor) { + if (element === null || element === document) { + return false; + } - x /= 95.047; - y /= 100; - z /= 108.883; + if (element === ancestor) { + return true; + } - x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116); + return _belongsTo(element.parentNode, ancestor); + } - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); + function Mousetrap(targetElement) { + var self = this; - return [l, a, b]; -} + targetElement = targetElement || document; -function xyz2lch(args) { - return lab2lch(xyz2lab(args)); -} + if (!(self instanceof Mousetrap)) { + return new Mousetrap(targetElement); + } -function lab2xyz(lab) { - var l = lab[0], - a = lab[1], - b = lab[2], - x, y, z, y2; + /** + * element to attach key events to + * + * @type {Element} + */ + self.target = targetElement; - if (l <= 8) { - y = (l * 100) / 903.3; - y2 = (7.787 * (y / 100)) + (16 / 116); - } else { - y = 100 * Math.pow((l + 16) / 116, 3); - y2 = Math.pow(y / 100, 1/3); - } + /** + * a list of all the callbacks setup via Mousetrap.bind() + * + * @type {Object} + */ + self._callbacks = {}; - x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3); + /** + * direct map of string combinations to callbacks used for trigger() + * + * @type {Object} + */ + self._directMap = {}; - z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3); + /** + * keeps track of what level each sequence is at since multiple + * sequences can start out with the same sequence + * + * @type {Object} + */ + var _sequenceLevels = {}; - return [x, y, z]; -} + /** + * variable to store the setTimeout call + * + * @type {null|number} + */ + var _resetTimer; -function lab2lch(lab) { - var l = lab[0], - a = lab[1], - b = lab[2], - hr, h, c; + /** + * temporary state where we will ignore the next keyup + * + * @type {boolean|string} + */ + var _ignoreNextKeyup = false; - hr = Math.atan2(b, a); - h = hr * 360 / 2 / Math.PI; - if (h < 0) { - h += 360; - } - c = Math.sqrt(a * a + b * b); - return [l, c, h]; -} + /** + * temporary state where we will ignore the next keypress + * + * @type {boolean} + */ + var _ignoreNextKeypress = false; -function lab2rgb(args) { - return xyz2rgb(lab2xyz(args)); -} + /** + * are we currently inside of a sequence? + * type of action ("keyup" or "keydown" or "keypress") or false + * + * @type {boolean|string} + */ + var _nextExpectedAction = false; -function lch2lab(lch) { - var l = lch[0], - c = lch[1], - h = lch[2], - a, b, hr; + /** + * resets all sequence counters except for the ones passed in + * + * @param {Object} doNotReset + * @returns void + */ + function _resetSequences(doNotReset) { + doNotReset = doNotReset || {}; - hr = h / 360 * 2 * Math.PI; - a = c * Math.cos(hr); - b = c * Math.sin(hr); - return [l, a, b]; -} + var activeSequences = false, + key; -function lch2xyz(args) { - return lab2xyz(lch2lab(args)); -} + for (key in _sequenceLevels) { + if (doNotReset[key]) { + activeSequences = true; + continue; + } + _sequenceLevels[key] = 0; + } -function lch2rgb(args) { - return lab2rgb(lch2lab(args)); -} + if (!activeSequences) { + _nextExpectedAction = false; + } + } -function keyword2rgb(keyword) { - return cssKeywords[keyword]; -} + /** + * finds all callbacks that match based on the keycode, modifiers, + * and action + * + * @param {string} character + * @param {Array} modifiers + * @param {Event|Object} e + * @param {string=} sequenceName - name of the sequence we are looking for + * @param {string=} combination + * @param {number=} level + * @returns {Array} + */ + function _getMatches(character, modifiers, e, sequenceName, combination, level) { + var i; + var callback; + var matches = []; + var action = e.type; -function keyword2hsl(args) { - return rgb2hsl(keyword2rgb(args)); -} + // if there are no events related to this keycode + if (!self._callbacks[character]) { + return []; + } -function keyword2hsv(args) { - return rgb2hsv(keyword2rgb(args)); -} + // if a modifier key is coming up on its own we should allow it + if (action == 'keyup' && _isModifier(character)) { + modifiers = [character]; + } -function keyword2hwb(args) { - return rgb2hwb(keyword2rgb(args)); -} + // loop through all callbacks for the key that was pressed + // and see if any of them match + for (i = 0; i < self._callbacks[character].length; ++i) { + callback = self._callbacks[character][i]; -function keyword2cmyk(args) { - return rgb2cmyk(keyword2rgb(args)); -} + // if a sequence name is not specified, but this is a sequence at + // the wrong level then move onto the next match + if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { + continue; + } -function keyword2lab(args) { - return rgb2lab(keyword2rgb(args)); -} + // if the action we are looking for doesn't match the action we got + // then we should keep going + if (action != callback.action) { + continue; + } -function keyword2xyz(args) { - return rgb2xyz(keyword2rgb(args)); -} + // if this is a keypress event and the meta key and control key + // are not pressed that means that we need to only look at the + // character, otherwise check the modifiers as well + // + // chrome will not fire a keypress if meta or control is down + // safari will fire a keypress if meta or meta+shift is down + // firefox will fire a keypress if meta or control is down + if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) { -var cssKeywords = { - aliceblue: [240,248,255], - antiquewhite: [250,235,215], - aqua: [0,255,255], - aquamarine: [127,255,212], - azure: [240,255,255], - beige: [245,245,220], - bisque: [255,228,196], - black: [0,0,0], - blanchedalmond: [255,235,205], - blue: [0,0,255], - blueviolet: [138,43,226], - brown: [165,42,42], - burlywood: [222,184,135], - cadetblue: [95,158,160], - chartreuse: [127,255,0], - chocolate: [210,105,30], - coral: [255,127,80], - cornflowerblue: [100,149,237], - cornsilk: [255,248,220], - crimson: [220,20,60], - cyan: [0,255,255], - darkblue: [0,0,139], - darkcyan: [0,139,139], - darkgoldenrod: [184,134,11], - darkgray: [169,169,169], - darkgreen: [0,100,0], - darkgrey: [169,169,169], - darkkhaki: [189,183,107], - darkmagenta: [139,0,139], - darkolivegreen: [85,107,47], - darkorange: [255,140,0], - darkorchid: [153,50,204], - darkred: [139,0,0], - darksalmon: [233,150,122], - darkseagreen: [143,188,143], - darkslateblue: [72,61,139], - darkslategray: [47,79,79], - darkslategrey: [47,79,79], - darkturquoise: [0,206,209], - darkviolet: [148,0,211], - deeppink: [255,20,147], - deepskyblue: [0,191,255], - dimgray: [105,105,105], - dimgrey: [105,105,105], - dodgerblue: [30,144,255], - firebrick: [178,34,34], - floralwhite: [255,250,240], - forestgreen: [34,139,34], - fuchsia: [255,0,255], - gainsboro: [220,220,220], - ghostwhite: [248,248,255], - gold: [255,215,0], - goldenrod: [218,165,32], - gray: [128,128,128], - green: [0,128,0], - greenyellow: [173,255,47], - grey: [128,128,128], - honeydew: [240,255,240], - hotpink: [255,105,180], - indianred: [205,92,92], - indigo: [75,0,130], - ivory: [255,255,240], - khaki: [240,230,140], - lavender: [230,230,250], - lavenderblush: [255,240,245], - lawngreen: [124,252,0], - lemonchiffon: [255,250,205], - lightblue: [173,216,230], - lightcoral: [240,128,128], - lightcyan: [224,255,255], - lightgoldenrodyellow: [250,250,210], - lightgray: [211,211,211], - lightgreen: [144,238,144], - lightgrey: [211,211,211], - lightpink: [255,182,193], - lightsalmon: [255,160,122], - lightseagreen: [32,178,170], - lightskyblue: [135,206,250], - lightslategray: [119,136,153], - lightslategrey: [119,136,153], - lightsteelblue: [176,196,222], - lightyellow: [255,255,224], - lime: [0,255,0], - limegreen: [50,205,50], - linen: [250,240,230], - magenta: [255,0,255], - maroon: [128,0,0], - mediumaquamarine: [102,205,170], - mediumblue: [0,0,205], - mediumorchid: [186,85,211], - mediumpurple: [147,112,219], - mediumseagreen: [60,179,113], - mediumslateblue: [123,104,238], - mediumspringgreen: [0,250,154], - mediumturquoise: [72,209,204], - mediumvioletred: [199,21,133], - midnightblue: [25,25,112], - mintcream: [245,255,250], - mistyrose: [255,228,225], - moccasin: [255,228,181], - navajowhite: [255,222,173], - navy: [0,0,128], - oldlace: [253,245,230], - olive: [128,128,0], - olivedrab: [107,142,35], - orange: [255,165,0], - orangered: [255,69,0], - orchid: [218,112,214], - palegoldenrod: [238,232,170], - palegreen: [152,251,152], - paleturquoise: [175,238,238], - palevioletred: [219,112,147], - papayawhip: [255,239,213], - peachpuff: [255,218,185], - peru: [205,133,63], - pink: [255,192,203], - plum: [221,160,221], - powderblue: [176,224,230], - purple: [128,0,128], - rebeccapurple: [102, 51, 153], - red: [255,0,0], - rosybrown: [188,143,143], - royalblue: [65,105,225], - saddlebrown: [139,69,19], - salmon: [250,128,114], - sandybrown: [244,164,96], - seagreen: [46,139,87], - seashell: [255,245,238], - sienna: [160,82,45], - silver: [192,192,192], - skyblue: [135,206,235], - slateblue: [106,90,205], - slategray: [112,128,144], - slategrey: [112,128,144], - snow: [255,250,250], - springgreen: [0,255,127], - steelblue: [70,130,180], - tan: [210,180,140], - teal: [0,128,128], - thistle: [216,191,216], - tomato: [255,99,71], - turquoise: [64,224,208], - violet: [238,130,238], - wheat: [245,222,179], - white: [255,255,255], - whitesmoke: [245,245,245], - yellow: [255,255,0], - yellowgreen: [154,205,50] -}; + // when you bind a combination or sequence a second time it + // should overwrite the first one. if a sequenceName or + // combination is specified in this call it does just that + // + // @todo make deleting its own method? + var deleteCombo = !sequenceName && callback.combo == combination; + var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; + if (deleteCombo || deleteSequence) { + self._callbacks[character].splice(i, 1); + } -var reverseKeywords = {}; -for (var key in cssKeywords) { - reverseKeywords[JSON.stringify(cssKeywords[key])] = key; -} + matches.push(callback); + } + } + return matches; + } -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * actually calls the callback function + * + * if your callback function returns false this will use the jquery + * convention - prevent default and stop propogation on the event + * + * @param {Function} callback + * @param {Event} e + * @returns void + */ + function _fireCallback(callback, e, combo, sequence) { -var isBuffer = __webpack_require__(13); -var toString = Object.prototype.toString; + // if this event should not happen stop here + if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { + return; + } -/** - * Get the native `typeof` a value. - * - * @param {*} `val` - * @return {*} Native javascript type - */ + if (callback(e, combo) === false) { + _preventDefault(e); + _stopPropagation(e); + } + } -module.exports = function kindOf(val) { - // primitivies - if (typeof val === 'undefined') { - return 'undefined'; - } - if (val === null) { - return 'null'; - } - if (val === true || val === false || val instanceof Boolean) { - return 'boolean'; - } - if (typeof val === 'string' || val instanceof String) { - return 'string'; - } - if (typeof val === 'number' || val instanceof Number) { - return 'number'; - } + /** + * handles a character key event + * + * @param {string} character + * @param {Array} modifiers + * @param {Event} e + * @returns void + */ + self._handleKey = function(character, modifiers, e) { + var callbacks = _getMatches(character, modifiers, e); + var i; + var doNotReset = {}; + var maxLevel = 0; + var processedSequenceCallback = false; - // functions - if (typeof val === 'function' || val instanceof Function) { - return 'function'; - } + // Calculate the maxLevel for sequences so we can only execute the longest callback sequence + for (i = 0; i < callbacks.length; ++i) { + if (callbacks[i].seq) { + maxLevel = Math.max(maxLevel, callbacks[i].level); + } + } - // array - if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) { - return 'array'; - } + // loop through matching callbacks for this key event + for (i = 0; i < callbacks.length; ++i) { - // check for instances of RegExp and Date before calling `toString` - if (val instanceof RegExp) { - return 'regexp'; - } - if (val instanceof Date) { - return 'date'; - } + // fire for all sequence callbacks + // this is because if for example you have multiple sequences + // bound such as "g i" and "g t" they both need to fire the + // callback for matching g cause otherwise you can only ever + // match the first one + if (callbacks[i].seq) { - // other objects - var type = toString.call(val); - - if (type === '[object RegExp]') { - return 'regexp'; - } - if (type === '[object Date]') { - return 'date'; - } - if (type === '[object Arguments]') { - return 'arguments'; - } - if (type === '[object Error]') { - return 'error'; - } + // only fire callbacks for the maxLevel to prevent + // subsequences from also firing + // + // for example 'a option b' should not cause 'option b' to fire + // even though 'option b' is part of the other sequence + // + // any sequences that do not match here will be discarded + // below by the _resetSequences call + if (callbacks[i].level != maxLevel) { + continue; + } - // buffer - if (isBuffer(val)) { - return 'buffer'; - } + processedSequenceCallback = true; - // es6: Map, WeakMap, Set, WeakSet - if (type === '[object Set]') { - return 'set'; - } - if (type === '[object WeakSet]') { - return 'weakset'; - } - if (type === '[object Map]') { - return 'map'; - } - if (type === '[object WeakMap]') { - return 'weakmap'; - } - if (type === '[object Symbol]') { - return 'symbol'; - } + // keep a list of which sequences were matches for later + doNotReset[callbacks[i].seq] = 1; + _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq); + continue; + } - // typed arrays - if (type === '[object Int8Array]') { - return 'int8array'; - } - if (type === '[object Uint8Array]') { - return 'uint8array'; - } - if (type === '[object Uint8ClampedArray]') { - return 'uint8clampedarray'; - } - if (type === '[object Int16Array]') { - return 'int16array'; - } - if (type === '[object Uint16Array]') { - return 'uint16array'; - } - if (type === '[object Int32Array]') { - return 'int32array'; - } - if (type === '[object Uint32Array]') { - return 'uint32array'; - } - if (type === '[object Float32Array]') { - return 'float32array'; - } - if (type === '[object Float64Array]') { - return 'float64array'; - } + // if there were no sequence matches but we are still here + // that means this is a regular match so we should fire that + if (!processedSequenceCallback) { + _fireCallback(callbacks[i].callback, e, callbacks[i].combo); + } + } - // must be a plain object - return 'object'; -}; + // if the key you pressed matches the type of sequence without + // being a modifier (ie "keyup" or "keypress") then we should + // reset all sequences that were not matched by this event + // + // this is so, for example, if you have the sequence "h a t" and you + // type "h e a r t" it does not match. in this case the "e" will + // cause the sequence to reset + // + // modifier keys are ignored because you can have a sequence + // that contains modifiers such as "enter ctrl+space" and in most + // cases the modifier key will be pressed before the next key + // + // also if you have a sequence such as "ctrl+b a" then pressing the + // "b" key will trigger a "keypress" and a "keydown" + // + // the "keydown" is expected when there is a modifier, but the + // "keypress" ends up matching the _nextExpectedAction since it occurs + // after and that causes the sequence to reset + // + // we ignore keypresses in a sequence that directly follow a keydown + // for the same character + var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress; + if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { + _resetSequences(doNotReset); + } + _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown'; + }; -/***/ }), -/* 13 */ -/***/ (function(module, exports) { + /** + * handles a keydown event + * + * @param {Event} e + * @returns void + */ + function _handleKeyEvent(e) { -/*! - * Determine if an object is a Buffer - * - * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> - * @license MIT - */ + // normalize e.which for key events + // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion + if (typeof e.which !== 'number') { + e.which = e.keyCode; + } -// The _isBuffer check is for Safari 5-7 support, because it's missing -// Object.prototype.constructor. Remove this eventually -module.exports = function (obj) { - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) -} + var character = _characterFromEvent(e); -function isBuffer (obj) { - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) -} + // no character found then stop + if (!character) { + return; + } -// For Node v0.10 support. Remove this eventually. -function isSlowBuffer (obj) { - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) -} + // need to use === for the character check because the character can be 0 + if (e.type == 'keyup' && _ignoreNextKeyup === character) { + _ignoreNextKeyup = false; + return; + } + self.handleKey(character, _eventModifiers(e), e); + } -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * called to set a 1 second timeout on the specified sequence + * + * this is so after each key press in the sequence you have 1 second + * to press the next key before you have to start over + * + * @returns void + */ + function _resetSequenceTimer() { + clearTimeout(_resetTimer); + _resetTimer = setTimeout(_resetSequences, 1000); + } -var lodash = __webpack_require__(15); -var isarray = __webpack_require__(4); -var isnumber = __webpack_require__(2); -var isstring = __webpack_require__(3); -var parse = __webpack_require__(1); + /** + * binds a key sequence to an event + * + * @param {string} combo - combo specified in bind call + * @param {Array} keys + * @param {Function} callback + * @param {string=} action + * @returns void + */ + function _bindSequence(combo, keys, callback, action) { -function convert(data) { - data = isarray(data[0]) && data[0].length !== 3 ? lodash.flatten(data, 1) : data; + // start off by adding a sequence level record for this combination + // and setting the level to 0 + _sequenceLevels[combo] = 0; - if (isnumber(data[0])) { - data = data.map(function(d) { - return [ d, d, d ]; - }); - } + /** + * callback to increase the sequence level for this sequence and reset + * all other sequences that were active + * + * @param {string} nextAction + * @returns {Function} + */ + function _increaseSequence(nextAction) { + return function() { + _nextExpectedAction = nextAction; + ++_sequenceLevels[combo]; + _resetSequenceTimer(); + }; + } - if (isstring(data[0])) { - data = data.map(function(d) { - return parse(d).rgb.map(function(c) { - return c / 255; - }); - }); - } + /** + * wraps the specified callback inside of another function in order + * to reset all sequence counters as soon as this sequence is done + * + * @param {Event} e + * @returns void + */ + function _callbackAndReset(e) { + _fireCallback(callback, e, combo); - return data; -} + // we should ignore the next key up if the action is key down + // or keypress. this is so if you finish a sequence and + // release the key the final key will not trigger a keyup + if (action !== 'keyup') { + _ignoreNextKeyup = _characterFromEvent(e); + } -module.exports = convert; + // weird race condition if a sequence ends with the key + // another sequence begins with + setTimeout(_resetSequences, 10); + } + // loop through keys one at a time and bind the appropriate callback + // function. for any key leading up to the final one it should + // increase the sequence. after the final, it should reset all sequences + // + // if an action is specified in the original bind call then that will + // be used throughout. otherwise we will pass the action that the + // next key in the sequence should match. this allows a sequence + // to mix and match keypress and keydown events depending on which + // ones are better suited to the key provided + for (var i = 0; i < keys.length; ++i) { + var isFinal = i + 1 === keys.length; + var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action); + _bindSingle(keys[i], wrappedCallback, action, combo, i); + } + } -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * binds a single keyboard combination + * + * @param {string} combination + * @param {Function} callback + * @param {string=} action + * @param {string=} sequenceName - name of sequence if part of sequence + * @param {number=} level - what part of the sequence the command is + * @returns void + */ + function _bindSingle(combination, callback, action, sequenceName, level) { -/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/** - * @license - * Lodash <https://lodash.com/> - * Copyright JS Foundation and other contributors <https://js.foundation/> - * Released under MIT license <https://lodash.com/license> - * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -;(function() { + // store a direct mapped reference for use with Mousetrap.trigger + self._directMap[combination + ':' + action] = callback; - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; + // make sure multiple spaces in a row become a single space + combination = combination.replace(/\s+/g, ' '); - /** Used as the semantic version number. */ - var VERSION = '4.17.4'; + var sequence = combination.split(' '); + var info; - /** Used as the size to enable large array optimizations. */ - var LARGE_ARRAY_SIZE = 200; + // if this pattern is a sequence of keys then run through this method + // to reprocess each pattern one key at a time + if (sequence.length > 1) { + _bindSequence(combination, sequence, callback, action); + return; + } - /** Error message constants. */ - var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', - FUNC_ERROR_TEXT = 'Expected a function'; + info = _getKeyInfo(combination, action); - /** Used to stand-in for `undefined` hash values. */ - var HASH_UNDEFINED = '__lodash_hash_undefined__'; + // make sure to initialize array if this is the first time + // a callback is added for this key + self._callbacks[info.key] = self._callbacks[info.key] || []; - /** Used as the maximum memoize cache size. */ - var MAX_MEMOIZE_SIZE = 500; + // remove an existing match if there is one + _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level); - /** Used as the internal argument placeholder. */ - var PLACEHOLDER = '__lodash_placeholder__'; + // add this call back to the array + // if it is a sequence put it at the beginning + // if not put it at the end + // + // this is important because the way these are processed expects + // the sequence ones to come first + self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({ + callback: callback, + modifiers: info.modifiers, + action: info.action, + seq: sequenceName, + level: level, + combo: combination + }); + } - /** Used to compose bitmasks for cloning. */ - var CLONE_DEEP_FLAG = 1, - CLONE_FLAT_FLAG = 2, - CLONE_SYMBOLS_FLAG = 4; + /** + * binds multiple combinations to the same callback + * + * @param {Array} combinations + * @param {Function} callback + * @param {string|undefined} action + * @returns void + */ + self._bindMultiple = function(combinations, callback, action) { + for (var i = 0; i < combinations.length; ++i) { + _bindSingle(combinations[i], callback, action); + } + }; - /** Used to compose bitmasks for value comparisons. */ - var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; + // start! + _addEvent(targetElement, 'keypress', _handleKeyEvent); + _addEvent(targetElement, 'keydown', _handleKeyEvent); + _addEvent(targetElement, 'keyup', _handleKeyEvent); + } - /** Used to compose bitmasks for function metadata. */ - var WRAP_BIND_FLAG = 1, - WRAP_BIND_KEY_FLAG = 2, - WRAP_CURRY_BOUND_FLAG = 4, - WRAP_CURRY_FLAG = 8, - WRAP_CURRY_RIGHT_FLAG = 16, - WRAP_PARTIAL_FLAG = 32, - WRAP_PARTIAL_RIGHT_FLAG = 64, - WRAP_ARY_FLAG = 128, - WRAP_REARG_FLAG = 256, - WRAP_FLIP_FLAG = 512; + /** + * binds an event to mousetrap + * + * can be a single key, a combination of keys separated with +, + * an array of keys, or a sequence of keys separated by spaces + * + * be sure to list the modifier keys first to make sure that the + * correct key ends up getting bound (the last key in the pattern) + * + * @param {string|Array} keys + * @param {Function} callback + * @param {string=} action - 'keypress', 'keydown', or 'keyup' + * @returns void + */ + Mousetrap.prototype.bind = function(keys, callback, action) { + var self = this; + keys = keys instanceof Array ? keys : [keys]; + self._bindMultiple.call(self, keys, callback, action); + return self; + }; - /** Used as default options for `_.truncate`. */ - var DEFAULT_TRUNC_LENGTH = 30, - DEFAULT_TRUNC_OMISSION = '...'; + /** + * unbinds an event to mousetrap + * + * the unbinding sets the callback function of the specified key combo + * to an empty function and deletes the corresponding key in the + * _directMap dict. + * + * TODO: actually remove this from the _callbacks dictionary instead + * of binding an empty function + * + * the keycombo+action has to be exactly the same as + * it was defined in the bind method + * + * @param {string|Array} keys + * @param {string} action + * @returns void + */ + Mousetrap.prototype.unbind = function(keys, action) { + var self = this; + return self.bind.call(self, keys, function() {}, action); + }; - /** Used to detect hot functions by number of calls within a span of milliseconds. */ - var HOT_COUNT = 800, - HOT_SPAN = 16; + /** + * triggers an event that has already been bound + * + * @param {string} keys + * @param {string=} action + * @returns void + */ + Mousetrap.prototype.trigger = function(keys, action) { + var self = this; + if (self._directMap[keys + ':' + action]) { + self._directMap[keys + ':' + action]({}, keys); + } + return self; + }; - /** Used to indicate the type of lazy iteratees. */ - var LAZY_FILTER_FLAG = 1, - LAZY_MAP_FLAG = 2, - LAZY_WHILE_FLAG = 3; + /** + * resets the library back to its initial state. this is useful + * if you want to clear out the current keyboard shortcuts and bind + * new ones - for example if you switch to another page + * + * @returns void + */ + Mousetrap.prototype.reset = function() { + var self = this; + self._callbacks = {}; + self._directMap = {}; + return self; + }; - /** Used as references for various `Number` constants. */ - var INFINITY = 1 / 0, - MAX_SAFE_INTEGER = 9007199254740991, - MAX_INTEGER = 1.7976931348623157e+308, - NAN = 0 / 0; + /** + * should we stop this event before firing off callbacks + * + * @param {Event} e + * @param {Element} element + * @return {boolean} + */ + Mousetrap.prototype.stopCallback = function(e, element) { + var self = this; - /** Used as references for the maximum length and index of an array. */ - var MAX_ARRAY_LENGTH = 4294967295, - MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, - HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + // if the element has the class "mousetrap" then no need to stop + if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) { + return false; + } - /** Used to associate wrap methods with their bit flags. */ - var wrapFlags = [ - ['ary', WRAP_ARY_FLAG], - ['bind', WRAP_BIND_FLAG], - ['bindKey', WRAP_BIND_KEY_FLAG], - ['curry', WRAP_CURRY_FLAG], - ['curryRight', WRAP_CURRY_RIGHT_FLAG], - ['flip', WRAP_FLIP_FLAG], - ['partial', WRAP_PARTIAL_FLAG], - ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], - ['rearg', WRAP_REARG_FLAG] - ]; + if (_belongsTo(element, self.target)) { + return false; + } - /** `Object#toString` result references. */ - var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - asyncTag = '[object AsyncFunction]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - domExcTag = '[object DOMException]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - mapTag = '[object Map]', - numberTag = '[object Number]', - nullTag = '[object Null]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - proxyTag = '[object Proxy]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]', - undefinedTag = '[object Undefined]', - weakMapTag = '[object WeakMap]', - weakSetTag = '[object WeakSet]'; + // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host, + // not the initial event target in the shadow tree. Note that not all events cross the + // shadow boundary. + // For shadow trees with `mode: 'open'`, the initial event target is the first element in + // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event + // target cannot be obtained. + if ('composedPath' in e && typeof e.composedPath === 'function') { + // For open shadow trees, update `element` so that the following check works. + var initialEventTarget = e.composedPath()[0]; + if (initialEventTarget !== e.target) { + element = initialEventTarget; + } + } - var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; + // stop for input, select, and textarea + return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable; + }; - /** Used to match empty string literals in compiled template source. */ - var reEmptyStringLeading = /\b__p \+= '';/g, - reEmptyStringMiddle = /\b(__p \+=) '' \+/g, - reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - - /** Used to match HTML entities and HTML characters. */ - var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, - reUnescapedHtml = /[&<>"']/g, - reHasEscapedHtml = RegExp(reEscapedHtml.source), - reHasUnescapedHtml = RegExp(reUnescapedHtml.source); - - /** Used to match template delimiters. */ - var reEscape = /<%-([\s\S]+?)%>/g, - reEvaluate = /<%([\s\S]+?)%>/g, - reInterpolate = /<%=([\s\S]+?)%>/g; - - /** Used to match property names within property paths. */ - var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; - - /** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ - var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, - reHasRegExpChar = RegExp(reRegExpChar.source); - - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g, - reTrimStart = /^\s+/, - reTrimEnd = /\s+$/; - - /** Used to match wrap detail comments. */ - var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, - reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, - reSplitDetails = /,? & /; - - /** Used to match words composed of alphanumeric characters. */ - var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; - - /** Used to match backslashes in property paths. */ - var reEscapeChar = /\\(\\)?/g; - - /** - * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). - */ - var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - - /** Used to match `RegExp` flags from their coerced string values. */ - var reFlags = /\w*$/; - - /** Used to detect bad signed hexadecimal string values. */ - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - - /** Used to detect binary string values. */ - var reIsBinary = /^0b[01]+$/i; - - /** Used to detect host constructors (Safari). */ - var reIsHostCtor = /^\[object .+?Constructor\]$/; - - /** Used to detect octal string values. */ - var reIsOctal = /^0o[0-7]+$/i; - - /** Used to detect unsigned integer values. */ - var reIsUint = /^(?:0|[1-9]\d*)$/; - - /** Used to match Latin Unicode letters (excluding mathematical operators). */ - var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; - - /** Used to ensure capturing order of template delimiters. */ - var reNoMatch = /($^)/; - - /** Used to match unescaped characters in compiled string literals. */ - var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - - /** Used to compose unicode character classes. */ - var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, - rsDingbatRange = '\\u2700-\\u27bf', - rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', - rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', - rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', - rsPunctuationRange = '\\u2000-\\u206f', - rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', - rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', - rsVarRange = '\\ufe0e\\ufe0f', - rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; - - /** Used to compose unicode capture groups. */ - var rsApos = "['\u2019]", - rsAstral = '[' + rsAstralRange + ']', - rsBreak = '[' + rsBreakRange + ']', - rsCombo = '[' + rsComboRange + ']', - rsDigits = '\\d+', - rsDingbat = '[' + rsDingbatRange + ']', - rsLower = '[' + rsLowerRange + ']', - rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', - rsFitz = '\\ud83c[\\udffb-\\udfff]', - rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', - rsNonAstral = '[^' + rsAstralRange + ']', - rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', - rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', - rsUpper = '[' + rsUpperRange + ']', - rsZWJ = '\\u200d'; - - /** Used to compose unicode regexes. */ - var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', - rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', - rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', - rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', - reOptMod = rsModifier + '?', - rsOptVar = '[' + rsVarRange + ']?', - rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', - rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', - rsSeq = rsOptVar + reOptMod + rsOptJoin, - rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, - rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - - /** Used to match apostrophes. */ - var reApos = RegExp(rsApos, 'g'); + /** + * exposes _handleKey publicly so it can be overwritten by extensions + */ + Mousetrap.prototype.handleKey = function() { + var self = this; + return self._handleKey.apply(self, arguments); + }; - /** - * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and - * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). - */ - var reComboMark = RegExp(rsCombo, 'g'); + /** + * allow custom key mappings + */ + Mousetrap.addKeycodes = function(object) { + for (var key in object) { + if (object.hasOwnProperty(key)) { + _MAP[key] = object[key]; + } + } + _REVERSE_MAP = null; + }; - /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ - var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + /** + * Init the global mousetrap functions + * + * This method is needed to allow the global mousetrap functions to work + * now that mousetrap is a constructor function. + */ + Mousetrap.init = function() { + var documentMousetrap = Mousetrap(document); + for (var method in documentMousetrap) { + if (method.charAt(0) !== '_') { + Mousetrap[method] = (function(method) { + return function() { + return documentMousetrap[method].apply(documentMousetrap, arguments); + }; + } (method)); + } + } + }; - /** Used to match complex or compound words. */ - var reUnicodeWord = RegExp([ - rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', - rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', - rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, - rsUpper + '+' + rsOptContrUpper, - rsOrdUpper, - rsOrdLower, - rsDigits, - rsEmoji - ].join('|'), 'g'); + Mousetrap.init(); - /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + // expose mousetrap to the global object + window.Mousetrap = Mousetrap; - /** Used to detect strings that need a more robust regexp to match words. */ - var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + // expose as a common js module + if (typeof module !== 'undefined' && module.exports) { + module.exports = Mousetrap; + } - /** Used to assign default `context` object properties. */ - var contextProps = [ - 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', - 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', - 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', - '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' - ]; + // expose mousetrap as an AMD module + if (true) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { + return Mousetrap; + }.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } +}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null); - /** Used to make template sourceURLs easier to identify. */ - var templateCounter = -1; - /** Used to identify `toStringTag` values of typed arrays. */ - var typedArrayTags = {}; - typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = - typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = - typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = - typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = - typedArrayTags[uint32Tag] = true; - typedArrayTags[argsTag] = typedArrayTags[arrayTag] = - typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = - typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = - typedArrayTags[errorTag] = typedArrayTags[funcTag] = - typedArrayTags[mapTag] = typedArrayTags[numberTag] = - typedArrayTags[objectTag] = typedArrayTags[regexpTag] = - typedArrayTags[setTag] = typedArrayTags[stringTag] = - typedArrayTags[weakMapTag] = false; +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { - /** Used to identify `toStringTag` values supported by `_.clone`. */ - var cloneableTags = {}; - cloneableTags[argsTag] = cloneableTags[arrayTag] = - cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = - cloneableTags[boolTag] = cloneableTags[dateTag] = - cloneableTags[float32Tag] = cloneableTags[float64Tag] = - cloneableTags[int8Tag] = cloneableTags[int16Tag] = - cloneableTags[int32Tag] = cloneableTags[mapTag] = - cloneableTags[numberTag] = cloneableTags[objectTag] = - cloneableTags[regexpTag] = cloneableTags[setTag] = - cloneableTags[stringTag] = cloneableTags[symbolTag] = - cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = - cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; - cloneableTags[errorTag] = cloneableTags[funcTag] = - cloneableTags[weakMapTag] = false; +"use strict"; - /** Used to map Latin Unicode letters to basic Latin letters. */ - var deburredLetters = { - // Latin-1 Supplement block. - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss', - // Latin Extended-A block. - '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', - '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', - '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', - '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', - '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', - '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', - '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', - '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', - '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', - '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', - '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', - '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', - '\u0134': 'J', '\u0135': 'j', - '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', - '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', - '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', - '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', - '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', - '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', - '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', - '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', - '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', - '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', - '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', - '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', - '\u0163': 't', '\u0165': 't', '\u0167': 't', - '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', - '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', - '\u0174': 'W', '\u0175': 'w', - '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', - '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', - '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', - '\u0132': 'IJ', '\u0133': 'ij', - '\u0152': 'Oe', '\u0153': 'oe', - '\u0149': "'n", '\u017f': 's' - }; - - /** Used to map characters to HTML entities. */ - var htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - }; - - /** Used to map HTML entities to characters. */ - var htmlUnescapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - ''': "'" - }; - - /** Used to escape characters for inclusion in compiled string literals. */ - var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - /** Built-in method references without a dependency on `root`. */ - var freeParseFloat = parseFloat, - freeParseInt = parseInt; - - /** Detect free variable `global` from Node.js. */ - var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - - /** Detect free variable `self`. */ - var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - - /** Used as a reference to the global object. */ - var root = freeGlobal || freeSelf || Function('return this')(); - - /** Detect free variable `exports`. */ - var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - - /** Detect free variable `module`. */ - var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - - /** Detect the popular CommonJS extension `module.exports`. */ - var moduleExports = freeModule && freeModule.exports === freeExports; - - /** Detect free variable `process` from Node.js. */ - var freeProcess = moduleExports && freeGlobal.process; - - /** Used to access faster Node.js helpers. */ - var nodeUtil = (function() { - try { - return freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) {} - }()); - - /* Node.js helper references. */ - var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, - nodeIsDate = nodeUtil && nodeUtil.isDate, - nodeIsMap = nodeUtil && nodeUtil.isMap, - nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, - nodeIsSet = nodeUtil && nodeUtil.isSet, - nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - - /*--------------------------------------------------------------------------*/ - - /** - * Adds the key-value `pair` to `map`. - * - * @private - * @param {Object} map The map to modify. - * @param {Array} pair The key-value pair to add. - * @returns {Object} Returns `map`. - */ - function addMapEntry(map, pair) { - // Don't return `map.set` because it's not chainable in IE 11. - map.set(pair[0], pair[1]); - return map; - } - - /** - * Adds `value` to `set`. - * - * @private - * @param {Object} set The set to modify. - * @param {*} value The value to add. - * @returns {Object} Returns `set`. - */ - function addSetEntry(set, value) { - // Don't return `set.add` because it's not chainable in IE 11. - set.add(value); - return set; - } - - /** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ - function apply(func, thisArg, args) { - switch (args.length) { - case 0: return func.call(thisArg); - case 1: return func.call(thisArg, args[0]); - case 2: return func.call(thisArg, args[0], args[1]); - case 3: return func.call(thisArg, args[0], args[1], args[2]); - } - return func.apply(thisArg, args); - } - - /** - * A specialized version of `baseAggregator` for arrays. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform keys. - * @param {Object} accumulator The initial aggregated object. - * @returns {Function} Returns `accumulator`. - */ - function arrayAggregator(array, setter, iteratee, accumulator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - var value = array[index]; - setter(accumulator, value, iteratee(value), array); - } - return accumulator; - } - - /** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEach(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } - } - return array; - } - - /** - * A specialized version of `_.forEachRight` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEachRight(array, iteratee) { - var length = array == null ? 0 : array.length; - - while (length--) { - if (iteratee(array[length], length, array) === false) { - break; - } - } - return array; - } - - /** - * A specialized version of `_.every` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - */ - function arrayEvery(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (!predicate(array[index], index, array)) { - return false; - } - } - return true; - } - - /** - * A specialized version of `_.filter` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ - function arrayFilter(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; - } - - /** - * A specialized version of `_.includes` for arrays without support for - * specifying an index to search from. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ - function arrayIncludes(array, value) { - var length = array == null ? 0 : array.length; - return !!length && baseIndexOf(array, value, 0) > -1; - } - - /** - * This function is like `arrayIncludes` except that it accepts a comparator. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @param {Function} comparator The comparator invoked per element. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ - function arrayIncludesWith(array, value, comparator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (comparator(value, array[index])) { - return true; - } - } - return false; - } - - /** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function arrayMap(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; - } - - /** - * Appends the elements of `values` to `array`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to append. - * @returns {Array} Returns `array`. - */ - function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; - - while (++index < length) { - array[offset + index] = values[index]; - } - return array; - } - - /** - * A specialized version of `_.reduce` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ - function arrayReduce(array, iteratee, accumulator, initAccum) { - var index = -1, - length = array == null ? 0 : array.length; - - if (initAccum && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; - } - - /** - * A specialized version of `_.reduceRight` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the last element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ - function arrayReduceRight(array, iteratee, accumulator, initAccum) { - var length = array == null ? 0 : array.length; - if (initAccum && length) { - accumulator = array[--length]; - } - while (length--) { - accumulator = iteratee(accumulator, array[length], length, array); - } - return accumulator; - } - - /** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ - function arraySome(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; - } - - /** - * Gets the size of an ASCII `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ - var asciiSize = baseProperty('length'); - - /** - * Converts an ASCII `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function asciiToArray(string) { - return string.split(''); - } - - /** - * Splits an ASCII `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ - function asciiWords(string) { - return string.match(reAsciiWord) || []; - } - - /** - * The base implementation of methods like `_.findKey` and `_.findLastKey`, - * without support for iteratee shorthands, which iterates over `collection` - * using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the found element or its key, else `undefined`. - */ - function baseFindKey(collection, predicate, eachFunc) { - var result; - eachFunc(collection, function(value, key, collection) { - if (predicate(value, key, collection)) { - result = key; - return false; - } - }); - return result; - } - - /** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; - } - - /** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseIndexOf(array, value, fromIndex) { - return value === value - ? strictIndexOf(array, value, fromIndex) - : baseFindIndex(array, baseIsNaN, fromIndex); - } - - /** - * This function is like `baseIndexOf` except that it accepts a comparator. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @param {Function} comparator The comparator invoked per element. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseIndexOfWith(array, value, fromIndex, comparator) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (comparator(array[index], value)) { - return index; - } - } - return -1; - } - - /** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ - function baseIsNaN(value) { - return value !== value; - } - - /** - * The base implementation of `_.mean` and `_.meanBy` without support for - * iteratee shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the mean. - */ - function baseMean(array, iteratee) { - var length = array == null ? 0 : array.length; - return length ? (baseSum(array, iteratee) / length) : NAN; - } - - /** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. - */ - function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; - } - - /** - * The base implementation of `_.propertyOf` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @returns {Function} Returns the new accessor function. - */ - function basePropertyOf(object) { - return function(key) { - return object == null ? undefined : object[key]; - }; - } - - /** - * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of - * `collection` as the initial value. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the accumulated value. - */ - function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, function(value, index, collection) { - accumulator = initAccum - ? (initAccum = false, value) - : iteratee(accumulator, value, index, collection); - }); - return accumulator; - } - - /** - * The base implementation of `_.sortBy` which uses `comparer` to define the - * sort order of `array` and replaces criteria objects with their corresponding - * values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ - function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; - } - - /** - * The base implementation of `_.sum` and `_.sumBy` without support for - * iteratee shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. - */ - function baseSum(array, iteratee) { - var result, - index = -1, - length = array.length; - - while (++index < length) { - var current = iteratee(array[index]); - if (current !== undefined) { - result = result === undefined ? current : (result + current); - } - } - return result; - } - - /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ - function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; - } - - /** - * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array - * of key-value pairs for `object` corresponding to the property names of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the key-value pairs. - */ - function baseToPairs(object, props) { - return arrayMap(props, function(key) { - return [key, object[key]]; - }); - } - - /** - * The base implementation of `_.unary` without support for storing metadata. - * - * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - */ - function baseUnary(func) { - return function(value) { - return func(value); - }; - } - - /** - * The base implementation of `_.values` and `_.valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. - */ - function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); - } - - /** - * Checks if a `cache` value for `key` exists. - * - * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function cacheHas(cache, key) { - return cache.has(key); - } - - /** - * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the first unmatched string symbol. - */ - function charsStartIndex(strSymbols, chrSymbols) { - var index = -1, - length = strSymbols.length; - - while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; - } - - /** - * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the last unmatched string symbol. - */ - function charsEndIndex(strSymbols, chrSymbols) { - var index = strSymbols.length; - - while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; - } - - /** - * Gets the number of `placeholder` occurrences in `array`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} placeholder The placeholder to search for. - * @returns {number} Returns the placeholder count. - */ - function countHolders(array, placeholder) { - var length = array.length, - result = 0; - - while (length--) { - if (array[length] === placeholder) { - ++result; - } - } - return result; - } - - /** - * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A - * letters to basic Latin letters. - * - * @private - * @param {string} letter The matched letter to deburr. - * @returns {string} Returns the deburred letter. - */ - var deburrLetter = basePropertyOf(deburredLetters); - - /** - * Used by `_.escape` to convert characters to HTML entities. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ - var escapeHtmlChar = basePropertyOf(htmlEscapes); - - /** - * Used by `_.template` to escape characters for inclusion in compiled string literals. - * - * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeStringChar(chr) { - return '\\' + stringEscapes[chr]; - } - - /** - * Gets the value at `key` of `object`. - * - * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ - function getValue(object, key) { - return object == null ? undefined : object[key]; - } - - /** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ - function hasUnicode(string) { - return reHasUnicode.test(string); - } - - /** - * Checks if `string` contains a word composed of Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a word is found, else `false`. - */ - function hasUnicodeWord(string) { - return reHasUnicodeWord.test(string); - } - - /** - * Converts `iterator` to an array. - * - * @private - * @param {Object} iterator The iterator to convert. - * @returns {Array} Returns the converted array. - */ - function iteratorToArray(iterator) { - var data, - result = []; - - while (!(data = iterator.next()).done) { - result.push(data.value); - } - return result; - } - - /** - * Converts `map` to its key-value pairs. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. - */ - function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; - } - - /** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - - /** - * Replaces all `placeholder` elements in `array` with an internal placeholder - * and returns an array of their indexes. - * - * @private - * @param {Array} array The array to modify. - * @param {*} placeholder The placeholder to replace. - * @returns {Array} Returns the new array of placeholder indexes. - */ - function replaceHolders(array, placeholder) { - var index = -1, - length = array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (value === placeholder || value === PLACEHOLDER) { - array[index] = PLACEHOLDER; - result[resIndex++] = index; - } - } - return result; - } - - /** - * Converts `set` to an array of its values. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. - */ - function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; +; +; +; +var isWebSocket = function (constructor) { + return constructor && constructor.CLOSING === 2; +}; +var isGlobalWebSocket = function () { + return typeof WebSocket !== 'undefined' && isWebSocket(WebSocket); +}; +var getDefaultOptions = function () { return ({ + constructor: isGlobalWebSocket() ? WebSocket : null, + maxReconnectionDelay: 10000, + minReconnectionDelay: 1500, + reconnectionDelayGrowFactor: 1.3, + connectionTimeout: 4000, + maxRetries: Infinity, + debug: false, +}); }; +var bypassProperty = function (src, dst, name) { + Object.defineProperty(dst, name, { + get: function () { return src[name]; }, + set: function (value) { src[name] = value; }, + enumerable: true, + configurable: true, }); - return result; - } - - /** - * Converts `set` to its value-value pairs. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the value-value pairs. - */ - function setToPairs(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = [value, value]; +}; +var initReconnectionDelay = function (config) { + return (config.minReconnectionDelay + Math.random() * config.minReconnectionDelay); +}; +var updateReconnectionDelay = function (config, previousDelay) { + var newDelay = previousDelay * config.reconnectionDelayGrowFactor; + return (newDelay > config.maxReconnectionDelay) + ? config.maxReconnectionDelay + : newDelay; +}; +var LEVEL_0_EVENTS = ['onopen', 'onclose', 'onmessage', 'onerror']; +var reassignEventListeners = function (ws, oldWs, listeners) { + Object.keys(listeners).forEach(function (type) { + listeners[type].forEach(function (_a) { + var listener = _a[0], options = _a[1]; + ws.addEventListener(type, listener, options); + }); }); - return result; - } - - /** - * A specialized version of `_.indexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function strictIndexOf(array, value, fromIndex) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (array[index] === value) { - return index; - } + if (oldWs) { + LEVEL_0_EVENTS.forEach(function (name) { + ws[name] = oldWs[name]; + }); } - return -1; - } - - /** - * A specialized version of `_.lastIndexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function strictLastIndexOf(array, value, fromIndex) { - var index = fromIndex + 1; - while (index--) { - if (array[index] === value) { - return index; - } +}; +var ReconnectingWebsocket = function (url, protocols, options) { + var _this = this; + if (options === void 0) { options = {}; } + var ws; + var connectingTimeout; + var reconnectDelay = 0; + var retriesCount = 0; + var shouldRetry = true; + var savedOnClose = null; + var listeners = {}; + // require new to construct + if (!(this instanceof ReconnectingWebsocket)) { + throw new TypeError("Failed to construct 'ReconnectingWebSocket': Please use the 'new' operator"); } - return index; - } - - /** - * Gets the number of symbols in `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the string size. - */ - function stringSize(string) { - return hasUnicode(string) - ? unicodeSize(string) - : asciiSize(string); - } - - /** - * Converts `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function stringToArray(string) { - return hasUnicode(string) - ? unicodeToArray(string) - : asciiToArray(string); - } - - /** - * Used by `_.unescape` to convert HTML entities to characters. - * - * @private - * @param {string} chr The matched character to unescape. - * @returns {string} Returns the unescaped character. - */ - var unescapeHtmlChar = basePropertyOf(htmlUnescapes); - - /** - * Gets the size of a Unicode `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ - function unicodeSize(string) { - var result = reUnicode.lastIndex = 0; - while (reUnicode.test(string)) { - ++result; + // Set config. Not using `Object.assign` because of IE11 + var config = getDefaultOptions(); + Object.keys(config) + .filter(function (key) { return options.hasOwnProperty(key); }) + .forEach(function (key) { return config[key] = options[key]; }); + if (!isWebSocket(config.constructor)) { + throw new TypeError('Invalid WebSocket constructor. Set `options.constructor`'); } - return result; - } - - /** - * Converts a Unicode `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function unicodeToArray(string) { - return string.match(reUnicode) || []; - } - - /** - * Splits a Unicode `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ - function unicodeWords(string) { - return string.match(reUnicodeWord) || []; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Create a new pristine `lodash` function using the `context` object. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Util - * @param {Object} [context=root] The context object. - * @returns {Function} Returns a new `lodash` function. - * @example - * - * _.mixin({ 'foo': _.constant('foo') }); - * - * var lodash = _.runInContext(); - * lodash.mixin({ 'bar': lodash.constant('bar') }); - * - * _.isFunction(_.foo); - * // => true - * _.isFunction(_.bar); - * // => false - * - * lodash.isFunction(lodash.foo); - * // => false - * lodash.isFunction(lodash.bar); - * // => true - * - * // Create a suped-up `defer` in Node.js. - * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; - */ - var runInContext = (function runInContext(context) { - context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); - - /** Built-in constructor references. */ - var Array = context.Array, - Date = context.Date, - Error = context.Error, - Function = context.Function, - Math = context.Math, - Object = context.Object, - RegExp = context.RegExp, - String = context.String, - TypeError = context.TypeError; - - /** Used for built-in method references. */ - var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype; - - /** Used to detect overreaching core-js shims. */ - var coreJsData = context['__core-js_shared__']; - - /** Used to resolve the decompiled source of functions. */ - var funcToString = funcProto.toString; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** Used to generate unique IDs. */ - var idCounter = 0; - - /** Used to detect methods masquerading as native. */ - var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; - }()); - + var log = config.debug ? function () { + var params = []; + for (var _i = 0; _i < arguments.length; _i++) { + params[_i] = arguments[_i]; + } + return console.log.apply(console, ['RWS:'].concat(params)); + } : function () { }; /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. + * Not using dispatchEvent, otherwise we must use a DOM Event object + * Deferred because we want to handle the close event before this */ - var nativeObjectToString = objectProto.toString; - - /** Used to infer the `Object` constructor. */ - var objectCtorString = funcToString.call(Object); - - /** Used to restore the original `_` reference in `_.noConflict`. */ - var oldDash = root._; - - /** Used to detect if a method is native. */ - var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' - ); - - /** Built-in value references. */ - var Buffer = moduleExports ? context.Buffer : undefined, - Symbol = context.Symbol, - Uint8Array = context.Uint8Array, - allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, - getPrototype = overArg(Object.getPrototypeOf, Object), - objectCreate = Object.create, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - splice = arrayProto.splice, - spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, - symIterator = Symbol ? Symbol.iterator : undefined, - symToStringTag = Symbol ? Symbol.toStringTag : undefined; - - var defineProperty = (function() { - try { - var func = getNative(Object, 'defineProperty'); - func({}, '', {}); - return func; - } catch (e) {} - }()); - - /** Mocked built-ins. */ - var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, - ctxNow = Date && Date.now !== root.Date.now && Date.now, - ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeCeil = Math.ceil, - nativeFloor = Math.floor, - nativeGetSymbols = Object.getOwnPropertySymbols, - nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, - nativeIsFinite = context.isFinite, - nativeJoin = arrayProto.join, - nativeKeys = overArg(Object.keys, Object), - nativeMax = Math.max, - nativeMin = Math.min, - nativeNow = Date.now, - nativeParseInt = context.parseInt, - nativeRandom = Math.random, - nativeReverse = arrayProto.reverse; + var emitError = function (code, msg) { return setTimeout(function () { + var err = new Error(msg); + err.code = code; + if (Array.isArray(listeners.error)) { + listeners.error.forEach(function (_a) { + var fn = _a[0]; + return fn(err); + }); + } + if (ws.onerror) { + ws.onerror(err); + } + }, 0); }; + var handleClose = function () { + log('handleClose', { shouldRetry: shouldRetry }); + retriesCount++; + log('retries count:', retriesCount); + if (retriesCount > config.maxRetries) { + emitError('EHOSTDOWN', 'Too many failed connection attempts'); + return; + } + if (!reconnectDelay) { + reconnectDelay = initReconnectionDelay(config); + } + else { + reconnectDelay = updateReconnectionDelay(config, reconnectDelay); + } + log('handleClose - reconnectDelay:', reconnectDelay); + if (shouldRetry) { + setTimeout(connect, reconnectDelay); + } + }; + var connect = function () { + if (!shouldRetry) { + return; + } + log('connect'); + var oldWs = ws; + var wsUrl = (typeof url === 'function') ? url() : url; + ws = new config.constructor(wsUrl, protocols); + connectingTimeout = setTimeout(function () { + log('timeout'); + ws.close(); + emitError('ETIMEDOUT', 'Connection timeout'); + }, config.connectionTimeout); + log('bypass properties'); + for (var key in ws) { + // @todo move to constant + if (['addEventListener', 'removeEventListener', 'close', 'send'].indexOf(key) < 0) { + bypassProperty(ws, _this, key); + } + } + ws.addEventListener('open', function () { + clearTimeout(connectingTimeout); + log('open'); + reconnectDelay = initReconnectionDelay(config); + log('reconnectDelay:', reconnectDelay); + retriesCount = 0; + }); + ws.addEventListener('close', handleClose); + reassignEventListeners(ws, oldWs, listeners); + // because when closing with fastClose=true, it is saved and set to null to avoid double calls + ws.onclose = ws.onclose || savedOnClose; + savedOnClose = null; + }; + log('init'); + connect(); + this.close = function (code, reason, _a) { + if (code === void 0) { code = 1000; } + if (reason === void 0) { reason = ''; } + var _b = _a === void 0 ? {} : _a, _c = _b.keepClosed, keepClosed = _c === void 0 ? false : _c, _d = _b.fastClose, fastClose = _d === void 0 ? true : _d, _e = _b.delay, delay = _e === void 0 ? 0 : _e; + log('close - params:', { reason: reason, keepClosed: keepClosed, fastClose: fastClose, delay: delay, retriesCount: retriesCount, maxRetries: config.maxRetries }); + shouldRetry = !keepClosed && retriesCount <= config.maxRetries; + if (delay) { + reconnectDelay = delay; + } + ws.close(code, reason); + if (fastClose) { + var fakeCloseEvent_1 = { + code: code, + reason: reason, + wasClean: true, + }; + // execute close listeners soon with a fake closeEvent + // and remove them from the WS instance so they + // don't get fired on the real close. + handleClose(); + ws.removeEventListener('close', handleClose); + // run and remove level2 + if (Array.isArray(listeners.close)) { + listeners.close.forEach(function (_a) { + var listener = _a[0], options = _a[1]; + listener(fakeCloseEvent_1); + ws.removeEventListener('close', listener, options); + }); + } + // run and remove level0 + if (ws.onclose) { + savedOnClose = ws.onclose; + ws.onclose(fakeCloseEvent_1); + ws.onclose = null; + } + } + }; + this.send = function (data) { + ws.send(data); + }; + this.addEventListener = function (type, listener, options) { + if (Array.isArray(listeners[type])) { + if (!listeners[type].some(function (_a) { + var l = _a[0]; + return l === listener; + })) { + listeners[type].push([listener, options]); + } + } + else { + listeners[type] = [[listener, options]]; + } + ws.addEventListener(type, listener, options); + }; + this.removeEventListener = function (type, listener, options) { + if (Array.isArray(listeners[type])) { + listeners[type] = listeners[type].filter(function (_a) { + var l = _a[0]; + return l !== listener; + }); + } + ws.removeEventListener(type, listener, options); + }; +}; +module.exports = ReconnectingWebsocket; - /* Built-in method references that are verified to be native. */ - var DataView = getNative(context, 'DataView'), - Map = getNative(context, 'Map'), - Promise = getNative(context, 'Promise'), - Set = getNative(context, 'Set'), - WeakMap = getNative(context, 'WeakMap'), - nativeCreate = getNative(Object, 'create'); - /** Used to store function metadata. */ - var metaMap = WeakMap && new WeakMap; +/***/ }), +/* 15 */ +/***/ (function(module, exports) { - /** Used to lookup unminified function names. */ - var realNames = {}; +module.exports = jQuery; - /** Used to detect maps, sets, and weakmaps. */ - var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { - /** Used to convert symbols to primitives and strings. */ - var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; +var require;/*global dallinger, require, settings */ +/*jshint esversion: 6 */ - /*------------------------------------------------------------------------*/ +(function (dallinger, require, settings) { - /** - * Creates a `lodash` object which wraps `value` to enable implicit method - * chain sequences. Methods that operate on and return arrays, collections, - * and functions can be chained together. Methods that retrieve a single value - * or may return a primitive value will automatically end the chain sequence - * and return the unwrapped value. Otherwise, the value must be unwrapped - * with `_#value`. - * - * Explicit chain sequences, which must be unwrapped with `_#value`, may be - * enabled using `_.chain`. - * - * The execution of chained methods is lazy, that is, it's deferred until - * `_#value` is implicitly or explicitly called. - * - * Lazy evaluation allows several methods to support shortcut fusion. - * Shortcut fusion is an optimization to merge iteratee calls; this avoids - * the creation of intermediate arrays and can greatly reduce the number of - * iteratee executions. Sections of a chain sequence qualify for shortcut - * fusion if the section is applied to an array and iteratees accept only - * one argument. The heuristic for whether a section qualifies for shortcut - * fusion is subject to change. - * - * Chaining is supported in custom builds as long as the `_#value` method is - * directly or indirectly included in the build. - * - * In addition to lodash methods, wrappers have `Array` and `String` methods. - * - * The wrapper `Array` methods are: - * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` - * - * The wrapper `String` methods are: - * `replace` and `split` - * - * The wrapper methods that support shortcut fusion are: - * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, - * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` - * - * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, - * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, - * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, - * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, - * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, - * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, - * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, - * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, - * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, - * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, - * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, - * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, - * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, - * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, - * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, - * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, - * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, - * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, - * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, - * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, - * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, - * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, - * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, - * `zipObject`, `zipObjectDeep`, and `zipWith` - * - * The wrapper methods that are **not** chainable by default are: - * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, - * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, - * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, - * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, - * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, - * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, - * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, - * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, - * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, - * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, - * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, - * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, - * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, - * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, - * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, - * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, - * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, - * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, - * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, - * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, - * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, - * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, - * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, - * `upperFirst`, `value`, and `words` - * - * @name _ - * @constructor - * @category Seq - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var wrapped = _([1, 2, 3]); - * - * // Returns an unwrapped value. - * wrapped.reduce(_.add); - * // => 6 - * - * // Returns a wrapped value. - * var squares = wrapped.map(square); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ - function lodash(value) { - if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { - if (value instanceof LodashWrapper) { - return value; - } - if (hasOwnProperty.call(value, '__wrapped__')) { - return wrapperClone(value); - } - } - return new LodashWrapper(value); - } +var grid = __webpack_require__(7); +var position = __webpack_require__(12); +var Mousetrap = __webpack_require__(13); +var ReconnectingWebSocket = __webpack_require__(14); +var $ = __webpack_require__(15); +var gaussian = __webpack_require__(11); +var Color = __webpack_require__(10); +var Identicon = __webpack_require__(9); +var md5 = __webpack_require__(1); +var itemlib = __webpack_require__ (8); - /** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} proto The object to inherit from. - * @returns {Object} Returns the new object. - */ - var baseCreate = (function() { - function object() {} - return function(proto) { - if (!isObject(proto)) { - return {}; - } - if (objectCreate) { - return objectCreate(proto); - } - object.prototype = proto; - var result = new object; - object.prototype = undefined; - return result; - }; - }()); +function coordsToIdx(x, y, columns) { + return y * columns + x; +} - /** - * The function whose prototype chain sequence wrappers inherit from. - * - * @private - */ - function baseLodash() { - // No operation performed. - } +function animateColor(color) { + if (settings.background_animation) { + rand = Math.random() * 0.02; + } else { + rand = 0.01; + } + return [ + color[0] * 0.95 + rand, + color[1] * 0.95 + rand, + color[2] * 0.95 + rand + ]; +} - /** - * The base constructor for creating `lodash` wrapper objects. - * - * @private - * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable explicit method chain sequences. - */ - function LodashWrapper(value, chainAll) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__chain__ = !!chainAll; - this.__index__ = 0; - this.__values__ = undefined; +function positionsAreEqual(a, b) { + // Items with null positions are never co-located + if (a === null || b === null) { + return false; + } + return a[0] === b[0] && a[1] === b[1]; +} + +class Section { + // Represents the currently visible section (window) of the grid + + constructor(data, left, top) { + this.left = left; + this.top = top; + this.columns = settings.window_columns; + this.rows = settings.window_rows; + this.data = []; + this.textures = []; + // build data array for just this section + for (var j = 0; j < this.rows; j++) { + for (var i = 0; i < this.columns; i++) { + this.data.push(data[this.sectionCoordsToGridIdx(i, j)]); + this.textures.push(0); + } } + } - /** - * By default, the template delimiters used by lodash are like those in - * embedded Ruby (ERB) as well as ES2015 template strings. Change the - * following template settings to use alternative delimiters. - * - * @static - * @memberOf _ - * @type {Object} - */ - lodash.templateSettings = { + gridCoordsToSectionIdx(x, y) { + // Convert grid coordinates to section data array index + return (y - this.top) * this.columns + (x - this.left); + } - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'escape': reEscape, + sectionCoordsToGridIdx(x, y) { + // Convert section coordinates to grid data array index + return coordsToIdx(this.left + x, this.top + y, settings.columns); + } - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'evaluate': reEvaluate, + plot(x, y, color, texture) { + // Set color at position (x, y) in full-grid coordinates. + if (x >= this.left && x < this.left + this.columns) { + if (y >= this.top && y < this.top + this.rows) { + this.data[this.gridCoordsToSectionIdx(x, y)] = color; + if (texture !== undefined ){ + this.textures[this.gridCoordsToSectionIdx(x, y)] = texture; + } + background[coordsToIdx(x, y, settings.columns)] = color; + } + } + } - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'interpolate': reInterpolate, + map(func) { + // For each cell, call func with (x, y, color) to get the new color + for (var j = 0; j < this.rows; j++) { + for (var i = 0; i < this.columns; i++) { + var idx = coordsToIdx(i, j, this.columns); + this.data[idx] = Reflect.apply( + func, this, [this.left + i, this.top + j, this.data[idx]]); + } + } + } +} - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type {string} - */ - 'variable': '', +var background = [], color; +for (var j = 0; j < settings.rows; j++) { + for (var i = 0; i < settings.columns; i++) { + color = [0, 0, 0]; + for (var k = 0; k < 15; k++) { + color = animateColor(color); + } + background.push(color); + } +} - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type {Object} - */ - 'imports': { +var initialSection = new Section(background, 0, 0); - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type {Function} - */ - '_': lodash - } - }; +var INVISIBLE_COLOR = [0.66, 0.66, 0.66]; +var CHANNEL = "griduniverse"; +var CONTROL_CHANNEL = "griduniverse_ctrl"; - // Ensure wrappers are instances of `baseLodash`. - lodash.prototype = baseLodash.prototype; - lodash.prototype.constructor = lodash; +var pixels = grid(initialSection.data, initialSection.textures, { + rows: settings.window_rows, + columns: settings.window_columns, + size: settings.block_size, + padding: settings.padding, + background: [0.1, 0.1, 0.1], + formatted: true +}); - LodashWrapper.prototype = baseCreate(baseLodash.prototype); - LodashWrapper.prototype.constructor = LodashWrapper; +var mouse = position(pixels.canvas); - /*------------------------------------------------------------------------*/ +var isSpectator = false; +var start = performance.now(); +var gridItems = new itemlib.GridItems(); +var walls = []; +var wall_map = {}; +var transitionsSeen = new Set(); +var rand; - /** - * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. - * - * @private - * @constructor - * @param {*} value The value to wrap. - */ - function LazyWrapper(value) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__dir__ = 1; - this.__filtered__ = false; - this.__iteratees__ = []; - this.__takeCount__ = MAX_ARRAY_LENGTH; - this.__views__ = []; +var name2idx = function (name) { + var names = settings.player_color_names; + for (var idx=0; idx < names.length; idx++) { + if (names[idx] === name) { + return idx; } + } +}; - /** - * Creates a clone of the lazy wrapper object. - * - * @private - * @name clone - * @memberOf LazyWrapper - * @returns {Object} Returns the cloned `LazyWrapper` object. - */ - function lazyClone() { - var result = new LazyWrapper(this.__wrapped__); - result.__actions__ = copyArray(this.__actions__); - result.__dir__ = this.__dir__; - result.__filtered__ = this.__filtered__; - result.__iteratees__ = copyArray(this.__iteratees__); - result.__takeCount__ = this.__takeCount__; - result.__views__ = copyArray(this.__views__); - return result; +var color2idx = function (color) { + var colors = settings.player_colors; + var value = color.join(','); + for (var idx=0; idx < colors.length; idx++) { + if (colors[idx].join(',') === value) { + return idx; } + } +}; - /** - * Reverses the direction of lazy iteration. - * - * @private - * @name reverse - * @memberOf LazyWrapper - * @returns {Object} Returns the new reversed `LazyWrapper` object. - */ - function lazyReverse() { - if (this.__filtered__) { - var result = new LazyWrapper(this); - result.__dir__ = -1; - result.__filtered__ = true; - } else { - result = this.clone(); - result.__dir__ *= -1; - } - return result; - } +var color2name = function (color) { + var idx = color2idx(color); + return settings.player_color_names[idx]; +} - /** - * Extracts the unwrapped value from its lazy wrapper. - * - * @private - * @name value - * @memberOf LazyWrapper - * @returns {*} Returns the unwrapped value. - */ - function lazyValue() { - var array = this.__wrapped__.value(), - dir = this.__dir__, - isArr = isArray(array), - isRight = dir < 0, - arrLength = isArr ? array.length : 0, - view = getView(0, arrLength, this.__views__), - start = view.start, - end = view.end, - length = end - start, - index = isRight ? end : (start - 1), - iteratees = this.__iteratees__, - iterLength = iteratees.length, - resIndex = 0, - takeCount = nativeMin(length, this.__takeCount__); - if (!isArr || (!isRight && arrLength == length && takeCount == length)) { - return baseWrapperValue(array, this.__actions__); - } - var result = []; +var Wall = function (settings) { + if (!(this instanceof Wall)) { + return new Wall(); + } + this.position = settings.position; + this.color = settings.color; + return this; +}; + +var Player = function (settings, dimness) { + if (!(this instanceof Player)) { + return new Player(); + } + this.id = settings.id; + this.position = settings.position; + this.positionInSync = true; + this.color = settings.color; + this.motion_auto = settings.motion_auto; + this.motion_direction = settings.motion_direction; + this.motion_speed_limit = settings.motion_speed_limit; + this.motion_timestamp = settings.motion_timestamp; + this.score = settings.score; + this.payoff = settings.payoff; + this.name = settings.name; + this.identity_visible = settings.identity_visible; + this.dimness = dimness; + this.replaceItem(settings.current_item); + return this; +}; + +Player.prototype.move = function(direction) { - outer: - while (length-- && resIndex < takeCount) { - index += dir; + function _isCrossable(position) { + const hasWall = ! _.isUndefined(wall_map[[position[1], position[0]]]); + if (hasWall) { + return false; + } + const itemHere = gridItems.atPosition(position); + return _.isNull(itemHere) || itemHere.crossable; + } - var iterIndex = -1, - value = array[index]; + this.motion_direction = direction; - while (++iterIndex < iterLength) { - var data = iteratees[iterIndex], - iteratee = data.iteratee, - type = data.type, - computed = iteratee(value); + var ts = performance.now() - start, + waitTime = 1000 / this.motion_speed_limit; - if (type == LAZY_MAP_FLAG) { - value = computed; - } else if (!computed) { - if (type == LAZY_FILTER_FLAG) { - continue outer; - } else { - break outer; - } - } + if (ts > this.motion_timestamp + waitTime) { + var newPosition = this.position.slice(); + + switch (direction) { + case "up": + if (this.position[0] > 0) { + newPosition[0] -= 1; } - result[resIndex++] = value; - } - return result; - } + break; - // Ensure `LazyWrapper` is an instance of `baseLodash`. - LazyWrapper.prototype = baseCreate(baseLodash.prototype); - LazyWrapper.prototype.constructor = LazyWrapper; + case "down": + if (this.position[0] < settings.rows - 1) { + newPosition[0] += 1; + } + break; - /*------------------------------------------------------------------------*/ + case "left": + if (this.position[1] > 0) { + newPosition[1] -= 1; + } + break; - /** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function Hash(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; + case "right": + if (this.position[1] < settings.columns - 1) { + newPosition[1] += 1; + } + break; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } + default: + console.log("Direction not recognized."); } - /** - * Removes all key-value entries from the hash. - * - * @private - * @name clear - * @memberOf Hash - */ - function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; + if (_isCrossable(newPosition) && (!players.isPlayerAt(newPosition) || settings.player_overlap)) { + this.position = newPosition; + this.motion_timestamp = ts; + return true; } + } + return false; +}; - /** - * Removes `key` and its value from the hash. - * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; + +Player.prototype.replaceItem = function(item) { + if (item && !(item instanceof itemlib.Item)) { + item = new itemlib.Item(item.id, item.item_id, item.maturity, item.remaining_uses) + } + this.currentItem = item; + displayWhatEgoPlayerIsCarrying(item); +}; + +Player.prototype.getTransition = function () { + var transition; + var player_item = this.currentItem; + var position = this.position; + var item_at_pos = gridItems.atPosition(position); + var transition_id = (player_item && player_item.itemId || '') + '|' + (item_at_pos && item_at_pos.itemId || ''); + var last_transition_id = 'last_' + transition_id; + if (item_at_pos && item_at_pos.remaining_uses == 1) { + transition = settings.transition_config[last_transition_id]; + if (transition) { + transition_id = last_transition_id; } + } + if (!transition) { + transition = settings.transition_config[transition_id]; + } + if (!transition) { + return null; + } + return {id: transition_id, transition: transition}; +} - /** - * Gets the hash value for `key`. - * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; +var playerSet = (function () { + + var PlayerSet = function (settings) { + if (!(this instanceof PlayerSet)) { + return new PlayerSet(settings); + } + + this._players = {}; + this.ego_id = settings.ego_id; + }; + + PlayerSet.prototype.isPlayerAt = function (position) { + var id, player; + + for (id in this._players) { + if (this._players.hasOwnProperty(id)) { + player = this._players[id]; + if (positionsAreEqual(position, player.position)) { + return true; + } + } + } + return false; + }; + + PlayerSet.prototype.drawToGrid = function (grid) { + var player, + id, + minScore, + maxScore, + d, + color, + player_color; + if (settings.score_visible) { + minScore = this.minScore(); + maxScore = this.maxScore(); + } + + for (id in this._players) { + if (this._players.hasOwnProperty(id)) { + player = this._players[id]; + /* It's unlikely that auto motion will keep identical pace to server-side auto-motion */ + /* this should be implemented either all on server or all on client */ + if (player.motion_auto) { + player.move(player.motion_direction); + } + if (id === this.ego_id || settings.others_visible) { + player_color = settings.player_colors[name2idx(player.color)]; + if (player.identity_visible) { + color = player_color; + } else { + color = (id === this.ego_id) ? Color.rgb(player_color).desaturate(0.6).rgb().array() : INVISIBLE_COLOR; + } + if (settings.score_visible) { + if (maxScore-minScore > 0) { + d = 0.75 * (1 - (player.score-minScore)/(maxScore-minScore)); + } else { + d = 0.375; + } + color = Color.rgb(player_color).desaturate(d).rgb().array(); + } else { + color = player_color; + } + var texture = 0; + if (settings.use_identicons) { + texture = parseInt(id, 10); + } + grid.plot(player.position[1], player.position[0], color, texture); + if (id === this.ego_id) { + store.set("color", color2name(color)); + } + } + } + } + }; + + PlayerSet.prototype.nearest = function (row, column) { + var distances = [], + distance, + player, + id; + + for (id in this._players) { + if (this._players.hasOwnProperty(id)) { + player = this._players[id]; + if (player.hasOwnProperty('position')) { + distance = Math.abs(row - player.position[0]) + Math.abs(column - player.position[1]); + distances.push({"player": player, "distance": distance}); + } + } } - return hasOwnProperty.call(data, key) ? data[key] : undefined; - } - /** - * Checks if a hash value for `key` exists. - * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function hashHas(key) { - var data = this.__data__; - return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); - } + distances.sort(function (a, b) { + return a.distance - b.distance; + }); - /** - * Sets the hash `key` to `value`. - * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ - function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; - return this; - } + return distances[0].player; + }; - // Add methods to `Hash`. - Hash.prototype.clear = hashClear; - Hash.prototype['delete'] = hashDelete; - Hash.prototype.get = hashGet; - Hash.prototype.has = hashHas; - Hash.prototype.set = hashSet; + PlayerSet.prototype.ego = function () { + return this.get(this.ego_id); + }; - /*------------------------------------------------------------------------*/ + PlayerSet.prototype.get = function (id) { + return this._players[id]; + }; - /** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function ListCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; + PlayerSet.prototype.count = function () { + return Object.keys(this._players).length; + }; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } + PlayerSet.prototype.update = function (allPlayersData) { + var freshPlayerData, + existingPlayer, + i; - /** - * Removes all key-value entries from the list cache. - * - * @private - * @name clear - * @memberOf ListCache - */ - function listCacheClear() { - this.__data__ = []; - this.size = 0; - } + for (i = 0; i < allPlayersData.length; i++) { + freshPlayerData = allPlayersData[i]; + existingPlayer = this._players[freshPlayerData.id]; + if (existingPlayer && existingPlayer.id === this.ego_id) { - /** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); + /* Don't override current player motion timestamp */ + freshPlayerData.motion_timestamp = existingPlayer.motion_timestamp; - if (index < 0) { - return false; + // Only override position from server if tremble is enabled, + // or if we know the Player's position is out of sync with the server. + // Otherwise, the ego player's motion is constantly jittery. + if (settings.motion_tremble_rate === 0 && existingPlayer.positionInSync) { + freshPlayerData.position = existingPlayer.position; + } else { + console.log("Overriding position from server!"); + } + } + var last_dimness = 1; + if (this._players[freshPlayerData.id] !== undefined) { + last_dimness = this._players[freshPlayerData.id].dimness; + } + this._players[freshPlayerData.id] = new Player(freshPlayerData, last_dimness); } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); + }; + + PlayerSet.prototype.startScheduledAutosyncOfEgoPosition = function () { + var self = this; + setInterval(function () { + var ego = self.ego(); + if (ego) { + ego.positionInSync = false; + console.log("Scheduled marking of (" + ego.id + ") as out of sync with server."); + } + }, 5000); + }; + + PlayerSet.prototype.maxScore = function () { + var id, + maxScore = 0; + for (id in this._players) { + if (this._players[id].score > maxScore) { + maxScore = this._players[id].score; + } + } + return maxScore; + }; + + PlayerSet.prototype.minScore = function () { + var id, + minScore = Infinity; + for (id in this._players) { + if (this._players[id].score < minScore) { + minScore = this._players[id].score; + } + } + return minScore; + }; + + PlayerSet.prototype.each = function (callback) { + var i = 0; + for (var id in this._players) { + if (this._players.hasOwnProperty(id)) { + callback(i, this._players[id]); + i++; + } } - --this.size; - return true; - } + }; - /** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); + PlayerSet.prototype.group_scores = function () { + var group_scores = {}; - return index < 0 ? undefined : data[index][1]; - } + this.each(function (i, player) { + var color_name = player.color; + var cur_score = group_scores[color_name] || 0; + group_scores[color_name] = cur_score + Math.round(player.score); + }); - /** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; - } + var group_order = Object.keys(group_scores).sort(function (a, b) { + return group_scores[a] > group_scores[b] ? -1 : (group_scores[a] < group_scores[b] ? 1 : 0); + }); - /** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ - function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); + return group_order.map(function(color_name) { + return {name: color_name, score: group_scores[color_name]}; + }); + }; - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; - } + PlayerSet.prototype.player_scores = function () { + var player_order = []; - // Add methods to `ListCache`. - ListCache.prototype.clear = listCacheClear; - ListCache.prototype['delete'] = listCacheDelete; - ListCache.prototype.get = listCacheGet; - ListCache.prototype.has = listCacheHas; - ListCache.prototype.set = listCacheSet; + this.each(function(i, player) { + player_order.push({id: player.id, name: player.name, score:player.score}); + }); - /*------------------------------------------------------------------------*/ + player_order = player_order.sort(function (a, b) { + return a.score > b.score ? -1 : (a.score < b.score ? 1 : 0); + }); + + return player_order; + }; + + return PlayerSet; +}()); + +var GUSocket = (function () { + var makeSocket = function (endpoint, channel, tolerance) { + var ws_scheme = (window.location.protocol === "https:") ? 'wss://' : 'ws://', + app_root = ws_scheme + location.host + '/', + socket; + + socket = new ReconnectingWebSocket( + app_root + endpoint + "?channel=" + channel + "&tolerance=" + tolerance + ); + socket.debug = true; - /** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function MapCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; + return socket; + }; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } + var dispatch = function (self, event) { + var marker = self.broadcastChannel + ':'; + if (event.data.indexOf(marker) !== 0) { + console.log( + "Message was not on channel " + self.broadcastChannel + ". Ignoring."); + return; + } + var msg = JSON.parse(event.data.substring(marker.length)); - /** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ - function mapCacheClear() { - this.size = 0; - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; - } + var callback = self.callbackMap[msg.type]; + if (typeof callback !== 'undefined') { + callback(msg); + } else { + console.log("Unrecognized message type " + msg.type + ' from backend.'); + } + }; - /** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. + /* + * Public API */ - function mapCacheDelete(key) { - var result = getMapData(this, key)['delete'](key); - this.size -= result ? 1 : 0; - return result; - } + var Socket = function (settings) { + if (!(this instanceof Socket)) { + return new Socket(settings); + } - /** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function mapCacheGet(key) { - return getMapData(this, key).get(key); - } + var self = this, + isOpen = $.Deferred(), + tolerance = typeof(settings.lagTolerance) !== 'undefined' ? settings.lagTolerance : 0.1; - /** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function mapCacheHas(key) { - return getMapData(this, key).has(key); - } + this.broadcastChannel = settings.broadcast; + this.controlChannel = settings.control; + this.callbackMap = settings.callbackMap; - /** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ - function mapCacheSet(key, value) { - var data = getMapData(this, key), - size = data.size; - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; - } + this.socket = makeSocket( + settings.endpoint, this.broadcastChannel, tolerance); - // Add methods to `MapCache`. - MapCache.prototype.clear = mapCacheClear; - MapCache.prototype['delete'] = mapCacheDelete; - MapCache.prototype.get = mapCacheGet; - MapCache.prototype.has = mapCacheHas; - MapCache.prototype.set = mapCacheSet; + this.socket.onmessage = function (event) { + dispatch(self, event); + }; + }; - /*------------------------------------------------------------------------*/ + Socket.prototype.open = function () { + var isOpen = $.Deferred(); - /** - * - * Creates an array cache object to store unique values. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ - function SetCache(values) { - var index = -1, - length = values == null ? 0 : values.length; + this.socket.onopen = function (event) { + isOpen.resolve(); + }; - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); - } - } + return isOpen; + }; - /** - * Adds `value` to the array cache. - * - * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. - */ - function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; - } + Socket.prototype.send = function (data) { + var msg = JSON.stringify(data), + channel = this.controlChannel; - /** - * Checks if `value` is in the array cache. - * - * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. - */ - function setCacheHas(value) { - return this.__data__.has(value); - } + console.log("Sending message to the " + channel + " channel: " + msg); + this.socket.send(channel + ':' + msg); + }; - // Add methods to `SetCache`. - SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; - SetCache.prototype.has = setCacheHas; + Socket.prototype.broadcast = function (data) { + var msg = JSON.stringify(data), + channel = this.broadcastChannel; - /*------------------------------------------------------------------------*/ + console.log("Broadcasting message to the " + channel + " channel: " + msg); + this.socket.send(channel + ':' + msg); + }; - /** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ - function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; - } + return Socket; +}()); - /** - * Removes all key-value entries from the stack. - * - * @private - * @name clear - * @memberOf Stack - */ - function stackClear() { - this.__data__ = new ListCache; - this.size = 0; - } +// ego will be updated on page load +var players = playerSet({'ego_id': undefined}); - /** - * Removes `key` and its value from the stack. - * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ - function stackDelete(key) { - var data = this.__data__, - result = data['delete'](key); +pixels.canvas.style.marginLeft = window.innerWidth * 0.03 / 2 + "px"; +pixels.canvas.style.marginTop = window.innerHeight * 0.04 / 2 + "px"; +document.body.style.transition = "0.3s all"; +document.body.style.background = "#ffffff"; - this.size = data.size; - return result; - } +var startTime = performance.now(); - /** - * Gets the stack value for `key`. - * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ - function stackGet(key) { - return this.__data__.get(key); - } +pixels.frame(function() { + // Update the background. + var ego = players.ego(), + w = getWindowPosition(), + section = new Section(background, w.left, w.top), + dimness, + rescaling, + x, y; - /** - * Checks if a stack value for `key` exists. - * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ - function stackHas(key) { - return this.__data__.has(key); - } + // Animate background for each visible cell + section.map(function(x, y, color) { + var newColor = animateColor(color); + background[coordsToIdx(x, y, settings.columns)] = newColor; + return newColor; + }); - /** - * Sets the stack `key` to `value`. - * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. - */ - function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); + for (const [position, item] of gridItems.entries()) { + if (players.isPlayerAt(position)) { + if (!item.interactive) { + // Non-interactive items get consumed immediately + gridItems.remove(position); } - data.set(key, value); - this.size = data.size; - return this; + } else { + section.plot(position[1], position[0], item.color); } + } - // Add methods to `Stack`. - Stack.prototype.clear = stackClear; - Stack.prototype['delete'] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; + // Draw the players: + players.drawToGrid(section); - /*------------------------------------------------------------------------*/ + // Show info about the item the current player + // is sharing a square with: + if (! _.isUndefined(ego)) { + updateItemInfoWindow(ego, gridItems); + } - /** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ - function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), - isArg = !isArr && isArguments(value), - isBuff = !isArr && !isArg && isBuffer(value), - isType = !isArr && !isArg && !isBuff && isTypedArray(value), - skipIndexes = isArr || isArg || isBuff || isType, - result = skipIndexes ? baseTimes(value.length, String) : [], - length = result.length; + // Add the Gaussian mask. + var elapsedTime = performance.now() - startTime; + var visibilityNow = clamp( + (settings.visibility * elapsedTime) / (1000 * settings.visibility_ramp_time), + 3, + settings.visibility + ); + if (settings.highlightEgo) { + visibilityNow = Math.min(visibilityNow, 4); + } + var g = gaussian(0, Math.pow(visibilityNow, 2)); + rescaling = 1 / g.pdf(0); - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && ( - // Safari 9 has enumerable `arguments.length` in strict mode. - key == 'length' || - // Node.js 0.10 has enumerable non-index properties on buffers. - (isBuff && (key == 'offset' || key == 'parent')) || - // PhantomJS 2 has enumerable non-index properties on typed arrays. - (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || - // Skip index properties. - isIndex(key, length) - ))) { - result.push(key); - } - } - return result; + if (typeof ego !== "undefined") { + x = ego.position[1]; + y = ego.position[0]; + } else { + x = 1e100; + y = 1e100; + } + section.map(function(i, j, color) { + var newColor; + // Draw walls + if (settings.walls_visible) { + color = wall_map[[i,j]] || color; } - - /** - * A specialized version of `_.sample` for arrays. - * - * @private - * @param {Array} array The array to sample. - * @returns {*} Returns the random element. - */ - function arraySample(array) { - var length = array.length; - return length ? array[baseRandom(0, length - 1)] : undefined; + // Add Blur + players.each(function (i, player) { + dimness = g.pdf(distance(y, x, player.position[0], player.position[1])) * rescaling; + player["dimness"] = dimness; + }); + newColor = color; + if (!isSpectator) { + dimness = g.pdf(distance(x, y, i, j)) * rescaling; + newColor = [ + color[0] * dimness, + color[1] * dimness, + color[2] * dimness + ]; } + return newColor; + }); + pixels.update(section.data, section.textures); +}); - /** - * A specialized version of `_.sampleSize` for arrays. - * - * @private - * @param {Array} array The array to sample. - * @param {number} n The number of elements to sample. - * @returns {Array} Returns the random elements. - */ - function arraySampleSize(array, n) { - return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); - } +function clamp(val, min, max) { + return Math.max(min, Math.min(max, val)); +} - /** - * A specialized version of `_.shuffle` for arrays. - * - * @private - * @param {Array} array The array to shuffle. - * @returns {Array} Returns the new shuffled array. - */ - function arrayShuffle(array) { - return shuffleSelf(copyArray(array)); +function distance(x, y, xx, yy) { + return Math.sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y)); +} + +function arraysEqual(arr1, arr2) { + for (var i = arr1.length; i--; ) { + if (arr1[i] !== arr2[i]) { + return false; } + } + return true; +} - /** - * This function is like `assignValue` except that it doesn't assign - * `undefined` values. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignMergeValue(object, key, value) { - if ((value !== undefined && !eq(object[key], value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); +function arraySearch(arr, val) { + for (var i = 0; i < arr.length; i++) { + if (arraysEqual(arr[i], val)) { + return i; } } + return false; +} - /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); - } +function getWindowPosition() { + var ego = players.ego(), + w = { + left: 0, + top: 0, + columns: settings.window_columns, + rows: settings.window_rows + }; + + if (typeof ego !== 'undefined') { + w.left = clamp( + ego.position[1] - Math.floor(settings.window_columns / 2), + 0, settings.columns - settings.window_columns); + w.top = clamp( + ego.position[0] - Math.floor(settings.window_rows / 2), + 0, settings.rows - settings.window_rows); + } + return w; +} + +function bindGameKeys(socket) { + var directions = ["up", "down", "left", "right"], + repeatDelayMS = 1000 / settings.motion_speed_limit, + lastDirection = null, + repeatIntervalId = null, + highlightEgo = false; + + function moveInDir(direction) { + var ego = players.ego(); + if (ego.move(direction) ) { + var msg = { + type: "move", + player_id: ego.id, + move: direction, + timestamp: ego.motion_timestamp + }; + socket.send(msg); } + } - /** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; + directions.forEach(function(direction) { + Mousetrap.bind( + direction, + function(e) { + e.preventDefault(); + if (direction === lastDirection) { + return; + } + + // New direction may be pressed before previous dir key is released + if (repeatIntervalId) { + clearInterval(repeatIntervalId); + } + + moveInDir(direction); // Move once immediately so there's no lag + lastDirection = direction; + repeatIntervalId = setInterval(moveInDir, repeatDelayMS, direction); + }, + 'keydown' + ); + + Mousetrap.bind( + direction, + function(e) { + e.preventDefault(); + if (direction) { + clearInterval(repeatIntervalId); + lastDirection = null; } + }, + "keyup" + ); + + }); + + Mousetrap.bind("space", function () { + var msg_type; + var ego = players.ego(); + var position = ego.position; + var item_at_pos = gridItems.atPosition(position); + var player_item = ego.currentItem; + var transition = ego.getTransition(); + if (!item_at_pos && !player_item) { + // If there's nothing here, we try to plant food GU 1.0 style + msg_type = "plant_food"; + } else if (transition) { + // Check for a transition between objects. For now we don't do anything + // client-side other checking that it exists. We could optimize display + // updates later + msg_type = "item_transition"; + transitionsSeen.add(transition.id); + } else if (player_item && player_item.calories) { + // If there's nothing here to transition with and we're holding something + // edible, consume it. + msg_type = "item_consume"; + player_item.remainingUses = player_item.remainingUses - 1; + if (player_item.remainingUses < 1) { + ego.replaceItem(null); } - return -1; + } else if (!player_item && item_at_pos && item_at_pos.portable) { + // If there's a portable item here and we don't something in hand, pick it up. + msg_type = "item_pick_up"; + gridItems.remove(position); + ego.replaceItem(item_at_pos); } - - /** - * Aggregates elements of `collection` on `accumulator` with keys transformed - * by `iteratee` and values set by `setter`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform keys. - * @param {Object} accumulator The initial aggregated object. - * @returns {Function} Returns `accumulator`. - */ - function baseAggregator(collection, setter, iteratee, accumulator) { - baseEach(collection, function(value, key, collection) { - setter(accumulator, value, iteratee(value), collection); - }); - return accumulator; + if (!msg_type) { + return; } + var msg = { + type: msg_type, + player_id: ego.id, + position: position + }; + socket.send(msg); + }); - /** - * The base implementation of `_.assign` without support for multiple sources - * or `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ - function baseAssign(object, source) { - return object && copyObject(source, keys(source), object); + Mousetrap.bind("d", function () { + var ego = players.ego(); + var position = ego.position; + var currentItem = ego.currentItem; + if (!currentItem || gridItems.atPosition(position)) { + return; } + var msg = { + type: "item_drop", + player_id: ego.id, + position: position + }; + socket.send(msg); + ego.replaceItem(null); + gridItems.add(currentItem, position); + }); - /** - * The base implementation of `_.assignIn` without support for multiple sources - * or `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ - function baseAssignIn(object, source) { - return object && copyObject(source, keysIn(source), object); - } + if (settings.mutable_colors) { + Mousetrap.bind('c', function () { + var keys = settings.player_color_names, + index = arraySearch(keys, players.ego().color), + nextItem = keys[(index + 1) % keys.length], + msg; - /** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ - function baseAssignValue(object, key, value) { - if (key == '__proto__' && defineProperty) { - defineProperty(object, key, { - 'configurable': true, - 'enumerable': true, - 'value': value, - 'writable': true - }); - } else { - object[key] = value; - } - } + players.ego().color = nextItem; + msg = { + type: "change_color", + player_id: players.ego().id, + color: players.ego().color + }; + socket.send(msg); + }); + } - /** - * The base implementation of `_.at` without support for individual paths. - * - * @private - * @param {Object} object The object to iterate over. - * @param {string[]} paths The property paths to pick. - * @returns {Array} Returns the picked elements. - */ - function baseAt(object, paths) { - var index = -1, - length = paths.length, - result = Array(length), - skip = object == null; + if (settings.identity_signaling) { + Mousetrap.bind("v", function () { + var ego = players.ego(), + msg; - while (++index < length) { - result[index] = skip ? undefined : get(object, paths[index]); - } - return result; - } + ego.identity_visible = !ego.identity_visible; + msg = { + type: "toggle_visible", + player_id: ego.id, + identity_visible: ego.identity_visible + }; + socket.send(msg); + }); + } - /** - * The base implementation of `_.clamp` which doesn't coerce arguments. - * - * @private - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. - */ - function baseClamp(number, lower, upper) { - if (number === number) { - if (upper !== undefined) { - number = number <= upper ? number : upper; - } - if (lower !== undefined) { - number = number >= lower ? number : lower; - } - } - return number; - } + if (settings.build_walls) { + Mousetrap.bind("w", function () { + var msg = { + type: "build_wall", + player_id: players.ego().id, + position: players.ego().position + }; + socket.send(msg); + }); + } + + Mousetrap.bind("h", function () { + settings.highlightEgo = !settings.highlightEgo; + }); +} + +function chatName(player_id) { + var ego = players.ego(), + entry = "<span class='name'>", + id = parseInt(player_id) - 1, + salt = $("#grid").data("identicon-salt"), + fg = settings.player_colors[name2idx(players.get(player_id).color)].concat(1), + bg, + identicon, + name, + options; + + if (id === ego) { + name = "You"; + } else if (settings.pseudonyms) { + name = players.get(player_id).name; + } else if (player_id % 1 === 0) { + name = "Player " + player_id; + } else { + // Non-integer player_id + return '<span class="name">' + player_id + '</span>'; + } - /** - * The base implementation of `_.clone` and `_.cloneDeep` which tracks - * traversed objects. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} bitmask The bitmask flags. - * 1 - Deep clone - * 2 - Flatten inherited properties - * 4 - Clone symbols - * @param {Function} [customizer] The function to customize cloning. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The parent object of `value`. - * @param {Object} [stack] Tracks traversed objects and their clone counterparts. - * @returns {*} Returns the cloned value. - */ - function baseClone(value, bitmask, customizer, key, object, stack) { - var result, - isDeep = bitmask & CLONE_DEEP_FLAG, - isFlat = bitmask & CLONE_FLAT_FLAG, - isFull = bitmask & CLONE_SYMBOLS_FLAG; + fg = fg.map(function(x) { return x * 255; }); + bg = fg.map(function(x) { return (x * 0.66); }); + bg[3] = 255; + options = { + size: 10, + foreground: fg, + background: bg, + format: 'svg' + }; - if (customizer) { - result = object ? customizer(value, key, object, stack) : customizer(value); - } - if (result !== undefined) { - return result; - } - if (!isObject(value)) { - return value; - } - var isArr = isArray(value); - if (isArr) { - result = initCloneArray(value); - if (!isDeep) { - return copyArray(value, result); - } - } else { - var tag = getTag(value), - isFunc = tag == funcTag || tag == genTag; + identicon = new Identicon(md5(salt + id), options).toString(); + if (settings.use_identicons) { + entry = entry + " <img src='data:image/svg+xml;base64," + identicon + "' />"; + } + entry = entry + " " + name + "</span> "; + return entry; +} - if (isBuffer(value)) { - return cloneBuffer(value, isDeep); - } - if (tag == objectTag || tag == argsTag || (isFunc && !object)) { - result = (isFlat || isFunc) ? {} : initCloneObject(value); - if (!isDeep) { - return isFlat - ? copySymbolsIn(value, baseAssignIn(result, value)) - : copySymbols(value, baseAssign(result, value)); - } - } else { - if (!cloneableTags[tag]) { - return object ? value : {}; - } - result = initCloneByTag(value, tag, baseClone, isDeep); - } - } - // Check for circular references and return its corresponding clone. - stack || (stack = new Stack); - var stacked = stack.get(value); - if (stacked) { - return stacked; - } - stack.set(value, result); +function onChatMessage(msg) { + var entry = chatName(msg.player_id); + if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) { + return; + } + $("#messages").append(($("<li>").text(": " + msg.contents)).prepend(entry)); + $("#chatlog").scrollTop($("#chatlog")[0].scrollHeight); +} - var keysFunc = isFull - ? (isFlat ? getAllKeysIn : getAllKeys) - : (isFlat ? keysIn : keys); +function onColorChanged(msg) { + store.set("color", msg.new_color); + if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) { + return; + } + pushMessage("<span class='name'>Moderator:</span> " + chatName(msg.player_id) + ' changed from team ' + msg.old_color + ' to team ' + msg.new_color + '.'); +} - var props = isArr ? undefined : keysFunc(value); - arrayEach(props || value, function(subValue, key) { - if (props) { - key = subValue; - subValue = value[key]; - } - // Recursively populate clone (susceptible to call stack limits). - assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - return result; - } +function onMoveRejected(msg) { + var offendingPlayerId = msg.player_id, + ego = players.ego(); - /** - * The base implementation of `_.conforms` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. - */ - function baseConforms(source) { - var props = keys(source); - return function(object) { - return baseConformsTo(object, source, props); - }; - } + if (ego && offendingPlayerId === ego.id) { + ego.positionInSync = false; + console.log("Marking your player (" + ego.id + ") as out of sync with server. Should sync on next state update"); + } +} - /** - * The base implementation of `_.conformsTo` which accepts `props` to check. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. - */ - function baseConformsTo(object, source, props) { - var length = props.length; - if (object == null) { - return !length; - } - object = Object(object); - while (length--) { - var key = props[length], - predicate = source[key], - value = object[key]; +function onDonationProcessed(msg) { + var donor = players.get(msg.donor_id), + recipient_id = msg.recipient_id, + team_idx, + donor_name, + recipient_name, + donated_points, + received_points, + entry; - if ((value === undefined && !(key in object)) || !predicate(value)) { - return false; - } - } - return true; + donor_name = chatName(msg.donor_id); + + if (recipient_id === 'all') { + recipient_name = '<span class="name">All players</span>'; + } else if (recipient_id.indexOf('group:') === 0) { + team_idx = +recipient_id.substring(6); + recipient_name = 'Everyone in <span class="name">' + settings.player_color_names[team_idx] + '</span>'; + } else { + recipient_name = chatName(recipient_id); } - /** - * The base implementation of `_.delay` and `_.defer` which accepts `args` - * to provide to `func`. - * - * @private - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {Array} args The arguments to provide to `func`. - * @returns {number|Object} Returns the timer id or timeout object. - */ - function baseDelay(func, wait, args) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return setTimeout(function() { func.apply(undefined, args); }, wait); + if (msg.amount === 1) { + donated_points = msg.amount + ' point.'; + } else { + donated_points = msg.amount + ' points.'; } - /** - * The base implementation of methods like `_.difference` without support - * for excluding multiple arrays or iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Array} values The values to exclude. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - */ - function baseDifference(array, values, iteratee, comparator) { - var index = -1, - includes = arrayIncludes, - isCommon = true, - length = array.length, - result = [], - valuesLength = values.length; + if (msg.received === 1) { + received_points = msg.received + ' point.'; + } else { + received_points = msg.received + ' points.'; + } - if (!length) { - return result; - } - if (iteratee) { - values = arrayMap(values, baseUnary(iteratee)); - } - if (comparator) { - includes = arrayIncludesWith; - isCommon = false; - } - else if (values.length >= LARGE_ARRAY_SIZE) { - includes = cacheHas; - isCommon = false; - values = new SetCache(values); - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee == null ? value : iteratee(value); + entry = donor_name + " contributed " + donated_points + " " + recipient_name + " received " + received_points; - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - var valuesIndex = valuesLength; - while (valuesIndex--) { - if (values[valuesIndex] === computed) { - continue outer; - } - } - result.push(value); - } - else if (!includes(values, computed, comparator)) { - result.push(value); - } - } - return result; + $("#messages").append($("<li>").html(entry)); + $("#chatlog").scrollTop($("#chatlog")[0].scrollHeight); + $('#individual-donate, #group-donate').addClass('button-outline'); + $('#donate label').text($('#donate label').data('orig-text')); + settings.donation_type = null; +} + +function updateDonationStatus(donation_is_active) { + // If alternating donation/consumption rounds, announce round type + if (settings.alternate_consumption_donation && (settings.donation_active !== donation_is_active)) { + if (donation_is_active) { + pushMessage("<span class='name'>Moderator:</span> Starting a donation round. Players cannot move, only donate."); + } else { + pushMessage("<span class='name'>Moderator:</span> Starting a consumption round. Players have to consume as much food as possible."); } + } + // Update donation status + settings.donation_active = donation_is_active; +} - /** - * The base implementation of `_.forEach` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ - var baseEach = createBaseEach(baseForOwn); - /** - * The base implementation of `_.forEachRight` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ - var baseEachRight = createBaseEach(baseForOwnRight, true); +function renderTransition(transition) { + if (! transition) { + return ""; + } + const transition_visibility = transition.transition.visible; + const states = [ + transition.transition.actor_start, + transition.transition.actor_end, + transition.transition.target_start, + transition.transition.target_end + ]; - /** - * The base implementation of `_.every` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false` - */ - function baseEvery(collection, predicate) { - var result = true; - baseEach(collection, function(value, index, collection) { - result = !!predicate(value, index, collection); - return result; - }); - return result; - } + const [aStartItem, aEndItem, tStartItem, tEndItem] = states.map( + (state) => settings.item_config[state] + ); - /** - * The base implementation of methods like `_.max` and `_.min` which accepts a - * `comparator` to determine the extremum value. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per iteration. - * @param {Function} comparator The comparator used to compare values. - * @returns {*} Returns the extremum value. - */ - function baseExtremum(array, iteratee, comparator) { - var index = -1, - length = array.length; + const aStartItemString = `✋${aStartItem ? aStartItem.name : '⬜'}`; + const tStartItemString = tStartItem ? tStartItem.name : '⬜'; + if (transition_visibility == "never") { + return `${aStartItemString} + ${tStartItemString}` + } + + if (transition_visibility == "seen" && !transitionsSeen.has(transition.id)) { + var aEndItemString = "✋❓"; + var tEndItemString = "✋❓"; + } else { + aEndItemString = `✋${aEndItem ? aEndItem.name: '⬜'}`; + tEndItemString = tEndItem ? tEndItem.name: '⬜'; + } + return `${aStartItemString} + ${tStartItemString} → ${aEndItemString} + ${tEndItemString}`; - while (++index < length) { - var value = array[index], - current = iteratee(value); +} +/** + * If the current player is sharing a grid position with an interactive + * item, we show information about it on the page. + * + * @param {Player} egoPlayer the current Player + * @param {itemlib.GridItems} gridItems the collection of all Items on the grid + */ +function updateItemInfoWindow(egoPlayer, gridItems) { + const inspectedItem = gridItems.atPosition(egoPlayer.position), + transition = egoPlayer.getTransition(), + $square = $("#location-contents-item"), + $transition = $("#transition-details"); - if (current != null && (computed === undefined - ? (current === current && !isSymbol(current)) - : comparator(current, computed) - )) { - var computed = current, - result = value; - } - } - return result; + if (! inspectedItem) { + $square.empty(); + } else { + $square.html(inspectedItem.name); + } + + if (! transition) { + // If we're holding an item with calories, indicate that we might want to eat it. + if (egoPlayer.currentItem && egoPlayer.currentItem.calories) { + $transition.html(`✋${egoPlayer.currentItem.name} + 🤤`); + } else { + $transition.empty(); } + } else { + $transition.html(renderTransition(transition)); + } +} - /** - * The base implementation of `_.fill` without an iteratee call guard. - * - * @private - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - */ - function baseFill(array, value, start, end) { - var length = array.length; +function displayWhatEgoPlayerIsCarrying(item) { + $('#inventory-item').text(item ? item.name : ''); +} - start = toInteger(start); - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = (end === undefined || end > length) ? length : toInteger(end); - if (end < 0) { - end += length; - } - end = start > end ? 0 : toLength(end); - while (start < end) { - array[start++] = value; - } - return array; - } +function onGameStateChange(msg) { + var $donationButtons = $('#individual-donate, #group-donate, #public-donate, #ingroup-donate'), + $timeElement = $("#time"), + $loading = $('.grid-loading'), + cur_wall, + ego, + state, + j, + k; - /** - * The base implementation of `_.filter` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ - function baseFilter(collection, predicate) { - var result = []; - baseEach(collection, function(value, index, collection) { - if (predicate(value, index, collection)) { - result.push(value); - } - }); - return result; - } + performance.mark('state_start'); + if ($loading.is(':visible')) $loading.fadeOut(); - /** - * The base implementation of `_.flatten` with support for restricting flattening. - * - * @private - * @param {Array} array The array to flatten. - * @param {number} depth The maximum recursion depth. - * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. - * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ - function baseFlatten(array, depth, predicate, isStrict, result) { - var index = -1, - length = array.length; + if (settings.paused_game) { + $timeElement.html(0); + return; + } - predicate || (predicate = isFlattenable); - result || (result = []); + // Update remaining time. + $timeElement.html(Math.max(Math.round(msg.remaining_time), 0)); - while (++index < length) { - var value = array[index]; - if (depth > 0 && predicate(value)) { - if (depth > 1) { - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, predicate, isStrict, result); - } else { - arrayPush(result, value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; - } + // Update round. + if (settings.num_rounds > 1) { + $("#round").html(msg.round + 1); + } - /** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseFor = createBaseFor(); + // Update players. + state = JSON.parse(msg.grid); + players.update(state.players); + ego = players.ego(); - /** - * This function is like `baseFor` except that it iterates over properties - * in the opposite order. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseForRight = createBaseFor(true); + updateDonationStatus(state.donation_active); - /** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys); + // Update gridItems + if (state.items !== undefined && state.items !== null) { + gridItems = new itemlib.GridItems(); + for (j = 0; j < state.items.length; j++) { + + gridItems.add( + new itemlib.Item( + state.items[j].id, + state.items[j].item_id, + state.items[j].maturity, + state.items[j].remaining_uses, + ), + state.items[j].position + ); + } + } + // Update walls if they haven't been created yet. + if (state.walls !== undefined && walls.length === 0) { + for (k = 0; k < state.walls.length; k++) { + cur_wall = state.walls[k]; + if (cur_wall instanceof Array) { + cur_wall = { + position: cur_wall, + color: [0.5, 0.5, 0.5] + }; + } + walls.push( + new Wall({ + position: cur_wall.position, + color: cur_wall.color + }) + ); + wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color; } + } - /** - * The base implementation of `_.forOwnRight` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwnRight(object, iteratee) { - return object && baseForRight(object, iteratee, keys); + // If new walls have been added, draw them + if (state.walls !== undefined && walls.length < state.walls.length) { + for (k = walls.length; k < state.walls.length; k++) { + cur_wall = state.walls[k]; + walls.push( + new Wall({ + position: cur_wall.position, + color: cur_wall.color + }) + ); + wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color; } + } - /** - * The base implementation of `_.functions` which creates an array of - * `object` function property names filtered from `props`. - * - * @private - * @param {Object} object The object to inspect. - * @param {Array} props The property names to filter. - * @returns {Array} Returns the function names. - */ - function baseFunctions(object, props) { - return arrayFilter(props, function(key) { - return isFunction(object[key]); - }); + // Update displayed score, set donation info. + if (ego !== undefined) { + $("#score").html(Math.round(ego.score)); + $("#dollars").html(ego.payoff.toFixed(2)); + window.state = msg.grid; + window.ego = ego.id; + if (settings.donation_active && + ego.score >= settings.donation_amount && + players.count() > 1 + ) { + $donationButtons.prop('disabled', false); + } else { + $('#donation-instructions').text(''); + $donationButtons.prop('disabled', true); } + } +} - /** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ - function baseGet(object, path) { - path = castPath(path, object); +function addWall(msg) { + var wall = msg.wall; + if (wall) { + walls.push( + new Wall({ + position: wall.position, + color: wall.color + }) + ); + wall_map[[wall.position[1], wall.position[0]]] = wall.color; + } +} - var index = 0, - length = path.length; +function pushMessage(html) { + $("#messages").append(($("<li>").html(html))); + $("#chatlog").scrollTop($("#chatlog")[0].scrollHeight); +} - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; +function displayLeaderboards(msg, callback) { + if (!settings.leaderboard_group && !settings.leaderboard_individual) { + if (callback) { + callback(); } - - /** - * The base implementation of `getAllKeys` and `getAllKeysIn` which uses - * `keysFunc` and `symbolsFunc` to get the enumerable property names and - * symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Function} keysFunc The function to get the keys of `object`. - * @param {Function} symbolsFunc The function to get the symbols of `object`. - * @returns {Array} Returns the array of property names and symbols. - */ - function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + return; + } + var i; + if (msg.type === 'new_round') { + pushMessage("<span class='name'>Moderator:</span> the round " + msg.round + ' standings are…'); + } else { + pushMessage("<span class='name'>Moderator:</span> the final standings are …"); + } + if (settings.leaderboard_group) { + if (settings.leaderboard_individual) { + pushMessage('<em>Group</em>'); + } + var group_scores = players.group_scores(); + var rgb_map = function (e) { return Math.round(e * 255); }; + for (i = 0; i < group_scores.length; i++) { + var group = group_scores[i]; + var color = settings.player_colors[name2idx(group.name)].map(rgb_map); + pushMessage('<span class="GroupScore">' + group.score + '</span><span class="GroupIndicator" style="background-color:' + Color.rgb(color).string() +';"></span>'); + } + } + if (settings.leaderboard_individual) { + if (settings.leaderboard_group) { + pushMessage('<em>Individual</em>'); + } + var player_scores = players.player_scores(); + var ego_id = players.ego_id; + for (i = 0; i < player_scores.length; i++) { + var player = player_scores[i]; + var player_name = chatName(player.id); + pushMessage('<span class="PlayerScore">' + Math.round(player.score) + '</span><span class="PlayerName">' + player_name + '</span>'); } + } + if (settings.leaderboard_time) { + settings.paused_game = true; + setTimeout(function () { + settings.paused_game = false; + if (callback) { + callback(); + } + }, 1000 * settings.leaderboard_time); + } else if (callback) { + callback(); + } +} - /** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ - function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; +function gameOverHandler(player_id) { + var callback; + if (!isSpectator) { + callback = function () { + $("#dashboard").hide(); + $("#instructions").hide(); + $("#chat").hide(); + if (player_id) { + window.location.href = "/questionnaire?participant_id=" + player_id; } - return (symToStringTag && symToStringTag in Object(value)) - ? getRawTag(value) - : objectToString(value); - } + }; + pixels.canvas.style.display = "none"; + } + return function (msg) { + $("#game-over").show(); + return displayLeaderboards(msg, callback); + }; +} - /** - * The base implementation of `_.gt` which doesn't coerce arguments. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - */ - function baseGt(value, other) { - return value > other; +$(document).ready(function() { + var player_id = dallinger.getUrlParameter('participant_id'); + isSpectator = typeof player_id === 'undefined'; + var socketSettings = { + 'endpoint': 'chat', + 'broadcast': CHANNEL, + 'control': CONTROL_CHANNEL, + 'lagTolerance': 0.001, + 'callbackMap': { + 'chat': onChatMessage, + 'donation_processed': onDonationProcessed, + 'color_changed': onColorChanged, + 'state': onGameStateChange, + 'new_round': displayLeaderboards, + 'stop': gameOverHandler(player_id), + 'wall_built': addWall, + 'move_rejection': onMoveRejected + } + }; + var socket = new GUSocket(socketSettings); + + socket.open().done(function () { + var data = { + type: 'connect', + player_id: isSpectator ? 'spectator' : player_id + }; + socket.send(data); + }); + + players.ego_id = player_id; + players.startScheduledAutosyncOfEgoPosition(); + $('#donate label').data('orig-text', $('#donate label').text()); + + setInterval(function () { + var delays = [], + start_marks = performance.getEntriesByName('state_start', 'mark'); + for (var i = 0; i < start_marks.length; i++) { + if (start_marks.length > i + 2) { + delays.push(start_marks[i+1].startTime - start_marks[i].startTime); + } } - - /** - * The base implementation of `_.has` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ - function baseHas(object, key) { - return object != null && hasOwnProperty.call(object, key); + if (delays.length) { + var average_delay = delays.reduce(function(sum, value){ + return sum + value; + }, 0) / delays.length; + console.log('Average delay between state updates: ' + average_delay + 'ms.'); } + }, 5000); - /** - * The base implementation of `_.hasIn` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ - function baseHasIn(object, key) { - return object != null && key in Object(object); - } + // Append the canvas. + $("#grid").append(pixels.canvas); - /** - * The base implementation of `_.inRange` which doesn't coerce arguments. - * - * @private - * @param {number} number The number to check. - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - */ - function baseInRange(number, start, end) { - return number >= nativeMin(start, end) && number < nativeMax(start, end); - } + // Opt out of the experiment. + $("#opt-out").click(function() { + window.location.href = "/questionnaire?participant_id=" + player_id; + }); - /** - * The base implementation of methods like `_.intersection`, without support - * for iteratee shorthands, that accepts an array of arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of shared values. - */ - function baseIntersection(arrays, iteratee, comparator) { - var includes = comparator ? arrayIncludesWith : arrayIncludes, - length = arrays[0].length, - othLength = arrays.length, - othIndex = othLength, - caches = Array(othLength), - maxLength = Infinity, - result = []; + if (isSpectator) { + $(".for-players").hide(); + } - while (othIndex--) { - var array = arrays[othIndex]; - if (othIndex && iteratee) { - array = arrayMap(array, baseUnary(iteratee)); - } - maxLength = nativeMin(array.length, maxLength); - caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) - ? new SetCache(othIndex && array) - : undefined; - } - array = arrays[0]; + // Consent to the experiment. + $("#go-to-experiment").click(function() { + window.location.href = "/exp"; + }); - var index = -1, - seen = caches[0]; + // Submit the questionnaire. + $("#submit-questionnaire").click(function() { + dallinger.submitResponses(); + }); - outer: - while (++index < length && result.length < maxLength) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; + if (settings.show_grid) { + pixels.canvas.style.display = "inline"; + } - value = (comparator || value !== 0) ? value : 0; - if (!(seen - ? cacheHas(seen, computed) - : includes(result, computed, comparator) - )) { - othIndex = othLength; - while (--othIndex) { - var cache = caches[othIndex]; - if (!(cache - ? cacheHas(cache, computed) - : includes(arrays[othIndex], computed, comparator)) - ) { - continue outer; - } - } - if (seen) { - seen.push(computed); - } - result.push(value); - } - } - return result; + if (settings.show_chatroom) { + $("#chat form").show(); + } + + var donateToClicked = function() { + var w = getWindowPosition(), + row = w.top + pixels2cells(mouse[1]), + column = w.left + pixels2cells(mouse[0]), + recipient = players.nearest(row, column), + donor = players.ego(), + amt = settings.donation_amount, + recipient_id, + msg; + + if (!settings.donation_active) { + return; } - /** - * The base implementation of `_.invert` and `_.invertBy` which inverts - * `object` with values transformed by `iteratee` and set by `setter`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform values. - * @param {Object} accumulator The initial inverted object. - * @returns {Function} Returns `accumulator`. - */ - function baseInverter(object, setter, iteratee, accumulator) { - baseForOwn(object, function(value, key, object) { - setter(accumulator, iteratee(value), key, object); - }); - return accumulator; + if (amt > donor.score) { + return; } - /** - * The base implementation of `_.invoke` without support for individual - * method arguments. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {Array} args The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - */ - function baseInvoke(object, path, args) { - path = castPath(path, object); - object = parent(object, path); - var func = object == null ? object : object[toKey(last(path))]; - return func == null ? undefined : apply(func, object, args); + if (settings.donation_type === 'individual') { + recipient_id = recipient.id; + } else if (settings.donation_type === 'group') { + recipient_id = 'group:' + name2idx(recipient.color).toString(); + } else { + return; } - /** - * The base implementation of `_.isArguments`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - */ - function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; + if (recipient_id !== donor.id) { + msg = { + type: "donation_submitted", + recipient_id: recipient_id, + donor_id: donor.id, + amount: amt + }; + socket.send(msg); } + }; - /** - * The base implementation of `_.isArrayBuffer` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. - */ - function baseIsArrayBuffer(value) { - return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; + var donateToAll = function() { + var donor = players.ego(), + amt = settings.donation_amount, + msg; + + msg = { + type: "donation_submitted", + recipient_id: 'all', + donor_id: donor.id, + amount: amt + }; + socket.send(msg); + }; + + var donateToInGroup = function () { + var donor = players.ego(), + amt = settings.donation_amount, + recipientId = 'group:' + name2idx(donor.color).toString(), + msg; + + msg = { + type: "donation_submitted", + recipient_id: recipientId, + donor_id: donor.id, + amount: amt + }; + socket.send(msg); + }; + + var pixels2cells = function(pix) { + return Math.floor(pix / (settings.block_size + settings.padding)); + }; + + $("form").submit(function() { + var chatmessage = $("#message").val().trim(), + msg; + + if (! chatmessage) { + return false; } - /** - * The base implementation of `_.isDate` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. - */ - function baseIsDate(value) { - return isObjectLike(value) && baseGetTag(value) == dateTag; + try { + msg = { + type: 'chat', + contents: chatmessage, + player_id: players.ego().id, + timestamp: performance.now() - start, + broadcast: true + }; + // send directly to all clients + socket.broadcast(msg); + // Also send to the server for logging + socket.send(msg); + } catch(err) { + console.error(err); + } finally { + $("#message").val(""); + return false; } + }); - /** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; + if (!isSpectator) { + // Main game keys: + bindGameKeys(socket); + // Donation click events: + $(pixels.canvas).click(function (e) { + donateToClicked(); + }); + $('#public-donate').click(donateToAll); + $('#ingroup-donate').click(donateToInGroup); + $('#group-donate').click(function () { + if (settings.donation_group) { + $('#donate label').text('Click on a color'); + settings.donation_type = 'group'; + $(this).prop('disabled', false); + $(this).removeClass('button-outline'); + $('#individual-donate').addClass('button-outline'); } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; + }); + $('#individual-donate').click(function () { + if (settings.donation_individual) { + $('#donate label').text('Click on a player'); + settings.donation_type = 'individual'; + $(this).removeClass('button-outline'); + $('#group-donate').addClass('button-outline'); } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); - } + }); + } - /** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = objIsArr ? arrayTag : getTag(object), - othTag = othIsArr ? arrayTag : getTag(other); +}); - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; +}(dallinger, require, window.settings)); - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, - isSameTag = objTag == othTag; - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) - : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); +/***/ }), +/* 17 */, +/* 18 */, +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; +var lodash = __webpack_require__(36); +var isarray = __webpack_require__(3); +var isnumber = __webpack_require__(4); +var isstring = __webpack_require__(5); +var parse = __webpack_require__(6); - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); - } +function convert(data) { + data = isarray(data[0]) && data[0].length !== 3 ? lodash.flatten(data, 1) : data; - /** - * The base implementation of `_.isMap` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - */ - function baseIsMap(value) { - return isObjectLike(value) && getTag(value) == mapTag; - } + if (isnumber(data[0])) { + data = data.map(function(d) { + return [ d, d, d ]; + }); + } - /** - * The base implementation of `_.isMatch` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ - function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; + if (isstring(data[0])) { + data = data.map(function(d) { + return parse(d).rgb.map(function(c) { + return c / 255; + }); + }); + } - if (object == null) { - return !length; - } - object = Object(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; + return data; +} - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var stack = new Stack; - if (customizer) { - var result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined - ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) - : result - )) { - return false; - } - } - } - return true; - } +module.exports = convert; - /** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ - function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); - } - /** - * The base implementation of `_.isRegExp` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. - */ - function baseIsRegExp(value) { - return isObjectLike(value) && baseGetTag(value) == regexpTag; - } +/***/ }), +/* 20 */ +/***/ (function(module, exports) { - /** - * The base implementation of `_.isSet` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - */ - function baseIsSet(value) { - return isObjectLike(value) && getTag(value) == setTag; - } +function layout(rows, columns, padding, size, aspect) { + var grid = []; - /** - * The base implementation of `_.isTypedArray` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - */ - function baseIsTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; - } + for (var i = 0; i < rows; i++) { + for (var j = 0; j < columns; j++) { + var x = -1 + aspect * (i * (padding + size) + padding); + var y = 1 - (j * (padding + size) + padding); + grid.push([ y, x ]); + var x_next = x + size - padding; + grid.push([ y, x_next ]); + var y_next = y - size + padding; + grid.push([ y_next, x ]); + + grid.push([ y_next, x ]); + grid.push([ y, x_next ]); + grid.push([ y_next, x_next ]); - /** - * The base implementation of `_.iteratee`. - * - * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. - */ - function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity; - } - if (typeof value == 'object') { - return isArray(value) - ? baseMatchesProperty(value[0], value[1]) - : baseMatches(value); - } - return property(value); } + } - /** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; - } + return grid.reverse(); +} - /** - * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function baseKeysIn(object) { - if (!isObject(object)) { - return nativeKeysIn(object); - } - var isProto = isPrototype(object), - result = []; - for (var key in object) { - if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; - } +module.exports = layout; - /** - * The base implementation of `_.lt` which doesn't coerce arguments. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - */ - function baseLt(value, other) { - return value < other; - } - /** - * The base implementation of `_.map` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function baseMap(collection, iteratee) { - var index = -1, - result = isArrayLike(collection) ? Array(collection.length) : []; +/***/ }), +/* 21 */ +/***/ (function(module, exports) { - baseEach(collection, function(value, key, collection) { - result[++index] = iteratee(value, key, collection); - }); - return result; - } +/** + * Derived from Identicon.js 2.3.1 + * http://github.com/stewartlord/identicon.js + * + * Copyright 2017, Stewart Lord and Dallinger Contributors + * Released under the BSD license + * http://www.opensource.org/licenses/bsd-license.php + */ - /** - * The base implementation of `_.matches` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. - */ - function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - return matchesStrictComparable(matchData[0][0], matchData[0][1]); - } - return function(object) { - return object === source || baseIsMatch(object, source, matchData); - }; - } - /** - * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ - function baseMatchesProperty(path, srcValue) { - if (isKey(path) && isStrictComparable(srcValue)) { - return matchesStrictComparable(toKey(path), srcValue); - } - return function(object) { - var objValue = get(object, path); - return (objValue === undefined && objValue === srcValue) - ? hasIn(object, path) - : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); - }; +var Identicon = function(hash, size, options){ + if (typeof(hash) !== 'string' || hash.length < 15) { + throw 'A hash of at least 15 characters is required.'; } - /** - * The base implementation of `_.merge` without support for multiple sources. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {number} srcIndex The index of `source`. - * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ - function baseMerge(object, source, srcIndex, customizer, stack) { - if (object === source) { - return; - } - baseFor(source, function(srcValue, key) { - if (isObject(srcValue)) { - stack || (stack = new Stack); - baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + this.defaults = { + background: [240, 240, 240, 255], + margin: 0.08, + size: 64, + saturation: 0.7, + brightness: 0.5, + format: 'pixels' + }; + + this.options = typeof(options) === 'object' ? options : this.defaults; + + this.hash = hash + this.background = [128, 128, 128]; + this.foreground = [255, 255, 255]; + this.size = size; +}; + +Identicon.prototype = { + background: null, + foreground: null, + hash: null, + margin: null, + size: null, + format: null, + + image: function(){ + return new Pixels(this.size, this.foreground, this.background) + }, + + render: function(){ + var image = this.image(), + size = this.size, + baseMargin = Math.floor(size * this.margin), + cell = Math.floor((size - (baseMargin * 2)) / 5), + margin = Math.floor((size - cell * 5) / 2), + bg = this.background, + fg = this.foreground; + + // the first 15 characters of the hash control the pixels (even/odd) + // they are drawn down the middle first, then mirrored outwards + var i, color; + for (i = 0; i < 15; i++) { + color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg; + if (i < 5) { + this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image); + } else if (i < 10) { + this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); + this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); + } else if (i < 15) { + this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); + this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); + } } - else { - var newValue = customizer - ? customizer(object[key], srcValue, (key + ''), object, source, stack) - : undefined; - if (newValue === undefined) { - newValue = srcValue; - } - assignMergeValue(object, key, newValue); + return image; + }, + + rectangle: function(x, y, w, h, color, image){ + var i, j; + for (i = x; i < x + w; i++) { + for (j = y; j < y + h; j++) { + image.buffer[j][i] = color; + } } - }, keysIn); } - /** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {number} srcIndex The index of `source`. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ - function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - var objValue = object[key], - srcValue = source[key], - stacked = stack.get(srcValue); +}; + +var Pixels = function(size){ + this.buffer = []; + for (i = 0; i < size; i++) { + var row = [] + for (j = 0; j < size; j++) { + row.push([0,0,120]); + } + this.buffer.push(row); + } +}; - if (stacked) { - assignMergeValue(object, key, stacked); - return; - } - var newValue = customizer - ? customizer(objValue, srcValue, (key + ''), object, source, stack) - : undefined; +Pixels.prototype = { + pixels: null, - var isCommon = newValue === undefined; +}; - if (isCommon) { - var isArr = isArray(srcValue), - isBuff = !isArr && isBuffer(srcValue), - isTyped = !isArr && !isBuff && isTypedArray(srcValue); - newValue = srcValue; - if (isArr || isBuff || isTyped) { - if (isArray(objValue)) { - newValue = objValue; - } - else if (isArrayLikeObject(objValue)) { - newValue = copyArray(objValue); - } - else if (isBuff) { - isCommon = false; - newValue = cloneBuffer(srcValue, true); - } - else if (isTyped) { - isCommon = false; - newValue = cloneTypedArray(srcValue, true); - } - else { - newValue = []; - } +module.exports = Identicon; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports) { + +/** +* A handy class to calculate color values. +* +* @version 1.0 +* @author Robert Eisele <robert@xarg.org> +* @copyright Copyright (c) 2010, Robert Eisele +* @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/ +* @license http://www.opensource.org/licenses/bsd-license.php BSD License +* +*/ + +(function() { + + // helper functions for that ctx + function write(buffer, offs) { + for (var i = 2; i < arguments.length; i++) { + for (var j = 0; j < arguments[i].length; j++) { + buffer[offs++] = arguments[i].charAt(j); + } + } } - else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = objValue; - if (isArguments(objValue)) { - newValue = toPlainObject(objValue); - } - else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { - newValue = initCloneObject(srcValue); - } + + function byte2(w) { + return String.fromCharCode((w >> 8) & 255, w & 255); + } + + function byte4(w) { + return String.fromCharCode((w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w & 255); + } + + function byte2lsb(w) { + return String.fromCharCode(w & 255, (w >> 8) & 255); + } + + // modified from original source to support NPM + var PNGlib = function(width,height,depth) { + + this.width = width; + this.height = height; + this.depth = depth; + + // pixel data and row filter identifier size + this.pix_size = height * (width + 1); + + // deflate header, pix_size, block headers, adler32 checksum + this.data_size = 2 + this.pix_size + 5 * Math.floor((0xfffe + this.pix_size) / 0xffff) + 4; + + // offsets and sizes of Png chunks + this.ihdr_offs = 0; // IHDR offset and size + this.ihdr_size = 4 + 4 + 13 + 4; + this.plte_offs = this.ihdr_offs + this.ihdr_size; // PLTE offset and size + this.plte_size = 4 + 4 + 3 * depth + 4; + this.trns_offs = this.plte_offs + this.plte_size; // tRNS offset and size + this.trns_size = 4 + 4 + depth + 4; + this.idat_offs = this.trns_offs + this.trns_size; // IDAT offset and size + this.idat_size = 4 + 4 + this.data_size + 4; + this.iend_offs = this.idat_offs + this.idat_size; // IEND offset and size + this.iend_size = 4 + 4 + 4; + this.buffer_size = this.iend_offs + this.iend_size; // total PNG size + + this.buffer = new Array(); + this.palette = new Object(); + this.pindex = 0; + + var _crc32 = new Array(); + + // initialize buffer with zero bytes + for (var i = 0; i < this.buffer_size; i++) { + this.buffer[i] = "\x00"; + } + + // initialize non-zero elements + write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), 'IHDR', byte4(width), byte4(height), "\x08\x03"); + write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), 'PLTE'); + write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), 'tRNS'); + write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), 'IDAT'); + write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), 'IEND'); + + // initialize deflate header + var header = ((8 + (7 << 4)) << 8) | (3 << 6); + header+= 31 - (header % 31); + + write(this.buffer, this.idat_offs + 8, byte2(header)); + + // initialize deflate block headers + for (var i = 0; (i << 16) - 1 < this.pix_size; i++) { + var size, bits; + if (i + 0xffff < this.pix_size) { + size = 0xffff; + bits = "\x00"; + } else { + size = this.pix_size - (i << 16) - i; + bits = "\x01"; + } + write(this.buffer, this.idat_offs + 8 + 2 + (i << 16) + (i << 2), bits, byte2lsb(size), byte2lsb(~size)); + } + + /* Create crc32 lookup table */ + for (var i = 0; i < 256; i++) { + var c = i; + for (var j = 0; j < 8; j++) { + if (c & 1) { + c = -306674912 ^ ((c >> 1) & 0x7fffffff); + } else { + c = (c >> 1) & 0x7fffffff; + } + } + _crc32[i] = c; + } + + // compute the index into a png for a given pixel + this.index = function(x,y) { + var i = y * (this.width + 1) + x + 1; + var j = this.idat_offs + 8 + 2 + 5 * Math.floor((i / 0xffff) + 1) + i; + return j; + } + + // convert a color and build up the palette + this.color = function(red, green, blue, alpha) { + + alpha = alpha >= 0 ? alpha : 255; + var color = (((((alpha << 8) | red) << 8) | green) << 8) | blue; + + if (typeof this.palette[color] == "undefined") { + if (this.pindex == this.depth) return "\x00"; + + var ndx = this.plte_offs + 8 + 3 * this.pindex; + + this.buffer[ndx + 0] = String.fromCharCode(red); + this.buffer[ndx + 1] = String.fromCharCode(green); + this.buffer[ndx + 2] = String.fromCharCode(blue); + this.buffer[this.trns_offs+8+this.pindex] = String.fromCharCode(alpha); + + this.palette[color] = String.fromCharCode(this.pindex++); + } + return this.palette[color]; + } + + // output a PNG string, Base64 encoded + this.getBase64 = function() { + + var s = this.getDump(); + + var ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var c1, c2, c3, e1, e2, e3, e4; + var l = s.length; + var i = 0; + var r = ""; + + do { + c1 = s.charCodeAt(i); + e1 = c1 >> 2; + c2 = s.charCodeAt(i+1); + e2 = ((c1 & 3) << 4) | (c2 >> 4); + c3 = s.charCodeAt(i+2); + if (l < i+2) { e3 = 64; } else { e3 = ((c2 & 0xf) << 2) | (c3 >> 6); } + if (l < i+3) { e4 = 64; } else { e4 = c3 & 0x3f; } + r+= ch.charAt(e1) + ch.charAt(e2) + ch.charAt(e3) + ch.charAt(e4); + } while ((i+= 3) < l); + return r; + } + + // output a PNG string + this.getDump = function() { + + // compute adler32 of output pixels + row filter bytes + var BASE = 65521; /* largest prime smaller than 65536 */ + var NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + var s1 = 1; + var s2 = 0; + var n = NMAX; + + for (var y = 0; y < this.height; y++) { + for (var x = -1; x < this.width; x++) { + s1+= this.buffer[this.index(x, y)].charCodeAt(0); + s2+= s1; + if ((n-= 1) == 0) { + s1%= BASE; + s2%= BASE; + n = NMAX; + } + } + } + s1%= BASE; + s2%= BASE; + write(this.buffer, this.idat_offs + this.idat_size - 8, byte4((s2 << 16) | s1)); + + // compute crc32 of the PNG chunks + function crc32(png, offs, size) { + var crc = -1; + for (var i = 4; i < size-4; i += 1) { + crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff); + } + write(png, offs+size-4, byte4(crc ^ -1)); + } + + crc32(this.buffer, this.ihdr_offs, this.ihdr_size); + crc32(this.buffer, this.plte_offs, this.plte_size); + crc32(this.buffer, this.trns_offs, this.trns_size); + crc32(this.buffer, this.idat_offs, this.idat_size); + crc32(this.buffer, this.iend_offs, this.iend_size); + + // convert PNG to string + return "\x89PNG\r\n\x1a\n"+this.buffer.join(''); + } } - else { - isCommon = false; + + // modified from original source to support NPM + if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + module.exports = PNGlib; + } else { + window.PNGlib = PNGlib; } - } - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, newValue); - mergeFunc(newValue, srcValue, srcIndex, customizer, stack); - stack['delete'](srcValue); - } - assignMergeValue(object, key, newValue); - } - - /** - * The base implementation of `_.nth` which doesn't coerce arguments. - * - * @private - * @param {Array} array The array to query. - * @param {number} n The index of the element to return. - * @returns {*} Returns the nth element of `array`. - */ - function baseNth(array, n) { - var length = array.length; - if (!length) { - return; - } - n += n < 0 ? length : 0; - return isIndex(n, length) ? array[n] : undefined; - } - - /** - * The base implementation of `_.orderBy` without param guards. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {string[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - */ - function baseOrderBy(collection, iteratees, orders) { - var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); - - var result = baseMap(collection, function(value, key, collection) { - var criteria = arrayMap(iteratees, function(iteratee) { - return iteratee(value); - }); - return { 'criteria': criteria, 'index': ++index, 'value': value }; - }); - - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); - } - - /** - * The base implementation of `_.pick` without support for individual - * property identifiers. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @returns {Object} Returns the new object. - */ - function basePick(object, paths) { - return basePickBy(object, paths, function(value, path) { - return hasIn(object, path); - }); - } + })(); - /** - * The base implementation of `_.pickBy` without support for iteratee shorthands. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. - */ - function basePickBy(object, paths, predicate) { - var index = -1, - length = paths.length, - result = {}; +/***/ }), +/* 23 */ +/***/ (function(module, exports) { - while (++index < length) { - var path = paths[index], - value = baseGet(object, path); +function range(j, k) { + return Array + .apply(null, Array((k - j) + 1)) + .map(function(discard, n){ return n + j; }); +} - if (predicate(value, path)) { - baseSet(result, castPath(path, object), value); - } - } - return result; - } - /** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - */ - function basePropertyDeep(path) { - return function(object) { - return baseGet(object, path); - }; - } - /** - * The base implementation of `_.pullAllBy` without support for iteratee - * shorthands. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - */ - function basePullAll(array, values, iteratee, comparator) { - var indexOf = comparator ? baseIndexOfWith : baseIndexOf, - index = -1, - length = values.length, - seen = array; +module.exports = range; - if (array === values) { - values = copyArray(values); - } - if (iteratee) { - seen = arrayMap(array, baseUnary(iteratee)); - } - while (++index < length) { - var fromIndex = 0, - value = values[index], - computed = iteratee ? iteratee(value) : value; - while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { - if (seen !== array) { - splice.call(seen, fromIndex, 1); - } - splice.call(array, fromIndex, 1); - } - } - return array; - } +/***/ }), +/* 24 */ +/***/ (function(module, exports) { - /** - * The base implementation of `_.pullAt` without support for individual - * indexes or capturing the removed elements. - * - * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns `array`. - */ - function basePullAt(array, indexes) { - var length = array ? indexes.length : 0, - lastIndex = length - 1; +function texcoord(rows, columns, texture_indexes, num_textures) { + var grid = []; + var texture; + var texture_start; + var texture_next; - while (length--) { - var index = indexes[length]; - if (length == lastIndex || index !== previous) { - var previous = index; - if (isIndex(index)) { - splice.call(array, index, 1); - } else { - baseUnset(array, index); - } - } - } - return array; - } + for (var i = 0; i < rows; i++) { + for (var j = 0; j < columns; j++) { + texture = texture_indexes[i*rows + j]; + texture_start = (1/num_textures)*texture; + texture_next = texture_start + (1/num_textures); - /** - * The base implementation of `_.random` without support for returning - * floating-point numbers. - * - * @private - * @param {number} lower The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the random number. - */ - function baseRandom(lower, upper) { - return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); + grid.push([ 0, texture_start ]); + grid.push([ 1, texture_start ]); + grid.push([ 0, texture_next ]); + + grid.push([ 0, texture_next ]); + grid.push([ 1, texture_start ]); + grid.push([ 1, texture_next ]); } + } - /** - * The base implementation of `_.range` and `_.rangeRight` which doesn't - * coerce arguments. - * - * @private - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @param {number} step The value to increment or decrement by. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the range of numbers. - */ - function baseRange(start, end, step, fromRight) { - var index = -1, - length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), - result = Array(length); + return grid; +} - while (length--) { - result[fromRight ? length : ++index] = start; - start += step; - } - return result; - } - /** - * The base implementation of `_.repeat` which doesn't coerce arguments. - * - * @private - * @param {string} string The string to repeat. - * @param {number} n The number of times to repeat the string. - * @returns {string} Returns the repeated string. - */ - function baseRepeat(string, n) { - var result = ''; - if (!string || n < 1 || n > MAX_SAFE_INTEGER) { - return result; - } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = nativeFloor(n / 2); - if (n) { - string += string; - } - } while (n); +module.exports = texcoord; - return result; - } - /** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - */ - function baseRest(func, start) { - return setToString(overRest(func, start, identity), func + ''); - } +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * The base implementation of `_.sample`. - * - * @private - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. - */ - function baseSample(collection) { - return arraySample(values(collection)); - } +var conversions = __webpack_require__(2); +var route = __webpack_require__(26); - /** - * The base implementation of `_.sampleSize` without param guards. - * - * @private - * @param {Array|Object} collection The collection to sample. - * @param {number} n The number of elements to sample. - * @returns {Array} Returns the random elements. - */ - function baseSampleSize(collection, n) { - var array = values(collection); - return shuffleSelf(array, baseClamp(n, 0, array.length)); - } +var convert = {}; - /** - * The base implementation of `_.set`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ - function baseSet(object, path, value, customizer) { - if (!isObject(object)) { - return object; - } - path = castPath(path, object); +var models = Object.keys(conversions); - var index = -1, - length = path.length, - lastIndex = length - 1, - nested = object; +function wrapRaw(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } - while (nested != null && ++index < length) { - var key = toKey(path[index]), - newValue = value; + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = isObject(objValue) - ? objValue - : (isIndex(path[index + 1]) ? [] : {}); - } - } - assignValue(nested, key, newValue); - nested = nested[key]; - } - return object; - } + return fn(args); + }; - /** - * The base implementation of `setData` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var baseSetData = !metaMap ? identity : function(func, data) { - metaMap.set(func, data); - return func; - }; + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } - /** - * The base implementation of `setToString` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ - var baseSetToString = !defineProperty ? identity : function(func, string) { - return defineProperty(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': constant(string), - 'writable': true - }); - }; + return wrappedFn; +} - /** - * The base implementation of `_.shuffle`. - * - * @private - * @param {Array|Object} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. - */ - function baseShuffle(collection) { - return shuffleSelf(values(collection)); - } +function wrapRounded(fn) { + var wrappedFn = function (args) { + if (args === undefined || args === null) { + return args; + } - /** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function baseSlice(array, start, end) { - var index = -1, - length = array.length; + if (arguments.length > 1) { + args = Array.prototype.slice.call(arguments); + } - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = end > length ? length : end; - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; + var result = fn(args); - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; - } + // we're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (var len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } - /** - * The base implementation of `_.some` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ - function baseSome(collection, predicate) { - var result; + return result; + }; - baseEach(collection, function(value, index, collection) { - result = predicate(value, index, collection); - return !result; - }); - return !!result; - } + // preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } - /** - * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which - * performs a binary search of `array` to determine the index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function baseSortedIndex(array, value, retHighest) { - var low = 0, - high = array == null ? low : array.length; + return wrappedFn; +} - if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { - while (low < high) { - var mid = (low + high) >>> 1, - computed = array[mid]; +models.forEach(function (fromModel) { + convert[fromModel] = {}; - if (computed !== null && !isSymbol(computed) && - (retHighest ? (computed <= value) : (computed < value))) { - low = mid + 1; - } else { - high = mid; - } - } - return high; - } - return baseSortedIndexBy(array, value, identity, retHighest); - } + Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); + Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); - /** - * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` - * which invokes `iteratee` for `value` and each element of `array` to compute - * their sort ranking. The iteratee is invoked with one argument; (value). - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The iteratee invoked per element. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ - function baseSortedIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); + var routes = route(fromModel); + var routeModels = Object.keys(routes); + + routeModels.forEach(function (toModel) { + var fn = routes[toModel]; + + convert[fromModel][toModel] = wrapRounded(fn); + convert[fromModel][toModel].raw = wrapRaw(fn); + }); +}); - var low = 0, - high = array == null ? 0 : array.length, - valIsNaN = value !== value, - valIsNull = value === null, - valIsSymbol = isSymbol(value), - valIsUndefined = value === undefined; +module.exports = convert; - while (low < high) { - var mid = nativeFloor((low + high) / 2), - computed = iteratee(array[mid]), - othIsDefined = computed !== undefined, - othIsNull = computed === null, - othIsReflexive = computed === computed, - othIsSymbol = isSymbol(computed); - if (valIsNaN) { - var setLow = retHighest || othIsReflexive; - } else if (valIsUndefined) { - setLow = othIsReflexive && (retHighest || othIsDefined); - } else if (valIsNull) { - setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); - } else if (valIsSymbol) { - setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); - } else if (othIsNull || othIsSymbol) { - setLow = false; - } else { - setLow = retHighest ? (computed <= value) : (computed < value); - } - if (setLow) { - low = mid + 1; - } else { - high = mid; - } - } - return nativeMin(high, MAX_ARRAY_INDEX); - } +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ - function baseSortedUniq(array, iteratee) { - var index = -1, - length = array.length, - resIndex = 0, - result = []; +var conversions = __webpack_require__(2); - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; +/* + this function routes a model to all other models. - if (!index || !eq(computed, seen)) { - var seen = computed; - result[resIndex++] = value === 0 ? 0 : value; - } - } - return result; - } + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). - /** - * The base implementation of `_.toNumber` which doesn't ensure correct - * conversions of binary, hexadecimal, or octal string values. - * - * @private - * @param {*} value The value to process. - * @returns {number} Returns the number. - */ - function baseToNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - return +value; - } + conversions that are not possible simply are not included. +*/ - /** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ - function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isArray(value)) { - // Recursively convert values (susceptible to call stack limits). - return arrayMap(value, baseToString) + ''; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; - } +function buildGraph() { + var graph = {}; + // https://jsperf.com/object-keys-vs-for-in-with-closure/3 + var models = Object.keys(conversions); - /** - * The base implementation of `_.uniqBy` without support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ - function baseUniq(array, iteratee, comparator) { - var index = -1, - includes = arrayIncludes, - length = array.length, - isCommon = true, - result = [], - seen = result; + for (var len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } - if (comparator) { - isCommon = false; - includes = arrayIncludesWith; - } - else if (length >= LARGE_ARRAY_SIZE) { - var set = iteratee ? null : createSet(array); - if (set) { - return setToArray(set); - } - isCommon = false; - includes = cacheHas; - seen = new SetCache; - } - else { - seen = iteratee ? [] : result; - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; + return graph; +} - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } - else if (!includes(seen, computed, comparator)) { - if (seen !== result) { - seen.push(computed); - } - result.push(value); - } - } - return result; - } +// https://en.wikipedia.org/wiki/Breadth-first_search +function deriveBFS(fromModel) { + var graph = buildGraph(); + var queue = [fromModel]; // unshift -> queue -> pop - /** - * The base implementation of `_.unset`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The property path to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. - */ - function baseUnset(object, path) { - path = castPath(path, object); - object = parent(object, path); - return object == null || delete object[toKey(last(path))]; - } + graph[fromModel].distance = 0; - /** - * The base implementation of `_.update`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to update. - * @param {Function} updater The function to produce the updated value. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ - function baseUpdate(object, path, updater, customizer) { - return baseSet(object, path, updater(baseGet(object, path)), customizer); - } + while (queue.length) { + var current = queue.pop(); + var adjacents = Object.keys(conversions[current]); - /** - * The base implementation of methods like `_.dropWhile` and `_.takeWhile` - * without support for iteratee shorthands. - * - * @private - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [isDrop] Specify dropping elements instead of taking them. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the slice of `array`. - */ - function baseWhile(array, predicate, isDrop, fromRight) { - var length = array.length, - index = fromRight ? length : -1; + for (var len = adjacents.length, i = 0; i < len; i++) { + var adjacent = adjacents[i]; + var node = graph[adjacent]; - while ((fromRight ? index-- : ++index < length) && - predicate(array[index], index, array)) {} + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } - return isDrop - ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) - : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); - } + return graph; +} + +function link(from, to) { + return function (args) { + return to(from(args)); + }; +} + +function wrapConversion(toModel, graph) { + var path = [graph[toModel].parent, toModel]; + var fn = conversions[graph[toModel].parent][toModel]; - /** - * The base implementation of `wrapperValue` which returns the result of - * performing a sequence of actions on the unwrapped `value`, where each - * successive action is supplied the return value of the previous. - * - * @private - * @param {*} value The unwrapped value. - * @param {Array} actions Actions to perform to resolve the unwrapped value. - * @returns {*} Returns the resolved value. - */ - function baseWrapperValue(value, actions) { - var result = value; - if (result instanceof LazyWrapper) { - result = result.value(); - } - return arrayReduce(actions, function(result, action) { - return action.func.apply(action.thisArg, arrayPush([result], action.args)); - }, result); - } + var cur = graph[toModel].parent; + while (graph[cur].parent) { + path.unshift(graph[cur].parent); + fn = link(conversions[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } - /** - * The base implementation of methods like `_.xor`, without support for - * iteratee shorthands, that accepts an array of arrays to inspect. - * - * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of values. - */ - function baseXor(arrays, iteratee, comparator) { - var length = arrays.length; - if (length < 2) { - return length ? baseUniq(arrays[0]) : []; - } - var index = -1, - result = Array(length); + fn.conversion = path; + return fn; +} - while (++index < length) { - var array = arrays[index], - othIndex = -1; +module.exports = function (fromModel) { + var graph = deriveBFS(fromModel); + var conversion = {}; - while (++othIndex < length) { - if (othIndex != index) { - result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); - } - } - } - return baseUniq(baseFlatten(result, 1), iteratee, comparator); - } + var models = Object.keys(graph); + for (var len = models.length, i = 0; i < len; i++) { + var toModel = models[i]; + var node = graph[toModel]; - /** - * This base implementation of `_.zipObject` which assigns values using `assignFunc`. - * - * @private - * @param {Array} props The property identifiers. - * @param {Array} values The property values. - * @param {Function} assignFunc The function to assign values. - * @returns {Object} Returns the new object. - */ - function baseZipObject(props, values, assignFunc) { - var index = -1, - length = props.length, - valsLength = values.length, - result = {}; + if (node.parent === null) { + // no possible conversion, or this node is the source model. + continue; + } - while (++index < length) { - var value = index < valsLength ? values[index] : undefined; - assignFunc(result, props[index], value); - } - return result; - } + conversion[toModel] = wrapConversion(toModel, graph); + } - /** - * Casts `value` to an empty array if it's not an array like object. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array|Object} Returns the cast array-like object. - */ - function castArrayLikeObject(value) { - return isArrayLikeObject(value) ? value : []; - } + return conversion; +}; - /** - * Casts `value` to `identity` if it's not a function. - * - * @private - * @param {*} value The value to inspect. - * @returns {Function} Returns cast function. - */ - function castFunction(value) { - return typeof value == 'function' ? value : identity; - } - /** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @param {Object} [object] The object to query keys on. - * @returns {Array} Returns the cast property path array. - */ - function castPath(value, object) { - if (isArray(value)) { - return value; - } - return isKey(value, object) ? [value] : stringToPath(toString(value)); - } - /** - * A `baseRest` alias which can be replaced with `identity` by module - * replacement plugins. - * - * @private - * @type {Function} - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. - */ - var castRest = baseRest; +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; - /** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ - function castSlice(array, start, end) { - var length = array.length; - end = end === undefined ? length : end; - return (!start && end >= length) ? array : baseSlice(array, start, end); - } - /** - * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). - * - * @private - * @param {number|Object} id The timer id or timeout object of the timer to clear. - */ - var clearTimeout = ctxClearTimeout || function(id) { - return root.clearTimeout(id); - }; +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Creates a clone of `buffer`. - * - * @private - * @param {Buffer} buffer The buffer to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Buffer} Returns the cloned buffer. - */ - function cloneBuffer(buffer, isDeep) { - if (isDeep) { - return buffer.slice(); - } - var length = buffer.length, - result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); +/* MIT license */ +var colorNames = __webpack_require__(29); +var swizzle = __webpack_require__(41); +var hasOwnProperty = Object.hasOwnProperty; - buffer.copy(result); - return result; - } +var reverseNames = Object.create(null); - /** - * Creates a clone of `arrayBuffer`. - * - * @private - * @param {ArrayBuffer} arrayBuffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. - */ - function cloneArrayBuffer(arrayBuffer) { - var result = new arrayBuffer.constructor(arrayBuffer.byteLength); - new Uint8Array(result).set(new Uint8Array(arrayBuffer)); - return result; - } +// create a list of reverse color names +for (var name in colorNames) { + if (hasOwnProperty.call(colorNames, name)) { + reverseNames[colorNames[name]] = name; + } +} - /** - * Creates a clone of `dataView`. - * - * @private - * @param {Object} dataView The data view to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned data view. - */ - function cloneDataView(dataView, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; - return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); - } +var cs = module.exports = { + to: {}, + get: {} +}; - /** - * Creates a clone of `map`. - * - * @private - * @param {Object} map The map to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned map. - */ - function cloneMap(map, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); - return arrayReduce(array, addMapEntry, new map.constructor); - } +cs.get = function (string) { + var prefix = string.substring(0, 3).toLowerCase(); + var val; + var model; + switch (prefix) { + case 'hsl': + val = cs.get.hsl(string); + model = 'hsl'; + break; + case 'hwb': + val = cs.get.hwb(string); + model = 'hwb'; + break; + default: + val = cs.get.rgb(string); + model = 'rgb'; + break; + } - /** - * Creates a clone of `regexp`. - * - * @private - * @param {Object} regexp The regexp to clone. - * @returns {Object} Returns the cloned regexp. - */ - function cloneRegExp(regexp) { - var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); - result.lastIndex = regexp.lastIndex; - return result; - } + if (!val) { + return null; + } - /** - * Creates a clone of `set`. - * - * @private - * @param {Object} set The set to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned set. - */ - function cloneSet(set, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); - return arrayReduce(array, addSetEntry, new set.constructor); - } + return {model: model, value: val}; +}; - /** - * Creates a clone of the `symbol` object. - * - * @private - * @param {Object} symbol The symbol object to clone. - * @returns {Object} Returns the cloned symbol object. - */ - function cloneSymbol(symbol) { - return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; - } +cs.get.rgb = function (string) { + if (!string) { + return null; + } - /** - * Creates a clone of `typedArray`. - * - * @private - * @param {Object} typedArray The typed array to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned typed array. - */ - function cloneTypedArray(typedArray, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; - return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); - } + var abbr = /^#([a-f0-9]{3,4})$/i; + var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i; + var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/; + var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/; + var keyword = /^(\w+)$/; - /** - * Compares values to sort them in ascending order. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {number} Returns the sort order indicator for `value`. - */ - function compareAscending(value, other) { - if (value !== other) { - var valIsDefined = value !== undefined, - valIsNull = value === null, - valIsReflexive = value === value, - valIsSymbol = isSymbol(value); + var rgb = [0, 0, 0, 1]; + var match; + var i; + var hexAlpha; - var othIsDefined = other !== undefined, - othIsNull = other === null, - othIsReflexive = other === other, - othIsSymbol = isSymbol(other); + if (match = string.match(hex)) { + hexAlpha = match[2]; + match = match[1]; - if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || - (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || - (valIsNull && othIsDefined && othIsReflexive) || - (!valIsDefined && othIsReflexive) || - !valIsReflexive) { - return 1; - } - if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || - (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || - (othIsNull && valIsDefined && valIsReflexive) || - (!othIsDefined && valIsReflexive) || - !othIsReflexive) { - return -1; - } - } - return 0; - } + for (i = 0; i < 3; i++) { + // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19 + var i2 = i * 2; + rgb[i] = parseInt(match.slice(i2, i2 + 2), 16); + } - /** - * Used by `_.orderBy` to compare multiple properties of a value to another - * and stable sort them. - * - * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, - * specify an order of "desc" for descending or "asc" for ascending sort order - * of corresponding values. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {boolean[]|string[]} orders The order to sort by for each property. - * @returns {number} Returns the sort order indicator for `object`. - */ - function compareMultiple(object, other, orders) { - var index = -1, - objCriteria = object.criteria, - othCriteria = other.criteria, - length = objCriteria.length, - ordersLength = orders.length; + if (hexAlpha) { + rgb[3] = parseInt(hexAlpha, 16) / 255; + } + } else if (match = string.match(abbr)) { + match = match[1]; + hexAlpha = match[3]; - while (++index < length) { - var result = compareAscending(objCriteria[index], othCriteria[index]); - if (result) { - if (index >= ordersLength) { - return result; - } - var order = orders[index]; - return result * (order == 'desc' ? -1 : 1); - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; - } + for (i = 0; i < 3; i++) { + rgb[i] = parseInt(match[i] + match[i], 16); + } - /** - * Creates an array that is the composition of partially applied arguments, - * placeholders, and provided arguments into a single array of arguments. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to prepend to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ - function composeArgs(args, partials, holders, isCurried) { - var argsIndex = -1, - argsLength = args.length, - holdersLength = holders.length, - leftIndex = -1, - leftLength = partials.length, - rangeLength = nativeMax(argsLength - holdersLength, 0), - result = Array(leftLength + rangeLength), - isUncurried = !isCurried; + if (hexAlpha) { + rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255; + } + } else if (match = string.match(rgba)) { + for (i = 0; i < 3; i++) { + rgb[i] = parseInt(match[i + 1], 0); + } - while (++leftIndex < leftLength) { - result[leftIndex] = partials[leftIndex]; - } - while (++argsIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[holders[argsIndex]] = args[argsIndex]; - } - } - while (rangeLength--) { - result[leftIndex++] = args[argsIndex++]; - } - return result; - } + if (match[4]) { + if (match[5]) { + rgb[3] = parseFloat(match[4]) * 0.01; + } else { + rgb[3] = parseFloat(match[4]); + } + } + } else if (match = string.match(per)) { + for (i = 0; i < 3; i++) { + rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55); + } - /** - * This function is like `composeArgs` except that the arguments composition - * is tailored for `_.partialRight`. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to append to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ - function composeArgsRight(args, partials, holders, isCurried) { - var argsIndex = -1, - argsLength = args.length, - holdersIndex = -1, - holdersLength = holders.length, - rightIndex = -1, - rightLength = partials.length, - rangeLength = nativeMax(argsLength - holdersLength, 0), - result = Array(rangeLength + rightLength), - isUncurried = !isCurried; + if (match[4]) { + if (match[5]) { + rgb[3] = parseFloat(match[4]) * 0.01; + } else { + rgb[3] = parseFloat(match[4]); + } + } + } else if (match = string.match(keyword)) { + if (match[1] === 'transparent') { + return [0, 0, 0, 0]; + } - while (++argsIndex < rangeLength) { - result[argsIndex] = args[argsIndex]; - } - var offset = argsIndex; - while (++rightIndex < rightLength) { - result[offset + rightIndex] = partials[rightIndex]; - } - while (++holdersIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[offset + holders[holdersIndex]] = args[argsIndex++]; - } - } - return result; - } + if (!hasOwnProperty.call(colorNames, match[1])) { + return null; + } - /** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ - function copyArray(source, array) { - var index = -1, - length = source.length; + rgb = colorNames[match[1]]; + rgb[3] = 1; - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; - } + return rgb; + } else { + return null; + } - /** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ - function copyObject(source, props, object, customizer) { - var isNew = !object; - object || (object = {}); + for (i = 0; i < 3; i++) { + rgb[i] = clamp(rgb[i], 0, 255); + } + rgb[3] = clamp(rgb[3], 0, 1); - var index = -1, - length = props.length; + return rgb; +}; - while (++index < length) { - var key = props[index]; +cs.get.hsl = function (string) { + if (!string) { + return null; + } - var newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; + var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/; + var match = string.match(hsl); - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - baseAssignValue(object, key, newValue); - } else { - assignValue(object, key, newValue); - } - } - return object; - } + if (match) { + var alpha = parseFloat(match[4]); + var h = ((parseFloat(match[1]) % 360) + 360) % 360; + var s = clamp(parseFloat(match[2]), 0, 100); + var l = clamp(parseFloat(match[3]), 0, 100); + var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1); - /** - * Copies own symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ - function copySymbols(source, object) { - return copyObject(source, getSymbols(source), object); - } + return [h, s, l, a]; + } - /** - * Copies own and inherited symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ - function copySymbolsIn(source, object) { - return copyObject(source, getSymbolsIn(source), object); - } + return null; +}; - /** - * Creates a function like `_.groupBy`. - * - * @private - * @param {Function} setter The function to set accumulator values. - * @param {Function} [initializer] The accumulator object initializer. - * @returns {Function} Returns the new aggregator function. - */ - function createAggregator(setter, initializer) { - return function(collection, iteratee) { - var func = isArray(collection) ? arrayAggregator : baseAggregator, - accumulator = initializer ? initializer() : {}; +cs.get.hwb = function (string) { + if (!string) { + return null; + } - return func(collection, setter, getIteratee(iteratee, 2), accumulator); - }; - } + var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/; + var match = string.match(hwb); - /** - * Creates a function like `_.assign`. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ - function createAssigner(assigner) { - return baseRest(function(object, sources) { - var index = -1, - length = sources.length, - customizer = length > 1 ? sources[length - 1] : undefined, - guard = length > 2 ? sources[2] : undefined; + if (match) { + var alpha = parseFloat(match[4]); + var h = ((parseFloat(match[1]) % 360) + 360) % 360; + var w = clamp(parseFloat(match[2]), 0, 100); + var b = clamp(parseFloat(match[3]), 0, 100); + var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1); + return [h, w, b, a]; + } + + return null; +}; - customizer = (assigner.length > 3 && typeof customizer == 'function') - ? (length--, customizer) - : undefined; +cs.to.hex = function () { + var rgba = swizzle(arguments); - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }); - } + return ( + '#' + + hexDouble(rgba[0]) + + hexDouble(rgba[1]) + + hexDouble(rgba[2]) + + (rgba[3] < 1 + ? (hexDouble(Math.round(rgba[3] * 255))) + : '') + ); +}; - /** - * Creates a `baseEach` or `baseEachRight` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return eachFunc(collection, iteratee); - } - var length = collection.length, - index = fromRight ? length : -1, - iterable = Object(collection); +cs.to.rgb = function () { + var rgba = swizzle(arguments); - while ((fromRight ? index-- : ++index < length)) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; - } + return rgba.length < 4 || rgba[3] === 1 + ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')' + : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')'; +}; - /** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; +cs.to.rgb.percent = function () { + var rgba = swizzle(arguments); - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; - } + var r = Math.round(rgba[0] / 255 * 100); + var g = Math.round(rgba[1] / 255 * 100); + var b = Math.round(rgba[2] / 255 * 100); - /** - * Creates a function that wraps `func` to invoke it with the optional `this` - * binding of `thisArg`. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createBind(func, bitmask, thisArg) { - var isBind = bitmask & WRAP_BIND_FLAG, - Ctor = createCtor(func); + return rgba.length < 4 || rgba[3] === 1 + ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)' + : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')'; +}; - function wrapper() { - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return fn.apply(isBind ? thisArg : this, arguments); - } - return wrapper; - } +cs.to.hsl = function () { + var hsla = swizzle(arguments); + return hsla.length < 4 || hsla[3] === 1 + ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)' + : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')'; +}; - /** - * Creates a function like `_.lowerFirst`. - * - * @private - * @param {string} methodName The name of the `String` case method to use. - * @returns {Function} Returns the new case function. - */ - function createCaseFirst(methodName) { - return function(string) { - string = toString(string); +// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax +// (hwb have alpha optional & 1 is default value) +cs.to.hwb = function () { + var hwba = swizzle(arguments); - var strSymbols = hasUnicode(string) - ? stringToArray(string) - : undefined; + var a = ''; + if (hwba.length >= 4 && hwba[3] !== 1) { + a = ', ' + hwba[3]; + } - var chr = strSymbols - ? strSymbols[0] - : string.charAt(0); + return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')'; +}; - var trailing = strSymbols - ? castSlice(strSymbols, 1).join('') - : string.slice(1); +cs.to.keyword = function (rgb) { + return reverseNames[rgb.slice(0, 3)]; +}; - return chr[methodName]() + trailing; - }; - } +// helpers +function clamp(num, min, max) { + return Math.min(Math.max(min, num), max); +} - /** - * Creates a function like `_.camelCase`. - * - * @private - * @param {Function} callback The function to combine each word. - * @returns {Function} Returns the new compounder function. - */ - function createCompounder(callback) { - return function(string) { - return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); - }; - } +function hexDouble(num) { + var str = Math.round(num).toString(16).toUpperCase(); + return (str.length < 2) ? '0' + str : str; +} - /** - * Creates a function that produces an instance of `Ctor` regardless of - * whether it was invoked as part of a `new` expression or by `call` or `apply`. - * - * @private - * @param {Function} Ctor The constructor to wrap. - * @returns {Function} Returns the new wrapped function. - */ - function createCtor(Ctor) { - return function() { - // Use a `switch` statement to work with class constructors. See - // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist - // for more details. - var args = arguments; - switch (args.length) { - case 0: return new Ctor; - case 1: return new Ctor(args[0]); - case 2: return new Ctor(args[0], args[1]); - case 3: return new Ctor(args[0], args[1], args[2]); - case 4: return new Ctor(args[0], args[1], args[2], args[3]); - case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); - case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); - case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - } - var thisBinding = baseCreate(Ctor.prototype), - result = Ctor.apply(thisBinding, args); - // Mimic the constructor's `return` behavior. - // See https://es5.github.io/#x13.2.2 for more details. - return isObject(result) ? result : thisBinding; - }; - } +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; + - /** - * Creates a function that wraps `func` to enable currying. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {number} arity The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createCurry(func, bitmask, arity) { - var Ctor = createCtor(func); +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { - function wrapper() { - var length = arguments.length, - args = Array(length), - index = length, - placeholder = getHolder(wrapper); +/** + * Box-Muller implementation + * https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform + */ - while (index--) { - args[index] = arguments[index]; - } - var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) - ? [] - : replaceHolders(args, placeholder); +(function(exports){ + const PRECISION = 1e9; + const _2PI = Math.PI * 2; - length -= holders.length; - if (length < arity) { - return createRecurry( - func, bitmask, createHybrid, wrapper.placeholder, undefined, - args, holders, undefined, undefined, arity - length); - } - var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - return apply(fn, this, args); - } - return wrapper; + /** + * + * @param {number} mean + * @param {number} std + * @param randFn - an optional function that returns a float between 0 (inclusive) and 1 + * (exclusive). Use this if you want to pass in a random number generator other than + * Math.random(). + * @returns {number} + */ + function generateGaussian(mean,std, randFn = null){ + var u1; + var u2; + if (randFn) { + u1 = randFn(); + u2 = randFn(); } - - /** - * Creates a `_.find` or `_.findLast` function. - * - * @private - * @param {Function} findIndexFunc The function to find the collection index. - * @returns {Function} Returns the new find function. - */ - function createFind(findIndexFunc) { - return function(collection, predicate, fromIndex) { - var iterable = Object(collection); - if (!isArrayLike(collection)) { - var iteratee = getIteratee(predicate, 3); - collection = keys(collection); - predicate = function(key) { return iteratee(iterable[key], key, iterable); }; - } - var index = findIndexFunc(collection, predicate, fromIndex); - return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; - }; + else { + u1 = Math.random(); + u2 = Math.random(); } + + var z0 = Math.sqrt(-2.0 * Math.log(u1)) * Math.cos(_2PI * u2); + var z1 = Math.sqrt(-2.0 * Math.log(u1)) * Math.sin(_2PI * u2); - /** - * Creates a `_.flow` or `_.flowRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new flow function. - */ - function createFlow(fromRight) { - return flatRest(function(funcs) { - var length = funcs.length, - index = length, - prereq = LodashWrapper.prototype.thru; - - if (fromRight) { - funcs.reverse(); - } - while (index--) { - var func = funcs[index]; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (prereq && !wrapper && getFuncName(func) == 'wrapper') { - var wrapper = new LodashWrapper([], true); - } - } - index = wrapper ? index : length; - while (++index < length) { - func = funcs[index]; - - var funcName = getFuncName(func), - data = funcName == 'wrapper' ? getData(func) : undefined; - - if (data && isLaziable(data[0]) && - data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && - !data[4].length && data[9] == 1 - ) { - wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); - } else { - wrapper = (func.length == 1 && isLaziable(func)) - ? wrapper[funcName]() - : wrapper.thru(func); - } - } - return function() { - var args = arguments, - value = args[0]; - - if (wrapper && args.length == 1 && isArray(value)) { - return wrapper.plant(value).value(); - } - var index = 0, - result = length ? funcs[index].apply(this, args) : value; - - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; - }); - } + return z0 * std + mean; + } - /** - * Creates a function that wraps `func` to invoke it with optional `this` - * binding of `thisArg`, partial application, and currying. - * - * @private - * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to - * the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [partialsRight] The arguments to append to those provided - * to the new function. - * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { - var isAry = bitmask & WRAP_ARY_FLAG, - isBind = bitmask & WRAP_BIND_FLAG, - isBindKey = bitmask & WRAP_BIND_KEY_FLAG, - isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), - isFlip = bitmask & WRAP_FLIP_FLAG, - Ctor = isBindKey ? undefined : createCtor(func); + exports(generateGaussian) +}) +( true + ? function(e) { module.exports = e; } + // istanbul ignore next + : function(e) { this["boxmuller"] = e; }); + - function wrapper() { - var length = arguments.length, - args = Array(length), - index = length; - while (index--) { - args[index] = arguments[index]; - } - if (isCurried) { - var placeholder = getHolder(wrapper), - holdersCount = countHolders(args, placeholder); - } - if (partials) { - args = composeArgs(args, partials, holders, isCurried); - } - if (partialsRight) { - args = composeArgsRight(args, partialsRight, holdersRight, isCurried); - } - length -= holdersCount; - if (isCurried && length < arity) { - var newHolders = replaceHolders(args, placeholder); - return createRecurry( - func, bitmask, createHybrid, wrapper.placeholder, thisArg, - args, newHolders, argPos, ary, arity - length - ); - } - var thisBinding = isBind ? thisArg : this, - fn = isBindKey ? thisBinding[func] : func; +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { - length = args.length; - if (argPos) { - args = reorder(args, argPos); - } else if (isFlip && length > 1) { - args.reverse(); - } - if (isAry && ary < length) { - args.length = ary; - } - if (this && this !== root && this instanceof wrapper) { - fn = Ctor || createCtor(fn); - } - return fn.apply(thisBinding, args); - } - return wrapper; - } +"use strict"; - /** - * Creates a function like `_.invertBy`. - * - * @private - * @param {Function} setter The function to set accumulator values. - * @param {Function} toIteratee The function to resolve iteratees. - * @returns {Function} Returns the new inverter function. - */ - function createInverter(setter, toIteratee) { - return function(object, iteratee) { - return baseInverter(object, setter, toIteratee(iteratee), {}); - }; - } - /** - * Creates a function that performs a mathematical operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @param {number} [defaultValue] The value used for `undefined` arguments. - * @returns {Function} Returns the new mathematical operation function. - */ - function createMathOperation(operator, defaultValue) { - return function(value, other) { - var result; - if (value === undefined && other === undefined) { - return defaultValue; - } - if (value !== undefined) { - result = value; - } - if (other !== undefined) { - if (result === undefined) { - return other; - } - if (typeof value == 'string' || typeof other == 'string') { - value = baseToString(value); - other = baseToString(other); - } else { - value = baseToNumber(value); - other = baseToNumber(other); - } - result = operator(value, other); - } - return result; - }; - } +/* eslint complexity: [2, 18], max-statements: [2, 33] */ +module.exports = function hasSymbols() { + if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } + if (typeof Symbol.iterator === 'symbol') { return true; } - /** - * Creates a function like `_.over`. - * - * @private - * @param {Function} arrayFunc The function to iterate over iteratees. - * @returns {Function} Returns the new over function. - */ - function createOver(arrayFunc) { - return flatRest(function(iteratees) { - iteratees = arrayMap(iteratees, baseUnary(getIteratee())); - return baseRest(function(args) { - var thisArg = this; - return arrayFunc(iteratees, function(iteratee) { - return apply(iteratee, thisArg, args); - }); - }); - }); - } + var obj = {}; + var sym = Symbol('test'); + var symObj = Object(sym); + if (typeof sym === 'string') { return false; } - /** - * Creates the padding for `string` based on `length`. The `chars` string - * is truncated if the number of characters exceeds `length`. - * - * @private - * @param {number} length The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padding for `string`. - */ - function createPadding(length, chars) { - chars = chars === undefined ? ' ' : baseToString(chars); + if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } + if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } - var charsLength = chars.length; - if (charsLength < 2) { - return charsLength ? baseRepeat(chars, length) : chars; - } - var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); - return hasUnicode(chars) - ? castSlice(stringToArray(result), 0, length).join('') - : result.slice(0, length); - } + // temp disabled per https://github.com/ljharb/object.assign/issues/17 + // if (sym instanceof Symbol) { return false; } + // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 + // if (!(symObj instanceof Symbol)) { return false; } - /** - * Creates a function that wraps `func` to invoke it with the `this` binding - * of `thisArg` and `partials` prepended to the arguments it receives. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to - * the new function. - * @returns {Function} Returns the new wrapped function. - */ - function createPartial(func, bitmask, thisArg, partials) { - var isBind = bitmask & WRAP_BIND_FLAG, - Ctor = createCtor(func); + // if (typeof Symbol.prototype.toString !== 'function') { return false; } + // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } - function wrapper() { - var argsIndex = -1, - argsLength = arguments.length, - leftIndex = -1, - leftLength = partials.length, - args = Array(leftLength + argsLength), - fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + var symVal = 42; + obj[sym] = symVal; + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } - while (++leftIndex < leftLength) { - args[leftIndex] = partials[leftIndex]; - } - while (argsLength--) { - args[leftIndex++] = arguments[++argsIndex]; - } - return apply(fn, isBind ? thisArg : this, args); - } - return wrapper; - } + if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } - /** - * Creates a `_.range` or `_.rangeRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new range function. - */ - function createRange(fromRight) { - return function(start, end, step) { - if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { - end = step = undefined; - } - // Ensure the sign of `-0` is preserved. - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); - } - step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); - return baseRange(start, end, step, fromRight); - }; - } + var syms = Object.getOwnPropertySymbols(obj); + if (syms.length !== 1 || syms[0] !== sym) { return false; } - /** - * Creates a function that performs a relational operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @returns {Function} Returns the new relational operation function. - */ - function createRelationalOperation(operator) { - return function(value, other) { - if (!(typeof value == 'string' && typeof other == 'string')) { - value = toNumber(value); - other = toNumber(other); - } - return operator(value, other); - }; - } + if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } - /** - * Creates a function that wraps `func` to continue currying. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {Function} wrapFunc The function to create the `func` wrapper. - * @param {*} placeholder The placeholder value. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to - * the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { - var isCurry = bitmask & WRAP_CURRY_FLAG, - newHolders = isCurry ? holders : undefined, - newHoldersRight = isCurry ? undefined : holders, - newPartials = isCurry ? partials : undefined, - newPartialsRight = isCurry ? undefined : partials; + if (typeof Object.getOwnPropertyDescriptor === 'function') { + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); + if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } + } - bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); - bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); + return true; +}; - if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { - bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); - } - var newData = [ - func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, - newHoldersRight, argPos, ary, arity - ]; - var result = wrapFunc.apply(undefined, newData); - if (isLaziable(func)) { - setData(result, newData); - } - result.placeholder = placeholder; - return setWrapToString(result, func, bitmask); - } +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var hasSymbols = __webpack_require__(31); + +module.exports = function hasToStringTagShams() { + return hasSymbols() && !!Symbol.toStringTag; +}; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { - /** - * Creates a function like `_.round`. - * - * @private - * @param {string} methodName The name of the `Math` method to use when rounding. - * @returns {Function} Returns the new round function. - */ - function createRound(methodName) { - var func = Math[methodName]; - return function(number, precision) { - number = toNumber(number); - precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); - if (precision) { - // Shift with exponential notation to avoid floating-point issues. - // See [MDN](https://mdn.io/round#Examples) for more details. - var pair = (toString(number) + 'e').split('e'), - value = func(pair[0] + 'e' + (+pair[1] + precision)); +module.exports = function isArrayish(obj) { + if (!obj || typeof obj === 'string') { + return false; + } - pair = (toString(value) + 'e').split('e'); - return +(pair[0] + 'e' + (+pair[1] - precision)); - } - return func(number); - }; - } + return obj instanceof Array || Array.isArray(obj) || + (obj.length >= 0 && (obj.splice instanceof Function || + (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String'))); +}; - /** - * Creates a set object of `values`. - * - * @private - * @param {Array} values The values to add to the set. - * @returns {Object} Returns the new set. - */ - var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { - return new Set(values); - }; - /** - * Creates a `_.toPairs` or `_.toPairsIn` function. - * - * @private - * @param {Function} keysFunc The function to get the keys of a given object. - * @returns {Function} Returns the new pairs function. - */ - function createToPairs(keysFunc) { - return function(object) { - var tag = getTag(object); - if (tag == mapTag) { - return mapToArray(object); - } - if (tag == setTag) { - return setToPairs(object); - } - return baseToPairs(object, keysFunc(object)); - }; - } +/***/ }), +/* 34 */ +/***/ (function(module, exports) { - /** - * Creates a function that either curries or invokes `func` with optional - * `this` binding and partially applied arguments. - * - * @private - * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask flags. - * 1 - `_.bind` - * 2 - `_.bindKey` - * 4 - `_.curry` or `_.curryRight` of a bound function - * 8 - `_.curry` - * 16 - `_.curryRight` - * 32 - `_.partial` - * 64 - `_.partialRight` - * 128 - `_.rearg` - * 256 - `_.ary` - * 512 - `_.flip` - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ - function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { - var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; - if (!isBindKey && typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - var length = partials ? partials.length : 0; - if (!length) { - bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); - partials = holders = undefined; - } - ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); - arity = arity === undefined ? arity : toInteger(arity); - length -= holders ? holders.length : 0; +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh <https://feross.org> + * @license MIT + */ - if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { - var partialsRight = partials, - holdersRight = holders; +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) +} - partials = holders = undefined; - } - var data = isBindKey ? undefined : getData(func); +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} - var newData = [ - func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, - argPos, ary, arity - ]; +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) +} - if (data) { - mergeData(newData, data); - } - func = newData[0]; - bitmask = newData[1]; - thisArg = newData[2]; - partials = newData[3]; - holders = newData[4]; - arity = newData[9] = newData[9] === undefined - ? (isBindKey ? 0 : func.length) - : nativeMax(newData[9] - length, 0); - if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { - bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); - } - if (!bitmask || bitmask == WRAP_BIND_FLAG) { - var result = createBind(func, bitmask, thisArg); - } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { - result = createCurry(func, bitmask, arity); - } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { - result = createPartial(func, bitmask, thisArg, partials); - } else { - result = createHybrid.apply(undefined, newData); - } - var setter = data ? baseSetData : setData; - return setWrapToString(setter(result, newData), func, bitmask); - } +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Used by `_.defaults` to customize its `_.assignIn` use to assign properties - * of source objects to the destination object for all destination properties - * that resolve to `undefined`. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to assign. - * @param {Object} object The parent object of `objValue`. - * @returns {*} Returns the value to assign. - */ - function customDefaultsAssignIn(objValue, srcValue, key, object) { - if (objValue === undefined || - (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { - return srcValue; - } - return objValue; - } +var isBuffer = __webpack_require__(34); +var toString = Object.prototype.toString; - /** - * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source - * objects into destination objects that are passed thru. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to merge. - * @param {Object} object The parent object of `objValue`. - * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - * @returns {*} Returns the value to assign. - */ - function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { - if (isObject(objValue) && isObject(srcValue)) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, objValue); - baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); - stack['delete'](srcValue); - } - return objValue; - } +/** + * Get the native `typeof` a value. + * + * @param {*} `val` + * @return {*} Native javascript type + */ - /** - * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain - * objects. - * - * @private - * @param {*} value The value to inspect. - * @param {string} key The key of the property to inspect. - * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. - */ - function customOmitClone(value) { - return isPlainObject(value) ? undefined : value; - } +module.exports = function kindOf(val) { + // primitivies + if (typeof val === 'undefined') { + return 'undefined'; + } + if (val === null) { + return 'null'; + } + if (val === true || val === false || val instanceof Boolean) { + return 'boolean'; + } + if (typeof val === 'string' || val instanceof String) { + return 'string'; + } + if (typeof val === 'number' || val instanceof Number) { + return 'number'; + } - /** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ - function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - arrLength = array.length, - othLength = other.length; + // functions + if (typeof val === 'function' || val instanceof Function) { + return 'function'; + } - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, - result = true, - seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + // array + if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) { + return 'array'; + } - stack.set(array, other); - stack.set(other, array); + // check for instances of RegExp and Date before calling `toString` + if (val instanceof RegExp) { + return 'regexp'; + } + if (val instanceof Date) { + return 'date'; + } - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; + // other objects + var type = toString.call(val); - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!cacheHas(seen, othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, bitmask, customizer, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; - } + if (type === '[object RegExp]') { + return 'regexp'; + } + if (type === '[object Date]') { + return 'date'; + } + if (type === '[object Arguments]') { + return 'arguments'; + } + if (type === '[object Error]') { + return 'error'; + } - /** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; + // buffer + if (isBuffer(val)) { + return 'buffer'; + } - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; + // es6: Map, WeakMap, Set, WeakSet + if (type === '[object Set]') { + return 'set'; + } + if (type === '[object WeakSet]') { + return 'weakset'; + } + if (type === '[object Map]') { + return 'map'; + } + if (type === '[object WeakMap]') { + return 'weakmap'; + } + if (type === '[object Symbol]') { + return 'symbol'; + } - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); + // typed arrays + if (type === '[object Int8Array]') { + return 'int8array'; + } + if (type === '[object Uint8Array]') { + return 'uint8array'; + } + if (type === '[object Uint8ClampedArray]') { + return 'uint8clampedarray'; + } + if (type === '[object Int16Array]') { + return 'int16array'; + } + if (type === '[object Uint16Array]') { + return 'uint16array'; + } + if (type === '[object Int32Array]') { + return 'int32array'; + } + if (type === '[object Uint32Array]') { + return 'uint32array'; + } + if (type === '[object Float32Array]') { + return 'float32array'; + } + if (type === '[object Float64Array]') { + return 'float64array'; + } - case errorTag: - return object.name == other.name && object.message == other.message; + // must be a plain object + return 'object'; +}; - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); - case mapTag: - var convert = mapToArray; +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert || (convert = setToArray); +/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/** + * @license + * Lodash <https://lodash.com/> + * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> + * Released under MIT license <https://lodash.com/license> + * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +;(function() { - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); - stack['delete'](object); - return result; + /** Used as the semantic version number. */ + var VERSION = '4.17.21'; - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; - } + /** Used as the size to enable large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; - /** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - objProps = getAllKeys(object), - objLength = objProps.length, - othProps = getAllKeys(other), - othLength = othProps.length; + /** Error message constants. */ + var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', + FUNC_ERROR_TEXT = 'Expected a function', + INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); + /** Used to stand-in for `undefined` hash values. */ + var HASH_UNDEFINED = '__lodash_hash_undefined__'; + + /** Used as the maximum memoize cache size. */ + var MAX_MEMOIZE_SIZE = 500; + + /** Used as the internal argument placeholder. */ + var PLACEHOLDER = '__lodash_placeholder__'; - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; + /** Used to compose bitmasks for cloning. */ + var CLONE_DEEP_FLAG = 1, + CLONE_FLAT_FLAG = 2, + CLONE_SYMBOLS_FLAG = 4; - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; + /** Used to compose bitmasks for value comparisons. */ + var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } - } - stack['delete'](object); - stack['delete'](other); - return result; - } + /** Used to compose bitmasks for function metadata. */ + var WRAP_BIND_FLAG = 1, + WRAP_BIND_KEY_FLAG = 2, + WRAP_CURRY_BOUND_FLAG = 4, + WRAP_CURRY_FLAG = 8, + WRAP_CURRY_RIGHT_FLAG = 16, + WRAP_PARTIAL_FLAG = 32, + WRAP_PARTIAL_RIGHT_FLAG = 64, + WRAP_ARY_FLAG = 128, + WRAP_REARG_FLAG = 256, + WRAP_FLIP_FLAG = 512; - /** - * A specialized version of `baseRest` which flattens the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. - */ - function flatRest(func) { - return setToString(overRest(func, undefined, flatten), func + ''); - } + /** Used as default options for `_.truncate`. */ + var DEFAULT_TRUNC_LENGTH = 30, + DEFAULT_TRUNC_OMISSION = '...'; - /** - * Creates an array of own enumerable property names and symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ - function getAllKeys(object) { - return baseGetAllKeys(object, keys, getSymbols); - } + /** Used to detect hot functions by number of calls within a span of milliseconds. */ + var HOT_COUNT = 800, + HOT_SPAN = 16; - /** - * Creates an array of own and inherited enumerable property names and - * symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ - function getAllKeysIn(object) { - return baseGetAllKeys(object, keysIn, getSymbolsIn); - } + /** Used to indicate the type of lazy iteratees. */ + var LAZY_FILTER_FLAG = 1, + LAZY_MAP_FLAG = 2, + LAZY_WHILE_FLAG = 3; - /** - * Gets metadata for `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {*} Returns the metadata for `func`. - */ - var getData = !metaMap ? noop : function(func) { - return metaMap.get(func); - }; + /** Used as references for various `Number` constants. */ + var INFINITY = 1 / 0, + MAX_SAFE_INTEGER = 9007199254740991, + MAX_INTEGER = 1.7976931348623157e+308, + NAN = 0 / 0; - /** - * Gets the name of `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {string} Returns the function name. - */ - function getFuncName(func) { - var result = (func.name + ''), - array = realNames[result], - length = hasOwnProperty.call(realNames, result) ? array.length : 0; + /** Used as references for the maximum length and index of an array. */ + var MAX_ARRAY_LENGTH = 4294967295, + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - while (length--) { - var data = array[length], - otherFunc = data.func; - if (otherFunc == null || otherFunc == func) { - return data.name; - } - } - return result; - } + /** Used to associate wrap methods with their bit flags. */ + var wrapFlags = [ + ['ary', WRAP_ARY_FLAG], + ['bind', WRAP_BIND_FLAG], + ['bindKey', WRAP_BIND_KEY_FLAG], + ['curry', WRAP_CURRY_FLAG], + ['curryRight', WRAP_CURRY_RIGHT_FLAG], + ['flip', WRAP_FLIP_FLAG], + ['partial', WRAP_PARTIAL_FLAG], + ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], + ['rearg', WRAP_REARG_FLAG] + ]; - /** - * Gets the argument placeholder value for `func`. - * - * @private - * @param {Function} func The function to inspect. - * @returns {*} Returns the placeholder value. - */ - function getHolder(func) { - var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; - return object.placeholder; - } + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + domExcTag = '[object DOMException]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + nullTag = '[object Null]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + proxyTag = '[object Proxy]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + undefinedTag = '[object Undefined]', + weakMapTag = '[object WeakMap]', + weakSetTag = '[object WeakSet]'; - /** - * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, - * this function returns the custom method, otherwise it returns `baseIteratee`. - * If arguments are provided, the chosen function is invoked with them and - * its result is returned. - * - * @private - * @param {*} [value] The value to convert to an iteratee. - * @param {number} [arity] The arity of the created iteratee. - * @returns {Function} Returns the chosen function or its result. - */ - function getIteratee() { - var result = lodash.iteratee || iteratee; - result = result === iteratee ? baseIteratee : result; - return arguments.length ? result(arguments[0], arguments[1]) : result; - } + var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; - /** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ - function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; - } + /** Used to match empty string literals in compiled template source. */ + var reEmptyStringLeading = /\b__p \+= '';/g, + reEmptyStringMiddle = /\b(__p \+=) '' \+/g, + reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - /** - * Gets the property names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ - function getMatchData(object) { - var result = keys(object), - length = result.length; + /** Used to match HTML entities and HTML characters. */ + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, + reUnescapedHtml = /[&<>"']/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); - while (length--) { - var key = result[length], - value = object[key]; + /** Used to match template delimiters. */ + var reEscape = /<%-([\s\S]+?)%>/g, + reEvaluate = /<%([\s\S]+?)%>/g, + reInterpolate = /<%=([\s\S]+?)%>/g; + + /** Used to match property names within property paths. */ + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + + /** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, + reHasRegExpChar = RegExp(reRegExpChar.source); - result[length] = [key, value, isStrictComparable(value)]; - } - return result; - } + /** Used to match leading whitespace. */ + var reTrimStart = /^\s+/; - /** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ - function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; - } + /** Used to match a single whitespace character. */ + var reWhitespace = /\s/; - /** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. - */ - function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), - tag = value[symToStringTag]; + /** Used to match wrap detail comments. */ + var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, + reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, + reSplitDetails = /,? & /; - try { - value[symToStringTag] = undefined; - var unmasked = true; - } catch (e) {} + /** Used to match words composed of alphanumeric characters. */ + var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; - } + /** + * Used to validate the `validate` option in `_.template` variable. + * + * Forbids characters which could potentially change the meaning of the function argument definition: + * - "()," (modification of function parameters) + * - "=" (default value) + * - "[]{}" (destructuring of function parameters) + * - "/" (beginning of a comment) + * - whitespace + */ + var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; - /** - * Creates an array of the own enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ - var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); - }; + /** Used to match backslashes in property paths. */ + var reEscapeChar = /\\(\\)?/g; - /** - * Creates an array of the own and inherited enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ - var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { - var result = []; - while (object) { - arrayPush(result, getSymbols(object)); - object = getPrototype(object); - } - return result; - }; + /** + * Used to match + * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). + */ + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - /** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ - var getTag = baseGetTag; + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; - // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. - if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = baseGetTag(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : ''; + /** Used to detect bad signed hexadecimal string values. */ + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; - } + /** Used to detect binary string values. */ + var reIsBinary = /^0b[01]+$/i; - /** - * Gets the view, applying any `transforms` to the `start` and `end` positions. - * - * @private - * @param {number} start The start of the view. - * @param {number} end The end of the view. - * @param {Array} transforms The transformations to apply to the view. - * @returns {Object} Returns an object containing the `start` and `end` - * positions of the view. - */ - function getView(start, end, transforms) { - var index = -1, - length = transforms.length; + /** Used to detect host constructors (Safari). */ + var reIsHostCtor = /^\[object .+?Constructor\]$/; - while (++index < length) { - var data = transforms[index], - size = data.size; + /** Used to detect octal string values. */ + var reIsOctal = /^0o[0-7]+$/i; - switch (data.type) { - case 'drop': start += size; break; - case 'dropRight': end -= size; break; - case 'take': end = nativeMin(end, start + size); break; - case 'takeRight': start = nativeMax(start, end - size); break; - } - } - return { 'start': start, 'end': end }; - } + /** Used to detect unsigned integer values. */ + var reIsUint = /^(?:0|[1-9]\d*)$/; - /** - * Extracts wrapper details from the `source` body comment. - * - * @private - * @param {string} source The source to inspect. - * @returns {Array} Returns the wrapper details. - */ - function getWrapDetails(source) { - var match = source.match(reWrapDetails); - return match ? match[1].split(reSplitDetails) : []; - } + /** Used to match Latin Unicode letters (excluding mathematical operators). */ + var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; - /** - * Checks if `path` exists on `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @param {Function} hasFunc The function to check properties. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - */ - function hasPath(object, path, hasFunc) { - path = castPath(path, object); + /** Used to ensure capturing order of template delimiters. */ + var reNoMatch = /($^)/; - var index = -1, - length = path.length, - result = false; + /** Used to match unescaped characters in compiled string literals. */ + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - while (++index < length) { - var key = toKey(path[index]); - if (!(result = object != null && hasFunc(object, key))) { - break; - } - object = object[key]; - } - if (result || ++index != length) { - return result; - } - length = object == null ? 0 : object.length; - return !!length && isLength(length) && isIndex(key, length) && - (isArray(object) || isArguments(object)); - } + /** Used to compose unicode character classes. */ + var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, + rsDingbatRange = '\\u2700-\\u27bf', + rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', + rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', + rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', + rsPunctuationRange = '\\u2000-\\u206f', + rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', + rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', + rsVarRange = '\\ufe0e\\ufe0f', + rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; - /** - * Initializes an array clone. - * - * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. - */ - function initCloneArray(array) { - var length = array.length, - result = array.constructor(length); + /** Used to compose unicode capture groups. */ + var rsApos = "['\u2019]", + rsAstral = '[' + rsAstralRange + ']', + rsBreak = '[' + rsBreakRange + ']', + rsCombo = '[' + rsComboRange + ']', + rsDigits = '\\d+', + rsDingbat = '[' + rsDingbatRange + ']', + rsLower = '[' + rsLowerRange + ']', + rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', + rsNonAstral = '[^' + rsAstralRange + ']', + rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', + rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', + rsUpper = '[' + rsUpperRange + ']', + rsZWJ = '\\u200d'; - // Add properties assigned by `RegExp#exec`. - if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { - result.index = array.index; - result.input = array.input; - } - return result; - } + /** Used to compose unicode regexes. */ + var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', + rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', + rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', + rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', + reOptMod = rsModifier + '?', + rsOptVar = '[' + rsVarRange + ']?', + rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', + rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', + rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', + rsSeq = rsOptVar + reOptMod + rsOptJoin, + rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, + rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - /** - * Initializes an object clone. - * - * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneObject(object) { - return (typeof object.constructor == 'function' && !isPrototype(object)) - ? baseCreate(getPrototype(object)) - : {}; - } + /** Used to match apostrophes. */ + var reApos = RegExp(rsApos, 'g'); - /** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneByTag(object, tag, cloneFunc, isDeep) { - var Ctor = object.constructor; - switch (tag) { - case arrayBufferTag: - return cloneArrayBuffer(object); + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ + var reComboMark = RegExp(rsCombo, 'g'); - case boolTag: - case dateTag: - return new Ctor(+object); + /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ + var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - case dataViewTag: - return cloneDataView(object, isDeep); + /** Used to match complex or compound words. */ + var reUnicodeWord = RegExp([ + rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', + rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', + rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, + rsUpper + '+' + rsOptContrUpper, + rsOrdUpper, + rsOrdLower, + rsDigits, + rsEmoji + ].join('|'), 'g'); - case float32Tag: case float64Tag: - case int8Tag: case int16Tag: case int32Tag: - case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: - return cloneTypedArray(object, isDeep); + /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ + var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); - case mapTag: - return cloneMap(object, isDeep, cloneFunc); + /** Used to detect strings that need a more robust regexp to match words. */ + var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; - case numberTag: - case stringTag: - return new Ctor(object); + /** Used to assign default `context` object properties. */ + var contextProps = [ + 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', + 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + ]; - case regexpTag: - return cloneRegExp(object); + /** Used to make template sourceURLs easier to identify. */ + var templateCounter = -1; - case setTag: - return cloneSet(object, isDeep, cloneFunc); + /** Used to identify `toStringTag` values of typed arrays. */ + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = + typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = + typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = + typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = + typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = + typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = + typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = + typedArrayTags[errorTag] = typedArrayTags[funcTag] = + typedArrayTags[mapTag] = typedArrayTags[numberTag] = + typedArrayTags[objectTag] = typedArrayTags[regexpTag] = + typedArrayTags[setTag] = typedArrayTags[stringTag] = + typedArrayTags[weakMapTag] = false; - case symbolTag: - return cloneSymbol(object); - } - } + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[weakMapTag] = false; - /** - * Inserts wrapper `details` in a comment at the top of the `source` body. - * - * @private - * @param {string} source The source to modify. - * @returns {Array} details The details to insert. - * @returns {string} Returns the modified source. - */ - function insertWrapDetails(source, details) { - var length = details.length; - if (!length) { - return source; - } - var lastIndex = length - 1; - details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; - details = details.join(length > 2 ? ', ' : ' '); - return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); - } + /** Used to map Latin Unicode letters to basic Latin letters. */ + var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 's' + }; - /** - * Checks if `value` is a flattenable `arguments` object or array. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. - */ - function isFlattenable(value) { - return isArray(value) || isArguments(value) || - !!(spreadableSymbol && value && value[spreadableSymbol]); - } + /** Used to map characters to HTML entities. */ + var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; - /** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); - } + /** Used to map HTML entities to characters. */ + var htmlUnescapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'" + }; - /** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ - function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object) - ) { - return eq(object[index], value); - } - return false; - } + /** Used to escape characters for inclusion in compiled string literals. */ + var stringEscapes = { + '\\': '\\', + "'": "'", + '\n': 'n', + '\r': 'r', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; - /** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ - function isKey(value, object) { - if (isArray(value)) { - return false; - } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); - } + /** Built-in method references without a dependency on `root`. */ + var freeParseFloat = parseFloat, + freeParseInt = parseInt; - /** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ - function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); - } + /** Detect free variable `global` from Node.js. */ + var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - /** - * Checks if `func` has a lazy counterpart. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` has a lazy counterpart, - * else `false`. - */ - function isLaziable(func) { - var funcName = getFuncName(func), - other = lodash[funcName]; + /** Detect free variable `self`. */ + var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { - return false; - } - if (func === other) { - return true; - } - var data = getData(other); - return !!data && func === data[0]; - } + /** Used as a reference to the global object. */ + var root = freeGlobal || freeSelf || Function('return this')(); - /** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ - function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); - } + /** Detect free variable `exports`. */ + var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - /** - * Checks if `func` is capable of being masked. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `func` is maskable, else `false`. - */ - var isMaskable = coreJsData ? isFunction : stubFalse; + /** Detect free variable `module`. */ + var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - /** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ - function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = freeModule && freeModule.exports === freeExports; - return value === proto; - } + /** Detect free variable `process` from Node.js. */ + var freeProcess = moduleExports && freeGlobal.process; - /** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ - function isStrictComparable(value) { - return value === value && !isObject(value); - } + /** Used to access faster Node.js helpers. */ + var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; - /** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ - function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; - } + if (types) { + return types; + } - /** - * A specialized version of `_.memoize` which clears the memoized function's - * cache when it exceeds `MAX_MEMOIZE_SIZE`. - * - * @private - * @param {Function} func The function to have its output memoized. - * @returns {Function} Returns the new memoized function. - */ - function memoizeCapped(func) { - var result = memoize(func, function(key) { - if (cache.size === MAX_MEMOIZE_SIZE) { - cache.clear(); - } - return key; - }); + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} + }()); - var cache = result.cache; - return result; - } + /* Node.js helper references. */ + var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, + nodeIsDate = nodeUtil && nodeUtil.isDate, + nodeIsMap = nodeUtil && nodeUtil.isMap, + nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, + nodeIsSet = nodeUtil && nodeUtil.isSet, + nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - /** - * Merges the function metadata of `source` into `data`. - * - * Merging metadata reduces the number of wrappers used to invoke a function. - * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` - * may be applied regardless of execution order. Methods like `_.ary` and - * `_.rearg` modify function arguments, making the order in which they are - * executed important, preventing the merging of metadata. However, we make - * an exception for a safe combined case where curried functions have `_.ary` - * and or `_.rearg` applied. - * - * @private - * @param {Array} data The destination metadata. - * @param {Array} source The source metadata. - * @returns {Array} Returns `data`. - */ - function mergeData(data, source) { - var bitmask = data[1], - srcBitmask = source[1], - newBitmask = bitmask | srcBitmask, - isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); + /*--------------------------------------------------------------------------*/ - var isCombo = - ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || - ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || - ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); + /** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ + function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); + } - // Exit early if metadata can't be merged. - if (!(isCommon || isCombo)) { - return data; - } - // Use source `thisArg` if available. - if (srcBitmask & WRAP_BIND_FLAG) { - data[2] = source[2]; - // Set when currying a bound function. - newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; - } - // Compose partial arguments. - var value = source[3]; - if (value) { - var partials = data[3]; - data[3] = partials ? composeArgs(partials, value, source[4]) : value; - data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; - } - // Compose partial right arguments. - value = source[5]; - if (value) { - partials = data[5]; - data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; - data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; - } - // Use source `argPos` if available. - value = source[7]; - if (value) { - data[7] = value; - } - // Use source `ary` if it's smaller. - if (srcBitmask & WRAP_ARY_FLAG) { - data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); - } - // Use source `arity` if one is not provided. - if (data[9] == null) { - data[9] = source[9]; - } - // Use source `func` and merge bitmasks. - data[0] = source[0]; - data[1] = newBitmask; + /** + * A specialized version of `baseAggregator` for arrays. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function arrayAggregator(array, setter, iteratee, accumulator) { + var index = -1, + length = array == null ? 0 : array.length; - return data; + while (++index < length) { + var value = array[index]; + setter(accumulator, value, iteratee(value), array); } + return accumulator; + } - /** - * This function is like - * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * except that it includes inherited enumerable properties. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - function nativeKeysIn(object) { - var result = []; - if (object != null) { - for (var key in Object(object)) { - result.push(key); - } - } - return result; - } + /** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; - /** - * Converts `value` to a string using `Object.prototype.toString`. - * - * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - */ - function objectToString(value) { - return nativeObjectToString.call(value); + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } } + return array; + } - /** - * A specialized version of `baseRest` which transforms the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @param {Function} transform The rest array transform. - * @returns {Function} Returns the new function. - */ - function overRest(func, start, transform) { - start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); + /** + * A specialized version of `_.forEachRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEachRight(array, iteratee) { + var length = array == null ? 0 : array.length; - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = transform(array); - return apply(func, this, otherArgs); - }; + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } } + return array; + } - /** - * Gets the parent value at `path` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} path The path to get the parent value of. - * @returns {*} Returns the parent value. - */ - function parent(object, path) { - return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); + /** + * A specialized version of `_.every` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + */ + function arrayEvery(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } } + return true; + } - /** - * Reorder `array` according to the specified indexes where the element at - * the first index is assigned as the first element, the element at - * the second index is assigned as the second element, and so on. - * - * @private - * @param {Array} array The array to reorder. - * @param {Array} indexes The arranged array indexes. - * @returns {Array} Returns `array`. - */ - function reorder(array, indexes) { - var arrLength = array.length, - length = nativeMin(indexes.length, arrLength), - oldArray = copyArray(array); + /** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; - while (length--) { - var index = indexes[length]; - array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; } - return array; } + return result; + } - /** - * Sets metadata for `func`. - * - * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity - * function to avoid garbage collection pauses in V8. See - * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) - * for more details. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var setData = shortOut(baseSetData); - - /** - * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). - * - * @private - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @returns {number|Object} Returns the timer id or timeout object. - */ - var setTimeout = ctxSetTimeout || function(func, wait) { - return root.setTimeout(func, wait); - }; + /** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; + } - /** - * Sets the `toString` method of `func` to return `string`. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ - var setToString = shortOut(baseSetToString); + /** + * This function is like `arrayIncludes` except that it accepts a comparator. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array == null ? 0 : array.length; - /** - * Sets the `toString` method of `wrapper` to mimic the source of `reference` - * with wrapper details in a comment at the top of the source body. - * - * @private - * @param {Function} wrapper The function to modify. - * @param {Function} reference The reference function. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @returns {Function} Returns `wrapper`. - */ - function setWrapToString(wrapper, reference, bitmask) { - var source = (reference + ''); - return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } } + return false; + } + + /** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); - /** - * Creates a function that'll short out and invoke `identity` instead - * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` - * milliseconds. - * - * @private - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new shortable function. - */ - function shortOut(func) { - var count = 0, - lastCalled = 0; + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } - return function() { - var stamp = nativeNow(), - remaining = HOT_SPAN - (stamp - lastCalled); + /** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ + function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; - lastCalled = stamp; - if (remaining > 0) { - if (++count >= HOT_COUNT) { - return arguments[0]; - } - } else { - count = 0; - } - return func.apply(undefined, arguments); - }; + while (++index < length) { + array[offset + index] = values[index]; } + return array; + } - /** - * A specialized version of `_.shuffle` which mutates and sets the size of `array`. - * - * @private - * @param {Array} array The array to shuffle. - * @param {number} [size=array.length] The size of `array`. - * @returns {Array} Returns `array`. - */ - function shuffleSelf(array, size) { - var index = -1, - length = array.length, - lastIndex = length - 1; + /** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; - size = size === undefined ? length : size; - while (++index < size) { - var rand = baseRandom(index, lastIndex), - value = array[rand]; + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } - array[rand] = array[index]; - array[index] = value; - } - array.length = size; - return array; + /** + * A specialized version of `_.reduceRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduceRight(array, iteratee, accumulator, initAccum) { + var length = array == null ? 0 : array.length; + if (initAccum && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); } + return accumulator; + } - /** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. - */ - var stringToPath = memoizeCapped(function(string) { - var result = []; - if (reLeadingDot.test(string)) { - result.push(''); - } - string.replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; - }); + /** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; - /** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ - function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } + return false; + } - /** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to convert. - * @returns {string} Returns the source code. - */ - function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} + /** + * Gets the size of an ASCII `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + var asciiSize = baseProperty('length'); + + /** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function asciiToArray(string) { + return string.split(''); + } + + /** + * Splits an ASCII `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function asciiWords(string) { + return string.match(reAsciiWord) || []; + } + + /** + * The base implementation of methods like `_.findKey` and `_.findLastKey`, + * without support for iteratee shorthands, which iterates over `collection` + * using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the found element or its key, else `undefined`. + */ + function baseFindKey(collection, predicate, eachFunc) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = key; + return false; } - return ''; - } + }); + return result; + } - /** - * Updates wrapper `details` based on `bitmask` flags. - * - * @private - * @returns {Array} details The details to modify. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @returns {Array} Returns `details`. - */ - function updateWrapDetails(details, bitmask) { - arrayEach(wrapFlags, function(pair) { - var value = '_.' + pair[0]; - if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { - details.push(value); - } - }); - return details.sort(); - } + /** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); - /** - * Creates a clone of `wrapper`. - * - * @private - * @param {Object} wrapper The wrapper to clone. - * @returns {Object} Returns the cloned wrapper. - */ - function wrapperClone(wrapper) { - if (wrapper instanceof LazyWrapper) { - return wrapper.clone(); + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; } - var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); - result.__actions__ = copyArray(wrapper.__actions__); - result.__index__ = wrapper.__index__; - result.__values__ = wrapper.__values__; - return result; } + return -1; + } - /*------------------------------------------------------------------------*/ + /** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); + } - /** - * Creates an array of elements split into groups the length of `size`. - * If `array` can't be split evenly, the final chunk will be the remaining - * elements. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to process. - * @param {number} [size=1] The length of each chunk - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the new array of chunks. - * @example - * - * _.chunk(['a', 'b', 'c', 'd'], 2); - * // => [['a', 'b'], ['c', 'd']] - * - * _.chunk(['a', 'b', 'c', 'd'], 3); - * // => [['a', 'b', 'c'], ['d']] - */ - function chunk(array, size, guard) { - if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { - size = 1; - } else { - size = nativeMax(toInteger(size), 0); - } - var length = array == null ? 0 : array.length; - if (!length || size < 1) { - return []; - } - var index = 0, - resIndex = 0, - result = Array(nativeCeil(length / size)); + /** + * This function is like `baseIndexOf` except that it accepts a comparator. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @param {Function} comparator The comparator invoked per element. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOfWith(array, value, fromIndex, comparator) { + var index = fromIndex - 1, + length = array.length; - while (index < length) { - result[resIndex++] = baseSlice(array, index, (index += size)); + while (++index < length) { + if (comparator(array[index], value)) { + return index; } - return result; } + return -1; + } - /** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are falsey. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to compact. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] - */ - function compact(array) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; + /** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ + function baseIsNaN(value) { + return value !== value; + } - while (++index < length) { - var value = array[index]; - if (value) { - result[resIndex++] = value; - } - } - return result; + /** + * The base implementation of `_.mean` and `_.meanBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the mean. + */ + function baseMean(array, iteratee) { + var length = array == null ? 0 : array.length; + return length ? (baseSum(array, iteratee) / length) : NAN; + } + + /** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.propertyOf` without support for deep paths. + * + * @private + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyOf(object) { + return function(key) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ + function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; } + return array; + } - /** - * Creates a new array concatenating `array` with any additional arrays - * and/or values. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to concatenate. - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. - * @example - * - * var array = [1]; - * var other = _.concat(array, 2, [3], [[4]]); - * - * console.log(other); - * // => [1, 2, 3, [4]] - * - * console.log(array); - * // => [1] - */ - function concat() { - var length = arguments.length; - if (!length) { - return []; - } - var args = Array(length - 1), - array = arguments[0], - index = length; + /** + * The base implementation of `_.sum` and `_.sumBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function baseSum(array, iteratee) { + var result, + index = -1, + length = array.length; - while (index--) { - args[index - 1] = arguments[index]; + while (++index < length) { + var current = iteratee(array[index]); + if (current !== undefined) { + result = result === undefined ? current : (result + current); } - return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); } + return result; + } - /** - * Creates an array of `array` values not included in the other given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * **Note:** Unlike `_.pullAll`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see _.without, _.xor - * @example - * - * _.difference([2, 1], [2, 3]); - * // => [1] - */ - var difference = baseRest(function(array, values) { - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) - : []; - }); + /** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ + function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); - /** - * This method is like `_.difference` except that it accepts `iteratee` which - * is invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * **Note:** Unlike `_.pullAllBy`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [1.2] - * - * // The `_.property` iteratee shorthand. - * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] - */ - var differenceBy = baseRest(function(array, values) { - var iteratee = last(values); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) - : []; + while (++index < n) { + result[index] = iteratee(index); + } + return result; + } + + /** + * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array + * of key-value pairs for `object` corresponding to the property names of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the key-value pairs. + */ + function baseToPairs(object, props) { + return arrayMap(props, function(key) { + return [key, object[key]]; }); + } - /** - * This method is like `_.difference` except that it accepts `comparator` - * which is invoked to compare elements of `array` to `values`. The order and - * references of result values are determined by the first array. The comparator - * is invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `_.pullAllWith`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * - * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); - * // => [{ 'x': 2, 'y': 1 }] - */ - var differenceWith = baseRest(function(array, values) { - var comparator = last(values); - if (isArrayLikeObject(comparator)) { - comparator = undefined; - } - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) - : []; + /** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ + function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; + } + + /** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + + /** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ + function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; }); + } - /** - * Creates a slice of `array` with `n` elements dropped from the beginning. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.drop([1, 2, 3]); - * // => [2, 3] - * - * _.drop([1, 2, 3], 2); - * // => [3] - * - * _.drop([1, 2, 3], 5); - * // => [] - * - * _.drop([1, 2, 3], 0); - * // => [1, 2, 3] - */ - function drop(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = (guard || n === undefined) ? 1 : toInteger(n); - return baseSlice(array, n < 0 ? 0 : n, length); - } + /** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function cacheHas(cache, key) { + return cache.has(key); + } - /** - * Creates a slice of `array` with `n` elements dropped from the end. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRight([1, 2, 3]); - * // => [1, 2] - * - * _.dropRight([1, 2, 3], 2); - * // => [1] - * - * _.dropRight([1, 2, 3], 5); - * // => [] - * - * _.dropRight([1, 2, 3], 0); - * // => [1, 2, 3] - */ - function dropRight(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = (guard || n === undefined) ? 1 : toInteger(n); - n = length - n; - return baseSlice(array, 0, n < 0 ? 0 : n); - } + /** + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the first unmatched string symbol. + */ + function charsStartIndex(strSymbols, chrSymbols) { + var index = -1, + length = strSymbols.length; + + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } - /** - * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.dropRightWhile(users, function(o) { return !o.active; }); - * // => objects for ['barney'] - * - * // The `_.matches` iteratee shorthand. - * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); - * // => objects for ['barney', 'fred'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.dropRightWhile(users, ['active', false]); - * // => objects for ['barney'] - * - * // The `_.property` iteratee shorthand. - * _.dropRightWhile(users, 'active'); - * // => objects for ['barney', 'fred', 'pebbles'] - */ - function dropRightWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3), true, true) - : []; - } + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the last unmatched string symbol. + */ + function charsEndIndex(strSymbols, chrSymbols) { + var index = strSymbols.length; - /** - * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.dropWhile(users, function(o) { return !o.active; }); - * // => objects for ['pebbles'] - * - * // The `_.matches` iteratee shorthand. - * _.dropWhile(users, { 'user': 'barney', 'active': false }); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.dropWhile(users, ['active', false]); - * // => objects for ['pebbles'] - * - * // The `_.property` iteratee shorthand. - * _.dropWhile(users, 'active'); - * // => objects for ['barney', 'fred', 'pebbles'] - */ - function dropWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3), true) - : []; - } + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } - /** - * Fills elements of `array` with `value` from `start` up to, but not - * including, `end`. - * - * **Note:** This method mutates `array`. - * - * @static - * @memberOf _ - * @since 3.2.0 - * @category Array - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3]; - * - * _.fill(array, 'a'); - * console.log(array); - * // => ['a', 'a', 'a'] - * - * _.fill(Array(3), 2); - * // => [2, 2, 2] - * - * _.fill([4, 6, 8, 10], '*', 1, 3); - * // => [4, '*', '*', 10] - */ - function fill(array, value, start, end) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { - start = 0; - end = length; - } - return baseFill(array, value, start, end); - } + /** + * Gets the number of `placeholder` occurrences in `array`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} placeholder The placeholder to search for. + * @returns {number} Returns the placeholder count. + */ + function countHolders(array, placeholder) { + var length = array.length, + result = 0; - /** - * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for instead of the element itself. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.findIndex(users, function(o) { return o.user == 'barney'; }); - * // => 0 - * - * // The `_.matches` iteratee shorthand. - * _.findIndex(users, { 'user': 'fred', 'active': false }); - * // => 1 - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findIndex(users, ['active', false]); - * // => 0 - * - * // The `_.property` iteratee shorthand. - * _.findIndex(users, 'active'); - * // => 2 - */ - function findIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax(length + index, 0); + while (length--) { + if (array[length] === placeholder) { + ++result; } - return baseFindIndex(array, getIteratee(predicate, 3), index); } + return result; + } + + /** + * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A + * letters to basic Latin letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + var deburrLetter = basePropertyOf(deburredLetters); + + /** + * Used by `_.escape` to convert characters to HTML entities. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + var escapeHtmlChar = basePropertyOf(htmlEscapes); + + /** + * Used by `_.template` to escape characters for inclusion in compiled string literals. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; + } + + /** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function getValue(object, key) { + return object == null ? undefined : object[key]; + } + + /** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ + function hasUnicode(string) { + return reHasUnicode.test(string); + } + + /** + * Checks if `string` contains a word composed of Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a word is found, else `false`. + */ + function hasUnicodeWord(string) { + return reHasUnicodeWord.test(string); + } - /** - * This method is like `_.findIndex` except that it iterates over elements - * of `collection` from right to left. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); - * // => 2 - * - * // The `_.matches` iteratee shorthand. - * _.findLastIndex(users, { 'user': 'barney', 'active': true }); - * // => 0 - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findLastIndex(users, ['active', false]); - * // => 2 - * - * // The `_.property` iteratee shorthand. - * _.findLastIndex(users, 'active'); - * // => 0 - */ - function findLastIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = length - 1; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = fromIndex < 0 - ? nativeMax(length + index, 0) - : nativeMin(index, length - 1); - } - return baseFindIndex(array, getIteratee(predicate, 3), index, true); - } + /** + * Converts `iterator` to an array. + * + * @private + * @param {Object} iterator The iterator to convert. + * @returns {Array} Returns the converted array. + */ + function iteratorToArray(iterator) { + var data, + result = []; - /** - * Flattens `array` a single level deep. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, [3, [4]], 5]]); - * // => [1, 2, [3, [4]], 5] - */ - function flatten(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, 1) : []; + while (!(data = iterator.next()).done) { + result.push(data.value); } + return result; + } - /** - * Recursively flattens `array`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flattenDeep([1, [2, [3, [4]], 5]]); - * // => [1, 2, 3, 4, 5] - */ - function flattenDeep(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, INFINITY) : []; - } + /** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ + function mapToArray(map) { + var index = -1, + result = Array(map.size); - /** - * Recursively flatten `array` up to `depth` times. - * - * @static - * @memberOf _ - * @since 4.4.0 - * @category Array - * @param {Array} array The array to flatten. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @example - * - * var array = [1, [2, [3, [4]], 5]]; - * - * _.flattenDepth(array, 1); - * // => [1, 2, [3, [4]], 5] - * - * _.flattenDepth(array, 2); - * // => [1, 2, 3, [4], 5] - */ - function flattenDepth(array, depth) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - depth = depth === undefined ? 1 : toInteger(depth); - return baseFlatten(array, depth); - } + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } - /** - * The inverse of `_.toPairs`; this method returns an object composed - * from key-value `pairs`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} pairs The key-value pairs. - * @returns {Object} Returns the new object. - * @example - * - * _.fromPairs([['a', 1], ['b', 2]]); - * // => { 'a': 1, 'b': 2 } - */ - function fromPairs(pairs) { - var index = -1, - length = pairs == null ? 0 : pairs.length, - result = {}; + /** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } - while (++index < length) { - var pair = pairs[index]; - result[pair[0]] = pair[1]; + /** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ + function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value === placeholder || value === PLACEHOLDER) { + array[index] = PLACEHOLDER; + result[resIndex++] = index; } - return result; } + return result; + } - /** - * Gets the first element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias first - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the first element of `array`. - * @example - * - * _.head([1, 2, 3]); - * // => 1 - * - * _.head([]); - * // => undefined - */ - function head(array) { - return (array && array.length) ? array[0] : undefined; - } + /** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ + function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; + } + + /** + * Converts `set` to its value-value pairs. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the value-value pairs. + */ + function setToPairs(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = [value, value]; + }); + return result; + } - /** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the - * offset from the end of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.indexOf([1, 2, 1, 2], 2); - * // => 1 - * - * // Search from the `fromIndex`. - * _.indexOf([1, 2, 1, 2], 2, 2); - * // => 3 - */ - function indexOf(array, value, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; + /** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax(length + index, 0); + } + return -1; + } + + /** + * A specialized version of `_.lastIndexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictLastIndexOf(array, value, fromIndex) { + var index = fromIndex + 1; + while (index--) { + if (array[index] === value) { + return index; } - return baseIndexOf(array, value, index); } + return index; + } - /** - * Gets all but the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.initial([1, 2, 3]); - * // => [1, 2] - */ - function initial(array) { - var length = array == null ? 0 : array.length; - return length ? baseSlice(array, 0, -1) : []; + /** + * Gets the number of symbols in `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the string size. + */ + function stringSize(string) { + return hasUnicode(string) + ? unicodeSize(string) + : asciiSize(string); + } + + /** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); + } + + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ + function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; + } + + /** + * Used by `_.unescape` to convert HTML entities to characters. + * + * @private + * @param {string} chr The matched character to unescape. + * @returns {string} Returns the unescaped character. + */ + var unescapeHtmlChar = basePropertyOf(htmlUnescapes); + + /** + * Gets the size of a Unicode `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + function unicodeSize(string) { + var result = reUnicode.lastIndex = 0; + while (reUnicode.test(string)) { + ++result; } + return result; + } - /** - * Creates an array of unique values that are included in all given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * _.intersection([2, 1], [2, 3]); - * // => [2] - */ - var intersection = baseRest(function(arrays) { - var mapped = arrayMap(arrays, castArrayLikeObject); - return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped) - : []; - }); + /** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function unicodeToArray(string) { + return string.match(reUnicode) || []; + } - /** - * This method is like `_.intersection` except that it accepts `iteratee` - * which is invoked for each element of each `arrays` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [2.1] - * - * // The `_.property` iteratee shorthand. - * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }] - */ - var intersectionBy = baseRest(function(arrays) { - var iteratee = last(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); + /** + * Splits a Unicode `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function unicodeWords(string) { + return string.match(reUnicodeWord) || []; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Create a new pristine `lodash` function using the `context` object. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Util + * @param {Object} [context=root] The context object. + * @returns {Function} Returns a new `lodash` function. + * @example + * + * _.mixin({ 'foo': _.constant('foo') }); + * + * var lodash = _.runInContext(); + * lodash.mixin({ 'bar': lodash.constant('bar') }); + * + * _.isFunction(_.foo); + * // => true + * _.isFunction(_.bar); + * // => false + * + * lodash.isFunction(lodash.foo); + * // => false + * lodash.isFunction(lodash.bar); + * // => true + * + * // Create a suped-up `defer` in Node.js. + * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; + */ + var runInContext = (function runInContext(context) { + context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); + + /** Built-in constructor references. */ + var Array = context.Array, + Date = context.Date, + Error = context.Error, + Function = context.Function, + Math = context.Math, + Object = context.Object, + RegExp = context.RegExp, + String = context.String, + TypeError = context.TypeError; - if (iteratee === last(mapped)) { - iteratee = undefined; - } else { - mapped.pop(); - } - return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped, getIteratee(iteratee, 2)) - : []; - }); + /** Used for built-in method references. */ + var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; - /** - * This method is like `_.intersection` except that it accepts `comparator` - * which is invoked to compare elements of `arrays`. The order and references - * of result values are determined by the first array. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.intersectionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }] - */ - var intersectionWith = baseRest(function(arrays) { - var comparator = last(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); + /** Used to detect overreaching core-js shims. */ + var coreJsData = context['__core-js_shared__']; - comparator = typeof comparator == 'function' ? comparator : undefined; - if (comparator) { - mapped.pop(); - } - return (mapped.length && mapped[0] === arrays[0]) - ? baseIntersection(mapped, undefined, comparator) - : []; - }); + /** Used to resolve the decompiled source of functions. */ + var funcToString = funcProto.toString; - /** - * Converts all elements in `array` into a string separated by `separator`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to convert. - * @param {string} [separator=','] The element separator. - * @returns {string} Returns the joined string. - * @example - * - * _.join(['a', 'b', 'c'], '~'); - * // => 'a~b~c' - */ - function join(array, separator) { - return array == null ? '' : nativeJoin.call(array, separator); - } + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; - /** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - */ - function last(array) { - var length = array == null ? 0 : array.length; - return length ? array[length - 1] : undefined; - } + /** Used to generate unique IDs. */ + var idCounter = 0; - /** - * This method is like `_.indexOf` except that it iterates over elements of - * `array` from right to left. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.lastIndexOf([1, 2, 1, 2], 2); - * // => 3 - * - * // Search from the `fromIndex`. - * _.lastIndexOf([1, 2, 1, 2], 2, 2); - * // => 1 - */ - function lastIndexOf(array, value, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = length; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); - } - return value === value - ? strictLastIndexOf(array, value, index) - : baseFindIndex(array, baseIsNaN, index, true); - } + /** Used to detect methods masquerading as native. */ + var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; + }()); /** - * Gets the element at index `n` of `array`. If `n` is negative, the nth - * element from the end is returned. - * - * @static - * @memberOf _ - * @since 4.11.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=0] The index of the element to return. - * @returns {*} Returns the nth element of `array`. - * @example - * - * var array = ['a', 'b', 'c', 'd']; - * - * _.nth(array, 1); - * // => 'b' - * - * _.nth(array, -2); - * // => 'c'; + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. */ - function nth(array, n) { - return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; - } + var nativeObjectToString = objectProto.toString; - /** - * Removes all given values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` - * to remove elements from an array by predicate. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {...*} [values] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = ['a', 'b', 'c', 'a', 'b', 'c']; - * - * _.pull(array, 'a', 'c'); - * console.log(array); - * // => ['b', 'b'] - */ - var pull = baseRest(pullAll); + /** Used to infer the `Object` constructor. */ + var objectCtorString = funcToString.call(Object); - /** - * This method is like `_.pull` except that it accepts an array of values to remove. - * - * **Note:** Unlike `_.difference`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = ['a', 'b', 'c', 'a', 'b', 'c']; - * - * _.pullAll(array, ['a', 'c']); - * console.log(array); - * // => ['b', 'b'] - */ - function pullAll(array, values) { - return (array && array.length && values && values.length) - ? basePullAll(array, values) - : array; - } + /** Used to restore the original `_` reference in `_.noConflict`. */ + var oldDash = root._; + + /** Used to detect if a method is native. */ + var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** Built-in value references. */ + var Buffer = moduleExports ? context.Buffer : undefined, + Symbol = context.Symbol, + Uint8Array = context.Uint8Array, + allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, + getPrototype = overArg(Object.getPrototypeOf, Object), + objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice, + spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, + symIterator = Symbol ? Symbol.iterator : undefined, + symToStringTag = Symbol ? Symbol.toStringTag : undefined; + + var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} + }()); + + /** Mocked built-ins. */ + var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, + ctxNow = Date && Date.now !== root.Date.now && Date.now, + ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; + + /* Built-in method references for those with the same name as other `lodash` methods. */ + var nativeCeil = Math.ceil, + nativeFloor = Math.floor, + nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeIsFinite = context.isFinite, + nativeJoin = arrayProto.join, + nativeKeys = overArg(Object.keys, Object), + nativeMax = Math.max, + nativeMin = Math.min, + nativeNow = Date.now, + nativeParseInt = context.parseInt, + nativeRandom = Math.random, + nativeReverse = arrayProto.reverse; - /** - * This method is like `_.pullAll` except that it accepts `iteratee` which is - * invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The iteratee is invoked with one argument: (value). - * - * **Note:** Unlike `_.differenceBy`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns `array`. - * @example - * - * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; - * - * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); - * console.log(array); - * // => [{ 'x': 2 }] - */ - function pullAllBy(array, values, iteratee) { - return (array && array.length && values && values.length) - ? basePullAll(array, values, getIteratee(iteratee, 2)) - : array; - } + /* Built-in method references that are verified to be native. */ + var DataView = getNative(context, 'DataView'), + Map = getNative(context, 'Map'), + Promise = getNative(context, 'Promise'), + Set = getNative(context, 'Set'), + WeakMap = getNative(context, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); - /** - * This method is like `_.pullAll` except that it accepts `comparator` which - * is invoked to compare elements of `array` to `values`. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `_.differenceWith`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.6.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - * @example - * - * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; - * - * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); - * console.log(array); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] - */ - function pullAllWith(array, values, comparator) { - return (array && array.length && values && values.length) - ? basePullAll(array, values, undefined, comparator) - : array; - } + /** Used to store function metadata. */ + var metaMap = WeakMap && new WeakMap; - /** - * Removes elements from `array` corresponding to `indexes` and returns an - * array of removed elements. - * - * **Note:** Unlike `_.at`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {...(number|number[])} [indexes] The indexes of elements to remove. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = ['a', 'b', 'c', 'd']; - * var pulled = _.pullAt(array, [1, 3]); - * - * console.log(array); - * // => ['a', 'c'] - * - * console.log(pulled); - * // => ['b', 'd'] - */ - var pullAt = flatRest(function(array, indexes) { - var length = array == null ? 0 : array.length, - result = baseAt(array, indexes); + /** Used to lookup unminified function names. */ + var realNames = {}; - basePullAt(array, arrayMap(indexes, function(index) { - return isIndex(index, length) ? +index : index; - }).sort(compareAscending)); + /** Used to detect maps, sets, and weakmaps. */ + var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); - return result; - }); + /** Used to convert symbols to primitives and strings. */ + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + + /*------------------------------------------------------------------------*/ /** - * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is invoked - * with three arguments: (value, index, array). - * - * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` - * to pull elements from an array by value. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new array of removed elements. - * @example - * - * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { - * return n % 2 == 0; - * }); + * Creates a `lodash` object which wraps `value` to enable implicit method + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. * - * console.log(array); - * // => [1, 3] + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. * - * console.log(evens); - * // => [2, 4] - */ - function remove(array, predicate) { - var result = []; - if (!(array && array.length)) { - return result; - } - var index = -1, - indexes = [], - length = array.length; - - predicate = getIteratee(predicate, 3); - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result.push(value); - indexes.push(index); - } - } - basePullAt(array, indexes); - return result; - } - - /** - * Reverses `array` so that the first element becomes the last, the second - * element becomes the second to last, and so on. + * The execution of chained methods is lazy, that is, it's deferred until + * `_#value` is implicitly or explicitly called. * - * **Note:** This method mutates `array` and is based on - * [`Array#reverse`](https://mdn.io/Array/reverse). + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array and iteratees accept only + * one argument. The heuristic for whether a section qualifies for shortcut + * fusion is subject to change. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @returns {Array} Returns `array`. - * @example + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. * - * var array = [1, 2, 3]; + * In addition to lodash methods, wrappers have `Array` and `String` methods. * - * _.reverse(array); - * // => [3, 2, 1] + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` * - * console.log(array); - * // => [3, 2, 1] - */ - function reverse(array) { - return array == null ? array : nativeReverse.call(array); - } - - /** - * Creates a slice of `array` from `start` up to, but not including, `end`. + * The wrapper `String` methods are: + * `replace` and `split` * - * **Note:** This method is used instead of - * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are - * returned. + * The wrapper methods that support shortcut fusion are: + * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, + * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, + * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function slice(array, start, end) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { - start = 0; - end = length; - } - else { - start = start == null ? 0 : toInteger(start); - end = end === undefined ? length : toInteger(end); - } - return baseSlice(array, start, end); - } - - /** - * Uses a binary search to determine the lowest index at which `value` - * should be inserted into `array` in order to maintain its sort order. + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, + * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, + * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, + * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, + * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, + * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, + * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, + * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, + * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, + * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, + * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, + * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, + * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, + * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, + * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, + * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, + * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, + * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, + * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, + * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, + * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, + * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, + * `upperFirst`, `value`, and `words` + * + * @name _ + * @constructor + * @category Seq + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * _.sortedIndex([30, 50], 40); - * // => 1 - */ - function sortedIndex(array, value) { - return baseSortedIndex(array, value); - } - - /** - * This method is like `_.sortedIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). + * function square(n) { + * return n * n; + * } * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example + * var wrapped = _([1, 2, 3]); * - * var objects = [{ 'x': 4 }, { 'x': 5 }]; + * // Returns an unwrapped value. + * wrapped.reduce(_.add); + * // => 6 * - * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); - * // => 0 + * // Returns a wrapped value. + * var squares = wrapped.map(square); * - * // The `_.property` iteratee shorthand. - * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); - * // => 0 + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true */ - function sortedIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); } /** - * This method is like `_.indexOf` except that it performs a binary - * search on a sorted `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example + * The base implementation of `_.create` without support for assigning + * properties to the created object. * - * _.sortedIndexOf([4, 5, 5, 5, 6], 5); - * // => 1 + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. */ - function sortedIndexOf(array, value) { - var length = array == null ? 0 : array.length; - if (length) { - var index = baseSortedIndex(array, value); - if (index < length && eq(array[index], value)) { - return index; + var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject(proto)) { + return {}; } - } - return -1; - } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; + }()); /** - * This method is like `_.sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example + * The function whose prototype chain sequence wrappers inherit from. * - * _.sortedLastIndex([4, 5, 5, 5, 6], 5); - * // => 4 + * @private */ - function sortedLastIndex(array, value) { - return baseSortedIndex(array, value, true); + function baseLodash() { + // No operation performed. } /** - * This method is like `_.sortedLastIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * var objects = [{ 'x': 4 }, { 'x': 5 }]; - * - * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); - * // => 1 + * The base constructor for creating `lodash` wrapper objects. * - * // The `_.property` iteratee shorthand. - * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); - * // => 1 + * @private + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable explicit method chain sequences. */ - function sortedLastIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); + function LodashWrapper(value, chainAll) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__chain__ = !!chainAll; + this.__index__ = 0; + this.__values__ = undefined; } /** - * This method is like `_.lastIndexOf` except that it performs a binary - * search on a sorted `array`. + * By default, the template delimiters used by lodash are like those in + * embedded Ruby (ERB) as well as ES2015 template strings. Change the + * following template settings to use alternative delimiters. * * @static * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); - * // => 3 + * @type {Object} */ - function sortedLastIndexOf(array, value) { - var length = array == null ? 0 : array.length; - if (length) { - var index = baseSortedIndex(array, value, true) - 1; - if (eq(array[index], value)) { - return index; - } + lodash.templateSettings = { + + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'escape': reEscape, + + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'evaluate': reEvaluate, + + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'interpolate': reInterpolate, + + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type {string} + */ + 'variable': '', + + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type {Object} + */ + 'imports': { + + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type {Function} + */ + '_': lodash } - return -1; - } + }; - /** - * This method is like `_.uniq` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.sortedUniq([1, 1, 2]); - * // => [1, 2] - */ - function sortedUniq(array) { - return (array && array.length) - ? baseSortedUniq(array) - : []; - } + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + lodash.prototype.constructor = lodash; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + + /*------------------------------------------------------------------------*/ /** - * This method is like `_.uniqBy` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. * - * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); - * // => [1.1, 2.3] + * @private + * @constructor + * @param {*} value The value to wrap. */ - function sortedUniqBy(array, iteratee) { - return (array && array.length) - ? baseSortedUniq(array, getIteratee(iteratee, 2)) - : []; + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = MAX_ARRAY_LENGTH; + this.__views__ = []; } /** - * Gets all but the first element of `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example + * Creates a clone of the lazy wrapper object. * - * _.tail([1, 2, 3]); - * // => [2, 3] + * @private + * @name clone + * @memberOf LazyWrapper + * @returns {Object} Returns the cloned `LazyWrapper` object. */ - function tail(array) { - var length = array == null ? 0 : array.length; - return length ? baseSlice(array, 1, length) : []; + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = copyArray(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = copyArray(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = copyArray(this.__views__); + return result; } /** - * Creates a slice of `array` with `n` elements taken from the beginning. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.take([1, 2, 3]); - * // => [1] - * - * _.take([1, 2, 3], 2); - * // => [1, 2] - * - * _.take([1, 2, 3], 5); - * // => [1, 2, 3] + * Reverses the direction of lazy iteration. * - * _.take([1, 2, 3], 0); - * // => [] + * @private + * @name reverse + * @memberOf LazyWrapper + * @returns {Object} Returns the new reversed `LazyWrapper` object. */ - function take(array, n, guard) { - if (!(array && array.length)) { - return []; + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; } - n = (guard || n === undefined) ? 1 : toInteger(n); - return baseSlice(array, 0, n < 0 ? 0 : n); + return result; } /** - * Creates a slice of `array` with `n` elements taken from the end. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.takeRight([1, 2, 3]); - * // => [3] - * - * _.takeRight([1, 2, 3], 2); - * // => [2, 3] - * - * _.takeRight([1, 2, 3], 5); - * // => [1, 2, 3] + * Extracts the unwrapped value from its lazy wrapper. * - * _.takeRight([1, 2, 3], 0); - * // => [] + * @private + * @name value + * @memberOf LazyWrapper + * @returns {*} Returns the unwrapped value. */ - function takeRight(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; + function lazyValue() { + var array = this.__wrapped__.value(), + dir = this.__dir__, + isArr = isArray(array), + isRight = dir < 0, + arrLength = isArr ? array.length : 0, + view = getView(0, arrLength, this.__views__), + start = view.start, + end = view.end, + length = end - start, + index = isRight ? end : (start - 1), + iteratees = this.__iteratees__, + iterLength = iteratees.length, + resIndex = 0, + takeCount = nativeMin(length, this.__takeCount__); + + if (!isArr || (!isRight && arrLength == length && takeCount == length)) { + return baseWrapperValue(array, this.__actions__); } - n = (guard || n === undefined) ? 1 : toInteger(n); - n = length - n; - return baseSlice(array, n < 0 ? 0 : n, length); - } + var result = []; - /** - * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.takeRightWhile(users, function(o) { return !o.active; }); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.matches` iteratee shorthand. - * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); - * // => objects for ['pebbles'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.takeRightWhile(users, ['active', false]); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.property` iteratee shorthand. - * _.takeRightWhile(users, 'active'); - * // => [] - */ - function takeRightWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3), false, true) - : []; + outer: + while (length-- && resIndex < takeCount) { + index += dir; + + var iterIndex = -1, + value = array[index]; + + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], + iteratee = data.iteratee, + type = data.type, + computed = iteratee(value); + + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; } + // Ensure `LazyWrapper` is an instance of `baseLodash`. + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + + /*------------------------------------------------------------------------*/ + /** - * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.takeWhile(users, function(o) { return !o.active; }); - * // => objects for ['barney', 'fred'] - * - * // The `_.matches` iteratee shorthand. - * _.takeWhile(users, { 'user': 'barney', 'active': false }); - * // => objects for ['barney'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.takeWhile(users, ['active', false]); - * // => objects for ['barney', 'fred'] + * Creates a hash object. * - * // The `_.property` iteratee shorthand. - * _.takeWhile(users, 'active'); - * // => [] + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ - function takeWhile(array, predicate) { - return (array && array.length) - ? baseWhile(array, getIteratee(predicate, 3)) - : []; + function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } /** - * Creates an array of unique values, in order, from all given arrays using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of combined values. - * @example + * Removes all key-value entries from the hash. * - * _.union([2], [1, 2]); - * // => [2, 1] + * @private + * @name clear + * @memberOf Hash */ - var union = baseRest(function(arrays) { - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); - }); + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; + } /** - * This method is like `_.union` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by - * which uniqueness is computed. Result values are chosen from the first - * array in which the value occurs. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of combined values. - * @example - * - * _.unionBy([2.1], [1.2, 2.3], Math.floor); - * // => [2.1, 1.2] + * Removes `key` and its value from the hash. * - * // The `_.property` iteratee shorthand. - * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ - var unionBy = baseRest(function(arrays) { - var iteratee = last(arrays); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; - } - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); - }); + function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; + } /** - * This method is like `_.union` except that it accepts `comparator` which - * is invoked to compare elements of `arrays`. Result values are chosen from - * the first array in which the value occurs. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of combined values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * Gets the hash value for `key`. * - * _.unionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ - var unionWith = baseRest(function(arrays) { - var comparator = last(arrays); - comparator = typeof comparator == 'function' ? comparator : undefined; - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); - }); + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; + } /** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each element - * is kept. The order of result values is determined by the order they occur - * in the array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example + * Checks if a hash value for `key` exists. * - * _.uniq([2, 1, 2]); - * // => [2, 1] + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ - function uniq(array) { - return (array && array.length) ? baseUniq(array) : []; + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); } /** - * This method is like `_.uniq` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * uniqueness is computed. The order of result values is determined by the - * order they occur in the array. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.uniqBy([2.1, 1.2, 2.3], Math.floor); - * // => [2.1, 1.2] + * Sets the hash `key` to `value`. * - * // The `_.property` iteratee shorthand. - * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. */ - function uniqBy(array, iteratee) { - return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; + function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; } + // Add methods to `Hash`. + Hash.prototype.clear = hashClear; + Hash.prototype['delete'] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + + /*------------------------------------------------------------------------*/ + /** - * This method is like `_.uniq` except that it accepts `comparator` which - * is invoked to compare elements of `array`. The order of result values is - * determined by the order they occur in the array.The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * Creates an list cache object. * - * _.uniqWith(objects, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ - function uniqWith(array, comparator) { - comparator = typeof comparator == 'function' ? comparator : undefined; - return (array && array.length) ? baseUniq(array, undefined, comparator) : []; + function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } /** - * This method is like `_.zip` except that it accepts an array of grouped - * elements and creates an array regrouping the elements to their pre-zip - * configuration. - * - * @static - * @memberOf _ - * @since 1.2.0 - * @category Array - * @param {Array} array The array of grouped elements to process. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); - * // => [['a', 1, true], ['b', 2, false]] + * Removes all key-value entries from the list cache. * - * _.unzip(zipped); - * // => [['a', 'b'], [1, 2], [true, false]] + * @private + * @name clear + * @memberOf ListCache */ - function unzip(array) { - if (!(array && array.length)) { - return []; - } - var length = 0; - array = arrayFilter(array, function(group) { - if (isArrayLikeObject(group)) { - length = nativeMax(group.length, length); - return true; - } - }); - return baseTimes(length, function(index) { - return arrayMap(array, baseProperty(index)); - }); + function listCacheClear() { + this.__data__ = []; + this.size = 0; } /** - * This method is like `_.unzip` except that it accepts `iteratee` to specify - * how regrouped values should be combined. The iteratee is invoked with the - * elements of each group: (...group). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Array - * @param {Array} array The array of grouped elements to process. - * @param {Function} [iteratee=_.identity] The function to combine - * regrouped values. - * @returns {Array} Returns the new array of regrouped elements. - * @example - * - * var zipped = _.zip([1, 2], [10, 20], [100, 200]); - * // => [[1, 10, 100], [2, 20, 200]] + * Removes `key` and its value from the list cache. * - * _.unzipWith(zipped, _.add); - * // => [3, 30, 300] + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ - function unzipWith(array, iteratee) { - if (!(array && array.length)) { - return []; + function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; } - var result = unzip(array); - if (iteratee == null) { - return result; + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); } - return arrayMap(result, function(group) { - return apply(iteratee, undefined, group); - }); + --this.size; + return true; } /** - * Creates an array excluding all given values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.pull`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...*} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see _.difference, _.xor - * @example + * Gets the list cache value for `key`. * - * _.without([2, 1, 2, 3], 1, 2); - * // => [3] + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ - var without = baseRest(function(array, values) { - return isArrayLikeObject(array) - ? baseDifference(array, values) - : []; - }); + function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; + } /** - * Creates an array of unique values that is the - * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) - * of the given arrays. The order of result values is determined by the order - * they occur in the arrays. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of filtered values. - * @see _.difference, _.without - * @example + * Checks if a list cache value for `key` exists. * - * _.xor([2, 1], [2, 3]); - * // => [1, 3] + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ - var xor = baseRest(function(arrays) { - return baseXor(arrayFilter(arrays, isArrayLikeObject)); - }); + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } /** - * This method is like `_.xor` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by - * which by which they're compared. The order of result values is determined - * by the order they occur in the arrays. The iteratee is invoked with one - * argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [1.2, 3.4] + * Sets the list cache `key` to `value`. * - * // The `_.property` iteratee shorthand. - * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. */ - var xorBy = baseRest(function(arrays) { - var iteratee = last(arrays); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; + function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; } - return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); - }); + return this; + } + + // Add methods to `ListCache`. + ListCache.prototype.clear = listCacheClear; + ListCache.prototype['delete'] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; + + /*------------------------------------------------------------------------*/ /** - * This method is like `_.xor` except that it accepts `comparator` which is - * invoked to compare elements of `arrays`. The order of result values is - * determined by the order they occur in the arrays. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * Creates a map cache object to store key-value pairs. * - * _.xorWith(objects, others, _.isEqual); - * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ - var xorWith = baseRest(function(arrays) { - var comparator = last(arrays); - comparator = typeof comparator == 'function' ? comparator : undefined; - return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); - }); + function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } /** - * Creates an array of grouped elements, the first of which contains the - * first elements of the given arrays, the second of which contains the - * second elements of the given arrays, and so on. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @returns {Array} Returns the new array of grouped elements. - * @example + * Removes all key-value entries from the map. * - * _.zip(['a', 'b'], [1, 2], [true, false]); - * // => [['a', 1, true], ['b', 2, false]] + * @private + * @name clear + * @memberOf MapCache */ - var zip = baseRest(unzip); + function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; + } /** - * This method is like `_.fromPairs` except that it accepts two arrays, - * one of property identifiers and one of corresponding values. - * - * @static - * @memberOf _ - * @since 0.4.0 - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example + * Removes `key` and its value from the map. * - * _.zipObject(['a', 'b'], [1, 2]); - * // => { 'a': 1, 'b': 2 } + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ - function zipObject(props, values) { - return baseZipObject(props || [], values || [], assignValue); + function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; } /** - * This method is like `_.zipObject` except that it supports property paths. - * - * @static - * @memberOf _ - * @since 4.1.0 - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example + * Gets the map value for `key`. * - * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); - * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ - function zipObjectDeep(props, values) { - return baseZipObject(props || [], values || [], baseSet); + function mapCacheGet(key) { + return getMapData(this, key).get(key); } /** - * This method is like `_.zip` except that it accepts `iteratee` to specify - * how grouped values should be combined. The iteratee is invoked with the - * elements of each group: (...group). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Array - * @param {...Array} [arrays] The arrays to process. - * @param {Function} [iteratee=_.identity] The function to combine - * grouped values. - * @returns {Array} Returns the new array of grouped elements. - * @example + * Checks if a map value for `key` exists. * - * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { - * return a + b + c; - * }); - * // => [111, 222] + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ - var zipWith = baseRest(function(arrays) { - var length = arrays.length, - iteratee = length > 1 ? arrays[length - 1] : undefined; - - iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; - return unzipWith(arrays, iteratee); - }); - - /*------------------------------------------------------------------------*/ + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } /** - * Creates a `lodash` wrapper instance that wraps `value` with explicit method - * chain sequences enabled. The result of such sequences must be unwrapped - * with `_#value`. - * - * @static - * @memberOf _ - * @since 1.3.0 - * @category Seq - * @param {*} value The value to wrap. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'pebbles', 'age': 1 } - * ]; + * Sets the map `key` to `value`. * - * var youngest = _ - * .chain(users) - * .sortBy('age') - * .map(function(o) { - * return o.user + ' is ' + o.age; - * }) - * .head() - * .value(); - * // => 'pebbles is 1' + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. */ - function chain(value) { - var result = lodash(value); - result.__chain__ = true; - return result; + function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; } + // Add methods to `MapCache`. + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype['delete'] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; + + /*------------------------------------------------------------------------*/ + /** - * This method invokes `interceptor` and returns `value`. The interceptor - * is invoked with one argument; (value). The purpose of this method is to - * "tap into" a method chain sequence in order to modify intermediate results. * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Seq - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @returns {*} Returns `value`. - * @example + * Creates an array cache object to store unique values. * - * _([1, 2, 3]) - * .tap(function(array) { - * // Mutate input array. - * array.pop(); - * }) - * .reverse() - * .value(); - * // => [2, 1] + * @private + * @constructor + * @param {Array} [values] The values to cache. */ - function tap(value, interceptor) { - interceptor(value); - return value; + function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } } /** - * This method is like `_.tap` except that it returns the result of `interceptor`. - * The purpose of this method is to "pass thru" values replacing intermediate - * results in a method chain sequence. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Seq - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @returns {*} Returns the result of `interceptor`. - * @example + * Adds `value` to the array cache. * - * _(' abc ') - * .chain() - * .trim() - * .thru(function(value) { - * return [value]; - * }) - * .value(); - * // => ['abc'] + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. */ - function thru(value, interceptor) { - return interceptor(value); + function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; } /** - * This method is the wrapper version of `_.at`. - * - * @name at - * @memberOf _ - * @since 1.0.0 - * @category Seq - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * Checks if `value` is in the array cache. * - * _(object).at(['a[0].b.c', 'a[1]']).value(); - * // => [3, 4] + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. */ - var wrapperAt = flatRest(function(paths) { - var length = paths.length, - start = length ? paths[0] : 0, - value = this.__wrapped__, - interceptor = function(object) { return baseAt(object, paths); }; - - if (length > 1 || this.__actions__.length || - !(value instanceof LazyWrapper) || !isIndex(start)) { - return this.thru(interceptor); - } - value = value.slice(start, +start + (length ? 1 : 0)); - value.__actions__.push({ - 'func': thru, - 'args': [interceptor], - 'thisArg': undefined - }); - return new LodashWrapper(value, this.__chain__).thru(function(array) { - if (length && !array.length) { - array.push(undefined); - } - return array; - }); - }); + function setCacheHas(value) { + return this.__data__.has(value); + } + + // Add methods to `SetCache`. + SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; + SetCache.prototype.has = setCacheHas; + + /*------------------------------------------------------------------------*/ /** - * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. - * - * @name chain - * @memberOf _ - * @since 0.1.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * // A sequence without explicit chaining. - * _(users).head(); - * // => { 'user': 'barney', 'age': 36 } + * Creates a stack cache object to store key-value pairs. * - * // A sequence with explicit chaining. - * _(users) - * .chain() - * .head() - * .pick('user') - * .value(); - * // => { 'user': 'barney' } + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ - function wrapperChain() { - return chain(this); + function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; } /** - * Executes the chain sequence and returns the wrapped result. - * - * @name commit - * @memberOf _ - * @since 3.2.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2]; - * var wrapped = _(array).push(3); - * - * console.log(array); - * // => [1, 2] - * - * wrapped = wrapped.commit(); - * console.log(array); - * // => [1, 2, 3] - * - * wrapped.last(); - * // => 3 + * Removes all key-value entries from the stack. * - * console.log(array); - * // => [1, 2, 3] + * @private + * @name clear + * @memberOf Stack */ - function wrapperCommit() { - return new LodashWrapper(this.value(), this.__chain__); + function stackClear() { + this.__data__ = new ListCache; + this.size = 0; } /** - * Gets the next value on a wrapped object following the - * [iterator protocol](https://mdn.io/iteration_protocols#iterator). - * - * @name next - * @memberOf _ - * @since 4.0.0 - * @category Seq - * @returns {Object} Returns the next iterator value. - * @example - * - * var wrapped = _([1, 2]); - * - * wrapped.next(); - * // => { 'done': false, 'value': 1 } - * - * wrapped.next(); - * // => { 'done': false, 'value': 2 } + * Removes `key` and its value from the stack. * - * wrapped.next(); - * // => { 'done': true, 'value': undefined } + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ - function wrapperNext() { - if (this.__values__ === undefined) { - this.__values__ = toArray(this.value()); - } - var done = this.__index__ >= this.__values__.length, - value = done ? undefined : this.__values__[this.__index__++]; + function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); - return { 'done': done, 'value': value }; + this.size = data.size; + return result; } /** - * Enables the wrapper to be iterable. - * - * @name Symbol.iterator - * @memberOf _ - * @since 4.0.0 - * @category Seq - * @returns {Object} Returns the wrapper object. - * @example - * - * var wrapped = _([1, 2]); - * - * wrapped[Symbol.iterator]() === wrapped; - * // => true + * Gets the stack value for `key`. * - * Array.from(wrapped); - * // => [1, 2] + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ - function wrapperToIterator() { - return this; + function stackGet(key) { + return this.__data__.get(key); } /** - * Creates a clone of the chain sequence planting `value` as the wrapped value. - * - * @name plant - * @memberOf _ - * @since 3.2.0 - * @category Seq - * @param {*} value The value to plant. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var wrapped = _([1, 2]).map(square); - * var other = wrapped.plant([3, 4]); - * - * other.value(); - * // => [9, 16] + * Checks if a stack value for `key` exists. * - * wrapped.value(); - * // => [1, 4] + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ - function wrapperPlant(value) { - var result, - parent = this; + function stackHas(key) { + return this.__data__.has(key); + } - while (parent instanceof baseLodash) { - var clone = wrapperClone(parent); - clone.__index__ = 0; - clone.__values__ = undefined; - if (result) { - previous.__wrapped__ = clone; - } else { - result = clone; + /** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ + function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; } - var previous = clone; - parent = parent.__wrapped__; + data = this.__data__ = new MapCache(pairs); } - previous.__wrapped__ = value; - return result; + data.set(key, value); + this.size = data.size; + return this; } + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + + /*------------------------------------------------------------------------*/ + /** - * This method is the wrapper version of `_.reverse`. - * - * **Note:** This method mutates the wrapped array. - * - * @name reverse - * @memberOf _ - * @since 0.1.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * var array = [1, 2, 3]; - * - * _(array).reverse().value() - * // => [3, 2, 1] + * Creates an array of the enumerable property names of the array-like `value`. * - * console.log(array); - * // => [3, 2, 1] + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. */ - function wrapperReverse() { - var value = this.__wrapped__; - if (value instanceof LazyWrapper) { - var wrapped = value; - if (this.__actions__.length) { - wrapped = new LazyWrapper(this); + function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); } - wrapped = wrapped.reverse(); - wrapped.__actions__.push({ - 'func': thru, - 'args': [reverse], - 'thisArg': undefined - }); - return new LodashWrapper(wrapped, this.__chain__); } - return this.thru(reverse); + return result; } /** - * Executes the chain sequence to resolve the unwrapped value. - * - * @name value - * @memberOf _ - * @since 0.1.0 - * @alias toJSON, valueOf - * @category Seq - * @returns {*} Returns the resolved unwrapped value. - * @example + * A specialized version of `_.sample` for arrays. * - * _([1, 2, 3]).value(); - * // => [1, 2, 3] + * @private + * @param {Array} array The array to sample. + * @returns {*} Returns the random element. */ - function wrapperValue() { - return baseWrapperValue(this.__wrapped__, this.__actions__); + function arraySample(array) { + var length = array.length; + return length ? array[baseRandom(0, length - 1)] : undefined; } - /*------------------------------------------------------------------------*/ - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the number of times the key was returned by `iteratee`. The - * iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.countBy([6.1, 4.2, 6.3], Math.floor); - * // => { '4': 1, '6': 2 } + * A specialized version of `_.sampleSize` for arrays. * - * // The `_.property` iteratee shorthand. - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } + * @private + * @param {Array} array The array to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. */ - var countBy = createAggregator(function(result, value, key) { - if (hasOwnProperty.call(result, key)) { - ++result[key]; - } else { - baseAssignValue(result, key, 1); - } - }); + function arraySampleSize(array, n) { + return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); + } /** - * Checks if `predicate` returns truthy for **all** elements of `collection`. - * Iteration is stopped once `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index|key, collection). - * - * **Note:** This method returns `true` for - * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because - * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of - * elements of empty collections. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes'], Boolean); - * // => false - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.every(users, { 'user': 'barney', 'active': false }); - * // => false + * A specialized version of `_.shuffle` for arrays. * - * // The `_.matchesProperty` iteratee shorthand. - * _.every(users, ['active', false]); - * // => true + * @private + * @param {Array} array The array to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function arrayShuffle(array) { + return shuffleSelf(copyArray(array)); + } + + /** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. * - * // The `_.property` iteratee shorthand. - * _.every(users, 'active'); - * // => false + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ - function every(collection, predicate, guard) { - var func = isArray(collection) ? arrayEvery : baseEvery; - if (guard && isIterateeCall(collection, predicate, guard)) { - predicate = undefined; + function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); } - return func(collection, getIteratee(predicate, 3)); } /** - * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * **Note:** Unlike `_.remove`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see _.reject - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * _.filter(users, function(o) { return !o.active; }); - * // => objects for ['fred'] - * - * // The `_.matches` iteratee shorthand. - * _.filter(users, { 'age': 36, 'active': true }); - * // => objects for ['barney'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.filter(users, ['active', false]); - * // => objects for ['fred'] + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. * - * // The `_.property` iteratee shorthand. - * _.filter(users, 'active'); - * // => objects for ['barney'] + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ - function filter(collection, predicate) { - var func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, getIteratee(predicate, 3)); + function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } } /** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.find(users, function(o) { return o.age < 40; }); - * // => object for 'barney' - * - * // The `_.matches` iteratee shorthand. - * _.find(users, { 'age': 1, 'active': true }); - * // => object for 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.find(users, ['active', false]); - * // => object for 'fred' + * Gets the index at which the `key` is found in `array` of key-value pairs. * - * // The `_.property` iteratee shorthand. - * _.find(users, 'active'); - * // => object for 'barney' + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. */ - var find = createFind(findIndex); + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } /** - * This method is like `_.find` except that it iterates over elements of - * `collection` from right to left. + * Aggregates elements of `collection` on `accumulator` with keys transformed + * by `iteratee` and values set by `setter`. * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=collection.length-1] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @example + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function baseAggregator(collection, setter, iteratee, accumulator) { + baseEach(collection, function(value, key, collection) { + setter(accumulator, value, iteratee(value), collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. * - * _.findLast([1, 2, 3, 4], function(n) { - * return n % 2 == 1; - * }); - * // => 3 + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. */ - var findLast = createFind(findLastIndex); + function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); + } /** - * Creates a flattened array of values by running each element in `collection` - * thru `iteratee` and flattening the mapped results. The iteratee is invoked - * with three arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [n, n]; - * } + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. * - * _.flatMap([1, 2], duplicate); - * // => [1, 1, 2, 2] + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. */ - function flatMap(collection, iteratee) { - return baseFlatten(map(collection, iteratee), 1); + function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); } /** - * This method is like `_.flatMap` except that it recursively flattens the - * mapped results. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [[[n, n]]]; - * } + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. * - * _.flatMapDeep([1, 2], duplicate); - * // => [1, 1, 2, 2] + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ - function flatMapDeep(collection, iteratee) { - return baseFlatten(map(collection, iteratee), INFINITY); + function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } } /** - * This method is like `_.flatMap` except that it recursively flattens the - * mapped results up to `depth` times. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [[[n, n]]]; - * } + * The base implementation of `_.at` without support for individual paths. * - * _.flatMapDepth([1, 2], duplicate, 2); - * // => [[1, 1], [2, 2]] + * @private + * @param {Object} object The object to iterate over. + * @param {string[]} paths The property paths to pick. + * @returns {Array} Returns the picked elements. */ - function flatMapDepth(collection, iteratee, depth) { - depth = depth === undefined ? 1 : toInteger(depth); - return baseFlatten(map(collection, iteratee), depth); + function baseAt(object, paths) { + var index = -1, + length = paths.length, + result = Array(length), + skip = object == null; + + while (++index < length) { + result[index] = skip ? undefined : get(object, paths[index]); + } + return result; } /** - * Iterates over elements of `collection` and invokes `iteratee` for each element. - * The iteratee is invoked with three arguments: (value, index|key, collection). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" - * property are iterated like arrays. To avoid this behavior use `_.forIn` - * or `_.forOwn` for object iteration. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias each - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEachRight - * @example - * - * _.forEach([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `1` then `2`. + * The base implementation of `_.clamp` which doesn't coerce arguments. * - * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). + * @private + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. */ - function forEach(collection, iteratee) { - var func = isArray(collection) ? arrayEach : baseEach; - return func(collection, getIteratee(iteratee, 3)); + function baseClamp(number, lower, upper) { + if (number === number) { + if (upper !== undefined) { + number = number <= upper ? number : upper; + } + if (lower !== undefined) { + number = number >= lower ? number : lower; + } + } + return number; } /** - * This method is like `_.forEach` except that it iterates over elements of - * `collection` from right to left. + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. * - * @static - * @memberOf _ - * @since 2.0.0 - * @alias eachRight - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEach - * @example + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG; + + if (customizer) { + result = object ? customizer(value, key, object, stack) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + } else if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + } + + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; + } + + /** + * The base implementation of `_.conforms` which doesn't clone `source`. * - * _.forEachRight([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `2` then `1`. + * @private + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. */ - function forEachRight(collection, iteratee) { - var func = isArray(collection) ? arrayEachRight : baseEachRight; - return func(collection, getIteratee(iteratee, 3)); + function baseConforms(source) { + var props = keys(source); + return function(object) { + return baseConformsTo(object, source, props); + }; } /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The order of grouped values - * is determined by the order they occur in `collection`. The corresponding - * value of each key is an array of elements responsible for generating the - * key. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([6.1, 4.2, 6.3], Math.floor); - * // => { '4': [4.2], '6': [6.1, 6.3] } + * The base implementation of `_.conformsTo` which accepts `props` to check. * - * // The `_.property` iteratee shorthand. - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. */ - var groupBy = createAggregator(function(result, value, key) { - if (hasOwnProperty.call(result, key)) { - result[key].push(value); - } else { - baseAssignValue(result, key, [value]); + function baseConformsTo(object, source, props) { + var length = props.length; + if (object == null) { + return !length; } - }); + object = Object(object); + while (length--) { + var key = props[length], + predicate = source[key], + value = object[key]; + + if ((value === undefined && !(key in object)) || !predicate(value)) { + return false; + } + } + return true; + } /** - * Checks if `value` is in `collection`. If `collection` is a string, it's - * checked for a substring of `value`, otherwise - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * is used for equality comparisons. If `fromIndex` is negative, it's used as - * the offset from the end of `collection`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. - * @returns {boolean} Returns `true` if `value` is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'a': 1, 'b': 2 }, 1); - * // => true + * The base implementation of `_.delay` and `_.defer` which accepts `args` + * to provide to `func`. * - * _.includes('abcd', 'bc'); - * // => true + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Array} args The arguments to provide to `func`. + * @returns {number|Object} Returns the timer id or timeout object. */ - function includes(collection, value, fromIndex, guard) { - collection = isArrayLike(collection) ? collection : values(collection); - fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; - - var length = collection.length; - if (fromIndex < 0) { - fromIndex = nativeMax(length + fromIndex, 0); + function baseDelay(func, wait, args) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); } - return isString(collection) - ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) - : (!!length && baseIndexOf(collection, value, fromIndex) > -1); + return setTimeout(function() { func.apply(undefined, args); }, wait); } /** - * Invokes the method at `path` of each element in `collection`, returning - * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `path` is a function, it's invoked - * for, and `this` bound to, each element in `collection`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array|Function|string} path The path of the method to invoke or - * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke each method with. - * @returns {Array} Returns the array of results. - * @example - * - * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. * - * _.invokeMap([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] + * @private + * @param {Array} array The array to inspect. + * @param {Array} values The values to exclude. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. */ - var invokeMap = baseRest(function(collection, path, args) { + function baseDifference(array, values, iteratee, comparator) { var index = -1, - isFunc = typeof path == 'function', - result = isArrayLike(collection) ? Array(collection.length) : []; + includes = arrayIncludes, + isCommon = true, + length = array.length, + result = [], + valuesLength = values.length; - baseEach(collection, function(value) { - result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); - }); + if (!length) { + return result; + } + if (iteratee) { + values = arrayMap(values, baseUnary(iteratee)); + } + if (comparator) { + includes = arrayIncludesWith; + isCommon = false; + } + else if (values.length >= LARGE_ARRAY_SIZE) { + includes = cacheHas; + isCommon = false; + values = new SetCache(values); + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee == null ? value : iteratee(value); + + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(values, computed, comparator)) { + result.push(value); + } + } return result; - }); + } /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the last element responsible for generating the key. The - * iteratee is invoked with one argument: (value). + * The base implementation of `_.forEach` without support for iteratee shorthands. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection + * @private * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var array = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.keyBy(array, function(o) { - * return String.fromCharCode(o.code); - * }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.keyBy(array, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. */ - var keyBy = createAggregator(function(result, value, key) { - baseAssignValue(result, key, value); - }); + var baseEach = createBaseEach(baseForOwn); /** - * Creates an array of values by running each element in `collection` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. - * - * The guarded methods are: - * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, - * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, - * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, - * `template`, `trim`, `trimEnd`, `trimStart`, and `words` - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - * @example - * - * function square(n) { - * return n * n; - * } - * - * _.map([4, 8], square); - * // => [16, 64] - * - * _.map({ 'a': 4, 'b': 8 }, square); - * // => [16, 64] (iteration order is not guaranteed) - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; + * The base implementation of `_.forEachRight` without support for iteratee shorthands. * - * // The `_.property` iteratee shorthand. - * _.map(users, 'user'); - * // => ['barney', 'fred'] + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. */ - function map(collection, iteratee) { - var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, getIteratee(iteratee, 3)); - } + var baseEachRight = createBaseEach(baseForOwnRight, true); /** - * This method is like `_.sortBy` except that it allows specifying the sort - * orders of the iteratees to sort by. If `orders` is unspecified, all values - * are sorted in ascending order. Otherwise, specify an order of "desc" for - * descending or "asc" for ascending sort order of corresponding values. + * The base implementation of `_.every` without support for iteratee shorthands. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection + * @private * @param {Array|Object} collection The collection to iterate over. - * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] - * The iteratees to sort by. - * @param {string[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. - * @returns {Array} Returns the new sorted array. - * @example + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` + */ + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + + /** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } - * ]; + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ + function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index], + current = iteratee(value); + + if (current != null && (computed === undefined + ? (current === current && !isSymbol(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; + } + + /** + * The base implementation of `_.fill` without an iteratee call guard. * - * // Sort by `user` in ascending order and by `age` in descending order. - * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + * @private + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. */ - function orderBy(collection, iteratees, orders, guard) { - if (collection == null) { - return []; + function baseFill(array, value, start, end) { + var length = array.length; + + start = toInteger(start); + if (start < 0) { + start = -start > length ? 0 : (length + start); } - if (!isArray(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; + end = (end === undefined || end > length) ? length : toInteger(end); + if (end < 0) { + end += length; } - orders = guard ? undefined : orders; - if (!isArray(orders)) { - orders = orders == null ? [] : [orders]; + end = start > end ? 0 : toLength(end); + while (start < end) { + array[start++] = value; } - return baseOrderBy(collection, iteratees, orders); + return array; } /** - * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, the second of which - * contains elements `predicate` returns falsey for. The predicate is - * invoked with one argument: (value). + * The base implementation of `_.filter` without support for iteratee shorthands. * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Collection + * @private * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the array of grouped elements. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } - * ]; - * - * _.partition(users, function(o) { return o.active; }); - * // => objects for [['fred'], ['barney', 'pebbles']] - * - * // The `_.matches` iteratee shorthand. - * _.partition(users, { 'age': 1, 'active': false }); - * // => objects for [['pebbles'], ['barney', 'fred']] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.partition(users, ['active', false]); - * // => objects for [['barney', 'pebbles'], ['fred']] - * - * // The `_.property` iteratee shorthand. - * _.partition(users, 'active'); - * // => objects for [['fred'], ['barney', 'pebbles']] + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. */ - var partition = createAggregator(function(result, value, key) { - result[key ? 0 : 1].push(value); - }, function() { return [[], []]; }); + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } /** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` thru `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not given, the first element of `collection` is used as the initial - * value. The iteratee is invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.reduce`, `_.reduceRight`, and `_.transform`. - * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, - * and `sortBy` + * The base implementation of `_.flatten` with support for restricting flattening. * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduceRight - * @example + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ + function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (depth > 0 && predicate(value)) { + if (depth > 1) { + // Recursively flatten arrays (susceptible to call stack limits). + baseFlatten(value, depth - 1, predicate, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } + + /** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. * - * _.reduce([1, 2], function(sum, n) { - * return sum + n; - * }, 0); - * // => 3 + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseFor = createBaseFor(); + + /** + * This function is like `baseFor` except that it iterates over properties + * in the opposite order. * - * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * return result; - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. */ - function reduce(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduce : baseReduce, - initAccum = arguments.length < 3; + var baseForRight = createBaseFor(true); - return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); + /** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); } /** - * This method is like `_.reduce` except that it iterates over elements of - * `collection` from right to left. + * The base implementation of `_.forOwnRight` without support for iteratee shorthands. * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduce - * @example + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwnRight(object, iteratee) { + return object && baseForRight(object, iteratee, keys); + } + + /** + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from `props`. * - * var array = [[0, 1], [2, 3], [4, 5]]; + * @private + * @param {Object} object The object to inspect. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the function names. + */ + function baseFunctions(object, props) { + return arrayFilter(props, function(key) { + return isFunction(object[key]); + }); + } + + /** + * The base implementation of `_.get` without support for default values. * - * _.reduceRight(array, function(flattened, other) { - * return flattened.concat(other); - * }, []); - * // => [4, 5, 2, 3, 0, 1] + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. */ - function reduceRight(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduceRight : baseReduce, - initAccum = arguments.length < 3; + function baseGet(object, path) { + path = castPath(path, object); - return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; } /** - * The opposite of `_.filter`; this method returns the elements of `collection` - * that `predicate` does **not** return truthy for. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see _.filter - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } - * ]; - * - * _.reject(users, function(o) { return !o.active; }); - * // => objects for ['fred'] + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. * - * // The `_.matches` iteratee shorthand. - * _.reject(users, { 'age': 40, 'active': true }); - * // => objects for ['barney'] + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + + /** + * The base implementation of `getTag` without fallbacks for buggy environments. * - * // The `_.matchesProperty` iteratee shorthand. - * _.reject(users, ['active', false]); - * // => objects for ['fred'] + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); + } + + /** + * The base implementation of `_.gt` which doesn't coerce arguments. * - * // The `_.property` iteratee shorthand. - * _.reject(users, 'active'); - * // => objects for ['barney'] + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. */ - function reject(collection, predicate) { - var func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, negate(getIteratee(predicate, 3))); + function baseGt(value, other) { + return value > other; } /** - * Gets a random element from `collection`. + * The base implementation of `_.has` without support for deep paths. * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. - * @example + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHas(object, key) { + return object != null && hasOwnProperty.call(object, key); + } + + /** + * The base implementation of `_.hasIn` without support for deep paths. * - * _.sample([1, 2, 3, 4]); - * // => 2 + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. */ - function sample(collection) { - var func = isArray(collection) ? arraySample : baseSample; - return func(collection); + function baseHasIn(object, key) { + return object != null && key in Object(object); } /** - * Gets `n` random elements at unique keys from `collection` up to the - * size of `collection`. + * The base implementation of `_.inRange` which doesn't coerce arguments. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @param {number} [n=1] The number of elements to sample. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the random elements. - * @example + * @private + * @param {number} number The number to check. + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + */ + function baseInRange(number, start, end) { + return number >= nativeMin(start, end) && number < nativeMax(start, end); + } + + /** + * The base implementation of methods like `_.intersection`, without support + * for iteratee shorthands, that accepts an array of arrays to inspect. * - * _.sampleSize([1, 2, 3], 2); - * // => [3, 1] + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of shared values. + */ + function baseIntersection(arrays, iteratee, comparator) { + var includes = comparator ? arrayIncludesWith : arrayIncludes, + length = arrays[0].length, + othLength = arrays.length, + othIndex = othLength, + caches = Array(othLength), + maxLength = Infinity, + result = []; + + while (othIndex--) { + var array = arrays[othIndex]; + if (othIndex && iteratee) { + array = arrayMap(array, baseUnary(iteratee)); + } + maxLength = nativeMin(array.length, maxLength); + caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) + ? new SetCache(othIndex && array) + : undefined; + } + array = arrays[0]; + + var index = -1, + seen = caches[0]; + + outer: + while (++index < length && result.length < maxLength) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (!(seen + ? cacheHas(seen, computed) + : includes(result, computed, comparator) + )) { + othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if (!(cache + ? cacheHas(cache, computed) + : includes(arrays[othIndex], computed, comparator)) + ) { + continue outer; + } + } + if (seen) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.invert` and `_.invertBy` which inverts + * `object` with values transformed by `iteratee` and set by `setter`. * - * _.sampleSize([1, 2, 3], 4); - * // => [2, 3, 1] + * @private + * @param {Object} object The object to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform values. + * @param {Object} accumulator The initial inverted object. + * @returns {Function} Returns `accumulator`. */ - function sampleSize(collection, n, guard) { - if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { - n = 1; - } else { - n = toInteger(n); - } - var func = isArray(collection) ? arraySampleSize : baseSampleSize; - return func(collection, n); + function baseInverter(object, setter, iteratee, accumulator) { + baseForOwn(object, function(value, key, object) { + setter(accumulator, iteratee(value), key, object); + }); + return accumulator; } /** - * Creates an array of shuffled values, using a version of the - * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. - * @example + * The base implementation of `_.invoke` without support for individual + * method arguments. * - * _.shuffle([1, 2, 3, 4]); - * // => [4, 1, 3, 2] + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. */ - function shuffle(collection) { - var func = isArray(collection) ? arrayShuffle : baseShuffle; - return func(collection); + function baseInvoke(object, path, args) { + path = castPath(path, object); + object = parent(object, path); + var func = object == null ? object : object[toKey(last(path))]; + return func == null ? undefined : apply(func, object, args); } /** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable string keyed properties for objects. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the collection size. - * @example - * - * _.size([1, 2, 3]); - * // => 3 - * - * _.size({ 'a': 1, 'b': 2 }); - * // => 2 + * The base implementation of `_.isArguments`. * - * _.size('pebbles'); - * // => 7 + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ - function size(collection) { - if (collection == null) { - return 0; - } - if (isArrayLike(collection)) { - return isString(collection) ? stringSize(collection) : collection.length; - } - var tag = getTag(collection); - if (tag == mapTag || tag == setTag) { - return collection.size; - } - return baseKeys(collection).length; + function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; } /** - * Checks if `predicate` returns truthy for **any** element of `collection`. - * Iteration is stopped once `predicate` returns truthy. The predicate is - * invoked with three arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - * @example - * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.some(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // The `_.matchesProperty` iteratee shorthand. - * _.some(users, ['active', false]); - * // => true + * The base implementation of `_.isArrayBuffer` without Node.js optimizations. * - * // The `_.property` iteratee shorthand. - * _.some(users, 'active'); - * // => true + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. */ - function some(collection, predicate, guard) { - var func = isArray(collection) ? arraySome : baseSome; - if (guard && isIterateeCall(collection, predicate, guard)) { - predicate = undefined; - } - return func(collection, getIteratee(predicate, 3)); + function baseIsArrayBuffer(value) { + return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; } /** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection thru each iteratee. This method - * performs a stable sort, that is, it preserves the original sort order of - * equal elements. The iteratees are invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[])} [iteratees=[_.identity]] - * The iteratees to sort by. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 34 } - * ]; + * The base implementation of `_.isDate` without Node.js optimizations. * - * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + */ + function baseIsDate(value) { + return isObjectLike(value) && baseGetTag(value) == dateTag; + } + + /** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. * - * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ - var sortBy = baseRest(function(collection, iteratees) { - if (collection == null) { - return []; + function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; } - var length = iteratees.length; - if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { - iteratees = []; - } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { - iteratees = [iteratees[0]]; + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; } - return baseOrderBy(collection, baseFlatten(iteratees, 1), []); - }); - - /*------------------------------------------------------------------------*/ + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); + } /** - * Gets the timestamp of the number of milliseconds that have elapsed since - * the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Date - * @returns {number} Returns the timestamp. - * @example + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => Logs the number of milliseconds it took for the deferred invocation. + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ - var now = ctxNow || function() { - return root.Date.now(); - }; + function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); - /*------------------------------------------------------------------------*/ + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; - /** - * The opposite of `_.before`; this method creates a function that invokes - * `func` once it's called `n` or more times. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {number} n The number of calls before `func` is invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => Logs 'done saving!' after the two async saves have completed. - */ - function after(n, func) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; } - n = toInteger(n); - return function() { - if (--n < 1) { - return func.apply(this, arguments); + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); } - }; + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); } /** - * Creates a function that invokes `func`, with up to `n` arguments, - * ignoring any additional arguments. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new capped function. - * @example + * The base implementation of `_.isMap` without Node.js optimizations. * - * _.map(['6', '8', '10'], _.ary(parseInt, 1)); - * // => [6, 8, 10] + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. */ - function ary(func, n, guard) { - n = guard ? undefined : n; - n = (func && n == null) ? func.length : n; - return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); + function baseIsMap(value) { + return isObjectLike(value) && getTag(value) == mapTag; } /** - * Creates a function that invokes `func`, with the `this` binding and arguments - * of the created function, while it's called less than `n` times. Subsequent - * calls to the created function return the result of the last `func` invocation. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {number} n The number of calls at which `func` is no longer invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example + * The base implementation of `_.isMatch` without support for iteratee shorthands. * - * jQuery(element).on('click', _.before(5, addContactToList)); - * // => Allows adding up to 4 contacts to the list. + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ - function before(n, func) { - var result; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; } - n = toInteger(n); - return function() { - if (--n > 0) { - result = func.apply(this, arguments); + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; } - if (n <= 1) { - func = undefined; + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) + : result + )) { + return false; + } } - return result; - }; + } + return true; } /** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and `partials` prepended to the arguments it receives. - * - * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for partially applied arguments. - * - * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" - * property of bound functions. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * function greet(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * - * var object = { 'user': 'fred' }; - * - * var bound = _.bind(greet, object, 'hi'); - * bound('!'); - * // => 'hi fred!' + * The base implementation of `_.isNative` without bad shim checks. * - * // Bound with placeholders. - * var bound = _.bind(greet, object, _, '!'); - * bound('hi'); - * // => 'hi fred!' + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. */ - var bind = baseRest(function(func, thisArg, partials) { - var bitmask = WRAP_BIND_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, getHolder(bind)); - bitmask |= WRAP_PARTIAL_FLAG; + function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; } - return createWrap(func, bitmask, thisArg, partials, holders); - }); + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } /** - * Creates a function that invokes the method at `object[key]` with `partials` - * prepended to the arguments it receives. - * - * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. See - * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) - * for more details. - * - * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * @static - * @memberOf _ - * @since 0.10.0 - * @category Function - * @param {Object} object The object to invoke the method on. - * @param {string} key The key of the method. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example + * The base implementation of `_.isRegExp` without Node.js optimizations. * - * var object = { - * 'user': 'fred', - * 'greet': function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * }; + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + */ + function baseIsRegExp(value) { + return isObjectLike(value) && baseGetTag(value) == regexpTag; + } + + /** + * The base implementation of `_.isSet` without Node.js optimizations. * - * var bound = _.bindKey(object, 'greet', 'hi'); - * bound('!'); - * // => 'hi fred!' + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ + function baseIsSet(value) { + return isObjectLike(value) && getTag(value) == setTag; + } + + /** + * The base implementation of `_.isTypedArray` without Node.js optimizations. * - * object.greet = function(greeting, punctuation) { - * return greeting + 'ya ' + this.user + punctuation; - * }; + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ + function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; + } + + /** + * The base implementation of `_.iteratee`. * - * bound('!'); - * // => 'hiya fred!' + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ + function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); + } + + /** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * - * // Bound with placeholders. - * var bound = _.bindKey(object, 'greet', _, '!'); - * bound('hi'); - * // => 'hiya fred!' + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. */ - var bindKey = baseRest(function(object, key, partials) { - var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; - if (partials.length) { - var holders = replaceHolders(partials, getHolder(bindKey)); - bitmask |= WRAP_PARTIAL_FLAG; + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); } - return createWrap(key, bitmask, object, partials, holders); - }); + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; + } /** - * Creates a function that accepts arguments of `func` and either invokes - * `func` returning its result, if at least `arity` number of arguments have - * been provided, or returns a function that accepts the remaining `func` - * arguments, and so on. The arity of `func` may be specified if `func.length` - * is not sufficient. - * - * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curry(abc); - * - * curried(1)(2)(3); - * // => [1, 2, 3] - * - * curried(1, 2)(3); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. * - * // Curried with placeholders. - * curried(1)(_, 3)(2); - * // => [1, 2, 3] + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. */ - function curry(func, arity, guard) { - arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curry.placeholder; + function baseKeysIn(object) { + if (!isObject(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } return result; } /** - * This method is like `_.curry` except that arguments are applied to `func` - * in the manner of `_.partialRight` instead of `_.partial`. - * - * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new curried function. - * @example - * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curryRight(abc); - * - * curried(3)(2)(1); - * // => [1, 2, 3] - * - * curried(2, 3)(1); - * // => [1, 2, 3] + * The base implementation of `_.lt` which doesn't coerce arguments. * - * curried(1, 2, 3); - * // => [1, 2, 3] + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ + function baseLt(value, other) { + return value < other; + } + + /** + * The base implementation of `_.map` without support for iteratee shorthands. * - * // Curried with placeholders. - * curried(3)(1, _)(2); - * // => [1, 2, 3] + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. */ - function curryRight(func, arity, guard) { - arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curryRight.placeholder; + function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); return result; } /** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide `options` to indicate whether `func` should be invoked on the - * leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent - * calls to the debounced function return the result of the last `func` - * invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the debounced function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.debounce` and `_.throttle`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=false] - * Specify invoking on the leading edge of the timeout. - * @param {number} [options.maxWait] - * The maximum time `func` is allowed to be delayed before it's invoked. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example + * The base implementation of `_.matches` which doesn't clone `source`. * - * // Avoid costly calculations while the window size is in flux. - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; + } + + /** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. * - * // Invoke `sendMail` when clicked, debouncing subsequent calls. - * jQuery(element).on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); + } + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; + } + + /** + * The base implementation of `_.merge` without support for multiple sources. * - * // Ensure `batchLog` is invoked once after 1 second of debounced calls. - * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); - * var source = new EventSource('/stream'); - * jQuery(source).on('message', debounced); + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); + if (isObject(srcValue)) { + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); + } + + /** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. * - * // Cancel the trailing debounced invocation. - * jQuery(window).on('popstate', debounced.cancel); + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ - function debounce(func, wait, options) { - var lastArgs, - lastThis, - maxWait, - result, - timerId, - lastCallTime, - lastInvokeTime = 0, - leading = false, - maxing = false, - trailing = true; + function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = toNumber(wait) || 0; - if (isObject(options)) { - leading = !!options.leading; - maxing = 'maxWait' in options; - maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; - trailing = 'trailing' in options ? !!options.trailing : trailing; + if (stacked) { + assignMergeValue(object, key, stacked); + return; } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; - function invokeFunc(time) { - var args = lastArgs, - thisArg = lastThis; + var isCommon = newValue === undefined; - lastArgs = lastThis = undefined; - lastInvokeTime = time; - result = func.apply(thisArg, args); - return result; - } + if (isCommon) { + var isArr = isArray(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); - function leadingEdge(time) { - // Reset any `maxWait` timer. - lastInvokeTime = time; - // Start the timer for the trailing edge. - timerId = setTimeout(timerExpired, wait); - // Invoke the leading edge. - return leading ? invokeFunc(time) : result; + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject(objValue) || isFunction(objValue)) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); } + assignMergeValue(object, key, newValue); + } - function remainingWait(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; + /** + * The base implementation of `_.nth` which doesn't coerce arguments. + * + * @private + * @param {Array} array The array to query. + * @param {number} n The index of the element to return. + * @returns {*} Returns the nth element of `array`. + */ + function baseNth(array, n) { + var length = array.length; + if (!length) { + return; + } + n += n < 0 ? length : 0; + return isIndex(n, length) ? array[n] : undefined; + } - return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; + /** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ + function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; } - function shouldInvoke(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime; + var index = -1; + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); - // Either this is the first call, activity has stopped and we're at the - // trailing edge, the system time has gone backwards and we're treating - // it as the trailing edge, or we've hit the `maxWait` limit. - return (lastCallTime === undefined || (timeSinceLastCall >= wait) || - (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); - } + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); - function timerExpired() { - var time = now(); - if (shouldInvoke(time)) { - return trailingEdge(time); - } - // Restart the timer. - timerId = setTimeout(timerExpired, remainingWait(time)); - } + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } - function trailingEdge(time) { - timerId = undefined; + /** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ + function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); + } - // Only invoke if we have `lastArgs` which means `func` has been - // debounced at least once. - if (trailing && lastArgs) { - return invokeFunc(time); - } - lastArgs = lastThis = undefined; - return result; - } + /** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ + function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; - function cancel() { - if (timerId !== undefined) { - clearTimeout(timerId); + while (++index < length) { + var path = paths[index], + value = baseGet(object, path); + + if (predicate(value, path)) { + baseSet(result, castPath(path, object), value); } - lastInvokeTime = 0; - lastArgs = lastCallTime = lastThis = timerId = undefined; } + return result; + } - function flush() { - return timerId === undefined ? result : trailingEdge(now()); - } + /** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; + } - function debounced() { - var time = now(), - isInvoking = shouldInvoke(time); + /** + * The base implementation of `_.pullAllBy` without support for iteratee + * shorthands. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + */ + function basePullAll(array, values, iteratee, comparator) { + var indexOf = comparator ? baseIndexOfWith : baseIndexOf, + index = -1, + length = values.length, + seen = array; - lastArgs = arguments; - lastThis = this; - lastCallTime = time; + if (array === values) { + values = copyArray(values); + } + if (iteratee) { + seen = arrayMap(array, baseUnary(iteratee)); + } + while (++index < length) { + var fromIndex = 0, + value = values[index], + computed = iteratee ? iteratee(value) : value; - if (isInvoking) { - if (timerId === undefined) { - return leadingEdge(lastCallTime); - } - if (maxing) { - // Handle invocations in a tight loop. - timerId = setTimeout(timerExpired, wait); - return invokeFunc(lastCallTime); + while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { + if (seen !== array) { + splice.call(seen, fromIndex, 1); } + splice.call(array, fromIndex, 1); } - if (timerId === undefined) { - timerId = setTimeout(timerExpired, wait); - } - return result; } - debounced.cancel = cancel; - debounced.flush = flush; - return debounced; + return array; } /** - * Defers invoking the `func` until the current call stack has cleared. Any - * additional arguments are provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {number} Returns the timer id. - * @example + * The base implementation of `_.pullAt` without support for individual + * indexes or capturing the removed elements. * - * _.defer(function(text) { - * console.log(text); - * }, 'deferred'); - * // => Logs 'deferred' after one millisecond. + * @private + * @param {Array} array The array to modify. + * @param {number[]} indexes The indexes of elements to remove. + * @returns {Array} Returns `array`. */ - var defer = baseRest(function(func, args) { - return baseDelay(func, 1, args); - }); + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0, + lastIndex = length - 1; + + while (length--) { + var index = indexes[length]; + if (length == lastIndex || index !== previous) { + var previous = index; + if (isIndex(index)) { + splice.call(array, index, 1); + } else { + baseUnset(array, index); + } + } + } + return array; + } /** - * Invokes `func` after `wait` milliseconds. Any additional arguments are - * provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {number} Returns the timer id. - * @example + * The base implementation of `_.random` without support for returning + * floating-point numbers. * - * _.delay(function(text) { - * console.log(text); - * }, 1000, 'later'); - * // => Logs 'later' after one second. + * @private + * @param {number} lower The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the random number. */ - var delay = baseRest(function(func, wait, args) { - return baseDelay(func, toNumber(wait) || 0, args); - }); + function baseRandom(lower, upper) { + return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); + } /** - * Creates a function that invokes `func` with arguments reversed. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to flip arguments for. - * @returns {Function} Returns the new flipped function. - * @example - * - * var flipped = _.flip(function() { - * return _.toArray(arguments); - * }); + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. * - * flipped('a', 'b', 'c', 'd'); - * // => ['d', 'c', 'b', 'a'] + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. */ - function flip(func) { - return createWrap(func, WRAP_FLIP_FLAG); + function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; + } + return result; } /** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) - * method interface of `clear`, `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoized function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] + * The base implementation of `_.repeat` which doesn't coerce arguments. * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; + * @private + * @param {string} string The string to repeat. + * @param {number} n The number of times to repeat the string. + * @returns {string} Returns the repeated string. */ - function memoize(func, resolver) { - if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); + function baseRepeat(string, n) { + var result = ''; + if (!string || n < 1 || n > MAX_SAFE_INTEGER) { + return result; } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; - - if (cache.has(key)) { - return cache.get(key); + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result) || cache; - return result; - }; - memoized.cache = new (memoize.Cache || MapCache); - return memoized; - } + n = nativeFloor(n / 2); + if (n) { + string += string; + } + } while (n); - // Expose `MapCache`. - memoize.Cache = MapCache; + return result; + } /** - * Creates a function that negates the result of the predicate `func`. The - * `func` predicate is invoked with the `this` binding and arguments of the - * created function. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} predicate The predicate to negate. - * @returns {Function} Returns the new negated function. - * @example - * - * function isEven(n) { - * return n % 2 == 0; - * } + * The base implementation of `_.rest` which doesn't validate or coerce arguments. * - * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); - * // => [1, 3, 5] + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. */ - function negate(predicate) { - if (typeof predicate != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - var args = arguments; - switch (args.length) { - case 0: return !predicate.call(this); - case 1: return !predicate.call(this, args[0]); - case 2: return !predicate.call(this, args[0], args[1]); - case 3: return !predicate.call(this, args[0], args[1], args[2]); - } - return !predicate.apply(this, args); - }; + function baseRest(func, start) { + return setToString(overRest(func, start, identity), func + ''); } /** - * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first invocation. The `func` is - * invoked with the `this` binding and arguments of the created function. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example + * The base implementation of `_.sample`. * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // => `createApplication` is invoked once + * @private + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. */ - function once(func) { - return before(2, func); + function baseSample(collection) { + return arraySample(values(collection)); } /** - * Creates a function that invokes `func` with its arguments transformed. - * - * @static - * @since 4.0.0 - * @memberOf _ - * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms=[_.identity]] - * The argument transforms. - * @returns {Function} Returns the new function. - * @example - * - * function doubled(n) { - * return n * 2; - * } - * - * function square(n) { - * return n * n; - * } - * - * var func = _.overArgs(function(x, y) { - * return [x, y]; - * }, [square, doubled]); + * The base implementation of `_.sampleSize` without param guards. * - * func(9, 3); - * // => [81, 6] + * @private + * @param {Array|Object} collection The collection to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function baseSampleSize(collection, n) { + var array = values(collection); + return shuffleSelf(array, baseClamp(n, 0, array.length)); + } + + /** + * The base implementation of `_.set`. * - * func(10, 5); - * // => [100, 10] + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. */ - var overArgs = castRest(function(func, transforms) { - transforms = (transforms.length == 1 && isArray(transforms[0])) - ? arrayMap(transforms[0], baseUnary(getIteratee())) - : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); + function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); - var funcsLength = transforms.length; - return baseRest(function(args) { - var index = -1, - length = nativeMin(args.length, funcsLength); + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; - while (++index < length) { - args[index] = transforms[index].call(this, args[index]); + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; } - return apply(func, this, args); - }); - }); + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; + } /** - * Creates a function that invokes `func` with `partials` prepended to the - * arguments it receives. This method is like `_.bind` except it does **not** - * alter the `this` binding. - * - * The `_.partial.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @since 0.2.0 - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * function greet(greeting, name) { - * return greeting + ' ' + name; - * } - * - * var sayHelloTo = _.partial(greet, 'hello'); - * sayHelloTo('fred'); - * // => 'hello fred' + * The base implementation of `setData` without support for hot loop shorting. * - * // Partially applied with placeholders. - * var greetFred = _.partial(greet, _, 'fred'); - * greetFred('hi'); - * // => 'hi fred' + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. */ - var partial = baseRest(function(func, partials) { - var holders = replaceHolders(partials, getHolder(partial)); - return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); - }); + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; /** - * This method is like `_.partial` except that partially applied arguments - * are appended to the arguments it receives. - * - * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * function greet(greeting, name) { - * return greeting + ' ' + name; - * } - * - * var greetFred = _.partialRight(greet, 'fred'); - * greetFred('hi'); - * // => 'hi fred' + * The base implementation of `setToString` without support for hot loop shorting. * - * // Partially applied with placeholders. - * var sayHelloTo = _.partialRight(greet, 'hello', _); - * sayHelloTo('fred'); - * // => 'hello fred' + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. */ - var partialRight = baseRest(function(func, partials) { - var holders = replaceHolders(partials, getHolder(partialRight)); - return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); - }); + var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); + }; /** - * Creates a function that invokes `func` with arguments arranged according - * to the specified `indexes` where the argument value at the first index is - * provided as the first argument, the argument value at the second index is - * provided as the second argument, and so on. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} indexes The arranged argument indexes. - * @returns {Function} Returns the new function. - * @example + * The base implementation of `_.shuffle`. * - * var rearged = _.rearg(function(a, b, c) { - * return [a, b, c]; - * }, [2, 0, 1]); + * @private + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function baseShuffle(collection) { + return shuffleSelf(values(collection)); + } + + /** + * The base implementation of `_.slice` without an iteratee call guard. * - * rearged('b', 'c', 'a') - * // => ['a', 'b', 'c'] + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. */ - var rearg = flatRest(function(func, indexes) { - return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); - }); + function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } /** - * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as - * an array. - * - * **Note:** This method is based on the - * [rest parameter](https://mdn.io/rest_parameters). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - * @example + * The base implementation of `_.some` without support for iteratee shorthands. * - * var say = _.rest(function(what, names) { - * return what + ' ' + _.initial(names).join(', ') + - * (_.size(names) > 1 ? ', & ' : '') + _.last(names); - * }); + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function baseSome(collection, predicate) { + var result; + + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; + } + + /** + * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which + * performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. * - * say('hello', 'fred', 'barney', 'pebbles'); - * // => 'hello fred, barney, & pebbles' + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. */ - function rest(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + function baseSortedIndex(array, value, retHighest) { + var low = 0, + high = array == null ? low : array.length; + + if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if (computed !== null && !isSymbol(computed) && + (retHighest ? (computed <= value) : (computed < value))) { + low = mid + 1; + } else { + high = mid; + } + } + return high; } - start = start === undefined ? start : toInteger(start); - return baseRest(func, start); + return baseSortedIndexBy(array, value, identity, retHighest); } /** - * Creates a function that invokes `func` with the `this` binding of the - * create function and an array of arguments much like - * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). - * - * **Note:** This method is based on the - * [spread operator](https://mdn.io/spread_operator). - * - * @static - * @memberOf _ - * @since 3.2.0 - * @category Function - * @param {Function} func The function to spread arguments over. - * @param {number} [start=0] The start position of the spread. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.spread(function(who, what) { - * return who + ' says ' + what; - * }); - * - * say(['fred', 'hello']); - * // => 'fred says hello' - * - * var numbers = Promise.all([ - * Promise.resolve(40), - * Promise.resolve(36) - * ]); + * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` + * which invokes `iteratee` for `value` and each element of `array` to compute + * their sort ranking. The iteratee is invoked with one argument; (value). * - * numbers.then(_.spread(function(x, y) { - * return x + y; - * })); - * // => a Promise of 76 + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} iteratee The iteratee invoked per element. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. */ - function spread(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + function baseSortedIndexBy(array, value, iteratee, retHighest) { + var low = 0, + high = array == null ? 0 : array.length; + if (high === 0) { + return 0; } - start = start == null ? 0 : nativeMax(toInteger(start), 0); - return baseRest(function(args) { - var array = args[start], - otherArgs = castSlice(args, 0, start); - if (array) { - arrayPush(otherArgs, array); + value = iteratee(value); + var valIsNaN = value !== value, + valIsNull = value === null, + valIsSymbol = isSymbol(value), + valIsUndefined = value === undefined; + + while (low < high) { + var mid = nativeFloor((low + high) / 2), + computed = iteratee(array[mid]), + othIsDefined = computed !== undefined, + othIsNull = computed === null, + othIsReflexive = computed === computed, + othIsSymbol = isSymbol(computed); + + if (valIsNaN) { + var setLow = retHighest || othIsReflexive; + } else if (valIsUndefined) { + setLow = othIsReflexive && (retHighest || othIsDefined); + } else if (valIsNull) { + setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); + } else if (valIsSymbol) { + setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); + } else if (othIsNull || othIsSymbol) { + setLow = false; + } else { + setLow = retHighest ? (computed <= value) : (computed < value); } - return apply(func, this, otherArgs); - }); + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); } /** - * Creates a throttled function that only invokes `func` at most once per - * every `wait` milliseconds. The throttled function comes with a `cancel` - * method to cancel delayed `func` invocations and a `flush` method to - * immediately invoke them. Provide `options` to indicate whether `func` - * should be invoked on the leading and/or trailing edge of the `wait` - * timeout. The `func` is invoked with the last arguments provided to the - * throttled function. Subsequent calls to the throttled function return the - * result of the last `func` invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the throttled function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.throttle` and `_.debounce`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to throttle. - * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=true] - * Specify invoking on the leading edge of the timeout. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // Avoid excessively updating the position while scrolling. - * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); - * - * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. - * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); - * jQuery(element).on('click', throttled); + * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without + * support for iteratee shorthands. * - * // Cancel the trailing throttled invocation. - * jQuery(window).on('popstate', throttled.cancel); + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. */ - function throttle(func, wait, options) { - var leading = true, - trailing = true; + function baseSortedUniq(array, iteratee) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - if (isObject(options)) { - leading = 'leading' in options ? !!options.leading : leading; - trailing = 'trailing' in options ? !!options.trailing : trailing; + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + if (!index || !eq(computed, seen)) { + var seen = computed; + result[resIndex++] = value === 0 ? 0 : value; + } } - return debounce(func, wait, { - 'leading': leading, - 'maxWait': wait, - 'trailing': trailing - }); + return result; } /** - * Creates a function that accepts up to one argument, ignoring any - * additional arguments. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - * @example + * The base implementation of `_.toNumber` which doesn't ensure correct + * conversions of binary, hexadecimal, or octal string values. * - * _.map(['6', '8', '10'], _.unary(parseInt)); - * // => [6, 8, 10] + * @private + * @param {*} value The value to process. + * @returns {number} Returns the number. */ - function unary(func) { - return ary(func, 1); + function baseToNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + return +value; } /** - * Creates a function that provides `value` to `wrapper` as its first - * argument. Any additional arguments provided to the function are appended - * to those provided to the `wrapper`. The wrapper is invoked with the `this` - * binding of the created function. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {*} value The value to wrap. - * @param {Function} [wrapper=identity] The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '<p>' + func(text) + '</p>'; - * }); + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. * - * p('fred, barney, & pebbles'); - * // => '<p>fred, barney, & pebbles</p>' + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. */ - function wrap(value, wrapper) { - return partial(castFunction(wrapper), value); + function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } - /*------------------------------------------------------------------------*/ - /** - * Casts `value` as an array if it's not one. - * - * @static - * @memberOf _ - * @since 4.4.0 - * @category Lang - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast array. - * @example - * - * _.castArray(1); - * // => [1] - * - * _.castArray({ 'a': 1 }); - * // => [{ 'a': 1 }] - * - * _.castArray('abc'); - * // => ['abc'] - * - * _.castArray(null); - * // => [null] - * - * _.castArray(undefined); - * // => [undefined] - * - * _.castArray(); - * // => [] + * The base implementation of `_.uniqBy` without support for iteratee shorthands. * - * var array = [1, 2, 3]; - * console.log(_.castArray(array) === array); - * // => true + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. */ - function castArray() { - if (!arguments.length) { - return []; + function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (comparator) { + isCommon = false; + includes = arrayIncludesWith; } - var value = arguments[0]; - return isArray(value) ? value : [value]; + else if (length >= LARGE_ARRAY_SIZE) { + var set = iteratee ? null : createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; } /** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. An empty object is returned for uncloneable values such - * as error objects, functions, DOM nodes, and WeakMaps. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @see _.cloneDeep - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * The base implementation of `_.unset`. * - * var shallow = _.clone(objects); - * console.log(shallow[0] === objects[0]); - * // => true + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The property path to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. */ - function clone(value) { - return baseClone(value, CLONE_SYMBOLS_FLAG); + function baseUnset(object, path) { + path = castPath(path, object); + object = parent(object, path); + return object == null || delete object[toKey(last(path))]; } /** - * This method is like `_.clone` except that it accepts `customizer` which - * is invoked to produce the cloned value. If `customizer` returns `undefined`, - * cloning is handled by the method instead. The `customizer` is invoked with - * up to four arguments; (value [, index|key, object, stack]). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the cloned value. - * @see _.cloneDeepWith - * @example - * - * function customizer(value) { - * if (_.isElement(value)) { - * return value.cloneNode(false); - * } - * } - * - * var el = _.cloneWith(document.body, customizer); + * The base implementation of `_.update`. * - * console.log(el === document.body); - * // => false - * console.log(el.nodeName); - * // => 'BODY' - * console.log(el.childNodes.length); - * // => 0 + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to update. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. */ - function cloneWith(value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); + function baseUpdate(object, path, updater, customizer) { + return baseSet(object, path, updater(baseGet(object, path)), customizer); } /** - * This method is like `_.clone` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @returns {*} Returns the deep cloned value. - * @see _.clone - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. * - * var deep = _.cloneDeep(objects); - * console.log(deep[0] === objects[0]); - * // => false + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. */ - function cloneDeep(value) { - return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length) && + predicate(array[index], index, array)) {} + + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); + } + + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to perform to resolve the unwrapped value. + * @returns {*} Returns the resolved value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + return arrayReduce(actions, function(result, action) { + return action.func.apply(action.thisArg, arrayPush([result], action.args)); + }, result); } /** - * This method is like `_.cloneWith` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the deep cloned value. - * @see _.cloneWith - * @example - * - * function customizer(value) { - * if (_.isElement(value)) { - * return value.cloneNode(true); - * } - * } - * - * var el = _.cloneDeepWith(document.body, customizer); + * The base implementation of methods like `_.xor`, without support for + * iteratee shorthands, that accepts an array of arrays to inspect. * - * console.log(el === document.body); - * // => false - * console.log(el.nodeName); - * // => 'BODY' - * console.log(el.childNodes.length); - * // => 20 + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of values. */ - function cloneDeepWith(value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); + function baseXor(arrays, iteratee, comparator) { + var length = arrays.length; + if (length < 2) { + return length ? baseUniq(arrays[0]) : []; + } + var index = -1, + result = Array(length); + + while (++index < length) { + var array = arrays[index], + othIndex = -1; + + while (++othIndex < length) { + if (othIndex != index) { + result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); + } + } + } + return baseUniq(baseFlatten(result, 1), iteratee, comparator); } /** - * Checks if `object` conforms to `source` by invoking the predicate - * properties of `source` with the corresponding property values of `object`. - * - * **Note:** This method is equivalent to `_.conforms` when `source` is - * partially applied. - * - * @static - * @memberOf _ - * @since 4.14.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * - * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); - * // => true + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. * - * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); - * // => false + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. */ - function conformsTo(object, source) { - return source == null || baseConformsTo(object, source, keys(source)); + function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; } /** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false + * Casts `value` to an empty array if it's not an array like object. * - * _.eq(NaN, NaN); - * // => true + * @private + * @param {*} value The value to inspect. + * @returns {Array|Object} Returns the cast array-like object. */ - function eq(value, other) { - return value === other || (value !== value && other !== other); + function castArrayLikeObject(value) { + return isArrayLikeObject(value) ? value : []; } /** - * Checks if `value` is greater than `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - * @see _.lt - * @example - * - * _.gt(3, 1); - * // => true - * - * _.gt(3, 3); - * // => false + * Casts `value` to `identity` if it's not a function. * - * _.gt(1, 3); - * // => false + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. */ - var gt = createRelationalOperation(baseGt); + function castFunction(value) { + return typeof value == 'function' ? value : identity; + } /** - * Checks if `value` is greater than or equal to `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to - * `other`, else `false`. - * @see _.lte - * @example - * - * _.gte(3, 1); - * // => true - * - * _.gte(3, 3); - * // => true + * Casts `value` to a path array if it's not one. * - * _.gte(1, 3); - * // => false + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. */ - var gte = createRelationalOperation(function(value, other) { - return value >= other; - }); + function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); + } /** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true + * A `baseRest` alias which can be replaced with `identity` by module + * replacement plugins. * - * _.isArguments([1, 2, 3]); - * // => false + * @private + * @type {Function} + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. */ - var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee'); - }; + var castRest = baseRest; /** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false + * Casts `array` to a slice if it's needed. * - * _.isArray(_.noop); - * // => false + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. */ - var isArray = Array.isArray; + function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); + } /** - * Checks if `value` is classified as an `ArrayBuffer` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. - * @example - * - * _.isArrayBuffer(new ArrayBuffer(2)); - * // => true + * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). * - * _.isArrayBuffer(new Array(2)); - * // => false + * @private + * @param {number|Object} id The timer id or timeout object of the timer to clear. */ - var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; + var clearTimeout = ctxClearTimeout || function(id) { + return root.clearTimeout(id); + }; /** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true + * Creates a clone of `buffer`. * - * _.isArrayLike(_.noop); - * // => false + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. */ - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); + function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; } /** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false + * Creates a clone of `arrayBuffer`. * - * _.isArrayLikeObject(_.noop); - * // => false + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. */ - function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); + function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array(result).set(new Uint8Array(arrayBuffer)); + return result; } /** - * Checks if `value` is classified as a boolean primitive or object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. - * @example - * - * _.isBoolean(false); - * // => true + * Creates a clone of `dataView`. * - * _.isBoolean(null); - * // => false + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. */ - function isBoolean(value) { - return value === true || value === false || - (isObjectLike(value) && baseGetTag(value) == boolTag); + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } /** - * Checks if `value` is a buffer. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. - * @example - * - * _.isBuffer(new Buffer(2)); - * // => true + * Creates a clone of `regexp`. * - * _.isBuffer(new Uint8Array(2)); - * // => false + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. */ - var isBuffer = nativeIsBuffer || stubFalse; + function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; + } /** - * Checks if `value` is classified as a `Date` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. - * @example - * - * _.isDate(new Date); - * // => true + * Creates a clone of the `symbol` object. * - * _.isDate('Mon April 23 2012'); - * // => false + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. */ - var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; + function cloneSymbol(symbol) { + return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; + } /** - * Checks if `value` is likely a DOM element. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. - * @example - * - * _.isElement(document.body); - * // => true + * Creates a clone of `typedArray`. * - * _.isElement('<body>'); - * // => false + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. */ - function isElement(value) { - return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); + function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } /** - * Checks if `value` is an empty object, collection, map, or set. - * - * Objects are considered empty if they have no own enumerable string keyed - * properties. - * - * Array-like values such as `arguments` objects, arrays, buffers, strings, or - * jQuery-like collections are considered empty if they have a `length` of `0`. - * Similarly, maps and sets are considered empty if they have a `size` of `0`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * _.isEmpty(null); - * // => true - * - * _.isEmpty(true); - * // => true - * - * _.isEmpty(1); - * // => true - * - * _.isEmpty([1, 2, 3]); - * // => false + * Compares values to sort them in ascending order. * - * _.isEmpty({ 'a': 1 }); - * // => false + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. */ - function isEmpty(value) { - if (value == null) { - return true; - } - if (isArrayLike(value) && - (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || - isBuffer(value) || isTypedArray(value) || isArguments(value))) { - return !value.length; - } - var tag = getTag(value); - if (tag == mapTag || tag == setTag) { - return !value.size; - } - if (isPrototype(value)) { - return !baseKeys(value).length; - } - for (var key in value) { - if (hasOwnProperty.call(value, key)) { - return false; + function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol(value); + + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol(other); + + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; } } - return true; + return 0; } /** - * Performs a deep comparison between two values to determine if they are - * equivalent. - * - * **Note:** This method supports comparing arrays, array buffers, booleans, - * date objects, error objects, maps, numbers, `Object` objects, regexes, - * sets, strings, symbols, and typed arrays. `Object` objects are compared - * by their own, not inherited, enumerable properties. Functions and DOM - * nodes are compared by strict equality, i.e. `===`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. * - * _.isEqual(object, other); - * // => true + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. * - * object === other; - * // => false + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. */ - function isEqual(value, other) { - return baseIsEqual(value, other); + function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; } /** - * This method is like `_.isEqual` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with up to - * six arguments: (objValue, othValue [, index|key, object, other, stack]). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, othValue) { - * if (isGreeting(objValue) && isGreeting(othValue)) { - * return true; - * } - * } - * - * var array = ['hello', 'goodbye']; - * var other = ['hi', 'goodbye']; + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. * - * _.isEqualWith(array, other, customizer); - * // => true + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. */ - function isEqualWith(value, other, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - var result = customizer ? customizer(value, other) : undefined; - return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; + function composeArgs(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersLength = holders.length, + leftIndex = -1, + leftLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(leftLength + rangeLength), + isUncurried = !isCurried; + + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + } + while (rangeLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; } /** - * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, - * `SyntaxError`, `TypeError`, or `URIError` object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. - * @example - * - * _.isError(new Error); - * // => true + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. * - * _.isError(Error); - * // => false + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. */ - function isError(value) { - if (!isObjectLike(value)) { - return false; + function composeArgsRight(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersIndex = -1, + holdersLength = holders.length, + rightIndex = -1, + rightLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(rangeLength + rightLength), + isUncurried = !isCurried; + + while (++argsIndex < rangeLength) { + result[argsIndex] = args[argsIndex]; } - var tag = baseGetTag(value); - return tag == errorTag || tag == domExcTag || - (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + } + return result; } /** - * Checks if `value` is a finite primitive number. - * - * **Note:** This method is based on - * [`Number.isFinite`](https://mdn.io/Number/isFinite). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. - * @example - * - * _.isFinite(3); - * // => true - * - * _.isFinite(Number.MIN_VALUE); - * // => true + * Copies the values of `source` to `array`. * - * _.isFinite(Infinity); - * // => false + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + /** + * Copies properties of `source` to `object`. * - * _.isFinite('3'); - * // => false + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. */ - function isFinite(value) { - return typeof value == 'number' && nativeIsFinite(value); + function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; } /** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true + * Copies own symbols of `source` to `object`. * - * _.isFunction(/abc/); - * // => false + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. */ - function isFunction(value) { - if (!isObject(value)) { - return false; - } - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 9 which returns 'object' for typed arrays and other constructors. - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); } /** - * Checks if `value` is an integer. - * - * **Note:** This method is based on - * [`Number.isInteger`](https://mdn.io/Number/isInteger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an integer, else `false`. - * @example - * - * _.isInteger(3); - * // => true - * - * _.isInteger(Number.MIN_VALUE); - * // => false - * - * _.isInteger(Infinity); - * // => false + * Copies own and inherited symbols of `source` to `object`. * - * _.isInteger('3'); - * // => false + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. */ - function isInteger(value) { - return typeof value == 'number' && value == toInteger(value); + function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); } /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false + * Creates a function like `_.groupBy`. * - * _.isLength('3'); - * // => false + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} [initializer] The accumulator object initializer. + * @returns {Function} Returns the new aggregator function. */ - function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + function createAggregator(setter, initializer) { + return function(collection, iteratee) { + var func = isArray(collection) ? arrayAggregator : baseAggregator, + accumulator = initializer ? initializer() : {}; + + return func(collection, setter, getIteratee(iteratee, 2), accumulator); + }; } /** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true + * Creates a function like `_.assign`. * - * _.isObject(null); - * // => false + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. */ - function isObject(value) { - var type = typeof value; - return value != null && (type == 'object' || type == 'function'); + function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; + + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); } /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false + * Creates a `baseEach` or `baseEachRight` function. * - * _.isObjectLike(null); - * // => false + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. */ - function isObjectLike(value) { - return value != null && typeof value == 'object'; + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = fromRight ? length : -1, + iterable = Object(collection); + + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; } /** - * Checks if `value` is classified as a `Map` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - * @example - * - * _.isMap(new Map); - * // => true + * Creates a base function for methods like `_.forIn` and `_.forOwn`. * - * _.isMap(new WeakMap); - * // => false + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. */ - var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; - /** - * Performs a partial deep comparison between `object` and `source` to - * determine if `object` contains equivalent property values. - * - * **Note:** This method is equivalent to `_.matches` when `source` is - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `_.isEqual` - * for a list of supported value comparisons. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * - * _.isMatch(object, { 'b': 2 }); - * // => true + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } + + /** + * Creates a function that wraps `func` to invoke it with the optional `this` + * binding of `thisArg`. * - * _.isMatch(object, { 'b': 1 }); - * // => false + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. */ - function isMatch(object, source) { - return object === source || baseIsMatch(object, source, getMatchData(source)); + function createBind(func, bitmask, thisArg) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); + + function wrapper() { + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return fn.apply(isBind ? thisArg : this, arguments); + } + return wrapper; } /** - * This method is like `_.isMatch` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with five - * arguments: (objValue, srcValue, index|key, object, source). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, srcValue) { - * if (isGreeting(objValue) && isGreeting(srcValue)) { - * return true; - * } - * } - * - * var object = { 'greeting': 'hello' }; - * var source = { 'greeting': 'hi' }; + * Creates a function like `_.lowerFirst`. * - * _.isMatchWith(object, source, customizer); - * // => true + * @private + * @param {string} methodName The name of the `String` case method to use. + * @returns {Function} Returns the new case function. */ - function isMatchWith(object, source, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseIsMatch(object, source, getMatchData(source), customizer); + function createCaseFirst(methodName) { + return function(string) { + string = toString(string); + + var strSymbols = hasUnicode(string) + ? stringToArray(string) + : undefined; + + var chr = strSymbols + ? strSymbols[0] + : string.charAt(0); + + var trailing = strSymbols + ? castSlice(strSymbols, 1).join('') + : string.slice(1); + + return chr[methodName]() + trailing; + }; } /** - * Checks if `value` is `NaN`. - * - * **Note:** This method is based on - * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as - * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for - * `undefined` and other non-number values. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - * @example - * - * _.isNaN(NaN); - * // => true - * - * _.isNaN(new Number(NaN)); - * // => true - * - * isNaN(undefined); - * // => true + * Creates a function like `_.camelCase`. * - * _.isNaN(undefined); - * // => false + * @private + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. */ - function isNaN(value) { - // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some - // ActiveX objects in IE. - return isNumber(value) && value != +value; + function createCompounder(callback) { + return function(string) { + return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); + }; } /** - * Checks if `value` is a pristine native function. - * - * **Note:** This method can't reliably detect native functions in the presence - * of the core-js package because core-js circumvents this kind of detection. - * Despite multiple requests, the core-js maintainer has made it clear: any - * attempt to fix the detection will be obstructed. As a result, we're left - * with little choice but to throw an error. Unfortunately, this also affects - * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), - * which rely on core-js. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. * - * _.isNative(_); - * // => false + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. */ - function isNative(value) { - if (isMaskable(value)) { - throw new Error(CORE_ERROR_TEXT); - } - return baseIsNative(value); + function createCtor(Ctor) { + return function() { + // Use a `switch` statement to work with class constructors. See + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); + + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; } /** - * Checks if `value` is `null`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `null`, else `false`. - * @example - * - * _.isNull(null); - * // => true + * Creates a function that wraps `func` to enable currying. * - * _.isNull(void 0); - * // => false + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {number} arity The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ - function isNull(value) { - return value === null; + function createCurry(func, bitmask, arity) { + var Ctor = createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length, + placeholder = getHolder(wrapper); + + while (index--) { + args[index] = arguments[index]; + } + var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) + ? [] + : replaceHolders(args, placeholder); + + length -= holders.length; + if (length < arity) { + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, undefined, + args, holders, undefined, undefined, arity - length); + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return apply(fn, this, args); + } + return wrapper; } /** - * Checks if `value` is `null` or `undefined`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is nullish, else `false`. - * @example - * - * _.isNil(null); - * // => true - * - * _.isNil(void 0); - * // => true + * Creates a `_.find` or `_.findLast` function. * - * _.isNil(NaN); - * // => false + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. */ - function isNil(value) { - return value == null; + function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = getIteratee(predicate, 3); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; } /** - * Checks if `value` is classified as a `Number` primitive or object. - * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are - * classified as numbers, use the `_.isFinite` method. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a number, else `false`. - * @example - * - * _.isNumber(3); - * // => true - * - * _.isNumber(Number.MIN_VALUE); - * // => true - * - * _.isNumber(Infinity); - * // => true + * Creates a `_.flow` or `_.flowRight` function. * - * _.isNumber('3'); - * // => false + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new flow function. */ - function isNumber(value) { - return typeof value == 'number' || - (isObjectLike(value) && baseGetTag(value) == numberTag); + function createFlow(fromRight) { + return flatRest(function(funcs) { + var length = funcs.length, + index = length, + prereq = LodashWrapper.prototype.thru; + + if (fromRight) { + funcs.reverse(); + } + while (index--) { + var func = funcs[index]; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (prereq && !wrapper && getFuncName(func) == 'wrapper') { + var wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? index : length; + while (++index < length) { + func = funcs[index]; + + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : undefined; + + if (data && isLaziable(data[0]) && + data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && + !data[4].length && data[9] == 1 + ) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = (func.length == 1 && isLaziable(func)) + ? wrapper[funcName]() + : wrapper.thru(func); + } + } + return function() { + var args = arguments, + value = args[0]; + + if (wrapper && args.length == 1 && isArray(value)) { + return wrapper.plant(value).value(); + } + var index = 0, + result = length ? funcs[index].apply(this, args) : value; + + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }); } /** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * @static - * @memberOf _ - * @since 0.8.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true + * Creates a function that wraps `func` to invoke it with optional `this` + * binding of `thisArg`, partial application, and currying. * - * _.isPlainObject(Object.create(null)); - * // => true + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ - function isPlainObject(value) { - if (!isObjectLike(value) || baseGetTag(value) != objectTag) { - return false; - } - var proto = getPrototype(value); - if (proto === null) { - return true; + function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & WRAP_ARY_FLAG, + isBind = bitmask & WRAP_BIND_FLAG, + isBindKey = bitmask & WRAP_BIND_KEY_FLAG, + isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), + isFlip = bitmask & WRAP_FLIP_FLAG, + Ctor = isBindKey ? undefined : createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length; + + while (index--) { + args[index] = arguments[index]; + } + if (isCurried) { + var placeholder = getHolder(wrapper), + holdersCount = countHolders(args, placeholder); + } + if (partials) { + args = composeArgs(args, partials, holders, isCurried); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight, isCurried); + } + length -= holdersCount; + if (isCurried && length < arity) { + var newHolders = replaceHolders(args, placeholder); + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, thisArg, + args, newHolders, argPos, ary, arity - length + ); + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; + + length = args.length; + if (argPos) { + args = reorder(args, argPos); + } else if (isFlip && length > 1) { + args.reverse(); + } + if (isAry && ary < length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtor(fn); + } + return fn.apply(thisBinding, args); } - var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; - return typeof Ctor == 'function' && Ctor instanceof Ctor && - funcToString.call(Ctor) == objectCtorString; + return wrapper; } /** - * Checks if `value` is classified as a `RegExp` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. - * @example - * - * _.isRegExp(/abc/); - * // => true + * Creates a function like `_.invertBy`. * - * _.isRegExp('/abc/'); - * // => false + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} toIteratee The function to resolve iteratees. + * @returns {Function} Returns the new inverter function. */ - var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; + function createInverter(setter, toIteratee) { + return function(object, iteratee) { + return baseInverter(object, setter, toIteratee(iteratee), {}); + }; + } /** - * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 - * double precision number which isn't the result of a rounded unsafe integer. - * - * **Note:** This method is based on - * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. - * @example - * - * _.isSafeInteger(3); - * // => true - * - * _.isSafeInteger(Number.MIN_VALUE); - * // => false - * - * _.isSafeInteger(Infinity); - * // => false + * Creates a function that performs a mathematical operation on two values. * - * _.isSafeInteger('3'); - * // => false + * @private + * @param {Function} operator The function to perform the operation. + * @param {number} [defaultValue] The value used for `undefined` arguments. + * @returns {Function} Returns the new mathematical operation function. */ - function isSafeInteger(value) { - return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; + function createMathOperation(operator, defaultValue) { + return function(value, other) { + var result; + if (value === undefined && other === undefined) { + return defaultValue; + } + if (value !== undefined) { + result = value; + } + if (other !== undefined) { + if (result === undefined) { + return other; + } + if (typeof value == 'string' || typeof other == 'string') { + value = baseToString(value); + other = baseToString(other); + } else { + value = baseToNumber(value); + other = baseToNumber(other); + } + result = operator(value, other); + } + return result; + }; } /** - * Checks if `value` is classified as a `Set` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - * @example - * - * _.isSet(new Set); - * // => true + * Creates a function like `_.over`. * - * _.isSet(new WeakSet); - * // => false + * @private + * @param {Function} arrayFunc The function to iterate over iteratees. + * @returns {Function} Returns the new over function. */ - var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + function createOver(arrayFunc) { + return flatRest(function(iteratees) { + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); + return baseRest(function(args) { + var thisArg = this; + return arrayFunc(iteratees, function(iteratee) { + return apply(iteratee, thisArg, args); + }); + }); + }); + } /** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * _.isString('abc'); - * // => true + * Creates the padding for `string` based on `length`. The `chars` string + * is truncated if the number of characters exceeds `length`. * - * _.isString(1); - * // => false + * @private + * @param {number} length The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padding for `string`. */ - function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); + function createPadding(length, chars) { + chars = chars === undefined ? ' ' : baseToString(chars); + + var charsLength = chars.length; + if (charsLength < 2) { + return charsLength ? baseRepeat(chars, length) : chars; + } + var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); + return hasUnicode(chars) + ? castSlice(stringToArray(result), 0, length).join('') + : result.slice(0, length); } /** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true + * Creates a function that wraps `func` to invoke it with the `this` binding + * of `thisArg` and `partials` prepended to the arguments it receives. * - * _.isSymbol('abc'); - * // => false + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. + * @returns {Function} Returns the new wrapped function. */ - function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && baseGetTag(value) == symbolTag); + function createPartial(func, bitmask, thisArg, partials) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); + + function wrapper() { + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + return apply(fn, isBind ? thisArg : this, args); + } + return wrapper; } /** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true + * Creates a `_.range` or `_.rangeRight` function. * - * _.isTypedArray([]); - * // => false + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. */ - var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step, fromRight); + }; + } /** - * Checks if `value` is `undefined`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true + * Creates a function that performs a relational operation on two values. * - * _.isUndefined(null); - * // => false + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new relational operation function. */ - function isUndefined(value) { - return value === undefined; + function createRelationalOperation(operator) { + return function(value, other) { + if (!(typeof value == 'string' && typeof other == 'string')) { + value = toNumber(value); + other = toNumber(other); + } + return operator(value, other); + }; } /** - * Checks if `value` is classified as a `WeakMap` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. - * @example - * - * _.isWeakMap(new WeakMap); - * // => true + * Creates a function that wraps `func` to continue currying. * - * _.isWeakMap(new Map); - * // => false + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {Function} wrapFunc The function to create the `func` wrapper. + * @param {*} placeholder The placeholder value. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ - function isWeakMap(value) { - return isObjectLike(value) && getTag(value) == weakMapTag; - } + function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { + var isCurry = bitmask & WRAP_CURRY_FLAG, + newHolders = isCurry ? holders : undefined, + newHoldersRight = isCurry ? undefined : holders, + newPartials = isCurry ? partials : undefined, + newPartialsRight = isCurry ? undefined : partials; - /** - * Checks if `value` is classified as a `WeakSet` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. - * @example - * - * _.isWeakSet(new WeakSet); - * // => true + bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); + + if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { + bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); + } + var newData = [ + func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, + newHoldersRight, argPos, ary, arity + ]; + + var result = wrapFunc.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return setWrapToString(result, func, bitmask); + } + + /** + * Creates a function like `_.round`. * - * _.isWeakSet(new Set); - * // => false + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. */ - function isWeakSet(value) { - return isObjectLike(value) && baseGetTag(value) == weakSetTag; + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + number = toNumber(number); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); + if (precision && nativeIsFinite(number)) { + // Shift with exponential notation to avoid floating-point issues. + // See [MDN](https://mdn.io/round#Examples) for more details. + var pair = (toString(number) + 'e').split('e'), + value = func(pair[0] + 'e' + (+pair[1] + precision)); + + pair = (toString(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); + } + return func(number); + }; } /** - * Checks if `value` is less than `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - * @see _.gt - * @example - * - * _.lt(1, 3); - * // => true - * - * _.lt(3, 3); - * // => false + * Creates a set object of `values`. * - * _.lt(3, 1); - * // => false + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. */ - var lt = createRelationalOperation(baseLt); + var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); + }; /** - * Checks if `value` is less than or equal to `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to - * `other`, else `false`. - * @see _.gte - * @example - * - * _.lte(1, 3); - * // => true - * - * _.lte(3, 3); - * // => true + * Creates a `_.toPairs` or `_.toPairsIn` function. * - * _.lte(3, 1); - * // => false + * @private + * @param {Function} keysFunc The function to get the keys of a given object. + * @returns {Function} Returns the new pairs function. */ - var lte = createRelationalOperation(function(value, other) { - return value <= other; - }); + function createToPairs(keysFunc) { + return function(object) { + var tag = getTag(object); + if (tag == mapTag) { + return mapToArray(object); + } + if (tag == setTag) { + return setToPairs(object); + } + return baseToPairs(object, keysFunc(object)); + }; + } /** - * Converts `value` to an array. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {Array} Returns the converted array. - * @example - * - * _.toArray({ 'a': 1, 'b': 2 }); - * // => [1, 2] - * - * _.toArray('abc'); - * // => ['a', 'b', 'c'] - * - * _.toArray(1); - * // => [] + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. * - * _.toArray(null); - * // => [] + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * 512 - `_.flip` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ - function toArray(value) { - if (!value) { - return []; + function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); } - if (isArrayLike(value)) { - return isString(value) ? stringToArray(value) : copyArray(value); + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); + partials = holders = undefined; } - if (symIterator && value[symIterator]) { - return iteratorToArray(value[symIterator]()); + ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); + arity = arity === undefined ? arity : toInteger(arity); + length -= holders ? holders.length : 0; + + if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; + + partials = holders = undefined; } - var tag = getTag(value), - func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); + var data = isBindKey ? undefined : getData(func); - return func(value); - } + var newData = [ + func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, + argPos, ary, arity + ]; - /** - * Converts `value` to a finite number. - * - * @static - * @memberOf _ - * @since 4.12.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted number. - * @example - * - * _.toFinite(3.2); - * // => 3.2 - * - * _.toFinite(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toFinite(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toFinite('3.2'); - * // => 3.2 - */ - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; + if (data) { + mergeData(newData, data); } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = (value < 0 ? -1 : 1); - return sign * MAX_INTEGER; + func = newData[0]; + bitmask = newData[1]; + thisArg = newData[2]; + partials = newData[3]; + holders = newData[4]; + arity = newData[9] = newData[9] === undefined + ? (isBindKey ? 0 : func.length) + : nativeMax(newData[9] - length, 0); + + if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { + bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); } - return value === value ? value : 0; + if (!bitmask || bitmask == WRAP_BIND_FLAG) { + var result = createBind(func, bitmask, thisArg); + } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { + result = createCurry(func, bitmask, arity); + } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { + result = createPartial(func, bitmask, thisArg, partials); + } else { + result = createHybrid.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setWrapToString(setter(result, newData), func, bitmask); } /** - * Converts `value` to an integer. - * - * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toInteger(3.2); - * // => 3 - * - * _.toInteger(Number.MIN_VALUE); - * // => 0 + * Used by `_.defaults` to customize its `_.assignIn` use to assign properties + * of source objects to the destination object for all destination properties + * that resolve to `undefined`. * - * _.toInteger(Infinity); - * // => 1.7976931348623157e+308 + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ + function customDefaultsAssignIn(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; + } + + /** + * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source + * objects into destination objects that are passed thru. * - * _.toInteger('3.2'); - * // => 3 + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to merge. + * @param {Object} object The parent object of `objValue`. + * @param {Object} source The parent object of `srcValue`. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + * @returns {*} Returns the value to assign. */ - function toInteger(value) { - var result = toFinite(value), - remainder = result % 1; - - return result === result ? (remainder ? result - remainder : result) : 0; + function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { + if (isObject(objValue) && isObject(srcValue)) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, objValue); + baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); + stack['delete'](srcValue); + } + return objValue; } /** - * Converts `value` to an integer suitable for use as the length of an - * array-like object. - * - * **Note:** This method is based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toLength(3.2); - * // => 3 - * - * _.toLength(Number.MIN_VALUE); - * // => 0 - * - * _.toLength(Infinity); - * // => 4294967295 + * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain + * objects. * - * _.toLength('3.2'); - * // => 3 + * @private + * @param {*} value The value to inspect. + * @param {string} key The key of the property to inspect. + * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. */ - function toLength(value) { - return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; + function customOmitClone(value) { + return isPlainObject(value) ? undefined : value; } /** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3.2); - * // => 3.2 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. * - * _.toNumber('3.2'); - * // => 3.2 + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ - function toNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; + function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; } - if (isObject(value)) { - var other = typeof value.valueOf == 'function' ? value.valueOf() : value; - value = isObject(other) ? (other + '') : other; + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; } - if (typeof value != 'string') { - return value === 0 ? value : +value; + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } } - value = value.replace(reTrim, ''); - var isBinary = reIsBinary.test(value); - return (isBinary || reIsOctal.test(value)) - ? freeParseInt(value.slice(2), isBinary ? 2 : 8) - : (reIsBadHex.test(value) ? NAN : +value); + stack['delete'](array); + stack['delete'](other); + return result; } /** - * Converts `value` to a plain object flattening inherited enumerable string - * keyed properties of `value` to own properties of the plain object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. - * @example - * - * function Foo() { - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. * - * _.assign({ 'a': 1 }, new Foo); - * // => { 'a': 1, 'b': 2 } + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * - * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); - * // => { 'a': 1, 'b': 2, 'c': 3 } + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ - function toPlainObject(value) { - return copyObject(value, keysIn(value)); + function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; } /** - * Converts `value` to a safe integer. A safe integer can be compared and - * represented correctly. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toSafeInteger(3.2); - * // => 3 - * - * _.toSafeInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toSafeInteger(Infinity); - * // => 9007199254740991 + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. * - * _.toSafeInteger('3.2'); - * // => 3 + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ - function toSafeInteger(value) { - return value - ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) - : (value === 0 ? value : 0); - } + function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; - /** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ - function toString(value) { - return value == null ? '' : baseToString(value); - } + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; + } + var result = true; + stack.set(object, other); + stack.set(other, object); - /*------------------------------------------------------------------------*/ + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; - /** - * Assigns own enumerable string keyed properties of source objects to the - * destination object. Source objects are applied from left to right. - * Subsequent sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object` and is loosely based on - * [`Object.assign`](https://mdn.io/Object/assign). - * - * @static - * @memberOf _ - * @since 0.10.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.assignIn - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } - * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; - * - * _.assign({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'c': 3 } - */ - var assign = createAssigner(function(object, source) { - if (isPrototype(source) || isArrayLike(source)) { - copyObject(source, keys(source), object); - return; + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); } - for (var key in source) { - if (hasOwnProperty.call(source, key)) { - assignValue(object, key, source[key]); + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; } } - }); + stack['delete'](object); + stack['delete'](other); + return result; + } /** - * This method is like `_.assign` except that it iterates over own and - * inherited source properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.assign - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } - * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; + * A specialized version of `baseRest` which flattens the rest array. * - * _.assignIn({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. */ - var assignIn = createAssigner(function(object, source) { - copyObject(source, keysIn(source), object); - }); + function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); + } /** - * This method is like `_.assignIn` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extendWith - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignInWith, customizer); + * Creates an array of own enumerable property names and symbols of `object`. * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. */ - var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { - copyObject(source, keysIn(source), object, customizer); - }); + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } - /** - * This method is like `_.assign` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignInWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignWith, customizer); + /** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. */ - var assignWith = createAssigner(function(object, source, srcIndex, customizer) { - copyObject(source, keys(source), object, customizer); - }); + function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); + } /** - * Creates an array of values corresponding to `paths` of `object`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Array} Returns the picked values. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * Gets metadata for `func`. * - * _.at(object, ['a[0].b.c', 'a[1]']); - * // => [3, 4] + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. */ - var at = flatRest(baseAt); + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; /** - * Creates an object that inherits from the `prototype` object. If a - * `properties` object is given, its own enumerable string keyed properties - * are assigned to the created object. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { - * 'constructor': Circle - * }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true + * Gets the name of `func`. * - * circle instanceof Shape; - * // => true + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. */ - function create(prototype, properties) { - var result = baseCreate(prototype); - return properties == null ? result : baseAssign(result, properties); + function getFuncName(func) { + var result = (func.name + ''), + array = realNames[result], + length = hasOwnProperty.call(realNames, result) ? array.length : 0; + + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; } /** - * Assigns own and inherited enumerable string keyed properties of source - * objects to the destination object for all destination properties that - * resolve to `undefined`. Source objects are applied from left to right. - * Once a property is set, additional values of the same property are ignored. - * - * **Note:** This method mutates `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.defaultsDeep - * @example + * Gets the argument placeholder value for `func`. * - * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } + * @private + * @param {Function} func The function to inspect. + * @returns {*} Returns the placeholder value. */ - var defaults = baseRest(function(args) { - args.push(undefined, customDefaultsAssignIn); - return apply(assignInWith, undefined, args); - }); + function getHolder(func) { + var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; + return object.placeholder; + } /** - * This method is like `_.defaults` except that it recursively assigns - * default properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 3.10.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.defaults - * @example + * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, + * this function returns the custom method, otherwise it returns `baseIteratee`. + * If arguments are provided, the chosen function is invoked with them and + * its result is returned. * - * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); - * // => { 'a': { 'b': 2, 'c': 3 } } + * @private + * @param {*} [value] The value to convert to an iteratee. + * @param {number} [arity] The arity of the created iteratee. + * @returns {Function} Returns the chosen function or its result. */ - var defaultsDeep = baseRest(function(args) { - args.push(undefined, customDefaultsMerge); - return apply(mergeWith, undefined, args); - }); + function getIteratee() { + var result = lodash.iteratee || iteratee; + result = result === iteratee ? baseIteratee : result; + return arguments.length ? result(arguments[0], arguments[1]) : result; + } /** - * This method is like `_.find` except that it returns the key of the first - * element `predicate` returns truthy for instead of the element itself. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. - * @example - * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findKey(users, function(o) { return o.age < 40; }); - * // => 'barney' (iteration order is not guaranteed) - * - * // The `_.matches` iteratee shorthand. - * _.findKey(users, { 'age': 1, 'active': true }); - * // => 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findKey(users, ['active', false]); - * // => 'fred' + * Gets the data for `map`. * - * // The `_.property` iteratee shorthand. - * _.findKey(users, 'active'); - * // => 'barney' + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. */ - function findKey(object, predicate) { - return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; } /** - * This method is like `_.findKey` except that it iterates over elements of - * a collection in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. - * @example - * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findLastKey(users, function(o) { return o.age < 40; }); - * // => returns 'pebbles' assuming `_.findKey` returns 'barney' + * Gets the property names, values, and compare flags of `object`. * - * // The `_.matches` iteratee shorthand. - * _.findLastKey(users, { 'age': 36, 'active': true }); - * // => 'barney' + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ + function getMatchData(object) { + var result = keys(object), + length = result.length; + + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } + return result; + } + + /** + * Gets the native function at `key` of `object`. * - * // The `_.matchesProperty` iteratee shorthand. - * _.findLastKey(users, ['active', false]); - * // => 'fred' + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; + } + + /** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * - * // The `_.property` iteratee shorthand. - * _.findLastKey(users, 'active'); - * // => 'pebbles' + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. */ - function findLastKey(object, predicate) { - return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); + function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; } /** - * Iterates over own and inherited enumerable string keyed properties of an - * object and invokes `iteratee` for each property. The iteratee is invoked - * with three arguments: (value, key, object). Iteratee functions may exit - * iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forInRight - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Creates an array of the own enumerable symbols of `object`. * - * _.forIn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. */ - function forIn(object, iteratee) { - return object == null - ? object - : baseFor(object, getIteratee(iteratee, 3), keysIn); - } + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); + }; /** - * This method is like `_.forIn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forIn - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } + * Creates an array of the own and inherited enumerable symbols of `object`. * - * Foo.prototype.c = 3; + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; + }; + + /** + * Gets the `toStringTag` of `value`. * - * _.forInRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. */ - function forInRight(object, iteratee) { - return object == null - ? object - : baseForRight(object, getIteratee(iteratee, 3), keysIn); + var getTag = baseGetTag; + + // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; } /** - * Iterates over own enumerable string keyed properties of an object and - * invokes `iteratee` for each property. The iteratee is invoked with three - * arguments: (value, key, object). Iteratee functions may exit iteration - * early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forOwnRight - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Gets the view, applying any `transforms` to the `start` and `end` positions. * - * _.forOwn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). + * @private + * @param {number} start The start of the view. + * @param {number} end The end of the view. + * @param {Array} transforms The transformations to apply to the view. + * @returns {Object} Returns an object containing the `start` and `end` + * positions of the view. */ - function forOwn(object, iteratee) { - return object && baseForOwn(object, getIteratee(iteratee, 3)); + function getView(start, end, transforms) { + var index = -1, + length = transforms.length; + + while (++index < length) { + var data = transforms[index], + size = data.size; + + switch (data.type) { + case 'drop': start += size; break; + case 'dropRight': end -= size; break; + case 'take': end = nativeMin(end, start + size); break; + case 'takeRight': start = nativeMax(start, end - size); break; + } + } + return { 'start': start, 'end': end }; } /** - * This method is like `_.forOwn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forOwn - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Extracts wrapper details from the `source` body comment. * - * _.forOwnRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. + * @private + * @param {string} source The source to inspect. + * @returns {Array} Returns the wrapper details. */ - function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, getIteratee(iteratee, 3)); + function getWrapDetails(source) { + var match = source.match(reWrapDetails); + return match ? match[1].split(reSplitDetails) : []; } /** - * Creates an array of function property names from own enumerable properties - * of `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the function names. - * @see _.functionsIn - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); + * Checks if `path` exists on `object`. * - * _.functions(new Foo); - * // => ['a', 'b'] + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. */ - function functions(object) { - return object == null ? [] : baseFunctions(object, keys(object)); + function hasPath(object, path, hasFunc) { + path = castPath(path, object); + + var index = -1, + length = path.length, + result = false; + + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; + } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); } /** - * Creates an array of function property names from own and inherited - * enumerable properties of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the function names. - * @see _.functions - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); + * Initializes an array clone. * - * _.functionsIn(new Foo); - * // => ['a', 'b', 'c'] + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. */ - function functionsIn(object) { - return object == null ? [] : baseFunctions(object, keysIn(object)); + function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; } /** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 + * Initializes an object clone. * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. */ - function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; + function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; } /** - * Checks if `path` is a direct property of `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = { 'a': { 'b': 2 } }; - * var other = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.has(object, 'a'); - * // => true - * - * _.has(object, 'a.b'); - * // => true + * Initializes an object clone based on its `toStringTag`. * - * _.has(object, ['a', 'b']); - * // => true + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. * - * _.has(other, 'a'); - * // => false + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. */ - function has(object, path) { - return object != null && hasPath(object, path, baseHas); + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return cloneArrayBuffer(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case dataViewTag: + return cloneDataView(object, isDeep); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + return cloneTypedArray(object, isDeep); + + case mapTag: + return new Ctor; + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + return cloneRegExp(object); + + case setTag: + return new Ctor; + + case symbolTag: + return cloneSymbol(object); + } } /** - * Checks if `path` is a direct or inherited property of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true - * - * _.hasIn(object, ['a', 'b']); - * // => true + * Inserts wrapper `details` in a comment at the top of the `source` body. * - * _.hasIn(object, 'b'); - * // => false + * @private + * @param {string} source The source to modify. + * @returns {Array} details The details to insert. + * @returns {string} Returns the modified source. */ - function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); + function insertWrapDetails(source, details) { + var length = details.length; + if (!length) { + return source; + } + var lastIndex = length - 1; + details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; + details = details.join(length > 2 ? ', ' : ' '); + return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); } /** - * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite - * property assignments of previous values. - * - * @static - * @memberOf _ - * @since 0.7.0 - * @category Object - * @param {Object} object The object to invert. - * @returns {Object} Returns the new inverted object. - * @example - * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * Checks if `value` is a flattenable `arguments` object or array. * - * _.invert(object); - * // => { '1': 'c', '2': 'b' } + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. */ - var invert = createInverter(function(result, value, key) { - result[value] = key; - }, constant(identity)); + function isFlattenable(value) { + return isArray(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); + } /** - * This method is like `_.invert` except that the inverted object is generated - * from the results of running each element of `object` thru `iteratee`. The - * corresponding inverted value of each inverted key is an array of keys - * responsible for generating the inverted value. The iteratee is invoked - * with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.1.0 - * @category Object - * @param {Object} object The object to invert. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Object} Returns the new inverted object. - * @example - * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; - * - * _.invertBy(object); - * // => { '1': ['a', 'c'], '2': ['b'] } + * Checks if `value` is a valid array-like index. * - * _.invertBy(object, function(value) { - * return 'group' + value; - * }); - * // => { 'group1': ['a', 'c'], 'group2': ['b'] } + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ - var invertBy = createInverter(function(result, value, key) { - if (hasOwnProperty.call(result, value)) { - result[value].push(key); - } else { - result[value] = [key]; - } - }, getIteratee); + function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); + } /** - * Invokes the method at `path` of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - * @example - * - * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + * Checks if the given arguments are from an iteratee call. * - * _.invoke(object, 'a[0].b.c.slice', 1, 3); - * // => [2, 3] + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. */ - var invoke = baseRest(baseInvoke); + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); + } + return false; + } /** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) + * Checks if `value` is a property name and not a property path. * - * _.keys('hi'); - * // => ['0', '1'] + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ - function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); } /** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Checks if `value` is suitable for use as unique object key. * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ - function keysIn(object) { - return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); + function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); } /** - * The opposite of `_.mapValues`; this method creates an object with the - * same values as `object` and keys generated by running each own enumerable - * string keyed property of `object` thru `iteratee`. The iteratee is invoked - * with three arguments: (value, key, object). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapValues - * @example + * Checks if `func` has a lazy counterpart. * - * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { - * return key + value; - * }); - * // => { 'a1': 1, 'b2': 2 } + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. */ - function mapKeys(object, iteratee) { - var result = {}; - iteratee = getIteratee(iteratee, 3); + function isLaziable(func) { + var funcName = getFuncName(func), + other = lodash[funcName]; - baseForOwn(object, function(value, key, object) { - baseAssignValue(result, iteratee(value, key, object), value); - }); - return result; + if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; } /** - * Creates an object with the same keys as `object` and values generated - * by running each own enumerable string keyed property of `object` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, key, object). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapKeys - * @example - * - * var users = { - * 'fred': { 'user': 'fred', 'age': 40 }, - * 'pebbles': { 'user': 'pebbles', 'age': 1 } - * }; - * - * _.mapValues(users, function(o) { return o.age; }); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * Checks if `func` has its source masked. * - * // The `_.property` iteratee shorthand. - * _.mapValues(users, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ - function mapValues(object, iteratee) { - var result = {}; - iteratee = getIteratee(iteratee, 3); - - baseForOwn(object, function(value, key, object) { - baseAssignValue(result, key, iteratee(value, key, object)); - }); - return result; + function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); } /** - * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable string keyed properties of source objects into the - * destination object. Source properties that resolve to `undefined` are - * skipped if a destination value exists. Array and plain object properties - * are merged recursively. Other objects and value types are overridden by - * assignment. Source objects are applied from left to right. Subsequent - * sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * var object = { - * 'a': [{ 'b': 2 }, { 'd': 4 }] - * }; - * - * var other = { - * 'a': [{ 'c': 3 }, { 'e': 5 }] - * }; + * Checks if `func` is capable of being masked. * - * _.merge(object, other); - * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `func` is maskable, else `false`. */ - var merge = createAssigner(function(object, source, srcIndex) { - baseMerge(object, source, srcIndex); - }); + var isMaskable = coreJsData ? isFunction : stubFalse; /** - * This method is like `_.merge` except that it accepts `customizer` which - * is invoked to produce the merged values of the destination and source - * properties. If `customizer` returns `undefined`, merging is handled by the - * method instead. The `customizer` is invoked with six arguments: - * (objValue, srcValue, key, object, source, stack). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * if (_.isArray(objValue)) { - * return objValue.concat(srcValue); - * } - * } + * Checks if `value` is likely a prototype object. * - * var object = { 'a': [1], 'b': [2] }; - * var other = { 'a': [3], 'b': [4] }; + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ + function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; + } + + /** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * - * _.mergeWith(object, other, customizer); - * // => { 'a': [1, 3], 'b': [2, 4] } + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. */ - var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { - baseMerge(object, source, srcIndex, customizer); - }); + function isStrictComparable(value) { + return value === value && !isObject(value); + } /** - * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable property paths of `object` that are not omitted. + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. * - * **Note:** This method is considerably slower than `_.pick`. + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; + } + + /** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to omit. - * @returns {Object} Returns the new object. - * @example + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ + function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; + } + + /** + * Merges the function metadata of `source` into `data`. * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * Merging metadata reduces the number of wrappers used to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. * - * _.omit(object, ['a', 'c']); - * // => { 'b': '2' } + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. */ - var omit = flatRest(function(object, paths) { - var result = {}; - if (object == null) { - return result; + function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); + + var isCombo = + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || + ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); + + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; } - var isDeep = false; - paths = arrayMap(paths, function(path) { - path = castPath(path, object); - isDeep || (isDeep = path.length > 1); - return path; - }); - copyObject(object, getAllKeysIn(object), result); - if (isDeep) { - result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); + // Use source `thisArg` if available. + if (srcBitmask & WRAP_BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; } - var length = paths.length; - while (length--) { - baseUnset(result, paths[length]); + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : value; + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; } - return result; - }); + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = value; + } + // Use source `ary` if it's smaller. + if (srcBitmask & WRAP_ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; + + return data; + } /** - * The opposite of `_.pickBy`; this method creates an object composed of - * the own and inherited enumerable string keyed properties of `object` that - * `predicate` doesn't return truthy for. The predicate is invoked with two - * arguments: (value, key). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The source object. - * @param {Function} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. * - * _.omitBy(object, _.isNumber); - * // => { 'b': '2' } + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. */ - function omitBy(object, predicate) { - return pickBy(object, negate(getIteratee(predicate))); + function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; } /** - * Creates an object composed of the picked `object` properties. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * Converts `value` to a string using `Object.prototype.toString`. * - * _.pick(object, ['a', 'c']); - * // => { 'a': 1, 'c': 3 } + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. */ - var pick = flatRest(function(object, paths) { - return object == null ? {} : basePick(object, paths); - }); + function objectToString(value) { + return nativeObjectToString.call(value); + } /** - * Creates an object composed of the `object` properties `predicate` returns - * truthy for. The predicate is invoked with two arguments: (value, key). + * A specialized version of `baseRest` which transforms the rest array. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The source object. - * @param {Function} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. - * @example + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ + function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply(func, this, otherArgs); + }; + } + + /** + * Gets the parent value at `path` of `object`. * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * @private + * @param {Object} object The object to query. + * @param {Array} path The path to get the parent value of. + * @returns {*} Returns the parent value. + */ + function parent(object, path) { + return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); + } + + /** + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. * - * _.pickBy(object, _.isNumber); - * // => { 'a': 1, 'c': 3 } + * @private + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. */ - function pickBy(object, predicate) { - if (object == null) { - return {}; + function reorder(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = copyArray(array); + + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; } - var props = arrayMap(getAllKeysIn(object), function(prop) { - return [prop]; - }); - predicate = getIteratee(predicate); - return basePickBy(object, props, function(value, path) { - return predicate(value, path[0]); - }); + return array; } /** - * This method is like `_.get` except that if the resolved value is a - * function it's invoked with the `this` binding of its parent object and - * its result is returned. + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object + * @private * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; - * - * _.result(object, 'a[0].b.c1'); - * // => 3 - * - * _.result(object, 'a[0].b.c2'); - * // => 4 - * - * _.result(object, 'a[0].b.c3', 'default'); - * // => 'default' - * - * _.result(object, 'a[0].b.c3', _.constant('default')); - * // => 'default' + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. */ - function result(object, path, defaultValue) { - path = castPath(path, object); - - var index = -1, - length = path.length; - - // Ensure the loop is entered when path is empty. - if (!length) { - length = 1; - object = undefined; + function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; } - while (++index < length) { - var value = object == null ? undefined : object[toKey(path[index])]; - if (value === undefined) { - index = length; - value = defaultValue; - } - object = isFunction(value) ? value.call(object) : value; + + if (key == '__proto__') { + return; } - return object; + + return object[key]; } /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, - * it's created. Arrays are created for missing index properties while objects - * are created for all other missing properties. Use `_.setWith` to customize - * `path` creation. + * Sets metadata for `func`. * - * **Note:** This method mutates `object`. + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) + * for more details. * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @returns {Object} Returns `object`. - * @example + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var setData = shortOut(baseSetData); + + /** + * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @returns {number|Object} Returns the timer id or timeout object. + */ + var setTimeout = ctxSetTimeout || function(func, wait) { + return root.setTimeout(func, wait); + }; + + /** + * Sets the `toString` method of `func` to return `string`. * - * _.set(object, 'a[0].b.c', 4); - * console.log(object.a[0].b.c); - * // => 4 + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var setToString = shortOut(baseSetToString); + + /** + * Sets the `toString` method of `wrapper` to mimic the source of `reference` + * with wrapper details in a comment at the top of the source body. * - * _.set(object, ['x', '0', 'y', 'z'], 5); - * console.log(object.x[0].y.z); - * // => 5 + * @private + * @param {Function} wrapper The function to modify. + * @param {Function} reference The reference function. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Function} Returns `wrapper`. */ - function set(object, path, value) { - return object == null ? object : baseSet(object, path, value); + function setWrapToString(wrapper, reference, bitmask) { + var source = (reference + ''); + return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); } /** - * This method is like `_.set` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * var object = {}; + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. * - * _.setWith(object, '[0][1]', 'a', Object); - * // => { '0': { '1': 'a' } } + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. */ - function setWith(object, path, value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return object == null ? object : baseSet(object, path, value, customizer); + function shortOut(func) { + var count = 0, + lastCalled = 0; + + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; } /** - * Creates an array of own enumerable string keyed-value pairs for `object` - * which can be consumed by `_.fromPairs`. If `object` is a map or set, its - * entries are returned. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias entries - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the key-value pairs. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * A specialized version of `_.shuffle` which mutates and sets the size of `array`. * - * _.toPairs(new Foo); - * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) + * @private + * @param {Array} array The array to shuffle. + * @param {number} [size=array.length] The size of `array`. + * @returns {Array} Returns `array`. */ - var toPairs = createToPairs(keys); + function shuffleSelf(array, size) { + var index = -1, + length = array.length, + lastIndex = length - 1; + + size = size === undefined ? length : size; + while (++index < size) { + var rand = baseRandom(index, lastIndex), + value = array[rand]; + + array[rand] = array[index]; + array[index] = value; + } + array.length = size; + return array; + } /** - * Creates an array of own and inherited enumerable string keyed-value pairs - * for `object` which can be consumed by `_.fromPairs`. If `object` is a map - * or set, its entries are returned. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias entriesIn - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the key-value pairs. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } + * Converts `string` to a property path array. * - * Foo.prototype.c = 3; + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ + var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; + }); + + /** + * Converts `value` to a string key if it's not a string or symbol. * - * _.toPairsIn(new Foo); - * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. */ - var toPairsIn = createToPairs(keysIn); + function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + } /** - * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable string keyed properties thru `iteratee`, with each invocation - * potentially mutating the `accumulator` object. If `accumulator` is not - * provided, a new object with the same `[[Prototype]]` will be used. The - * iteratee is invoked with four arguments: (accumulator, value, key, object). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 1.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @returns {*} Returns the accumulated value. - * @example - * - * _.transform([2, 3, 4], function(result, n) { - * result.push(n *= n); - * return n % 2 == 0; - * }, []); - * // => [4, 9] + * Converts `func` to its source code. * - * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. */ - function transform(object, iteratee, accumulator) { - var isArr = isArray(object), - isArrLike = isArr || isBuffer(object) || isTypedArray(object); + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; + } - iteratee = getIteratee(iteratee, 4); - if (accumulator == null) { - var Ctor = object && object.constructor; - if (isArrLike) { - accumulator = isArr ? new Ctor : []; - } - else if (isObject(object)) { - accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; - } - else { - accumulator = {}; + /** + * Updates wrapper `details` based on `bitmask` flags. + * + * @private + * @returns {Array} details The details to modify. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Array} Returns `details`. + */ + function updateWrapDetails(details, bitmask) { + arrayEach(wrapFlags, function(pair) { + var value = '_.' + pair[0]; + if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { + details.push(value); } - } - (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); }); - return accumulator; + return details.sort(); } /** - * Removes the property at `path` of `object`. + * Creates a clone of `wrapper`. * - * **Note:** This method mutates `object`. + * @private + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. + */ + function wrapperClone(wrapper) { + if (wrapper instanceof LazyWrapper) { + return wrapper.clone(); + } + var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); + result.__actions__ = copyArray(wrapper.__actions__); + result.__index__ = wrapper.__index__; + result.__values__ = wrapper.__values__; + return result; + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of elements split into groups the length of `size`. + * If `array` can't be split evenly, the final chunk will be the remaining + * elements. * * @static * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the new array of chunks. * @example * - * var object = { 'a': [{ 'b': { 'c': 7 } }] }; - * _.unset(object, 'a[0].b.c'); - * // => true - * - * console.log(object); - * // => { 'a': [{ 'b': {} }] }; - * - * _.unset(object, ['a', '0', 'b', 'c']); - * // => true + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] * - * console.log(object); - * // => { 'a': [{ 'b': {} }] }; + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] */ - function unset(object, path) { - return object == null ? true : baseUnset(object, path); + function chunk(array, size, guard) { + if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { + size = 1; + } else { + size = nativeMax(toInteger(size), 0); + } + var length = array == null ? 0 : array.length; + if (!length || size < 1) { + return []; + } + var index = 0, + resIndex = 0, + result = Array(nativeCeil(length / size)); + + while (index < length) { + result[resIndex++] = baseSlice(array, index, (index += size)); + } + return result; } /** - * This method is like `_.set` except that accepts `updater` to produce the - * value to set. Use `_.updateWith` to customize `path` creation. The `updater` - * is invoked with one argument: (value). - * - * **Note:** This method mutates `object`. + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. * * @static * @memberOf _ - * @since 4.6.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {Function} updater The function to produce the updated value. - * @returns {Object} Returns `object`. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. * @example * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.update(object, 'a[0].b.c', function(n) { return n * n; }); - * console.log(object.a[0].b.c); - * // => 9 - * - * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); - * console.log(object.x[0].y.z); - * // => 0 + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] */ - function update(object, path, updater) { - return object == null ? object : baseUpdate(object, path, castFunction(updater)); + function compact(array) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result[resIndex++] = value; + } + } + return result; } /** - * This method is like `_.update` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. + * Creates a new array concatenating `array` with any additional arrays + * and/or values. * * @static * @memberOf _ - * @since 4.6.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {Function} updater The function to produce the updated value. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. * @example * - * var object = {}; + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); * - * _.updateWith(object, '[0][1]', _.constant('a'), Object); - * // => { '0': { '1': 'a' } } + * console.log(other); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] */ - function updateWith(object, path, updater, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); + function concat() { + var length = arguments.length; + if (!length) { + return []; + } + var args = Array(length - 1), + array = arguments[0], + index = length; + + while (index--) { + args[index - 1] = arguments[index]; + } + return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); } /** - * Creates an array of the own enumerable string keyed property values of `object`. + * Creates an array of `array` values not included in the other given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. * - * **Note:** Non-object values are coerced to objects. + * **Note:** Unlike `_.pullAll`, this method returns a new array. * * @static - * @since 0.1.0 * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.without, _.xor * @example * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.values(new Foo); - * // => [1, 2] (iteration order is not guaranteed) - * - * _.values('hi'); - * // => ['h', 'i'] + * _.difference([2, 1], [2, 3]); + * // => [1] */ - function values(object) { - return object == null ? [] : baseValues(object, keys(object)); - } + var difference = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) + : []; + }); /** - * Creates an array of the own and inherited enumerable string keyed property - * values of `object`. + * This method is like `_.difference` except that it accepts `iteratee` which + * is invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). * - * **Note:** Non-object values are coerced to objects. + * **Note:** Unlike `_.pullAllBy`, this method returns a new array. * * @static * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. * @example * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2] * - * _.valuesIn(new Foo); - * // => [1, 2, 3] (iteration order is not guaranteed) + * // The `_.property` iteratee shorthand. + * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] */ - function valuesIn(object) { - return object == null ? [] : baseValues(object, keysIn(object)); - } - - /*------------------------------------------------------------------------*/ + var differenceBy = baseRest(function(array, values) { + var iteratee = last(values); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) + : []; + }); /** - * Clamps `number` within the inclusive `lower` and `upper` bounds. + * This method is like `_.difference` except that it accepts `comparator` + * which is invoked to compare elements of `array` to `values`. The order and + * references of result values are determined by the first array. The comparator + * is invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.pullAllWith`, this method returns a new array. * * @static * @memberOf _ * @since 4.0.0 - * @category Number - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. * @example * - * _.clamp(-10, -5, 5); - * // => -5 + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; * - * _.clamp(10, -5, 5); - * // => 5 + * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); + * // => [{ 'x': 2, 'y': 1 }] */ - function clamp(number, lower, upper) { - if (upper === undefined) { - upper = lower; - lower = undefined; - } - if (upper !== undefined) { - upper = toNumber(upper); - upper = upper === upper ? upper : 0; - } - if (lower !== undefined) { - lower = toNumber(lower); - lower = lower === lower ? lower : 0; + var differenceWith = baseRest(function(array, values) { + var comparator = last(values); + if (isArrayLikeObject(comparator)) { + comparator = undefined; } - return baseClamp(toNumber(number), lower, upper); - } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) + : []; + }); /** - * Checks if `n` is between `start` and up to, but not including, `end`. If - * `end` is not specified, it's set to `start` with `start` then set to `0`. - * If `start` is greater than `end` the params are swapped to support - * negative ranges. + * Creates a slice of `array` with `n` elements dropped from the beginning. * * @static * @memberOf _ - * @since 3.3.0 - * @category Number - * @param {number} number The number to check. - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - * @see _.range, _.rangeRight + * @since 0.5.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. * @example * - * _.inRange(3, 2, 4); - * // => true - * - * _.inRange(4, 8); - * // => true - * - * _.inRange(4, 2); - * // => false - * - * _.inRange(2, 2); - * // => false + * _.drop([1, 2, 3]); + * // => [2, 3] * - * _.inRange(1.2, 2); - * // => true + * _.drop([1, 2, 3], 2); + * // => [3] * - * _.inRange(5.2, 4); - * // => false + * _.drop([1, 2, 3], 5); + * // => [] * - * _.inRange(-3, -2, -6); - * // => true + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] */ - function inRange(number, start, end) { - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); + function drop(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } - number = toNumber(number); - return baseInRange(number, start, end); + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, n < 0 ? 0 : n, length); } /** - * Produces a random number between the inclusive `lower` and `upper` bounds. - * If only one argument is provided a number between `0` and the given number - * is returned. If `floating` is `true`, or either `lower` or `upper` are - * floats, a floating-point number is returned instead of an integer. - * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. + * Creates a slice of `array` with `n` elements dropped from the end. * * @static * @memberOf _ - * @since 0.7.0 - * @category Number - * @param {number} [lower=0] The lower bound. - * @param {number} [upper=1] The upper bound. - * @param {boolean} [floating] Specify returning a floating-point number. - * @returns {number} Returns the random number. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. * @example * - * _.random(0, 5); - * // => an integer between 0 and 5 + * _.dropRight([1, 2, 3]); + * // => [1, 2] * - * _.random(5); - * // => also an integer between 0 and 5 + * _.dropRight([1, 2, 3], 2); + * // => [1] * - * _.random(5, true); - * // => a floating-point number between 0 and 5 + * _.dropRight([1, 2, 3], 5); + * // => [] * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(lower, upper, floating) { - if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { - upper = floating = undefined; - } - if (floating === undefined) { - if (typeof upper == 'boolean') { - floating = upper; - upper = undefined; - } - else if (typeof lower == 'boolean') { - floating = lower; - lower = undefined; - } - } - if (lower === undefined && upper === undefined) { - lower = 0; - upper = 1; - } - else { - lower = toFinite(lower); - if (upper === undefined) { - upper = lower; - lower = 0; - } else { - upper = toFinite(upper); - } - } - if (lower > upper) { - var temp = lower; - lower = upper; - upper = temp; - } - if (floating || lower % 1 || upper % 1) { - var rand = nativeRandom(); - return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function dropRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } - return baseRandom(lower, upper); + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, 0, n < 0 ? 0 : n); } - /*------------------------------------------------------------------------*/ - /** - * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). * * @static * @memberOf _ * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the camel cased string. + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. * @example * - * _.camelCase('Foo Bar'); - * // => 'fooBar' + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; * - * _.camelCase('--foo-bar--'); - * // => 'fooBar' + * _.dropRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney'] * - * _.camelCase('__FOO_BAR__'); - * // => 'fooBar' + * // The `_.matches` iteratee shorthand. + * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropRightWhile(users, ['active', false]); + * // => objects for ['barney'] + * + * // The `_.property` iteratee shorthand. + * _.dropRightWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] */ - var camelCase = createCompounder(function(result, word, index) { - word = word.toLowerCase(); - return result + (index ? capitalize(word) : word); - }); + function dropRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true, true) + : []; + } /** - * Converts the first character of `string` to upper case and the remaining - * to lower case. + * Creates a slice of `array` excluding elements dropped from the beginning. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). * * @static * @memberOf _ * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to capitalize. - * @returns {string} Returns the capitalized string. + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. * @example * - * _.capitalize('FRED'); - * // => 'Fred' + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.dropWhile(users, function(o) { return !o.active; }); + * // => objects for ['pebbles'] + * + * // The `_.matches` iteratee shorthand. + * _.dropWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropWhile(users, ['active', false]); + * // => objects for ['pebbles'] + * + * // The `_.property` iteratee shorthand. + * _.dropWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] */ - function capitalize(string) { - return upperFirst(toString(string).toLowerCase()); + function dropWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true) + : []; } /** - * Deburrs `string` by converting - * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) - * letters to basic Latin letters and removing - * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + * Fills elements of `array` with `value` from `start` up to, but not + * including, `end`. + * + * **Note:** This method mutates `array`. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to deburr. - * @returns {string} Returns the deburred string. + * @since 3.2.0 + * @category Array + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. * @example * - * _.deburr('déjà vu'); - * // => 'deja vu' + * var array = [1, 2, 3]; + * + * _.fill(array, 'a'); + * console.log(array); + * // => ['a', 'a', 'a'] + * + * _.fill(Array(3), 2); + * // => [2, 2, 2] + * + * _.fill([4, 6, 8, 10], '*', 1, 3); + * // => [4, '*', '*', 10] */ - function deburr(string) { - string = toString(string); - return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); + function fill(array, value, start, end) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); } /** - * Checks if `string` ends with the given target string. + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=string.length] The position to search up to. - * @returns {boolean} Returns `true` if `string` ends with `target`, - * else `false`. + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. * @example * - * _.endsWith('abc', 'c'); - * // => true + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; * - * _.endsWith('abc', 'b'); - * // => false + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 * - * _.endsWith('abc', 'b', 2); - * // => true + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 */ - function endsWith(string, target, position) { - string = toString(string); - target = baseToString(target); - - var length = string.length; - position = position === undefined - ? length - : baseClamp(toInteger(position), 0, length); - - var end = position; - position -= target.length; - return position >= 0 && string.slice(position, end) == target; + function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseFindIndex(array, getIteratee(predicate, 3), index); } /** - * Converts the characters "&", "<", ">", '"', and "'" in `string` to their - * corresponding HTML entities. + * This method is like `_.findIndex` except that it iterates over elements + * of `collection` from right to left. * - * **Note:** No other characters are escaped. To escape additional - * characters use a third-party library like [_he_](https://mths.be/he). + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example * - * Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. See - * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; * - * When working with HTML you should always - * [quote attribute values](http://wonko.com/post/html-escaping) to reduce - * XSS vectors. + * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); + * // => 2 + * + * // The `_.matches` iteratee shorthand. + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); + * // => 0 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastIndex(users, ['active', false]); + * // => 2 + * + * // The `_.property` iteratee shorthand. + * _.findLastIndex(users, 'active'); + * // => 0 + */ + function findLastIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length - 1; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = fromIndex < 0 + ? nativeMax(length + index, 0) + : nativeMin(index, length - 1); + } + return baseFindIndex(array, getIteratee(predicate, 3), index, true); + } + + /** + * Flattens `array` a single level deep. * * @static - * @since 0.1.0 * @memberOf _ - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. * @example * - * _.escape('fred, barney, & pebbles'); - * // => 'fred, barney, & pebbles' + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] */ - function escape(string) { - string = toString(string); - return (string && reHasUnescapedHtml.test(string)) - ? string.replace(reUnescapedHtml, escapeHtmlChar) - : string; + function flatten(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, 1) : []; } /** - * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", - * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. + * Recursively flattens `array`. * * @static * @memberOf _ * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. * @example * - * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https://lodash\.com/\)' + * _.flattenDeep([1, [2, [3, [4]], 5]]); + * // => [1, 2, 3, 4, 5] */ - function escapeRegExp(string) { - string = toString(string); - return (string && reHasRegExpChar.test(string)) - ? string.replace(reRegExpChar, '\\$&') - : string; + function flattenDeep(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, INFINITY) : []; } /** - * Converts `string` to - * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * Recursively flatten `array` up to `depth` times. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the kebab cased string. + * @since 4.4.0 + * @category Array + * @param {Array} array The array to flatten. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. * @example * - * _.kebabCase('Foo Bar'); - * // => 'foo-bar' + * var array = [1, [2, [3, [4]], 5]]; * - * _.kebabCase('fooBar'); - * // => 'foo-bar' + * _.flattenDepth(array, 1); + * // => [1, 2, [3, [4]], 5] * - * _.kebabCase('__FOO_BAR__'); - * // => 'foo-bar' + * _.flattenDepth(array, 2); + * // => [1, 2, 3, [4], 5] */ - var kebabCase = createCompounder(function(result, word, index) { - return result + (index ? '-' : '') + word.toLowerCase(); - }); + function flattenDepth(array, depth) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(array, depth); + } /** - * Converts `string`, as space separated words, to lower case. + * The inverse of `_.toPairs`; this method returns an object composed + * from key-value `pairs`. * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the lower cased string. + * @category Array + * @param {Array} pairs The key-value pairs. + * @returns {Object} Returns the new object. * @example * - * _.lowerCase('--Foo-Bar--'); - * // => 'foo bar' - * - * _.lowerCase('fooBar'); - * // => 'foo bar' - * - * _.lowerCase('__FOO_BAR__'); - * // => 'foo bar' + * _.fromPairs([['a', 1], ['b', 2]]); + * // => { 'a': 1, 'b': 2 } */ - var lowerCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + word.toLowerCase(); - }); + function fromPairs(pairs) { + var index = -1, + length = pairs == null ? 0 : pairs.length, + result = {}; + + while (++index < length) { + var pair = pairs[index]; + result[pair[0]] = pair[1]; + } + return result; + } /** - * Converts the first character of `string` to lower case. + * Gets the first element of `array`. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. + * @since 0.1.0 + * @alias first + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the first element of `array`. * @example * - * _.lowerFirst('Fred'); - * // => 'fred' + * _.head([1, 2, 3]); + * // => 1 * - * _.lowerFirst('FRED'); - * // => 'fRED' + * _.head([]); + * // => undefined */ - var lowerFirst = createCaseFirst('toLowerCase'); + function head(array) { + return (array && array.length) ? array[0] : undefined; + } /** - * Pads `string` on the left and right sides if it's shorter than `length`. - * Padding characters are truncated if they can't be evenly divided by `length`. + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it's used as the + * offset from the end of `array`. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.pad('abc', 8); - * // => ' abc ' - * - * _.pad('abc', 8, '_-'); - * // => '_-abc_-_' + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 * - * _.pad('abc', 3); - * // => 'abc' + * // Search from the `fromIndex`. + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 */ - function pad(string, length, chars) { - string = toString(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - if (!length || strLength >= length) { - return string; + function indexOf(array, value, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; } - var mid = (length - strLength) / 2; - return ( - createPadding(nativeFloor(mid), chars) + - string + - createPadding(nativeCeil(mid), chars) - ); + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseIndexOf(array, value, index); } /** - * Pads `string` on the right side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. + * Gets all but the last element of `array`. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. * @example * - * _.padEnd('abc', 6); - * // => 'abc ' - * - * _.padEnd('abc', 6, '_-'); - * // => 'abc_-_' - * - * _.padEnd('abc', 3); - * // => 'abc' + * _.initial([1, 2, 3]); + * // => [1, 2] */ - function padEnd(string, length, chars) { - string = toString(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - return (length && strLength < length) - ? (string + createPadding(length - strLength, chars)) - : string; + function initial(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 0, -1) : []; } /** - * Pads `string` on the left side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. + * Creates an array of unique values that are included in all given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of intersecting values. * @example * - * _.padStart('abc', 6); - * // => ' abc' + * _.intersection([2, 1], [2, 3]); + * // => [2] + */ + var intersection = baseRest(function(arrays) { + var mapped = arrayMap(arrays, castArrayLikeObject); + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped) + : []; + }); + + /** + * This method is like `_.intersection` except that it accepts `iteratee` + * which is invoked for each element of each `arrays` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of intersecting values. + * @example * - * _.padStart('abc', 6, '_-'); - * // => '_-_abc' + * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [2.1] * - * _.padStart('abc', 3); - * // => 'abc' + * // The `_.property` iteratee shorthand. + * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }] */ - function padStart(string, length, chars) { - string = toString(string); - length = toInteger(length); + var intersectionBy = baseRest(function(arrays) { + var iteratee = last(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); - var strLength = length ? stringSize(string) : 0; - return (length && strLength < length) - ? (createPadding(length - strLength, chars) + string) - : string; - } + if (iteratee === last(mapped)) { + iteratee = undefined; + } else { + mapped.pop(); + } + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, getIteratee(iteratee, 2)) + : []; + }); /** - * Converts `string` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `value` is a - * hexadecimal, in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the - * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. + * This method is like `_.intersection` except that it accepts `comparator` + * which is invoked to compare elements of `arrays`. The order and references + * of result values are determined by the first array. The comparator is + * invoked with two arguments: (arrVal, othVal). * * @static * @memberOf _ - * @since 1.1.0 - * @category String - * @param {string} string The string to convert. - * @param {number} [radix=10] The radix to interpret `value` by. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {number} Returns the converted integer. + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of intersecting values. * @example * - * _.parseInt('08'); - * // => 8 + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; * - * _.map(['6', '08', '10'], _.parseInt); - * // => [6, 8, 10] + * _.intersectionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }] */ - function parseInt(string, radix, guard) { - if (guard || radix == null) { - radix = 0; - } else if (radix) { - radix = +radix; + var intersectionWith = baseRest(function(arrays) { + var comparator = last(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); + + comparator = typeof comparator == 'function' ? comparator : undefined; + if (comparator) { + mapped.pop(); } - return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); - } + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, undefined, comparator) + : []; + }); /** - * Repeats the given string `n` times. + * Converts all elements in `array` into a string separated by `separator`. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to repeat. - * @param {number} [n=1] The number of times to repeat the string. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the repeated string. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to convert. + * @param {string} [separator=','] The element separator. + * @returns {string} Returns the joined string. * @example * - * _.repeat('*', 3); - * // => '***' - * - * _.repeat('abc', 2); - * // => 'abcabc' - * - * _.repeat('abc', 0); - * // => '' + * _.join(['a', 'b', 'c'], '~'); + * // => 'a~b~c' */ - function repeat(string, n, guard) { - if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { - n = 1; - } else { - n = toInteger(n); - } - return baseRepeat(toString(string), n); + function join(array, separator) { + return array == null ? '' : nativeJoin.call(array, separator); } /** - * Replaces matches for `pattern` in `string` with `replacement`. - * - * **Note:** This method is based on - * [`String#replace`](https://mdn.io/String/replace). + * Gets the last element of `array`. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to modify. - * @param {RegExp|string} pattern The pattern to replace. - * @param {Function|string} replacement The match replacement. - * @returns {string} Returns the modified string. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. * @example * - * _.replace('Hi Fred', 'Fred', 'Barney'); - * // => 'Hi Barney' + * _.last([1, 2, 3]); + * // => 3 */ - function replace() { - var args = arguments, - string = toString(args[0]); - - return args.length < 3 ? string : string.replace(args[1], args[2]); + function last(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; } /** - * Converts `string` to - * [snake case](https://en.wikipedia.org/wiki/Snake_case). + * This method is like `_.indexOf` except that it iterates over elements of + * `array` from right to left. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the snake cased string. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.snakeCase('Foo Bar'); - * // => 'foo_bar' - * - * _.snakeCase('fooBar'); - * // => 'foo_bar' + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 * - * _.snakeCase('--FOO-BAR--'); - * // => 'foo_bar' + * // Search from the `fromIndex`. + * _.lastIndexOf([1, 2, 1, 2], 2, 2); + * // => 1 */ - var snakeCase = createCompounder(function(result, word, index) { - return result + (index ? '_' : '') + word.toLowerCase(); - }); + function lastIndexOf(array, value, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); + } + return value === value + ? strictLastIndexOf(array, value, index) + : baseFindIndex(array, baseIsNaN, index, true); + } /** - * Splits `string` by `separator`. - * - * **Note:** This method is based on - * [`String#split`](https://mdn.io/String/split). + * Gets the element at index `n` of `array`. If `n` is negative, the nth + * element from the end is returned. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to split. - * @param {RegExp|string} separator The separator pattern to split by. - * @param {number} [limit] The length to truncate results to. - * @returns {Array} Returns the string segments. + * @since 4.11.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=0] The index of the element to return. + * @returns {*} Returns the nth element of `array`. * @example * - * _.split('a-b-c', '-', 2); - * // => ['a', 'b'] + * var array = ['a', 'b', 'c', 'd']; + * + * _.nth(array, 1); + * // => 'b' + * + * _.nth(array, -2); + * // => 'c'; */ - function split(string, separator, limit) { - if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { - separator = limit = undefined; - } - limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; - if (!limit) { - return []; - } - string = toString(string); - if (string && ( - typeof separator == 'string' || - (separator != null && !isRegExp(separator)) - )) { - separator = baseToString(separator); - if (!separator && hasUnicode(string)) { - return castSlice(stringToArray(string), 0, limit); - } - } - return string.split(separator, limit); + function nth(array, n) { + return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; } /** - * Converts `string` to - * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * Removes all given values from `array` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` + * to remove elements from an array by predicate. * * @static * @memberOf _ - * @since 3.1.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the start cased string. + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...*} [values] The values to remove. + * @returns {Array} Returns `array`. * @example * - * _.startCase('--foo-bar--'); - * // => 'Foo Bar' - * - * _.startCase('fooBar'); - * // => 'Foo Bar' + * var array = ['a', 'b', 'c', 'a', 'b', 'c']; * - * _.startCase('__FOO_BAR__'); - * // => 'FOO BAR' + * _.pull(array, 'a', 'c'); + * console.log(array); + * // => ['b', 'b'] */ - var startCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + upperFirst(word); - }); + var pull = baseRest(pullAll); /** - * Checks if `string` starts with the given target string. + * This method is like `_.pull` except that it accepts an array of values to remove. + * + * **Note:** Unlike `_.difference`, this method mutates `array`. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, - * else `false`. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @returns {Array} Returns `array`. * @example * - * _.startsWith('abc', 'a'); - * // => true - * - * _.startsWith('abc', 'b'); - * // => false + * var array = ['a', 'b', 'c', 'a', 'b', 'c']; * - * _.startsWith('abc', 'b', 1); - * // => true + * _.pullAll(array, ['a', 'c']); + * console.log(array); + * // => ['b', 'b'] */ - function startsWith(string, target, position) { - string = toString(string); - position = position == null - ? 0 - : baseClamp(toInteger(position), 0, string.length); - - target = baseToString(target); - return string.slice(position, position + target.length) == target; + function pullAll(array, values) { + return (array && array.length && values && values.length) + ? basePullAll(array, values) + : array; } /** - * Creates a compiled template function that can interpolate data properties - * in "interpolate" delimiters, HTML-escape interpolated data properties in - * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data - * properties may be accessed as free variables in the template. If a setting - * object is given, it takes precedence over `_.templateSettings` values. - * - * **Note:** In the development build `_.template` utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for easier debugging. - * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * This method is like `_.pullAll` except that it accepts `iteratee` which is + * invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The iteratee is invoked with one argument: (value). * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * **Note:** Unlike `_.differenceBy`, this method mutates `array`. * * @static - * @since 0.1.0 * @memberOf _ - * @category String - * @param {string} [string=''] The template string. - * @param {Object} [options={}] The options object. - * @param {RegExp} [options.escape=_.templateSettings.escape] - * The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] - * The "evaluate" delimiter. - * @param {Object} [options.imports=_.templateSettings.imports] - * An object to import into the template as free variables. - * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] - * The "interpolate" delimiter. - * @param {string} [options.sourceURL='lodash.templateSources[n]'] - * The sourceURL of the compiled template. - * @param {string} [options.variable='obj'] - * The data object variable name. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the compiled template function. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns `array`. * @example * - * // Use the "interpolate" delimiter to create a compiled template. - * var compiled = _.template('hello <%= user %>!'); - * compiled({ 'user': 'fred' }); - * // => 'hello fred!' + * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; * - * // Use the HTML "escape" delimiter to escape data property values. - * var compiled = _.template('<b><%- value %></b>'); - * compiled({ 'value': '<script>' }); - * // => '<b><script></b>' + * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); + * console.log(array); + * // => [{ 'x': 2 }] + */ + function pullAllBy(array, values, iteratee) { + return (array && array.length && values && values.length) + ? basePullAll(array, values, getIteratee(iteratee, 2)) + : array; + } + + /** + * This method is like `_.pullAll` except that it accepts `comparator` which + * is invoked to compare elements of `array` to `values`. The comparator is + * invoked with two arguments: (arrVal, othVal). * - * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. - * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); - * compiled({ 'users': ['fred', 'barney'] }); - * // => '<li>fred</li><li>barney</li>' + * **Note:** Unlike `_.differenceWith`, this method mutates `array`. * - * // Use the internal `print` function in "evaluate" delimiters. - * var compiled = _.template('<% print("hello " + user); %>!'); - * compiled({ 'user': 'barney' }); - * // => 'hello barney!' + * @static + * @memberOf _ + * @since 4.6.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + * @example * - * // Use the ES template literal delimiter as an "interpolate" delimiter. - * // Disable support by replacing the "interpolate" delimiter. - * var compiled = _.template('hello ${ user }!'); - * compiled({ 'user': 'pebbles' }); - * // => 'hello pebbles!' + * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; * - * // Use backslashes to treat delimiters as plain text. - * var compiled = _.template('<%= "\\<%- value %\\>" %>'); - * compiled({ 'value': 'ignored' }); - * // => '<%- value %>' + * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); + * console.log(array); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] + */ + function pullAllWith(array, values, comparator) { + return (array && array.length && values && values.length) + ? basePullAll(array, values, undefined, comparator) + : array; + } + + /** + * Removes elements from `array` corresponding to `indexes` and returns an + * array of removed elements. * - * // Use the `imports` option to import `jQuery` as `jq`. - * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; - * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); - * compiled({ 'users': ['fred', 'barney'] }); - * // => '<li>fred</li><li>barney</li>' + * **Note:** Unlike `_.at`, this method mutates `array`. * - * // Use the `sourceURL` option to specify a custom sourceURL for the template. - * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); - * compiled(data); - * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...(number|number[])} [indexes] The indexes of elements to remove. + * @returns {Array} Returns the new array of removed elements. + * @example * - * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. - * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); - * compiled.source; - * // => function(data) { - * // var __t, __p = ''; - * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; - * // return __p; - * // } + * var array = ['a', 'b', 'c', 'd']; + * var pulled = _.pullAt(array, [1, 3]); * - * // Use custom template delimiters. - * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; - * var compiled = _.template('hello {{ user }}!'); - * compiled({ 'user': 'mustache' }); - * // => 'hello mustache!' + * console.log(array); + * // => ['a', 'c'] * - * // Use the `source` property to inline compiled templates for meaningful - * // line numbers in error messages and stack traces. - * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ - * var JST = {\ - * "main": ' + _.template(mainText).source + '\ - * };\ - * '); - */ - function template(string, options, guard) { - // Based on John Resig's `tmpl` implementation - // (http://ejohn.org/blog/javascript-micro-templating/) - // and Laura Doktorova's doT.js (https://github.com/olado/doT). - var settings = lodash.templateSettings; - - if (guard && isIterateeCall(string, options, guard)) { - options = undefined; - } - string = toString(string); - options = assignInWith({}, options, settings, customDefaultsAssignIn); - - var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), - importsKeys = keys(imports), - importsValues = baseValues(imports, importsKeys); - - var isEscaping, - isEvaluating, - index = 0, - interpolate = options.interpolate || reNoMatch, - source = "__p += '"; - - // Compile the regexp to match each delimiter. - var reDelimiters = RegExp( - (options.escape || reNoMatch).source + '|' + - interpolate.source + '|' + - (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + - (options.evaluate || reNoMatch).source + '|$' - , 'g'); - - // Use a sourceURL for easier debugging. - var sourceURL = '//# sourceURL=' + - ('sourceURL' in options - ? options.sourceURL - : ('lodash.templateSources[' + (++templateCounter) + ']') - ) + '\n'; - - string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { - interpolateValue || (interpolateValue = esTemplateValue); - - // Escape characters that can't be included in string literals. - source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); - - // Replace delimiters with snippets. - if (escapeValue) { - isEscaping = true; - source += "' +\n__e(" + escapeValue + ") +\n'"; - } - if (evaluateValue) { - isEvaluating = true; - source += "';\n" + evaluateValue + ";\n__p += '"; - } - if (interpolateValue) { - source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; - } - index = offset + match.length; + * console.log(pulled); + * // => ['b', 'd'] + */ + var pullAt = flatRest(function(array, indexes) { + var length = array == null ? 0 : array.length, + result = baseAt(array, indexes); - // The JS engine embedded in Adobe products needs `match` returned in - // order to produce the correct `offset` value. - return match; - }); + basePullAt(array, arrayMap(indexes, function(index) { + return isIndex(index, length) ? +index : index; + }).sort(compareAscending)); - source += "';\n"; + return result; + }); - // If `variable` is not specified wrap a with-statement around the generated - // code to add the data object to the top of the scope chain. - var variable = options.variable; - if (!variable) { - source = 'with (obj) {\n' + source + '\n}\n'; + /** + * Removes all elements from `array` that `predicate` returns truthy for + * and returns an array of the removed elements. The predicate is invoked + * with three arguments: (value, index, array). + * + * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` + * to pull elements from an array by value. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4]; + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); + * + * console.log(array); + * // => [1, 3] + * + * console.log(evens); + * // => [2, 4] + */ + function remove(array, predicate) { + var result = []; + if (!(array && array.length)) { + return result; } - // Cleanup code by stripping empty strings. - source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) - .replace(reEmptyStringMiddle, '$1') - .replace(reEmptyStringTrailing, '$1;'); - - // Frame code as the function body. - source = 'function(' + (variable || 'obj') + ') {\n' + - (variable - ? '' - : 'obj || (obj = {});\n' - ) + - "var __t, __p = ''" + - (isEscaping - ? ', __e = _.escape' - : '' - ) + - (isEvaluating - ? ', __j = Array.prototype.join;\n' + - "function print() { __p += __j.call(arguments, '') }\n" - : ';\n' - ) + - source + - 'return __p\n}'; - - var result = attempt(function() { - return Function(importsKeys, sourceURL + 'return ' + source) - .apply(undefined, importsValues); - }); + var index = -1, + indexes = [], + length = array.length; - // Provide the compiled function's source by its `toString` method or - // the `source` property as a convenience for inlining compiled templates. - result.source = source; - if (isError(result)) { - throw result; + predicate = getIteratee(predicate, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } } + basePullAt(array, indexes); return result; } /** - * Converts `string`, as a whole, to lower case just like - * [String#toLowerCase](https://mdn.io/toLowerCase). + * Reverses `array` so that the first element becomes the last, the second + * element becomes the second to last, and so on. + * + * **Note:** This method mutates `array` and is based on + * [`Array#reverse`](https://mdn.io/Array/reverse). * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the lower cased string. + * @category Array + * @param {Array} array The array to modify. + * @returns {Array} Returns `array`. * @example * - * _.toLower('--Foo-Bar--'); - * // => '--foo-bar--' + * var array = [1, 2, 3]; * - * _.toLower('fooBar'); - * // => 'foobar' + * _.reverse(array); + * // => [3, 2, 1] * - * _.toLower('__FOO_BAR__'); - * // => '__foo_bar__' + * console.log(array); + * // => [3, 2, 1] */ - function toLower(value) { - return toString(value).toLowerCase(); + function reverse(array) { + return array == null ? array : nativeReverse.call(array); } /** - * Converts `string`, as a whole, to upper case just like - * [String#toUpperCase](https://mdn.io/toUpperCase). + * Creates a slice of `array` from `start` up to, but not including, `end`. + * + * **Note:** This method is used instead of + * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are + * returned. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the upper cased string. - * @example - * - * _.toUpper('--foo-bar--'); - * // => '--FOO-BAR--' + * @since 3.0.0 + * @category Array + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function slice(array, start, end) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + else { + start = start == null ? 0 : toInteger(start); + end = end === undefined ? length : toInteger(end); + } + return baseSlice(array, start, end); + } + + /** + * Uses a binary search to determine the lowest index at which `value` + * should be inserted into `array` in order to maintain its sort order. * - * _.toUpper('fooBar'); - * // => 'FOOBAR' + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example * - * _.toUpper('__foo_bar__'); - * // => '__FOO_BAR__' + * _.sortedIndex([30, 50], 40); + * // => 1 */ - function toUpper(value) { - return toString(value).toUpperCase(); + function sortedIndex(array, value) { + return baseSortedIndex(array, value); } /** - * Removes leading and trailing whitespace or specified characters from `string`. + * This method is like `_.sortedIndex` except that it accepts `iteratee` + * which is invoked for `value` and each element of `array` to compute their + * sort ranking. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the trimmed string. + * @since 4.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * - * _.trim(' abc '); - * // => 'abc' + * var objects = [{ 'x': 4 }, { 'x': 5 }]; * - * _.trim('-_-abc-_-', '_-'); - * // => 'abc' + * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); + * // => 0 * - * _.map([' foo ', ' bar '], _.trim); - * // => ['foo', 'bar'] + * // The `_.property` iteratee shorthand. + * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); + * // => 0 */ - function trim(string, chars, guard) { - string = toString(string); - if (string && (guard || chars === undefined)) { - return string.replace(reTrim, ''); - } - if (!string || !(chars = baseToString(chars))) { - return string; - } - var strSymbols = stringToArray(string), - chrSymbols = stringToArray(chars), - start = charsStartIndex(strSymbols, chrSymbols), - end = charsEndIndex(strSymbols, chrSymbols) + 1; - - return castSlice(strSymbols, start, end).join(''); + function sortedIndexBy(array, value, iteratee) { + return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); } /** - * Removes trailing whitespace or specified characters from `string`. + * This method is like `_.indexOf` except that it performs a binary + * search on a sorted `array`. * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the trimmed string. + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.trimEnd(' abc '); - * // => ' abc' - * - * _.trimEnd('-_-abc-_-', '_-'); - * // => '-_-abc' + * _.sortedIndexOf([4, 5, 5, 5, 6], 5); + * // => 1 */ - function trimEnd(string, chars, guard) { - string = toString(string); - if (string && (guard || chars === undefined)) { - return string.replace(reTrimEnd, ''); - } - if (!string || !(chars = baseToString(chars))) { - return string; + function sortedIndexOf(array, value) { + var length = array == null ? 0 : array.length; + if (length) { + var index = baseSortedIndex(array, value); + if (index < length && eq(array[index], value)) { + return index; + } } - var strSymbols = stringToArray(string), - end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; - - return castSlice(strSymbols, 0, end).join(''); + return -1; } /** - * Removes leading whitespace or specified characters from `string`. + * This method is like `_.sortedIndex` except that it returns the highest + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the trimmed string. + * @since 3.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * - * _.trimStart(' abc '); - * // => 'abc ' - * - * _.trimStart('-_-abc-_-', '_-'); - * // => 'abc-_-' + * _.sortedLastIndex([4, 5, 5, 5, 6], 5); + * // => 4 */ - function trimStart(string, chars, guard) { - string = toString(string); - if (string && (guard || chars === undefined)) { - return string.replace(reTrimStart, ''); - } - if (!string || !(chars = baseToString(chars))) { - return string; - } - var strSymbols = stringToArray(string), - start = charsStartIndex(strSymbols, stringToArray(chars)); - - return castSlice(strSymbols, start).join(''); + function sortedLastIndex(array, value) { + return baseSortedIndex(array, value, true); } /** - * Truncates `string` if it's longer than the given maximum string length. - * The last characters of the truncated string are replaced with the omission - * string which defaults to "...". + * This method is like `_.sortedLastIndex` except that it accepts `iteratee` + * which is invoked for `value` and each element of `array` to compute their + * sort ranking. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to truncate. - * @param {Object} [options={}] The options object. - * @param {number} [options.length=30] The maximum string length. - * @param {string} [options.omission='...'] The string to indicate text is omitted. - * @param {RegExp|string} [options.separator] The separator pattern to truncate to. - * @returns {string} Returns the truncated string. + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. * @example * - * _.truncate('hi-diddly-ho there, neighborino'); - * // => 'hi-diddly-ho there, neighbo...' - * - * _.truncate('hi-diddly-ho there, neighborino', { - * 'length': 24, - * 'separator': ' ' - * }); - * // => 'hi-diddly-ho there,...' + * var objects = [{ 'x': 4 }, { 'x': 5 }]; * - * _.truncate('hi-diddly-ho there, neighborino', { - * 'length': 24, - * 'separator': /,? +/ - * }); - * // => 'hi-diddly-ho there...' + * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); + * // => 1 * - * _.truncate('hi-diddly-ho there, neighborino', { - * 'omission': ' [...]' - * }); - * // => 'hi-diddly-ho there, neig [...]' + * // The `_.property` iteratee shorthand. + * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); + * // => 1 */ - function truncate(string, options) { - var length = DEFAULT_TRUNC_LENGTH, - omission = DEFAULT_TRUNC_OMISSION; - - if (isObject(options)) { - var separator = 'separator' in options ? options.separator : separator; - length = 'length' in options ? toInteger(options.length) : length; - omission = 'omission' in options ? baseToString(options.omission) : omission; - } - string = toString(string); - - var strLength = string.length; - if (hasUnicode(string)) { - var strSymbols = stringToArray(string); - strLength = strSymbols.length; - } - if (length >= strLength) { - return string; - } - var end = length - stringSize(omission); - if (end < 1) { - return omission; - } - var result = strSymbols - ? castSlice(strSymbols, 0, end).join('') - : string.slice(0, end); - - if (separator === undefined) { - return result + omission; - } - if (strSymbols) { - end += (result.length - end); - } - if (isRegExp(separator)) { - if (string.slice(end).search(separator)) { - var match, - substring = result; - - if (!separator.global) { - separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); - } - separator.lastIndex = 0; - while ((match = separator.exec(substring))) { - var newEnd = match.index; - } - result = result.slice(0, newEnd === undefined ? end : newEnd); - } - } else if (string.indexOf(baseToString(separator), end) != end) { - var index = result.lastIndexOf(separator); - if (index > -1) { - result = result.slice(0, index); - } - } - return result + omission; + function sortedLastIndexBy(array, value, iteratee) { + return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); } /** - * The inverse of `_.escape`; this method converts the HTML entities - * `&`, `<`, `>`, `"`, and `'` in `string` to - * their corresponding characters. - * - * **Note:** No other HTML entities are unescaped. To unescape additional - * HTML entities use a third-party library like [_he_](https://mths.be/he). + * This method is like `_.lastIndexOf` except that it performs a binary + * search on a sorted `array`. * * @static * @memberOf _ - * @since 0.6.0 - * @category String - * @param {string} [string=''] The string to unescape. - * @returns {string} Returns the unescaped string. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.unescape('fred, barney, & pebbles'); - * // => 'fred, barney, & pebbles' + * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); + * // => 3 */ - function unescape(string) { - string = toString(string); - return (string && reHasEscapedHtml.test(string)) - ? string.replace(reEscapedHtml, unescapeHtmlChar) - : string; + function sortedLastIndexOf(array, value) { + var length = array == null ? 0 : array.length; + if (length) { + var index = baseSortedIndex(array, value, true) - 1; + if (eq(array[index], value)) { + return index; + } + } + return -1; } /** - * Converts `string`, as space separated words, to upper case. + * This method is like `_.uniq` except that it's designed and optimized + * for sorted arrays. * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the upper cased string. + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. * @example * - * _.upperCase('--foo-bar'); - * // => 'FOO BAR' - * - * _.upperCase('fooBar'); - * // => 'FOO BAR' - * - * _.upperCase('__foo_bar__'); - * // => 'FOO BAR' + * _.sortedUniq([1, 1, 2]); + * // => [1, 2] */ - var upperCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + word.toUpperCase(); - }); + function sortedUniq(array) { + return (array && array.length) + ? baseSortedUniq(array) + : []; + } /** - * Converts the first character of `string` to upper case. + * This method is like `_.uniqBy` except that it's designed and optimized + * for sorted arrays. * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. * @example * - * _.upperFirst('fred'); - * // => 'Fred' - * - * _.upperFirst('FRED'); - * // => 'FRED' + * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); + * // => [1.1, 2.3] */ - var upperFirst = createCaseFirst('toUpperCase'); + function sortedUniqBy(array, iteratee) { + return (array && array.length) + ? baseSortedUniq(array, getIteratee(iteratee, 2)) + : []; + } /** - * Splits `string` into an array of its words. + * Gets all but the first element of `array`. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {RegExp|string} [pattern] The pattern to match words. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the words of `string`. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. * @example * - * _.words('fred, barney, & pebbles'); - * // => ['fred', 'barney', 'pebbles'] - * - * _.words('fred, barney, & pebbles', /[^, ]+/g); - * // => ['fred', 'barney', '&', 'pebbles'] + * _.tail([1, 2, 3]); + * // => [2, 3] */ - function words(string, pattern, guard) { - string = toString(string); - pattern = guard ? undefined : pattern; - - if (pattern === undefined) { - return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); - } - return string.match(pattern) || []; + function tail(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 1, length) : []; } - /*------------------------------------------------------------------------*/ - /** - * Attempts to invoke `func`, returning either the result or the caught error - * object. Any additional arguments are provided to `func` when it's invoked. + * Creates a slice of `array` with `n` elements taken from the beginning. * * @static * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {Function} func The function to attempt. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {*} Returns the `func` result or error object. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. * @example * - * // Avoid throwing errors for invalid selectors. - * var elements = _.attempt(function(selector) { - * return document.querySelectorAll(selector); - * }, '>_>'); + * _.take([1, 2, 3]); + * // => [1] * - * if (_.isError(elements)) { - * elements = []; - * } + * _.take([1, 2, 3], 2); + * // => [1, 2] + * + * _.take([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.take([1, 2, 3], 0); + * // => [] */ - var attempt = baseRest(function(func, args) { - try { - return apply(func, undefined, args); - } catch (e) { - return isError(e) ? e : new Error(e); + function take(array, n, guard) { + if (!(array && array.length)) { + return []; } - }); + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, 0, n < 0 ? 0 : n); + } /** - * Binds methods of an object to the object itself, overwriting the existing - * method. - * - * **Note:** This method doesn't set the "length" property of bound functions. + * Creates a slice of `array` with `n` elements taken from the end. * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...(string|string[])} methodNames The object method names to bind. - * @returns {Object} Returns `object`. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. * @example * - * var view = { - * 'label': 'docs', - * 'click': function() { - * console.log('clicked ' + this.label); - * } - * }; + * _.takeRight([1, 2, 3]); + * // => [3] * - * _.bindAll(view, ['click']); - * jQuery(element).on('click', view.click); - * // => Logs 'clicked docs' when clicked. + * _.takeRight([1, 2, 3], 2); + * // => [2, 3] + * + * _.takeRight([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.takeRight([1, 2, 3], 0); + * // => [] */ - var bindAll = flatRest(function(object, methodNames) { - arrayEach(methodNames, function(key) { - key = toKey(key); - baseAssignValue(object, key, bind(object[key], object)); - }); - return object; - }); + function takeRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, n < 0 ? 0 : n, length); + } /** - * Creates a function that iterates over `pairs` and invokes the corresponding - * function of the first predicate to return truthy. The predicate-function - * pairs are invoked with the `this` binding and arguments of the created - * function. + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {Array} pairs The predicate-function pairs. - * @returns {Function} Returns the new composite function. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. * @example * - * var func = _.cond([ - * [_.matches({ 'a': 1 }), _.constant('matches A')], - * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], - * [_.stubTrue, _.constant('no match')] - * ]); + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; * - * func({ 'a': 1, 'b': 2 }); - * // => 'matches A' + * _.takeRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['fred', 'pebbles'] * - * func({ 'a': 0, 'b': 1 }); - * // => 'matches B' + * // The `_.matches` iteratee shorthand. + * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['pebbles'] * - * func({ 'a': '1', 'b': '2' }); - * // => 'no match' + * // The `_.matchesProperty` iteratee shorthand. + * _.takeRightWhile(users, ['active', false]); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.property` iteratee shorthand. + * _.takeRightWhile(users, 'active'); + * // => [] */ - function cond(pairs) { - var length = pairs == null ? 0 : pairs.length, - toIteratee = getIteratee(); - - pairs = !length ? [] : arrayMap(pairs, function(pair) { - if (typeof pair[1] != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - return [toIteratee(pair[0]), pair[1]]; - }); - - return baseRest(function(args) { - var index = -1; - while (++index < length) { - var pair = pairs[index]; - if (apply(pair[0], this, args)) { - return apply(pair[1], this, args); - } - } - }); + function takeRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), false, true) + : []; } /** - * Creates a function that invokes the predicate properties of `source` with - * the corresponding property values of a given object, returning `true` if - * all predicates return truthy, else `false`. - * - * **Note:** The created function is equivalent to `_.conformsTo` with - * `source` partially applied. + * Creates a slice of `array` with elements taken from the beginning. Elements + * are taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. * @example * - * var objects = [ - * { 'a': 2, 'b': 1 }, - * { 'a': 1, 'b': 2 } + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } * ]; * - * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); - * // => [{ 'a': 1, 'b': 2 }] + * _.takeWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matches` iteratee shorthand. + * _.takeWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.takeWhile(users, ['active', false]); + * // => objects for ['barney', 'fred'] + * + * // The `_.property` iteratee shorthand. + * _.takeWhile(users, 'active'); + * // => [] */ - function conforms(source) { - return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); + function takeWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3)) + : []; } /** - * Creates a function that returns `value`. + * Creates an array of unique values, in order, from all given arrays using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. * * @static * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new constant function. + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. * @example * - * var objects = _.times(2, _.constant({ 'a': 1 })); - * - * console.log(objects); - * // => [{ 'a': 1 }, { 'a': 1 }] - * - * console.log(objects[0] === objects[1]); - * // => true + * _.union([2], [1, 2]); + * // => [2, 1] */ - function constant(value) { - return function() { - return value; - }; - } + var union = baseRest(function(arrays) { + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); + }); /** - * Checks `value` to determine whether a default value should be returned in - * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, - * or `undefined`. + * This method is like `_.union` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which uniqueness is computed. Result values are chosen from the first + * array in which the value occurs. The iteratee is invoked with one argument: + * (value). * * @static * @memberOf _ - * @since 4.14.0 - * @category Util - * @param {*} value The value to check. - * @param {*} defaultValue The default value. - * @returns {*} Returns the resolved value. + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of combined values. * @example * - * _.defaultTo(1, 10); - * // => 1 + * _.unionBy([2.1], [1.2, 2.3], Math.floor); + * // => [2.1, 1.2] * - * _.defaultTo(undefined, 10); - * // => 10 + * // The `_.property` iteratee shorthand. + * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] */ - function defaultTo(value, defaultValue) { - return (value == null || value !== value) ? defaultValue : value; - } + var unionBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); + }); /** - * Creates a function that returns the result of invoking the given functions - * with the `this` binding of the created function, where each successive - * invocation is supplied the return value of the previous. + * This method is like `_.union` except that it accepts `comparator` which + * is invoked to compare elements of `arrays`. Result values are chosen from + * the first array in which the value occurs. The comparator is invoked + * with two arguments: (arrVal, othVal). * * @static * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {...(Function|Function[])} [funcs] The functions to invoke. - * @returns {Function} Returns the new composite function. - * @see _.flowRight + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of combined values. * @example * - * function square(n) { - * return n * n; - * } + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; * - * var addSquare = _.flow([_.add, square]); - * addSquare(1, 2); - * // => 9 + * _.unionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] */ - var flow = createFlow(); + var unionWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); + }); /** - * This method is like `_.flow` except that it creates a function that - * invokes the given functions from right to left. + * Creates a duplicate-free version of an array, using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons, in which only the first occurrence of each element + * is kept. The order of result values is determined by the order they occur + * in the array. * * @static - * @since 3.0.0 * @memberOf _ - * @category Util - * @param {...(Function|Function[])} [funcs] The functions to invoke. - * @returns {Function} Returns the new composite function. - * @see _.flow + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. * @example * - * function square(n) { - * return n * n; - * } - * - * var addSquare = _.flowRight([square, _.add]); - * addSquare(1, 2); - * // => 9 + * _.uniq([2, 1, 2]); + * // => [2, 1] */ - var flowRight = createFlow(true); + function uniq(array) { + return (array && array.length) ? baseUniq(array) : []; + } /** - * This method returns the first argument it receives. + * This method is like `_.uniq` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * uniqueness is computed. The order of result values is determined by the + * order they occur in the array. The iteratee is invoked with one argument: + * (value). * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. * @example * - * var object = { 'a': 1 }; + * _.uniqBy([2.1, 1.2, 2.3], Math.floor); + * // => [2.1, 1.2] * - * console.log(_.identity(object) === object); - * // => true + * // The `_.property` iteratee shorthand. + * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] */ - function identity(value) { - return value; + function uniqBy(array, iteratee) { + return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; } /** - * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name, the created function returns the - * property value for a given element. If `func` is an array or object, the - * created function returns `true` for elements that contain the equivalent - * source properties, otherwise it returns `false`. + * This method is like `_.uniq` except that it accepts `comparator` which + * is invoked to compare elements of `array`. The order of result values is + * determined by the order they occur in the array.The comparator is invoked + * with two arguments: (arrVal, othVal). * * @static - * @since 4.0.0 * @memberOf _ - * @category Util - * @param {*} [func=_.identity] The value to convert to a callback. - * @returns {Function} Returns the callback. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. * @example * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); - * // => [{ 'user': 'barney', 'age': 36, 'active': true }] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.filter(users, _.iteratee(['user', 'fred'])); - * // => [{ 'user': 'fred', 'age': 40 }] - * - * // The `_.property` iteratee shorthand. - * _.map(users, _.iteratee('user')); - * // => ['barney', 'fred'] - * - * // Create custom iteratee shorthands. - * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { - * return !_.isRegExp(func) ? iteratee(func) : function(string) { - * return func.test(string); - * }; - * }); + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; * - * _.filter(['abc', 'def'], /ef/); - * // => ['def'] + * _.uniqWith(objects, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] */ - function iteratee(func) { - return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); + function uniqWith(array, comparator) { + comparator = typeof comparator == 'function' ? comparator : undefined; + return (array && array.length) ? baseUniq(array, undefined, comparator) : []; } /** - * Creates a function that performs a partial deep comparison between a given - * object and `source`, returning `true` if the given object has equivalent - * property values, else `false`. - * - * **Note:** The created function is equivalent to `_.isMatch` with `source` - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `_.isEqual` - * for a list of supported value comparisons. + * This method is like `_.zip` except that it accepts an array of grouped + * elements and creates an array regrouping the elements to their pre-zip + * configuration. * * @static * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. + * @since 1.2.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @returns {Array} Returns the new array of regrouped elements. * @example * - * var objects = [ - * { 'a': 1, 'b': 2, 'c': 3 }, - * { 'a': 4, 'b': 5, 'c': 6 } - * ]; + * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] * - * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); - * // => [{ 'a': 4, 'b': 5, 'c': 6 }] + * _.unzip(zipped); + * // => [['a', 'b'], [1, 2], [true, false]] */ - function matches(source) { - return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLikeObject(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + return baseTimes(length, function(index) { + return arrayMap(array, baseProperty(index)); + }); } /** - * Creates a function that performs a partial deep comparison between the - * value at `path` of a given object to `srcValue`, returning `true` if the - * object value is equivalent, else `false`. - * - * **Note:** Partial comparisons will match empty array and empty object - * `srcValue` values against any array or object value, respectively. See - * `_.isEqual` for a list of supported value comparisons. + * This method is like `_.unzip` except that it accepts `iteratee` to specify + * how regrouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). * * @static * @memberOf _ - * @since 3.2.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. + * @since 3.8.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @param {Function} [iteratee=_.identity] The function to combine + * regrouped values. + * @returns {Array} Returns the new array of regrouped elements. * @example * - * var objects = [ - * { 'a': 1, 'b': 2, 'c': 3 }, - * { 'a': 4, 'b': 5, 'c': 6 } - * ]; + * var zipped = _.zip([1, 2], [10, 20], [100, 200]); + * // => [[1, 10, 100], [2, 20, 200]] * - * _.find(objects, _.matchesProperty('a', 4)); - * // => { 'a': 4, 'b': 5, 'c': 6 } + * _.unzipWith(zipped, _.add); + * // => [3, 30, 300] */ - function matchesProperty(path, srcValue) { - return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); + function unzipWith(array, iteratee) { + if (!(array && array.length)) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + return arrayMap(result, function(group) { + return apply(iteratee, undefined, group); + }); } /** - * Creates a function that invokes the method at `path` of a given object. - * Any additional arguments are provided to the invoked method. + * Creates an array excluding all given values using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.pull`, this method returns a new array. * * @static * @memberOf _ - * @since 3.7.0 - * @category Util - * @param {Array|string} path The path of the method to invoke. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {Function} Returns the new invoker function. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...*} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.difference, _.xor * @example * - * var objects = [ - * { 'a': { 'b': _.constant(2) } }, - * { 'a': { 'b': _.constant(1) } } - * ]; - * - * _.map(objects, _.method('a.b')); - * // => [2, 1] - * - * _.map(objects, _.method(['a', 'b'])); - * // => [2, 1] + * _.without([2, 1, 2, 3], 1, 2); + * // => [3] */ - var method = baseRest(function(path, args) { - return function(object) { - return baseInvoke(object, path, args); - }; + var without = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, values) + : []; }); /** - * The opposite of `_.method`; this method creates a function that invokes - * the method at a given path of `object`. Any additional arguments are - * provided to the invoked method. + * Creates an array of unique values that is the + * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the given arrays. The order of result values is determined by the order + * they occur in the arrays. * * @static * @memberOf _ - * @since 3.7.0 - * @category Util - * @param {Object} object The object to query. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {Function} Returns the new invoker function. + * @since 2.4.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of filtered values. + * @see _.difference, _.without * @example * - * var array = _.times(3, _.constant), - * object = { 'a': array, 'b': array, 'c': array }; - * - * _.map(['a[2]', 'c[0]'], _.methodOf(object)); - * // => [2, 0] - * - * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); - * // => [2, 0] + * _.xor([2, 1], [2, 3]); + * // => [1, 3] */ - var methodOf = baseRest(function(object, args) { - return function(path) { - return baseInvoke(object, path, args); - }; + var xor = baseRest(function(arrays) { + return baseXor(arrayFilter(arrays, isArrayLikeObject)); }); /** - * Adds all own enumerable string keyed function properties of a source - * object to the destination object. If `object` is a function, then methods - * are added to its prototype as well. - * - * **Note:** Use `_.runInContext` to create a pristine `lodash` function to - * avoid conflicts caused by modifying the original. + * This method is like `_.xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which by which they're compared. The order of result values is determined + * by the order they occur in the arrays. The iteratee is invoked with one + * argument: (value). * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @param {Function|Object} [object=lodash] The destination object. - * @param {Object} source The object of functions to add. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.chain=true] Specify whether mixins are chainable. - * @returns {Function|Object} Returns `object`. + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. * @example * - * function vowels(string) { - * return _.filter(string, function(v) { - * return /[aeiou]/i.test(v); - * }); - * } - * - * _.mixin({ 'vowels': vowels }); - * _.vowels('fred'); - * // => ['e'] - * - * _('fred').vowels().value(); - * // => ['e'] + * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2, 3.4] * - * _.mixin({ 'vowels': vowels }, { 'chain': false }); - * _('fred').vowels(); - * // => ['e'] + * // The `_.property` iteratee shorthand. + * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] */ - function mixin(object, source, options) { - var props = keys(source), - methodNames = baseFunctions(source, props); - - if (options == null && - !(isObject(source) && (methodNames.length || !props.length))) { - options = source; - source = object; - object = this; - methodNames = baseFunctions(source, keys(source)); + var xorBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; } - var chain = !(isObject(options) && 'chain' in options) || !!options.chain, - isFunc = isFunction(object); - - arrayEach(methodNames, function(methodName) { - var func = source[methodName]; - object[methodName] = func; - if (isFunc) { - object.prototype[methodName] = function() { - var chainAll = this.__chain__; - if (chain || chainAll) { - var result = object(this.__wrapped__), - actions = result.__actions__ = copyArray(this.__actions__); - - actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); - result.__chain__ = chainAll; - return result; - } - return func.apply(object, arrayPush([this.value()], arguments)); - }; - } - }); - - return object; - } + return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); + }); /** - * Reverts the `_` variable to its previous value and returns a reference to - * the `lodash` function. + * This method is like `_.xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The order of result values is + * determined by the order they occur in the arrays. The comparator is invoked + * with two arguments: (arrVal, othVal). * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @returns {Function} Returns the `lodash` function. + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. * @example * - * var lodash = _.noConflict(); + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.xorWith(objects, others, _.isEqual); + * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] */ - function noConflict() { - if (root._ === this) { - root._ = oldDash; - } - return this; - } + var xorWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); + }); /** - * This method returns `undefined`. + * Creates an array of grouped elements, the first of which contains the + * first elements of the given arrays, the second of which contains the + * second elements of the given arrays, and so on. * * @static * @memberOf _ - * @since 2.3.0 - * @category Util + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @returns {Array} Returns the new array of grouped elements. * @example * - * _.times(2, _.noop); - * // => [undefined, undefined] + * _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] */ - function noop() { - // No operation performed. - } + var zip = baseRest(unzip); /** - * Creates a function that gets the argument at index `n`. If `n` is negative, - * the nth argument from the end is returned. + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property identifiers and one of corresponding values. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {number} [n=0] The index of the argument to return. - * @returns {Function} Returns the new pass-thru function. + * @since 0.4.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. * @example * - * var func = _.nthArg(1); - * func('a', 'b', 'c', 'd'); - * // => 'b' - * - * var func = _.nthArg(-2); - * func('a', 'b', 'c', 'd'); - * // => 'c' + * _.zipObject(['a', 'b'], [1, 2]); + * // => { 'a': 1, 'b': 2 } */ - function nthArg(n) { - n = toInteger(n); - return baseRest(function(args) { - return baseNth(args, n); - }); + function zipObject(props, values) { + return baseZipObject(props || [], values || [], assignValue); } /** - * Creates a function that invokes `iteratees` with the arguments it receives - * and returns their results. + * This method is like `_.zipObject` except that it supports property paths. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {...(Function|Function[])} [iteratees=[_.identity]] - * The iteratees to invoke. - * @returns {Function} Returns the new function. + * @since 4.1.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. * @example * - * var func = _.over([Math.max, Math.min]); - * - * func(1, 2, 3, 4); - * // => [4, 1] + * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); + * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } */ - var over = createOver(arrayMap); + function zipObjectDeep(props, values) { + return baseZipObject(props || [], values || [], baseSet); + } /** - * Creates a function that checks if **all** of the `predicates` return - * truthy when invoked with the arguments it receives. + * This method is like `_.zip` except that it accepts `iteratee` to specify + * how grouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {...(Function|Function[])} [predicates=[_.identity]] - * The predicates to check. - * @returns {Function} Returns the new function. + * @since 3.8.0 + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee=_.identity] The function to combine + * grouped values. + * @returns {Array} Returns the new array of grouped elements. * @example * - * var func = _.overEvery([Boolean, isFinite]); - * - * func('1'); - * // => true - * - * func(null); - * // => false - * - * func(NaN); - * // => false + * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { + * return a + b + c; + * }); + * // => [111, 222] */ - var overEvery = createOver(arrayEvery); + var zipWith = baseRest(function(arrays) { + var length = arrays.length, + iteratee = length > 1 ? arrays[length - 1] : undefined; + + iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; + return unzipWith(arrays, iteratee); + }); + + /*------------------------------------------------------------------------*/ /** - * Creates a function that checks if **any** of the `predicates` return - * truthy when invoked with the arguments it receives. + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {...(Function|Function[])} [predicates=[_.identity]] - * The predicates to check. - * @returns {Function} Returns the new function. + * @since 1.3.0 + * @category Seq + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * var func = _.overSome([Boolean, isFinite]); - * - * func('1'); - * // => true - * - * func(null); - * // => true + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; * - * func(NaN); - * // => false + * var youngest = _ + * .chain(users) + * .sortBy('age') + * .map(function(o) { + * return o.user + ' is ' + o.age; + * }) + * .head() + * .value(); + * // => 'pebbles is 1' */ - var overSome = createOver(arraySome); + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } /** - * Creates a function that returns the value at `path` of a given object. + * This method invokes `interceptor` and returns `value`. The interceptor + * is invoked with one argument; (value). The purpose of this method is to + * "tap into" a method chain sequence in order to modify intermediate results. * * @static * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. + * @since 0.1.0 + * @category Seq + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @returns {*} Returns `value`. * @example * - * var objects = [ - * { 'a': { 'b': 2 } }, - * { 'a': { 'b': 1 } } - * ]; - * - * _.map(objects, _.property('a.b')); + * _([1, 2, 3]) + * .tap(function(array) { + * // Mutate input array. + * array.pop(); + * }) + * .reverse() + * .value(); * // => [2, 1] - * - * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); - * // => [1, 2] */ - function property(path) { - return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); + function tap(value, interceptor) { + interceptor(value); + return value; } /** - * The opposite of `_.property`; this method creates a function that returns - * the value at a given path of `object`. + * This method is like `_.tap` except that it returns the result of `interceptor`. + * The purpose of this method is to "pass thru" values replacing intermediate + * results in a method chain sequence. * * @static * @memberOf _ * @since 3.0.0 - * @category Util - * @param {Object} object The object to query. - * @returns {Function} Returns the new accessor function. + * @category Seq + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @returns {*} Returns the result of `interceptor`. * @example * - * var array = [0, 1, 2], - * object = { 'a': array, 'b': array, 'c': array }; - * - * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); - * // => [2, 0] - * - * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); - * // => [2, 0] + * _(' abc ') + * .chain() + * .trim() + * .thru(function(value) { + * return [value]; + * }) + * .value(); + * // => ['abc'] */ - function propertyOf(object) { - return function(path) { - return object == null ? undefined : baseGet(object, path); - }; + function thru(value, interceptor) { + return interceptor(value); } /** - * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. A step of `-1` is used if a negative - * `start` is specified without an `end` or `step`. If `end` is not specified, - * it's set to `start` with `start` then set to `0`. - * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. + * This method is the wrapper version of `_.at`. * - * @static - * @since 0.1.0 + * @name at * @memberOf _ - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see _.inRange, _.rangeRight + * @since 1.0.0 + * @category Seq + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * _.range(4); - * // => [0, 1, 2, 3] - * - * _.range(-4); - * // => [0, -1, -2, -3] + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; * - * _.range(1, 5); - * // => [1, 2, 3, 4] + * _(object).at(['a[0].b.c', 'a[1]']).value(); + * // => [3, 4] + */ + var wrapperAt = flatRest(function(paths) { + var length = paths.length, + start = length ? paths[0] : 0, + value = this.__wrapped__, + interceptor = function(object) { return baseAt(object, paths); }; + + if (length > 1 || this.__actions__.length || + !(value instanceof LazyWrapper) || !isIndex(start)) { + return this.thru(interceptor); + } + value = value.slice(start, +start + (length ? 1 : 0)); + value.__actions__.push({ + 'func': thru, + 'args': [interceptor], + 'thisArg': undefined + }); + return new LodashWrapper(value, this.__chain__).thru(function(array) { + if (length && !array.length) { + array.push(undefined); + } + return array; + }); + }); + + /** + * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. * - * _.range(0, 20, 5); - * // => [0, 5, 10, 15] + * @name chain + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example * - * _.range(0, -4, -1); - * // => [0, -1, -2, -3] + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; * - * _.range(1, 4, 0); - * // => [1, 1, 1] + * // A sequence without explicit chaining. + * _(users).head(); + * // => { 'user': 'barney', 'age': 36 } * - * _.range(0); - * // => [] + * // A sequence with explicit chaining. + * _(users) + * .chain() + * .head() + * .pick('user') + * .value(); + * // => { 'user': 'barney' } */ - var range = createRange(); + function wrapperChain() { + return chain(this); + } /** - * This method is like `_.range` except that it populates values in - * descending order. + * Executes the chain sequence and returns the wrapped result. * - * @static + * @name commit * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see _.inRange, _.range - * @example - * - * _.rangeRight(4); - * // => [3, 2, 1, 0] - * - * _.rangeRight(-4); - * // => [-3, -2, -1, 0] + * @since 3.2.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example * - * _.rangeRight(1, 5); - * // => [4, 3, 2, 1] + * var array = [1, 2]; + * var wrapped = _(array).push(3); * - * _.rangeRight(0, 20, 5); - * // => [15, 10, 5, 0] + * console.log(array); + * // => [1, 2] * - * _.rangeRight(0, -4, -1); - * // => [-3, -2, -1, 0] + * wrapped = wrapped.commit(); + * console.log(array); + * // => [1, 2, 3] * - * _.rangeRight(1, 4, 0); - * // => [1, 1, 1] + * wrapped.last(); + * // => 3 * - * _.rangeRight(0); - * // => [] + * console.log(array); + * // => [1, 2, 3] */ - var rangeRight = createRange(true); + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } /** - * This method returns a new empty array. + * Gets the next value on a wrapped object following the + * [iterator protocol](https://mdn.io/iteration_protocols#iterator). * - * @static + * @name next * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {Array} Returns the new empty array. + * @since 4.0.0 + * @category Seq + * @returns {Object} Returns the next iterator value. * @example * - * var arrays = _.times(2, _.stubArray); + * var wrapped = _([1, 2]); * - * console.log(arrays); - * // => [[], []] + * wrapped.next(); + * // => { 'done': false, 'value': 1 } * - * console.log(arrays[0] === arrays[1]); - * // => false + * wrapped.next(); + * // => { 'done': false, 'value': 2 } + * + * wrapped.next(); + * // => { 'done': true, 'value': undefined } */ - function stubArray() { - return []; + function wrapperNext() { + if (this.__values__ === undefined) { + this.__values__ = toArray(this.value()); + } + var done = this.__index__ >= this.__values__.length, + value = done ? undefined : this.__values__[this.__index__++]; + + return { 'done': done, 'value': value }; } /** - * This method returns `false`. + * Enables the wrapper to be iterable. * - * @static + * @name Symbol.iterator * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {boolean} Returns `false`. + * @since 4.0.0 + * @category Seq + * @returns {Object} Returns the wrapper object. * @example * - * _.times(2, _.stubFalse); - * // => [false, false] + * var wrapped = _([1, 2]); + * + * wrapped[Symbol.iterator]() === wrapped; + * // => true + * + * Array.from(wrapped); + * // => [1, 2] */ - function stubFalse() { - return false; + function wrapperToIterator() { + return this; } /** - * This method returns a new empty object. + * Creates a clone of the chain sequence planting `value` as the wrapped value. * - * @static + * @name plant * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {Object} Returns the new empty object. + * @since 3.2.0 + * @category Seq + * @param {*} value The value to plant. + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * var objects = _.times(2, _.stubObject); + * function square(n) { + * return n * n; + * } * - * console.log(objects); - * // => [{}, {}] + * var wrapped = _([1, 2]).map(square); + * var other = wrapped.plant([3, 4]); * - * console.log(objects[0] === objects[1]); - * // => false + * other.value(); + * // => [9, 16] + * + * wrapped.value(); + * // => [1, 4] */ - function stubObject() { - return {}; + function wrapperPlant(value) { + var result, + parent = this; + + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + clone.__index__ = 0; + clone.__values__ = undefined; + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; } /** - * This method returns an empty string. + * This method is the wrapper version of `_.reverse`. * - * @static + * **Note:** This method mutates the wrapped array. + * + * @name reverse * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {string} Returns the empty string. + * @since 0.1.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * _.times(2, _.stubString); - * // => ['', ''] + * var array = [1, 2, 3]; + * + * _(array).reverse().value() + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] */ - function stubString() { - return ''; + function wrapperReverse() { + var value = this.__wrapped__; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ + 'func': thru, + 'args': [reverse], + 'thisArg': undefined + }); + return new LodashWrapper(wrapped, this.__chain__); + } + return this.thru(reverse); } /** - * This method returns `true`. + * Executes the chain sequence to resolve the unwrapped value. * - * @static + * @name value * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {boolean} Returns `true`. + * @since 0.1.0 + * @alias toJSON, valueOf + * @category Seq + * @returns {*} Returns the resolved unwrapped value. * @example * - * _.times(2, _.stubTrue); - * // => [true, true] + * _([1, 2, 3]).value(); + * // => [1, 2, 3] */ - function stubTrue() { - return true; + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); } + /*------------------------------------------------------------------------*/ + /** - * Invokes the iteratee `n` times, returning an array of the results of - * each invocation. The iteratee is invoked with one argument; (index). + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the number of times the key was returned by `iteratee`. The + * iteratee is invoked with one argument: (value). * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the array of results. + * @since 0.5.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. * @example * - * _.times(3, String); - * // => ['0', '1', '2'] + * _.countBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': 1, '6': 2 } * - * _.times(4, _.constant(0)); - * // => [0, 0, 0, 0] + * // The `_.property` iteratee shorthand. + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } */ - function times(n, iteratee) { - n = toInteger(n); - if (n < 1 || n > MAX_SAFE_INTEGER) { - return []; - } - var index = MAX_ARRAY_LENGTH, - length = nativeMin(n, MAX_ARRAY_LENGTH); - - iteratee = getIteratee(iteratee); - n -= MAX_ARRAY_LENGTH; - - var result = baseTimes(length, iteratee); - while (++index < n) { - iteratee(index); + var countBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + ++result[key]; + } else { + baseAssignValue(result, key, 1); } - return result; - } + }); /** - * Converts `value` to a property path array. + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * Iteration is stopped once `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {*} value The value to convert. - * @returns {Array} Returns the new property path array. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. * @example * - * _.toPath('a.b.c'); - * // => ['a', 'b', 'c'] + * _.every([true, 1, null, 'yes'], Boolean); + * // => false * - * _.toPath('a[0].b.c'); - * // => ['a', '0', 'b', 'c'] + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.every(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.every(users, 'active'); + * // => false */ - function toPath(value) { - if (isArray(value)) { - return arrayMap(value, toKey); + function every(collection, predicate, guard) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; } - return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); + return func(collection, getIteratee(predicate, 3)); } /** - * Generates a unique ID. If `prefix` is given, the ID is appended to it. + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @param {string} [prefix=''] The value to prefix the ID with. - * @returns {string} Returns the unique ID. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.reject * @example * - * _.uniqueId('contact_'); - * // => 'contact_104' + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; * - * _.uniqueId(); - * // => '105' - */ - function uniqueId(prefix) { - var id = ++idCounter; - return toString(prefix) + id; - } - - /*------------------------------------------------------------------------*/ - - /** - * Adds two numbers. + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] * - * @static - * @memberOf _ - * @since 3.4.0 - * @category Math - * @param {number} augend The first number in an addition. - * @param {number} addend The second number in an addition. - * @returns {number} Returns the total. - * @example + * // The `_.matches` iteratee shorthand. + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] * - * _.add(6, 4); - * // => 10 + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.filter(users, 'active'); + * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] */ - var add = createMathOperation(function(augend, addend) { - return augend + addend; - }, 0); + function filter(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, getIteratee(predicate, 3)); + } /** - * Computes `number` rounded up to `precision`. + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ - * @since 3.10.0 - * @category Math - * @param {number} number The number to round up. - * @param {number} [precision=0] The precision to round up to. - * @returns {number} Returns the rounded up number. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.ceil(4.006); - * // => 5 + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; * - * _.ceil(6.004, 2); - * // => 6.01 + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' * - * _.ceil(6040, -2); - * // => 6100 - */ - var ceil = createRound('ceil'); - - /** - * Divide two numbers. + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Math - * @param {number} dividend The first number in a division. - * @param {number} divisor The second number in a division. - * @returns {number} Returns the quotient. - * @example + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' * - * _.divide(6, 4); - * // => 1.5 + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' */ - var divide = createMathOperation(function(dividend, divisor) { - return dividend / divisor; - }, 1); + var find = createFind(findIndex); /** - * Computes `number` rounded down to `precision`. + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. * * @static * @memberOf _ - * @since 3.10.0 - * @category Math - * @param {number} number The number to round down. - * @param {number} [precision=0] The precision to round down to. - * @returns {number} Returns the rounded down number. + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=collection.length-1] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.floor(4.006); - * // => 4 - * - * _.floor(0.046, 2); - * // => 0.04 - * - * _.floor(4060, -2); - * // => 4000 + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 */ - var floor = createRound('floor'); + var findLast = createFind(findLastIndex); /** - * Computes the maximum value of `array`. If `array` is empty or falsey, - * `undefined` is returned. + * Creates a flattened array of values by running each element in `collection` + * thru `iteratee` and flattening the mapped results. The iteratee is invoked + * with three arguments: (value, index|key, collection). * * @static - * @since 0.1.0 * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the maximum value. + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. * @example * - * _.max([4, 2, 8, 6]); - * // => 8 + * function duplicate(n) { + * return [n, n]; + * } * - * _.max([]); - * // => undefined + * _.flatMap([1, 2], duplicate); + * // => [1, 1, 2, 2] */ - function max(array) { - return (array && array.length) - ? baseExtremum(array, identity, baseGt) - : undefined; + function flatMap(collection, iteratee) { + return baseFlatten(map(collection, iteratee), 1); } /** - * This method is like `_.max` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. * * @static * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the maximum value. + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. * @example * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; - * - * _.maxBy(objects, function(o) { return o.n; }); - * // => { 'n': 2 } + * function duplicate(n) { + * return [[[n, n]]]; + * } * - * // The `_.property` iteratee shorthand. - * _.maxBy(objects, 'n'); - * // => { 'n': 2 } + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] */ - function maxBy(array, iteratee) { - return (array && array.length) - ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) - : undefined; + function flatMapDeep(collection, iteratee) { + return baseFlatten(map(collection, iteratee), INFINITY); } /** - * Computes the mean of the values in `array`. + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results up to `depth` times. * * @static * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the mean. + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. * @example * - * _.mean([4, 2, 8, 6]); - * // => 5 + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDepth([1, 2], duplicate, 2); + * // => [[1, 1], [2, 2]] */ - function mean(array) { - return baseMean(array, identity); + function flatMapDepth(collection, iteratee, depth) { + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(map(collection, iteratee), depth); } /** - * This method is like `_.mean` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be averaged. - * The iteratee is invoked with one argument: (value). + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. * * @static * @memberOf _ - * @since 4.7.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the mean. + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight * @example * - * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; - * - * _.meanBy(objects, function(o) { return o.n; }); - * // => 5 + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. * - * // The `_.property` iteratee shorthand. - * _.meanBy(objects, 'n'); - * // => 5 + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ - function meanBy(array, iteratee) { - return baseMean(array, getIteratee(iteratee, 2)); + function forEach(collection, iteratee) { + var func = isArray(collection) ? arrayEach : baseEach; + return func(collection, getIteratee(iteratee, 3)); } /** - * Computes the minimum value of `array`. If `array` is empty or falsey, - * `undefined` is returned. + * This method is like `_.forEach` except that it iterates over elements of + * `collection` from right to left. * * @static - * @since 0.1.0 * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the minimum value. + * @since 2.0.0 + * @alias eachRight + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEach * @example * - * _.min([4, 2, 8, 6]); - * // => 2 - * - * _.min([]); - * // => undefined + * _.forEachRight([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `2` then `1`. */ - function min(array) { - return (array && array.length) - ? baseExtremum(array, identity, baseLt) - : undefined; + function forEachRight(collection, iteratee) { + var func = isArray(collection) ? arrayEachRight : baseEachRight; + return func(collection, getIteratee(iteratee, 3)); } /** - * This method is like `_.min` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The order of grouped values + * is determined by the order they occur in `collection`. The corresponding + * value of each key is an array of elements responsible for generating the + * key. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the minimum value. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. * @example * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; - * - * _.minBy(objects, function(o) { return o.n; }); - * // => { 'n': 1 } + * _.groupBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': [4.2], '6': [6.1, 6.3] } * * // The `_.property` iteratee shorthand. - * _.minBy(objects, 'n'); - * // => { 'n': 1 } + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } */ - function minBy(array, iteratee) { - return (array && array.length) - ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) - : undefined; - } + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + baseAssignValue(result, key, [value]); + } + }); /** - * Multiply two numbers. + * Checks if `value` is in `collection`. If `collection` is a string, it's + * checked for a substring of `value`, otherwise + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * is used for equality comparisons. If `fromIndex` is negative, it's used as + * the offset from the end of `collection`. * * @static * @memberOf _ - * @since 4.7.0 - * @category Math - * @param {number} multiplier The first number in a multiplication. - * @param {number} multiplicand The second number in a multiplication. - * @returns {number} Returns the product. + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {boolean} Returns `true` if `value` is found, else `false`. * @example * - * _.multiply(6, 4); - * // => 24 + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'a': 1, 'b': 2 }, 1); + * // => true + * + * _.includes('abcd', 'bc'); + * // => true */ - var multiply = createMathOperation(function(multiplier, multiplicand) { - return multiplier * multiplicand; - }, 1); + function includes(collection, value, fromIndex, guard) { + collection = isArrayLike(collection) ? collection : values(collection); + fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; + + var length = collection.length; + if (fromIndex < 0) { + fromIndex = nativeMax(length + fromIndex, 0); + } + return isString(collection) + ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) + : (!!length && baseIndexOf(collection, value, fromIndex) > -1); + } /** - * Computes `number` rounded to `precision`. + * Invokes the method at `path` of each element in `collection`, returning + * an array of the results of each invoked method. Any additional arguments + * are provided to each invoked method. If `path` is a function, it's invoked + * for, and `this` bound to, each element in `collection`. * * @static * @memberOf _ - * @since 3.10.0 - * @category Math - * @param {number} number The number to round. - * @param {number} [precision=0] The precision to round to. - * @returns {number} Returns the rounded number. + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|string} path The path of the method to invoke or + * the function invoked per iteration. + * @param {...*} [args] The arguments to invoke each method with. + * @returns {Array} Returns the array of results. * @example * - * _.round(4.006); - * // => 4 - * - * _.round(4.006, 2); - * // => 4.01 + * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); + * // => [[1, 5, 7], [1, 2, 3]] * - * _.round(4060, -2); - * // => 4100 + * _.invokeMap([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] */ - var round = createRound('round'); + var invokeMap = baseRest(function(collection, path, args) { + var index = -1, + isFunc = typeof path == 'function', + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value) { + result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); + }); + return result; + }); /** - * Subtract two numbers. + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the last element responsible for generating the key. The + * iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @since 4.0.0 - * @category Math - * @param {number} minuend The first number in a subtraction. - * @param {number} subtrahend The second number in a subtraction. - * @returns {number} Returns the difference. + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. * @example * - * _.subtract(6, 4); - * // => 2 + * var array = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.keyBy(array, function(o) { + * return String.fromCharCode(o.code); + * }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.keyBy(array, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } */ - var subtract = createMathOperation(function(minuend, subtrahend) { - return minuend - subtrahend; - }, 0); + var keyBy = createAggregator(function(result, value, key) { + baseAssignValue(result, key, value); + }); /** - * Computes the sum of the values in `array`. + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` * * @static * @memberOf _ - * @since 3.4.0 - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the sum. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. * @example * - * _.sum([4, 2, 8, 6]); - * // => 20 + * function square(n) { + * return n * n; + * } + * + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] */ - function sum(array) { - return (array && array.length) - ? baseSum(array, identity) - : 0; + function map(collection, iteratee) { + var func = isArray(collection) ? arrayMap : baseMap; + return func(collection, getIteratee(iteratee, 3)); } /** - * This method is like `_.sum` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be summed. - * The iteratee is invoked with one argument: (value). + * This method is like `_.sortBy` except that it allows specifying the sort + * orders of the iteratees to sort by. If `orders` is unspecified, all values + * are sorted in ascending order. Otherwise, specify an order of "desc" for + * descending or "asc" for ascending sort order of corresponding values. * * @static * @memberOf _ * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the sum. + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] + * The iteratees to sort by. + * @param {string[]} [orders] The sort orders of `iteratees`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {Array} Returns the new sorted array. * @example * - * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; - * - * _.sumBy(objects, function(o) { return o.n; }); - * // => 20 + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 34 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 36 } + * ]; * - * // The `_.property` iteratee shorthand. - * _.sumBy(objects, 'n'); - * // => 20 + * // Sort by `user` in ascending order and by `age` in descending order. + * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] */ - function sumBy(array, iteratee) { - return (array && array.length) - ? baseSum(array, getIteratee(iteratee, 2)) - : 0; + function orderBy(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [iteratees]; + } + orders = guard ? undefined : orders; + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseOrderBy(collection, iteratees, orders); } - /*------------------------------------------------------------------------*/ - - // Add methods that return wrapped values in chain sequences. - lodash.after = after; - lodash.ary = ary; - lodash.assign = assign; - lodash.assignIn = assignIn; - lodash.assignInWith = assignInWith; - lodash.assignWith = assignWith; - lodash.at = at; - lodash.before = before; - lodash.bind = bind; - lodash.bindAll = bindAll; - lodash.bindKey = bindKey; - lodash.castArray = castArray; - lodash.chain = chain; - lodash.chunk = chunk; - lodash.compact = compact; - lodash.concat = concat; - lodash.cond = cond; - lodash.conforms = conforms; - lodash.constant = constant; - lodash.countBy = countBy; - lodash.create = create; - lodash.curry = curry; - lodash.curryRight = curryRight; - lodash.debounce = debounce; - lodash.defaults = defaults; - lodash.defaultsDeep = defaultsDeep; - lodash.defer = defer; - lodash.delay = delay; - lodash.difference = difference; - lodash.differenceBy = differenceBy; - lodash.differenceWith = differenceWith; - lodash.drop = drop; - lodash.dropRight = dropRight; - lodash.dropRightWhile = dropRightWhile; - lodash.dropWhile = dropWhile; - lodash.fill = fill; - lodash.filter = filter; - lodash.flatMap = flatMap; - lodash.flatMapDeep = flatMapDeep; - lodash.flatMapDepth = flatMapDepth; - lodash.flatten = flatten; - lodash.flattenDeep = flattenDeep; - lodash.flattenDepth = flattenDepth; - lodash.flip = flip; - lodash.flow = flow; - lodash.flowRight = flowRight; - lodash.fromPairs = fromPairs; - lodash.functions = functions; - lodash.functionsIn = functionsIn; - lodash.groupBy = groupBy; - lodash.initial = initial; - lodash.intersection = intersection; - lodash.intersectionBy = intersectionBy; - lodash.intersectionWith = intersectionWith; - lodash.invert = invert; - lodash.invertBy = invertBy; - lodash.invokeMap = invokeMap; - lodash.iteratee = iteratee; - lodash.keyBy = keyBy; - lodash.keys = keys; - lodash.keysIn = keysIn; - lodash.map = map; - lodash.mapKeys = mapKeys; - lodash.mapValues = mapValues; - lodash.matches = matches; - lodash.matchesProperty = matchesProperty; - lodash.memoize = memoize; - lodash.merge = merge; - lodash.mergeWith = mergeWith; - lodash.method = method; - lodash.methodOf = methodOf; - lodash.mixin = mixin; - lodash.negate = negate; - lodash.nthArg = nthArg; - lodash.omit = omit; - lodash.omitBy = omitBy; - lodash.once = once; - lodash.orderBy = orderBy; - lodash.over = over; - lodash.overArgs = overArgs; - lodash.overEvery = overEvery; - lodash.overSome = overSome; - lodash.partial = partial; - lodash.partialRight = partialRight; - lodash.partition = partition; - lodash.pick = pick; - lodash.pickBy = pickBy; - lodash.property = property; - lodash.propertyOf = propertyOf; - lodash.pull = pull; - lodash.pullAll = pullAll; - lodash.pullAllBy = pullAllBy; - lodash.pullAllWith = pullAllWith; - lodash.pullAt = pullAt; - lodash.range = range; - lodash.rangeRight = rangeRight; - lodash.rearg = rearg; - lodash.reject = reject; - lodash.remove = remove; - lodash.rest = rest; - lodash.reverse = reverse; - lodash.sampleSize = sampleSize; - lodash.set = set; - lodash.setWith = setWith; - lodash.shuffle = shuffle; - lodash.slice = slice; - lodash.sortBy = sortBy; - lodash.sortedUniq = sortedUniq; - lodash.sortedUniqBy = sortedUniqBy; - lodash.split = split; - lodash.spread = spread; - lodash.tail = tail; - lodash.take = take; - lodash.takeRight = takeRight; - lodash.takeRightWhile = takeRightWhile; - lodash.takeWhile = takeWhile; - lodash.tap = tap; - lodash.throttle = throttle; - lodash.thru = thru; - lodash.toArray = toArray; - lodash.toPairs = toPairs; - lodash.toPairsIn = toPairsIn; - lodash.toPath = toPath; - lodash.toPlainObject = toPlainObject; - lodash.transform = transform; - lodash.unary = unary; - lodash.union = union; - lodash.unionBy = unionBy; - lodash.unionWith = unionWith; - lodash.uniq = uniq; - lodash.uniqBy = uniqBy; - lodash.uniqWith = uniqWith; - lodash.unset = unset; - lodash.unzip = unzip; - lodash.unzipWith = unzipWith; - lodash.update = update; - lodash.updateWith = updateWith; - lodash.values = values; - lodash.valuesIn = valuesIn; - lodash.without = without; - lodash.words = words; - lodash.wrap = wrap; - lodash.xor = xor; - lodash.xorBy = xorBy; - lodash.xorWith = xorWith; - lodash.zip = zip; - lodash.zipObject = zipObject; - lodash.zipObjectDeep = zipObjectDeep; - lodash.zipWith = zipWith; - - // Add aliases. - lodash.entries = toPairs; - lodash.entriesIn = toPairsIn; - lodash.extend = assignIn; - lodash.extendWith = assignInWith; - - // Add methods to `lodash.prototype`. - mixin(lodash, lodash); - - /*------------------------------------------------------------------------*/ + /** + * Creates an array of elements split into two groups, the first of which + * contains elements `predicate` returns truthy for, the second of which + * contains elements `predicate` returns falsey for. The predicate is + * invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the array of grouped elements. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true }, + * { 'user': 'pebbles', 'age': 1, 'active': false } + * ]; + * + * _.partition(users, function(o) { return o.active; }); + * // => objects for [['fred'], ['barney', 'pebbles']] + * + * // The `_.matches` iteratee shorthand. + * _.partition(users, { 'age': 1, 'active': false }); + * // => objects for [['pebbles'], ['barney', 'fred']] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.partition(users, ['active', false]); + * // => objects for [['barney', 'pebbles'], ['fred']] + * + * // The `_.property` iteratee shorthand. + * _.partition(users, 'active'); + * // => objects for [['fred'], ['barney', 'pebbles']] + */ + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { return [[], []]; }); - // Add methods that return unwrapped values in chain sequences. - lodash.add = add; - lodash.attempt = attempt; - lodash.camelCase = camelCase; - lodash.capitalize = capitalize; - lodash.ceil = ceil; - lodash.clamp = clamp; - lodash.clone = clone; - lodash.cloneDeep = cloneDeep; - lodash.cloneDeepWith = cloneDeepWith; - lodash.cloneWith = cloneWith; - lodash.conformsTo = conformsTo; - lodash.deburr = deburr; - lodash.defaultTo = defaultTo; - lodash.divide = divide; - lodash.endsWith = endsWith; - lodash.eq = eq; - lodash.escape = escape; - lodash.escapeRegExp = escapeRegExp; - lodash.every = every; - lodash.find = find; - lodash.findIndex = findIndex; - lodash.findKey = findKey; - lodash.findLast = findLast; - lodash.findLastIndex = findLastIndex; - lodash.findLastKey = findLastKey; - lodash.floor = floor; - lodash.forEach = forEach; - lodash.forEachRight = forEachRight; - lodash.forIn = forIn; - lodash.forInRight = forInRight; - lodash.forOwn = forOwn; - lodash.forOwnRight = forOwnRight; - lodash.get = get; - lodash.gt = gt; - lodash.gte = gte; - lodash.has = has; - lodash.hasIn = hasIn; - lodash.head = head; - lodash.identity = identity; - lodash.includes = includes; - lodash.indexOf = indexOf; - lodash.inRange = inRange; - lodash.invoke = invoke; - lodash.isArguments = isArguments; - lodash.isArray = isArray; - lodash.isArrayBuffer = isArrayBuffer; - lodash.isArrayLike = isArrayLike; - lodash.isArrayLikeObject = isArrayLikeObject; - lodash.isBoolean = isBoolean; - lodash.isBuffer = isBuffer; - lodash.isDate = isDate; - lodash.isElement = isElement; - lodash.isEmpty = isEmpty; - lodash.isEqual = isEqual; - lodash.isEqualWith = isEqualWith; - lodash.isError = isError; - lodash.isFinite = isFinite; - lodash.isFunction = isFunction; - lodash.isInteger = isInteger; - lodash.isLength = isLength; - lodash.isMap = isMap; - lodash.isMatch = isMatch; - lodash.isMatchWith = isMatchWith; - lodash.isNaN = isNaN; - lodash.isNative = isNative; - lodash.isNil = isNil; - lodash.isNull = isNull; - lodash.isNumber = isNumber; - lodash.isObject = isObject; - lodash.isObjectLike = isObjectLike; - lodash.isPlainObject = isPlainObject; - lodash.isRegExp = isRegExp; - lodash.isSafeInteger = isSafeInteger; - lodash.isSet = isSet; - lodash.isString = isString; - lodash.isSymbol = isSymbol; - lodash.isTypedArray = isTypedArray; - lodash.isUndefined = isUndefined; - lodash.isWeakMap = isWeakMap; - lodash.isWeakSet = isWeakSet; - lodash.join = join; - lodash.kebabCase = kebabCase; - lodash.last = last; - lodash.lastIndexOf = lastIndexOf; - lodash.lowerCase = lowerCase; - lodash.lowerFirst = lowerFirst; - lodash.lt = lt; - lodash.lte = lte; - lodash.max = max; - lodash.maxBy = maxBy; - lodash.mean = mean; - lodash.meanBy = meanBy; - lodash.min = min; - lodash.minBy = minBy; - lodash.stubArray = stubArray; - lodash.stubFalse = stubFalse; - lodash.stubObject = stubObject; - lodash.stubString = stubString; - lodash.stubTrue = stubTrue; - lodash.multiply = multiply; - lodash.nth = nth; - lodash.noConflict = noConflict; - lodash.noop = noop; - lodash.now = now; - lodash.pad = pad; - lodash.padEnd = padEnd; - lodash.padStart = padStart; - lodash.parseInt = parseInt; - lodash.random = random; - lodash.reduce = reduce; - lodash.reduceRight = reduceRight; - lodash.repeat = repeat; - lodash.replace = replace; - lodash.result = result; - lodash.round = round; - lodash.runInContext = runInContext; - lodash.sample = sample; - lodash.size = size; - lodash.snakeCase = snakeCase; - lodash.some = some; - lodash.sortedIndex = sortedIndex; - lodash.sortedIndexBy = sortedIndexBy; - lodash.sortedIndexOf = sortedIndexOf; - lodash.sortedLastIndex = sortedLastIndex; - lodash.sortedLastIndexBy = sortedLastIndexBy; - lodash.sortedLastIndexOf = sortedLastIndexOf; - lodash.startCase = startCase; - lodash.startsWith = startsWith; - lodash.subtract = subtract; - lodash.sum = sum; - lodash.sumBy = sumBy; - lodash.template = template; - lodash.times = times; - lodash.toFinite = toFinite; - lodash.toInteger = toInteger; - lodash.toLength = toLength; - lodash.toLower = toLower; - lodash.toNumber = toNumber; - lodash.toSafeInteger = toSafeInteger; - lodash.toString = toString; - lodash.toUpper = toUpper; - lodash.trim = trim; - lodash.trimEnd = trimEnd; - lodash.trimStart = trimStart; - lodash.truncate = truncate; - lodash.unescape = unescape; - lodash.uniqueId = uniqueId; - lodash.upperCase = upperCase; - lodash.upperFirst = upperFirst; + /** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `collection` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduceRight + * @example + * + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }, 0); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * return result; + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + */ + function reduce(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduce : baseReduce, + initAccum = arguments.length < 3; - // Add aliases. - lodash.each = forEach; - lodash.eachRight = forEachRight; - lodash.first = head; + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); + } - mixin(lodash, (function() { - var source = {}; - baseForOwn(lodash, function(func, methodName) { - if (!hasOwnProperty.call(lodash.prototype, methodName)) { - source[methodName] = func; - } - }); - return source; - }()), { 'chain': false }); + /** + * This method is like `_.reduce` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduce + * @example + * + * var array = [[0, 1], [2, 3], [4, 5]]; + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); + * // => [4, 5, 2, 3, 0, 1] + */ + function reduceRight(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduceRight : baseReduce, + initAccum = arguments.length < 3; - /*------------------------------------------------------------------------*/ + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); + } /** - * The semantic version number. + * The opposite of `_.filter`; this method returns the elements of `collection` + * that `predicate` does **not** return truthy for. * * @static * @memberOf _ - * @type {string} + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.filter + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true } + * ]; + * + * _.reject(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.reject(users, { 'age': 40, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.reject(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.reject(users, 'active'); + * // => objects for ['barney'] */ - lodash.VERSION = VERSION; - - // Assign default placeholders. - arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { - lodash[methodName].placeholder = lodash; - }); - - // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. - arrayEach(['drop', 'take'], function(methodName, index) { - LazyWrapper.prototype[methodName] = function(n) { - n = n === undefined ? 1 : nativeMax(toInteger(n), 0); - - var result = (this.__filtered__ && !index) - ? new LazyWrapper(this) - : this.clone(); - - if (result.__filtered__) { - result.__takeCount__ = nativeMin(n, result.__takeCount__); - } else { - result.__views__.push({ - 'size': nativeMin(n, MAX_ARRAY_LENGTH), - 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') - }); - } - return result; - }; - - LazyWrapper.prototype[methodName + 'Right'] = function(n) { - return this.reverse()[methodName](n).reverse(); - }; - }); - - // Add `LazyWrapper` methods that accept an `iteratee` value. - arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { - var type = index + 1, - isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; - - LazyWrapper.prototype[methodName] = function(iteratee) { - var result = this.clone(); - result.__iteratees__.push({ - 'iteratee': getIteratee(iteratee, 3), - 'type': type - }); - result.__filtered__ = result.__filtered__ || isFilter; - return result; - }; - }); - - // Add `LazyWrapper` methods for `_.head` and `_.last`. - arrayEach(['head', 'last'], function(methodName, index) { - var takeName = 'take' + (index ? 'Right' : ''); - - LazyWrapper.prototype[methodName] = function() { - return this[takeName](1).value()[0]; - }; - }); - - // Add `LazyWrapper` methods for `_.initial` and `_.tail`. - arrayEach(['initial', 'tail'], function(methodName, index) { - var dropName = 'drop' + (index ? '' : 'Right'); + function reject(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, negate(getIteratee(predicate, 3))); + } - LazyWrapper.prototype[methodName] = function() { - return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); - }; - }); + /** + * Gets a random element from `collection`. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + */ + function sample(collection) { + var func = isArray(collection) ? arraySample : baseSample; + return func(collection); + } - LazyWrapper.prototype.compact = function() { - return this.filter(identity); - }; + /** + * Gets `n` random elements at unique keys from `collection` up to the + * size of `collection`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to sample. + * @param {number} [n=1] The number of elements to sample. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the random elements. + * @example + * + * _.sampleSize([1, 2, 3], 2); + * // => [3, 1] + * + * _.sampleSize([1, 2, 3], 4); + * // => [2, 3, 1] + */ + function sampleSize(collection, n, guard) { + if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { + n = 1; + } else { + n = toInteger(n); + } + var func = isArray(collection) ? arraySampleSize : baseSampleSize; + return func(collection, n); + } - LazyWrapper.prototype.find = function(predicate) { - return this.filter(predicate).head(); - }; + /** + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + * @example + * + * _.shuffle([1, 2, 3, 4]); + * // => [4, 1, 3, 2] + */ + function shuffle(collection) { + var func = isArray(collection) ? arrayShuffle : baseShuffle; + return func(collection); + } - LazyWrapper.prototype.findLast = function(predicate) { - return this.reverse().find(predicate); - }; + /** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable string keyed properties for objects. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the collection size. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ + function size(collection) { + if (collection == null) { + return 0; + } + if (isArrayLike(collection)) { + return isString(collection) ? stringSize(collection) : collection.length; + } + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + return baseKeys(collection).length; + } - LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { - if (typeof path == 'function') { - return new LazyWrapper(this); + /** + * Checks if `predicate` returns truthy for **any** element of `collection`. + * Iteration is stopped once `predicate` returns truthy. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + * @example + * + * _.some([null, 0, 'yes', false], Boolean); + * // => true + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.some(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.some(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.some(users, 'active'); + * // => true + */ + function some(collection, predicate, guard) { + var func = isArray(collection) ? arraySome : baseSome; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; } - return this.map(function(value) { - return baseInvoke(value, path, args); - }); - }); - - LazyWrapper.prototype.reject = function(predicate) { - return this.filter(negate(getIteratee(predicate))); - }; - - LazyWrapper.prototype.slice = function(start, end) { - start = toInteger(start); + return func(collection, getIteratee(predicate, 3)); + } - var result = this; - if (result.__filtered__ && (start > 0 || end < 0)) { - return new LazyWrapper(result); - } - if (start < 0) { - result = result.takeRight(-start); - } else if (start) { - result = result.drop(start); + /** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection thru each iteratee. This method + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The iteratees are invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to sort by. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 30 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.sortBy(users, [function(o) { return o.user; }]); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] + * + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] + */ + var sortBy = baseRest(function(collection, iteratees) { + if (collection == null) { + return []; } - if (end !== undefined) { - end = toInteger(end); - result = end < 0 ? result.dropRight(-end) : result.take(end - start); + var length = iteratees.length; + if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + iteratees = []; + } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + iteratees = [iteratees[0]]; } - return result; - }; + return baseOrderBy(collection, baseFlatten(iteratees, 1), []); + }); - LazyWrapper.prototype.takeRightWhile = function(predicate) { - return this.reverse().takeWhile(predicate).reverse(); - }; + /*------------------------------------------------------------------------*/ - LazyWrapper.prototype.toArray = function() { - return this.take(MAX_ARRAY_LENGTH); + /** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ + var now = ctxNow || function() { + return root.Date.now(); }; - // Add `LazyWrapper` methods to `lodash.prototype`. - baseForOwn(LazyWrapper.prototype, function(func, methodName) { - var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), - isTaker = /^(?:head|last)$/.test(methodName), - lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], - retUnwrapped = isTaker || /^find/.test(methodName); + /*------------------------------------------------------------------------*/ - if (!lodashFunc) { - return; + /** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. + */ + function after(n, func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); } - lodash.prototype[methodName] = function() { - var value = this.__wrapped__, - args = isTaker ? [1] : arguments, - isLazy = value instanceof LazyWrapper, - iteratee = args[0], - useLazy = isLazy || isArray(value); - - var interceptor = function(value) { - var result = lodashFunc.apply(lodash, arrayPush([value], args)); - return (isTaker && chainAll) ? result[0] : result; - }; - - if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { - // Avoid lazy use if the iteratee has a "length" value other than `1`. - isLazy = useLazy = false; - } - var chainAll = this.__chain__, - isHybrid = !!this.__actions__.length, - isUnwrapped = retUnwrapped && !chainAll, - onlyLazy = isLazy && !isHybrid; - - if (!retUnwrapped && useLazy) { - value = onlyLazy ? value : new LazyWrapper(this); - var result = func.apply(value, args); - result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); - return new LodashWrapper(result, chainAll); - } - if (isUnwrapped && onlyLazy) { - return func.apply(this, args); + n = toInteger(n); + return function() { + if (--n < 1) { + return func.apply(this, arguments); } - result = this.thru(interceptor); - return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; }; - }); + } - // Add `Array` methods to `lodash.prototype`. - arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { - var func = arrayProto[methodName], - chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', - retUnwrapped = /^(?:pop|shift)$/.test(methodName); + /** + * Creates a function that invokes `func`, with up to `n` arguments, + * ignoring any additional arguments. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @param {number} [n=func.length] The arity cap. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new capped function. + * @example + * + * _.map(['6', '8', '10'], _.ary(parseInt, 1)); + * // => [6, 8, 10] + */ + function ary(func, n, guard) { + n = guard ? undefined : n; + n = (func && n == null) ? func.length : n; + return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); + } - lodash.prototype[methodName] = function() { - var args = arguments; - if (retUnwrapped && !this.__chain__) { - var value = this.value(); - return func.apply(isArray(value) ? value : [], args); + /** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it's called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {number} n The number of calls at which `func` is no longer invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * jQuery(element).on('click', _.before(5, addContactToList)); + * // => Allows adding up to 4 contacts to the list. + */ + function before(n, func) { + var result; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function() { + if (--n > 0) { + result = func.apply(this, arguments); } - return this[chainName](function(value) { - return func.apply(isArray(value) ? value : [], args); - }); + if (n <= 1) { + func = undefined; + } + return result; }; + } + + /** + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and `partials` prepended to the arguments it receives. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" + * property of bound functions. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * function greet(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * + * var object = { 'user': 'fred' }; + * + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * // Bound with placeholders. + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' + */ + var bind = baseRest(function(func, thisArg, partials) { + var bitmask = WRAP_BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bind)); + bitmask |= WRAP_PARTIAL_FLAG; + } + return createWrap(func, bitmask, thisArg, partials, holders); }); - // Map minified method names to their real names. - baseForOwn(LazyWrapper.prototype, function(func, methodName) { - var lodashFunc = lodash[methodName]; - if (lodashFunc) { - var key = (lodashFunc.name + ''), - names = realNames[key] || (realNames[key] = []); - - names.push({ 'name': methodName, 'func': lodashFunc }); + /** + * Creates a function that invokes the method at `object[key]` with `partials` + * prepended to the arguments it receives. + * + * This method differs from `_.bind` by allowing bound functions to reference + * methods that may be redefined or don't yet exist. See + * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * for more details. + * + * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Function + * @param {Object} object The object to invoke the method on. + * @param {string} key The key of the method. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var object = { + * 'user': 'fred', + * 'greet': function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * }; + * + * var bound = _.bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function(greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // Bound with placeholders. + * var bound = _.bindKey(object, 'greet', _, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ + var bindKey = baseRest(function(object, key, partials) { + var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bindKey)); + bitmask |= WRAP_PARTIAL_FLAG; } + return createWrap(key, bitmask, object, partials, holders); }); - realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ - 'name': 'wrapper', - 'func': undefined - }]; - - // Add methods to `LazyWrapper`. - LazyWrapper.prototype.clone = lazyClone; - LazyWrapper.prototype.reverse = lazyReverse; - LazyWrapper.prototype.value = lazyValue; - - // Add chain sequence methods to the `lodash` wrapper. - lodash.prototype.at = wrapperAt; - lodash.prototype.chain = wrapperChain; - lodash.prototype.commit = wrapperCommit; - lodash.prototype.next = wrapperNext; - lodash.prototype.plant = wrapperPlant; - lodash.prototype.reverse = wrapperReverse; - lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - - // Add lazy aliases. - lodash.prototype.first = lodash.prototype.head; - - if (symIterator) { - lodash.prototype[symIterator] = wrapperToIterator; + /** + * Creates a function that accepts arguments of `func` and either invokes + * `func` returning its result, if at least `arity` number of arguments have + * been provided, or returns a function that accepts the remaining `func` + * arguments, and so on. The arity of `func` may be specified if `func.length` + * is not sufficient. + * + * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curry(abc); + * + * curried(1)(2)(3); + * // => [1, 2, 3] + * + * curried(1, 2)(3); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(1)(_, 3)(2); + * // => [1, 2, 3] + */ + function curry(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curry.placeholder; + return result; } - return lodash; - }); - - /*--------------------------------------------------------------------------*/ - - // Export lodash. - var _ = runInContext(); - - // Some AMD build optimizers, like r.js, check for condition patterns like: - if (true) { - // Expose Lodash on the global object to prevent errors when Lodash is - // loaded by a script tag in the presence of an AMD loader. - // See http://requirejs.org/docs/errors.html#mismatch for more details. - // Use `_.noConflict` to remove Lodash from the global object. - root._ = _; - - // Define as an anonymous module so, through path mapping, it can be - // referenced as the "underscore" module. - !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { - return _; - }.call(exports, __webpack_require__, exports, module), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } - // Check for `exports` after `define` in case a build optimizer adds it. - else if (freeModule) { - // Export for Node.js. - (freeModule.exports = _)._ = _; - // Export for CommonJS support. - freeExports._ = _; - } - else { - // Export to the global object. - root._ = _; - } -}.call(this)); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16), __webpack_require__(17)(module))) - -/***/ }), -/* 16 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 17 */ -/***/ (function(module, exports) { - -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; + /** + * This method is like `_.curry` except that arguments are applied to `func` + * in the manner of `_.partialRight` instead of `_.partial`. + * + * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curryRight(abc); + * + * curried(3)(2)(1); + * // => [1, 2, 3] + * + * curried(2, 3)(1); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(3)(1, _)(2); + * // => [1, 2, 3] + */ + function curryRight(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryRight.placeholder; + return result; + } -/***/ }), -/* 18 */ -/***/ (function(module, exports) { + /** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ + function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; -function layout(rows, columns, padding, size, aspect) { - var grid = []; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = toNumber(wait) || 0; + if (isObject(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } - for (var i = 0; i < rows; i++) { - for (var j = 0; j < columns; j++) { - var x = -1 + aspect * (i * (padding + size) + padding); - var y = 1 - (j * (padding + size) + padding); - grid.push([ y, x ]); - var x_next = x + size - padding; - grid.push([ y, x_next ]); - var y_next = y - size + padding; - grid.push([ y_next, x ]); + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; - grid.push([ y_next, x ]); - grid.push([ y, x_next ]); - grid.push([ y_next, x_next ]); + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } - } - } + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } - return grid.reverse(); -} + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } -module.exports = layout; + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } -/***/ }), -/* 19 */ -/***/ (function(module, exports) { + function timerExpired() { + var time = now(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } -function texcoord(rows, columns, texture_indexes, num_textures) { - var grid = []; - var texture; - var texture_start; - var texture_next; + function trailingEdge(time) { + timerId = undefined; - for (var i = 0; i < rows; i++) { - for (var j = 0; j < columns; j++) { - texture = texture_indexes[i*rows + j]; - texture_start = (1/num_textures)*texture; - texture_next = texture_start + (1/num_textures); + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } - grid.push([ 0, texture_start ]); - grid.push([ 1, texture_start ]); - grid.push([ 0, texture_next ]); - - grid.push([ 0, texture_next ]); - grid.push([ 1, texture_start ]); - grid.push([ 1, texture_next ]); - } - } + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } - return grid; -} + function flush() { + return timerId === undefined ? result : trailingEdge(now()); + } + function debounced() { + var time = now(), + isInvoking = shouldInvoke(time); -module.exports = texcoord; + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; + } -/***/ }), -/* 20 */ -/***/ (function(module, exports) { + /** + * Defers invoking the `func` until the current call stack has cleared. Any + * additional arguments are provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to defer. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. + * @example + * + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); + * // => Logs 'deferred' after one millisecond. + */ + var defer = baseRest(function(func, args) { + return baseDelay(func, 1, args); + }); -function range(j, k) { - return Array - .apply(null, Array((k - j) + 1)) - .map(function(discard, n){ return n + j; }); -} + /** + * Invokes `func` after `wait` milliseconds. Any additional arguments are + * provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. + * @example + * + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); + * // => Logs 'later' after one second. + */ + var delay = baseRest(function(func, wait, args) { + return baseDelay(func, toNumber(wait) || 0, args); + }); + /** + * Creates a function that invokes `func` with arguments reversed. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to flip arguments for. + * @returns {Function} Returns the new flipped function. + * @example + * + * var flipped = _.flip(function() { + * return _.toArray(arguments); + * }); + * + * flipped('a', 'b', 'c', 'd'); + * // => ['d', 'c', 'b', 'a'] + */ + function flip(func) { + return createWrap(func, WRAP_FLIP_FLAG); + } + /** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ + function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; -module.exports = range; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; + } + // Expose `MapCache`. + memoize.Cache = MapCache; -/***/ }), -/* 21 */ -/***/ (function(module, exports) { + /** + * Creates a function that negates the result of the predicate `func`. The + * `func` predicate is invoked with the `this` binding and arguments of the + * created function. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} predicate The predicate to negate. + * @returns {Function} Returns the new negated function. + * @example + * + * function isEven(n) { + * return n % 2 == 0; + * } + * + * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); + * // => [1, 3, 5] + */ + function negate(predicate) { + if (typeof predicate != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + var args = arguments; + switch (args.length) { + case 0: return !predicate.call(this); + case 1: return !predicate.call(this, args[0]); + case 2: return !predicate.call(this, args[0], args[1]); + case 3: return !predicate.call(this, args[0], args[1], args[2]); + } + return !predicate.apply(this, args); + }; + } -/** - * Derived from Identicon.js 2.3.1 - * http://github.com/stewartlord/identicon.js - * - * Copyright 2017, Stewart Lord and Dallinger Contributors - * Released under the BSD license - * http://www.opensource.org/licenses/bsd-license.php - */ + /** + * Creates a function that is restricted to invoking `func` once. Repeat calls + * to the function return the value of the first invocation. The `func` is + * invoked with the `this` binding and arguments of the created function. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var initialize = _.once(createApplication); + * initialize(); + * initialize(); + * // => `createApplication` is invoked once + */ + function once(func) { + return before(2, func); + } + /** + * Creates a function that invokes `func` with its arguments transformed. + * + * @static + * @since 4.0.0 + * @memberOf _ + * @category Function + * @param {Function} func The function to wrap. + * @param {...(Function|Function[])} [transforms=[_.identity]] + * The argument transforms. + * @returns {Function} Returns the new function. + * @example + * + * function doubled(n) { + * return n * 2; + * } + * + * function square(n) { + * return n * n; + * } + * + * var func = _.overArgs(function(x, y) { + * return [x, y]; + * }, [square, doubled]); + * + * func(9, 3); + * // => [81, 6] + * + * func(10, 5); + * // => [100, 10] + */ + var overArgs = castRest(function(func, transforms) { + transforms = (transforms.length == 1 && isArray(transforms[0])) + ? arrayMap(transforms[0], baseUnary(getIteratee())) + : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); -var Identicon = function(hash, size, options){ - if (typeof(hash) !== 'string' || hash.length < 15) { - throw 'A hash of at least 15 characters is required.'; - } + var funcsLength = transforms.length; + return baseRest(function(args) { + var index = -1, + length = nativeMin(args.length, funcsLength); - this.defaults = { - background: [240, 240, 240, 255], - margin: 0.08, - size: 64, - saturation: 0.7, - brightness: 0.5, - format: 'pixels' - }; + while (++index < length) { + args[index] = transforms[index].call(this, args[index]); + } + return apply(func, this, args); + }); + }); - this.options = typeof(options) === 'object' ? options : this.defaults; + /** + * Creates a function that invokes `func` with `partials` prepended to the + * arguments it receives. This method is like `_.bind` except it does **not** + * alter the `this` binding. + * + * The `_.partial.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method doesn't set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @since 0.2.0 + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * function greet(greeting, name) { + * return greeting + ' ' + name; + * } + * + * var sayHelloTo = _.partial(greet, 'hello'); + * sayHelloTo('fred'); + * // => 'hello fred' + * + * // Partially applied with placeholders. + * var greetFred = _.partial(greet, _, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + */ + var partial = baseRest(function(func, partials) { + var holders = replaceHolders(partials, getHolder(partial)); + return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); + }); - this.hash = hash - this.background = [128, 128, 128]; - this.foreground = [255, 255, 255]; - this.size = size; -}; + /** + * This method is like `_.partial` except that partially applied arguments + * are appended to the arguments it receives. + * + * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method doesn't set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * function greet(greeting, name) { + * return greeting + ' ' + name; + * } + * + * var greetFred = _.partialRight(greet, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + * + * // Partially applied with placeholders. + * var sayHelloTo = _.partialRight(greet, 'hello', _); + * sayHelloTo('fred'); + * // => 'hello fred' + */ + var partialRight = baseRest(function(func, partials) { + var holders = replaceHolders(partials, getHolder(partialRight)); + return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); + }); -Identicon.prototype = { - background: null, - foreground: null, - hash: null, - margin: null, - size: null, - format: null, + /** + * Creates a function that invokes `func` with arguments arranged according + * to the specified `indexes` where the argument value at the first index is + * provided as the first argument, the argument value at the second index is + * provided as the second argument, and so on. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to rearrange arguments for. + * @param {...(number|number[])} indexes The arranged argument indexes. + * @returns {Function} Returns the new function. + * @example + * + * var rearged = _.rearg(function(a, b, c) { + * return [a, b, c]; + * }, [2, 0, 1]); + * + * rearged('b', 'c', 'a') + * // => ['a', 'b', 'c'] + */ + var rearg = flatRest(function(func, indexes) { + return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); + }); - image: function(){ - return new Pixels(this.size, this.foreground, this.background) - }, + /** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as + * an array. + * + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.rest(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ + function rest(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start === undefined ? start : toInteger(start); + return baseRest(func, start); + } - render: function(){ - var image = this.image(), - size = this.size, - baseMargin = Math.floor(size * this.margin), - cell = Math.floor((size - (baseMargin * 2)) / 5), - margin = Math.floor((size - cell * 5) / 2), - bg = this.background, - fg = this.foreground; + /** + * Creates a function that invokes `func` with the `this` binding of the + * create function and an array of arguments much like + * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). + * + * **Note:** This method is based on the + * [spread operator](https://mdn.io/spread_operator). + * + * @static + * @memberOf _ + * @since 3.2.0 + * @category Function + * @param {Function} func The function to spread arguments over. + * @param {number} [start=0] The start position of the spread. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.spread(function(who, what) { + * return who + ' says ' + what; + * }); + * + * say(['fred', 'hello']); + * // => 'fred says hello' + * + * var numbers = Promise.all([ + * Promise.resolve(40), + * Promise.resolve(36) + * ]); + * + * numbers.then(_.spread(function(x, y) { + * return x + y; + * })); + * // => a Promise of 76 + */ + function spread(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start == null ? 0 : nativeMax(toInteger(start), 0); + return baseRest(function(args) { + var array = args[start], + otherArgs = castSlice(args, 0, start); - // the first 15 characters of the hash control the pixels (even/odd) - // they are drawn down the middle first, then mirrored outwards - var i, color; - for (i = 0; i < 15; i++) { - color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg; - if (i < 5) { - this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image); - } else if (i < 10) { - this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); - this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); - } else if (i < 15) { - this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); - this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); - } + if (array) { + arrayPush(otherArgs, array); } + return apply(func, this, otherArgs); + }); + } - return image; - }, + /** + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed `func` invocations and a `flush` method to + * immediately invoke them. Provide `options` to indicate whether `func` + * should be invoked on the leading and/or trailing edge of the `wait` + * timeout. The `func` is invoked with the last arguments provided to the + * throttled function. Subsequent calls to the throttled function return the + * result of the last `func` invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the throttled function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.throttle` and `_.debounce`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to throttle. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=true] + * Specify invoking on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // Avoid excessively updating the position while scrolling. + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); + * + * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); + * jQuery(element).on('click', throttled); + * + * // Cancel the trailing throttled invocation. + * jQuery(window).on('popstate', throttled.cancel); + */ + function throttle(func, wait, options) { + var leading = true, + trailing = true; - rectangle: function(x, y, w, h, color, image){ - var i, j; - for (i = x; i < x + w; i++) { - for (j = y; j < y + h; j++) { - image.buffer[j][i] = color; - } - } + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (isObject(options)) { + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { + 'leading': leading, + 'maxWait': wait, + 'trailing': trailing + }); } -}; - -var Pixels = function(size){ - this.buffer = []; - for (i = 0; i < size; i++) { - var row = [] - for (j = 0; j < size; j++) { - row.push([0,0,120]); - } - this.buffer.push(row); + /** + * Creates a function that accepts up to one argument, ignoring any + * additional arguments. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + * @example + * + * _.map(['6', '8', '10'], _.unary(parseInt)); + * // => [6, 8, 10] + */ + function unary(func) { + return ary(func, 1); } -}; - -Pixels.prototype = { - pixels: null, - -}; - - -module.exports = Identicon; - - -/***/ }), -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { - -(function (global, factory) { - true ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.createREGL = factory()); -}(this, (function () { 'use strict'; - -var arrayTypes = { - "[object Int8Array]": 5120, - "[object Int16Array]": 5122, - "[object Int32Array]": 5124, - "[object Uint8Array]": 5121, - "[object Uint8ClampedArray]": 5121, - "[object Uint16Array]": 5123, - "[object Uint32Array]": 5125, - "[object Float32Array]": 5126, - "[object Float64Array]": 5121, - "[object ArrayBuffer]": 5121 -}; - -var isTypedArray = function (x) { - return Object.prototype.toString.call(x) in arrayTypes -}; - -var extend = function (base, opts) { - var keys = Object.keys(opts); - for (var i = 0; i < keys.length; ++i) { - base[keys[i]] = opts[keys[i]]; - } - return base -}; - -// Error checking and parameter validation. -// -// Statements for the form `check.someProcedure(...)` get removed by -// a browserify transform for optimized/minified bundles. -// -/* globals btoa */ -// only used for extracting shader names. if btoa not present, then errors -// will be slightly crappier -function decodeB64 (str) { - if (typeof btoa !== 'undefined') { - return btoa(str) - } - return 'base64:' + str -} - -function raise (message) { - var error = new Error('(regl) ' + message); - console.error(error); - throw error -} - -function check (pred, message) { - if (!pred) { - raise(message); - } -} -function encolon (message) { - if (message) { - return ': ' + message - } - return '' -} + /** + * Creates a function that provides `value` to `wrapper` as its first + * argument. Any additional arguments provided to the function are appended + * to those provided to the `wrapper`. The wrapper is invoked with the `this` + * binding of the created function. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {*} value The value to wrap. + * @param {Function} [wrapper=identity] The wrapper function. + * @returns {Function} Returns the new function. + * @example + * + * var p = _.wrap(_.escape, function(func, text) { + * return '<p>' + func(text) + '</p>'; + * }); + * + * p('fred, barney, & pebbles'); + * // => '<p>fred, barney, & pebbles</p>' + */ + function wrap(value, wrapper) { + return partial(castFunction(wrapper), value); + } -function checkParameter (param, possibilities, message) { - if (!(param in possibilities)) { - raise('unknown parameter (' + param + ')' + encolon(message) + - '. possible values: ' + Object.keys(possibilities).join()); - } -} + /*------------------------------------------------------------------------*/ -function checkIsTypedArray (data, message) { - if (!isTypedArray(data)) { - raise( - 'invalid parameter type' + encolon(message) + - '. must be a typed array'); - } -} + /** + * Casts `value` as an array if it's not one. + * + * @static + * @memberOf _ + * @since 4.4.0 + * @category Lang + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast array. + * @example + * + * _.castArray(1); + * // => [1] + * + * _.castArray({ 'a': 1 }); + * // => [{ 'a': 1 }] + * + * _.castArray('abc'); + * // => ['abc'] + * + * _.castArray(null); + * // => [null] + * + * _.castArray(undefined); + * // => [undefined] + * + * _.castArray(); + * // => [] + * + * var array = [1, 2, 3]; + * console.log(_.castArray(array) === array); + * // => true + */ + function castArray() { + if (!arguments.length) { + return []; + } + var value = arguments[0]; + return isArray(value) ? value : [value]; + } -function checkTypeOf (value, type, message) { - if (typeof value !== type) { - raise( - 'invalid parameter type' + encolon(message) + - '. expected ' + type + ', got ' + (typeof value)); - } -} + /** + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); + * // => true + */ + function clone(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG); + } -function checkNonNegativeInt (value, message) { - if (!((value >= 0) && - ((value | 0) === value))) { - raise('invalid parameter type, (' + value + ')' + encolon(message) + - '. must be a nonnegative integer'); - } -} + /** + * This method is like `_.clone` except that it accepts `customizer` which + * is invoked to produce the cloned value. If `customizer` returns `undefined`, + * cloning is handled by the method instead. The `customizer` is invoked with + * up to four arguments; (value [, index|key, object, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the cloned value. + * @see _.cloneDeepWith + * @example + * + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } + * } + * + * var el = _.cloneWith(document.body, customizer); + * + * console.log(el === document.body); + * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 0 + */ + function cloneWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); + } -function checkOneOf (value, list, message) { - if (list.indexOf(value) < 0) { - raise('invalid value' + encolon(message) + '. must be one of: ' + list); - } -} + /** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ + function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); + } -var constructorKeys = [ - 'gl', - 'canvas', - 'container', - 'attributes', - 'pixelRatio', - 'extensions', - 'optionalExtensions', - 'profile', - 'onDone' -]; + /** + * This method is like `_.cloneWith` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the deep cloned value. + * @see _.cloneWith + * @example + * + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } + * } + * + * var el = _.cloneDeepWith(document.body, customizer); + * + * console.log(el === document.body); + * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 20 + */ + function cloneDeepWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); + } -function checkConstructor (obj) { - Object.keys(obj).forEach(function (key) { - if (constructorKeys.indexOf(key) < 0) { - raise('invalid regl constructor argument "' + key + '". must be one of ' + constructorKeys); + /** + * Checks if `object` conforms to `source` by invoking the predicate + * properties of `source` with the corresponding property values of `object`. + * + * **Note:** This method is equivalent to `_.conforms` when `source` is + * partially applied. + * + * @static + * @memberOf _ + * @since 4.14.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * + * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); + * // => true + * + * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); + * // => false + */ + function conformsTo(object, source) { + return source == null || baseConformsTo(object, source, keys(source)); } - }); -} -function leftPad (str, n) { - str = str + ''; - while (str.length < n) { - str = ' ' + str; - } - return str -} + /** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ + function eq(value, other) { + return value === other || (value !== value && other !== other); + } -function ShaderFile () { - this.name = 'unknown'; - this.lines = []; - this.index = {}; - this.hasErrors = false; -} + /** + * Checks if `value` is greater than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + * @see _.lt + * @example + * + * _.gt(3, 1); + * // => true + * + * _.gt(3, 3); + * // => false + * + * _.gt(1, 3); + * // => false + */ + var gt = createRelationalOperation(baseGt); -function ShaderLine (number, line) { - this.number = number; - this.line = line; - this.errors = []; -} + /** + * Checks if `value` is greater than or equal to `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than or equal to + * `other`, else `false`. + * @see _.lte + * @example + * + * _.gte(3, 1); + * // => true + * + * _.gte(3, 3); + * // => true + * + * _.gte(1, 3); + * // => false + */ + var gte = createRelationalOperation(function(value, other) { + return value >= other; + }); -function ShaderError (fileNumber, lineNumber, message) { - this.file = fileNumber; - this.line = lineNumber; - this.message = message; -} + /** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ + var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); + }; -function guessCommand () { - var error = new Error(); - var stack = (error.stack || error).toString(); - var pat = /compileProcedure.*\n\s*at.*\((.*)\)/.exec(stack); - if (pat) { - return pat[1] - } - var pat2 = /compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(stack); - if (pat2) { - return pat2[1] - } - return 'unknown' -} + /** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ + var isArray = Array.isArray; -function guessCallSite () { - var error = new Error(); - var stack = (error.stack || error).toString(); - var pat = /at REGLCommand.*\n\s+at.*\((.*)\)/.exec(stack); - if (pat) { - return pat[1] - } - var pat2 = /at REGLCommand.*\n\s+at\s+(.*)\n/.exec(stack); - if (pat2) { - return pat2[1] - } - return 'unknown' -} + /** + * Checks if `value` is classified as an `ArrayBuffer` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + * @example + * + * _.isArrayBuffer(new ArrayBuffer(2)); + * // => true + * + * _.isArrayBuffer(new Array(2)); + * // => false + */ + var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; -function parseSource (source, command) { - var lines = source.split('\n'); - var lineNumber = 1; - var fileNumber = 0; - var files = { - unknown: new ShaderFile(), - 0: new ShaderFile() - }; - files.unknown.name = files[0].name = command || guessCommand(); - files.unknown.lines.push(new ShaderLine(0, '')); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i]; - var parts = /^\s*\#\s*(\w+)\s+(.+)\s*$/.exec(line); - if (parts) { - switch (parts[1]) { - case 'line': - var lineNumberInfo = /(\d+)(\s+\d+)?/.exec(parts[2]); - if (lineNumberInfo) { - lineNumber = lineNumberInfo[1] | 0; - if (lineNumberInfo[2]) { - fileNumber = lineNumberInfo[2] | 0; - if (!(fileNumber in files)) { - files[fileNumber] = new ShaderFile(); - } - } - } - break - case 'define': - var nameInfo = /SHADER_NAME(_B64)?\s+(.*)$/.exec(parts[2]); - if (nameInfo) { - files[fileNumber].name = (nameInfo[1] - ? decodeB64(nameInfo[2]) - : nameInfo[2]); - } - break - } + /** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); } - files[fileNumber].lines.push(new ShaderLine(lineNumber++, line)); - } - Object.keys(files).forEach(function (fileNumber) { - var file = files[fileNumber]; - file.lines.forEach(function (line) { - file.index[line.number] = line; - }); - }); - return files -} -function parseErrorLog (errLog) { - var result = []; - errLog.split('\n').forEach(function (errMsg) { - if (errMsg.length < 5) { - return - } - var parts = /^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(errMsg); - if (parts) { - result.push(new ShaderError( - parts[1] | 0, - parts[2] | 0, - parts[3].trim())); - } else if (errMsg.length > 0) { - result.push(new ShaderError('unknown', 0, errMsg)); + /** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ + function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); } - }); - return result -} -function annotateFiles (files, errors) { - errors.forEach(function (error) { - var file = files[error.file]; - if (file) { - var line = file.index[error.line]; - if (line) { - line.errors.push(error); - file.hasErrors = true; - return - } + /** + * Checks if `value` is classified as a boolean primitive or object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. + * @example + * + * _.isBoolean(false); + * // => true + * + * _.isBoolean(null); + * // => false + */ + function isBoolean(value) { + return value === true || value === false || + (isObjectLike(value) && baseGetTag(value) == boolTag); } - files.unknown.hasErrors = true; - files.unknown.lines[0].errors.push(error); - }); -} -function checkShaderError (gl, shader, source, type, command) { - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - var errLog = gl.getShaderInfoLog(shader); - var typeName = type === gl.FRAGMENT_SHADER ? 'fragment' : 'vertex'; - checkCommandType(source, 'string', typeName + ' shader source must be a string', command); - var files = parseSource(source, command); - var errors = parseErrorLog(errLog); - annotateFiles(files, errors); + /** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ + var isBuffer = nativeIsBuffer || stubFalse; - Object.keys(files).forEach(function (fileNumber) { - var file = files[fileNumber]; - if (!file.hasErrors) { - return - } + /** + * Checks if `value` is classified as a `Date` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + * @example + * + * _.isDate(new Date); + * // => true + * + * _.isDate('Mon April 23 2012'); + * // => false + */ + var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; - var strings = ['']; - var styles = ['']; + /** + * Checks if `value` is likely a DOM element. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. + * @example + * + * _.isElement(document.body); + * // => true + * + * _.isElement('<body>'); + * // => false + */ + function isElement(value) { + return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); + } - function push (str, style) { - strings.push(str); - styles.push(style || ''); + /** + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ + function isEmpty(value) { + if (value == null) { + return true; } - - push('file number ' + fileNumber + ': ' + file.name + '\n', 'color:red;text-decoration:underline;font-weight:bold'); - - file.lines.forEach(function (line) { - if (line.errors.length > 0) { - push(leftPad(line.number, 4) + '| ', 'background-color:yellow; font-weight:bold'); - push(line.line + '\n', 'color:red; background-color:yellow; font-weight:bold'); - - // try to guess token - var offset = 0; - line.errors.forEach(function (error) { - var message = error.message; - var token = /^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(message); - if (token) { - var tokenPat = token[1]; - message = token[2]; - switch (tokenPat) { - case 'assign': - tokenPat = '='; - break - } - offset = Math.max(line.line.indexOf(tokenPat, offset), 0); - } else { - offset = 0; - } - - push(leftPad('| ', 6)); - push(leftPad('^^^', offset + 3) + '\n', 'font-weight:bold'); - push(leftPad('| ', 6)); - push(message + '\n', 'font-weight:bold'); - }); - push(leftPad('| ', 6) + '\n'); - } else { - push(leftPad(line.number, 4) + '| '); - push(line.line + '\n', 'color:red'); + if (isArrayLike(value) && + (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || + isBuffer(value) || isTypedArray(value) || isArguments(value))) { + return !value.length; + } + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + if (isPrototype(value)) { + return !baseKeys(value).length; + } + for (var key in value) { + if (hasOwnProperty.call(value, key)) { + return false; } - }); - if (typeof document !== 'undefined') { - styles[0] = strings.join('%c'); - console.log.apply(console, styles); - } else { - console.log(strings.join('')); } - }); - - check.raise('Error compiling ' + typeName + ' shader, ' + files[0].name); - } -} - -function checkLinkError (gl, program, fragShader, vertShader, command) { - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - var errLog = gl.getProgramInfoLog(program); - var fragParse = parseSource(fragShader, command); - var vertParse = parseSource(vertShader, command); - - var header = 'Error linking program with vertex shader, "' + - vertParse[0].name + '", and fragment shader "' + fragParse[0].name + '"'; - - if (typeof document !== 'undefined') { - console.log('%c' + header + '\n%c' + errLog, - 'color:red;text-decoration:underline;font-weight:bold', - 'color:red'); - } else { - console.log(header + '\n' + errLog); + return true; } - check.raise(header); - } -} - -function saveCommandRef (object) { - object._commandRef = guessCommand(); -} - -function saveDrawCommandInfo (opts, uniforms, attributes, stringStore) { - saveCommandRef(opts); - function id (str) { - if (str) { - return stringStore.id(str) + /** + * Performs a deep comparison between two values to determine if they are + * equivalent. + * + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are compared by strict equality, i.e. `===`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.isEqual(object, other); + * // => true + * + * object === other; + * // => false + */ + function isEqual(value, other) { + return baseIsEqual(value, other); } - return 0 - } - opts._fragId = id(opts.static.frag); - opts._vertId = id(opts.static.vert); - - function addProps (dict, set) { - Object.keys(set).forEach(function (u) { - dict[stringStore.id(u)] = true; - }); - } - - var uniformSet = opts._uniformSet = {}; - addProps(uniformSet, uniforms.static); - addProps(uniformSet, uniforms.dynamic); - - var attributeSet = opts._attributeSet = {}; - addProps(attributeSet, attributes.static); - addProps(attributeSet, attributes.dynamic); - - opts._hasCount = ( - 'count' in opts.static || - 'count' in opts.dynamic || - 'elements' in opts.static || - 'elements' in opts.dynamic); -} - -function commandRaise (message, command) { - var callSite = guessCallSite(); - raise(message + - ' in command ' + (command || guessCommand()) + - (callSite === 'unknown' ? '' : ' called from ' + callSite)); -} - -function checkCommand (pred, message, command) { - if (!pred) { - commandRaise(message, command || guessCommand()); - } -} - -function checkParameterCommand (param, possibilities, message, command) { - if (!(param in possibilities)) { - commandRaise( - 'unknown parameter (' + param + ')' + encolon(message) + - '. possible values: ' + Object.keys(possibilities).join(), - command || guessCommand()); - } -} - -function checkCommandType (value, type, message, command) { - if (typeof value !== type) { - commandRaise( - 'invalid parameter type' + encolon(message) + - '. expected ' + type + ', got ' + (typeof value), - command || guessCommand()); - } -} - -function checkOptional (block) { - block(); -} - -function checkFramebufferFormat (attachment, texFormats, rbFormats) { - if (attachment.texture) { - checkOneOf( - attachment.texture._texture.internalformat, - texFormats, - 'unsupported texture format for attachment'); - } else { - checkOneOf( - attachment.renderbuffer._renderbuffer.format, - rbFormats, - 'unsupported renderbuffer format for attachment'); - } -} - -var GL_CLAMP_TO_EDGE = 0x812F; - -var GL_NEAREST = 0x2600; -var GL_NEAREST_MIPMAP_NEAREST = 0x2700; -var GL_LINEAR_MIPMAP_NEAREST = 0x2701; -var GL_NEAREST_MIPMAP_LINEAR = 0x2702; -var GL_LINEAR_MIPMAP_LINEAR = 0x2703; - -var GL_BYTE = 5120; -var GL_UNSIGNED_BYTE = 5121; -var GL_SHORT = 5122; -var GL_UNSIGNED_SHORT = 5123; -var GL_INT = 5124; -var GL_UNSIGNED_INT = 5125; -var GL_FLOAT = 5126; - -var GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033; -var GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034; -var GL_UNSIGNED_SHORT_5_6_5 = 0x8363; -var GL_UNSIGNED_INT_24_8_WEBGL = 0x84FA; - -var GL_HALF_FLOAT_OES = 0x8D61; - -var TYPE_SIZE = {}; - -TYPE_SIZE[GL_BYTE] = -TYPE_SIZE[GL_UNSIGNED_BYTE] = 1; - -TYPE_SIZE[GL_SHORT] = -TYPE_SIZE[GL_UNSIGNED_SHORT] = -TYPE_SIZE[GL_HALF_FLOAT_OES] = -TYPE_SIZE[GL_UNSIGNED_SHORT_5_6_5] = -TYPE_SIZE[GL_UNSIGNED_SHORT_4_4_4_4] = -TYPE_SIZE[GL_UNSIGNED_SHORT_5_5_5_1] = 2; - -TYPE_SIZE[GL_INT] = -TYPE_SIZE[GL_UNSIGNED_INT] = -TYPE_SIZE[GL_FLOAT] = -TYPE_SIZE[GL_UNSIGNED_INT_24_8_WEBGL] = 4; - -function pixelSize (type, channels) { - if (type === GL_UNSIGNED_SHORT_5_5_5_1 || - type === GL_UNSIGNED_SHORT_4_4_4_4 || - type === GL_UNSIGNED_SHORT_5_6_5) { - return 2 - } else if (type === GL_UNSIGNED_INT_24_8_WEBGL) { - return 4 - } else { - return TYPE_SIZE[type] * channels - } -} -function isPow2 (v) { - return !(v & (v - 1)) && (!!v) -} + /** + * This method is like `_.isEqual` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with up to + * six arguments: (objValue, othValue [, index|key, object, other, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, othValue) { + * if (isGreeting(objValue) && isGreeting(othValue)) { + * return true; + * } + * } + * + * var array = ['hello', 'goodbye']; + * var other = ['hi', 'goodbye']; + * + * _.isEqualWith(array, other, customizer); + * // => true + */ + function isEqualWith(value, other, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; + } -function checkTexture2D (info, mipData, limits) { - var i; - var w = mipData.width; - var h = mipData.height; - var c = mipData.channels; + /** + * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, + * `SyntaxError`, `TypeError`, or `URIError` object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @example + * + * _.isError(new Error); + * // => true + * + * _.isError(Error); + * // => false + */ + function isError(value) { + if (!isObjectLike(value)) { + return false; + } + var tag = baseGetTag(value); + return tag == errorTag || tag == domExcTag || + (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); + } - // Check texture shape - check(w > 0 && w <= limits.maxTextureSize && - h > 0 && h <= limits.maxTextureSize, - 'invalid texture shape'); + /** + * Checks if `value` is a finite primitive number. + * + * **Note:** This method is based on + * [`Number.isFinite`](https://mdn.io/Number/isFinite). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @example + * + * _.isFinite(3); + * // => true + * + * _.isFinite(Number.MIN_VALUE); + * // => true + * + * _.isFinite(Infinity); + * // => false + * + * _.isFinite('3'); + * // => false + */ + function isFinite(value) { + return typeof value == 'number' && nativeIsFinite(value); + } - // check wrap mode - if (info.wrapS !== GL_CLAMP_TO_EDGE || info.wrapT !== GL_CLAMP_TO_EDGE) { - check(isPow2(w) && isPow2(h), - 'incompatible wrap mode for texture, both width and height must be power of 2'); - } + /** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ + function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + } - if (mipData.mipmask === 1) { - if (w !== 1 && h !== 1) { - check( - info.minFilter !== GL_NEAREST_MIPMAP_NEAREST && - info.minFilter !== GL_NEAREST_MIPMAP_LINEAR && - info.minFilter !== GL_LINEAR_MIPMAP_NEAREST && - info.minFilter !== GL_LINEAR_MIPMAP_LINEAR, - 'min filter requires mipmap'); + /** + * Checks if `value` is an integer. + * + * **Note:** This method is based on + * [`Number.isInteger`](https://mdn.io/Number/isInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an integer, else `false`. + * @example + * + * _.isInteger(3); + * // => true + * + * _.isInteger(Number.MIN_VALUE); + * // => false + * + * _.isInteger(Infinity); + * // => false + * + * _.isInteger('3'); + * // => false + */ + function isInteger(value) { + return typeof value == 'number' && value == toInteger(value); } - } else { - // texture must be power of 2 - check(isPow2(w) && isPow2(h), - 'texture must be a square power of 2 to support mipmapping'); - check(mipData.mipmask === (w << 1) - 1, - 'missing or incomplete mipmap data'); - } - if (mipData.type === GL_FLOAT) { - if (limits.extensions.indexOf('oes_texture_float_linear') < 0) { - check(info.minFilter === GL_NEAREST && info.magFilter === GL_NEAREST, - 'filter not supported, must enable oes_texture_float_linear'); + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ + function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } - check(!info.genMipmaps, - 'mipmap generation not supported with float textures'); - } - // check image complete - var mipimages = mipData.images; - for (i = 0; i < 16; ++i) { - if (mipimages[i]) { - var mw = w >> i; - var mh = h >> i; - check(mipData.mipmask & (1 << i), 'missing mipmap data'); + /** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ + function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); + } - var img = mipimages[i]; + /** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ + function isObjectLike(value) { + return value != null && typeof value == 'object'; + } - check( - img.width === mw && - img.height === mh, - 'invalid shape for mip images'); + /** + * Checks if `value` is classified as a `Map` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + * @example + * + * _.isMap(new Map); + * // => true + * + * _.isMap(new WeakMap); + * // => false + */ + var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; - check( - img.format === mipData.format && - img.internalformat === mipData.internalformat && - img.type === mipData.type, - 'incompatible type for mip image'); + /** + * Performs a partial deep comparison between `object` and `source` to + * determine if `object` contains equivalent property values. + * + * **Note:** This method is equivalent to `_.matches` when `source` is + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * + * _.isMatch(object, { 'b': 2 }); + * // => true + * + * _.isMatch(object, { 'b': 1 }); + * // => false + */ + function isMatch(object, source) { + return object === source || baseIsMatch(object, source, getMatchData(source)); + } - if (img.compressed) { - // TODO: check size for compressed images - } else if (img.data) { - // check(img.data.byteLength === mw * mh * - // Math.max(pixelSize(img.type, c), img.unpackAlignment), - var rowSize = Math.ceil(pixelSize(img.type, c) * mw / img.unpackAlignment) * img.unpackAlignment; - check(img.data.byteLength === rowSize * mh, - 'invalid data for image, buffer size is inconsistent with image format'); - } else if (img.element) { - // TODO: check element can be loaded - } else if (img.copy) { - // TODO: check compatible format and type - } - } else if (!info.genMipmaps) { - check((mipData.mipmask & (1 << i)) === 0, 'extra mipmap data'); + /** + * This method is like `_.isMatch` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with five + * arguments: (objValue, srcValue, index|key, object, source). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, srcValue) { + * if (isGreeting(objValue) && isGreeting(srcValue)) { + * return true; + * } + * } + * + * var object = { 'greeting': 'hello' }; + * var source = { 'greeting': 'hi' }; + * + * _.isMatchWith(object, source, customizer); + * // => true + */ + function isMatchWith(object, source, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseIsMatch(object, source, getMatchData(source), customizer); } - } - - if (mipData.compressed) { - check(!info.genMipmaps, - 'mipmap generation for compressed images not supported'); - } -} - -function checkTextureCube (texture, info, faces, limits) { - var w = texture.width; - var h = texture.height; - var c = texture.channels; - - // Check texture shape - check( - w > 0 && w <= limits.maxTextureSize && h > 0 && h <= limits.maxTextureSize, - 'invalid texture shape'); - check( - w === h, - 'cube map must be square'); - check( - info.wrapS === GL_CLAMP_TO_EDGE && info.wrapT === GL_CLAMP_TO_EDGE, - 'wrap mode not supported by cube map'); - - for (var i = 0; i < faces.length; ++i) { - var face = faces[i]; - check( - face.width === w && face.height === h, - 'inconsistent cube map face shape'); - if (info.genMipmaps) { - check(!face.compressed, - 'can not generate mipmap for compressed textures'); - check(face.mipmask === 1, - 'can not specify mipmaps and generate mipmaps'); - } else { - // TODO: check mip and filter mode + /** + * Checks if `value` is `NaN`. + * + * **Note:** This method is based on + * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as + * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for + * `undefined` and other non-number values. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + * @example + * + * _.isNaN(NaN); + * // => true + * + * _.isNaN(new Number(NaN)); + * // => true + * + * isNaN(undefined); + * // => true + * + * _.isNaN(undefined); + * // => false + */ + function isNaN(value) { + // An `NaN` primitive is the only value that is not equal to itself. + // Perform the `toStringTag` check first to avoid errors with some + // ActiveX objects in IE. + return isNumber(value) && value != +value; } - var mipmaps = face.images; - for (var j = 0; j < 16; ++j) { - var img = mipmaps[j]; - if (img) { - var mw = w >> j; - var mh = h >> j; - check(face.mipmask & (1 << j), 'missing mipmap data'); - check( - img.width === mw && - img.height === mh, - 'invalid shape for mip images'); - check( - img.format === texture.format && - img.internalformat === texture.internalformat && - img.type === texture.type, - 'incompatible type for mip image'); - - if (img.compressed) { - // TODO: check size for compressed images - } else if (img.data) { - check(img.data.byteLength === mw * mh * - Math.max(pixelSize(img.type, c), img.unpackAlignment), - 'invalid data for image, buffer size is inconsistent with image format'); - } else if (img.element) { - // TODO: check element can be loaded - } else if (img.copy) { - // TODO: check compatible format and type - } + /** + * Checks if `value` is a pristine native function. + * + * **Note:** This method can't reliably detect native functions in the presence + * of the core-js package because core-js circumvents this kind of detection. + * Despite multiple requests, the core-js maintainer has made it clear: any + * attempt to fix the detection will be obstructed. As a result, we're left + * with little choice but to throw an error. Unfortunately, this also affects + * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), + * which rely on core-js. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ + function isNative(value) { + if (isMaskable(value)) { + throw new Error(CORE_ERROR_TEXT); } + return baseIsNative(value); } - } -} - -var check$1 = extend(check, { - optional: checkOptional, - raise: raise, - commandRaise: commandRaise, - command: checkCommand, - parameter: checkParameter, - commandParameter: checkParameterCommand, - constructor: checkConstructor, - type: checkTypeOf, - commandType: checkCommandType, - isTypedArray: checkIsTypedArray, - nni: checkNonNegativeInt, - oneOf: checkOneOf, - shaderError: checkShaderError, - linkError: checkLinkError, - callSite: guessCallSite, - saveCommandRef: saveCommandRef, - saveDrawInfo: saveDrawCommandInfo, - framebufferFormat: checkFramebufferFormat, - guessCommand: guessCommand, - texture2D: checkTexture2D, - textureCube: checkTextureCube -}); - -var VARIABLE_COUNTER = 0; -var DYN_FUNC = 0; - -function DynamicVariable (type, data) { - this.id = (VARIABLE_COUNTER++); - this.type = type; - this.data = data; -} + /** + * Checks if `value` is `null`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `null`, else `false`. + * @example + * + * _.isNull(null); + * // => true + * + * _.isNull(void 0); + * // => false + */ + function isNull(value) { + return value === null; + } -function escapeStr (str) { - return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') -} + /** + * Checks if `value` is `null` or `undefined`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is nullish, else `false`. + * @example + * + * _.isNil(null); + * // => true + * + * _.isNil(void 0); + * // => true + * + * _.isNil(NaN); + * // => false + */ + function isNil(value) { + return value == null; + } -function splitParts (str) { - if (str.length === 0) { - return [] - } + /** + * Checks if `value` is classified as a `Number` primitive or object. + * + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are + * classified as numbers, use the `_.isFinite` method. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a number, else `false`. + * @example + * + * _.isNumber(3); + * // => true + * + * _.isNumber(Number.MIN_VALUE); + * // => true + * + * _.isNumber(Infinity); + * // => true + * + * _.isNumber('3'); + * // => false + */ + function isNumber(value) { + return typeof value == 'number' || + (isObjectLike(value) && baseGetTag(value) == numberTag); + } - var firstChar = str.charAt(0); - var lastChar = str.charAt(str.length - 1); + /** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ + function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; + } - if (str.length > 1 && - firstChar === lastChar && - (firstChar === '"' || firstChar === "'")) { - return ['"' + escapeStr(str.substr(1, str.length - 2)) + '"'] - } + /** + * Checks if `value` is classified as a `RegExp` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + * @example + * + * _.isRegExp(/abc/); + * // => true + * + * _.isRegExp('/abc/'); + * // => false + */ + var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; - var parts = /\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(str); - if (parts) { - return ( - splitParts(str.substr(0, parts.index)) - .concat(splitParts(parts[1])) - .concat(splitParts(str.substr(parts.index + parts[0].length))) - ) - } + /** + * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 + * double precision number which isn't the result of a rounded unsafe integer. + * + * **Note:** This method is based on + * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. + * @example + * + * _.isSafeInteger(3); + * // => true + * + * _.isSafeInteger(Number.MIN_VALUE); + * // => false + * + * _.isSafeInteger(Infinity); + * // => false + * + * _.isSafeInteger('3'); + * // => false + */ + function isSafeInteger(value) { + return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; + } - var subparts = str.split('.'); - if (subparts.length === 1) { - return ['"' + escapeStr(str) + '"'] - } + /** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ + var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; - var result = []; - for (var i = 0; i < subparts.length; ++i) { - result = result.concat(splitParts(subparts[i])); - } - return result -} + /** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a string, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ + function isString(value) { + return typeof value == 'string' || + (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); + } -function toAccessorString (str) { - return '[' + splitParts(str).join('][') + ']' -} + /** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ + function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); + } -function defineDynamic (type, data) { - return new DynamicVariable(type, toAccessorString(data + '')) -} + /** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ + var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; -function isDynamic (x) { - return (typeof x === 'function' && !x._reglType) || - x instanceof DynamicVariable -} + /** + * Checks if `value` is `undefined`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ + function isUndefined(value) { + return value === undefined; + } -function unbox (x, path) { - if (typeof x === 'function') { - return new DynamicVariable(DYN_FUNC, x) - } - return x -} + /** + * Checks if `value` is classified as a `WeakMap` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. + * @example + * + * _.isWeakMap(new WeakMap); + * // => true + * + * _.isWeakMap(new Map); + * // => false + */ + function isWeakMap(value) { + return isObjectLike(value) && getTag(value) == weakMapTag; + } -var dynamic = { - DynamicVariable: DynamicVariable, - define: defineDynamic, - isDynamic: isDynamic, - unbox: unbox, - accessor: toAccessorString -}; + /** + * Checks if `value` is classified as a `WeakSet` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. + * @example + * + * _.isWeakSet(new WeakSet); + * // => true + * + * _.isWeakSet(new Set); + * // => false + */ + function isWeakSet(value) { + return isObjectLike(value) && baseGetTag(value) == weakSetTag; + } -/* globals requestAnimationFrame, cancelAnimationFrame */ -var raf = { - next: typeof requestAnimationFrame === 'function' - ? function (cb) { return requestAnimationFrame(cb) } - : function (cb) { return setTimeout(cb, 16) }, - cancel: typeof cancelAnimationFrame === 'function' - ? function (raf) { return cancelAnimationFrame(raf) } - : clearTimeout -}; + /** + * Checks if `value` is less than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + * @see _.gt + * @example + * + * _.lt(1, 3); + * // => true + * + * _.lt(3, 3); + * // => false + * + * _.lt(3, 1); + * // => false + */ + var lt = createRelationalOperation(baseLt); -/* globals performance */ -var clock = (typeof performance !== 'undefined' && performance.now) - ? function () { return performance.now() } - : function () { return +(new Date()) }; + /** + * Checks if `value` is less than or equal to `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than or equal to + * `other`, else `false`. + * @see _.gte + * @example + * + * _.lte(1, 3); + * // => true + * + * _.lte(3, 3); + * // => true + * + * _.lte(3, 1); + * // => false + */ + var lte = createRelationalOperation(function(value, other) { + return value <= other; + }); -function createStringStore () { - var stringIds = {'': 0}; - var stringValues = ['']; - return { - id: function (str) { - var result = stringIds[str]; - if (result) { - return result + /** + * Converts `value` to an array. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Array} Returns the converted array. + * @example + * + * _.toArray({ 'a': 1, 'b': 2 }); + * // => [1, 2] + * + * _.toArray('abc'); + * // => ['a', 'b', 'c'] + * + * _.toArray(1); + * // => [] + * + * _.toArray(null); + * // => [] + */ + function toArray(value) { + if (!value) { + return []; } - result = stringIds[str] = stringValues.length; - stringValues.push(str); - return result - }, + if (isArrayLike(value)) { + return isString(value) ? stringToArray(value) : copyArray(value); + } + if (symIterator && value[symIterator]) { + return iteratorToArray(value[symIterator]()); + } + var tag = getTag(value), + func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); - str: function (id) { - return stringValues[id] + return func(value); } - } -} - -// Context and canvas creation helper functions -function createCanvas (element, onDone, pixelRatio) { - var canvas = document.createElement('canvas'); - extend(canvas.style, { - border: 0, - margin: 0, - padding: 0, - top: 0, - left: 0 - }); - element.appendChild(canvas); - - if (element === document.body) { - canvas.style.position = 'absolute'; - extend(element.style, { - margin: 0, - padding: 0 - }); - } - function resize () { - var w = window.innerWidth; - var h = window.innerHeight; - if (element !== document.body) { - var bounds = element.getBoundingClientRect(); - w = bounds.right - bounds.left; - h = bounds.bottom - bounds.top; + /** + * Converts `value` to a finite number. + * + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 + */ + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; + } + return value === value ? value : 0; } - canvas.width = pixelRatio * w; - canvas.height = pixelRatio * h; - extend(canvas.style, { - width: w + 'px', - height: h + 'px' - }); - } - window.addEventListener('resize', resize, false); - - function onDestroy () { - window.removeEventListener('resize', resize); - element.removeChild(canvas); - } - - resize(); - - return { - canvas: canvas, - onDestroy: onDestroy - } -} + /** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ + function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; -function createContext (canvas, contexAttributes) { - function get (name) { - try { - return canvas.getContext(name, contexAttributes) - } catch (e) { - return null + return result === result ? (remainder ? result - remainder : result) : 0; } - } - return ( - get('webgl') || - get('experimental-webgl') || - get('webgl-experimental') - ) -} - -function isHTMLElement (obj) { - return ( - typeof obj.nodeName === 'string' && - typeof obj.appendChild === 'function' && - typeof obj.getBoundingClientRect === 'function' - ) -} - -function isWebGLContext (obj) { - return ( - typeof obj.drawArrays === 'function' || - typeof obj.drawElements === 'function' - ) -} - -function parseExtensions (input) { - if (typeof input === 'string') { - return input.split() - } - check$1(Array.isArray(input), 'invalid extension array'); - return input -} - -function getElement (desc) { - if (typeof desc === 'string') { - check$1(typeof document !== 'undefined', 'not supported outside of DOM'); - return document.querySelector(desc) - } - return desc -} -function parseArgs (args_) { - var args = args_ || {}; - var element, container, canvas, gl; - var contextAttributes = {}; - var extensions = []; - var optionalExtensions = []; - var pixelRatio = (typeof window === 'undefined' ? 1 : window.devicePixelRatio); - var profile = false; - var onDone = function (err) { - if (err) { - check$1.raise(err); - } - }; - var onDestroy = function () {}; - if (typeof args === 'string') { - check$1( - typeof document !== 'undefined', - 'selector queries only supported in DOM enviroments'); - element = document.querySelector(args); - check$1(element, 'invalid query string for element'); - } else if (typeof args === 'object') { - if (isHTMLElement(args)) { - element = args; - } else if (isWebGLContext(args)) { - gl = args; - canvas = gl.canvas; - } else { - check$1.constructor(args); - if ('gl' in args) { - gl = args.gl; - } else if ('canvas' in args) { - canvas = getElement(args.canvas); - } else if ('container' in args) { - container = getElement(args.container); - } - if ('attributes' in args) { - contextAttributes = args.attributes; - check$1.type(contextAttributes, 'object', 'invalid context attributes'); - } - if ('extensions' in args) { - extensions = parseExtensions(args.extensions); - } - if ('optionalExtensions' in args) { - optionalExtensions = parseExtensions(args.optionalExtensions); + /** + * Converts `value` to an integer suitable for use as the length of an + * array-like object. + * + * **Note:** This method is based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toLength(3.2); + * // => 3 + * + * _.toLength(Number.MIN_VALUE); + * // => 0 + * + * _.toLength(Infinity); + * // => 4294967295 + * + * _.toLength('3.2'); + * // => 3 + */ + function toLength(value) { + return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; + } + + /** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ + function toNumber(value) { + if (typeof value == 'number') { + return value; } - if ('onDone' in args) { - check$1.type( - args.onDone, 'function', - 'invalid or missing onDone callback'); - onDone = args.onDone; + if (isSymbol(value)) { + return NAN; } - if ('profile' in args) { - profile = !!args.profile; + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? (other + '') : other; } - if ('pixelRatio' in args) { - pixelRatio = +args.pixelRatio; - check$1(pixelRatio > 0, 'invalid pixel ratio'); + if (typeof value != 'string') { + return value === 0 ? value : +value; } + value = baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); } - } else { - check$1.raise('invalid arguments to regl'); - } - if (element) { - if (element.nodeName.toLowerCase() === 'canvas') { - canvas = element; - } else { - container = element; + /** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ + function toPlainObject(value) { + return copyObject(value, keysIn(value)); } - } - if (!gl) { - if (!canvas) { - check$1( - typeof document !== 'undefined', - 'must manually specify webgl context outside of DOM environments'); - var result = createCanvas(container || document.body, onDone, pixelRatio); - if (!result) { - return null - } - canvas = result.canvas; - onDestroy = result.onDestroy; + /** + * Converts `value` to a safe integer. A safe integer can be compared and + * represented correctly. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toSafeInteger(3.2); + * // => 3 + * + * _.toSafeInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toSafeInteger(Infinity); + * // => 9007199254740991 + * + * _.toSafeInteger('3.2'); + * // => 3 + */ + function toSafeInteger(value) { + return value + ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) + : (value === 0 ? value : 0); } - gl = createContext(canvas, contextAttributes); - } - - if (!gl) { - onDestroy(); - onDone('webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org'); - return null - } - - return { - gl: gl, - canvas: canvas, - container: container, - extensions: extensions, - optionalExtensions: optionalExtensions, - pixelRatio: pixelRatio, - profile: profile, - onDone: onDone, - onDestroy: onDestroy - } -} - -function createExtensionCache (gl, config) { - var extensions = {}; - - function tryLoadExtension (name_) { - check$1.type(name_, 'string', 'extension name must be string'); - var name = name_.toLowerCase(); - var ext; - try { - ext = extensions[name] = gl.getExtension(name); - } catch (e) {} - return !!ext - } - for (var i = 0; i < config.extensions.length; ++i) { - var name = config.extensions[i]; - if (!tryLoadExtension(name)) { - config.onDestroy(); - config.onDone('"' + name + '" extension is not supported by the current WebGL context, try upgrading your system or a different browser'); - return null + /** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ + function toString(value) { + return value == null ? '' : baseToString(value); } - } - config.optionalExtensions.forEach(tryLoadExtension); + /*------------------------------------------------------------------------*/ - return { - extensions: extensions, - restore: function () { - Object.keys(extensions).forEach(function (name) { - if (!tryLoadExtension(name)) { - throw new Error('(regl): error restoring extension ' + name) + /** + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object` and is loosely based on + * [`Object.assign`](https://mdn.io/Object/assign). + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assignIn + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assign({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'c': 3 } + */ + var assign = createAssigner(function(object, source) { + if (isPrototype(source) || isArrayLike(source)) { + copyObject(source, keys(source), object); + return; + } + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + assignValue(object, key, source[key]); } - }); - } - } -} + } + }); -var GL_SUBPIXEL_BITS = 0x0D50; -var GL_RED_BITS = 0x0D52; -var GL_GREEN_BITS = 0x0D53; -var GL_BLUE_BITS = 0x0D54; -var GL_ALPHA_BITS = 0x0D55; -var GL_DEPTH_BITS = 0x0D56; -var GL_STENCIL_BITS = 0x0D57; - -var GL_ALIASED_POINT_SIZE_RANGE = 0x846D; -var GL_ALIASED_LINE_WIDTH_RANGE = 0x846E; - -var GL_MAX_TEXTURE_SIZE = 0x0D33; -var GL_MAX_VIEWPORT_DIMS = 0x0D3A; -var GL_MAX_VERTEX_ATTRIBS = 0x8869; -var GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB; -var GL_MAX_VARYING_VECTORS = 0x8DFC; -var GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; -var GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; -var GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872; -var GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD; -var GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; -var GL_MAX_RENDERBUFFER_SIZE = 0x84E8; - -var GL_VENDOR = 0x1F00; -var GL_RENDERER = 0x1F01; -var GL_VERSION = 0x1F02; -var GL_SHADING_LANGUAGE_VERSION = 0x8B8C; - -var GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; - -var GL_MAX_COLOR_ATTACHMENTS_WEBGL = 0x8CDF; -var GL_MAX_DRAW_BUFFERS_WEBGL = 0x8824; + /** + * This method is like `_.assign` except that it iterates over own and + * inherited source properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assign + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assignIn({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } + */ + var assignIn = createAssigner(function(object, source) { + copyObject(source, keysIn(source), object); + }); -var wrapLimits = function (gl, extensions) { - var maxAnisotropic = 1; - if (extensions.ext_texture_filter_anisotropic) { - maxAnisotropic = gl.getParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); - } + /** + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extendWith + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignInWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keysIn(source), object, customizer); + }); - var maxDrawbuffers = 1; - var maxColorAttachments = 1; - if (extensions.webgl_draw_buffers) { - maxDrawbuffers = gl.getParameter(GL_MAX_DRAW_BUFFERS_WEBGL); - maxColorAttachments = gl.getParameter(GL_MAX_COLOR_ATTACHMENTS_WEBGL); - } + /** + * This method is like `_.assign` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignInWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keys(source), object, customizer); + }); - return { - // drawing buffer bit depth - colorBits: [ - gl.getParameter(GL_RED_BITS), - gl.getParameter(GL_GREEN_BITS), - gl.getParameter(GL_BLUE_BITS), - gl.getParameter(GL_ALPHA_BITS) - ], - depthBits: gl.getParameter(GL_DEPTH_BITS), - stencilBits: gl.getParameter(GL_STENCIL_BITS), - subpixelBits: gl.getParameter(GL_SUBPIXEL_BITS), + /** + * Creates an array of values corresponding to `paths` of `object`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Array} Returns the picked values. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _.at(object, ['a[0].b.c', 'a[1]']); + * // => [3, 4] + */ + var at = flatRest(baseAt); - // supported extensions - extensions: Object.keys(extensions).filter(function (ext) { - return !!extensions[ext] - }), + /** + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given, its own enumerable string keyed properties + * are assigned to the created object. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Object + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @returns {Object} Returns the new object. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * function Circle() { + * Shape.call(this); + * } + * + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); + * + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true + */ + function create(prototype, properties) { + var result = baseCreate(prototype); + return properties == null ? result : baseAssign(result, properties); + } - // max aniso samples - maxAnisotropic: maxAnisotropic, + /** + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep + * @example + * + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var defaults = baseRest(function(object, sources) { + object = Object(object); - // max draw buffers - maxDrawbuffers: maxDrawbuffers, - maxColorAttachments: maxColorAttachments, + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; - // point and line size ranges - pointSizeDims: gl.getParameter(GL_ALIASED_POINT_SIZE_RANGE), - lineWidthDims: gl.getParameter(GL_ALIASED_LINE_WIDTH_RANGE), - maxViewportDims: gl.getParameter(GL_MAX_VIEWPORT_DIMS), - maxCombinedTextureUnits: gl.getParameter(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS), - maxCubeMapSize: gl.getParameter(GL_MAX_CUBE_MAP_TEXTURE_SIZE), - maxRenderbufferSize: gl.getParameter(GL_MAX_RENDERBUFFER_SIZE), - maxTextureUnits: gl.getParameter(GL_MAX_TEXTURE_IMAGE_UNITS), - maxTextureSize: gl.getParameter(GL_MAX_TEXTURE_SIZE), - maxAttributes: gl.getParameter(GL_MAX_VERTEX_ATTRIBS), - maxVertexUniforms: gl.getParameter(GL_MAX_VERTEX_UNIFORM_VECTORS), - maxVertexTextureUnits: gl.getParameter(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS), - maxVaryingVectors: gl.getParameter(GL_MAX_VARYING_VECTORS), - maxFragmentUniforms: gl.getParameter(GL_MAX_FRAGMENT_UNIFORM_VECTORS), + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } - // vendor info - glsl: gl.getParameter(GL_SHADING_LANGUAGE_VERSION), - renderer: gl.getParameter(GL_RENDERER), - vendor: gl.getParameter(GL_VENDOR), - version: gl.getParameter(GL_VERSION) - } -}; + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } -function isNDArrayLike (obj) { - return ( - !!obj && - typeof obj === 'object' && - Array.isArray(obj.shape) && - Array.isArray(obj.stride) && - typeof obj.offset === 'number' && - obj.shape.length === obj.stride.length && - (Array.isArray(obj.data) || - isTypedArray(obj.data))) -} + return object; + }); -var values = function (obj) { - return Object.keys(obj).map(function (key) { return obj[key] }) -}; + /** + * This method is like `_.defaults` except that it recursively assigns + * default properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaults + * @example + * + * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); + * // => { 'a': { 'b': 2, 'c': 3 } } + */ + var defaultsDeep = baseRest(function(args) { + args.push(undefined, customDefaultsMerge); + return apply(mergeWith, undefined, args); + }); -function loop (n, f) { - var result = Array(n); - for (var i = 0; i < n; ++i) { - result[i] = f(i); - } - return result -} + /** + * This method is like `_.find` except that it returns the key of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findKey(users, function(o) { return o.age < 40; }); + * // => 'barney' (iteration order is not guaranteed) + * + * // The `_.matches` iteratee shorthand. + * _.findKey(users, { 'age': 1, 'active': true }); + * // => 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findKey(users, 'active'); + * // => 'barney' + */ + function findKey(object, predicate) { + return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); + } -var GL_BYTE$1 = 5120; -var GL_UNSIGNED_BYTE$2 = 5121; -var GL_SHORT$1 = 5122; -var GL_UNSIGNED_SHORT$1 = 5123; -var GL_INT$1 = 5124; -var GL_UNSIGNED_INT$1 = 5125; -var GL_FLOAT$2 = 5126; + /** + * This method is like `_.findKey` except that it iterates over elements of + * a collection in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findLastKey(users, function(o) { return o.age < 40; }); + * // => returns 'pebbles' assuming `_.findKey` returns 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.findLastKey(users, { 'age': 36, 'active': true }); + * // => 'barney' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findLastKey(users, 'active'); + * // => 'pebbles' + */ + function findLastKey(object, predicate) { + return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); + } -var bufferPool = loop(8, function () { - return [] -}); + /** + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + */ + function forIn(object, iteratee) { + return object == null + ? object + : baseFor(object, getIteratee(iteratee, 3), keysIn); + } -function nextPow16 (v) { - for (var i = 16; i <= (1 << 28); i *= 16) { - if (v <= i) { - return i + /** + * This method is like `_.forIn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forIn + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forInRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. + */ + function forInRight(object, iteratee) { + return object == null + ? object + : baseForRight(object, getIteratee(iteratee, 3), keysIn); } - } - return 0 -} -function log2 (v) { - var r, shift; - r = (v > 0xFFFF) << 4; - v >>>= r; - shift = (v > 0xFF) << 3; - v >>>= shift; r |= shift; - shift = (v > 0xF) << 2; - v >>>= shift; r |= shift; - shift = (v > 0x3) << 1; - v >>>= shift; r |= shift; - return r | (v >> 1) -} + /** + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ + function forOwn(object, iteratee) { + return object && baseForOwn(object, getIteratee(iteratee, 3)); + } -function alloc (n) { - var sz = nextPow16(n); - var bin = bufferPool[log2(sz) >> 2]; - if (bin.length > 0) { - return bin.pop() - } - return new ArrayBuffer(sz) -} + /** + * This method is like `_.forOwn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwn + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. + */ + function forOwnRight(object, iteratee) { + return object && baseForOwnRight(object, getIteratee(iteratee, 3)); + } -function free (buf) { - bufferPool[log2(buf.byteLength) >> 2].push(buf); -} + /** + * Creates an array of function property names from own enumerable properties + * of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functionsIn + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functions(new Foo); + * // => ['a', 'b'] + */ + function functions(object) { + return object == null ? [] : baseFunctions(object, keys(object)); + } -function allocType (type, n) { - var result = null; - switch (type) { - case GL_BYTE$1: - result = new Int8Array(alloc(n), 0, n); - break - case GL_UNSIGNED_BYTE$2: - result = new Uint8Array(alloc(n), 0, n); - break - case GL_SHORT$1: - result = new Int16Array(alloc(2 * n), 0, n); - break - case GL_UNSIGNED_SHORT$1: - result = new Uint16Array(alloc(2 * n), 0, n); - break - case GL_INT$1: - result = new Int32Array(alloc(4 * n), 0, n); - break - case GL_UNSIGNED_INT$1: - result = new Uint32Array(alloc(4 * n), 0, n); - break - case GL_FLOAT$2: - result = new Float32Array(alloc(4 * n), 0, n); - break - default: - return null - } - if (result.length !== n) { - return result.subarray(0, n) - } - return result -} + /** + * Creates an array of function property names from own and inherited + * enumerable properties of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functions + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ + function functionsIn(object) { + return object == null ? [] : baseFunctions(object, keysIn(object)); + } -function freeType (array) { - free(array.buffer); -} + /** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; + } -var pool = { - alloc: alloc, - free: free, - allocType: allocType, - freeType: freeType -}; + /** + * Checks if `path` is a direct property of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); + * // => false + */ + function has(object, path) { + return object != null && hasPath(object, path, baseHas); + } -var flattenUtils = { - shape: arrayShape$1, - flatten: flattenArray -}; + /** + * Checks if `path` is a direct or inherited property of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false + */ + function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); + } -function flatten1D (array, nx, out) { - for (var i = 0; i < nx; ++i) { - out[i] = array[i]; - } -} + /** + * Creates an object composed of the inverted keys and values of `object`. + * If `object` contains duplicate values, subsequent values overwrite + * property assignments of previous values. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Object + * @param {Object} object The object to invert. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invert(object); + * // => { '1': 'c', '2': 'b' } + */ + var invert = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } -function flatten2D (array, nx, ny, out) { - var ptr = 0; - for (var i = 0; i < nx; ++i) { - var row = array[i]; - for (var j = 0; j < ny; ++j) { - out[ptr++] = row[j]; - } - } -} + result[value] = key; + }, constant(identity)); -function flatten3D (array, nx, ny, nz, out, ptr_) { - var ptr = ptr_; - for (var i = 0; i < nx; ++i) { - var row = array[i]; - for (var j = 0; j < ny; ++j) { - var col = row[j]; - for (var k = 0; k < nz; ++k) { - out[ptr++] = col[k]; + /** + * This method is like `_.invert` except that the inverted object is generated + * from the results of running each element of `object` thru `iteratee`. The + * corresponding inverted value of each inverted key is an array of keys + * responsible for generating the inverted value. The iteratee is invoked + * with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.1.0 + * @category Object + * @param {Object} object The object to invert. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invertBy(object); + * // => { '1': ['a', 'c'], '2': ['b'] } + * + * _.invertBy(object, function(value) { + * return 'group' + value; + * }); + * // => { 'group1': ['a', 'c'], 'group2': ['b'] } + */ + var invertBy = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); } - } - } -} -function flattenRec (array, shape, level, out, ptr) { - var stride = 1; - for (var i = level + 1; i < shape.length; ++i) { - stride *= shape[i]; - } - var n = shape[level]; - if (shape.length - level === 4) { - var nx = shape[level + 1]; - var ny = shape[level + 2]; - var nz = shape[level + 3]; - for (i = 0; i < n; ++i) { - flatten3D(array[i], nx, ny, nz, out, ptr); - ptr += stride; - } - } else { - for (i = 0; i < n; ++i) { - flattenRec(array[i], shape, level + 1, out, ptr); - ptr += stride; - } - } -} + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [key]; + } + }, getIteratee); -function flattenArray (array, shape, type, out_) { - var sz = 1; - if (shape.length) { - for (var i = 0; i < shape.length; ++i) { - sz *= shape[i]; - } - } else { - sz = 0; - } - var out = out_ || pool.allocType(type, sz); - switch (shape.length) { - case 0: - break - case 1: - flatten1D(array, shape[0], out); - break - case 2: - flatten2D(array, shape[0], shape[1], out); - break - case 3: - flatten3D(array, shape[0], shape[1], shape[2], out, 0); - break - default: - flattenRec(array, shape, 0, out, 0); - } - return out -} + /** + * Invokes the method at `path` of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + * @example + * + * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + * + * _.invoke(object, 'a[0].b.c.slice', 1, 3); + * // => [2, 3] + */ + var invoke = baseRest(baseInvoke); -function arrayShape$1 (array_) { - var shape = []; - for (var array = array_; array.length; array = array[0]) { - shape.push(array.length); - } - return shape -} + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } -var int8 = 5120; -var int16 = 5122; -var int32 = 5124; -var uint8 = 5121; -var uint16 = 5123; -var uint32 = 5125; -var float = 5126; -var float32 = 5126; -var glTypes = { - int8: int8, - int16: int16, - int32: int32, - uint8: uint8, - uint16: uint16, - uint32: uint32, - float: float, - float32: float32 -}; + /** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ + function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); + } -var dynamic$1 = 35048; -var stream = 35040; -var usageTypes = { - dynamic: dynamic$1, - stream: stream, - "static": 35044 -}; + /** + * The opposite of `_.mapValues`; this method creates an object with the + * same values as `object` and keys generated by running each own enumerable + * string keyed property of `object` thru `iteratee`. The iteratee is invoked + * with three arguments: (value, key, object). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapValues + * @example + * + * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { + * return key + value; + * }); + * // => { 'a1': 1, 'b2': 2 } + */ + function mapKeys(object, iteratee) { + var result = {}; + iteratee = getIteratee(iteratee, 3); -var arrayFlatten = flattenUtils.flatten; -var arrayShape = flattenUtils.shape; + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, iteratee(value, key, object), value); + }); + return result; + } -var GL_STATIC_DRAW = 0x88E4; -var GL_STREAM_DRAW = 0x88E0; + /** + * Creates an object with the same keys as `object` and values generated + * by running each own enumerable string keyed property of `object` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapKeys + * @example + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * _.mapValues(users, function(o) { return o.age; }); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * + * // The `_.property` iteratee shorthand. + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ + function mapValues(object, iteratee) { + var result = {}; + iteratee = getIteratee(iteratee, 3); -var GL_UNSIGNED_BYTE$1 = 5121; -var GL_FLOAT$1 = 5126; + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, key, iteratee(value, key, object)); + }); + return result; + } -var DTYPES_SIZES = []; -DTYPES_SIZES[5120] = 1; // int8 -DTYPES_SIZES[5122] = 2; // int16 -DTYPES_SIZES[5124] = 4; // int32 -DTYPES_SIZES[5121] = 1; // uint8 -DTYPES_SIZES[5123] = 2; // uint16 -DTYPES_SIZES[5125] = 4; // uint32 -DTYPES_SIZES[5126] = 4; // float32 + /** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ + var merge = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); + }); -function typedArrayCode (data) { - return arrayTypes[Object.prototype.toString.call(data)] | 0 -} + /** + * This method is like `_.merge` except that it accepts `customizer` which + * is invoked to produce the merged values of the destination and source + * properties. If `customizer` returns `undefined`, merging is handled by the + * method instead. The `customizer` is invoked with six arguments: + * (objValue, srcValue, key, object, source, stack). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} customizer The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * function customizer(objValue, srcValue) { + * if (_.isArray(objValue)) { + * return objValue.concat(srcValue); + * } + * } + * + * var object = { 'a': [1], 'b': [2] }; + * var other = { 'a': [3], 'b': [4] }; + * + * _.mergeWith(object, other, customizer); + * // => { 'a': [1, 3], 'b': [2, 4] } + */ + var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { + baseMerge(object, source, srcIndex, customizer); + }); -function copyArray (out, inp) { - for (var i = 0; i < inp.length; ++i) { - out[i] = inp[i]; - } -} + /** + * The opposite of `_.pick`; this method creates an object composed of the + * own and inherited enumerable property paths of `object` that are not omitted. + * + * **Note:** This method is considerably slower than `_.pick`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to omit. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.omit(object, ['a', 'c']); + * // => { 'b': '2' } + */ + var omit = flatRest(function(object, paths) { + var result = {}; + if (object == null) { + return result; + } + var isDeep = false; + paths = arrayMap(paths, function(path) { + path = castPath(path, object); + isDeep || (isDeep = path.length > 1); + return path; + }); + copyObject(object, getAllKeysIn(object), result); + if (isDeep) { + result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); + } + var length = paths.length; + while (length--) { + baseUnset(result, paths[length]); + } + return result; + }); -function transpose ( - result, data, shapeX, shapeY, strideX, strideY, offset) { - var ptr = 0; - for (var i = 0; i < shapeX; ++i) { - for (var j = 0; j < shapeY; ++j) { - result[ptr++] = data[strideX * i + strideY * j + offset]; + /** + * The opposite of `_.pickBy`; this method creates an object composed of + * the own and inherited enumerable string keyed properties of `object` that + * `predicate` doesn't return truthy for. The predicate is invoked with two + * arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.omitBy(object, _.isNumber); + * // => { 'b': '2' } + */ + function omitBy(object, predicate) { + return pickBy(object, negate(getIteratee(predicate))); } - } -} - -function wrapBufferState (gl, stats, config) { - var bufferCount = 0; - var bufferSet = {}; - function REGLBuffer (type) { - this.id = bufferCount++; - this.buffer = gl.createBuffer(); - this.type = type; - this.usage = GL_STATIC_DRAW; - this.byteLength = 0; - this.dimension = 1; - this.dtype = GL_UNSIGNED_BYTE$1; - - this.persistentData = null; + /** + * Creates an object composed of the picked `object` properties. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } + */ + var pick = flatRest(function(object, paths) { + return object == null ? {} : basePick(object, paths); + }); - if (config.profile) { - this.stats = {size: 0}; + /** + * Creates an object composed of the `object` properties `predicate` returns + * truthy for. The predicate is invoked with two arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pickBy(object, _.isNumber); + * // => { 'a': 1, 'c': 3 } + */ + function pickBy(object, predicate) { + if (object == null) { + return {}; + } + var props = arrayMap(getAllKeysIn(object), function(prop) { + return [prop]; + }); + predicate = getIteratee(predicate); + return basePickBy(object, props, function(value, path) { + return predicate(value, path[0]); + }); } - } - REGLBuffer.prototype.bind = function () { - gl.bindBuffer(this.type, this.buffer); - }; + /** + * This method is like `_.get` except that if the resolved value is a + * function it's invoked with the `this` binding of its parent object and + * its result is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to resolve. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; + * + * _.result(object, 'a[0].b.c1'); + * // => 3 + * + * _.result(object, 'a[0].b.c2'); + * // => 4 + * + * _.result(object, 'a[0].b.c3', 'default'); + * // => 'default' + * + * _.result(object, 'a[0].b.c3', _.constant('default')); + * // => 'default' + */ + function result(object, path, defaultValue) { + path = castPath(path, object); - REGLBuffer.prototype.destroy = function () { - destroy(this); - }; + var index = -1, + length = path.length; - var streamPool = []; + // Ensure the loop is entered when path is empty. + if (!length) { + length = 1; + object = undefined; + } + while (++index < length) { + var value = object == null ? undefined : object[toKey(path[index])]; + if (value === undefined) { + index = length; + value = defaultValue; + } + object = isFunction(value) ? value.call(object) : value; + } + return object; + } - function createStream (type, data) { - var buffer = streamPool.pop(); - if (!buffer) { - buffer = new REGLBuffer(type); + /** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ + function set(object, path, value) { + return object == null ? object : baseSet(object, path, value); } - buffer.bind(); - initBufferFromData(buffer, data, GL_STREAM_DRAW, 0, 1, false); - return buffer - } - function destroyStream (stream$$1) { - streamPool.push(stream$$1); - } + /** + * This method is like `_.set` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.setWith(object, '[0][1]', 'a', Object); + * // => { '0': { '1': 'a' } } + */ + function setWith(object, path, value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseSet(object, path, value, customizer); + } - function initBufferFromTypedArray (buffer, data, usage) { - buffer.byteLength = data.byteLength; - gl.bufferData(buffer.type, data, usage); - } + /** + * Creates an array of own enumerable string keyed-value pairs for `object` + * which can be consumed by `_.fromPairs`. If `object` is a map or set, its + * entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entries + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairs(new Foo); + * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) + */ + var toPairs = createToPairs(keys); - function initBufferFromData (buffer, data, usage, dtype, dimension, persist) { - var shape; - buffer.usage = usage; - if (Array.isArray(data)) { - buffer.dtype = dtype || GL_FLOAT$1; - if (data.length > 0) { - var flatData; - if (Array.isArray(data[0])) { - shape = arrayShape(data); - var dim = 1; - for (var i = 1; i < shape.length; ++i) { - dim *= shape[i]; - } - buffer.dimension = dim; - flatData = arrayFlatten(data, shape, buffer.dtype); - initBufferFromTypedArray(buffer, flatData, usage); - if (persist) { - buffer.persistentData = flatData; - } else { - pool.freeType(flatData); - } - } else if (typeof data[0] === 'number') { - buffer.dimension = dimension; - var typedData = pool.allocType(buffer.dtype, data.length); - copyArray(typedData, data); - initBufferFromTypedArray(buffer, typedData, usage); - if (persist) { - buffer.persistentData = typedData; - } else { - pool.freeType(typedData); - } - } else if (isTypedArray(data[0])) { - buffer.dimension = data[0].length; - buffer.dtype = dtype || typedArrayCode(data[0]) || GL_FLOAT$1; - flatData = arrayFlatten( - data, - [data.length, data[0].length], - buffer.dtype); - initBufferFromTypedArray(buffer, flatData, usage); - if (persist) { - buffer.persistentData = flatData; - } else { - pool.freeType(flatData); - } - } else { - check$1.raise('invalid buffer data'); - } - } - } else if (isTypedArray(data)) { - buffer.dtype = dtype || typedArrayCode(data); - buffer.dimension = dimension; - initBufferFromTypedArray(buffer, data, usage); - if (persist) { - buffer.persistentData = new Uint8Array(new Uint8Array(data.buffer)); - } - } else if (isNDArrayLike(data)) { - shape = data.shape; - var stride = data.stride; - var offset = data.offset; - - var shapeX = 0; - var shapeY = 0; - var strideX = 0; - var strideY = 0; - if (shape.length === 1) { - shapeX = shape[0]; - shapeY = 1; - strideX = stride[0]; - strideY = 0; - } else if (shape.length === 2) { - shapeX = shape[0]; - shapeY = shape[1]; - strideX = stride[0]; - strideY = stride[1]; - } else { - check$1.raise('invalid shape'); - } + /** + * Creates an array of own and inherited enumerable string keyed-value pairs + * for `object` which can be consumed by `_.fromPairs`. If `object` is a map + * or set, its entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entriesIn + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairsIn(new Foo); + * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) + */ + var toPairsIn = createToPairs(keysIn); - buffer.dtype = dtype || typedArrayCode(data.data) || GL_FLOAT$1; - buffer.dimension = shapeY; + /** + * An alternative to `_.reduce`; this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own + * enumerable string keyed properties thru `iteratee`, with each invocation + * potentially mutating the `accumulator` object. If `accumulator` is not + * provided, a new object with the same `[[Prototype]]` will be used. The + * iteratee is invoked with four arguments: (accumulator, value, key, object). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 1.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @returns {*} Returns the accumulated value. + * @example + * + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; + * }, []); + * // => [4, 9] + * + * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } + */ + function transform(object, iteratee, accumulator) { + var isArr = isArray(object), + isArrLike = isArr || isBuffer(object) || isTypedArray(object); - var transposeData = pool.allocType(buffer.dtype, shapeX * shapeY); - transpose(transposeData, - data.data, - shapeX, shapeY, - strideX, strideY, - offset); - initBufferFromTypedArray(buffer, transposeData, usage); - if (persist) { - buffer.persistentData = transposeData; - } else { - pool.freeType(transposeData); + iteratee = getIteratee(iteratee, 4); + if (accumulator == null) { + var Ctor = object && object.constructor; + if (isArrLike) { + accumulator = isArr ? new Ctor : []; + } + else if (isObject(object)) { + accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; + } + else { + accumulator = {}; + } } - } else { - check$1.raise('invalid buffer data'); + (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; } - } - - function destroy (buffer) { - stats.bufferCount--; - - var handle = buffer.buffer; - check$1(handle, 'buffer must not be deleted already'); - gl.deleteBuffer(handle); - buffer.buffer = null; - delete bufferSet[buffer.id]; - } - - function createBuffer (options, type, deferInit, persistent) { - stats.bufferCount++; - var buffer = new REGLBuffer(type); - bufferSet[buffer.id] = buffer; + /** + * Removes the property at `path` of `object`. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 7 } }] }; + * _.unset(object, 'a[0].b.c'); + * // => true + * + * console.log(object); + * // => { 'a': [{ 'b': {} }] }; + * + * _.unset(object, ['a', '0', 'b', 'c']); + * // => true + * + * console.log(object); + * // => { 'a': [{ 'b': {} }] }; + */ + function unset(object, path) { + return object == null ? true : baseUnset(object, path); + } - function reglBuffer (options) { - var usage = GL_STATIC_DRAW; - var data = null; - var byteLength = 0; - var dtype = 0; - var dimension = 1; - if (Array.isArray(options) || - isTypedArray(options) || - isNDArrayLike(options)) { - data = options; - } else if (typeof options === 'number') { - byteLength = options | 0; - } else if (options) { - check$1.type( - options, 'object', - 'buffer arguments must be an object, a number or an array'); + /** + * This method is like `_.set` except that accepts `updater` to produce the + * value to set. Use `_.updateWith` to customize `path` creation. The `updater` + * is invoked with one argument: (value). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {Function} updater The function to produce the updated value. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.update(object, 'a[0].b.c', function(n) { return n * n; }); + * console.log(object.a[0].b.c); + * // => 9 + * + * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); + * console.log(object.x[0].y.z); + * // => 0 + */ + function update(object, path, updater) { + return object == null ? object : baseUpdate(object, path, castFunction(updater)); + } - if ('data' in options) { - check$1( - data === null || - Array.isArray(data) || - isTypedArray(data) || - isNDArrayLike(data), - 'invalid data for buffer'); - data = options.data; - } + /** + * This method is like `_.update` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.updateWith(object, '[0][1]', _.constant('a'), Object); + * // => { '0': { '1': 'a' } } + */ + function updateWith(object, path, updater, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); + } - if ('usage' in options) { - check$1.parameter(options.usage, usageTypes, 'invalid buffer usage'); - usage = usageTypes[options.usage]; - } + /** + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ + function values(object) { + return object == null ? [] : baseValues(object, keys(object)); + } - if ('type' in options) { - check$1.parameter(options.type, glTypes, 'invalid buffer type'); - dtype = glTypes[options.type]; - } + /** + * Creates an array of the own and inherited enumerable string keyed property + * values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.valuesIn(new Foo); + * // => [1, 2, 3] (iteration order is not guaranteed) + */ + function valuesIn(object) { + return object == null ? [] : baseValues(object, keysIn(object)); + } - if ('dimension' in options) { - check$1.type(options.dimension, 'number', 'invalid dimension'); - dimension = options.dimension | 0; - } + /*------------------------------------------------------------------------*/ - if ('length' in options) { - check$1.nni(byteLength, 'buffer length must be a nonnegative integer'); - byteLength = options.length | 0; - } + /** + * Clamps `number` within the inclusive `lower` and `upper` bounds. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Number + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + * @example + * + * _.clamp(-10, -5, 5); + * // => -5 + * + * _.clamp(10, -5, 5); + * // => 5 + */ + function clamp(number, lower, upper) { + if (upper === undefined) { + upper = lower; + lower = undefined; } - - buffer.bind(); - if (!data) { - gl.bufferData(buffer.type, byteLength, usage); - buffer.dtype = dtype || GL_UNSIGNED_BYTE$1; - buffer.usage = usage; - buffer.dimension = dimension; - buffer.byteLength = byteLength; - } else { - initBufferFromData(buffer, data, usage, dtype, dimension, persistent); + if (upper !== undefined) { + upper = toNumber(upper); + upper = upper === upper ? upper : 0; } - - if (config.profile) { - buffer.stats.size = buffer.byteLength * DTYPES_SIZES[buffer.dtype]; + if (lower !== undefined) { + lower = toNumber(lower); + lower = lower === lower ? lower : 0; } - - return reglBuffer + return baseClamp(toNumber(number), lower, upper); } - function setSubData (data, offset) { - check$1(offset + data.byteLength <= buffer.byteLength, - 'invalid buffer subdata call, buffer is too small. ' + ' Can\'t write data of size ' + data.byteLength + ' starting from offset ' + offset + ' to a buffer of size ' + buffer.byteLength); - - gl.bufferSubData(buffer.type, offset, data); + /** + * Checks if `n` is between `start` and up to, but not including, `end`. If + * `end` is not specified, it's set to `start` with `start` then set to `0`. + * If `start` is greater than `end` the params are swapped to support + * negative ranges. + * + * @static + * @memberOf _ + * @since 3.3.0 + * @category Number + * @param {number} number The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + * @see _.range, _.rangeRight + * @example + * + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + * + * _.inRange(-3, -2, -6); + * // => true + */ + function inRange(number, start, end) { + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + number = toNumber(number); + return baseInRange(number, start, end); } - function subdata (data, offset_) { - var offset = (offset_ || 0) | 0; - var shape; - buffer.bind(); - if (Array.isArray(data)) { - if (data.length > 0) { - if (typeof data[0] === 'number') { - var converted = pool.allocType(buffer.dtype, data.length); - copyArray(converted, data); - setSubData(converted, offset); - pool.freeType(converted); - } else if (Array.isArray(data[0]) || isTypedArray(data[0])) { - shape = arrayShape(data); - var flatData = arrayFlatten(data, shape, buffer.dtype); - setSubData(flatData, offset); - pool.freeType(flatData); - } else { - check$1.raise('invalid buffer data'); - } + /** + * Produces a random number between the inclusive `lower` and `upper` bounds. + * If only one argument is provided a number between `0` and the given number + * is returned. If `floating` is `true`, or either `lower` or `upper` are + * floats, a floating-point number is returned instead of an integer. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Number + * @param {number} [lower=0] The lower bound. + * @param {number} [upper=1] The upper bound. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(lower, upper, floating) { + if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { + upper = floating = undefined; + } + if (floating === undefined) { + if (typeof upper == 'boolean') { + floating = upper; + upper = undefined; } - } else if (isTypedArray(data)) { - setSubData(data, offset); - } else if (isNDArrayLike(data)) { - shape = data.shape; - var stride = data.stride; - - var shapeX = 0; - var shapeY = 0; - var strideX = 0; - var strideY = 0; - if (shape.length === 1) { - shapeX = shape[0]; - shapeY = 1; - strideX = stride[0]; - strideY = 0; - } else if (shape.length === 2) { - shapeX = shape[0]; - shapeY = shape[1]; - strideX = stride[0]; - strideY = stride[1]; - } else { - check$1.raise('invalid shape'); + else if (typeof lower == 'boolean') { + floating = lower; + lower = undefined; } - var dtype = Array.isArray(data.data) - ? buffer.dtype - : typedArrayCode(data.data); - - var transposeData = pool.allocType(dtype, shapeX * shapeY); - transpose(transposeData, - data.data, - shapeX, shapeY, - strideX, strideY, - data.offset); - setSubData(transposeData, offset); - pool.freeType(transposeData); - } else { - check$1.raise('invalid data for buffer subdata'); } - return reglBuffer - } - - if (!deferInit) { - reglBuffer(options); - } - - reglBuffer._reglType = 'buffer'; - reglBuffer._buffer = buffer; - reglBuffer.subdata = subdata; - if (config.profile) { - reglBuffer.stats = buffer.stats; - } - reglBuffer.destroy = function () { destroy(buffer); }; - - return reglBuffer - } - - function restoreBuffers () { - values(bufferSet).forEach(function (buffer) { - buffer.buffer = gl.createBuffer(); - gl.bindBuffer(buffer.type, buffer.buffer); - gl.bufferData( - buffer.type, buffer.persistentData || buffer.byteLength, buffer.usage); - }); - } - - if (config.profile) { - stats.getTotalBufferSize = function () { - var total = 0; - // TODO: Right now, the streams are not part of the total count. - Object.keys(bufferSet).forEach(function (key) { - total += bufferSet[key].stats.size; - }); - return total - }; - } - - return { - create: createBuffer, - - createStream: createStream, - destroyStream: destroyStream, - - clear: function () { - values(bufferSet).forEach(destroy); - streamPool.forEach(destroy); - }, - - getBuffer: function (wrapper) { - if (wrapper && wrapper._buffer instanceof REGLBuffer) { - return wrapper._buffer + if (lower === undefined && upper === undefined) { + lower = 0; + upper = 1; } - return null - }, - - restore: restoreBuffers, - - _initBuffer: initBufferFromData - } -} - -var points = 0; -var point = 0; -var lines = 1; -var line = 1; -var triangles = 4; -var triangle = 4; -var primTypes = { - points: points, - point: point, - lines: lines, - line: line, - triangles: triangles, - triangle: triangle, - "line loop": 2, - "line strip": 3, - "triangle strip": 5, - "triangle fan": 6 -}; - -var GL_POINTS = 0; -var GL_LINES = 1; -var GL_TRIANGLES = 4; - -var GL_BYTE$2 = 5120; -var GL_UNSIGNED_BYTE$3 = 5121; -var GL_SHORT$2 = 5122; -var GL_UNSIGNED_SHORT$2 = 5123; -var GL_INT$2 = 5124; -var GL_UNSIGNED_INT$2 = 5125; - -var GL_ELEMENT_ARRAY_BUFFER = 34963; - -var GL_STREAM_DRAW$1 = 0x88E0; -var GL_STATIC_DRAW$1 = 0x88E4; - -function wrapElementsState (gl, extensions, bufferState, stats) { - var elementSet = {}; - var elementCount = 0; - - var elementTypes = { - 'uint8': GL_UNSIGNED_BYTE$3, - 'uint16': GL_UNSIGNED_SHORT$2 - }; - - if (extensions.oes_element_index_uint) { - elementTypes.uint32 = GL_UNSIGNED_INT$2; - } - - function REGLElementBuffer (buffer) { - this.id = elementCount++; - elementSet[this.id] = this; - this.buffer = buffer; - this.primType = GL_TRIANGLES; - this.vertCount = 0; - this.type = 0; - } - - REGLElementBuffer.prototype.bind = function () { - this.buffer.bind(); - }; - - var bufferPool = []; - - function createElementStream (data) { - var result = bufferPool.pop(); - if (!result) { - result = new REGLElementBuffer(bufferState.create( - null, - GL_ELEMENT_ARRAY_BUFFER, - true, - false)._buffer); - } - initElements(result, data, GL_STREAM_DRAW$1, -1, -1, 0, 0); - return result - } - - function destroyElementStream (elements) { - bufferPool.push(elements); - } - - function initElements ( - elements, - data, - usage, - prim, - count, - byteLength, - type) { - elements.buffer.bind(); - if (data) { - var predictedType = type; - if (!type && ( - !isTypedArray(data) || - (isNDArrayLike(data) && !isTypedArray(data.data)))) { - predictedType = extensions.oes_element_index_uint - ? GL_UNSIGNED_INT$2 - : GL_UNSIGNED_SHORT$2; + else { + lower = toFinite(lower); + if (upper === undefined) { + upper = lower; + lower = 0; + } else { + upper = toFinite(upper); + } + } + if (lower > upper) { + var temp = lower; + lower = upper; + upper = temp; } - bufferState._initBuffer( - elements.buffer, - data, - usage, - predictedType, - 3); - } else { - gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, byteLength, usage); - elements.buffer.dtype = dtype || GL_UNSIGNED_BYTE$3; - elements.buffer.usage = usage; - elements.buffer.dimension = 3; - elements.buffer.byteLength = byteLength; - } - - var dtype = type; - if (!type) { - switch (elements.buffer.dtype) { - case GL_UNSIGNED_BYTE$3: - case GL_BYTE$2: - dtype = GL_UNSIGNED_BYTE$3; - break - - case GL_UNSIGNED_SHORT$2: - case GL_SHORT$2: - dtype = GL_UNSIGNED_SHORT$2; - break - - case GL_UNSIGNED_INT$2: - case GL_INT$2: - dtype = GL_UNSIGNED_INT$2; - break - - default: - check$1.raise('unsupported type for element array'); + if (floating || lower % 1 || upper % 1) { + var rand = nativeRandom(); + return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); } - elements.buffer.dtype = dtype; + return baseRandom(lower, upper); } - elements.type = dtype; - // Check oes_element_index_uint extension - check$1( - dtype !== GL_UNSIGNED_INT$2 || - !!extensions.oes_element_index_uint, - '32 bit element buffers not supported, enable oes_element_index_uint first'); + /*------------------------------------------------------------------------*/ - // try to guess default primitive type and arguments - var vertCount = count; - if (vertCount < 0) { - vertCount = elements.buffer.byteLength; - if (dtype === GL_UNSIGNED_SHORT$2) { - vertCount >>= 1; - } else if (dtype === GL_UNSIGNED_INT$2) { - vertCount >>= 2; - } - } - elements.vertCount = vertCount; + /** + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Foo Bar'); + * // => 'fooBar' + * + * _.camelCase('--foo-bar--'); + * // => 'fooBar' + * + * _.camelCase('__FOO_BAR__'); + * // => 'fooBar' + */ + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? capitalize(word) : word); + }); - // try to guess primitive type from cell dimension - var primType = prim; - if (prim < 0) { - primType = GL_TRIANGLES; - var dimension = elements.buffer.dimension; - if (dimension === 1) primType = GL_POINTS; - if (dimension === 2) primType = GL_LINES; - if (dimension === 3) primType = GL_TRIANGLES; + /** + * Converts the first character of `string` to upper case and the remaining + * to lower case. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. + * @example + * + * _.capitalize('FRED'); + * // => 'Fred' + */ + function capitalize(string) { + return upperFirst(toString(string).toLowerCase()); } - elements.primType = primType; - } - - function destroyElements (elements) { - stats.elementsCount--; - check$1(elements.buffer !== null, 'must not double destroy elements'); - delete elementSet[elements.id]; - elements.buffer.destroy(); - elements.buffer = null; - } + /** + * Deburrs `string` by converting + * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) + * letters to basic Latin letters and removing + * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to deburr. + * @returns {string} Returns the deburred string. + * @example + * + * _.deburr('déjà vu'); + * // => 'deja vu' + */ + function deburr(string) { + string = toString(string); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); + } - function createElements (options, persistent) { - var buffer = bufferState.create(null, GL_ELEMENT_ARRAY_BUFFER, true); - var elements = new REGLElementBuffer(buffer._buffer); - stats.elementsCount++; + /** + * Checks if `string` ends with the given target string. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search up to. + * @returns {boolean} Returns `true` if `string` ends with `target`, + * else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ + function endsWith(string, target, position) { + string = toString(string); + target = baseToString(target); - function reglElements (options) { - if (!options) { - buffer(); - elements.primType = GL_TRIANGLES; - elements.vertCount = 0; - elements.type = GL_UNSIGNED_BYTE$3; - } else if (typeof options === 'number') { - buffer(options); - elements.primType = GL_TRIANGLES; - elements.vertCount = options | 0; - elements.type = GL_UNSIGNED_BYTE$3; - } else { - var data = null; - var usage = GL_STATIC_DRAW$1; - var primType = -1; - var vertCount = -1; - var byteLength = 0; - var dtype = 0; - if (Array.isArray(options) || - isTypedArray(options) || - isNDArrayLike(options)) { - data = options; - } else { - check$1.type(options, 'object', 'invalid arguments for elements'); - if ('data' in options) { - data = options.data; - check$1( - Array.isArray(data) || - isTypedArray(data) || - isNDArrayLike(data), - 'invalid data for element buffer'); - } - if ('usage' in options) { - check$1.parameter( - options.usage, - usageTypes, - 'invalid element buffer usage'); - usage = usageTypes[options.usage]; - } - if ('primitive' in options) { - check$1.parameter( - options.primitive, - primTypes, - 'invalid element buffer primitive'); - primType = primTypes[options.primitive]; - } - if ('count' in options) { - check$1( - typeof options.count === 'number' && options.count >= 0, - 'invalid vertex count for elements'); - vertCount = options.count | 0; - } - if ('type' in options) { - check$1.parameter( - options.type, - elementTypes, - 'invalid buffer type'); - dtype = elementTypes[options.type]; - } - if ('length' in options) { - byteLength = options.length | 0; - } else { - byteLength = vertCount; - if (dtype === GL_UNSIGNED_SHORT$2 || dtype === GL_SHORT$2) { - byteLength *= 2; - } else if (dtype === GL_UNSIGNED_INT$2 || dtype === GL_INT$2) { - byteLength *= 4; - } - } - } - initElements( - elements, - data, - usage, - primType, - vertCount, - byteLength, - dtype); - } + var length = string.length; + position = position === undefined + ? length + : baseClamp(toInteger(position), 0, length); - return reglElements + var end = position; + position -= target.length; + return position >= 0 && string.slice(position, end) == target; } - reglElements(options); - - reglElements._reglType = 'elements'; - reglElements._elements = elements; - reglElements.subdata = function (data, offset) { - buffer.subdata(data, offset); - return reglElements - }; - reglElements.destroy = function () { - destroyElements(elements); - }; - - return reglElements - } + /** + * Converts the characters "&", "<", ">", '"', and "'" in `string` to their + * corresponding HTML entities. + * + * **Note:** No other characters are escaped. To escape additional + * characters use a third-party library like [_he_](https://mths.be/he). + * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't need escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escape('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ + function escape(string) { + string = toString(string); + return (string && reHasUnescapedHtml.test(string)) + ? string.replace(reUnescapedHtml, escapeHtmlChar) + : string; + } - return { - create: createElements, - createStream: createElementStream, - destroyStream: destroyElementStream, - getElements: function (elements) { - if (typeof elements === 'function' && - elements._elements instanceof REGLElementBuffer) { - return elements._elements - } - return null - }, - clear: function () { - values(elementSet).forEach(destroyElements); + /** + * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", + * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](https://lodash.com/)'); + * // => '\[lodash\]\(https://lodash\.com/\)' + */ + function escapeRegExp(string) { + string = toString(string); + return (string && reHasRegExpChar.test(string)) + ? string.replace(reRegExpChar, '\\$&') + : string; } - } -} - -var FLOAT = new Float32Array(1); -var INT = new Uint32Array(FLOAT.buffer); -var GL_UNSIGNED_SHORT$4 = 5123; + /** + * Converts `string` to + * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Foo Bar'); + * // => 'foo-bar' + * + * _.kebabCase('fooBar'); + * // => 'foo-bar' + * + * _.kebabCase('__FOO_BAR__'); + * // => 'foo-bar' + */ + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? '-' : '') + word.toLowerCase(); + }); -function convertToHalfFloat (array) { - var ushorts = pool.allocType(GL_UNSIGNED_SHORT$4, array.length); + /** + * Converts `string`, as space separated words, to lower case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the lower cased string. + * @example + * + * _.lowerCase('--Foo-Bar--'); + * // => 'foo bar' + * + * _.lowerCase('fooBar'); + * // => 'foo bar' + * + * _.lowerCase('__FOO_BAR__'); + * // => 'foo bar' + */ + var lowerCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + word.toLowerCase(); + }); - for (var i = 0; i < array.length; ++i) { - if (isNaN(array[i])) { - ushorts[i] = 0xffff; - } else if (array[i] === Infinity) { - ushorts[i] = 0x7c00; - } else if (array[i] === -Infinity) { - ushorts[i] = 0xfc00; - } else { - FLOAT[0] = array[i]; - var x = INT[0]; + /** + * Converts the first character of `string` to lower case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.lowerFirst('Fred'); + * // => 'fred' + * + * _.lowerFirst('FRED'); + * // => 'fRED' + */ + var lowerFirst = createCaseFirst('toLowerCase'); - var sgn = (x >>> 31) << 15; - var exp = ((x << 1) >>> 24) - 127; - var frac = (x >> 13) & ((1 << 10) - 1); + /** + * Pads `string` on the left and right sides if it's shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ + function pad(string, length, chars) { + string = toString(string); + length = toInteger(length); - if (exp < -24) { - // round non-representable denormals to 0 - ushorts[i] = sgn; - } else if (exp < -14) { - // handle denormals - var s = -14 - exp; - ushorts[i] = sgn + ((frac + (1 << 10)) >> s); - } else if (exp > 15) { - // round overflow to +/- Infinity - ushorts[i] = sgn + 0x7c00; - } else { - // otherwise convert directly - ushorts[i] = sgn + ((exp + 15) << 10) + frac; + var strLength = length ? stringSize(string) : 0; + if (!length || strLength >= length) { + return string; } + var mid = (length - strLength) / 2; + return ( + createPadding(nativeFloor(mid), chars) + + string + + createPadding(nativeCeil(mid), chars) + ); } - } - - return ushorts -} -function isArrayLike (s) { - return Array.isArray(s) || isTypedArray(s) -} - -var GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3; - -var GL_TEXTURE_2D = 0x0DE1; -var GL_TEXTURE_CUBE_MAP = 0x8513; -var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; - -var GL_RGBA = 0x1908; -var GL_ALPHA = 0x1906; -var GL_RGB = 0x1907; -var GL_LUMINANCE = 0x1909; -var GL_LUMINANCE_ALPHA = 0x190A; - -var GL_RGBA4 = 0x8056; -var GL_RGB5_A1 = 0x8057; -var GL_RGB565 = 0x8D62; - -var GL_UNSIGNED_SHORT_4_4_4_4$1 = 0x8033; -var GL_UNSIGNED_SHORT_5_5_5_1$1 = 0x8034; -var GL_UNSIGNED_SHORT_5_6_5$1 = 0x8363; -var GL_UNSIGNED_INT_24_8_WEBGL$1 = 0x84FA; - -var GL_DEPTH_COMPONENT = 0x1902; -var GL_DEPTH_STENCIL = 0x84F9; - -var GL_SRGB_EXT = 0x8C40; -var GL_SRGB_ALPHA_EXT = 0x8C42; - -var GL_HALF_FLOAT_OES$1 = 0x8D61; - -var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; -var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; -var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; -var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; - -var GL_COMPRESSED_RGB_ATC_WEBGL = 0x8C92; -var GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93; -var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE; + /** + * Pads `string` on the right side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padEnd('abc', 6); + * // => 'abc ' + * + * _.padEnd('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padEnd('abc', 3); + * // => 'abc' + */ + function padEnd(string, length, chars) { + string = toString(string); + length = toInteger(length); -var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; -var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01; -var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; -var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03; + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (string + createPadding(length - strLength, chars)) + : string; + } -var GL_COMPRESSED_RGB_ETC1_WEBGL = 0x8D64; + /** + * Pads `string` on the left side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padStart('abc', 6); + * // => ' abc' + * + * _.padStart('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padStart('abc', 3); + * // => 'abc' + */ + function padStart(string, length, chars) { + string = toString(string); + length = toInteger(length); -var GL_UNSIGNED_BYTE$4 = 0x1401; -var GL_UNSIGNED_SHORT$3 = 0x1403; -var GL_UNSIGNED_INT$3 = 0x1405; -var GL_FLOAT$3 = 0x1406; + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (createPadding(length - strLength, chars) + string) + : string; + } -var GL_TEXTURE_WRAP_S = 0x2802; -var GL_TEXTURE_WRAP_T = 0x2803; + /** + * Converts `string` to an integer of the specified radix. If `radix` is + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a + * hexadecimal, in which case a `radix` of `16` is used. + * + * **Note:** This method aligns with the + * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category String + * @param {string} string The string to convert. + * @param {number} [radix=10] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {number} Returns the converted integer. + * @example + * + * _.parseInt('08'); + * // => 8 + * + * _.map(['6', '08', '10'], _.parseInt); + * // => [6, 8, 10] + */ + function parseInt(string, radix, guard) { + if (guard || radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); + } -var GL_REPEAT = 0x2901; -var GL_CLAMP_TO_EDGE$1 = 0x812F; -var GL_MIRRORED_REPEAT = 0x8370; + /** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=1] The number of times to repeat the string. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ + function repeat(string, n, guard) { + if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { + n = 1; + } else { + n = toInteger(n); + } + return baseRepeat(toString(string), n); + } -var GL_TEXTURE_MAG_FILTER = 0x2800; -var GL_TEXTURE_MIN_FILTER = 0x2801; + /** + * Replaces matches for `pattern` in `string` with `replacement`. + * + * **Note:** This method is based on + * [`String#replace`](https://mdn.io/String/replace). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to modify. + * @param {RegExp|string} pattern The pattern to replace. + * @param {Function|string} replacement The match replacement. + * @returns {string} Returns the modified string. + * @example + * + * _.replace('Hi Fred', 'Fred', 'Barney'); + * // => 'Hi Barney' + */ + function replace() { + var args = arguments, + string = toString(args[0]); -var GL_NEAREST$1 = 0x2600; -var GL_LINEAR = 0x2601; -var GL_NEAREST_MIPMAP_NEAREST$1 = 0x2700; -var GL_LINEAR_MIPMAP_NEAREST$1 = 0x2701; -var GL_NEAREST_MIPMAP_LINEAR$1 = 0x2702; -var GL_LINEAR_MIPMAP_LINEAR$1 = 0x2703; + return args.length < 3 ? string : string.replace(args[1], args[2]); + } -var GL_GENERATE_MIPMAP_HINT = 0x8192; -var GL_DONT_CARE = 0x1100; -var GL_FASTEST = 0x1101; -var GL_NICEST = 0x1102; + /** + * Converts `string` to + * [snake case](https://en.wikipedia.org/wiki/Snake_case). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Foo Bar'); + * // => 'foo_bar' + * + * _.snakeCase('fooBar'); + * // => 'foo_bar' + * + * _.snakeCase('--FOO-BAR--'); + * // => 'foo_bar' + */ + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? '_' : '') + word.toLowerCase(); + }); -var GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; + /** + * Splits `string` by `separator`. + * + * **Note:** This method is based on + * [`String#split`](https://mdn.io/String/split). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to split. + * @param {RegExp|string} separator The separator pattern to split by. + * @param {number} [limit] The length to truncate results to. + * @returns {Array} Returns the string segments. + * @example + * + * _.split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ + function split(string, separator, limit) { + if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { + separator = limit = undefined; + } + limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; + if (!limit) { + return []; + } + string = toString(string); + if (string && ( + typeof separator == 'string' || + (separator != null && !isRegExp(separator)) + )) { + separator = baseToString(separator); + if (!separator && hasUnicode(string)) { + return castSlice(stringToArray(string), 0, limit); + } + } + return string.split(separator, limit); + } -var GL_UNPACK_ALIGNMENT = 0x0CF5; -var GL_UNPACK_FLIP_Y_WEBGL = 0x9240; -var GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; -var GL_UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243; + /** + * Converts `string` to + * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * + * @static + * @memberOf _ + * @since 3.1.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the start cased string. + * @example + * + * _.startCase('--foo-bar--'); + * // => 'Foo Bar' + * + * _.startCase('fooBar'); + * // => 'Foo Bar' + * + * _.startCase('__FOO_BAR__'); + * // => 'FOO BAR' + */ + var startCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + upperFirst(word); + }); -var GL_BROWSER_DEFAULT_WEBGL = 0x9244; + /** + * Checks if `string` starts with the given target string. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=0] The position to search from. + * @returns {boolean} Returns `true` if `string` starts with `target`, + * else `false`. + * @example + * + * _.startsWith('abc', 'a'); + * // => true + * + * _.startsWith('abc', 'b'); + * // => false + * + * _.startsWith('abc', 'b', 1); + * // => true + */ + function startsWith(string, target, position) { + string = toString(string); + position = position == null + ? 0 + : baseClamp(toInteger(position), 0, string.length); -var GL_TEXTURE0 = 0x84C0; + target = baseToString(target); + return string.slice(position, position + target.length) == target; + } -var MIPMAP_FILTERS = [ - GL_NEAREST_MIPMAP_NEAREST$1, - GL_NEAREST_MIPMAP_LINEAR$1, - GL_LINEAR_MIPMAP_NEAREST$1, - GL_LINEAR_MIPMAP_LINEAR$1 -]; + /** + * Creates a compiled template function that can interpolate data properties + * in "interpolate" delimiters, HTML-escape interpolated data properties in + * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data + * properties may be accessed as free variables in the template. If a setting + * object is given, it takes precedence over `_.templateSettings` values. + * + * **Note:** In the development build `_.template` utilizes + * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * for easier debugging. + * + * For more information on precompiling templates see + * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * + * For more information on Chrome extension sandboxes see + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category String + * @param {string} [string=''] The template string. + * @param {Object} [options={}] The options object. + * @param {RegExp} [options.escape=_.templateSettings.escape] + * The HTML "escape" delimiter. + * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] + * The "evaluate" delimiter. + * @param {Object} [options.imports=_.templateSettings.imports] + * An object to import into the template as free variables. + * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] + * The "interpolate" delimiter. + * @param {string} [options.sourceURL='lodash.templateSources[n]'] + * The sourceURL of the compiled template. + * @param {string} [options.variable='obj'] + * The data object variable name. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the compiled template function. + * @example + * + * // Use the "interpolate" delimiter to create a compiled template. + * var compiled = _.template('hello <%= user %>!'); + * compiled({ 'user': 'fred' }); + * // => 'hello fred!' + * + * // Use the HTML "escape" delimiter to escape data property values. + * var compiled = _.template('<b><%- value %></b>'); + * compiled({ 'value': '<script>' }); + * // => '<b><script></b>' + * + * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. + * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); + * compiled({ 'users': ['fred', 'barney'] }); + * // => '<li>fred</li><li>barney</li>' + * + * // Use the internal `print` function in "evaluate" delimiters. + * var compiled = _.template('<% print("hello " + user); %>!'); + * compiled({ 'user': 'barney' }); + * // => 'hello barney!' + * + * // Use the ES template literal delimiter as an "interpolate" delimiter. + * // Disable support by replacing the "interpolate" delimiter. + * var compiled = _.template('hello ${ user }!'); + * compiled({ 'user': 'pebbles' }); + * // => 'hello pebbles!' + * + * // Use backslashes to treat delimiters as plain text. + * var compiled = _.template('<%= "\\<%- value %\\>" %>'); + * compiled({ 'value': 'ignored' }); + * // => '<%- value %>' + * + * // Use the `imports` option to import `jQuery` as `jq`. + * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; + * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); + * compiled({ 'users': ['fred', 'barney'] }); + * // => '<li>fred</li><li>barney</li>' + * + * // Use the `sourceURL` option to specify a custom sourceURL for the template. + * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); + * compiled(data); + * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. + * + * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. + * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); + * compiled.source; + * // => function(data) { + * // var __t, __p = ''; + * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; + * // return __p; + * // } + * + * // Use custom template delimiters. + * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; + * var compiled = _.template('hello {{ user }}!'); + * compiled({ 'user': 'mustache' }); + * // => 'hello mustache!' + * + * // Use the `source` property to inline compiled templates for meaningful + * // line numbers in error messages and stack traces. + * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ + * var JST = {\ + * "main": ' + _.template(mainText).source + '\ + * };\ + * '); + */ + function template(string, options, guard) { + // Based on John Resig's `tmpl` implementation + // (http://ejohn.org/blog/javascript-micro-templating/) + // and Laura Doktorova's doT.js (https://github.com/olado/doT). + var settings = lodash.templateSettings; -var CHANNELS_FORMAT = [ - 0, - GL_LUMINANCE, - GL_LUMINANCE_ALPHA, - GL_RGB, - GL_RGBA -]; + if (guard && isIterateeCall(string, options, guard)) { + options = undefined; + } + string = toString(string); + options = assignInWith({}, options, settings, customDefaultsAssignIn); -var FORMAT_CHANNELS = {}; -FORMAT_CHANNELS[GL_LUMINANCE] = -FORMAT_CHANNELS[GL_ALPHA] = -FORMAT_CHANNELS[GL_DEPTH_COMPONENT] = 1; -FORMAT_CHANNELS[GL_DEPTH_STENCIL] = -FORMAT_CHANNELS[GL_LUMINANCE_ALPHA] = 2; -FORMAT_CHANNELS[GL_RGB] = -FORMAT_CHANNELS[GL_SRGB_EXT] = 3; -FORMAT_CHANNELS[GL_RGBA] = -FORMAT_CHANNELS[GL_SRGB_ALPHA_EXT] = 4; + var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), + importsKeys = keys(imports), + importsValues = baseValues(imports, importsKeys); -function objectName (str) { - return '[object ' + str + ']' -} + var isEscaping, + isEvaluating, + index = 0, + interpolate = options.interpolate || reNoMatch, + source = "__p += '"; -var CANVAS_CLASS = objectName('HTMLCanvasElement'); -var CONTEXT2D_CLASS = objectName('CanvasRenderingContext2D'); -var IMAGE_CLASS = objectName('HTMLImageElement'); -var VIDEO_CLASS = objectName('HTMLVideoElement'); + // Compile the regexp to match each delimiter. + var reDelimiters = RegExp( + (options.escape || reNoMatch).source + '|' + + interpolate.source + '|' + + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + + (options.evaluate || reNoMatch).source + '|$' + , 'g'); -var PIXEL_CLASSES = Object.keys(arrayTypes).concat([ - CANVAS_CLASS, - CONTEXT2D_CLASS, - IMAGE_CLASS, - VIDEO_CLASS -]); + // Use a sourceURL for easier debugging. + // The sourceURL gets injected into the source that's eval-ed, so be careful + // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in + // and escape the comment, thus injecting code that gets evaled. + var sourceURL = '//# sourceURL=' + + (hasOwnProperty.call(options, 'sourceURL') + ? (options.sourceURL + '').replace(/\s/g, ' ') + : ('lodash.templateSources[' + (++templateCounter) + ']') + ) + '\n'; -// for every texture type, store -// the size in bytes. -var TYPE_SIZES = []; -TYPE_SIZES[GL_UNSIGNED_BYTE$4] = 1; -TYPE_SIZES[GL_FLOAT$3] = 4; -TYPE_SIZES[GL_HALF_FLOAT_OES$1] = 2; + string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + interpolateValue || (interpolateValue = esTemplateValue); -TYPE_SIZES[GL_UNSIGNED_SHORT$3] = 2; -TYPE_SIZES[GL_UNSIGNED_INT$3] = 4; + // Escape characters that can't be included in string literals. + source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); -var FORMAT_SIZES_SPECIAL = []; -FORMAT_SIZES_SPECIAL[GL_RGBA4] = 2; -FORMAT_SIZES_SPECIAL[GL_RGB5_A1] = 2; -FORMAT_SIZES_SPECIAL[GL_RGB565] = 2; -FORMAT_SIZES_SPECIAL[GL_DEPTH_STENCIL] = 4; + // Replace delimiters with snippets. + if (escapeValue) { + isEscaping = true; + source += "' +\n__e(" + escapeValue + ") +\n'"; + } + if (evaluateValue) { + isEvaluating = true; + source += "';\n" + evaluateValue + ";\n__p += '"; + } + if (interpolateValue) { + source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; + } + index = offset + match.length; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_S3TC_DXT1_EXT] = 0.5; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT] = 0.5; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT] = 1; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT] = 1; + // The JS engine embedded in Adobe products needs `match` returned in + // order to produce the correct `offset` value. + return match; + }); -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ATC_WEBGL] = 0.5; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 1; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 1; + source += "';\n"; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 0.5; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 0.25; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 0.5; -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 0.25; + // If `variable` is not specified wrap a with-statement around the generated + // code to add the data object to the top of the scope chain. + var variable = hasOwnProperty.call(options, 'variable') && options.variable; + if (!variable) { + source = 'with (obj) {\n' + source + '\n}\n'; + } + // Throw an error if a forbidden character was found in `variable`, to prevent + // potential command injection attacks. + else if (reForbiddenIdentifierChars.test(variable)) { + throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); + } -FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ETC1_WEBGL] = 0.5; + // Cleanup code by stripping empty strings. + source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) + .replace(reEmptyStringMiddle, '$1') + .replace(reEmptyStringTrailing, '$1;'); -function isNumericArray (arr) { - return ( - Array.isArray(arr) && - (arr.length === 0 || - typeof arr[0] === 'number')) -} + // Frame code as the function body. + source = 'function(' + (variable || 'obj') + ') {\n' + + (variable + ? '' + : 'obj || (obj = {});\n' + ) + + "var __t, __p = ''" + + (isEscaping + ? ', __e = _.escape' + : '' + ) + + (isEvaluating + ? ', __j = Array.prototype.join;\n' + + "function print() { __p += __j.call(arguments, '') }\n" + : ';\n' + ) + + source + + 'return __p\n}'; -function isRectArray (arr) { - if (!Array.isArray(arr)) { - return false - } - var width = arr.length; - if (width === 0 || !isArrayLike(arr[0])) { - return false - } - return true -} + var result = attempt(function() { + return Function(importsKeys, sourceURL + 'return ' + source) + .apply(undefined, importsValues); + }); -function classString (x) { - return Object.prototype.toString.call(x) -} + // Provide the compiled function's source by its `toString` method or + // the `source` property as a convenience for inlining compiled templates. + result.source = source; + if (isError(result)) { + throw result; + } + return result; + } -function isCanvasElement (object) { - return classString(object) === CANVAS_CLASS -} + /** + * Converts `string`, as a whole, to lower case just like + * [String#toLowerCase](https://mdn.io/toLowerCase). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the lower cased string. + * @example + * + * _.toLower('--Foo-Bar--'); + * // => '--foo-bar--' + * + * _.toLower('fooBar'); + * // => 'foobar' + * + * _.toLower('__FOO_BAR__'); + * // => '__foo_bar__' + */ + function toLower(value) { + return toString(value).toLowerCase(); + } -function isContext2D (object) { - return classString(object) === CONTEXT2D_CLASS -} + /** + * Converts `string`, as a whole, to upper case just like + * [String#toUpperCase](https://mdn.io/toUpperCase). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the upper cased string. + * @example + * + * _.toUpper('--foo-bar--'); + * // => '--FOO-BAR--' + * + * _.toUpper('fooBar'); + * // => 'FOOBAR' + * + * _.toUpper('__foo_bar__'); + * // => '__FOO_BAR__' + */ + function toUpper(value) { + return toString(value).toUpperCase(); + } -function isImageElement (object) { - return classString(object) === IMAGE_CLASS -} + /** + * Removes leading and trailing whitespace or specified characters from `string`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to trim. + * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the trimmed string. + * @example + * + * _.trim(' abc '); + * // => 'abc' + * + * _.trim('-_-abc-_-', '_-'); + * // => 'abc' + * + * _.map([' foo ', ' bar '], _.trim); + * // => ['foo', 'bar'] + */ + function trim(string, chars, guard) { + string = toString(string); + if (string && (guard || chars === undefined)) { + return baseTrim(string); + } + if (!string || !(chars = baseToString(chars))) { + return string; + } + var strSymbols = stringToArray(string), + chrSymbols = stringToArray(chars), + start = charsStartIndex(strSymbols, chrSymbols), + end = charsEndIndex(strSymbols, chrSymbols) + 1; -function isVideoElement (object) { - return classString(object) === VIDEO_CLASS -} + return castSlice(strSymbols, start, end).join(''); + } -function isPixelData (object) { - if (!object) { - return false - } - var className = classString(object); - if (PIXEL_CLASSES.indexOf(className) >= 0) { - return true - } - return ( - isNumericArray(object) || - isRectArray(object) || - isNDArrayLike(object)) -} + /** + * Removes trailing whitespace or specified characters from `string`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to trim. + * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the trimmed string. + * @example + * + * _.trimEnd(' abc '); + * // => ' abc' + * + * _.trimEnd('-_-abc-_-', '_-'); + * // => '-_-abc' + */ + function trimEnd(string, chars, guard) { + string = toString(string); + if (string && (guard || chars === undefined)) { + return string.slice(0, trimmedEndIndex(string) + 1); + } + if (!string || !(chars = baseToString(chars))) { + return string; + } + var strSymbols = stringToArray(string), + end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; -function typedArrayCode$1 (data) { - return arrayTypes[Object.prototype.toString.call(data)] | 0 -} + return castSlice(strSymbols, 0, end).join(''); + } -function convertData (result, data) { - var n = data.length; - switch (result.type) { - case GL_UNSIGNED_BYTE$4: - case GL_UNSIGNED_SHORT$3: - case GL_UNSIGNED_INT$3: - case GL_FLOAT$3: - var converted = pool.allocType(result.type, n); - converted.set(data); - result.data = converted; - break + /** + * Removes leading whitespace or specified characters from `string`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to trim. + * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the trimmed string. + * @example + * + * _.trimStart(' abc '); + * // => 'abc ' + * + * _.trimStart('-_-abc-_-', '_-'); + * // => 'abc-_-' + */ + function trimStart(string, chars, guard) { + string = toString(string); + if (string && (guard || chars === undefined)) { + return string.replace(reTrimStart, ''); + } + if (!string || !(chars = baseToString(chars))) { + return string; + } + var strSymbols = stringToArray(string), + start = charsStartIndex(strSymbols, stringToArray(chars)); - case GL_HALF_FLOAT_OES$1: - result.data = convertToHalfFloat(data); - break + return castSlice(strSymbols, start).join(''); + } - default: - check$1.raise('unsupported texture type, must specify a typed array'); - } -} + /** + * Truncates `string` if it's longer than the given maximum string length. + * The last characters of the truncated string are replaced with the omission + * string which defaults to "...". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to truncate. + * @param {Object} [options={}] The options object. + * @param {number} [options.length=30] The maximum string length. + * @param {string} [options.omission='...'] The string to indicate text is omitted. + * @param {RegExp|string} [options.separator] The separator pattern to truncate to. + * @returns {string} Returns the truncated string. + * @example + * + * _.truncate('hi-diddly-ho there, neighborino'); + * // => 'hi-diddly-ho there, neighbo...' + * + * _.truncate('hi-diddly-ho there, neighborino', { + * 'length': 24, + * 'separator': ' ' + * }); + * // => 'hi-diddly-ho there,...' + * + * _.truncate('hi-diddly-ho there, neighborino', { + * 'length': 24, + * 'separator': /,? +/ + * }); + * // => 'hi-diddly-ho there...' + * + * _.truncate('hi-diddly-ho there, neighborino', { + * 'omission': ' [...]' + * }); + * // => 'hi-diddly-ho there, neig [...]' + */ + function truncate(string, options) { + var length = DEFAULT_TRUNC_LENGTH, + omission = DEFAULT_TRUNC_OMISSION; -function preConvert (image, n) { - return pool.allocType( - image.type === GL_HALF_FLOAT_OES$1 - ? GL_FLOAT$3 - : image.type, n) -} + if (isObject(options)) { + var separator = 'separator' in options ? options.separator : separator; + length = 'length' in options ? toInteger(options.length) : length; + omission = 'omission' in options ? baseToString(options.omission) : omission; + } + string = toString(string); -function postConvert (image, data) { - if (image.type === GL_HALF_FLOAT_OES$1) { - image.data = convertToHalfFloat(data); - pool.freeType(data); - } else { - image.data = data; - } -} + var strLength = string.length; + if (hasUnicode(string)) { + var strSymbols = stringToArray(string); + strLength = strSymbols.length; + } + if (length >= strLength) { + return string; + } + var end = length - stringSize(omission); + if (end < 1) { + return omission; + } + var result = strSymbols + ? castSlice(strSymbols, 0, end).join('') + : string.slice(0, end); -function transposeData (image, array, strideX, strideY, strideC, offset) { - var w = image.width; - var h = image.height; - var c = image.channels; - var n = w * h * c; - var data = preConvert(image, n); + if (separator === undefined) { + return result + omission; + } + if (strSymbols) { + end += (result.length - end); + } + if (isRegExp(separator)) { + if (string.slice(end).search(separator)) { + var match, + substring = result; - var p = 0; - for (var i = 0; i < h; ++i) { - for (var j = 0; j < w; ++j) { - for (var k = 0; k < c; ++k) { - data[p++] = array[strideX * j + strideY * i + strideC * k + offset]; + if (!separator.global) { + separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); + } + separator.lastIndex = 0; + while ((match = separator.exec(substring))) { + var newEnd = match.index; + } + result = result.slice(0, newEnd === undefined ? end : newEnd); + } + } else if (string.indexOf(baseToString(separator), end) != end) { + var index = result.lastIndexOf(separator); + if (index > -1) { + result = result.slice(0, index); + } } + return result + omission; } - } - postConvert(image, data); -} + /** + * The inverse of `_.escape`; this method converts the HTML entities + * `&`, `<`, `>`, `"`, and `'` in `string` to + * their corresponding characters. + * + * **Note:** No other HTML entities are unescaped. To unescape additional + * HTML entities use a third-party library like [_he_](https://mths.be/he). + * + * @static + * @memberOf _ + * @since 0.6.0 + * @category String + * @param {string} [string=''] The string to unescape. + * @returns {string} Returns the unescaped string. + * @example + * + * _.unescape('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ + function unescape(string) { + string = toString(string); + return (string && reHasEscapedHtml.test(string)) + ? string.replace(reEscapedHtml, unescapeHtmlChar) + : string; + } -function getTextureSize (format, type, width, height, isMipmap, isCube) { - var s; - if (typeof FORMAT_SIZES_SPECIAL[format] !== 'undefined') { - // we have a special array for dealing with weird color formats such as RGB5A1 - s = FORMAT_SIZES_SPECIAL[format]; - } else { - s = FORMAT_CHANNELS[format] * TYPE_SIZES[type]; - } + /** + * Converts `string`, as space separated words, to upper case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the upper cased string. + * @example + * + * _.upperCase('--foo-bar'); + * // => 'FOO BAR' + * + * _.upperCase('fooBar'); + * // => 'FOO BAR' + * + * _.upperCase('__foo_bar__'); + * // => 'FOO BAR' + */ + var upperCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + word.toUpperCase(); + }); - if (isCube) { - s *= 6; - } + /** + * Converts the first character of `string` to upper case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.upperFirst('fred'); + * // => 'Fred' + * + * _.upperFirst('FRED'); + * // => 'FRED' + */ + var upperFirst = createCaseFirst('toUpperCase'); - if (isMipmap) { - // compute the total size of all the mipmaps. - var total = 0; + /** + * Splits `string` into an array of its words. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {RegExp|string} [pattern] The pattern to match words. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the words of `string`. + * @example + * + * _.words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + * _.words('fred, barney, & pebbles', /[^, ]+/g); + * // => ['fred', 'barney', '&', 'pebbles'] + */ + function words(string, pattern, guard) { + string = toString(string); + pattern = guard ? undefined : pattern; - var w = width; - while (w >= 1) { - // we can only use mipmaps on a square image, - // so we can simply use the width and ignore the height: - total += s * w * w; - w /= 2; + if (pattern === undefined) { + return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); + } + return string.match(pattern) || []; } - return total - } else { - return s * width * height - } -} -function createTextureSet ( - gl, extensions, limits, reglPoll, contextState, stats, config) { - // ------------------------------------------------------- - // Initialize constants and parameter tables here - // ------------------------------------------------------- - var mipmapHint = { - "don't care": GL_DONT_CARE, - 'dont care': GL_DONT_CARE, - 'nice': GL_NICEST, - 'fast': GL_FASTEST - }; + /*------------------------------------------------------------------------*/ - var wrapModes = { - 'repeat': GL_REPEAT, - 'clamp': GL_CLAMP_TO_EDGE$1, - 'mirror': GL_MIRRORED_REPEAT - }; + /** + * Attempts to invoke `func`, returning either the result or the caught error + * object. Any additional arguments are provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Util + * @param {Function} func The function to attempt. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {*} Returns the `func` result or error object. + * @example + * + * // Avoid throwing errors for invalid selectors. + * var elements = _.attempt(function(selector) { + * return document.querySelectorAll(selector); + * }, '>_>'); + * + * if (_.isError(elements)) { + * elements = []; + * } + */ + var attempt = baseRest(function(func, args) { + try { + return apply(func, undefined, args); + } catch (e) { + return isError(e) ? e : new Error(e); + } + }); - var magFilters = { - 'nearest': GL_NEAREST$1, - 'linear': GL_LINEAR - }; + /** + * Binds methods of an object to the object itself, overwriting the existing + * method. + * + * **Note:** This method doesn't set the "length" property of bound functions. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {Object} object The object to bind and assign the bound methods to. + * @param {...(string|string[])} methodNames The object method names to bind. + * @returns {Object} Returns `object`. + * @example + * + * var view = { + * 'label': 'docs', + * 'click': function() { + * console.log('clicked ' + this.label); + * } + * }; + * + * _.bindAll(view, ['click']); + * jQuery(element).on('click', view.click); + * // => Logs 'clicked docs' when clicked. + */ + var bindAll = flatRest(function(object, methodNames) { + arrayEach(methodNames, function(key) { + key = toKey(key); + baseAssignValue(object, key, bind(object[key], object)); + }); + return object; + }); - var minFilters = extend({ - 'mipmap': GL_LINEAR_MIPMAP_LINEAR$1, - 'nearest mipmap nearest': GL_NEAREST_MIPMAP_NEAREST$1, - 'linear mipmap nearest': GL_LINEAR_MIPMAP_NEAREST$1, - 'nearest mipmap linear': GL_NEAREST_MIPMAP_LINEAR$1, - 'linear mipmap linear': GL_LINEAR_MIPMAP_LINEAR$1 - }, magFilters); + /** + * Creates a function that iterates over `pairs` and invokes the corresponding + * function of the first predicate to return truthy. The predicate-function + * pairs are invoked with the `this` binding and arguments of the created + * function. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {Array} pairs The predicate-function pairs. + * @returns {Function} Returns the new composite function. + * @example + * + * var func = _.cond([ + * [_.matches({ 'a': 1 }), _.constant('matches A')], + * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], + * [_.stubTrue, _.constant('no match')] + * ]); + * + * func({ 'a': 1, 'b': 2 }); + * // => 'matches A' + * + * func({ 'a': 0, 'b': 1 }); + * // => 'matches B' + * + * func({ 'a': '1', 'b': '2' }); + * // => 'no match' + */ + function cond(pairs) { + var length = pairs == null ? 0 : pairs.length, + toIteratee = getIteratee(); - var colorSpace = { - 'none': 0, - 'browser': GL_BROWSER_DEFAULT_WEBGL - }; + pairs = !length ? [] : arrayMap(pairs, function(pair) { + if (typeof pair[1] != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return [toIteratee(pair[0]), pair[1]]; + }); - var textureTypes = { - 'uint8': GL_UNSIGNED_BYTE$4, - 'rgba4': GL_UNSIGNED_SHORT_4_4_4_4$1, - 'rgb565': GL_UNSIGNED_SHORT_5_6_5$1, - 'rgb5 a1': GL_UNSIGNED_SHORT_5_5_5_1$1 - }; + return baseRest(function(args) { + var index = -1; + while (++index < length) { + var pair = pairs[index]; + if (apply(pair[0], this, args)) { + return apply(pair[1], this, args); + } + } + }); + } - var textureFormats = { - 'alpha': GL_ALPHA, - 'luminance': GL_LUMINANCE, - 'luminance alpha': GL_LUMINANCE_ALPHA, - 'rgb': GL_RGB, - 'rgba': GL_RGBA, - 'rgba4': GL_RGBA4, - 'rgb5 a1': GL_RGB5_A1, - 'rgb565': GL_RGB565 - }; + /** + * Creates a function that invokes the predicate properties of `source` with + * the corresponding property values of a given object, returning `true` if + * all predicates return truthy, else `false`. + * + * **Note:** The created function is equivalent to `_.conformsTo` with + * `source` partially applied. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. + * @example + * + * var objects = [ + * { 'a': 2, 'b': 1 }, + * { 'a': 1, 'b': 2 } + * ]; + * + * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); + * // => [{ 'a': 1, 'b': 2 }] + */ + function conforms(source) { + return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); + } - var compressedTextureFormats = {}; + /** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ + function constant(value) { + return function() { + return value; + }; + } - if (extensions.ext_srgb) { - textureFormats.srgb = GL_SRGB_EXT; - textureFormats.srgba = GL_SRGB_ALPHA_EXT; - } + /** + * Checks `value` to determine whether a default value should be returned in + * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, + * or `undefined`. + * + * @static + * @memberOf _ + * @since 4.14.0 + * @category Util + * @param {*} value The value to check. + * @param {*} defaultValue The default value. + * @returns {*} Returns the resolved value. + * @example + * + * _.defaultTo(1, 10); + * // => 1 + * + * _.defaultTo(undefined, 10); + * // => 10 + */ + function defaultTo(value, defaultValue) { + return (value == null || value !== value) ? defaultValue : value; + } - if (extensions.oes_texture_float) { - textureTypes.float32 = textureTypes.float = GL_FLOAT$3; - } + /** + * Creates a function that returns the result of invoking the given functions + * with the `this` binding of the created function, where each successive + * invocation is supplied the return value of the previous. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Util + * @param {...(Function|Function[])} [funcs] The functions to invoke. + * @returns {Function} Returns the new composite function. + * @see _.flowRight + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flow([_.add, square]); + * addSquare(1, 2); + * // => 9 + */ + var flow = createFlow(); - if (extensions.oes_texture_half_float) { - textureTypes['float16'] = textureTypes['half float'] = GL_HALF_FLOAT_OES$1; - } + /** + * This method is like `_.flow` except that it creates a function that + * invokes the given functions from right to left. + * + * @static + * @since 3.0.0 + * @memberOf _ + * @category Util + * @param {...(Function|Function[])} [funcs] The functions to invoke. + * @returns {Function} Returns the new composite function. + * @see _.flow + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flowRight([square, _.add]); + * addSquare(1, 2); + * // => 9 + */ + var flowRight = createFlow(true); - if (extensions.webgl_depth_texture) { - extend(textureFormats, { - 'depth': GL_DEPTH_COMPONENT, - 'depth stencil': GL_DEPTH_STENCIL - }); + /** + * This method returns the first argument it receives. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'a': 1 }; + * + * console.log(_.identity(object) === object); + * // => true + */ + function identity(value) { + return value; + } - extend(textureTypes, { - 'uint16': GL_UNSIGNED_SHORT$3, - 'uint32': GL_UNSIGNED_INT$3, - 'depth stencil': GL_UNSIGNED_INT_24_8_WEBGL$1 - }); - } + /** + * Creates a function that invokes `func` with the arguments of the created + * function. If `func` is a property name, the created function returns the + * property value for a given element. If `func` is an array or object, the + * created function returns `true` for elements that contain the equivalent + * source properties, otherwise it returns `false`. + * + * @static + * @since 4.0.0 + * @memberOf _ + * @category Util + * @param {*} [func=_.identity] The value to convert to a callback. + * @returns {Function} Returns the callback. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); + * // => [{ 'user': 'barney', 'age': 36, 'active': true }] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, _.iteratee(['user', 'fred'])); + * // => [{ 'user': 'fred', 'age': 40 }] + * + * // The `_.property` iteratee shorthand. + * _.map(users, _.iteratee('user')); + * // => ['barney', 'fred'] + * + * // Create custom iteratee shorthands. + * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { + * return !_.isRegExp(func) ? iteratee(func) : function(string) { + * return func.test(string); + * }; + * }); + * + * _.filter(['abc', 'def'], /ef/); + * // => ['def'] + */ + function iteratee(func) { + return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); + } - if (extensions.webgl_compressed_texture_s3tc) { - extend(compressedTextureFormats, { - 'rgb s3tc dxt1': GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - 'rgba s3tc dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, - 'rgba s3tc dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, - 'rgba s3tc dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT - }); - } + /** + * Creates a function that performs a partial deep comparison between a given + * object and `source`, returning `true` if the given object has equivalent + * property values, else `false`. + * + * **Note:** The created function is equivalent to `_.isMatch` with `source` + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. + * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Util + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + * @example + * + * var objects = [ + * { 'a': 1, 'b': 2, 'c': 3 }, + * { 'a': 4, 'b': 5, 'c': 6 } + * ]; + * + * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); + * // => [{ 'a': 4, 'b': 5, 'c': 6 }] + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] + */ + function matches(source) { + return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); + } - if (extensions.webgl_compressed_texture_atc) { - extend(compressedTextureFormats, { - 'rgb atc': GL_COMPRESSED_RGB_ATC_WEBGL, - 'rgba atc explicit alpha': GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, - 'rgba atc interpolated alpha': GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL - }); - } + /** + * Creates a function that performs a partial deep comparison between the + * value at `path` of a given object to `srcValue`, returning `true` if the + * object value is equivalent, else `false`. + * + * **Note:** Partial comparisons will match empty array and empty object + * `srcValue` values against any array or object value, respectively. See + * `_.isEqual` for a list of supported value comparisons. + * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * + * @static + * @memberOf _ + * @since 3.2.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + * @example + * + * var objects = [ + * { 'a': 1, 'b': 2, 'c': 3 }, + * { 'a': 4, 'b': 5, 'c': 6 } + * ]; + * + * _.find(objects, _.matchesProperty('a', 4)); + * // => { 'a': 4, 'b': 5, 'c': 6 } + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] + */ + function matchesProperty(path, srcValue) { + return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); + } - if (extensions.webgl_compressed_texture_pvrtc) { - extend(compressedTextureFormats, { - 'rgb pvrtc 4bppv1': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, - 'rgb pvrtc 2bppv1': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, - 'rgba pvrtc 4bppv1': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, - 'rgba pvrtc 2bppv1': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG + /** + * Creates a function that invokes the method at `path` of a given object. + * Any additional arguments are provided to the invoked method. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Util + * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {Function} Returns the new invoker function. + * @example + * + * var objects = [ + * { 'a': { 'b': _.constant(2) } }, + * { 'a': { 'b': _.constant(1) } } + * ]; + * + * _.map(objects, _.method('a.b')); + * // => [2, 1] + * + * _.map(objects, _.method(['a', 'b'])); + * // => [2, 1] + */ + var method = baseRest(function(path, args) { + return function(object) { + return baseInvoke(object, path, args); + }; }); - } - if (extensions.webgl_compressed_texture_etc1) { - compressedTextureFormats['rgb etc1'] = GL_COMPRESSED_RGB_ETC1_WEBGL; - } + /** + * The opposite of `_.method`; this method creates a function that invokes + * the method at a given path of `object`. Any additional arguments are + * provided to the invoked method. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Util + * @param {Object} object The object to query. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {Function} Returns the new invoker function. + * @example + * + * var array = _.times(3, _.constant), + * object = { 'a': array, 'b': array, 'c': array }; + * + * _.map(['a[2]', 'c[0]'], _.methodOf(object)); + * // => [2, 0] + * + * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); + * // => [2, 0] + */ + var methodOf = baseRest(function(object, args) { + return function(path) { + return baseInvoke(object, path, args); + }; + }); - // Copy over all texture formats - var supportedCompressedFormats = Array.prototype.slice.call( - gl.getParameter(GL_COMPRESSED_TEXTURE_FORMATS)); - Object.keys(compressedTextureFormats).forEach(function (name) { - var format = compressedTextureFormats[name]; - if (supportedCompressedFormats.indexOf(format) >= 0) { - textureFormats[name] = format; - } - }); + /** + * Adds all own enumerable string keyed function properties of a source + * object to the destination object. If `object` is a function, then methods + * are added to its prototype as well. + * + * **Note:** Use `_.runInContext` to create a pristine `lodash` function to + * avoid conflicts caused by modifying the original. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {Function|Object} [object=lodash] The destination object. + * @param {Object} source The object of functions to add. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.chain=true] Specify whether mixins are chainable. + * @returns {Function|Object} Returns `object`. + * @example + * + * function vowels(string) { + * return _.filter(string, function(v) { + * return /[aeiou]/i.test(v); + * }); + * } + * + * _.mixin({ 'vowels': vowels }); + * _.vowels('fred'); + * // => ['e'] + * + * _('fred').vowels().value(); + * // => ['e'] + * + * _.mixin({ 'vowels': vowels }, { 'chain': false }); + * _('fred').vowels(); + * // => ['e'] + */ + function mixin(object, source, options) { + var props = keys(source), + methodNames = baseFunctions(source, props); - var supportedFormats = Object.keys(textureFormats); - limits.textureFormats = supportedFormats; + if (options == null && + !(isObject(source) && (methodNames.length || !props.length))) { + options = source; + source = object; + object = this; + methodNames = baseFunctions(source, keys(source)); + } + var chain = !(isObject(options) && 'chain' in options) || !!options.chain, + isFunc = isFunction(object); - // associate with every format string its - // corresponding GL-value. - var textureFormatsInvert = []; - Object.keys(textureFormats).forEach(function (key) { - var val = textureFormats[key]; - textureFormatsInvert[val] = key; - }); + arrayEach(methodNames, function(methodName) { + var func = source[methodName]; + object[methodName] = func; + if (isFunc) { + object.prototype[methodName] = function() { + var chainAll = this.__chain__; + if (chain || chainAll) { + var result = object(this.__wrapped__), + actions = result.__actions__ = copyArray(this.__actions__); - // associate with every type string its - // corresponding GL-value. - var textureTypesInvert = []; - Object.keys(textureTypes).forEach(function (key) { - var val = textureTypes[key]; - textureTypesInvert[val] = key; - }); + actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); + result.__chain__ = chainAll; + return result; + } + return func.apply(object, arrayPush([this.value()], arguments)); + }; + } + }); - var magFiltersInvert = []; - Object.keys(magFilters).forEach(function (key) { - var val = magFilters[key]; - magFiltersInvert[val] = key; - }); + return object; + } - var minFiltersInvert = []; - Object.keys(minFilters).forEach(function (key) { - var val = minFilters[key]; - minFiltersInvert[val] = key; - }); + /** + * Reverts the `_` variable to its previous value and returns a reference to + * the `lodash` function. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @returns {Function} Returns the `lodash` function. + * @example + * + * var lodash = _.noConflict(); + */ + function noConflict() { + if (root._ === this) { + root._ = oldDash; + } + return this; + } - var wrapModesInvert = []; - Object.keys(wrapModes).forEach(function (key) { - var val = wrapModes[key]; - wrapModesInvert[val] = key; - }); + /** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ + function noop() { + // No operation performed. + } - // colorFormats[] gives the format (channels) associated to an - // internalformat - var colorFormats = supportedFormats.reduce(function (color, key) { - var glenum = textureFormats[key]; - if (glenum === GL_LUMINANCE || - glenum === GL_ALPHA || - glenum === GL_LUMINANCE || - glenum === GL_LUMINANCE_ALPHA || - glenum === GL_DEPTH_COMPONENT || - glenum === GL_DEPTH_STENCIL) { - color[glenum] = glenum; - } else if (glenum === GL_RGB5_A1 || key.indexOf('rgba') >= 0) { - color[glenum] = GL_RGBA; - } else { - color[glenum] = GL_RGB; + /** + * Creates a function that gets the argument at index `n`. If `n` is negative, + * the nth argument from the end is returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {number} [n=0] The index of the argument to return. + * @returns {Function} Returns the new pass-thru function. + * @example + * + * var func = _.nthArg(1); + * func('a', 'b', 'c', 'd'); + * // => 'b' + * + * var func = _.nthArg(-2); + * func('a', 'b', 'c', 'd'); + * // => 'c' + */ + function nthArg(n) { + n = toInteger(n); + return baseRest(function(args) { + return baseNth(args, n); + }); } - return color - }, {}); - function TexFlags () { - // format info - this.internalformat = GL_RGBA; - this.format = GL_RGBA; - this.type = GL_UNSIGNED_BYTE$4; - this.compressed = false; + /** + * Creates a function that invokes `iteratees` with the arguments it receives + * and returns their results. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to invoke. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.over([Math.max, Math.min]); + * + * func(1, 2, 3, 4); + * // => [4, 1] + */ + var over = createOver(arrayMap); - // pixel storage - this.premultiplyAlpha = false; - this.flipY = false; - this.unpackAlignment = 1; - this.colorSpace = 0; + /** + * Creates a function that checks if **all** of the `predicates` return + * truthy when invoked with the arguments it receives. + * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {...(Function|Function[])} [predicates=[_.identity]] + * The predicates to check. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.overEvery([Boolean, isFinite]); + * + * func('1'); + * // => true + * + * func(null); + * // => false + * + * func(NaN); + * // => false + */ + var overEvery = createOver(arrayEvery); - // shape info - this.width = 0; - this.height = 0; - this.channels = 0; - } + /** + * Creates a function that checks if **any** of the `predicates` return + * truthy when invoked with the arguments it receives. + * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {...(Function|Function[])} [predicates=[_.identity]] + * The predicates to check. + * @returns {Function} Returns the new function. + * @example + * + * var func = _.overSome([Boolean, isFinite]); + * + * func('1'); + * // => true + * + * func(null); + * // => true + * + * func(NaN); + * // => false + * + * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) + * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) + */ + var overSome = createOver(arraySome); - function copyFlags (result, other) { - result.internalformat = other.internalformat; - result.format = other.format; - result.type = other.type; - result.compressed = other.compressed; + /** + * Creates a function that returns the value at `path` of a given object. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + * @example + * + * var objects = [ + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } + * ]; + * + * _.map(objects, _.property('a.b')); + * // => [2, 1] + * + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); + * // => [1, 2] + */ + function property(path) { + return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); + } - result.premultiplyAlpha = other.premultiplyAlpha; - result.flipY = other.flipY; - result.unpackAlignment = other.unpackAlignment; - result.colorSpace = other.colorSpace; + /** + * The opposite of `_.property`; this method creates a function that returns + * the value at a given path of `object`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Util + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. + * @example + * + * var array = [0, 1, 2], + * object = { 'a': array, 'b': array, 'c': array }; + * + * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); + * // => [2, 0] + * + * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); + * // => [2, 0] + */ + function propertyOf(object) { + return function(path) { + return object == null ? undefined : baseGet(object, path); + }; + } - result.width = other.width; - result.height = other.height; - result.channels = other.channels; - } + /** + * Creates an array of numbers (positive and/or negative) progressing from + * `start` up to, but not including, `end`. A step of `-1` is used if a negative + * `start` is specified without an `end` or `step`. If `end` is not specified, + * it's set to `start` with `start` then set to `0`. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the range of numbers. + * @see _.inRange, _.rangeRight + * @example + * + * _.range(4); + * // => [0, 1, 2, 3] + * + * _.range(-4); + * // => [0, -1, -2, -3] + * + * _.range(1, 5); + * // => [1, 2, 3, 4] + * + * _.range(0, 20, 5); + * // => [0, 5, 10, 15] + * + * _.range(0, -4, -1); + * // => [0, -1, -2, -3] + * + * _.range(1, 4, 0); + * // => [1, 1, 1] + * + * _.range(0); + * // => [] + */ + var range = createRange(); - function parseFlags (flags, options) { - if (typeof options !== 'object' || !options) { - return - } + /** + * This method is like `_.range` except that it populates values in + * descending order. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the range of numbers. + * @see _.inRange, _.range + * @example + * + * _.rangeRight(4); + * // => [3, 2, 1, 0] + * + * _.rangeRight(-4); + * // => [-3, -2, -1, 0] + * + * _.rangeRight(1, 5); + * // => [4, 3, 2, 1] + * + * _.rangeRight(0, 20, 5); + * // => [15, 10, 5, 0] + * + * _.rangeRight(0, -4, -1); + * // => [-3, -2, -1, 0] + * + * _.rangeRight(1, 4, 0); + * // => [1, 1, 1] + * + * _.rangeRight(0); + * // => [] + */ + var rangeRight = createRange(true); - if ('premultiplyAlpha' in options) { - check$1.type(options.premultiplyAlpha, 'boolean', - 'invalid premultiplyAlpha'); - flags.premultiplyAlpha = options.premultiplyAlpha; + /** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ + function stubArray() { + return []; } - if ('flipY' in options) { - check$1.type(options.flipY, 'boolean', - 'invalid texture flip'); - flags.flipY = options.flipY; + /** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ + function stubFalse() { + return false; } - if ('alignment' in options) { - check$1.oneOf(options.alignment, [1, 2, 4, 8], - 'invalid texture unpack alignment'); - flags.unpackAlignment = options.alignment; + /** + * This method returns a new empty object. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Object} Returns the new empty object. + * @example + * + * var objects = _.times(2, _.stubObject); + * + * console.log(objects); + * // => [{}, {}] + * + * console.log(objects[0] === objects[1]); + * // => false + */ + function stubObject() { + return {}; } - if ('colorSpace' in options) { - check$1.parameter(options.colorSpace, colorSpace, - 'invalid colorSpace'); - flags.colorSpace = colorSpace[options.colorSpace]; + /** + * This method returns an empty string. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {string} Returns the empty string. + * @example + * + * _.times(2, _.stubString); + * // => ['', ''] + */ + function stubString() { + return ''; } - if ('type' in options) { - var type = options.type; - check$1(extensions.oes_texture_float || - !(type === 'float' || type === 'float32'), - 'you must enable the OES_texture_float extension in order to use floating point textures.'); - check$1(extensions.oes_texture_half_float || - !(type === 'half float' || type === 'float16'), - 'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.'); - check$1(extensions.webgl_depth_texture || - !(type === 'uint16' || type === 'uint32' || type === 'depth stencil'), - 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.'); - check$1.parameter(type, textureTypes, - 'invalid texture type'); - flags.type = textureTypes[type]; + /** + * This method returns `true`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `true`. + * @example + * + * _.times(2, _.stubTrue); + * // => [true, true] + */ + function stubTrue() { + return true; } - var w = flags.width; - var h = flags.height; - var c = flags.channels; - var hasChannels = false; - if ('shape' in options) { - check$1(Array.isArray(options.shape) && options.shape.length >= 2, - 'shape must be an array'); - w = options.shape[0]; - h = options.shape[1]; - if (options.shape.length === 3) { - c = options.shape[2]; - check$1(c > 0 && c <= 4, 'invalid number of channels'); - hasChannels = true; - } - check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width'); - check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height'); - } else { - if ('radius' in options) { - w = h = options.radius; - check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid radius'); - } - if ('width' in options) { - w = options.width; - check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width'); - } - if ('height' in options) { - h = options.height; - check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height'); + /** + * Invokes the iteratee `n` times, returning an array of the results of + * each invocation. The iteratee is invoked with one argument; (index). + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the array of results. + * @example + * + * _.times(3, String); + * // => ['0', '1', '2'] + * + * _.times(4, _.constant(0)); + * // => [0, 0, 0, 0] + */ + function times(n, iteratee) { + n = toInteger(n); + if (n < 1 || n > MAX_SAFE_INTEGER) { + return []; } - if ('channels' in options) { - c = options.channels; - check$1(c > 0 && c <= 4, 'invalid number of channels'); - hasChannels = true; + var index = MAX_ARRAY_LENGTH, + length = nativeMin(n, MAX_ARRAY_LENGTH); + + iteratee = getIteratee(iteratee); + n -= MAX_ARRAY_LENGTH; + + var result = baseTimes(length, iteratee); + while (++index < n) { + iteratee(index); } + return result; } - flags.width = w | 0; - flags.height = h | 0; - flags.channels = c | 0; - var hasFormat = false; - if ('format' in options) { - var formatStr = options.format; - check$1(extensions.webgl_depth_texture || - !(formatStr === 'depth' || formatStr === 'depth stencil'), - 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.'); - check$1.parameter(formatStr, textureFormats, - 'invalid texture format'); - var internalformat = flags.internalformat = textureFormats[formatStr]; - flags.format = colorFormats[internalformat]; - if (formatStr in textureTypes) { - if (!('type' in options)) { - flags.type = textureTypes[formatStr]; - } - } - if (formatStr in compressedTextureFormats) { - flags.compressed = true; + /** + * Converts `value` to a property path array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {*} value The value to convert. + * @returns {Array} Returns the new property path array. + * @example + * + * _.toPath('a.b.c'); + * // => ['a', 'b', 'c'] + * + * _.toPath('a[0].b.c'); + * // => ['a', '0', 'b', 'c'] + */ + function toPath(value) { + if (isArray(value)) { + return arrayMap(value, toKey); } - hasFormat = true; + return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); } - // Reconcile channels and format - if (!hasChannels && hasFormat) { - flags.channels = FORMAT_CHANNELS[flags.format]; - } else if (hasChannels && !hasFormat) { - if (flags.channels !== CHANNELS_FORMAT[flags.format]) { - flags.format = flags.internalformat = CHANNELS_FORMAT[flags.channels]; - } - } else if (hasFormat && hasChannels) { - check$1( - flags.channels === FORMAT_CHANNELS[flags.format], - 'number of channels inconsistent with specified format'); + /** + * Generates a unique ID. If `prefix` is given, the ID is appended to it. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {string} [prefix=''] The value to prefix the ID with. + * @returns {string} Returns the unique ID. + * @example + * + * _.uniqueId('contact_'); + * // => 'contact_104' + * + * _.uniqueId(); + * // => '105' + */ + function uniqueId(prefix) { + var id = ++idCounter; + return toString(prefix) + id; } - } - function setFlags (flags) { - gl.pixelStorei(GL_UNPACK_FLIP_Y_WEBGL, flags.flipY); - gl.pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL, flags.premultiplyAlpha); - gl.pixelStorei(GL_UNPACK_COLORSPACE_CONVERSION_WEBGL, flags.colorSpace); - gl.pixelStorei(GL_UNPACK_ALIGNMENT, flags.unpackAlignment); - } + /*------------------------------------------------------------------------*/ - // ------------------------------------------------------- - // Tex image data - // ------------------------------------------------------- - function TexImage () { - TexFlags.call(this); + /** + * Adds two numbers. + * + * @static + * @memberOf _ + * @since 3.4.0 + * @category Math + * @param {number} augend The first number in an addition. + * @param {number} addend The second number in an addition. + * @returns {number} Returns the total. + * @example + * + * _.add(6, 4); + * // => 10 + */ + var add = createMathOperation(function(augend, addend) { + return augend + addend; + }, 0); - this.xOffset = 0; - this.yOffset = 0; + /** + * Computes `number` rounded up to `precision`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Math + * @param {number} number The number to round up. + * @param {number} [precision=0] The precision to round up to. + * @returns {number} Returns the rounded up number. + * @example + * + * _.ceil(4.006); + * // => 5 + * + * _.ceil(6.004, 2); + * // => 6.01 + * + * _.ceil(6040, -2); + * // => 6100 + */ + var ceil = createRound('ceil'); - // data - this.data = null; - this.needsFree = false; + /** + * Divide two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} dividend The first number in a division. + * @param {number} divisor The second number in a division. + * @returns {number} Returns the quotient. + * @example + * + * _.divide(6, 4); + * // => 1.5 + */ + var divide = createMathOperation(function(dividend, divisor) { + return dividend / divisor; + }, 1); - // html element - this.element = null; + /** + * Computes `number` rounded down to `precision`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Math + * @param {number} number The number to round down. + * @param {number} [precision=0] The precision to round down to. + * @returns {number} Returns the rounded down number. + * @example + * + * _.floor(4.006); + * // => 4 + * + * _.floor(0.046, 2); + * // => 0.04 + * + * _.floor(4060, -2); + * // => 4000 + */ + var floor = createRound('floor'); - // copyTexImage info - this.needsCopy = false; - } + /** + * Computes the maximum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * _.max([]); + * // => undefined + */ + function max(array) { + return (array && array.length) + ? baseExtremum(array, identity, baseGt) + : undefined; + } - function parseImage (image, options) { - var data = null; - if (isPixelData(options)) { - data = options; - } else if (options) { - check$1.type(options, 'object', 'invalid pixel data type'); - parseFlags(image, options); - if ('x' in options) { - image.xOffset = options.x | 0; - } - if ('y' in options) { - image.yOffset = options.y | 0; - } - if (isPixelData(options.data)) { - data = options.data; - } + /** + * This method is like `_.max` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * the value is ranked. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {*} Returns the maximum value. + * @example + * + * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * + * _.maxBy(objects, function(o) { return o.n; }); + * // => { 'n': 2 } + * + * // The `_.property` iteratee shorthand. + * _.maxBy(objects, 'n'); + * // => { 'n': 2 } + */ + function maxBy(array, iteratee) { + return (array && array.length) + ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) + : undefined; + } + + /** + * Computes the mean of the values in `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @returns {number} Returns the mean. + * @example + * + * _.mean([4, 2, 8, 6]); + * // => 5 + */ + function mean(array) { + return baseMean(array, identity); + } + + /** + * This method is like `_.mean` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the value to be averaged. + * The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the mean. + * @example + * + * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + * + * _.meanBy(objects, function(o) { return o.n; }); + * // => 5 + * + * // The `_.property` iteratee shorthand. + * _.meanBy(objects, 'n'); + * // => 5 + */ + function meanBy(array, iteratee) { + return baseMean(array, getIteratee(iteratee, 2)); } - check$1( - !image.compressed || - data instanceof Uint8Array, - 'compressed texture data must be stored in a uint8array'); - - if (options.copy) { - check$1(!data, 'can not specify copy and data field for the same texture'); - var viewW = contextState.viewportWidth; - var viewH = contextState.viewportHeight; - image.width = image.width || (viewW - image.xOffset); - image.height = image.height || (viewH - image.yOffset); - image.needsCopy = true; - check$1(image.xOffset >= 0 && image.xOffset < viewW && - image.yOffset >= 0 && image.yOffset < viewH && - image.width > 0 && image.width <= viewW && - image.height > 0 && image.height <= viewH, - 'copy texture read out of bounds'); - } else if (!data) { - image.width = image.width || 1; - image.height = image.height || 1; - image.channels = image.channels || 4; - } else if (isTypedArray(data)) { - image.channels = image.channels || 4; - image.data = data; - if (!('type' in options) && image.type === GL_UNSIGNED_BYTE$4) { - image.type = typedArrayCode$1(data); - } - } else if (isNumericArray(data)) { - image.channels = image.channels || 4; - convertData(image, data); - image.alignment = 1; - image.needsFree = true; - } else if (isNDArrayLike(data)) { - var array = data.data; - if (!Array.isArray(array) && image.type === GL_UNSIGNED_BYTE$4) { - image.type = typedArrayCode$1(array); - } - var shape = data.shape; - var stride = data.stride; - var shapeX, shapeY, shapeC, strideX, strideY, strideC; - if (shape.length === 3) { - shapeC = shape[2]; - strideC = stride[2]; - } else { - check$1(shape.length === 2, 'invalid ndarray pixel data, must be 2 or 3D'); - shapeC = 1; - strideC = 1; - } - shapeX = shape[0]; - shapeY = shape[1]; - strideX = stride[0]; - strideY = stride[1]; - image.alignment = 1; - image.width = shapeX; - image.height = shapeY; - image.channels = shapeC; - image.format = image.internalformat = CHANNELS_FORMAT[shapeC]; - image.needsFree = true; - transposeData(image, array, strideX, strideY, strideC, data.offset); - } else if (isCanvasElement(data) || isContext2D(data)) { - if (isCanvasElement(data)) { - image.element = data; - } else { - image.element = data.canvas; - } - image.width = image.element.width; - image.height = image.element.height; - image.channels = 4; - } else if (isImageElement(data)) { - image.element = data; - image.width = data.naturalWidth; - image.height = data.naturalHeight; - image.channels = 4; - } else if (isVideoElement(data)) { - image.element = data; - image.width = data.videoWidth; - image.height = data.videoHeight; - image.channels = 4; - } else if (isRectArray(data)) { - var w = image.width || data[0].length; - var h = image.height || data.length; - var c = image.channels; - if (isArrayLike(data[0][0])) { - c = c || data[0][0].length; - } else { - c = c || 1; - } - var arrayShape = flattenUtils.shape(data); - var n = 1; - for (var dd = 0; dd < arrayShape.length; ++dd) { - n *= arrayShape[dd]; - } - var allocData = preConvert(image, n); - flattenUtils.flatten(data, arrayShape, '', allocData); - postConvert(image, allocData); - image.alignment = 1; - image.width = w; - image.height = h; - image.channels = c; - image.format = image.internalformat = CHANNELS_FORMAT[c]; - image.needsFree = true; + /** + * Computes the minimum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * _.min([]); + * // => undefined + */ + function min(array) { + return (array && array.length) + ? baseExtremum(array, identity, baseLt) + : undefined; } - if (image.type === GL_FLOAT$3) { - check$1(limits.extensions.indexOf('oes_texture_float') >= 0, - 'oes_texture_float extension not enabled'); - } else if (image.type === GL_HALF_FLOAT_OES$1) { - check$1(limits.extensions.indexOf('oes_texture_half_float') >= 0, - 'oes_texture_half_float extension not enabled'); + /** + * This method is like `_.min` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * the value is ranked. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {*} Returns the minimum value. + * @example + * + * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * + * _.minBy(objects, function(o) { return o.n; }); + * // => { 'n': 1 } + * + * // The `_.property` iteratee shorthand. + * _.minBy(objects, 'n'); + * // => { 'n': 1 } + */ + function minBy(array, iteratee) { + return (array && array.length) + ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) + : undefined; } - // do compressed texture validation here. - } + /** + * Multiply two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} multiplier The first number in a multiplication. + * @param {number} multiplicand The second number in a multiplication. + * @returns {number} Returns the product. + * @example + * + * _.multiply(6, 4); + * // => 24 + */ + var multiply = createMathOperation(function(multiplier, multiplicand) { + return multiplier * multiplicand; + }, 1); - function setImage (info, target, miplevel) { - var element = info.element; - var data = info.data; - var internalformat = info.internalformat; - var format = info.format; - var type = info.type; - var width = info.width; - var height = info.height; + /** + * Computes `number` rounded to `precision`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Math + * @param {number} number The number to round. + * @param {number} [precision=0] The precision to round to. + * @returns {number} Returns the rounded number. + * @example + * + * _.round(4.006); + * // => 4 + * + * _.round(4.006, 2); + * // => 4.01 + * + * _.round(4060, -2); + * // => 4100 + */ + var round = createRound('round'); - setFlags(info); + /** + * Subtract two numbers. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {number} minuend The first number in a subtraction. + * @param {number} subtrahend The second number in a subtraction. + * @returns {number} Returns the difference. + * @example + * + * _.subtract(6, 4); + * // => 2 + */ + var subtract = createMathOperation(function(minuend, subtrahend) { + return minuend - subtrahend; + }, 0); - if (element) { - gl.texImage2D(target, miplevel, format, format, type, element); - } else if (info.compressed) { - gl.compressedTexImage2D(target, miplevel, internalformat, width, height, 0, data); - } else if (info.needsCopy) { - reglPoll(); - gl.copyTexImage2D( - target, miplevel, format, info.xOffset, info.yOffset, width, height, 0); - } else { - gl.texImage2D( - target, miplevel, format, width, height, 0, format, type, data); + /** + * Computes the sum of the values in `array`. + * + * @static + * @memberOf _ + * @since 3.4.0 + * @category Math + * @param {Array} array The array to iterate over. + * @returns {number} Returns the sum. + * @example + * + * _.sum([4, 2, 8, 6]); + * // => 20 + */ + function sum(array) { + return (array && array.length) + ? baseSum(array, identity) + : 0; } - } - - function setSubImage (info, target, x, y, miplevel) { - var element = info.element; - var data = info.data; - var internalformat = info.internalformat; - var format = info.format; - var type = info.type; - var width = info.width; - var height = info.height; - - setFlags(info); - if (element) { - gl.texSubImage2D( - target, miplevel, x, y, format, type, element); - } else if (info.compressed) { - gl.compressedTexSubImage2D( - target, miplevel, x, y, internalformat, width, height, data); - } else if (info.needsCopy) { - reglPoll(); - gl.copyTexSubImage2D( - target, miplevel, x, y, info.xOffset, info.yOffset, width, height); - } else { - gl.texSubImage2D( - target, miplevel, x, y, width, height, format, type, data); + /** + * This method is like `_.sum` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the value to be summed. + * The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the sum. + * @example + * + * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + * + * _.sumBy(objects, function(o) { return o.n; }); + * // => 20 + * + * // The `_.property` iteratee shorthand. + * _.sumBy(objects, 'n'); + * // => 20 + */ + function sumBy(array, iteratee) { + return (array && array.length) + ? baseSum(array, getIteratee(iteratee, 2)) + : 0; } - } - // texImage pool - var imagePool = []; + /*------------------------------------------------------------------------*/ + + // Add methods that return wrapped values in chain sequences. + lodash.after = after; + lodash.ary = ary; + lodash.assign = assign; + lodash.assignIn = assignIn; + lodash.assignInWith = assignInWith; + lodash.assignWith = assignWith; + lodash.at = at; + lodash.before = before; + lodash.bind = bind; + lodash.bindAll = bindAll; + lodash.bindKey = bindKey; + lodash.castArray = castArray; + lodash.chain = chain; + lodash.chunk = chunk; + lodash.compact = compact; + lodash.concat = concat; + lodash.cond = cond; + lodash.conforms = conforms; + lodash.constant = constant; + lodash.countBy = countBy; + lodash.create = create; + lodash.curry = curry; + lodash.curryRight = curryRight; + lodash.debounce = debounce; + lodash.defaults = defaults; + lodash.defaultsDeep = defaultsDeep; + lodash.defer = defer; + lodash.delay = delay; + lodash.difference = difference; + lodash.differenceBy = differenceBy; + lodash.differenceWith = differenceWith; + lodash.drop = drop; + lodash.dropRight = dropRight; + lodash.dropRightWhile = dropRightWhile; + lodash.dropWhile = dropWhile; + lodash.fill = fill; + lodash.filter = filter; + lodash.flatMap = flatMap; + lodash.flatMapDeep = flatMapDeep; + lodash.flatMapDepth = flatMapDepth; + lodash.flatten = flatten; + lodash.flattenDeep = flattenDeep; + lodash.flattenDepth = flattenDepth; + lodash.flip = flip; + lodash.flow = flow; + lodash.flowRight = flowRight; + lodash.fromPairs = fromPairs; + lodash.functions = functions; + lodash.functionsIn = functionsIn; + lodash.groupBy = groupBy; + lodash.initial = initial; + lodash.intersection = intersection; + lodash.intersectionBy = intersectionBy; + lodash.intersectionWith = intersectionWith; + lodash.invert = invert; + lodash.invertBy = invertBy; + lodash.invokeMap = invokeMap; + lodash.iteratee = iteratee; + lodash.keyBy = keyBy; + lodash.keys = keys; + lodash.keysIn = keysIn; + lodash.map = map; + lodash.mapKeys = mapKeys; + lodash.mapValues = mapValues; + lodash.matches = matches; + lodash.matchesProperty = matchesProperty; + lodash.memoize = memoize; + lodash.merge = merge; + lodash.mergeWith = mergeWith; + lodash.method = method; + lodash.methodOf = methodOf; + lodash.mixin = mixin; + lodash.negate = negate; + lodash.nthArg = nthArg; + lodash.omit = omit; + lodash.omitBy = omitBy; + lodash.once = once; + lodash.orderBy = orderBy; + lodash.over = over; + lodash.overArgs = overArgs; + lodash.overEvery = overEvery; + lodash.overSome = overSome; + lodash.partial = partial; + lodash.partialRight = partialRight; + lodash.partition = partition; + lodash.pick = pick; + lodash.pickBy = pickBy; + lodash.property = property; + lodash.propertyOf = propertyOf; + lodash.pull = pull; + lodash.pullAll = pullAll; + lodash.pullAllBy = pullAllBy; + lodash.pullAllWith = pullAllWith; + lodash.pullAt = pullAt; + lodash.range = range; + lodash.rangeRight = rangeRight; + lodash.rearg = rearg; + lodash.reject = reject; + lodash.remove = remove; + lodash.rest = rest; + lodash.reverse = reverse; + lodash.sampleSize = sampleSize; + lodash.set = set; + lodash.setWith = setWith; + lodash.shuffle = shuffle; + lodash.slice = slice; + lodash.sortBy = sortBy; + lodash.sortedUniq = sortedUniq; + lodash.sortedUniqBy = sortedUniqBy; + lodash.split = split; + lodash.spread = spread; + lodash.tail = tail; + lodash.take = take; + lodash.takeRight = takeRight; + lodash.takeRightWhile = takeRightWhile; + lodash.takeWhile = takeWhile; + lodash.tap = tap; + lodash.throttle = throttle; + lodash.thru = thru; + lodash.toArray = toArray; + lodash.toPairs = toPairs; + lodash.toPairsIn = toPairsIn; + lodash.toPath = toPath; + lodash.toPlainObject = toPlainObject; + lodash.transform = transform; + lodash.unary = unary; + lodash.union = union; + lodash.unionBy = unionBy; + lodash.unionWith = unionWith; + lodash.uniq = uniq; + lodash.uniqBy = uniqBy; + lodash.uniqWith = uniqWith; + lodash.unset = unset; + lodash.unzip = unzip; + lodash.unzipWith = unzipWith; + lodash.update = update; + lodash.updateWith = updateWith; + lodash.values = values; + lodash.valuesIn = valuesIn; + lodash.without = without; + lodash.words = words; + lodash.wrap = wrap; + lodash.xor = xor; + lodash.xorBy = xorBy; + lodash.xorWith = xorWith; + lodash.zip = zip; + lodash.zipObject = zipObject; + lodash.zipObjectDeep = zipObjectDeep; + lodash.zipWith = zipWith; - function allocImage () { - return imagePool.pop() || new TexImage() - } + // Add aliases. + lodash.entries = toPairs; + lodash.entriesIn = toPairsIn; + lodash.extend = assignIn; + lodash.extendWith = assignInWith; - function freeImage (image) { - if (image.needsFree) { - pool.freeType(image.data); - } - TexImage.call(image); - imagePool.push(image); - } + // Add methods to `lodash.prototype`. + mixin(lodash, lodash); - // ------------------------------------------------------- - // Mip map - // ------------------------------------------------------- - function MipMap () { - TexFlags.call(this); + /*------------------------------------------------------------------------*/ - this.genMipmaps = false; - this.mipmapHint = GL_DONT_CARE; - this.mipmask = 0; - this.images = Array(16); - } + // Add methods that return unwrapped values in chain sequences. + lodash.add = add; + lodash.attempt = attempt; + lodash.camelCase = camelCase; + lodash.capitalize = capitalize; + lodash.ceil = ceil; + lodash.clamp = clamp; + lodash.clone = clone; + lodash.cloneDeep = cloneDeep; + lodash.cloneDeepWith = cloneDeepWith; + lodash.cloneWith = cloneWith; + lodash.conformsTo = conformsTo; + lodash.deburr = deburr; + lodash.defaultTo = defaultTo; + lodash.divide = divide; + lodash.endsWith = endsWith; + lodash.eq = eq; + lodash.escape = escape; + lodash.escapeRegExp = escapeRegExp; + lodash.every = every; + lodash.find = find; + lodash.findIndex = findIndex; + lodash.findKey = findKey; + lodash.findLast = findLast; + lodash.findLastIndex = findLastIndex; + lodash.findLastKey = findLastKey; + lodash.floor = floor; + lodash.forEach = forEach; + lodash.forEachRight = forEachRight; + lodash.forIn = forIn; + lodash.forInRight = forInRight; + lodash.forOwn = forOwn; + lodash.forOwnRight = forOwnRight; + lodash.get = get; + lodash.gt = gt; + lodash.gte = gte; + lodash.has = has; + lodash.hasIn = hasIn; + lodash.head = head; + lodash.identity = identity; + lodash.includes = includes; + lodash.indexOf = indexOf; + lodash.inRange = inRange; + lodash.invoke = invoke; + lodash.isArguments = isArguments; + lodash.isArray = isArray; + lodash.isArrayBuffer = isArrayBuffer; + lodash.isArrayLike = isArrayLike; + lodash.isArrayLikeObject = isArrayLikeObject; + lodash.isBoolean = isBoolean; + lodash.isBuffer = isBuffer; + lodash.isDate = isDate; + lodash.isElement = isElement; + lodash.isEmpty = isEmpty; + lodash.isEqual = isEqual; + lodash.isEqualWith = isEqualWith; + lodash.isError = isError; + lodash.isFinite = isFinite; + lodash.isFunction = isFunction; + lodash.isInteger = isInteger; + lodash.isLength = isLength; + lodash.isMap = isMap; + lodash.isMatch = isMatch; + lodash.isMatchWith = isMatchWith; + lodash.isNaN = isNaN; + lodash.isNative = isNative; + lodash.isNil = isNil; + lodash.isNull = isNull; + lodash.isNumber = isNumber; + lodash.isObject = isObject; + lodash.isObjectLike = isObjectLike; + lodash.isPlainObject = isPlainObject; + lodash.isRegExp = isRegExp; + lodash.isSafeInteger = isSafeInteger; + lodash.isSet = isSet; + lodash.isString = isString; + lodash.isSymbol = isSymbol; + lodash.isTypedArray = isTypedArray; + lodash.isUndefined = isUndefined; + lodash.isWeakMap = isWeakMap; + lodash.isWeakSet = isWeakSet; + lodash.join = join; + lodash.kebabCase = kebabCase; + lodash.last = last; + lodash.lastIndexOf = lastIndexOf; + lodash.lowerCase = lowerCase; + lodash.lowerFirst = lowerFirst; + lodash.lt = lt; + lodash.lte = lte; + lodash.max = max; + lodash.maxBy = maxBy; + lodash.mean = mean; + lodash.meanBy = meanBy; + lodash.min = min; + lodash.minBy = minBy; + lodash.stubArray = stubArray; + lodash.stubFalse = stubFalse; + lodash.stubObject = stubObject; + lodash.stubString = stubString; + lodash.stubTrue = stubTrue; + lodash.multiply = multiply; + lodash.nth = nth; + lodash.noConflict = noConflict; + lodash.noop = noop; + lodash.now = now; + lodash.pad = pad; + lodash.padEnd = padEnd; + lodash.padStart = padStart; + lodash.parseInt = parseInt; + lodash.random = random; + lodash.reduce = reduce; + lodash.reduceRight = reduceRight; + lodash.repeat = repeat; + lodash.replace = replace; + lodash.result = result; + lodash.round = round; + lodash.runInContext = runInContext; + lodash.sample = sample; + lodash.size = size; + lodash.snakeCase = snakeCase; + lodash.some = some; + lodash.sortedIndex = sortedIndex; + lodash.sortedIndexBy = sortedIndexBy; + lodash.sortedIndexOf = sortedIndexOf; + lodash.sortedLastIndex = sortedLastIndex; + lodash.sortedLastIndexBy = sortedLastIndexBy; + lodash.sortedLastIndexOf = sortedLastIndexOf; + lodash.startCase = startCase; + lodash.startsWith = startsWith; + lodash.subtract = subtract; + lodash.sum = sum; + lodash.sumBy = sumBy; + lodash.template = template; + lodash.times = times; + lodash.toFinite = toFinite; + lodash.toInteger = toInteger; + lodash.toLength = toLength; + lodash.toLower = toLower; + lodash.toNumber = toNumber; + lodash.toSafeInteger = toSafeInteger; + lodash.toString = toString; + lodash.toUpper = toUpper; + lodash.trim = trim; + lodash.trimEnd = trimEnd; + lodash.trimStart = trimStart; + lodash.truncate = truncate; + lodash.unescape = unescape; + lodash.uniqueId = uniqueId; + lodash.upperCase = upperCase; + lodash.upperFirst = upperFirst; - function parseMipMapFromShape (mipmap, width, height) { - var img = mipmap.images[0] = allocImage(); - mipmap.mipmask = 1; - img.width = mipmap.width = width; - img.height = mipmap.height = height; - img.channels = mipmap.channels = 4; - } + // Add aliases. + lodash.each = forEach; + lodash.eachRight = forEachRight; + lodash.first = head; - function parseMipMapFromObject (mipmap, options) { - var imgData = null; - if (isPixelData(options)) { - imgData = mipmap.images[0] = allocImage(); - copyFlags(imgData, mipmap); - parseImage(imgData, options); - mipmap.mipmask = 1; - } else { - parseFlags(mipmap, options); - if (Array.isArray(options.mipmap)) { - var mipData = options.mipmap; - for (var i = 0; i < mipData.length; ++i) { - imgData = mipmap.images[i] = allocImage(); - copyFlags(imgData, mipmap); - imgData.width >>= i; - imgData.height >>= i; - parseImage(imgData, mipData[i]); - mipmap.mipmask |= (1 << i); + mixin(lodash, (function() { + var source = {}; + baseForOwn(lodash, function(func, methodName) { + if (!hasOwnProperty.call(lodash.prototype, methodName)) { + source[methodName] = func; } - } else { - imgData = mipmap.images[0] = allocImage(); - copyFlags(imgData, mipmap); - parseImage(imgData, options); - mipmap.mipmask = 1; - } - } - copyFlags(mipmap, mipmap.images[0]); - - // For textures of the compressed format WEBGL_compressed_texture_s3tc - // we must have that - // - // "When level equals zero width and height must be a multiple of 4. - // When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. " - // - // but we do not yet support having multiple mipmap levels for compressed textures, - // so we only test for level zero. - - if (mipmap.compressed && - (mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT) || - (mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || - (mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) || - (mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) { - check$1(mipmap.width % 4 === 0 && - mipmap.height % 4 === 0, - 'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4'); - } - } - - function setMipMap (mipmap, target) { - var images = mipmap.images; - for (var i = 0; i < images.length; ++i) { - if (!images[i]) { - return - } - setImage(images[i], target, i); - } - } - - var mipPool = []; - - function allocMipMap () { - var result = mipPool.pop() || new MipMap(); - TexFlags.call(result); - result.mipmask = 0; - for (var i = 0; i < 16; ++i) { - result.images[i] = null; - } - return result - } - - function freeMipMap (mipmap) { - var images = mipmap.images; - for (var i = 0; i < images.length; ++i) { - if (images[i]) { - freeImage(images[i]); - } - images[i] = null; - } - mipPool.push(mipmap); - } - - // ------------------------------------------------------- - // Tex info - // ------------------------------------------------------- - function TexInfo () { - this.minFilter = GL_NEAREST$1; - this.magFilter = GL_NEAREST$1; - - this.wrapS = GL_CLAMP_TO_EDGE$1; - this.wrapT = GL_CLAMP_TO_EDGE$1; - - this.anisotropic = 1; - - this.genMipmaps = false; - this.mipmapHint = GL_DONT_CARE; - } - - function parseTexInfo (info, options) { - if ('min' in options) { - var minFilter = options.min; - check$1.parameter(minFilter, minFilters); - info.minFilter = minFilters[minFilter]; - if (MIPMAP_FILTERS.indexOf(info.minFilter) >= 0) { - info.genMipmaps = true; - } - } - - if ('mag' in options) { - var magFilter = options.mag; - check$1.parameter(magFilter, magFilters); - info.magFilter = magFilters[magFilter]; - } - - var wrapS = info.wrapS; - var wrapT = info.wrapT; - if ('wrap' in options) { - var wrap = options.wrap; - if (typeof wrap === 'string') { - check$1.parameter(wrap, wrapModes); - wrapS = wrapT = wrapModes[wrap]; - } else if (Array.isArray(wrap)) { - check$1.parameter(wrap[0], wrapModes); - check$1.parameter(wrap[1], wrapModes); - wrapS = wrapModes[wrap[0]]; - wrapT = wrapModes[wrap[1]]; - } - } else { - if ('wrapS' in options) { - var optWrapS = options.wrapS; - check$1.parameter(optWrapS, wrapModes); - wrapS = wrapModes[optWrapS]; - } - if ('wrapT' in options) { - var optWrapT = options.wrapT; - check$1.parameter(optWrapT, wrapModes); - wrapT = wrapModes[optWrapT]; - } - } - info.wrapS = wrapS; - info.wrapT = wrapT; - - if ('anisotropic' in options) { - var anisotropic = options.anisotropic; - check$1(typeof anisotropic === 'number' && - anisotropic >= 1 && anisotropic <= limits.maxAnisotropic, - 'aniso samples must be between 1 and '); - info.anisotropic = options.anisotropic; - } - - if ('mipmap' in options) { - var hasMipMap = false; - switch (typeof options.mipmap) { - case 'string': - check$1.parameter(options.mipmap, mipmapHint, - 'invalid mipmap hint'); - info.mipmapHint = mipmapHint[options.mipmap]; - info.genMipmaps = true; - hasMipMap = true; - break - - case 'boolean': - hasMipMap = info.genMipmaps = options.mipmap; - break - - case 'object': - check$1(Array.isArray(options.mipmap), 'invalid mipmap type'); - info.genMipmaps = false; - hasMipMap = true; - break - - default: - check$1.raise('invalid mipmap type'); - } - if (hasMipMap && !('min' in options)) { - info.minFilter = GL_NEAREST_MIPMAP_NEAREST$1; - } - } - } - - function setTexInfo (info, target) { - gl.texParameteri(target, GL_TEXTURE_MIN_FILTER, info.minFilter); - gl.texParameteri(target, GL_TEXTURE_MAG_FILTER, info.magFilter); - gl.texParameteri(target, GL_TEXTURE_WRAP_S, info.wrapS); - gl.texParameteri(target, GL_TEXTURE_WRAP_T, info.wrapT); - if (extensions.ext_texture_filter_anisotropic) { - gl.texParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, info.anisotropic); - } - if (info.genMipmaps) { - gl.hint(GL_GENERATE_MIPMAP_HINT, info.mipmapHint); - gl.generateMipmap(target); - } - } - - // ------------------------------------------------------- - // Full texture object - // ------------------------------------------------------- - var textureCount = 0; - var textureSet = {}; - var numTexUnits = limits.maxTextureUnits; - var textureUnits = Array(numTexUnits).map(function () { - return null - }); - - function REGLTexture (target) { - TexFlags.call(this); - this.mipmask = 0; - this.internalformat = GL_RGBA; - - this.id = textureCount++; - - this.refCount = 1; + }); + return source; + }()), { 'chain': false }); - this.target = target; - this.texture = gl.createTexture(); + /*------------------------------------------------------------------------*/ - this.unit = -1; - this.bindCount = 0; + /** + * The semantic version number. + * + * @static + * @memberOf _ + * @type {string} + */ + lodash.VERSION = VERSION; - this.texInfo = new TexInfo(); + // Assign default placeholders. + arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { + lodash[methodName].placeholder = lodash; + }); - if (config.profile) { - this.stats = {size: 0}; - } - } + // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. + arrayEach(['drop', 'take'], function(methodName, index) { + LazyWrapper.prototype[methodName] = function(n) { + n = n === undefined ? 1 : nativeMax(toInteger(n), 0); - function tempBind (texture) { - gl.activeTexture(GL_TEXTURE0); - gl.bindTexture(texture.target, texture.texture); - } + var result = (this.__filtered__ && !index) + ? new LazyWrapper(this) + : this.clone(); - function tempRestore () { - var prev = textureUnits[0]; - if (prev) { - gl.bindTexture(prev.target, prev.texture); - } else { - gl.bindTexture(GL_TEXTURE_2D, null); - } - } + if (result.__filtered__) { + result.__takeCount__ = nativeMin(n, result.__takeCount__); + } else { + result.__views__.push({ + 'size': nativeMin(n, MAX_ARRAY_LENGTH), + 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') + }); + } + return result; + }; - function destroy (texture) { - var handle = texture.texture; - check$1(handle, 'must not double destroy texture'); - var unit = texture.unit; - var target = texture.target; - if (unit >= 0) { - gl.activeTexture(GL_TEXTURE0 + unit); - gl.bindTexture(target, null); - textureUnits[unit] = null; - } - gl.deleteTexture(handle); - texture.texture = null; - texture.params = null; - texture.pixels = null; - texture.refCount = 0; - delete textureSet[texture.id]; - stats.textureCount--; - } + LazyWrapper.prototype[methodName + 'Right'] = function(n) { + return this.reverse()[methodName](n).reverse(); + }; + }); - extend(REGLTexture.prototype, { - bind: function () { - var texture = this; - texture.bindCount += 1; - var unit = texture.unit; - if (unit < 0) { - for (var i = 0; i < numTexUnits; ++i) { - var other = textureUnits[i]; - if (other) { - if (other.bindCount > 0) { - continue - } - other.unit = -1; - } - textureUnits[i] = texture; - unit = i; - break - } - if (unit >= numTexUnits) { - check$1.raise('insufficient number of texture units'); - } - if (config.profile && stats.maxTextureUnits < (unit + 1)) { - stats.maxTextureUnits = unit + 1; // +1, since the units are zero-based - } - texture.unit = unit; - gl.activeTexture(GL_TEXTURE0 + unit); - gl.bindTexture(texture.target, texture.texture); - } - return unit - }, + // Add `LazyWrapper` methods that accept an `iteratee` value. + arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { + var type = index + 1, + isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; - unbind: function () { - this.bindCount -= 1; - }, + LazyWrapper.prototype[methodName] = function(iteratee) { + var result = this.clone(); + result.__iteratees__.push({ + 'iteratee': getIteratee(iteratee, 3), + 'type': type + }); + result.__filtered__ = result.__filtered__ || isFilter; + return result; + }; + }); - decRef: function () { - if (--this.refCount <= 0) { - destroy(this); - } - } - }); + // Add `LazyWrapper` methods for `_.head` and `_.last`. + arrayEach(['head', 'last'], function(methodName, index) { + var takeName = 'take' + (index ? 'Right' : ''); - function createTexture2D (a, b) { - var texture = new REGLTexture(GL_TEXTURE_2D); - textureSet[texture.id] = texture; - stats.textureCount++; + LazyWrapper.prototype[methodName] = function() { + return this[takeName](1).value()[0]; + }; + }); - function reglTexture2D (a, b) { - var texInfo = texture.texInfo; - TexInfo.call(texInfo); - var mipData = allocMipMap(); + // Add `LazyWrapper` methods for `_.initial` and `_.tail`. + arrayEach(['initial', 'tail'], function(methodName, index) { + var dropName = 'drop' + (index ? '' : 'Right'); - if (typeof a === 'number') { - if (typeof b === 'number') { - parseMipMapFromShape(mipData, a | 0, b | 0); - } else { - parseMipMapFromShape(mipData, a | 0, a | 0); - } - } else if (a) { - check$1.type(a, 'object', 'invalid arguments to regl.texture'); - parseTexInfo(texInfo, a); - parseMipMapFromObject(mipData, a); - } else { - // empty textures get assigned a default shape of 1x1 - parseMipMapFromShape(mipData, 1, 1); - } + LazyWrapper.prototype[methodName] = function() { + return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); + }; + }); - if (texInfo.genMipmaps) { - mipData.mipmask = (mipData.width << 1) - 1; - } - texture.mipmask = mipData.mipmask; + LazyWrapper.prototype.compact = function() { + return this.filter(identity); + }; - copyFlags(texture, mipData); + LazyWrapper.prototype.find = function(predicate) { + return this.filter(predicate).head(); + }; - check$1.texture2D(texInfo, mipData, limits); - texture.internalformat = mipData.internalformat; + LazyWrapper.prototype.findLast = function(predicate) { + return this.reverse().find(predicate); + }; - reglTexture2D.width = mipData.width; - reglTexture2D.height = mipData.height; + LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { + if (typeof path == 'function') { + return new LazyWrapper(this); + } + return this.map(function(value) { + return baseInvoke(value, path, args); + }); + }); - tempBind(texture); - setMipMap(mipData, GL_TEXTURE_2D); - setTexInfo(texInfo, GL_TEXTURE_2D); - tempRestore(); + LazyWrapper.prototype.reject = function(predicate) { + return this.filter(negate(getIteratee(predicate))); + }; - freeMipMap(mipData); + LazyWrapper.prototype.slice = function(start, end) { + start = toInteger(start); - if (config.profile) { - texture.stats.size = getTextureSize( - texture.internalformat, - texture.type, - mipData.width, - mipData.height, - texInfo.genMipmaps, - false); + var result = this; + if (result.__filtered__ && (start > 0 || end < 0)) { + return new LazyWrapper(result); } - reglTexture2D.format = textureFormatsInvert[texture.internalformat]; - reglTexture2D.type = textureTypesInvert[texture.type]; - - reglTexture2D.mag = magFiltersInvert[texInfo.magFilter]; - reglTexture2D.min = minFiltersInvert[texInfo.minFilter]; + if (start < 0) { + result = result.takeRight(-start); + } else if (start) { + result = result.drop(start); + } + if (end !== undefined) { + end = toInteger(end); + result = end < 0 ? result.dropRight(-end) : result.take(end - start); + } + return result; + }; - reglTexture2D.wrapS = wrapModesInvert[texInfo.wrapS]; - reglTexture2D.wrapT = wrapModesInvert[texInfo.wrapT]; + LazyWrapper.prototype.takeRightWhile = function(predicate) { + return this.reverse().takeWhile(predicate).reverse(); + }; - return reglTexture2D - } + LazyWrapper.prototype.toArray = function() { + return this.take(MAX_ARRAY_LENGTH); + }; - function subimage (image, x_, y_, level_) { - check$1(!!image, 'must specify image data'); + // Add `LazyWrapper` methods to `lodash.prototype`. + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), + isTaker = /^(?:head|last)$/.test(methodName), + lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], + retUnwrapped = isTaker || /^find/.test(methodName); - var x = x_ | 0; - var y = y_ | 0; - var level = level_ | 0; + if (!lodashFunc) { + return; + } + lodash.prototype[methodName] = function() { + var value = this.__wrapped__, + args = isTaker ? [1] : arguments, + isLazy = value instanceof LazyWrapper, + iteratee = args[0], + useLazy = isLazy || isArray(value); - var imageData = allocImage(); - copyFlags(imageData, texture); - imageData.width = 0; - imageData.height = 0; - parseImage(imageData, image); - imageData.width = imageData.width || ((texture.width >> level) - x); - imageData.height = imageData.height || ((texture.height >> level) - y); + var interceptor = function(value) { + var result = lodashFunc.apply(lodash, arrayPush([value], args)); + return (isTaker && chainAll) ? result[0] : result; + }; - check$1( - texture.type === imageData.type && - texture.format === imageData.format && - texture.internalformat === imageData.internalformat, - 'incompatible format for texture.subimage'); - check$1( - x >= 0 && y >= 0 && - x + imageData.width <= texture.width && - y + imageData.height <= texture.height, - 'texture.subimage write out of bounds'); - check$1( - texture.mipmask & (1 << level), - 'missing mipmap data'); - check$1( - imageData.data || imageData.element || imageData.needsCopy, - 'missing image data'); + if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { + // Avoid lazy use if the iteratee has a "length" value other than `1`. + isLazy = useLazy = false; + } + var chainAll = this.__chain__, + isHybrid = !!this.__actions__.length, + isUnwrapped = retUnwrapped && !chainAll, + onlyLazy = isLazy && !isHybrid; - tempBind(texture); - setSubImage(imageData, GL_TEXTURE_2D, x, y, level); - tempRestore(); + if (!retUnwrapped && useLazy) { + value = onlyLazy ? value : new LazyWrapper(this); + var result = func.apply(value, args); + result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); + return new LodashWrapper(result, chainAll); + } + if (isUnwrapped && onlyLazy) { + return func.apply(this, args); + } + result = this.thru(interceptor); + return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; + }; + }); - freeImage(imageData); + // Add `Array` methods to `lodash.prototype`. + arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { + var func = arrayProto[methodName], + chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', + retUnwrapped = /^(?:pop|shift)$/.test(methodName); - return reglTexture2D - } + lodash.prototype[methodName] = function() { + var args = arguments; + if (retUnwrapped && !this.__chain__) { + var value = this.value(); + return func.apply(isArray(value) ? value : [], args); + } + return this[chainName](function(value) { + return func.apply(isArray(value) ? value : [], args); + }); + }; + }); - function resize (w_, h_) { - var w = w_ | 0; - var h = (h_ | 0) || w; - if (w === texture.width && h === texture.height) { - return reglTexture2D + // Map minified method names to their real names. + baseForOwn(LazyWrapper.prototype, function(func, methodName) { + var lodashFunc = lodash[methodName]; + if (lodashFunc) { + var key = lodashFunc.name + ''; + if (!hasOwnProperty.call(realNames, key)) { + realNames[key] = []; + } + realNames[key].push({ 'name': methodName, 'func': lodashFunc }); } + }); - reglTexture2D.width = texture.width = w; - reglTexture2D.height = texture.height = h; + realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ + 'name': 'wrapper', + 'func': undefined + }]; - tempBind(texture); - for (var i = 0; texture.mipmask >> i; ++i) { - gl.texImage2D( - GL_TEXTURE_2D, - i, - texture.format, - w >> i, - h >> i, - 0, - texture.format, - texture.type, - null); - } - tempRestore(); + // Add methods to `LazyWrapper`. + LazyWrapper.prototype.clone = lazyClone; + LazyWrapper.prototype.reverse = lazyReverse; + LazyWrapper.prototype.value = lazyValue; - // also, recompute the texture size. - if (config.profile) { - texture.stats.size = getTextureSize( - texture.internalformat, - texture.type, - w, - h, - false, - false); - } + // Add chain sequence methods to the `lodash` wrapper. + lodash.prototype.at = wrapperAt; + lodash.prototype.chain = wrapperChain; + lodash.prototype.commit = wrapperCommit; + lodash.prototype.next = wrapperNext; + lodash.prototype.plant = wrapperPlant; + lodash.prototype.reverse = wrapperReverse; + lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - return reglTexture2D + // Add lazy aliases. + lodash.prototype.first = lodash.prototype.head; + + if (symIterator) { + lodash.prototype[symIterator] = wrapperToIterator; } + return lodash; + }); - reglTexture2D(a, b); + /*--------------------------------------------------------------------------*/ - reglTexture2D.subimage = subimage; - reglTexture2D.resize = resize; - reglTexture2D._reglType = 'texture2d'; - reglTexture2D._texture = texture; - if (config.profile) { - reglTexture2D.stats = texture.stats; - } - reglTexture2D.destroy = function () { - texture.decRef(); - }; + // Export lodash. + var _ = runInContext(); - return reglTexture2D + // Some AMD build optimizers, like r.js, check for condition patterns like: + if (true) { + // Expose Lodash on the global object to prevent errors when Lodash is + // loaded by a script tag in the presence of an AMD loader. + // See http://requirejs.org/docs/errors.html#mismatch for more details. + // Use `_.noConflict` to remove Lodash from the global object. + root._ = _; + + // Define as an anonymous module so, through path mapping, it can be + // referenced as the "underscore" module. + !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { + return _; + }.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } + // Check for `exports` after `define` in case a build optimizer adds it. + else if (freeModule) { + // Export for Node.js. + (freeModule.exports = _)._ = _; + // Export for CommonJS support. + freeExports._ = _; + } + else { + // Export to the global object. + root._ = _; } +}.call(this)); - function createTextureCube (a0, a1, a2, a3, a4, a5) { - var texture = new REGLTexture(GL_TEXTURE_CUBE_MAP); - textureSet[texture.id] = texture; - stats.cubeCount++; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(42), __webpack_require__(43)(module))) - var faces = new Array(6); +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { - function reglTextureCube (a0, a1, a2, a3, a4, a5) { - var i; - var texInfo = texture.texInfo; - TexInfo.call(texInfo); - for (i = 0; i < 6; ++i) { - faces[i] = allocMipMap(); - } +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - if (typeof a0 === 'number' || !a0) { - var s = (a0 | 0) || 1; - for (i = 0; i < 6; ++i) { - parseMipMapFromShape(faces[i], s, s); - } - } else if (typeof a0 === 'object') { - if (a1) { - parseMipMapFromObject(faces[0], a0); - parseMipMapFromObject(faces[1], a1); - parseMipMapFromObject(faces[2], a2); - parseMipMapFromObject(faces[3], a3); - parseMipMapFromObject(faces[4], a4); - parseMipMapFromObject(faces[5], a5); - } else { - parseTexInfo(texInfo, a0); - parseFlags(texture, a0); - if ('faces' in a0) { - var face_input = a0.faces; - check$1(Array.isArray(face_input) && face_input.length === 6, - 'cube faces must be a length 6 array'); - for (i = 0; i < 6; ++i) { - check$1(typeof face_input[i] === 'object' && !!face_input[i], - 'invalid input for cube map face'); - copyFlags(faces[i], texture); - parseMipMapFromObject(faces[i], face_input[i]); - } - } else { - for (i = 0; i < 6; ++i) { - parseMipMapFromObject(faces[i], a0); - } - } - } - } else { - check$1.raise('invalid arguments to cube map'); - } - copyFlags(texture, faces[0]); - if (texInfo.genMipmaps) { - texture.mipmask = (faces[0].width << 1) - 1; - } else { - texture.mipmask = faces[0].mipmask; - } - check$1.textureCube(texture, texInfo, faces, limits); - texture.internalformat = faces[0].internalformat; +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} - reglTextureCube.width = faces[0].width; - reglTextureCube.height = faces[0].height; +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} - tempBind(texture); - for (i = 0; i < 6; ++i) { - setMipMap(faces[i], GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); - } - setTexInfo(texInfo, GL_TEXTURE_CUBE_MAP); - tempRestore(); +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} - if (config.profile) { - texture.stats.size = getTextureSize( - texture.internalformat, - texture.type, - reglTextureCube.width, - reglTextureCube.height, - texInfo.genMipmaps, - true); - } +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; +module.exports.once = once; - reglTextureCube.format = textureFormatsInvert[texture.internalformat]; - reglTextureCube.type = textureTypesInvert[texture.type]; +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; - reglTextureCube.mag = magFiltersInvert[texInfo.magFilter]; - reglTextureCube.min = minFiltersInvert[texInfo.minFilter]; +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; - reglTextureCube.wrapS = wrapModesInvert[texInfo.wrapS]; - reglTextureCube.wrapT = wrapModesInvert[texInfo.wrapT]; +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; - for (i = 0; i < 6; ++i) { - freeMipMap(faces[i]); - } +function checkListener(listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} - return reglTextureCube +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); } + defaultMaxListeners = arg; + } +}); - function subimage (face, image, x_, y_, level_) { - check$1(!!image, 'must specify image data'); - check$1(typeof face === 'number' && face === (face | 0) && - face >= 0 && face < 6, 'invalid face'); +EventEmitter.init = function() { - var x = x_ | 0; - var y = y_ | 0; - var level = level_ | 0; + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } - var imageData = allocImage(); - copyFlags(imageData, texture); - imageData.width = 0; - imageData.height = 0; - parseImage(imageData, image); - imageData.width = imageData.width || ((texture.width >> level) - x); - imageData.height = imageData.height || ((texture.height >> level) - y); + this._maxListeners = this._maxListeners || undefined; +}; - check$1( - texture.type === imageData.type && - texture.format === imageData.format && - texture.internalformat === imageData.internalformat, - 'incompatible format for texture.subimage'); - check$1( - x >= 0 && y >= 0 && - x + imageData.width <= texture.width && - y + imageData.height <= texture.height, - 'texture.subimage write out of bounds'); - check$1( - texture.mipmask & (1 << level), - 'missing mipmap data'); - check$1( - imageData.data || imageData.element || imageData.needsCopy, - 'missing image data'); +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function _getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} - tempBind(texture); - setSubImage(imageData, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, x, y, level); - tempRestore(); +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; - freeImage(imageData); +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); - return reglTextureCube + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } - function resize (radius_) { - var radius = radius_ | 0; - if (radius === texture.width) { - return - } + var handler = events[type]; - reglTextureCube.width = texture.width = radius; - reglTextureCube.height = texture.height = radius; + if (handler === undefined) + return false; - tempBind(texture); - for (var i = 0; i < 6; ++i) { - for (var j = 0; texture.mipmask >> j; ++j) { - gl.texImage2D( - GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, - j, - texture.format, - radius >> j, - radius >> j, - 0, - texture.format, - texture.type, - null); - } - } - tempRestore(); + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } - if (config.profile) { - texture.stats.size = getTextureSize( - texture.internalformat, - texture.type, - reglTextureCube.width, - reglTextureCube.height, - false, - true); - } + return true; +}; - return reglTextureCube - } +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; - reglTextureCube(a0, a1, a2, a3, a4, a5); + checkListener(listener); - reglTextureCube.subimage = subimage; - reglTextureCube.resize = resize; - reglTextureCube._reglType = 'textureCube'; - reglTextureCube._texture = texture; - if (config.profile) { - reglTextureCube.stats = texture.stats; - } - reglTextureCube.destroy = function () { - texture.decRef(); - }; + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); - return reglTextureCube + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; } - // Called when regl is destroyed - function destroyTextures () { - for (var i = 0; i < numTexUnits; ++i) { - gl.activeTexture(GL_TEXTURE0 + i); - gl.bindTexture(GL_TEXTURE_2D, null); - textureUnits[i] = null; + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); } - values(textureSet).forEach(destroy); - stats.cubeCount = 0; - stats.textureCount = 0; + // Check for listener leak + m = _getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } } - if (config.profile) { - stats.getTotalTextureSize = function () { - var total = 0; - Object.keys(textureSet).forEach(function (key) { - total += textureSet[key].stats.size; - }); - return total + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); }; + +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); } +} - function restoreTextures () { - values(textureSet).forEach(function (texture) { - texture.texture = gl.createTexture(); - gl.bindTexture(texture.target, texture.texture); - for (var i = 0; i < 32; ++i) { - if ((texture.mipmask & (1 << i)) === 0) { - continue +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + checkListener(listener); + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + checkListener(listener); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + checkListener(listener); + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); } - if (texture.target === GL_TEXTURE_2D) { - gl.texImage2D(GL_TEXTURE_2D, - i, - texture.internalformat, - texture.width >> i, - texture.height >> i, - 0, - texture.internalformat, - texture.type, - null); - } else { - for (var j = 0; j < 6; ++j) { - gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, - i, - texture.internalformat, - texture.width >> i, - texture.height >> i, - 0, - texture.internalformat, - texture.type, - null); + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; } } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); } - setTexInfo(texture.texInfo, texture.target); - }); - } - return { - create2D: createTexture2D, - createCube: createTextureCube, - clear: destroyTextures, - getTexture: function (wrapper) { - return null - }, - restore: restoreTextures - } -} + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; -var GL_RENDERBUFFER = 0x8D41; + events = this._events; + if (events === undefined) + return this; -var GL_RGBA4$1 = 0x8056; -var GL_RGB5_A1$1 = 0x8057; -var GL_RGB565$1 = 0x8D62; -var GL_DEPTH_COMPONENT16 = 0x81A5; -var GL_STENCIL_INDEX8 = 0x8D48; -var GL_DEPTH_STENCIL$1 = 0x84F9; + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } -var GL_SRGB8_ALPHA8_EXT = 0x8C43; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } -var GL_RGBA32F_EXT = 0x8814; + listeners = events[type]; -var GL_RGBA16F_EXT = 0x881A; -var GL_RGB16F_EXT = 0x881B; + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } -var FORMAT_SIZES = []; + return this; + }; -FORMAT_SIZES[GL_RGBA4$1] = 2; -FORMAT_SIZES[GL_RGB5_A1$1] = 2; -FORMAT_SIZES[GL_RGB565$1] = 2; +function _listeners(target, type, unwrap) { + var events = target._events; -FORMAT_SIZES[GL_DEPTH_COMPONENT16] = 2; -FORMAT_SIZES[GL_STENCIL_INDEX8] = 1; -FORMAT_SIZES[GL_DEPTH_STENCIL$1] = 4; + if (events === undefined) + return []; -FORMAT_SIZES[GL_SRGB8_ALPHA8_EXT] = 4; -FORMAT_SIZES[GL_RGBA32F_EXT] = 16; -FORMAT_SIZES[GL_RGBA16F_EXT] = 8; -FORMAT_SIZES[GL_RGB16F_EXT] = 6; + var evlistener = events[type]; + if (evlistener === undefined) + return []; -function getRenderbufferSize (format, width, height) { - return FORMAT_SIZES[format] * width * height + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); } -var wrapRenderbuffers = function (gl, extensions, limits, stats, config) { - var formatTypes = { - 'rgba4': GL_RGBA4$1, - 'rgb565': GL_RGB565$1, - 'rgb5 a1': GL_RGB5_A1$1, - 'depth': GL_DEPTH_COMPONENT16, - 'stencil': GL_STENCIL_INDEX8, - 'depth stencil': GL_DEPTH_STENCIL$1 - }; +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; - if (extensions.ext_srgb) { - formatTypes['srgba'] = GL_SRGB8_ALPHA8_EXT; - } +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; - if (extensions.ext_color_buffer_half_float) { - formatTypes['rgba16f'] = GL_RGBA16F_EXT; - formatTypes['rgb16f'] = GL_RGB16F_EXT; +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); } +}; - if (extensions.webgl_color_buffer_float) { - formatTypes['rgba32f'] = GL_RGBA32F_EXT; +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } } - var formatTypesInvert = []; - Object.keys(formatTypes).forEach(function (key) { - var val = formatTypes[key]; - formatTypesInvert[val] = key; - }); + return 0; +} - var renderbufferCount = 0; - var renderbufferSet = {}; +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; - function REGLRenderbuffer (renderbuffer) { - this.id = renderbufferCount++; - this.refCount = 1; +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} - this.renderbuffer = renderbuffer; +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} - this.format = GL_RGBA4$1; - this.width = 0; - this.height = 0; +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} - if (config.profile) { - this.stats = {size: 0}; +function once(emitter, name) { + return new Promise(function (resolve, reject) { + function errorListener(err) { + emitter.removeListener(name, resolver); + reject(err); } - } - REGLRenderbuffer.prototype.decRef = function () { - if (--this.refCount <= 0) { - destroy(this); + function resolver() { + if (typeof emitter.removeListener === 'function') { + emitter.removeListener('error', errorListener); + } + resolve([].slice.call(arguments)); + }; + + eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); + if (name !== 'error') { + addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); } - }; + }); +} - function destroy (rb) { - var handle = rb.renderbuffer; - check$1(handle, 'must not double destroy renderbuffer'); - gl.bindRenderbuffer(GL_RENDERBUFFER, null); - gl.deleteRenderbuffer(handle); - rb.renderbuffer = null; - rb.refCount = 0; - delete renderbufferSet[rb.id]; - stats.renderbufferCount--; +function addErrorHandlerIfEventEmitter(emitter, handler, flags) { + if (typeof emitter.on === 'function') { + eventTargetAgnosticAddListener(emitter, 'error', handler, flags); } +} - function createRenderbuffer (a, b) { - var renderbuffer = new REGLRenderbuffer(gl.createRenderbuffer()); - renderbufferSet[renderbuffer.id] = renderbuffer; - stats.renderbufferCount++; +function eventTargetAgnosticAddListener(emitter, name, listener, flags) { + if (typeof emitter.on === 'function') { + if (flags.once) { + emitter.once(name, listener); + } else { + emitter.on(name, listener); + } + } else if (typeof emitter.addEventListener === 'function') { + // EventTarget does not have `error` event semantics like Node + // EventEmitters, we do not listen for `error` events here. + emitter.addEventListener(name, function wrapListener(arg) { + // IE does not have builtin `{ once: true }` support so we + // have to do it manually. + if (flags.once) { + emitter.removeEventListener(name, wrapListener); + } + listener(arg); + }); + } else { + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); + } +} + + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + +/* MIT license */ + +module.exports = { + rgb2hsl: rgb2hsl, + rgb2hsv: rgb2hsv, + rgb2hwb: rgb2hwb, + rgb2cmyk: rgb2cmyk, + rgb2keyword: rgb2keyword, + rgb2xyz: rgb2xyz, + rgb2lab: rgb2lab, + rgb2lch: rgb2lch, - function reglRenderbuffer (a, b) { - var w = 0; - var h = 0; - var format = GL_RGBA4$1; + hsl2rgb: hsl2rgb, + hsl2hsv: hsl2hsv, + hsl2hwb: hsl2hwb, + hsl2cmyk: hsl2cmyk, + hsl2keyword: hsl2keyword, - if (typeof a === 'object' && a) { - var options = a; - if ('shape' in options) { - var shape = options.shape; - check$1(Array.isArray(shape) && shape.length >= 2, - 'invalid renderbuffer shape'); - w = shape[0] | 0; - h = shape[1] | 0; - } else { - if ('radius' in options) { - w = h = options.radius | 0; - } - if ('width' in options) { - w = options.width | 0; - } - if ('height' in options) { - h = options.height | 0; - } - } - if ('format' in options) { - check$1.parameter(options.format, formatTypes, - 'invalid renderbuffer format'); - format = formatTypes[options.format]; - } - } else if (typeof a === 'number') { - w = a | 0; - if (typeof b === 'number') { - h = b | 0; - } else { - h = w; - } - } else if (!a) { - w = h = 1; - } else { - check$1.raise('invalid arguments to renderbuffer constructor'); - } + hsv2rgb: hsv2rgb, + hsv2hsl: hsv2hsl, + hsv2hwb: hsv2hwb, + hsv2cmyk: hsv2cmyk, + hsv2keyword: hsv2keyword, - // check shape - check$1( - w > 0 && h > 0 && - w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize, - 'invalid renderbuffer size'); + hwb2rgb: hwb2rgb, + hwb2hsl: hwb2hsl, + hwb2hsv: hwb2hsv, + hwb2cmyk: hwb2cmyk, + hwb2keyword: hwb2keyword, - if (w === renderbuffer.width && - h === renderbuffer.height && - format === renderbuffer.format) { - return - } + cmyk2rgb: cmyk2rgb, + cmyk2hsl: cmyk2hsl, + cmyk2hsv: cmyk2hsv, + cmyk2hwb: cmyk2hwb, + cmyk2keyword: cmyk2keyword, - reglRenderbuffer.width = renderbuffer.width = w; - reglRenderbuffer.height = renderbuffer.height = h; - renderbuffer.format = format; + keyword2rgb: keyword2rgb, + keyword2hsl: keyword2hsl, + keyword2hsv: keyword2hsv, + keyword2hwb: keyword2hwb, + keyword2cmyk: keyword2cmyk, + keyword2lab: keyword2lab, + keyword2xyz: keyword2xyz, - gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer); - gl.renderbufferStorage(GL_RENDERBUFFER, format, w, h); + xyz2rgb: xyz2rgb, + xyz2lab: xyz2lab, + xyz2lch: xyz2lch, - if (config.profile) { - renderbuffer.stats.size = getRenderbufferSize(renderbuffer.format, renderbuffer.width, renderbuffer.height); - } - reglRenderbuffer.format = formatTypesInvert[renderbuffer.format]; + lab2xyz: lab2xyz, + lab2rgb: lab2rgb, + lab2lch: lab2lch, - return reglRenderbuffer - } + lch2lab: lch2lab, + lch2xyz: lch2xyz, + lch2rgb: lch2rgb +} - function resize (w_, h_) { - var w = w_ | 0; - var h = (h_ | 0) || w; - if (w === renderbuffer.width && h === renderbuffer.height) { - return reglRenderbuffer - } +function rgb2hsl(rgb) { + var r = rgb[0]/255, + g = rgb[1]/255, + b = rgb[2]/255, + min = Math.min(r, g, b), + max = Math.max(r, g, b), + delta = max - min, + h, s, l; - // check shape - check$1( - w > 0 && h > 0 && - w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize, - 'invalid renderbuffer size'); + if (max == min) + h = 0; + else if (r == max) + h = (g - b) / delta; + else if (g == max) + h = 2 + (b - r) / delta; + else if (b == max) + h = 4 + (r - g)/ delta; - reglRenderbuffer.width = renderbuffer.width = w; - reglRenderbuffer.height = renderbuffer.height = h; + h = Math.min(h * 60, 360); - gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer); - gl.renderbufferStorage(GL_RENDERBUFFER, renderbuffer.format, w, h); + if (h < 0) + h += 360; - // also, recompute size. - if (config.profile) { - renderbuffer.stats.size = getRenderbufferSize( - renderbuffer.format, renderbuffer.width, renderbuffer.height); - } + l = (min + max) / 2; - return reglRenderbuffer - } + if (max == min) + s = 0; + else if (l <= 0.5) + s = delta / (max + min); + else + s = delta / (2 - max - min); - reglRenderbuffer(a, b); + return [h, s * 100, l * 100]; +} - reglRenderbuffer.resize = resize; - reglRenderbuffer._reglType = 'renderbuffer'; - reglRenderbuffer._renderbuffer = renderbuffer; - if (config.profile) { - reglRenderbuffer.stats = renderbuffer.stats; - } - reglRenderbuffer.destroy = function () { - renderbuffer.decRef(); - }; +function rgb2hsv(rgb) { + var r = rgb[0], + g = rgb[1], + b = rgb[2], + min = Math.min(r, g, b), + max = Math.max(r, g, b), + delta = max - min, + h, s, v; - return reglRenderbuffer - } + if (max == 0) + s = 0; + else + s = (delta/max * 1000)/10; - if (config.profile) { - stats.getTotalRenderbufferSize = function () { - var total = 0; - Object.keys(renderbufferSet).forEach(function (key) { - total += renderbufferSet[key].stats.size; - }); - return total - }; - } + if (max == min) + h = 0; + else if (r == max) + h = (g - b) / delta; + else if (g == max) + h = 2 + (b - r) / delta; + else if (b == max) + h = 4 + (r - g) / delta; - function restoreRenderbuffers () { - values(renderbufferSet).forEach(function (rb) { - rb.renderbuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(GL_RENDERBUFFER, rb.renderbuffer); - gl.renderbufferStorage(GL_RENDERBUFFER, rb.format, rb.width, rb.height); - }); - gl.bindRenderbuffer(GL_RENDERBUFFER, null); - } + h = Math.min(h * 60, 360); - return { - create: createRenderbuffer, - clear: function () { - values(renderbufferSet).forEach(destroy); - }, - restore: restoreRenderbuffers - } -}; + if (h < 0) + h += 360; -// We store these constants so that the minifier can inline them -var GL_FRAMEBUFFER = 0x8D40; -var GL_RENDERBUFFER$1 = 0x8D41; + v = ((max / 255) * 1000) / 10; -var GL_TEXTURE_2D$1 = 0x0DE1; -var GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 = 0x8515; + return [h, s, v]; +} -var GL_COLOR_ATTACHMENT0 = 0x8CE0; -var GL_DEPTH_ATTACHMENT = 0x8D00; -var GL_STENCIL_ATTACHMENT = 0x8D20; -var GL_DEPTH_STENCIL_ATTACHMENT = 0x821A; +function rgb2hwb(rgb) { + var r = rgb[0], + g = rgb[1], + b = rgb[2], + h = rgb2hsl(rgb)[0], + w = 1/255 * Math.min(r, Math.min(g, b)), + b = 1 - 1/255 * Math.max(r, Math.max(g, b)); -var GL_FRAMEBUFFER_COMPLETE = 0x8CD5; -var GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; -var GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; -var GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; -var GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD; + return [h, w * 100, b * 100]; +} -var GL_HALF_FLOAT_OES$2 = 0x8D61; -var GL_UNSIGNED_BYTE$5 = 0x1401; -var GL_FLOAT$4 = 0x1406; +function rgb2cmyk(rgb) { + var r = rgb[0] / 255, + g = rgb[1] / 255, + b = rgb[2] / 255, + c, m, y, k; -var GL_RGBA$1 = 0x1908; + k = Math.min(1 - r, 1 - g, 1 - b); + c = (1 - r - k) / (1 - k) || 0; + m = (1 - g - k) / (1 - k) || 0; + y = (1 - b - k) / (1 - k) || 0; + return [c * 100, m * 100, y * 100, k * 100]; +} -var GL_DEPTH_COMPONENT$1 = 0x1902; +function rgb2keyword(rgb) { + return reverseKeywords[JSON.stringify(rgb)]; +} -var colorTextureFormatEnums = [ - GL_RGBA$1 -]; +function rgb2xyz(rgb) { + var r = rgb[0] / 255, + g = rgb[1] / 255, + b = rgb[2] / 255; -// for every texture format, store -// the number of channels -var textureFormatChannels = []; -textureFormatChannels[GL_RGBA$1] = 4; + // assume sRGB + r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); + g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); + b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); -// for every texture type, store -// the size in bytes. -var textureTypeSizes = []; -textureTypeSizes[GL_UNSIGNED_BYTE$5] = 1; -textureTypeSizes[GL_FLOAT$4] = 4; -textureTypeSizes[GL_HALF_FLOAT_OES$2] = 2; + var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); + var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); + var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); -var GL_RGBA4$2 = 0x8056; -var GL_RGB5_A1$2 = 0x8057; -var GL_RGB565$2 = 0x8D62; -var GL_DEPTH_COMPONENT16$1 = 0x81A5; -var GL_STENCIL_INDEX8$1 = 0x8D48; -var GL_DEPTH_STENCIL$2 = 0x84F9; + return [x * 100, y *100, z * 100]; +} -var GL_SRGB8_ALPHA8_EXT$1 = 0x8C43; +function rgb2lab(rgb) { + var xyz = rgb2xyz(rgb), + x = xyz[0], + y = xyz[1], + z = xyz[2], + l, a, b; -var GL_RGBA32F_EXT$1 = 0x8814; + x /= 95.047; + y /= 100; + z /= 108.883; -var GL_RGBA16F_EXT$1 = 0x881A; -var GL_RGB16F_EXT$1 = 0x881B; + x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116); -var colorRenderbufferFormatEnums = [ - GL_RGBA4$2, - GL_RGB5_A1$2, - GL_RGB565$2, - GL_SRGB8_ALPHA8_EXT$1, - GL_RGBA16F_EXT$1, - GL_RGB16F_EXT$1, - GL_RGBA32F_EXT$1 -]; + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); -var statusCode = {}; -statusCode[GL_FRAMEBUFFER_COMPLETE] = 'complete'; -statusCode[GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT] = 'incomplete attachment'; -statusCode[GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS] = 'incomplete dimensions'; -statusCode[GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT] = 'incomplete, missing attachment'; -statusCode[GL_FRAMEBUFFER_UNSUPPORTED] = 'unsupported'; + return [l, a, b]; +} -function wrapFBOState ( - gl, - extensions, - limits, - textureState, - renderbufferState, - stats) { - var framebufferState = { - cur: null, - next: null, - dirty: false, - setFBO: null - }; +function rgb2lch(args) { + return lab2lch(rgb2lab(args)); +} - var colorTextureFormats = ['rgba']; - var colorRenderbufferFormats = ['rgba4', 'rgb565', 'rgb5 a1']; +function hsl2rgb(hsl) { + var h = hsl[0] / 360, + s = hsl[1] / 100, + l = hsl[2] / 100, + t1, t2, t3, rgb, val; - if (extensions.ext_srgb) { - colorRenderbufferFormats.push('srgba'); + if (s == 0) { + val = l * 255; + return [val, val, val]; } - if (extensions.ext_color_buffer_half_float) { - colorRenderbufferFormats.push('rgba16f', 'rgb16f'); - } + if (l < 0.5) + t2 = l * (1 + s); + else + t2 = l + s - l * s; + t1 = 2 * l - t2; - if (extensions.webgl_color_buffer_float) { - colorRenderbufferFormats.push('rgba32f'); - } + rgb = [0, 0, 0]; + for (var i = 0; i < 3; i++) { + t3 = h + 1 / 3 * - (i - 1); + t3 < 0 && t3++; + t3 > 1 && t3--; - var colorTypes = ['uint8']; - if (extensions.oes_texture_half_float) { - colorTypes.push('half float', 'float16'); - } - if (extensions.oes_texture_float) { - colorTypes.push('float', 'float32'); + if (6 * t3 < 1) + val = t1 + (t2 - t1) * 6 * t3; + else if (2 * t3 < 1) + val = t2; + else if (3 * t3 < 2) + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + else + val = t1; + + rgb[i] = val * 255; } - function FramebufferAttachment (target, texture, renderbuffer) { - this.target = target; - this.texture = texture; - this.renderbuffer = renderbuffer; + return rgb; +} - var w = 0; - var h = 0; - if (texture) { - w = texture.width; - h = texture.height; - } else if (renderbuffer) { - w = renderbuffer.width; - h = renderbuffer.height; - } - this.width = w; - this.height = h; - } +function hsl2hsv(hsl) { + var h = hsl[0], + s = hsl[1] / 100, + l = hsl[2] / 100, + sv, v; - function decRef (attachment) { - if (attachment) { - if (attachment.texture) { - attachment.texture._texture.decRef(); - } - if (attachment.renderbuffer) { - attachment.renderbuffer._renderbuffer.decRef(); - } - } + if(l === 0) { + // no need to do calc on black + // also avoids divide by 0 error + return [0, 0, 0]; } - function incRefAndCheckShape (attachment, width, height) { - if (!attachment) { - return - } - if (attachment.texture) { - var texture = attachment.texture._texture; - var tw = Math.max(1, texture.width); - var th = Math.max(1, texture.height); - check$1(tw === width && th === height, - 'inconsistent width/height for supplied texture'); - texture.refCount += 1; - } else { - var renderbuffer = attachment.renderbuffer._renderbuffer; - check$1( - renderbuffer.width === width && renderbuffer.height === height, - 'inconsistent width/height for renderbuffer'); - renderbuffer.refCount += 1; - } - } + l *= 2; + s *= (l <= 1) ? l : 2 - l; + v = (l + s) / 2; + sv = (2 * s) / (l + s); + return [h, sv * 100, v * 100]; +} - function attach (location, attachment) { - if (attachment) { - if (attachment.texture) { - gl.framebufferTexture2D( - GL_FRAMEBUFFER, - location, - attachment.target, - attachment.texture._texture.texture, - 0); - } else { - gl.framebufferRenderbuffer( - GL_FRAMEBUFFER, - location, - GL_RENDERBUFFER$1, - attachment.renderbuffer._renderbuffer.renderbuffer); - } - } - } +function hsl2hwb(args) { + return rgb2hwb(hsl2rgb(args)); +} - function parseAttachment (attachment) { - var target = GL_TEXTURE_2D$1; - var texture = null; - var renderbuffer = null; +function hsl2cmyk(args) { + return rgb2cmyk(hsl2rgb(args)); +} - var data = attachment; - if (typeof attachment === 'object') { - data = attachment.data; - if ('target' in attachment) { - target = attachment.target | 0; - } - } +function hsl2keyword(args) { + return rgb2keyword(hsl2rgb(args)); +} - check$1.type(data, 'function', 'invalid attachment data'); - var type = data._reglType; - if (type === 'texture2d') { - texture = data; - check$1(target === GL_TEXTURE_2D$1); - } else if (type === 'textureCube') { - texture = data; - check$1( - target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 && - target < GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + 6, - 'invalid cube map target'); - } else if (type === 'renderbuffer') { - renderbuffer = data; - target = GL_RENDERBUFFER$1; - } else { - check$1.raise('invalid regl object for attachment'); - } +function hsv2rgb(hsv) { + var h = hsv[0] / 60, + s = hsv[1] / 100, + v = hsv[2] / 100, + hi = Math.floor(h) % 6; - return new FramebufferAttachment(target, texture, renderbuffer) - } + var f = h - Math.floor(h), + p = 255 * v * (1 - s), + q = 255 * v * (1 - (s * f)), + t = 255 * v * (1 - (s * (1 - f))), + v = 255 * v; - function allocAttachment ( - width, - height, - isTexture, - format, - type) { - if (isTexture) { - var texture = textureState.create2D({ - width: width, - height: height, - format: format, - type: type - }); - texture._texture.refCount = 0; - return new FramebufferAttachment(GL_TEXTURE_2D$1, texture, null) - } else { - var rb = renderbufferState.create({ - width: width, - height: height, - format: format - }); - rb._renderbuffer.refCount = 0; - return new FramebufferAttachment(GL_RENDERBUFFER$1, null, rb) - } + switch(hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; } +} - function unwrapAttachment (attachment) { - return attachment && (attachment.texture || attachment.renderbuffer) - } +function hsv2hsl(hsv) { + var h = hsv[0], + s = hsv[1] / 100, + v = hsv[2] / 100, + sl, l; - function resizeAttachment (attachment, w, h) { - if (attachment) { - if (attachment.texture) { - attachment.texture.resize(w, h); - } else if (attachment.renderbuffer) { - attachment.renderbuffer.resize(w, h); - } - } - } + l = (2 - s) * v; + sl = s * v; + sl /= (l <= 1) ? l : 2 - l; + sl = sl || 0; + l /= 2; + return [h, sl * 100, l * 100]; +} - var framebufferCount = 0; - var framebufferSet = {}; +function hsv2hwb(args) { + return rgb2hwb(hsv2rgb(args)) +} - function REGLFramebuffer () { - this.id = framebufferCount++; - framebufferSet[this.id] = this; +function hsv2cmyk(args) { + return rgb2cmyk(hsv2rgb(args)); +} - this.framebuffer = gl.createFramebuffer(); - this.width = 0; - this.height = 0; +function hsv2keyword(args) { + return rgb2keyword(hsv2rgb(args)); +} - this.colorAttachments = []; - this.depthAttachment = null; - this.stencilAttachment = null; - this.depthStencilAttachment = null; - } +// http://dev.w3.org/csswg/css-color/#hwb-to-rgb +function hwb2rgb(hwb) { + var h = hwb[0] / 360, + wh = hwb[1] / 100, + bl = hwb[2] / 100, + ratio = wh + bl, + i, v, f, n; - function decFBORefs (framebuffer) { - framebuffer.colorAttachments.forEach(decRef); - decRef(framebuffer.depthAttachment); - decRef(framebuffer.stencilAttachment); - decRef(framebuffer.depthStencilAttachment); + // wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio; + bl /= ratio; } - function destroy (framebuffer) { - var handle = framebuffer.framebuffer; - check$1(handle, 'must not double destroy framebuffer'); - gl.deleteFramebuffer(handle); - framebuffer.framebuffer = null; - stats.framebufferCount--; - delete framebufferSet[framebuffer.id]; + i = Math.floor(6 * h); + v = 1 - bl; + f = 6 * h - i; + if ((i & 0x01) != 0) { + f = 1 - f; } + n = wh + f * (v - wh); // linear interpolation - function updateFramebuffer (framebuffer) { - var i; + switch (i) { + default: + case 6: + case 0: r = v; g = n; b = wh; break; + case 1: r = n; g = v; b = wh; break; + case 2: r = wh; g = v; b = n; break; + case 3: r = wh; g = n; b = v; break; + case 4: r = n; g = wh; b = v; break; + case 5: r = v; g = wh; b = n; break; + } - gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer.framebuffer); - var colorAttachments = framebuffer.colorAttachments; - for (i = 0; i < colorAttachments.length; ++i) { - attach(GL_COLOR_ATTACHMENT0 + i, colorAttachments[i]); - } - for (i = colorAttachments.length; i < limits.maxColorAttachments; ++i) { - gl.framebufferTexture2D( - GL_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0 + i, - GL_TEXTURE_2D$1, - null, - 0); - } + return [r * 255, g * 255, b * 255]; +} - gl.framebufferTexture2D( - GL_FRAMEBUFFER, - GL_DEPTH_STENCIL_ATTACHMENT, - GL_TEXTURE_2D$1, - null, - 0); - gl.framebufferTexture2D( - GL_FRAMEBUFFER, - GL_DEPTH_ATTACHMENT, - GL_TEXTURE_2D$1, - null, - 0); - gl.framebufferTexture2D( - GL_FRAMEBUFFER, - GL_STENCIL_ATTACHMENT, - GL_TEXTURE_2D$1, - null, - 0); +function hwb2hsl(args) { + return rgb2hsl(hwb2rgb(args)); +} - attach(GL_DEPTH_ATTACHMENT, framebuffer.depthAttachment); - attach(GL_STENCIL_ATTACHMENT, framebuffer.stencilAttachment); - attach(GL_DEPTH_STENCIL_ATTACHMENT, framebuffer.depthStencilAttachment); +function hwb2hsv(args) { + return rgb2hsv(hwb2rgb(args)); +} - // Check status code - var status = gl.checkFramebufferStatus(GL_FRAMEBUFFER); - if (status !== GL_FRAMEBUFFER_COMPLETE) { - check$1.raise('framebuffer configuration not supported, status = ' + - statusCode[status]); - } +function hwb2cmyk(args) { + return rgb2cmyk(hwb2rgb(args)); +} - gl.bindFramebuffer(GL_FRAMEBUFFER, framebufferState.next); - framebufferState.cur = framebufferState.next; +function hwb2keyword(args) { + return rgb2keyword(hwb2rgb(args)); +} - // FIXME: Clear error code here. This is a work around for a bug in - // headless-gl - gl.getError(); - } +function cmyk2rgb(cmyk) { + var c = cmyk[0] / 100, + m = cmyk[1] / 100, + y = cmyk[2] / 100, + k = cmyk[3] / 100, + r, g, b; - function createFBO (a0, a1) { - var framebuffer = new REGLFramebuffer(); - stats.framebufferCount++; + r = 1 - Math.min(1, c * (1 - k) + k); + g = 1 - Math.min(1, m * (1 - k) + k); + b = 1 - Math.min(1, y * (1 - k) + k); + return [r * 255, g * 255, b * 255]; +} - function reglFramebuffer (a, b) { - var i; +function cmyk2hsl(args) { + return rgb2hsl(cmyk2rgb(args)); +} - check$1(framebufferState.next !== framebuffer, - 'can not update framebuffer which is currently in use'); +function cmyk2hsv(args) { + return rgb2hsv(cmyk2rgb(args)); +} - var extDrawBuffers = extensions.webgl_draw_buffers; +function cmyk2hwb(args) { + return rgb2hwb(cmyk2rgb(args)); +} - var width = 0; - var height = 0; +function cmyk2keyword(args) { + return rgb2keyword(cmyk2rgb(args)); +} - var needsDepth = true; - var needsStencil = true; - var colorBuffer = null; - var colorTexture = true; - var colorFormat = 'rgba'; - var colorType = 'uint8'; - var colorCount = 1; +function xyz2rgb(xyz) { + var x = xyz[0] / 100, + y = xyz[1] / 100, + z = xyz[2] / 100, + r, g, b; - var depthBuffer = null; - var stencilBuffer = null; - var depthStencilBuffer = null; - var depthStencilTexture = false; + r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); + g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); + b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); - if (typeof a === 'number') { - width = a | 0; - height = (b | 0) || width; - } else if (!a) { - width = height = 1; - } else { - check$1.type(a, 'object', 'invalid arguments for framebuffer'); - var options = a; + // assume sRGB + r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) + : r = (r * 12.92); - if ('shape' in options) { - var shape = options.shape; - check$1(Array.isArray(shape) && shape.length >= 2, - 'invalid shape for framebuffer'); - width = shape[0]; - height = shape[1]; - } else { - if ('radius' in options) { - width = height = options.radius; - } - if ('width' in options) { - width = options.width; - } - if ('height' in options) { - height = options.height; - } - } + g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) + : g = (g * 12.92); - if ('color' in options || - 'colors' in options) { - colorBuffer = - options.color || - options.colors; - if (Array.isArray(colorBuffer)) { - check$1( - colorBuffer.length === 1 || extDrawBuffers, - 'multiple render targets not supported'); - } - } + b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) + : b = (b * 12.92); - if (!colorBuffer) { - if ('colorCount' in options) { - colorCount = options.colorCount | 0; - check$1(colorCount > 0, 'invalid color buffer count'); - } + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); - if ('colorTexture' in options) { - colorTexture = !!options.colorTexture; - colorFormat = 'rgba4'; - } + return [r * 255, g * 255, b * 255]; +} - if ('colorType' in options) { - colorType = options.colorType; - if (!colorTexture) { - if (colorType === 'half float' || colorType === 'float16') { - check$1(extensions.ext_color_buffer_half_float, - 'you must enable EXT_color_buffer_half_float to use 16-bit render buffers'); - colorFormat = 'rgba16f'; - } else if (colorType === 'float' || colorType === 'float32') { - check$1(extensions.webgl_color_buffer_float, - 'you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers'); - colorFormat = 'rgba32f'; - } - } else { - check$1(extensions.oes_texture_float || - !(colorType === 'float' || colorType === 'float32'), - 'you must enable OES_texture_float in order to use floating point framebuffer objects'); - check$1(extensions.oes_texture_half_float || - !(colorType === 'half float' || colorType === 'float16'), - 'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects'); - } - check$1.oneOf(colorType, colorTypes, 'invalid color type'); - } +function xyz2lab(xyz) { + var x = xyz[0], + y = xyz[1], + z = xyz[2], + l, a, b; - if ('colorFormat' in options) { - colorFormat = options.colorFormat; - if (colorTextureFormats.indexOf(colorFormat) >= 0) { - colorTexture = true; - } else if (colorRenderbufferFormats.indexOf(colorFormat) >= 0) { - colorTexture = false; - } else { - if (colorTexture) { - check$1.oneOf( - options.colorFormat, colorTextureFormats, - 'invalid color format for texture'); - } else { - check$1.oneOf( - options.colorFormat, colorRenderbufferFormats, - 'invalid color format for renderbuffer'); - } - } - } - } + x /= 95.047; + y /= 100; + z /= 108.883; - if ('depthTexture' in options || 'depthStencilTexture' in options) { - depthStencilTexture = !!(options.depthTexture || - options.depthStencilTexture); - check$1(!depthStencilTexture || extensions.webgl_depth_texture, - 'webgl_depth_texture extension not supported'); - } + x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116); - if ('depth' in options) { - if (typeof options.depth === 'boolean') { - needsDepth = options.depth; - } else { - depthBuffer = options.depth; - needsStencil = false; - } - } + l = (116 * y) - 16; + a = 500 * (x - y); + b = 200 * (y - z); - if ('stencil' in options) { - if (typeof options.stencil === 'boolean') { - needsStencil = options.stencil; - } else { - stencilBuffer = options.stencil; - needsDepth = false; - } - } + return [l, a, b]; +} - if ('depthStencil' in options) { - if (typeof options.depthStencil === 'boolean') { - needsDepth = needsStencil = options.depthStencil; - } else { - depthStencilBuffer = options.depthStencil; - needsDepth = false; - needsStencil = false; - } - } - } +function xyz2lch(args) { + return lab2lch(xyz2lab(args)); +} - // parse attachments - var colorAttachments = null; - var depthAttachment = null; - var stencilAttachment = null; - var depthStencilAttachment = null; +function lab2xyz(lab) { + var l = lab[0], + a = lab[1], + b = lab[2], + x, y, z, y2; - // Set up color attachments - if (Array.isArray(colorBuffer)) { - colorAttachments = colorBuffer.map(parseAttachment); - } else if (colorBuffer) { - colorAttachments = [parseAttachment(colorBuffer)]; - } else { - colorAttachments = new Array(colorCount); - for (i = 0; i < colorCount; ++i) { - colorAttachments[i] = allocAttachment( - width, - height, - colorTexture, - colorFormat, - colorType); - } - } + if (l <= 8) { + y = (l * 100) / 903.3; + y2 = (7.787 * (y / 100)) + (16 / 116); + } else { + y = 100 * Math.pow((l + 16) / 116, 3); + y2 = Math.pow(y / 100, 1/3); + } - check$1(extensions.webgl_draw_buffers || colorAttachments.length <= 1, - 'you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers.'); - check$1(colorAttachments.length <= limits.maxColorAttachments, - 'too many color attachments, not supported'); + x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3); - width = width || colorAttachments[0].width; - height = height || colorAttachments[0].height; + z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3); - if (depthBuffer) { - depthAttachment = parseAttachment(depthBuffer); - } else if (needsDepth && !needsStencil) { - depthAttachment = allocAttachment( - width, - height, - depthStencilTexture, - 'depth', - 'uint32'); - } + return [x, y, z]; +} - if (stencilBuffer) { - stencilAttachment = parseAttachment(stencilBuffer); - } else if (needsStencil && !needsDepth) { - stencilAttachment = allocAttachment( - width, - height, - false, - 'stencil', - 'uint8'); - } +function lab2lch(lab) { + var l = lab[0], + a = lab[1], + b = lab[2], + hr, h, c; - if (depthStencilBuffer) { - depthStencilAttachment = parseAttachment(depthStencilBuffer); - } else if (!depthBuffer && !stencilBuffer && needsStencil && needsDepth) { - depthStencilAttachment = allocAttachment( - width, - height, - depthStencilTexture, - 'depth stencil', - 'depth stencil'); - } + hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; + if (h < 0) { + h += 360; + } + c = Math.sqrt(a * a + b * b); + return [l, c, h]; +} - check$1( - (!!depthBuffer) + (!!stencilBuffer) + (!!depthStencilBuffer) <= 1, - 'invalid framebuffer configuration, can specify exactly one depth/stencil attachment'); +function lab2rgb(args) { + return xyz2rgb(lab2xyz(args)); +} - var commonColorAttachmentSize = null; +function lch2lab(lch) { + var l = lch[0], + c = lch[1], + h = lch[2], + a, b, hr; - for (i = 0; i < colorAttachments.length; ++i) { - incRefAndCheckShape(colorAttachments[i], width, height); - check$1(!colorAttachments[i] || - (colorAttachments[i].texture && - colorTextureFormatEnums.indexOf(colorAttachments[i].texture._texture.format) >= 0) || - (colorAttachments[i].renderbuffer && - colorRenderbufferFormatEnums.indexOf(colorAttachments[i].renderbuffer._renderbuffer.format) >= 0), - 'framebuffer color attachment ' + i + ' is invalid'); + hr = h / 360 * 2 * Math.PI; + a = c * Math.cos(hr); + b = c * Math.sin(hr); + return [l, a, b]; +} - if (colorAttachments[i] && colorAttachments[i].texture) { - var colorAttachmentSize = - textureFormatChannels[colorAttachments[i].texture._texture.format] * - textureTypeSizes[colorAttachments[i].texture._texture.type]; +function lch2xyz(args) { + return lab2xyz(lch2lab(args)); +} - if (commonColorAttachmentSize === null) { - commonColorAttachmentSize = colorAttachmentSize; - } else { - // We need to make sure that all color attachments have the same number of bitplanes - // (that is, the same numer of bits per pixel) - // This is required by the GLES2.0 standard. See the beginning of Chapter 4 in that document. - check$1(commonColorAttachmentSize === colorAttachmentSize, - 'all color attachments much have the same number of bits per pixel.'); - } - } - } - incRefAndCheckShape(depthAttachment, width, height); - check$1(!depthAttachment || - (depthAttachment.texture && - depthAttachment.texture._texture.format === GL_DEPTH_COMPONENT$1) || - (depthAttachment.renderbuffer && - depthAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_COMPONENT16$1), - 'invalid depth attachment for framebuffer object'); - incRefAndCheckShape(stencilAttachment, width, height); - check$1(!stencilAttachment || - (stencilAttachment.renderbuffer && - stencilAttachment.renderbuffer._renderbuffer.format === GL_STENCIL_INDEX8$1), - 'invalid stencil attachment for framebuffer object'); - incRefAndCheckShape(depthStencilAttachment, width, height); - check$1(!depthStencilAttachment || - (depthStencilAttachment.texture && - depthStencilAttachment.texture._texture.format === GL_DEPTH_STENCIL$2) || - (depthStencilAttachment.renderbuffer && - depthStencilAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_STENCIL$2), - 'invalid depth-stencil attachment for framebuffer object'); +function lch2rgb(args) { + return lab2rgb(lch2lab(args)); +} - // decrement references - decFBORefs(framebuffer); +function keyword2rgb(keyword) { + return cssKeywords[keyword]; +} - framebuffer.width = width; - framebuffer.height = height; +function keyword2hsl(args) { + return rgb2hsl(keyword2rgb(args)); +} - framebuffer.colorAttachments = colorAttachments; - framebuffer.depthAttachment = depthAttachment; - framebuffer.stencilAttachment = stencilAttachment; - framebuffer.depthStencilAttachment = depthStencilAttachment; +function keyword2hsv(args) { + return rgb2hsv(keyword2rgb(args)); +} - reglFramebuffer.color = colorAttachments.map(unwrapAttachment); - reglFramebuffer.depth = unwrapAttachment(depthAttachment); - reglFramebuffer.stencil = unwrapAttachment(stencilAttachment); - reglFramebuffer.depthStencil = unwrapAttachment(depthStencilAttachment); +function keyword2hwb(args) { + return rgb2hwb(keyword2rgb(args)); +} - reglFramebuffer.width = framebuffer.width; - reglFramebuffer.height = framebuffer.height; +function keyword2cmyk(args) { + return rgb2cmyk(keyword2rgb(args)); +} - updateFramebuffer(framebuffer); +function keyword2lab(args) { + return rgb2lab(keyword2rgb(args)); +} - return reglFramebuffer - } +function keyword2xyz(args) { + return rgb2xyz(keyword2rgb(args)); +} - function resize (w_, h_) { - check$1(framebufferState.next !== framebuffer, - 'can not resize a framebuffer which is currently in use'); +var cssKeywords = { + aliceblue: [240,248,255], + antiquewhite: [250,235,215], + aqua: [0,255,255], + aquamarine: [127,255,212], + azure: [240,255,255], + beige: [245,245,220], + bisque: [255,228,196], + black: [0,0,0], + blanchedalmond: [255,235,205], + blue: [0,0,255], + blueviolet: [138,43,226], + brown: [165,42,42], + burlywood: [222,184,135], + cadetblue: [95,158,160], + chartreuse: [127,255,0], + chocolate: [210,105,30], + coral: [255,127,80], + cornflowerblue: [100,149,237], + cornsilk: [255,248,220], + crimson: [220,20,60], + cyan: [0,255,255], + darkblue: [0,0,139], + darkcyan: [0,139,139], + darkgoldenrod: [184,134,11], + darkgray: [169,169,169], + darkgreen: [0,100,0], + darkgrey: [169,169,169], + darkkhaki: [189,183,107], + darkmagenta: [139,0,139], + darkolivegreen: [85,107,47], + darkorange: [255,140,0], + darkorchid: [153,50,204], + darkred: [139,0,0], + darksalmon: [233,150,122], + darkseagreen: [143,188,143], + darkslateblue: [72,61,139], + darkslategray: [47,79,79], + darkslategrey: [47,79,79], + darkturquoise: [0,206,209], + darkviolet: [148,0,211], + deeppink: [255,20,147], + deepskyblue: [0,191,255], + dimgray: [105,105,105], + dimgrey: [105,105,105], + dodgerblue: [30,144,255], + firebrick: [178,34,34], + floralwhite: [255,250,240], + forestgreen: [34,139,34], + fuchsia: [255,0,255], + gainsboro: [220,220,220], + ghostwhite: [248,248,255], + gold: [255,215,0], + goldenrod: [218,165,32], + gray: [128,128,128], + green: [0,128,0], + greenyellow: [173,255,47], + grey: [128,128,128], + honeydew: [240,255,240], + hotpink: [255,105,180], + indianred: [205,92,92], + indigo: [75,0,130], + ivory: [255,255,240], + khaki: [240,230,140], + lavender: [230,230,250], + lavenderblush: [255,240,245], + lawngreen: [124,252,0], + lemonchiffon: [255,250,205], + lightblue: [173,216,230], + lightcoral: [240,128,128], + lightcyan: [224,255,255], + lightgoldenrodyellow: [250,250,210], + lightgray: [211,211,211], + lightgreen: [144,238,144], + lightgrey: [211,211,211], + lightpink: [255,182,193], + lightsalmon: [255,160,122], + lightseagreen: [32,178,170], + lightskyblue: [135,206,250], + lightslategray: [119,136,153], + lightslategrey: [119,136,153], + lightsteelblue: [176,196,222], + lightyellow: [255,255,224], + lime: [0,255,0], + limegreen: [50,205,50], + linen: [250,240,230], + magenta: [255,0,255], + maroon: [128,0,0], + mediumaquamarine: [102,205,170], + mediumblue: [0,0,205], + mediumorchid: [186,85,211], + mediumpurple: [147,112,219], + mediumseagreen: [60,179,113], + mediumslateblue: [123,104,238], + mediumspringgreen: [0,250,154], + mediumturquoise: [72,209,204], + mediumvioletred: [199,21,133], + midnightblue: [25,25,112], + mintcream: [245,255,250], + mistyrose: [255,228,225], + moccasin: [255,228,181], + navajowhite: [255,222,173], + navy: [0,0,128], + oldlace: [253,245,230], + olive: [128,128,0], + olivedrab: [107,142,35], + orange: [255,165,0], + orangered: [255,69,0], + orchid: [218,112,214], + palegoldenrod: [238,232,170], + palegreen: [152,251,152], + paleturquoise: [175,238,238], + palevioletred: [219,112,147], + papayawhip: [255,239,213], + peachpuff: [255,218,185], + peru: [205,133,63], + pink: [255,192,203], + plum: [221,160,221], + powderblue: [176,224,230], + purple: [128,0,128], + rebeccapurple: [102, 51, 153], + red: [255,0,0], + rosybrown: [188,143,143], + royalblue: [65,105,225], + saddlebrown: [139,69,19], + salmon: [250,128,114], + sandybrown: [244,164,96], + seagreen: [46,139,87], + seashell: [255,245,238], + sienna: [160,82,45], + silver: [192,192,192], + skyblue: [135,206,235], + slateblue: [106,90,205], + slategray: [112,128,144], + slategrey: [112,128,144], + snow: [255,250,250], + springgreen: [0,255,127], + steelblue: [70,130,180], + tan: [210,180,140], + teal: [0,128,128], + thistle: [216,191,216], + tomato: [255,99,71], + turquoise: [64,224,208], + violet: [238,130,238], + wheat: [245,222,179], + white: [255,255,255], + whitesmoke: [245,245,245], + yellow: [255,255,0], + yellowgreen: [154,205,50] +}; - var w = w_ | 0; - var h = (h_ | 0) || w; - if (w === framebuffer.width && h === framebuffer.height) { - return reglFramebuffer - } +var reverseKeywords = {}; +for (var key in cssKeywords) { + reverseKeywords[JSON.stringify(cssKeywords[key])] = key; +} - // resize all buffers - var colorAttachments = framebuffer.colorAttachments; - for (var i = 0; i < colorAttachments.length; ++i) { - resizeAttachment(colorAttachments[i], w, h); - } - resizeAttachment(framebuffer.depthAttachment, w, h); - resizeAttachment(framebuffer.stencilAttachment, w, h); - resizeAttachment(framebuffer.depthStencilAttachment, w, h); - framebuffer.width = reglFramebuffer.width = w; - framebuffer.height = reglFramebuffer.height = h; +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { - updateFramebuffer(framebuffer); +var conversions = __webpack_require__(38); - return reglFramebuffer - } +var convert = function() { + return new Converter(); +} - reglFramebuffer(a0, a1); +for (var func in conversions) { + // export Raw versions + convert[func + "Raw"] = (function(func) { + // accept array or plain args + return function(arg) { + if (typeof arg == "number") + arg = Array.prototype.slice.call(arguments); + return conversions[func](arg); + } + })(func); - return extend(reglFramebuffer, { - resize: resize, - _reglType: 'framebuffer', - _framebuffer: framebuffer, - destroy: function () { - destroy(framebuffer); - decFBORefs(framebuffer); - }, - use: function (block) { - framebufferState.setFBO({ - framebuffer: reglFramebuffer - }, block); - } - }) - } + var pair = /(\w+)2(\w+)/.exec(func), + from = pair[1], + to = pair[2]; - function createCubeFBO (options) { - var faces = Array(6); + // export rgb2hsl and ["rgb"]["hsl"] + convert[from] = convert[from] || {}; - function reglFramebufferCube (a) { - var i; + convert[from][to] = convert[func] = (function(func) { + return function(arg) { + if (typeof arg == "number") + arg = Array.prototype.slice.call(arguments); + + var val = conversions[func](arg); + if (typeof val == "string" || val === undefined) + return val; // keyword - check$1(faces.indexOf(framebufferState.next) < 0, - 'can not update framebuffer which is currently in use'); + for (var i = 0; i < val.length; i++) + val[i] = Math.round(val[i]); + return val; + } + })(func); +} - var extDrawBuffers = extensions.webgl_draw_buffers; - var params = { - color: null - }; +/* Converter does lazy conversion and caching */ +var Converter = function() { + this.convs = {}; +}; - var radius = 0; +/* Either get the values for a space or + set the values for a space, depending on args */ +Converter.prototype.routeSpace = function(space, args) { + var values = args[0]; + if (values === undefined) { + // color.rgb() + return this.getValues(space); + } + // color.rgb(10, 10, 10) + if (typeof values == "number") { + values = Array.prototype.slice.call(args); + } - var colorBuffer = null; - var colorFormat = 'rgba'; - var colorType = 'uint8'; - var colorCount = 1; + return this.setValues(space, values); +}; + +/* Set the values for a space, invalidating cache */ +Converter.prototype.setValues = function(space, values) { + this.space = space; + this.convs = {}; + this.convs[space] = values; + return this; +}; - if (typeof a === 'number') { - radius = a | 0; - } else if (!a) { - radius = 1; - } else { - check$1.type(a, 'object', 'invalid arguments for framebuffer'); - var options = a; +/* Get the values for a space. If there's already + a conversion for the space, fetch it, otherwise + compute it */ +Converter.prototype.getValues = function(space) { + var vals = this.convs[space]; + if (!vals) { + var fspace = this.space, + from = this.convs[fspace]; + vals = convert[fspace][space](from); - if ('shape' in options) { - var shape = options.shape; - check$1( - Array.isArray(shape) && shape.length >= 2, - 'invalid shape for framebuffer'); - check$1( - shape[0] === shape[1], - 'cube framebuffer must be square'); - radius = shape[0]; - } else { - if ('radius' in options) { - radius = options.radius | 0; - } - if ('width' in options) { - radius = options.width | 0; - if ('height' in options) { - check$1(options.height === radius, 'must be square'); - } - } else if ('height' in options) { - radius = options.height | 0; - } - } + this.convs[space] = vals; + } + return vals; +}; - if ('color' in options || - 'colors' in options) { - colorBuffer = - options.color || - options.colors; - if (Array.isArray(colorBuffer)) { - check$1( - colorBuffer.length === 1 || extDrawBuffers, - 'multiple render targets not supported'); - } - } +["rgb", "hsl", "hsv", "cmyk", "keyword"].forEach(function(space) { + Converter.prototype[space] = function(vals) { + return this.routeSpace(space, arguments); + } +}); - if (!colorBuffer) { - if ('colorCount' in options) { - colorCount = options.colorCount | 0; - check$1(colorCount > 0, 'invalid color buffer count'); - } +module.exports = convert; - if ('colorType' in options) { - check$1.oneOf( - options.colorType, colorTypes, - 'invalid color type'); - colorType = options.colorType; - } +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { - if ('colorFormat' in options) { - colorFormat = options.colorFormat; - check$1.oneOf( - options.colorFormat, colorTextureFormats, - 'invalid color format for texture'); - } - } +(function (global, factory) { + true ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.createREGL = factory()); +}(this, (function () { 'use strict'; - if ('depth' in options) { - params.depth = options.depth; - } +var isTypedArray = function (x) { + return ( + x instanceof Uint8Array || + x instanceof Uint16Array || + x instanceof Uint32Array || + x instanceof Int8Array || + x instanceof Int16Array || + x instanceof Int32Array || + x instanceof Float32Array || + x instanceof Float64Array || + x instanceof Uint8ClampedArray + ) +} - if ('stencil' in options) { - params.stencil = options.stencil; - } +var extend = function (base, opts) { + var keys = Object.keys(opts) + for (var i = 0; i < keys.length; ++i) { + base[keys[i]] = opts[keys[i]] + } + return base +} - if ('depthStencil' in options) { - params.depthStencil = options.depthStencil; - } - } +// Error checking and parameter validation. +// +// Statements for the form `check.someProcedure(...)` get removed by +// a browserify transform for optimized/minified bundles. +// +/* globals atob */ +var endl = '\n' - var colorCubes; - if (colorBuffer) { - if (Array.isArray(colorBuffer)) { - colorCubes = []; - for (i = 0; i < colorBuffer.length; ++i) { - colorCubes[i] = colorBuffer[i]; - } - } else { - colorCubes = [ colorBuffer ]; - } - } else { - colorCubes = Array(colorCount); - var cubeMapParams = { - radius: radius, - format: colorFormat, - type: colorType - }; - for (i = 0; i < colorCount; ++i) { - colorCubes[i] = textureState.createCube(cubeMapParams); - } - } +// only used for extracting shader names. if atob not present, then errors +// will be slightly crappier +function decodeB64 (str) { + if (typeof atob !== 'undefined') { + return atob(str) + } + return 'base64:' + str +} - // Check color cubes - params.color = Array(colorCubes.length); - for (i = 0; i < colorCubes.length; ++i) { - var cube = colorCubes[i]; - check$1( - typeof cube === 'function' && cube._reglType === 'textureCube', - 'invalid cube map'); - radius = radius || cube.width; - check$1( - cube.width === radius && cube.height === radius, - 'invalid cube map shape'); - params.color[i] = { - target: GL_TEXTURE_CUBE_MAP_POSITIVE_X$1, - data: colorCubes[i] - }; - } +function raise (message) { + var error = new Error('(regl) ' + message) + console.error(error) + throw error +} - for (i = 0; i < 6; ++i) { - for (var j = 0; j < colorCubes.length; ++j) { - params.color[j].target = GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i; - } - // reuse depth-stencil attachments across all cube maps - if (i > 0) { - params.depth = faces[0].depth; - params.stencil = faces[0].stencil; - params.depthStencil = faces[0].depthStencil; - } - if (faces[i]) { - (faces[i])(params); - } else { - faces[i] = createFBO(params); - } - } +function check (pred, message) { + if (!pred) { + raise(message) + } +} - return extend(reglFramebufferCube, { - width: radius, - height: radius, - color: colorCubes - }) - } +function encolon (message) { + if (message) { + return ': ' + message + } + return '' +} - function resize (radius_) { - var i; - var radius = radius_ | 0; - check$1(radius > 0 && radius <= limits.maxCubeMapSize, - 'invalid radius for cube fbo'); +function checkParameter (param, possibilities, message) { + if (!(param in possibilities)) { + raise('unknown parameter (' + param + ')' + encolon(message) + + '. possible values: ' + Object.keys(possibilities).join()) + } +} - if (radius === reglFramebufferCube.width) { - return reglFramebufferCube - } +function checkIsTypedArray (data, message) { + if (!isTypedArray(data)) { + raise( + 'invalid parameter type' + encolon(message) + + '. must be a typed array') + } +} - var colors = reglFramebufferCube.color; - for (i = 0; i < colors.length; ++i) { - colors[i].resize(radius); - } +function standardTypeEh (value, type) { + switch (type) { + case 'number': return typeof value === 'number' + case 'object': return typeof value === 'object' + case 'string': return typeof value === 'string' + case 'boolean': return typeof value === 'boolean' + case 'function': return typeof value === 'function' + case 'undefined': return typeof value === 'undefined' + case 'symbol': return typeof value === 'symbol' + } +} - for (i = 0; i < 6; ++i) { - faces[i].resize(radius); - } +function checkTypeOf (value, type, message) { + if (!standardTypeEh(value, type)) { + raise( + 'invalid parameter type' + encolon(message) + + '. expected ' + type + ', got ' + (typeof value)) + } +} - reglFramebufferCube.width = reglFramebufferCube.height = radius; +function checkNonNegativeInt (value, message) { + if (!((value >= 0) && + ((value | 0) === value))) { + raise('invalid parameter type, (' + value + ')' + encolon(message) + + '. must be a nonnegative integer') + } +} - return reglFramebufferCube - } +function checkOneOf (value, list, message) { + if (list.indexOf(value) < 0) { + raise('invalid value' + encolon(message) + '. must be one of: ' + list) + } +} - reglFramebufferCube(options); +var constructorKeys = [ + 'gl', + 'canvas', + 'container', + 'attributes', + 'pixelRatio', + 'extensions', + 'optionalExtensions', + 'profile', + 'onDone' +] - return extend(reglFramebufferCube, { - faces: faces, - resize: resize, - _reglType: 'framebufferCube', - destroy: function () { - faces.forEach(function (f) { - f.destroy(); - }); - } - }) - } +function checkConstructor (obj) { + Object.keys(obj).forEach(function (key) { + if (constructorKeys.indexOf(key) < 0) { + raise('invalid regl constructor argument "' + key + '". must be one of ' + constructorKeys) + } + }) +} - function restoreFramebuffers () { - values(framebufferSet).forEach(function (fb) { - fb.framebuffer = gl.createFramebuffer(); - updateFramebuffer(fb); - }); +function leftPad (str, n) { + str = str + '' + while (str.length < n) { + str = ' ' + str } + return str +} - return extend(framebufferState, { - getFramebuffer: function (object) { - if (typeof object === 'function' && object._reglType === 'framebuffer') { - var fbo = object._framebuffer; - if (fbo instanceof REGLFramebuffer) { - return fbo - } - } - return null - }, - create: createFBO, - createCube: createCubeFBO, - clear: function () { - values(framebufferSet).forEach(destroy); - }, - restore: restoreFramebuffers - }) +function ShaderFile () { + this.name = 'unknown' + this.lines = [] + this.index = {} + this.hasErrors = false } -var GL_FLOAT$5 = 5126; +function ShaderLine (number, line) { + this.number = number + this.line = line + this.errors = [] +} -function AttributeRecord () { - this.state = 0; - - this.x = 0.0; - this.y = 0.0; - this.z = 0.0; - this.w = 0.0; - - this.buffer = null; - this.size = 0; - this.normalized = false; - this.type = GL_FLOAT$5; - this.offset = 0; - this.stride = 0; - this.divisor = 0; +function ShaderError (fileNumber, lineNumber, message) { + this.file = fileNumber + this.line = lineNumber + this.message = message } -function wrapAttributeState ( - gl, - extensions, - limits, - bufferState, - stringStore) { - var NUM_ATTRIBUTES = limits.maxAttributes; - var attributeBindings = new Array(NUM_ATTRIBUTES); - for (var i = 0; i < NUM_ATTRIBUTES; ++i) { - attributeBindings[i] = new AttributeRecord(); +function guessCommand () { + var error = new Error() + var stack = (error.stack || error).toString() + var pat = /compileProcedure.*\n\s*at.*\((.*)\)/.exec(stack) + if (pat) { + return pat[1] + } + var pat2 = /compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(stack) + if (pat2) { + return pat2[1] } + return 'unknown' +} - return { - Record: AttributeRecord, - scope: {}, - state: attributeBindings +function guessCallSite () { + var error = new Error() + var stack = (error.stack || error).toString() + var pat = /at REGLCommand.*\n\s+at.*\((.*)\)/.exec(stack) + if (pat) { + return pat[1] } + var pat2 = /at REGLCommand.*\n\s+at\s+(.*)\n/.exec(stack) + if (pat2) { + return pat2[1] + } + return 'unknown' } -var GL_FRAGMENT_SHADER = 35632; -var GL_VERTEX_SHADER = 35633; - -var GL_ACTIVE_UNIFORMS = 0x8B86; -var GL_ACTIVE_ATTRIBUTES = 0x8B89; - -function wrapShaderState (gl, stringStore, stats, config) { - // =================================================== - // glsl compilation and linking - // =================================================== - var fragShaders = {}; - var vertShaders = {}; - - function ActiveInfo (name, id, location, info) { - this.name = name; - this.id = id; - this.location = location; - this.info = info; +function parseSource (source, command) { + var lines = source.split('\n') + var lineNumber = 1 + var fileNumber = 0 + var files = { + unknown: new ShaderFile(), + 0: new ShaderFile() } - - function insertActiveInfo (list, info) { - for (var i = 0; i < list.length; ++i) { - if (list[i].id === info.id) { - list[i].location = info.location; - return + files.unknown.name = files[0].name = command || guessCommand() + files.unknown.lines.push(new ShaderLine(0, '')) + for (var i = 0; i < lines.length; ++i) { + var line = lines[i] + var parts = /^\s*#\s*(\w+)\s+(.+)\s*$/.exec(line) + if (parts) { + switch (parts[1]) { + case 'line': + var lineNumberInfo = /(\d+)(\s+\d+)?/.exec(parts[2]) + if (lineNumberInfo) { + lineNumber = lineNumberInfo[1] | 0 + if (lineNumberInfo[2]) { + fileNumber = lineNumberInfo[2] | 0 + if (!(fileNumber in files)) { + files[fileNumber] = new ShaderFile() + } + } + } + break + case 'define': + var nameInfo = /SHADER_NAME(_B64)?\s+(.*)$/.exec(parts[2]) + if (nameInfo) { + files[fileNumber].name = (nameInfo[1] + ? decodeB64(nameInfo[2]) + : nameInfo[2]) + } + break } } - list.push(info); + files[fileNumber].lines.push(new ShaderLine(lineNumber++, line)) } + Object.keys(files).forEach(function (fileNumber) { + var file = files[fileNumber] + file.lines.forEach(function (line) { + file.index[line.number] = line + }) + }) + return files +} - function getShader (type, id, command) { - var cache = type === GL_FRAGMENT_SHADER ? fragShaders : vertShaders; - var shader = cache[id]; - - if (!shader) { - var source = stringStore.str(id); - shader = gl.createShader(type); - gl.shaderSource(shader, source); - gl.compileShader(shader); - check$1.shaderError(gl, shader, source, type, command); - cache[id] = shader; +function parseErrorLog (errLog) { + var result = [] + errLog.split('\n').forEach(function (errMsg) { + if (errMsg.length < 5) { + return + } + var parts = /^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(errMsg) + if (parts) { + result.push(new ShaderError( + parts[1] | 0, + parts[2] | 0, + parts[3].trim())) + } else if (errMsg.length > 0) { + result.push(new ShaderError('unknown', 0, errMsg)) } + }) + return result +} - return shader - } +function annotateFiles (files, errors) { + errors.forEach(function (error) { + var file = files[error.file] + if (file) { + var line = file.index[error.line] + if (line) { + line.errors.push(error) + file.hasErrors = true + return + } + } + files.unknown.hasErrors = true + files.unknown.lines[0].errors.push(error) + }) +} - // =================================================== - // program linking - // =================================================== - var programCache = {}; - var programList = []; +function checkShaderError (gl, shader, source, type, command) { + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + var errLog = gl.getShaderInfoLog(shader) + var typeName = type === gl.FRAGMENT_SHADER ? 'fragment' : 'vertex' + checkCommandType(source, 'string', typeName + ' shader source must be a string', command) + var files = parseSource(source, command) + var errors = parseErrorLog(errLog) + annotateFiles(files, errors) - var PROGRAM_COUNTER = 0; + Object.keys(files).forEach(function (fileNumber) { + var file = files[fileNumber] + if (!file.hasErrors) { + return + } - function REGLProgram (fragId, vertId) { - this.id = PROGRAM_COUNTER++; - this.fragId = fragId; - this.vertId = vertId; - this.program = null; - this.uniforms = []; - this.attributes = []; + var strings = [''] + var styles = [''] - if (config.profile) { - this.stats = { - uniformsCount: 0, - attributesCount: 0 - }; - } - } + function push (str, style) { + strings.push(str) + styles.push(style || '') + } - function linkProgram (desc, command) { - var i, info; + push('file number ' + fileNumber + ': ' + file.name + '\n', 'color:red;text-decoration:underline;font-weight:bold') - // ------------------------------- - // compile & link - // ------------------------------- - var fragShader = getShader(GL_FRAGMENT_SHADER, desc.fragId); - var vertShader = getShader(GL_VERTEX_SHADER, desc.vertId); + file.lines.forEach(function (line) { + if (line.errors.length > 0) { + push(leftPad(line.number, 4) + '| ', 'background-color:yellow; font-weight:bold') + push(line.line + endl, 'color:red; background-color:yellow; font-weight:bold') - var program = desc.program = gl.createProgram(); - gl.attachShader(program, fragShader); - gl.attachShader(program, vertShader); - gl.linkProgram(program); - check$1.linkError( - gl, - program, - stringStore.str(desc.fragId), - stringStore.str(desc.vertId), - command); + // try to guess token + var offset = 0 + line.errors.forEach(function (error) { + var message = error.message + var token = /^\s*'(.*)'\s*:\s*(.*)$/.exec(message) + if (token) { + var tokenPat = token[1] + message = token[2] + switch (tokenPat) { + case 'assign': + tokenPat = '=' + break + } + offset = Math.max(line.line.indexOf(tokenPat, offset), 0) + } else { + offset = 0 + } - // ------------------------------- - // grab uniforms - // ------------------------------- - var numUniforms = gl.getProgramParameter(program, GL_ACTIVE_UNIFORMS); - if (config.profile) { - desc.stats.uniformsCount = numUniforms; - } - var uniforms = desc.uniforms; - for (i = 0; i < numUniforms; ++i) { - info = gl.getActiveUniform(program, i); - if (info) { - if (info.size > 1) { - for (var j = 0; j < info.size; ++j) { - var name = info.name.replace('[0]', '[' + j + ']'); - insertActiveInfo(uniforms, new ActiveInfo( - name, - stringStore.id(name), - gl.getUniformLocation(program, name), - info)); - } + push(leftPad('| ', 6)) + push(leftPad('^^^', offset + 3) + endl, 'font-weight:bold') + push(leftPad('| ', 6)) + push(message + endl, 'font-weight:bold') + }) + push(leftPad('| ', 6) + endl) } else { - insertActiveInfo(uniforms, new ActiveInfo( - info.name, - stringStore.id(info.name), - gl.getUniformLocation(program, info.name), - info)); + push(leftPad(line.number, 4) + '| ') + push(line.line + endl, 'color:red') } + }) + if (typeof document !== 'undefined' && !window.chrome) { + styles[0] = strings.join('%c') + console.log.apply(console, styles) + } else { + console.log(strings.join('')) } - } + }) - // ------------------------------- - // grab attributes - // ------------------------------- - var numAttributes = gl.getProgramParameter(program, GL_ACTIVE_ATTRIBUTES); - if (config.profile) { - desc.stats.attributesCount = numAttributes; - } + check.raise('Error compiling ' + typeName + ' shader, ' + files[0].name) + } +} - var attributes = desc.attributes; - for (i = 0; i < numAttributes; ++i) { - info = gl.getActiveAttrib(program, i); - if (info) { - insertActiveInfo(attributes, new ActiveInfo( - info.name, - stringStore.id(info.name), - gl.getAttribLocation(program, info.name), - info)); - } +function checkLinkError (gl, program, fragShader, vertShader, command) { + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { + var errLog = gl.getProgramInfoLog(program) + var fragParse = parseSource(fragShader, command) + var vertParse = parseSource(vertShader, command) + + var header = 'Error linking program with vertex shader, "' + + vertParse[0].name + '", and fragment shader "' + fragParse[0].name + '"' + + if (typeof document !== 'undefined') { + console.log('%c' + header + endl + '%c' + errLog, + 'color:red;text-decoration:underline;font-weight:bold', + 'color:red') + } else { + console.log(header + endl + errLog) } + check.raise(header) } +} - if (config.profile) { - stats.getMaxUniformsCount = function () { - var m = 0; - programList.forEach(function (desc) { - if (desc.stats.uniformsCount > m) { - m = desc.stats.uniformsCount; - } - }); - return m - }; +function saveCommandRef (object) { + object._commandRef = guessCommand() +} - stats.getMaxAttributesCount = function () { - var m = 0; - programList.forEach(function (desc) { - if (desc.stats.attributesCount > m) { - m = desc.stats.attributesCount; - } - }); - return m - }; - } +function saveDrawCommandInfo (opts, uniforms, attributes, stringStore) { + saveCommandRef(opts) - function restoreShaders () { - fragShaders = {}; - vertShaders = {}; - for (var i = 0; i < programList.length; ++i) { - linkProgram(programList[i]); + function id (str) { + if (str) { + return stringStore.id(str) } + return 0 } + opts._fragId = id(opts.static.frag) + opts._vertId = id(opts.static.vert) - return { - clear: function () { - var deleteShader = gl.deleteShader.bind(gl); - values(fragShaders).forEach(deleteShader); - fragShaders = {}; - values(vertShaders).forEach(deleteShader); - vertShaders = {}; + function addProps (dict, set) { + Object.keys(set).forEach(function (u) { + dict[stringStore.id(u)] = true + }) + } - programList.forEach(function (desc) { - gl.deleteProgram(desc.program); - }); - programList.length = 0; - programCache = {}; + var uniformSet = opts._uniformSet = {} + addProps(uniformSet, uniforms.static) + addProps(uniformSet, uniforms.dynamic) - stats.shaderCount = 0; - }, + var attributeSet = opts._attributeSet = {} + addProps(attributeSet, attributes.static) + addProps(attributeSet, attributes.dynamic) - program: function (vertId, fragId, command) { - check$1.command(vertId >= 0, 'missing vertex shader', command); - check$1.command(fragId >= 0, 'missing fragment shader', command); + opts._hasCount = ( + 'count' in opts.static || + 'count' in opts.dynamic || + 'elements' in opts.static || + 'elements' in opts.dynamic) +} - var cache = programCache[fragId]; - if (!cache) { - cache = programCache[fragId] = {}; - } - var program = cache[vertId]; - if (!program) { - program = new REGLProgram(fragId, vertId); - stats.shaderCount++; +function commandRaise (message, command) { + var callSite = guessCallSite() + raise(message + + ' in command ' + (command || guessCommand()) + + (callSite === 'unknown' ? '' : ' called from ' + callSite)) +} - linkProgram(program, command); - cache[vertId] = program; - programList.push(program); - } - return program - }, +function checkCommand (pred, message, command) { + if (!pred) { + commandRaise(message, command || guessCommand()) + } +} - restore: restoreShaders, +function checkParameterCommand (param, possibilities, message, command) { + if (!(param in possibilities)) { + commandRaise( + 'unknown parameter (' + param + ')' + encolon(message) + + '. possible values: ' + Object.keys(possibilities).join(), + command || guessCommand()) + } +} - shader: getShader, +function checkCommandType (value, type, message, command) { + if (!standardTypeEh(value, type)) { + commandRaise( + 'invalid parameter type' + encolon(message) + + '. expected ' + type + ', got ' + (typeof value), + command || guessCommand()) + } +} - frag: -1, - vert: -1 +function checkOptional (block) { + block() +} + +function checkFramebufferFormat (attachment, texFormats, rbFormats) { + if (attachment.texture) { + checkOneOf( + attachment.texture._texture.internalformat, + texFormats, + 'unsupported texture format for attachment') + } else { + checkOneOf( + attachment.renderbuffer._renderbuffer.format, + rbFormats, + 'unsupported renderbuffer format for attachment') } } -var GL_RGBA$2 = 6408; -var GL_UNSIGNED_BYTE$6 = 5121; -var GL_PACK_ALIGNMENT = 0x0D05; -var GL_FLOAT$6 = 0x1406; // 5126 +var GL_CLAMP_TO_EDGE = 0x812F -function wrapReadPixels ( - gl, - framebufferState, - reglPoll, - context, - glAttributes, - extensions) { - function readPixelsImpl (input) { - var type; - if (framebufferState.next === null) { - check$1( - glAttributes.preserveDrawingBuffer, - 'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'); - type = GL_UNSIGNED_BYTE$6; - } else { - check$1( - framebufferState.next.colorAttachments[0].texture !== null, - 'You cannot read from a renderbuffer'); - type = framebufferState.next.colorAttachments[0].texture._texture.type; +var GL_NEAREST = 0x2600 +var GL_NEAREST_MIPMAP_NEAREST = 0x2700 +var GL_LINEAR_MIPMAP_NEAREST = 0x2701 +var GL_NEAREST_MIPMAP_LINEAR = 0x2702 +var GL_LINEAR_MIPMAP_LINEAR = 0x2703 - if (extensions.oes_texture_float) { - check$1( - type === GL_UNSIGNED_BYTE$6 || type === GL_FLOAT$6, - 'Reading from a framebuffer is only allowed for the types \'uint8\' and \'float\''); - } else { - check$1( - type === GL_UNSIGNED_BYTE$6, - 'Reading from a framebuffer is only allowed for the type \'uint8\''); - } - } +var GL_BYTE = 5120 +var GL_UNSIGNED_BYTE = 5121 +var GL_SHORT = 5122 +var GL_UNSIGNED_SHORT = 5123 +var GL_INT = 5124 +var GL_UNSIGNED_INT = 5125 +var GL_FLOAT = 5126 - var x = 0; - var y = 0; - var width = context.framebufferWidth; - var height = context.framebufferHeight; - var data = null; +var GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033 +var GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034 +var GL_UNSIGNED_SHORT_5_6_5 = 0x8363 +var GL_UNSIGNED_INT_24_8_WEBGL = 0x84FA - if (isTypedArray(input)) { - data = input; - } else if (input) { - check$1.type(input, 'object', 'invalid arguments to regl.read()'); - x = input.x | 0; - y = input.y | 0; - check$1( - x >= 0 && x < context.framebufferWidth, - 'invalid x offset for regl.read'); - check$1( - y >= 0 && y < context.framebufferHeight, - 'invalid y offset for regl.read'); - width = (input.width || (context.framebufferWidth - x)) | 0; - height = (input.height || (context.framebufferHeight - y)) | 0; - data = input.data || null; - } +var GL_HALF_FLOAT_OES = 0x8D61 - // sanity check input.data - if (data) { - if (type === GL_UNSIGNED_BYTE$6) { - check$1( - data instanceof Uint8Array, - 'buffer must be \'Uint8Array\' when reading from a framebuffer of type \'uint8\''); - } else if (type === GL_FLOAT$6) { - check$1( - data instanceof Float32Array, - 'buffer must be \'Float32Array\' when reading from a framebuffer of type \'float\''); - } - } +var TYPE_SIZE = {} - check$1( - width > 0 && width + x <= context.framebufferWidth, - 'invalid width for read pixels'); - check$1( - height > 0 && height + y <= context.framebufferHeight, - 'invalid height for read pixels'); +TYPE_SIZE[GL_BYTE] = +TYPE_SIZE[GL_UNSIGNED_BYTE] = 1 - // Update WebGL state - reglPoll(); +TYPE_SIZE[GL_SHORT] = +TYPE_SIZE[GL_UNSIGNED_SHORT] = +TYPE_SIZE[GL_HALF_FLOAT_OES] = +TYPE_SIZE[GL_UNSIGNED_SHORT_5_6_5] = +TYPE_SIZE[GL_UNSIGNED_SHORT_4_4_4_4] = +TYPE_SIZE[GL_UNSIGNED_SHORT_5_5_5_1] = 2 - // Compute size - var size = width * height * 4; +TYPE_SIZE[GL_INT] = +TYPE_SIZE[GL_UNSIGNED_INT] = +TYPE_SIZE[GL_FLOAT] = +TYPE_SIZE[GL_UNSIGNED_INT_24_8_WEBGL] = 4 - // Allocate data - if (!data) { - if (type === GL_UNSIGNED_BYTE$6) { - data = new Uint8Array(size); - } else if (type === GL_FLOAT$6) { - data = data || new Float32Array(size); - } - } +function pixelSize (type, channels) { + if (type === GL_UNSIGNED_SHORT_5_5_5_1 || + type === GL_UNSIGNED_SHORT_4_4_4_4 || + type === GL_UNSIGNED_SHORT_5_6_5) { + return 2 + } else if (type === GL_UNSIGNED_INT_24_8_WEBGL) { + return 4 + } else { + return TYPE_SIZE[type] * channels + } +} - // Type check - check$1.isTypedArray(data, 'data buffer for regl.read() must be a typedarray'); - check$1(data.byteLength >= size, 'data buffer for regl.read() too small'); +function isPow2 (v) { + return !(v & (v - 1)) && (!!v) +} - // Run read pixels - gl.pixelStorei(GL_PACK_ALIGNMENT, 4); - gl.readPixels(x, y, width, height, GL_RGBA$2, - type, - data); +function checkTexture2D (info, mipData, limits) { + var i + var w = mipData.width + var h = mipData.height + var c = mipData.channels - return data + // Check texture shape + check(w > 0 && w <= limits.maxTextureSize && + h > 0 && h <= limits.maxTextureSize, + 'invalid texture shape') + + // check wrap mode + if (info.wrapS !== GL_CLAMP_TO_EDGE || info.wrapT !== GL_CLAMP_TO_EDGE) { + check(isPow2(w) && isPow2(h), + 'incompatible wrap mode for texture, both width and height must be power of 2') } - function readPixelsFBO (options) { - var result; - framebufferState.setFBO({ - framebuffer: options.framebuffer - }, function () { - result = readPixelsImpl(options); - }); - return result + if (mipData.mipmask === 1) { + if (w !== 1 && h !== 1) { + check( + info.minFilter !== GL_NEAREST_MIPMAP_NEAREST && + info.minFilter !== GL_NEAREST_MIPMAP_LINEAR && + info.minFilter !== GL_LINEAR_MIPMAP_NEAREST && + info.minFilter !== GL_LINEAR_MIPMAP_LINEAR, + 'min filter requires mipmap') + } + } else { + // texture must be power of 2 + check(isPow2(w) && isPow2(h), + 'texture must be a square power of 2 to support mipmapping') + check(mipData.mipmask === (w << 1) - 1, + 'missing or incomplete mipmap data') } - function readPixels (options) { - if (!options || !('framebuffer' in options)) { - return readPixelsImpl(options) - } else { - return readPixelsFBO(options) + if (mipData.type === GL_FLOAT) { + if (limits.extensions.indexOf('oes_texture_float_linear') < 0) { + check(info.minFilter === GL_NEAREST && info.magFilter === GL_NEAREST, + 'filter not supported, must enable oes_texture_float_linear') } + check(!info.genMipmaps, + 'mipmap generation not supported with float textures') } - return readPixels -} + // check image complete + var mipimages = mipData.images + for (i = 0; i < 16; ++i) { + if (mipimages[i]) { + var mw = w >> i + var mh = h >> i + check(mipData.mipmask & (1 << i), 'missing mipmap data') -function slice (x) { - return Array.prototype.slice.call(x) -} + var img = mipimages[i] -function join (x) { - return slice(x).join('') -} + check( + img.width === mw && + img.height === mh, + 'invalid shape for mip images') -function createEnvironment () { - // Unique variable id counter - var varCounter = 0; + check( + img.format === mipData.format && + img.internalformat === mipData.internalformat && + img.type === mipData.type, + 'incompatible type for mip image') - // Linked values are passed from this scope into the generated code block - // Calling link() passes a value into the generated scope and returns - // the variable name which it is bound to - var linkedNames = []; - var linkedValues = []; - function link (value) { - for (var i = 0; i < linkedValues.length; ++i) { - if (linkedValues[i] === value) { - return linkedNames[i] + if (img.compressed) { + // TODO: check size for compressed images + } else if (img.data) { + // check(img.data.byteLength === mw * mh * + // Math.max(pixelSize(img.type, c), img.unpackAlignment), + var rowSize = Math.ceil(pixelSize(img.type, c) * mw / img.unpackAlignment) * img.unpackAlignment + check(img.data.byteLength === rowSize * mh, + 'invalid data for image, buffer size is inconsistent with image format') + } else if (img.element) { + // TODO: check element can be loaded + } else if (img.copy) { + // TODO: check compatible format and type } + } else if (!info.genMipmaps) { + check((mipData.mipmask & (1 << i)) === 0, 'extra mipmap data') } + } - var name = 'g' + (varCounter++); - linkedNames.push(name); - linkedValues.push(value); - return name + if (mipData.compressed) { + check(!info.genMipmaps, + 'mipmap generation for compressed images not supported') } +} - // create a code block - function block () { - var code = []; - function push () { - code.push.apply(code, slice(arguments)); - } +function checkTextureCube (texture, info, faces, limits) { + var w = texture.width + var h = texture.height + var c = texture.channels - var vars = []; - function def () { - var name = 'v' + (varCounter++); - vars.push(name); + // Check texture shape + check( + w > 0 && w <= limits.maxTextureSize && h > 0 && h <= limits.maxTextureSize, + 'invalid texture shape') + check( + w === h, + 'cube map must be square') + check( + info.wrapS === GL_CLAMP_TO_EDGE && info.wrapT === GL_CLAMP_TO_EDGE, + 'wrap mode not supported by cube map') - if (arguments.length > 0) { - code.push(name, '='); - code.push.apply(code, slice(arguments)); - code.push(';'); - } + for (var i = 0; i < faces.length; ++i) { + var face = faces[i] + check( + face.width === w && face.height === h, + 'inconsistent cube map face shape') - return name + if (info.genMipmaps) { + check(!face.compressed, + 'can not generate mipmap for compressed textures') + check(face.mipmask === 1, + 'can not specify mipmaps and generate mipmaps') + } else { + // TODO: check mip and filter mode } - return extend(push, { - def: def, - toString: function () { - return join([ - (vars.length > 0 ? 'var ' + vars + ';' : ''), - join(code) - ]) - } - }) - } - - function scope () { - var entry = block(); - var exit = block(); - - var entryToString = entry.toString; - var exitToString = exit.toString; - - function save (object, prop) { - exit(object, prop, '=', entry.def(object, prop), ';'); - } + var mipmaps = face.images + for (var j = 0; j < 16; ++j) { + var img = mipmaps[j] + if (img) { + var mw = w >> j + var mh = h >> j + check(face.mipmask & (1 << j), 'missing mipmap data') + check( + img.width === mw && + img.height === mh, + 'invalid shape for mip images') + check( + img.format === texture.format && + img.internalformat === texture.internalformat && + img.type === texture.type, + 'incompatible type for mip image') - return extend(function () { - entry.apply(entry, slice(arguments)); - }, { - def: entry.def, - entry: entry, - exit: exit, - save: save, - set: function (object, prop, value) { - save(object, prop); - entry(object, prop, '=', value, ';'); - }, - toString: function () { - return entryToString() + exitToString() + if (img.compressed) { + // TODO: check size for compressed images + } else if (img.data) { + check(img.data.byteLength === mw * mh * + Math.max(pixelSize(img.type, c), img.unpackAlignment), + 'invalid data for image, buffer size is inconsistent with image format') + } else if (img.element) { + // TODO: check element can be loaded + } else if (img.copy) { + // TODO: check compatible format and type + } } - }) + } } +} - function conditional () { - var pred = join(arguments); - var thenBlock = scope(); - var elseBlock = scope(); +var check$1 = extend(check, { + optional: checkOptional, + raise: raise, + commandRaise: commandRaise, + command: checkCommand, + parameter: checkParameter, + commandParameter: checkParameterCommand, + constructor: checkConstructor, + type: checkTypeOf, + commandType: checkCommandType, + isTypedArray: checkIsTypedArray, + nni: checkNonNegativeInt, + oneOf: checkOneOf, + shaderError: checkShaderError, + linkError: checkLinkError, + callSite: guessCallSite, + saveCommandRef: saveCommandRef, + saveDrawInfo: saveDrawCommandInfo, + framebufferFormat: checkFramebufferFormat, + guessCommand: guessCommand, + texture2D: checkTexture2D, + textureCube: checkTextureCube +}); - var thenToString = thenBlock.toString; - var elseToString = elseBlock.toString; +var VARIABLE_COUNTER = 0 - return extend(thenBlock, { - then: function () { - thenBlock.apply(thenBlock, slice(arguments)); - return this - }, - else: function () { - elseBlock.apply(elseBlock, slice(arguments)); - return this - }, - toString: function () { - var elseClause = elseToString(); - if (elseClause) { - elseClause = 'else{' + elseClause + '}'; - } - return join([ - 'if(', pred, '){', - thenToString(), - '}', elseClause - ]) - } - }) - } +var DYN_FUNC = 0 +var DYN_CONSTANT = 5 +var DYN_ARRAY = 6 - // procedure list - var globalBlock = block(); - var procedures = {}; - function proc (name, count) { - var args = []; - function arg () { - var name = 'a' + args.length; - args.push(name); - return name - } +function DynamicVariable (type, data) { + this.id = (VARIABLE_COUNTER++) + this.type = type + this.data = data +} - count = count || 0; - for (var i = 0; i < count; ++i) { - arg(); - } +function escapeStr (str) { + return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') +} - var body = scope(); - var bodyToString = body.toString; +function splitParts (str) { + if (str.length === 0) { + return [] + } - var result = procedures[name] = extend(body, { - arg: arg, - toString: function () { - return join([ - 'function(', args.join(), '){', - bodyToString(), - '}' - ]) - } - }); + var firstChar = str.charAt(0) + var lastChar = str.charAt(str.length - 1) - return result + if (str.length > 1 && + firstChar === lastChar && + (firstChar === '"' || firstChar === "'")) { + return ['"' + escapeStr(str.substr(1, str.length - 2)) + '"'] } - function compile () { - var code = ['"use strict";', - globalBlock, - 'return {']; - Object.keys(procedures).forEach(function (name) { - code.push('"', name, '":', procedures[name].toString(), ','); - }); - code.push('}'); - var src = join(code) - .replace(/;/g, ';\n') - .replace(/}/g, '}\n') - .replace(/{/g, '{\n'); - var proc = Function.apply(null, linkedNames.concat(src)); - return proc.apply(null, linkedValues) + var parts = /\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(str) + if (parts) { + return ( + splitParts(str.substr(0, parts.index)) + .concat(splitParts(parts[1])) + .concat(splitParts(str.substr(parts.index + parts[0].length))) + ) } - return { - global: globalBlock, - link: link, - block: block, - proc: proc, - scope: scope, - cond: conditional, - compile: compile + var subparts = str.split('.') + if (subparts.length === 1) { + return ['"' + escapeStr(str) + '"'] } -} -// "cute" names for vector components -var CUTE_COMPONENTS = 'xyzw'.split(''); - -var GL_UNSIGNED_BYTE$7 = 5121; - -var ATTRIB_STATE_POINTER = 1; -var ATTRIB_STATE_CONSTANT = 2; - -var DYN_FUNC$1 = 0; -var DYN_PROP$1 = 1; -var DYN_CONTEXT$1 = 2; -var DYN_STATE$1 = 3; -var DYN_THUNK = 4; - -var S_DITHER = 'dither'; -var S_BLEND_ENABLE = 'blend.enable'; -var S_BLEND_COLOR = 'blend.color'; -var S_BLEND_EQUATION = 'blend.equation'; -var S_BLEND_FUNC = 'blend.func'; -var S_DEPTH_ENABLE = 'depth.enable'; -var S_DEPTH_FUNC = 'depth.func'; -var S_DEPTH_RANGE = 'depth.range'; -var S_DEPTH_MASK = 'depth.mask'; -var S_COLOR_MASK = 'colorMask'; -var S_CULL_ENABLE = 'cull.enable'; -var S_CULL_FACE = 'cull.face'; -var S_FRONT_FACE = 'frontFace'; -var S_LINE_WIDTH = 'lineWidth'; -var S_POLYGON_OFFSET_ENABLE = 'polygonOffset.enable'; -var S_POLYGON_OFFSET_OFFSET = 'polygonOffset.offset'; -var S_SAMPLE_ALPHA = 'sample.alpha'; -var S_SAMPLE_ENABLE = 'sample.enable'; -var S_SAMPLE_COVERAGE = 'sample.coverage'; -var S_STENCIL_ENABLE = 'stencil.enable'; -var S_STENCIL_MASK = 'stencil.mask'; -var S_STENCIL_FUNC = 'stencil.func'; -var S_STENCIL_OPFRONT = 'stencil.opFront'; -var S_STENCIL_OPBACK = 'stencil.opBack'; -var S_SCISSOR_ENABLE = 'scissor.enable'; -var S_SCISSOR_BOX = 'scissor.box'; -var S_VIEWPORT = 'viewport'; - -var S_PROFILE = 'profile'; - -var S_FRAMEBUFFER = 'framebuffer'; -var S_VERT = 'vert'; -var S_FRAG = 'frag'; -var S_ELEMENTS = 'elements'; -var S_PRIMITIVE = 'primitive'; -var S_COUNT = 'count'; -var S_OFFSET = 'offset'; -var S_INSTANCES = 'instances'; - -var SUFFIX_WIDTH = 'Width'; -var SUFFIX_HEIGHT = 'Height'; - -var S_FRAMEBUFFER_WIDTH = S_FRAMEBUFFER + SUFFIX_WIDTH; -var S_FRAMEBUFFER_HEIGHT = S_FRAMEBUFFER + SUFFIX_HEIGHT; -var S_VIEWPORT_WIDTH = S_VIEWPORT + SUFFIX_WIDTH; -var S_VIEWPORT_HEIGHT = S_VIEWPORT + SUFFIX_HEIGHT; -var S_DRAWINGBUFFER = 'drawingBuffer'; -var S_DRAWINGBUFFER_WIDTH = S_DRAWINGBUFFER + SUFFIX_WIDTH; -var S_DRAWINGBUFFER_HEIGHT = S_DRAWINGBUFFER + SUFFIX_HEIGHT; + var result = [] + for (var i = 0; i < subparts.length; ++i) { + result = result.concat(splitParts(subparts[i])) + } + return result +} -var NESTED_OPTIONS = [ - S_BLEND_FUNC, - S_BLEND_EQUATION, - S_STENCIL_FUNC, - S_STENCIL_OPFRONT, - S_STENCIL_OPBACK, - S_SAMPLE_COVERAGE, - S_VIEWPORT, - S_SCISSOR_BOX, - S_POLYGON_OFFSET_OFFSET -]; +function toAccessorString (str) { + return '[' + splitParts(str).join('][') + ']' +} -var GL_ARRAY_BUFFER$1 = 34962; -var GL_ELEMENT_ARRAY_BUFFER$1 = 34963; - -var GL_FRAGMENT_SHADER$1 = 35632; -var GL_VERTEX_SHADER$1 = 35633; - -var GL_TEXTURE_2D$2 = 0x0DE1; -var GL_TEXTURE_CUBE_MAP$1 = 0x8513; - -var GL_CULL_FACE = 0x0B44; -var GL_BLEND = 0x0BE2; -var GL_DITHER = 0x0BD0; -var GL_STENCIL_TEST = 0x0B90; -var GL_DEPTH_TEST = 0x0B71; -var GL_SCISSOR_TEST = 0x0C11; -var GL_POLYGON_OFFSET_FILL = 0x8037; -var GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E; -var GL_SAMPLE_COVERAGE = 0x80A0; - -var GL_FLOAT$7 = 5126; -var GL_FLOAT_VEC2 = 35664; -var GL_FLOAT_VEC3 = 35665; -var GL_FLOAT_VEC4 = 35666; -var GL_INT$3 = 5124; -var GL_INT_VEC2 = 35667; -var GL_INT_VEC3 = 35668; -var GL_INT_VEC4 = 35669; -var GL_BOOL = 35670; -var GL_BOOL_VEC2 = 35671; -var GL_BOOL_VEC3 = 35672; -var GL_BOOL_VEC4 = 35673; -var GL_FLOAT_MAT2 = 35674; -var GL_FLOAT_MAT3 = 35675; -var GL_FLOAT_MAT4 = 35676; -var GL_SAMPLER_2D = 35678; -var GL_SAMPLER_CUBE = 35680; - -var GL_TRIANGLES$1 = 4; - -var GL_FRONT = 1028; -var GL_BACK = 1029; -var GL_CW = 0x0900; -var GL_CCW = 0x0901; -var GL_MIN_EXT = 0x8007; -var GL_MAX_EXT = 0x8008; -var GL_ALWAYS = 519; -var GL_KEEP = 7680; -var GL_ZERO = 0; -var GL_ONE = 1; -var GL_FUNC_ADD = 0x8006; -var GL_LESS = 513; - -var GL_FRAMEBUFFER$1 = 0x8D40; -var GL_COLOR_ATTACHMENT0$1 = 0x8CE0; +function defineDynamic (type, data) { + return new DynamicVariable(type, toAccessorString(data + '')) +} -var blendFuncs = { - '0': 0, - '1': 1, - 'zero': 0, - 'one': 1, - 'src color': 768, - 'one minus src color': 769, - 'src alpha': 770, - 'one minus src alpha': 771, - 'dst color': 774, - 'one minus dst color': 775, - 'dst alpha': 772, - 'one minus dst alpha': 773, - 'constant color': 32769, - 'one minus constant color': 32770, - 'constant alpha': 32771, - 'one minus constant alpha': 32772, - 'src alpha saturate': 776 -}; +function isDynamic (x) { + return (typeof x === 'function' && !x._reglType) || (x instanceof DynamicVariable) +} -// There are invalid values for srcRGB and dstRGB. See: -// https://www.khronos.org/registry/webgl/specs/1.0/#6.13 -// https://github.com/KhronosGroup/WebGL/blob/0d3201f5f7ec3c0060bc1f04077461541f1987b9/conformance-suites/1.0.3/conformance/misc/webgl-specific.html#L56 -var invalidBlendCombinations = [ - 'constant color, constant alpha', - 'one minus constant color, constant alpha', - 'constant color, one minus constant alpha', - 'one minus constant color, one minus constant alpha', - 'constant alpha, constant color', - 'constant alpha, one minus constant color', - 'one minus constant alpha, constant color', - 'one minus constant alpha, one minus constant color' -]; +function unbox (x, path) { + if (typeof x === 'function') { + return new DynamicVariable(DYN_FUNC, x) + } else if (typeof x === 'number' || typeof x === 'boolean') { + return new DynamicVariable(DYN_CONSTANT, x) + } else if (Array.isArray(x)) { + return new DynamicVariable(DYN_ARRAY, x.map((y, i) => unbox(y, path + '[' + i + ']'))) + } else if (x instanceof DynamicVariable) { + return x + } + check$1(false, 'invalid option type in uniform ' + path) +} -var compareFuncs = { - 'never': 512, - 'less': 513, - '<': 513, - 'equal': 514, - '=': 514, - '==': 514, - '===': 514, - 'lequal': 515, - '<=': 515, - 'greater': 516, - '>': 516, - 'notequal': 517, - '!=': 517, - '!==': 517, - 'gequal': 518, - '>=': 518, - 'always': 519 +var dynamic = { + DynamicVariable: DynamicVariable, + define: defineDynamic, + isDynamic: isDynamic, + unbox: unbox, + accessor: toAccessorString }; -var stencilOps = { - '0': 0, - 'zero': 0, - 'keep': 7680, - 'replace': 7681, - 'increment': 7682, - 'decrement': 7683, - 'increment wrap': 34055, - 'decrement wrap': 34056, - 'invert': 5386 +/* globals requestAnimationFrame, cancelAnimationFrame */ +var raf = { + next: typeof requestAnimationFrame === 'function' + ? function (cb) { return requestAnimationFrame(cb) } + : function (cb) { return setTimeout(cb, 16) }, + cancel: typeof cancelAnimationFrame === 'function' + ? function (raf) { return cancelAnimationFrame(raf) } + : clearTimeout }; -var shaderType = { - 'frag': GL_FRAGMENT_SHADER$1, - 'vert': GL_VERTEX_SHADER$1 -}; +/* globals performance */ +var clock = (typeof performance !== 'undefined' && performance.now) + ? function () { return performance.now() } + : function () { return +(new Date()) }; -var orientationType = { - 'cw': GL_CW, - 'ccw': GL_CCW -}; +function createStringStore () { + var stringIds = { '': 0 } + var stringValues = [''] + return { + id: function (str) { + var result = stringIds[str] + if (result) { + return result + } + result = stringIds[str] = stringValues.length + stringValues.push(str) + return result + }, -function isBufferArgs (x) { - return Array.isArray(x) || - isTypedArray(x) || - isNDArrayLike(x) + str: function (id) { + return stringValues[id] + } + } } -// Make sure viewport is processed first -function sortState (state) { - return state.sort(function (a, b) { - if (a === S_VIEWPORT) { - return -1 - } else if (b === S_VIEWPORT) { - return 1 - } - return (a < b) ? -1 : 1 +// Context and canvas creation helper functions +function createCanvas (element, onDone, pixelRatio) { + var canvas = document.createElement('canvas') + extend(canvas.style, { + border: 0, + margin: 0, + padding: 0, + top: 0, + left: 0 }) -} + element.appendChild(canvas) -function Declaration (thisDep, contextDep, propDep, append) { - this.thisDep = thisDep; - this.contextDep = contextDep; - this.propDep = propDep; - this.append = append; -} + if (element === document.body) { + canvas.style.position = 'absolute' + extend(element.style, { + margin: 0, + padding: 0 + }) + } -function isStatic (decl) { - return decl && !(decl.thisDep || decl.contextDep || decl.propDep) -} + function resize () { + var w = window.innerWidth + var h = window.innerHeight + if (element !== document.body) { + var bounds = element.getBoundingClientRect() + w = bounds.right - bounds.left + h = bounds.bottom - bounds.top + } + canvas.width = pixelRatio * w + canvas.height = pixelRatio * h + extend(canvas.style, { + width: w + 'px', + height: h + 'px' + }) + } -function createStaticDecl (append) { - return new Declaration(false, false, false, append) + var resizeObserver + if (element !== document.body && typeof ResizeObserver === 'function') { + // ignore 'ResizeObserver' is not defined + // eslint-disable-next-line + resizeObserver = new ResizeObserver(function () { + // setTimeout to avoid flicker + setTimeout(resize) + }) + resizeObserver.observe(element) + } else { + window.addEventListener('resize', resize, false) + } + + function onDestroy () { + if (resizeObserver) { + resizeObserver.disconnect() + } else { + window.removeEventListener('resize', resize) + } + element.removeChild(canvas) + } + + resize() + + return { + canvas: canvas, + onDestroy: onDestroy + } } -function createDynamicDecl (dyn, append) { - var type = dyn.type; - if (type === DYN_FUNC$1) { - var numArgs = dyn.data.length; - return new Declaration( - true, - numArgs >= 1, - numArgs >= 2, - append) - } else if (type === DYN_THUNK) { - var data = dyn.data; - return new Declaration( - data.thisDep, - data.contextDep, - data.propDep, - append) - } else { - return new Declaration( - type === DYN_STATE$1, - type === DYN_CONTEXT$1, - type === DYN_PROP$1, - append) +function createContext (canvas, contextAttributes) { + function get (name) { + try { + return canvas.getContext(name, contextAttributes) + } catch (e) { + return null + } } + return ( + get('webgl') || + get('experimental-webgl') || + get('webgl-experimental') + ) } -var SCOPE_DECL = new Declaration(false, false, false, function () {}); +function isHTMLElement (obj) { + return ( + typeof obj.nodeName === 'string' && + typeof obj.appendChild === 'function' && + typeof obj.getBoundingClientRect === 'function' + ) +} -function reglCore ( - gl, - stringStore, - extensions, - limits, - bufferState, - elementState, - textureState, - framebufferState, - uniformState, - attributeState, - shaderState, - drawState, - contextState, - timer, - config) { - var AttributeRecord = attributeState.Record; +function isWebGLContext (obj) { + return ( + typeof obj.drawArrays === 'function' || + typeof obj.drawElements === 'function' + ) +} - var blendEquations = { - 'add': 32774, - 'subtract': 32778, - 'reverse subtract': 32779 - }; - if (extensions.ext_blend_minmax) { - blendEquations.min = GL_MIN_EXT; - blendEquations.max = GL_MAX_EXT; +function parseExtensions (input) { + if (typeof input === 'string') { + return input.split() } + check$1(Array.isArray(input), 'invalid extension array') + return input +} - var extInstancing = extensions.angle_instanced_arrays; - var extDrawBuffers = extensions.webgl_draw_buffers; - - // =================================================== - // =================================================== - // WEBGL STATE - // =================================================== - // =================================================== - var currentState = { - dirty: true, - profile: config.profile - }; - var nextState = {}; - var GL_STATE_NAMES = []; - var GL_FLAGS = {}; - var GL_VARIABLES = {}; - - function propName (name) { - return name.replace('.', '_') +function getElement (desc) { + if (typeof desc === 'string') { + check$1(typeof document !== 'undefined', 'not supported outside of DOM') + return document.querySelector(desc) } + return desc +} - function stateFlag (sname, cap, init) { - var name = propName(sname); - GL_STATE_NAMES.push(sname); - nextState[name] = currentState[name] = !!init; - GL_FLAGS[name] = cap; +function parseArgs (args_) { + var args = args_ || {} + var element, container, canvas, gl + var contextAttributes = {} + var extensions = [] + var optionalExtensions = [] + var pixelRatio = (typeof window === 'undefined' ? 1 : window.devicePixelRatio) + var profile = false + var onDone = function (err) { + if (err) { + check$1.raise(err) + } + } + var onDestroy = function () {} + if (typeof args === 'string') { + check$1( + typeof document !== 'undefined', + 'selector queries only supported in DOM enviroments') + element = document.querySelector(args) + check$1(element, 'invalid query string for element') + } else if (typeof args === 'object') { + if (isHTMLElement(args)) { + element = args + } else if (isWebGLContext(args)) { + gl = args + canvas = gl.canvas + } else { + check$1.constructor(args) + if ('gl' in args) { + gl = args.gl + } else if ('canvas' in args) { + canvas = getElement(args.canvas) + } else if ('container' in args) { + container = getElement(args.container) + } + if ('attributes' in args) { + contextAttributes = args.attributes + check$1.type(contextAttributes, 'object', 'invalid context attributes') + } + if ('extensions' in args) { + extensions = parseExtensions(args.extensions) + } + if ('optionalExtensions' in args) { + optionalExtensions = parseExtensions(args.optionalExtensions) + } + if ('onDone' in args) { + check$1.type( + args.onDone, 'function', + 'invalid or missing onDone callback') + onDone = args.onDone + } + if ('profile' in args) { + profile = !!args.profile + } + if ('pixelRatio' in args) { + pixelRatio = +args.pixelRatio + check$1(pixelRatio > 0, 'invalid pixel ratio') + } + } + } else { + check$1.raise('invalid arguments to regl') } - function stateVariable (sname, func, init) { - var name = propName(sname); - GL_STATE_NAMES.push(sname); - if (Array.isArray(init)) { - currentState[name] = init.slice(); - nextState[name] = init.slice(); + if (element) { + if (element.nodeName.toLowerCase() === 'canvas') { + canvas = element } else { - currentState[name] = nextState[name] = init; + container = element } - GL_VARIABLES[name] = func; } - // Dithering - stateFlag(S_DITHER, GL_DITHER); + if (!gl) { + if (!canvas) { + check$1( + typeof document !== 'undefined', + 'must manually specify webgl context outside of DOM environments') + var result = createCanvas(container || document.body, onDone, pixelRatio) + if (!result) { + return null + } + canvas = result.canvas + onDestroy = result.onDestroy + } + // workaround for chromium bug, premultiplied alpha value is platform dependent + if (contextAttributes.premultipliedAlpha === undefined) contextAttributes.premultipliedAlpha = true + gl = createContext(canvas, contextAttributes) + } - // Blending - stateFlag(S_BLEND_ENABLE, GL_BLEND); - stateVariable(S_BLEND_COLOR, 'blendColor', [0, 0, 0, 0]); - stateVariable(S_BLEND_EQUATION, 'blendEquationSeparate', - [GL_FUNC_ADD, GL_FUNC_ADD]); - stateVariable(S_BLEND_FUNC, 'blendFuncSeparate', - [GL_ONE, GL_ZERO, GL_ONE, GL_ZERO]); + if (!gl) { + onDestroy() + onDone('webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org') + return null + } - // Depth - stateFlag(S_DEPTH_ENABLE, GL_DEPTH_TEST, true); - stateVariable(S_DEPTH_FUNC, 'depthFunc', GL_LESS); - stateVariable(S_DEPTH_RANGE, 'depthRange', [0, 1]); - stateVariable(S_DEPTH_MASK, 'depthMask', true); + return { + gl: gl, + canvas: canvas, + container: container, + extensions: extensions, + optionalExtensions: optionalExtensions, + pixelRatio: pixelRatio, + profile: profile, + onDone: onDone, + onDestroy: onDestroy + } +} - // Color mask - stateVariable(S_COLOR_MASK, S_COLOR_MASK, [true, true, true, true]); +function createExtensionCache (gl, config) { + var extensions = {} - // Face culling - stateFlag(S_CULL_ENABLE, GL_CULL_FACE); - stateVariable(S_CULL_FACE, 'cullFace', GL_BACK); + function tryLoadExtension (name_) { + check$1.type(name_, 'string', 'extension name must be string') + var name = name_.toLowerCase() + var ext + try { + ext = extensions[name] = gl.getExtension(name) + } catch (e) {} + return !!ext + } - // Front face orientation - stateVariable(S_FRONT_FACE, S_FRONT_FACE, GL_CCW); + for (var i = 0; i < config.extensions.length; ++i) { + var name = config.extensions[i] + if (!tryLoadExtension(name)) { + config.onDestroy() + config.onDone('"' + name + '" extension is not supported by the current WebGL context, try upgrading your system or a different browser') + return null + } + } - // Line width - stateVariable(S_LINE_WIDTH, S_LINE_WIDTH, 1); + config.optionalExtensions.forEach(tryLoadExtension) - // Polygon offset - stateFlag(S_POLYGON_OFFSET_ENABLE, GL_POLYGON_OFFSET_FILL); - stateVariable(S_POLYGON_OFFSET_OFFSET, 'polygonOffset', [0, 0]); + return { + extensions: extensions, + restore: function () { + Object.keys(extensions).forEach(function (name) { + if (extensions[name] && !tryLoadExtension(name)) { + throw new Error('(regl): error restoring extension ' + name) + } + }) + } + } +} - // Sample coverage - stateFlag(S_SAMPLE_ALPHA, GL_SAMPLE_ALPHA_TO_COVERAGE); - stateFlag(S_SAMPLE_ENABLE, GL_SAMPLE_COVERAGE); - stateVariable(S_SAMPLE_COVERAGE, 'sampleCoverage', [1, false]); +function loop (n, f) { + var result = Array(n) + for (var i = 0; i < n; ++i) { + result[i] = f(i) + } + return result +} - // Stencil - stateFlag(S_STENCIL_ENABLE, GL_STENCIL_TEST); - stateVariable(S_STENCIL_MASK, 'stencilMask', -1); - stateVariable(S_STENCIL_FUNC, 'stencilFunc', [GL_ALWAYS, 0, -1]); - stateVariable(S_STENCIL_OPFRONT, 'stencilOpSeparate', - [GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP]); - stateVariable(S_STENCIL_OPBACK, 'stencilOpSeparate', - [GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP]); +var GL_BYTE$1 = 5120 +var GL_UNSIGNED_BYTE$2 = 5121 +var GL_SHORT$1 = 5122 +var GL_UNSIGNED_SHORT$1 = 5123 +var GL_INT$1 = 5124 +var GL_UNSIGNED_INT$1 = 5125 +var GL_FLOAT$2 = 5126 - // Scissor - stateFlag(S_SCISSOR_ENABLE, GL_SCISSOR_TEST); - stateVariable(S_SCISSOR_BOX, 'scissor', - [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]); +function nextPow16 (v) { + for (var i = 16; i <= (1 << 28); i *= 16) { + if (v <= i) { + return i + } + } + return 0 +} - // Viewport - stateVariable(S_VIEWPORT, S_VIEWPORT, - [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]); +function log2 (v) { + var r, shift + r = (v > 0xFFFF) << 4 + v >>>= r + shift = (v > 0xFF) << 3 + v >>>= shift; r |= shift + shift = (v > 0xF) << 2 + v >>>= shift; r |= shift + shift = (v > 0x3) << 1 + v >>>= shift; r |= shift + return r | (v >> 1) +} - // =================================================== - // =================================================== - // ENVIRONMENT - // =================================================== - // =================================================== - var sharedState = { - gl: gl, - context: contextState, - strings: stringStore, - next: nextState, - current: currentState, - draw: drawState, - elements: elementState, - buffer: bufferState, - shader: shaderState, - attributes: attributeState.state, - uniforms: uniformState, - framebuffer: framebufferState, - extensions: extensions, +function createPool () { + var bufferPool = loop(8, function () { + return [] + }) - timer: timer, - isBufferArgs: isBufferArgs - }; + function alloc (n) { + var sz = nextPow16(n) + var bin = bufferPool[log2(sz) >> 2] + if (bin.length > 0) { + return bin.pop() + } + return new ArrayBuffer(sz) + } - var sharedConstants = { - primTypes: primTypes, - compareFuncs: compareFuncs, - blendFuncs: blendFuncs, - blendEquations: blendEquations, - stencilOps: stencilOps, - glTypes: glTypes, - orientationType: orientationType - }; + function free (buf) { + bufferPool[log2(buf.byteLength) >> 2].push(buf) + } - check$1.optional(function () { - sharedState.isArrayLike = isArrayLike; - }); + function allocType (type, n) { + var result = null + switch (type) { + case GL_BYTE$1: + result = new Int8Array(alloc(n), 0, n) + break + case GL_UNSIGNED_BYTE$2: + result = new Uint8Array(alloc(n), 0, n) + break + case GL_SHORT$1: + result = new Int16Array(alloc(2 * n), 0, n) + break + case GL_UNSIGNED_SHORT$1: + result = new Uint16Array(alloc(2 * n), 0, n) + break + case GL_INT$1: + result = new Int32Array(alloc(4 * n), 0, n) + break + case GL_UNSIGNED_INT$1: + result = new Uint32Array(alloc(4 * n), 0, n) + break + case GL_FLOAT$2: + result = new Float32Array(alloc(4 * n), 0, n) + break + default: + return null + } + if (result.length !== n) { + return result.subarray(0, n) + } + return result + } - if (extDrawBuffers) { - sharedConstants.backBuffer = [GL_BACK]; - sharedConstants.drawBuffer = loop(limits.maxDrawbuffers, function (i) { - if (i === 0) { - return [0] - } - return loop(i, function (j) { - return GL_COLOR_ATTACHMENT0$1 + j - }) - }); + function freeType (array) { + free(array.buffer) } - var drawCallCounter = 0; - function createREGLEnvironment () { - var env = createEnvironment(); - var link = env.link; - var global = env.global; - env.id = drawCallCounter++; + return { + alloc: alloc, + free: free, + allocType: allocType, + freeType: freeType + } +} - env.batchId = '0'; +var pool = createPool() + +// zero pool for initial zero data +pool.zero = createPool() + +var GL_SUBPIXEL_BITS = 0x0D50 +var GL_RED_BITS = 0x0D52 +var GL_GREEN_BITS = 0x0D53 +var GL_BLUE_BITS = 0x0D54 +var GL_ALPHA_BITS = 0x0D55 +var GL_DEPTH_BITS = 0x0D56 +var GL_STENCIL_BITS = 0x0D57 + +var GL_ALIASED_POINT_SIZE_RANGE = 0x846D +var GL_ALIASED_LINE_WIDTH_RANGE = 0x846E + +var GL_MAX_TEXTURE_SIZE = 0x0D33 +var GL_MAX_VIEWPORT_DIMS = 0x0D3A +var GL_MAX_VERTEX_ATTRIBS = 0x8869 +var GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB +var GL_MAX_VARYING_VECTORS = 0x8DFC +var GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D +var GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C +var GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872 +var GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD +var GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C +var GL_MAX_RENDERBUFFER_SIZE = 0x84E8 + +var GL_VENDOR = 0x1F00 +var GL_RENDERER = 0x1F01 +var GL_VERSION = 0x1F02 +var GL_SHADING_LANGUAGE_VERSION = 0x8B8C + +var GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF + +var GL_MAX_COLOR_ATTACHMENTS_WEBGL = 0x8CDF +var GL_MAX_DRAW_BUFFERS_WEBGL = 0x8824 + +var GL_TEXTURE_2D = 0x0DE1 +var GL_TEXTURE_CUBE_MAP = 0x8513 +var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515 +var GL_TEXTURE0 = 0x84C0 +var GL_RGBA = 0x1908 +var GL_FLOAT$1 = 0x1406 +var GL_UNSIGNED_BYTE$1 = 0x1401 +var GL_FRAMEBUFFER = 0x8D40 +var GL_FRAMEBUFFER_COMPLETE = 0x8CD5 +var GL_COLOR_ATTACHMENT0 = 0x8CE0 +var GL_COLOR_BUFFER_BIT$1 = 0x4000 - // link shared state - var SHARED = link(sharedState); - var shared = env.shared = { - props: 'a0' - }; - Object.keys(sharedState).forEach(function (prop) { - shared[prop] = global.def(SHARED, '.', prop); - }); +var wrapLimits = function (gl, extensions) { + var maxAnisotropic = 1 + if (extensions.ext_texture_filter_anisotropic) { + maxAnisotropic = gl.getParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) + } - // Inject runtime assertion stuff for debug builds - check$1.optional(function () { - env.CHECK = link(check$1); - env.commandStr = check$1.guessCommand(); - env.command = link(env.commandStr); - env.assert = function (block, pred, message) { - block( - 'if(!(', pred, '))', - this.CHECK, '.commandRaise(', link(message), ',', this.command, ');'); - }; + var maxDrawbuffers = 1 + var maxColorAttachments = 1 + if (extensions.webgl_draw_buffers) { + maxDrawbuffers = gl.getParameter(GL_MAX_DRAW_BUFFERS_WEBGL) + maxColorAttachments = gl.getParameter(GL_MAX_COLOR_ATTACHMENTS_WEBGL) + } - sharedConstants.invalidBlendCombinations = invalidBlendCombinations; - }); + // detect if reading float textures is available (Safari doesn't support) + var readFloat = !!extensions.oes_texture_float + if (readFloat) { + var readFloatTexture = gl.createTexture() + gl.bindTexture(GL_TEXTURE_2D, readFloatTexture) + gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_FLOAT$1, null) - // Copy GL state variables over - var nextVars = env.next = {}; - var currentVars = env.current = {}; - Object.keys(GL_VARIABLES).forEach(function (variable) { - if (Array.isArray(currentState[variable])) { - nextVars[variable] = global.def(shared.next, '.', variable); - currentVars[variable] = global.def(shared.current, '.', variable); - } - }); + var fbo = gl.createFramebuffer() + gl.bindFramebuffer(GL_FRAMEBUFFER, fbo) + gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, readFloatTexture, 0) + gl.bindTexture(GL_TEXTURE_2D, null) - // Initialize shared constants - var constants = env.constants = {}; - Object.keys(sharedConstants).forEach(function (name) { - constants[name] = global.def(JSON.stringify(sharedConstants[name])); - }); + if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) !== GL_FRAMEBUFFER_COMPLETE) readFloat = false - // Helper function for calling a block - env.invoke = function (block, x) { - switch (x.type) { - case DYN_FUNC$1: - var argList = [ - 'this', - shared.context, - shared.props, - env.batchId - ]; - return block.def( - link(x.data), '.call(', - argList.slice(0, Math.max(x.data.length + 1, 4)), - ')') - case DYN_PROP$1: - return block.def(shared.props, x.data) - case DYN_CONTEXT$1: - return block.def(shared.context, x.data) - case DYN_STATE$1: - return block.def('this', x.data) - case DYN_THUNK: - x.data.append(env, block); - return x.data.ref - } - }; + else { + gl.viewport(0, 0, 1, 1) + gl.clearColor(1.0, 0.0, 0.0, 1.0) + gl.clear(GL_COLOR_BUFFER_BIT$1) + var pixels = pool.allocType(GL_FLOAT$1, 4) + gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT$1, pixels) - env.attribCache = {}; + if (gl.getError()) readFloat = false + else { + gl.deleteFramebuffer(fbo) + gl.deleteTexture(readFloatTexture) - var scopeAttribs = {}; - env.scopeAttrib = function (name) { - var id = stringStore.id(name); - if (id in scopeAttribs) { - return scopeAttribs[id] + readFloat = pixels[0] === 1.0 } - var binding = attributeState.scope[id]; - if (!binding) { - binding = attributeState.scope[id] = new AttributeRecord(); - } - var result = scopeAttribs[id] = link(binding); - return result - }; - return env + pool.freeType(pixels) + } } - // =================================================== - // =================================================== - // PARSING - // =================================================== - // =================================================== - function parseProfile (options) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; + // detect non power of two cube textures support (IE doesn't support) + var isIE = typeof navigator !== 'undefined' && (/MSIE/.test(navigator.userAgent) || /Trident\//.test(navigator.appVersion) || /Edge/.test(navigator.userAgent)) - var profileEnable; - if (S_PROFILE in staticOptions) { - var value = !!staticOptions[S_PROFILE]; - profileEnable = createStaticDecl(function (env, scope) { - return value - }); - profileEnable.enable = value; - } else if (S_PROFILE in dynamicOptions) { - var dyn = dynamicOptions[S_PROFILE]; - profileEnable = createDynamicDecl(dyn, function (env, scope) { - return env.invoke(scope, dyn) - }); - } + var npotTextureCube = true - return profileEnable + if (!isIE) { + var cubeTexture = gl.createTexture() + var data = pool.allocType(GL_UNSIGNED_BYTE$1, 36) + gl.activeTexture(GL_TEXTURE0) + gl.bindTexture(GL_TEXTURE_CUBE_MAP, cubeTexture) + gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE$1, data) + pool.freeType(data) + gl.bindTexture(GL_TEXTURE_CUBE_MAP, null) + gl.deleteTexture(cubeTexture) + npotTextureCube = !gl.getError() } - function parseFramebuffer (options, env) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; - - if (S_FRAMEBUFFER in staticOptions) { - var framebuffer = staticOptions[S_FRAMEBUFFER]; - if (framebuffer) { - framebuffer = framebufferState.getFramebuffer(framebuffer); - check$1.command(framebuffer, 'invalid framebuffer object'); - return createStaticDecl(function (env, block) { - var FRAMEBUFFER = env.link(framebuffer); - var shared = env.shared; - block.set( - shared.framebuffer, - '.next', - FRAMEBUFFER); - var CONTEXT = shared.context; - block.set( - CONTEXT, - '.' + S_FRAMEBUFFER_WIDTH, - FRAMEBUFFER + '.width'); - block.set( - CONTEXT, - '.' + S_FRAMEBUFFER_HEIGHT, - FRAMEBUFFER + '.height'); - return FRAMEBUFFER - }) - } else { - return createStaticDecl(function (env, scope) { - var shared = env.shared; - scope.set( - shared.framebuffer, - '.next', - 'null'); - var CONTEXT = shared.context; - scope.set( - CONTEXT, - '.' + S_FRAMEBUFFER_WIDTH, - CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH); - scope.set( - CONTEXT, - '.' + S_FRAMEBUFFER_HEIGHT, - CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT); - return 'null' - }) - } - } else if (S_FRAMEBUFFER in dynamicOptions) { - var dyn = dynamicOptions[S_FRAMEBUFFER]; - return createDynamicDecl(dyn, function (env, scope) { - var FRAMEBUFFER_FUNC = env.invoke(scope, dyn); - var shared = env.shared; - var FRAMEBUFFER_STATE = shared.framebuffer; - var FRAMEBUFFER = scope.def( - FRAMEBUFFER_STATE, '.getFramebuffer(', FRAMEBUFFER_FUNC, ')'); - - check$1.optional(function () { - env.assert(scope, - '!' + FRAMEBUFFER_FUNC + '||' + FRAMEBUFFER, - 'invalid framebuffer object'); - }); + return { + // drawing buffer bit depth + colorBits: [ + gl.getParameter(GL_RED_BITS), + gl.getParameter(GL_GREEN_BITS), + gl.getParameter(GL_BLUE_BITS), + gl.getParameter(GL_ALPHA_BITS) + ], + depthBits: gl.getParameter(GL_DEPTH_BITS), + stencilBits: gl.getParameter(GL_STENCIL_BITS), + subpixelBits: gl.getParameter(GL_SUBPIXEL_BITS), - scope.set( - FRAMEBUFFER_STATE, - '.next', - FRAMEBUFFER); - var CONTEXT = shared.context; - scope.set( - CONTEXT, - '.' + S_FRAMEBUFFER_WIDTH, - FRAMEBUFFER + '?' + FRAMEBUFFER + '.width:' + - CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH); - scope.set( - CONTEXT, - '.' + S_FRAMEBUFFER_HEIGHT, - FRAMEBUFFER + - '?' + FRAMEBUFFER + '.height:' + - CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT); - return FRAMEBUFFER - }) - } else { - return null - } - } + // supported extensions + extensions: Object.keys(extensions).filter(function (ext) { + return !!extensions[ext] + }), - function parseViewportScissor (options, framebuffer, env) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; + // max aniso samples + maxAnisotropic: maxAnisotropic, - function parseBox (param) { - if (param in staticOptions) { - var box = staticOptions[param]; - check$1.commandType(box, 'object', 'invalid ' + param, env.commandStr); + // max draw buffers + maxDrawbuffers: maxDrawbuffers, + maxColorAttachments: maxColorAttachments, - var isStatic = true; - var x = box.x | 0; - var y = box.y | 0; - var w, h; - if ('width' in box) { - w = box.width | 0; - check$1.command(w >= 0, 'invalid ' + param, env.commandStr); - } else { - isStatic = false; - } - if ('height' in box) { - h = box.height | 0; - check$1.command(h >= 0, 'invalid ' + param, env.commandStr); - } else { - isStatic = false; - } + // point and line size ranges + pointSizeDims: gl.getParameter(GL_ALIASED_POINT_SIZE_RANGE), + lineWidthDims: gl.getParameter(GL_ALIASED_LINE_WIDTH_RANGE), + maxViewportDims: gl.getParameter(GL_MAX_VIEWPORT_DIMS), + maxCombinedTextureUnits: gl.getParameter(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS), + maxCubeMapSize: gl.getParameter(GL_MAX_CUBE_MAP_TEXTURE_SIZE), + maxRenderbufferSize: gl.getParameter(GL_MAX_RENDERBUFFER_SIZE), + maxTextureUnits: gl.getParameter(GL_MAX_TEXTURE_IMAGE_UNITS), + maxTextureSize: gl.getParameter(GL_MAX_TEXTURE_SIZE), + maxAttributes: gl.getParameter(GL_MAX_VERTEX_ATTRIBS), + maxVertexUniforms: gl.getParameter(GL_MAX_VERTEX_UNIFORM_VECTORS), + maxVertexTextureUnits: gl.getParameter(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS), + maxVaryingVectors: gl.getParameter(GL_MAX_VARYING_VECTORS), + maxFragmentUniforms: gl.getParameter(GL_MAX_FRAGMENT_UNIFORM_VECTORS), - return new Declaration( - !isStatic && framebuffer && framebuffer.thisDep, - !isStatic && framebuffer && framebuffer.contextDep, - !isStatic && framebuffer && framebuffer.propDep, - function (env, scope) { - var CONTEXT = env.shared.context; - var BOX_W = w; - if (!('width' in box)) { - BOX_W = scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', x); - } - var BOX_H = h; - if (!('height' in box)) { - BOX_H = scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', y); - } - return [x, y, BOX_W, BOX_H] - }) - } else if (param in dynamicOptions) { - var dynBox = dynamicOptions[param]; - var result = createDynamicDecl(dynBox, function (env, scope) { - var BOX = env.invoke(scope, dynBox); + // vendor info + glsl: gl.getParameter(GL_SHADING_LANGUAGE_VERSION), + renderer: gl.getParameter(GL_RENDERER), + vendor: gl.getParameter(GL_VENDOR), + version: gl.getParameter(GL_VERSION), - check$1.optional(function () { - env.assert(scope, - BOX + '&&typeof ' + BOX + '==="object"', - 'invalid ' + param); - }); + // quirks + readFloat: readFloat, + npotTextureCube: npotTextureCube + } +} - var CONTEXT = env.shared.context; - var BOX_X = scope.def(BOX, '.x|0'); - var BOX_Y = scope.def(BOX, '.y|0'); - var BOX_W = scope.def( - '"width" in ', BOX, '?', BOX, '.width|0:', - '(', CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', BOX_X, ')'); - var BOX_H = scope.def( - '"height" in ', BOX, '?', BOX, '.height|0:', - '(', CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', BOX_Y, ')'); +function isNDArrayLike (obj) { + return ( + !!obj && + typeof obj === 'object' && + Array.isArray(obj.shape) && + Array.isArray(obj.stride) && + typeof obj.offset === 'number' && + obj.shape.length === obj.stride.length && + (Array.isArray(obj.data) || + isTypedArray(obj.data))) +} - check$1.optional(function () { - env.assert(scope, - BOX_W + '>=0&&' + - BOX_H + '>=0', - 'invalid ' + param); - }); +var values = function (obj) { + return Object.keys(obj).map(function (key) { return obj[key] }) +} - return [BOX_X, BOX_Y, BOX_W, BOX_H] - }); - if (framebuffer) { - result.thisDep = result.thisDep || framebuffer.thisDep; - result.contextDep = result.contextDep || framebuffer.contextDep; - result.propDep = result.propDep || framebuffer.propDep; - } - return result - } else if (framebuffer) { - return new Declaration( - framebuffer.thisDep, - framebuffer.contextDep, - framebuffer.propDep, - function (env, scope) { - var CONTEXT = env.shared.context; - return [ - 0, 0, - scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH), - scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT)] - }) - } else { - return null - } - } +var flattenUtils = { + shape: arrayShape$1, + flatten: flattenArray +}; - var viewport = parseBox(S_VIEWPORT); +function flatten1D (array, nx, out) { + for (var i = 0; i < nx; ++i) { + out[i] = array[i] + } +} - if (viewport) { - var prevViewport = viewport; - viewport = new Declaration( - viewport.thisDep, - viewport.contextDep, - viewport.propDep, - function (env, scope) { - var VIEWPORT = prevViewport.append(env, scope); - var CONTEXT = env.shared.context; - scope.set( - CONTEXT, - '.' + S_VIEWPORT_WIDTH, - VIEWPORT[2]); - scope.set( - CONTEXT, - '.' + S_VIEWPORT_HEIGHT, - VIEWPORT[3]); - return VIEWPORT - }); +function flatten2D (array, nx, ny, out) { + var ptr = 0 + for (var i = 0; i < nx; ++i) { + var row = array[i] + for (var j = 0; j < ny; ++j) { + out[ptr++] = row[j] } + } +} - return { - viewport: viewport, - scissor_box: parseBox(S_SCISSOR_BOX) +function flatten3D (array, nx, ny, nz, out, ptr_) { + var ptr = ptr_ + for (var i = 0; i < nx; ++i) { + var row = array[i] + for (var j = 0; j < ny; ++j) { + var col = row[j] + for (var k = 0; k < nz; ++k) { + out[ptr++] = col[k] + } } } +} - function parseProgram (options) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; - - function parseShader (name) { - if (name in staticOptions) { - var id = stringStore.id(staticOptions[name]); - check$1.optional(function () { - shaderState.shader(shaderType[name], id, check$1.guessCommand()); - }); - var result = createStaticDecl(function () { - return id - }); - result.id = id; - return result - } else if (name in dynamicOptions) { - var dyn = dynamicOptions[name]; - return createDynamicDecl(dyn, function (env, scope) { - var str = env.invoke(scope, dyn); - var id = scope.def(env.shared.strings, '.id(', str, ')'); - check$1.optional(function () { - scope( - env.shared.shader, '.shader(', - shaderType[name], ',', - id, ',', - env.command, ');'); - }); - return id - }) - } - return null +function flattenRec (array, shape, level, out, ptr) { + var stride = 1 + for (var i = level + 1; i < shape.length; ++i) { + stride *= shape[i] + } + var n = shape[level] + if (shape.length - level === 4) { + var nx = shape[level + 1] + var ny = shape[level + 2] + var nz = shape[level + 3] + for (i = 0; i < n; ++i) { + flatten3D(array[i], nx, ny, nz, out, ptr) + ptr += stride } - - var frag = parseShader(S_FRAG); - var vert = parseShader(S_VERT); - - var program = null; - var progVar; - if (isStatic(frag) && isStatic(vert)) { - program = shaderState.program(vert.id, frag.id); - progVar = createStaticDecl(function (env, scope) { - return env.link(program) - }); - } else { - progVar = new Declaration( - (frag && frag.thisDep) || (vert && vert.thisDep), - (frag && frag.contextDep) || (vert && vert.contextDep), - (frag && frag.propDep) || (vert && vert.propDep), - function (env, scope) { - var SHADER_STATE = env.shared.shader; - var fragId; - if (frag) { - fragId = frag.append(env, scope); - } else { - fragId = scope.def(SHADER_STATE, '.', S_FRAG); - } - var vertId; - if (vert) { - vertId = vert.append(env, scope); - } else { - vertId = scope.def(SHADER_STATE, '.', S_VERT); - } - var progDef = SHADER_STATE + '.program(' + vertId + ',' + fragId; - check$1.optional(function () { - progDef += ',' + env.command; - }); - return scope.def(progDef + ')') - }); + } else { + for (i = 0; i < n; ++i) { + flattenRec(array[i], shape, level + 1, out, ptr) + ptr += stride } + } +} - return { - frag: frag, - vert: vert, - progVar: progVar, - program: program +function flattenArray (array, shape, type, out_) { + var sz = 1 + if (shape.length) { + for (var i = 0; i < shape.length; ++i) { + sz *= shape[i] } + } else { + sz = 0 } + var out = out_ || pool.allocType(type, sz) + switch (shape.length) { + case 0: + break + case 1: + flatten1D(array, shape[0], out) + break + case 2: + flatten2D(array, shape[0], shape[1], out) + break + case 3: + flatten3D(array, shape[0], shape[1], shape[2], out, 0) + break + default: + flattenRec(array, shape, 0, out, 0) + } + return out +} - function parseDraw (options, env) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; +function arrayShape$1 (array_) { + var shape = [] + for (var array = array_; array.length; array = array[0]) { + shape.push(array.length) + } + return shape +} - function parseElements () { - if (S_ELEMENTS in staticOptions) { - var elements = staticOptions[S_ELEMENTS]; - if (isBufferArgs(elements)) { - elements = elementState.getElements(elementState.create(elements, true)); - } else if (elements) { - elements = elementState.getElements(elements); - check$1.command(elements, 'invalid elements', env.commandStr); - } - var result = createStaticDecl(function (env, scope) { - if (elements) { - var result = env.link(elements); - env.ELEMENTS = result; - return result - } - env.ELEMENTS = null; - return null - }); - result.value = elements; - return result - } else if (S_ELEMENTS in dynamicOptions) { - var dyn = dynamicOptions[S_ELEMENTS]; - return createDynamicDecl(dyn, function (env, scope) { - var shared = env.shared; +var arrayTypes = { + "[object Int8Array]": 5120, + "[object Int16Array]": 5122, + "[object Int32Array]": 5124, + "[object Uint8Array]": 5121, + "[object Uint8ClampedArray]": 5121, + "[object Uint16Array]": 5123, + "[object Uint32Array]": 5125, + "[object Float32Array]": 5126, + "[object Float64Array]": 5121, + "[object ArrayBuffer]": 5121 +}; + +var int8 = 5120; +var int16 = 5122; +var int32 = 5124; +var uint8 = 5121; +var uint16 = 5123; +var uint32 = 5125; +var float = 5126; +var float32 = 5126; +var glTypes = { + int8: int8, + int16: int16, + int32: int32, + uint8: uint8, + uint16: uint16, + uint32: uint32, + float: float, + float32: float32 +}; - var IS_BUFFER_ARGS = shared.isBufferArgs; - var ELEMENT_STATE = shared.elements; +var dynamic$1 = 35048; +var stream = 35040; +var usageTypes = { + dynamic: dynamic$1, + stream: stream, + "static": 35044 +}; - var elementDefn = env.invoke(scope, dyn); - var elements = scope.def('null'); - var elementStream = scope.def(IS_BUFFER_ARGS, '(', elementDefn, ')'); +var arrayFlatten = flattenUtils.flatten +var arrayShape = flattenUtils.shape - var ifte = env.cond(elementStream) - .then(elements, '=', ELEMENT_STATE, '.createStream(', elementDefn, ');') - .else(elements, '=', ELEMENT_STATE, '.getElements(', elementDefn, ');'); +var GL_STATIC_DRAW = 0x88E4 +var GL_STREAM_DRAW = 0x88E0 - check$1.optional(function () { - env.assert(ifte.else, - '!' + elementDefn + '||' + elements, - 'invalid elements'); - }); +var GL_UNSIGNED_BYTE$3 = 5121 +var GL_FLOAT$3 = 5126 - scope.entry(ifte); - scope.exit( - env.cond(elementStream) - .then(ELEMENT_STATE, '.destroyStream(', elements, ');')); +var DTYPES_SIZES = [] +DTYPES_SIZES[5120] = 1 // int8 +DTYPES_SIZES[5122] = 2 // int16 +DTYPES_SIZES[5124] = 4 // int32 +DTYPES_SIZES[5121] = 1 // uint8 +DTYPES_SIZES[5123] = 2 // uint16 +DTYPES_SIZES[5125] = 4 // uint32 +DTYPES_SIZES[5126] = 4 // float32 - env.ELEMENTS = elements; +function typedArrayCode (data) { + return arrayTypes[Object.prototype.toString.call(data)] | 0 +} - return elements - }) - } +function copyArray (out, inp) { + for (var i = 0; i < inp.length; ++i) { + out[i] = inp[i] + } +} - return null +function transpose ( + result, data, shapeX, shapeY, strideX, strideY, offset) { + var ptr = 0 + for (var i = 0; i < shapeX; ++i) { + for (var j = 0; j < shapeY; ++j) { + result[ptr++] = data[strideX * i + strideY * j + offset] } + } +} - var elements = parseElements(); +function wrapBufferState (gl, stats, config, destroyBuffer) { + var bufferCount = 0 + var bufferSet = {} - function parsePrimitive () { - if (S_PRIMITIVE in staticOptions) { - var primitive = staticOptions[S_PRIMITIVE]; - check$1.commandParameter(primitive, primTypes, 'invalid primitve', env.commandStr); - return createStaticDecl(function (env, scope) { - return primTypes[primitive] - }) - } else if (S_PRIMITIVE in dynamicOptions) { - var dynPrimitive = dynamicOptions[S_PRIMITIVE]; - return createDynamicDecl(dynPrimitive, function (env, scope) { - var PRIM_TYPES = env.constants.primTypes; - var prim = env.invoke(scope, dynPrimitive); - check$1.optional(function () { - env.assert(scope, - prim + ' in ' + PRIM_TYPES, - 'invalid primitive, must be one of ' + Object.keys(primTypes)); - }); - return scope.def(PRIM_TYPES, '[', prim, ']') - }) - } else if (elements) { - if (isStatic(elements)) { - if (elements.value) { - return createStaticDecl(function (env, scope) { - return scope.def(env.ELEMENTS, '.primType') - }) - } else { - return createStaticDecl(function () { - return GL_TRIANGLES$1 - }) - } - } else { - return new Declaration( - elements.thisDep, - elements.contextDep, - elements.propDep, - function (env, scope) { - var elements = env.ELEMENTS; - return scope.def(elements, '?', elements, '.primType:', GL_TRIANGLES$1) - }) - } - } - return null - } + function REGLBuffer (type) { + this.id = bufferCount++ + this.buffer = gl.createBuffer() + this.type = type + this.usage = GL_STATIC_DRAW + this.byteLength = 0 + this.dimension = 1 + this.dtype = GL_UNSIGNED_BYTE$3 - function parseParam (param, isOffset) { - if (param in staticOptions) { - var value = staticOptions[param] | 0; - check$1.command(!isOffset || value >= 0, 'invalid ' + param, env.commandStr); - return createStaticDecl(function (env, scope) { - if (isOffset) { - env.OFFSET = value; - } - return value - }) - } else if (param in dynamicOptions) { - var dynValue = dynamicOptions[param]; - return createDynamicDecl(dynValue, function (env, scope) { - var result = env.invoke(scope, dynValue); - if (isOffset) { - env.OFFSET = result; - check$1.optional(function () { - env.assert(scope, - result + '>=0', - 'invalid ' + param); - }); - } - return result - }) - } else if (isOffset && elements) { - return createStaticDecl(function (env, scope) { - env.OFFSET = '0'; - return 0 - }) - } - return null + this.persistentData = null + + if (config.profile) { + this.stats = { size: 0 } } + } + + REGLBuffer.prototype.bind = function () { + gl.bindBuffer(this.type, this.buffer) + } - var OFFSET = parseParam(S_OFFSET, true); + REGLBuffer.prototype.destroy = function () { + destroy(this) + } - function parseVertCount () { - if (S_COUNT in staticOptions) { - var count = staticOptions[S_COUNT] | 0; - check$1.command( - typeof count === 'number' && count >= 0, 'invalid vertex count', env.commandStr); - return createStaticDecl(function () { - return count - }) - } else if (S_COUNT in dynamicOptions) { - var dynCount = dynamicOptions[S_COUNT]; - return createDynamicDecl(dynCount, function (env, scope) { - var result = env.invoke(scope, dynCount); - check$1.optional(function () { - env.assert(scope, - 'typeof ' + result + '==="number"&&' + - result + '>=0&&' + - result + '===(' + result + '|0)', - 'invalid vertex count'); - }); - return result - }) - } else if (elements) { - if (isStatic(elements)) { - if (elements) { - if (OFFSET) { - return new Declaration( - OFFSET.thisDep, - OFFSET.contextDep, - OFFSET.propDep, - function (env, scope) { - var result = scope.def( - env.ELEMENTS, '.vertCount-', env.OFFSET); + var streamPool = [] + + function createStream (type, data) { + var buffer = streamPool.pop() + if (!buffer) { + buffer = new REGLBuffer(type) + } + buffer.bind() + initBufferFromData(buffer, data, GL_STREAM_DRAW, 0, 1, false) + return buffer + } - check$1.optional(function () { - env.assert(scope, - result + '>=0', - 'invalid vertex offset/element buffer too small'); - }); + function destroyStream (stream$$1) { + streamPool.push(stream$$1) + } - return result - }) - } else { - return createStaticDecl(function (env, scope) { - return scope.def(env.ELEMENTS, '.vertCount') - }) - } + function initBufferFromTypedArray (buffer, data, usage) { + buffer.byteLength = data.byteLength + gl.bufferData(buffer.type, data, usage) + } + + function initBufferFromData (buffer, data, usage, dtype, dimension, persist) { + var shape + buffer.usage = usage + if (Array.isArray(data)) { + buffer.dtype = dtype || GL_FLOAT$3 + if (data.length > 0) { + var flatData + if (Array.isArray(data[0])) { + shape = arrayShape(data) + var dim = 1 + for (var i = 1; i < shape.length; ++i) { + dim *= shape[i] + } + buffer.dimension = dim + flatData = arrayFlatten(data, shape, buffer.dtype) + initBufferFromTypedArray(buffer, flatData, usage) + if (persist) { + buffer.persistentData = flatData } else { - var result = createStaticDecl(function () { - return -1 - }); - check$1.optional(function () { - result.MISSING = true; - }); - return result + pool.freeType(flatData) + } + } else if (typeof data[0] === 'number') { + buffer.dimension = dimension + var typedData = pool.allocType(buffer.dtype, data.length) + copyArray(typedData, data) + initBufferFromTypedArray(buffer, typedData, usage) + if (persist) { + buffer.persistentData = typedData + } else { + pool.freeType(typedData) + } + } else if (isTypedArray(data[0])) { + buffer.dimension = data[0].length + buffer.dtype = dtype || typedArrayCode(data[0]) || GL_FLOAT$3 + flatData = arrayFlatten( + data, + [data.length, data[0].length], + buffer.dtype) + initBufferFromTypedArray(buffer, flatData, usage) + if (persist) { + buffer.persistentData = flatData + } else { + pool.freeType(flatData) } } else { - var variable = new Declaration( - elements.thisDep || OFFSET.thisDep, - elements.contextDep || OFFSET.contextDep, - elements.propDep || OFFSET.propDep, - function (env, scope) { - var elements = env.ELEMENTS; - if (env.OFFSET) { - return scope.def(elements, '?', elements, '.vertCount-', - env.OFFSET, ':-1') - } - return scope.def(elements, '?', elements, '.vertCount:-1') - }); - check$1.optional(function () { - variable.DYNAMIC = true; - }); - return variable + check$1.raise('invalid buffer data') } } - return null - } + } else if (isTypedArray(data)) { + buffer.dtype = dtype || typedArrayCode(data) + buffer.dimension = dimension + initBufferFromTypedArray(buffer, data, usage) + if (persist) { + buffer.persistentData = new Uint8Array(new Uint8Array(data.buffer)) + } + } else if (isNDArrayLike(data)) { + shape = data.shape + var stride = data.stride + var offset = data.offset + + var shapeX = 0 + var shapeY = 0 + var strideX = 0 + var strideY = 0 + if (shape.length === 1) { + shapeX = shape[0] + shapeY = 1 + strideX = stride[0] + strideY = 0 + } else if (shape.length === 2) { + shapeX = shape[0] + shapeY = shape[1] + strideX = stride[0] + strideY = stride[1] + } else { + check$1.raise('invalid shape') + } - return { - elements: elements, - primitive: parsePrimitive(), - count: parseVertCount(), - instances: parseParam(S_INSTANCES, false), - offset: OFFSET + buffer.dtype = dtype || typedArrayCode(data.data) || GL_FLOAT$3 + buffer.dimension = shapeY + + var transposeData = pool.allocType(buffer.dtype, shapeX * shapeY) + transpose(transposeData, + data.data, + shapeX, shapeY, + strideX, strideY, + offset) + initBufferFromTypedArray(buffer, transposeData, usage) + if (persist) { + buffer.persistentData = transposeData + } else { + pool.freeType(transposeData) + } + } else if (data instanceof ArrayBuffer) { + buffer.dtype = GL_UNSIGNED_BYTE$3 + buffer.dimension = dimension + initBufferFromTypedArray(buffer, data, usage) + if (persist) { + buffer.persistentData = new Uint8Array(new Uint8Array(data)) + } + } else { + check$1.raise('invalid buffer data') } } - function parseGLState (options, env) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; - - var STATE = {}; - - GL_STATE_NAMES.forEach(function (prop) { - var param = propName(prop); - - function parseParam (parseStatic, parseDynamic) { - if (prop in staticOptions) { - var value = parseStatic(staticOptions[prop]); - STATE[param] = createStaticDecl(function () { - return value - }); - } else if (prop in dynamicOptions) { - var dyn = dynamicOptions[prop]; - STATE[param] = createDynamicDecl(dyn, function (env, scope) { - return parseDynamic(env, scope, env.invoke(scope, dyn)) - }); - } - } + function destroy (buffer) { + stats.bufferCount-- - switch (prop) { - case S_CULL_ENABLE: - case S_BLEND_ENABLE: - case S_DITHER: - case S_STENCIL_ENABLE: - case S_DEPTH_ENABLE: - case S_SCISSOR_ENABLE: - case S_POLYGON_OFFSET_ENABLE: - case S_SAMPLE_ALPHA: - case S_SAMPLE_ENABLE: - case S_DEPTH_MASK: - return parseParam( - function (value) { - check$1.commandType(value, 'boolean', prop, env.commandStr); - return value - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - 'typeof ' + value + '==="boolean"', - 'invalid flag ' + prop, env.commandStr); - }); - return value - }) + // remove attribute link + destroyBuffer(buffer) - case S_DEPTH_FUNC: - return parseParam( - function (value) { - check$1.commandParameter(value, compareFuncs, 'invalid ' + prop, env.commandStr); - return compareFuncs[value] - }, - function (env, scope, value) { - var COMPARE_FUNCS = env.constants.compareFuncs; - check$1.optional(function () { - env.assert(scope, - value + ' in ' + COMPARE_FUNCS, - 'invalid ' + prop + ', must be one of ' + Object.keys(compareFuncs)); - }); - return scope.def(COMPARE_FUNCS, '[', value, ']') - }) + var handle = buffer.buffer + check$1(handle, 'buffer must not be deleted already') + gl.deleteBuffer(handle) + buffer.buffer = null + delete bufferSet[buffer.id] + } - case S_DEPTH_RANGE: - return parseParam( - function (value) { - check$1.command( - isArrayLike(value) && - value.length === 2 && - typeof value[0] === 'number' && - typeof value[1] === 'number' && - value[0] <= value[1], - 'depth range is 2d array', - env.commandStr); - return value - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - env.shared.isArrayLike + '(' + value + ')&&' + - value + '.length===2&&' + - 'typeof ' + value + '[0]==="number"&&' + - 'typeof ' + value + '[1]==="number"&&' + - value + '[0]<=' + value + '[1]', - 'depth range must be a 2d array'); - }); + function createBuffer (options, type, deferInit, persistent) { + stats.bufferCount++ - var Z_NEAR = scope.def('+', value, '[0]'); - var Z_FAR = scope.def('+', value, '[1]'); - return [Z_NEAR, Z_FAR] - }) + var buffer = new REGLBuffer(type) + bufferSet[buffer.id] = buffer - case S_BLEND_FUNC: - return parseParam( - function (value) { - check$1.commandType(value, 'object', 'blend.func', env.commandStr); - var srcRGB = ('srcRGB' in value ? value.srcRGB : value.src); - var srcAlpha = ('srcAlpha' in value ? value.srcAlpha : value.src); - var dstRGB = ('dstRGB' in value ? value.dstRGB : value.dst); - var dstAlpha = ('dstAlpha' in value ? value.dstAlpha : value.dst); - check$1.commandParameter(srcRGB, blendFuncs, param + '.srcRGB', env.commandStr); - check$1.commandParameter(srcAlpha, blendFuncs, param + '.srcAlpha', env.commandStr); - check$1.commandParameter(dstRGB, blendFuncs, param + '.dstRGB', env.commandStr); - check$1.commandParameter(dstAlpha, blendFuncs, param + '.dstAlpha', env.commandStr); + function reglBuffer (options) { + var usage = GL_STATIC_DRAW + var data = null + var byteLength = 0 + var dtype = 0 + var dimension = 1 + if (Array.isArray(options) || + isTypedArray(options) || + isNDArrayLike(options) || + options instanceof ArrayBuffer) { + data = options + } else if (typeof options === 'number') { + byteLength = options | 0 + } else if (options) { + check$1.type( + options, 'object', + 'buffer arguments must be an object, a number or an array') - check$1.command( - (invalidBlendCombinations.indexOf(srcRGB + ', ' + dstRGB) === -1), - 'unallowed blending combination (srcRGB, dstRGB) = (' + srcRGB + ', ' + dstRGB + ')', env.commandStr); + if ('data' in options) { + check$1( + data === null || + Array.isArray(data) || + isTypedArray(data) || + isNDArrayLike(data), + 'invalid data for buffer') + data = options.data + } - return [ - blendFuncs[srcRGB], - blendFuncs[dstRGB], - blendFuncs[srcAlpha], - blendFuncs[dstAlpha] - ] - }, - function (env, scope, value) { - var BLEND_FUNCS = env.constants.blendFuncs; + if ('usage' in options) { + check$1.parameter(options.usage, usageTypes, 'invalid buffer usage') + usage = usageTypes[options.usage] + } - check$1.optional(function () { - env.assert(scope, - value + '&&typeof ' + value + '==="object"', - 'invalid blend func, must be an object'); - }); + if ('type' in options) { + check$1.parameter(options.type, glTypes, 'invalid buffer type') + dtype = glTypes[options.type] + } - function read (prefix, suffix) { - var func = scope.def( - '"', prefix, suffix, '" in ', value, - '?', value, '.', prefix, suffix, - ':', value, '.', prefix); + if ('dimension' in options) { + check$1.type(options.dimension, 'number', 'invalid dimension') + dimension = options.dimension | 0 + } - check$1.optional(function () { - env.assert(scope, - func + ' in ' + BLEND_FUNCS, - 'invalid ' + prop + '.' + prefix + suffix + ', must be one of ' + Object.keys(blendFuncs)); - }); + if ('length' in options) { + check$1.nni(byteLength, 'buffer length must be a nonnegative integer') + byteLength = options.length | 0 + } + } - return func - } + buffer.bind() + if (!data) { + // #475 + if (byteLength) gl.bufferData(buffer.type, byteLength, usage) + buffer.dtype = dtype || GL_UNSIGNED_BYTE$3 + buffer.usage = usage + buffer.dimension = dimension + buffer.byteLength = byteLength + } else { + initBufferFromData(buffer, data, usage, dtype, dimension, persistent) + } - var srcRGB = read('src', 'RGB'); - var dstRGB = read('dst', 'RGB'); + if (config.profile) { + buffer.stats.size = buffer.byteLength * DTYPES_SIZES[buffer.dtype] + } - check$1.optional(function () { - var INVALID_BLEND_COMBINATIONS = env.constants.invalidBlendCombinations; + return reglBuffer + } - env.assert(scope, - INVALID_BLEND_COMBINATIONS + - '.indexOf(' + srcRGB + '+", "+' + dstRGB + ') === -1 ', - 'unallowed blending combination for (srcRGB, dstRGB)' - ); - }); + function setSubData (data, offset) { + check$1(offset + data.byteLength <= buffer.byteLength, + 'invalid buffer subdata call, buffer is too small. ' + ' Can\'t write data of size ' + data.byteLength + ' starting from offset ' + offset + ' to a buffer of size ' + buffer.byteLength) - var SRC_RGB = scope.def(BLEND_FUNCS, '[', srcRGB, ']'); - var SRC_ALPHA = scope.def(BLEND_FUNCS, '[', read('src', 'Alpha'), ']'); - var DST_RGB = scope.def(BLEND_FUNCS, '[', dstRGB, ']'); - var DST_ALPHA = scope.def(BLEND_FUNCS, '[', read('dst', 'Alpha'), ']'); + gl.bufferSubData(buffer.type, offset, data) + } - return [SRC_RGB, DST_RGB, SRC_ALPHA, DST_ALPHA] - }) + function subdata (data, offset_) { + var offset = (offset_ || 0) | 0 + var shape + buffer.bind() + if (isTypedArray(data) || data instanceof ArrayBuffer) { + setSubData(data, offset) + } else if (Array.isArray(data)) { + if (data.length > 0) { + if (typeof data[0] === 'number') { + var converted = pool.allocType(buffer.dtype, data.length) + copyArray(converted, data) + setSubData(converted, offset) + pool.freeType(converted) + } else if (Array.isArray(data[0]) || isTypedArray(data[0])) { + shape = arrayShape(data) + var flatData = arrayFlatten(data, shape, buffer.dtype) + setSubData(flatData, offset) + pool.freeType(flatData) + } else { + check$1.raise('invalid buffer data') + } + } + } else if (isNDArrayLike(data)) { + shape = data.shape + var stride = data.stride - case S_BLEND_EQUATION: - return parseParam( - function (value) { - if (typeof value === 'string') { - check$1.commandParameter(value, blendEquations, 'invalid ' + prop, env.commandStr); - return [ - blendEquations[value], - blendEquations[value] - ] - } else if (typeof value === 'object') { - check$1.commandParameter( - value.rgb, blendEquations, prop + '.rgb', env.commandStr); - check$1.commandParameter( - value.alpha, blendEquations, prop + '.alpha', env.commandStr); - return [ - blendEquations[value.rgb], - blendEquations[value.alpha] - ] - } else { - check$1.commandRaise('invalid blend.equation', env.commandStr); - } - }, - function (env, scope, value) { - var BLEND_EQUATIONS = env.constants.blendEquations; + var shapeX = 0 + var shapeY = 0 + var strideX = 0 + var strideY = 0 + if (shape.length === 1) { + shapeX = shape[0] + shapeY = 1 + strideX = stride[0] + strideY = 0 + } else if (shape.length === 2) { + shapeX = shape[0] + shapeY = shape[1] + strideX = stride[0] + strideY = stride[1] + } else { + check$1.raise('invalid shape') + } + var dtype = Array.isArray(data.data) + ? buffer.dtype + : typedArrayCode(data.data) - var RGB = scope.def(); - var ALPHA = scope.def(); + var transposeData = pool.allocType(dtype, shapeX * shapeY) + transpose(transposeData, + data.data, + shapeX, shapeY, + strideX, strideY, + data.offset) + setSubData(transposeData, offset) + pool.freeType(transposeData) + } else { + check$1.raise('invalid data for buffer subdata') + } + return reglBuffer + } - var ifte = env.cond('typeof ', value, '==="string"'); + if (!deferInit) { + reglBuffer(options) + } - check$1.optional(function () { - function checkProp (block, name, value) { - env.assert(block, - value + ' in ' + BLEND_EQUATIONS, - 'invalid ' + name + ', must be one of ' + Object.keys(blendEquations)); - } - checkProp(ifte.then, prop, value); + reglBuffer._reglType = 'buffer' + reglBuffer._buffer = buffer + reglBuffer.subdata = subdata + if (config.profile) { + reglBuffer.stats = buffer.stats + } + reglBuffer.destroy = function () { destroy(buffer) } - env.assert(ifte.else, - value + '&&typeof ' + value + '==="object"', - 'invalid ' + prop); - checkProp(ifte.else, prop + '.rgb', value + '.rgb'); - checkProp(ifte.else, prop + '.alpha', value + '.alpha'); - }); + return reglBuffer + } - ifte.then( - RGB, '=', ALPHA, '=', BLEND_EQUATIONS, '[', value, '];'); - ifte.else( - RGB, '=', BLEND_EQUATIONS, '[', value, '.rgb];', - ALPHA, '=', BLEND_EQUATIONS, '[', value, '.alpha];'); + function restoreBuffers () { + values(bufferSet).forEach(function (buffer) { + buffer.buffer = gl.createBuffer() + gl.bindBuffer(buffer.type, buffer.buffer) + gl.bufferData( + buffer.type, buffer.persistentData || buffer.byteLength, buffer.usage) + }) + } - scope(ifte); + if (config.profile) { + stats.getTotalBufferSize = function () { + var total = 0 + // TODO: Right now, the streams are not part of the total count. + Object.keys(bufferSet).forEach(function (key) { + total += bufferSet[key].stats.size + }) + return total + } + } - return [RGB, ALPHA] - }) + return { + create: createBuffer, - case S_BLEND_COLOR: - return parseParam( - function (value) { - check$1.command( - isArrayLike(value) && - value.length === 4, - 'blend.color must be a 4d array', env.commandStr); - return loop(4, function (i) { - return +value[i] - }) - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - env.shared.isArrayLike + '(' + value + ')&&' + - value + '.length===4', - 'blend.color must be a 4d array'); - }); - return loop(4, function (i) { - return scope.def('+', value, '[', i, ']') - }) - }) + createStream: createStream, + destroyStream: destroyStream, - case S_STENCIL_MASK: - return parseParam( - function (value) { - check$1.commandType(value, 'number', param, env.commandStr); - return value | 0 - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - 'typeof ' + value + '==="number"', - 'invalid stencil.mask'); - }); - return scope.def(value, '|0') - }) + clear: function () { + values(bufferSet).forEach(destroy) + streamPool.forEach(destroy) + }, - case S_STENCIL_FUNC: - return parseParam( - function (value) { - check$1.commandType(value, 'object', param, env.commandStr); - var cmp = value.cmp || 'keep'; - var ref = value.ref || 0; - var mask = 'mask' in value ? value.mask : -1; - check$1.commandParameter(cmp, compareFuncs, prop + '.cmp', env.commandStr); - check$1.commandType(ref, 'number', prop + '.ref', env.commandStr); - check$1.commandType(mask, 'number', prop + '.mask', env.commandStr); - return [ - compareFuncs[cmp], - ref, - mask - ] - }, - function (env, scope, value) { - var COMPARE_FUNCS = env.constants.compareFuncs; - check$1.optional(function () { - function assert () { - env.assert(scope, - Array.prototype.join.call(arguments, ''), - 'invalid stencil.func'); - } - assert(value + '&&typeof ', value, '==="object"'); - assert('!("cmp" in ', value, ')||(', - value, '.cmp in ', COMPARE_FUNCS, ')'); - }); - var cmp = scope.def( - '"cmp" in ', value, - '?', COMPARE_FUNCS, '[', value, '.cmp]', - ':', GL_KEEP); - var ref = scope.def(value, '.ref|0'); - var mask = scope.def( - '"mask" in ', value, - '?', value, '.mask|0:-1'); - return [cmp, ref, mask] - }) + getBuffer: function (wrapper) { + if (wrapper && wrapper._buffer instanceof REGLBuffer) { + return wrapper._buffer + } + return null + }, - case S_STENCIL_OPFRONT: - case S_STENCIL_OPBACK: - return parseParam( - function (value) { - check$1.commandType(value, 'object', param, env.commandStr); - var fail = value.fail || 'keep'; - var zfail = value.zfail || 'keep'; - var zpass = value.zpass || 'keep'; - check$1.commandParameter(fail, stencilOps, prop + '.fail', env.commandStr); - check$1.commandParameter(zfail, stencilOps, prop + '.zfail', env.commandStr); - check$1.commandParameter(zpass, stencilOps, prop + '.zpass', env.commandStr); - return [ - prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT, - stencilOps[fail], - stencilOps[zfail], - stencilOps[zpass] - ] - }, - function (env, scope, value) { - var STENCIL_OPS = env.constants.stencilOps; + restore: restoreBuffers, - check$1.optional(function () { - env.assert(scope, - value + '&&typeof ' + value + '==="object"', - 'invalid ' + prop); - }); + _initBuffer: initBufferFromData + } +} - function read (name) { - check$1.optional(function () { - env.assert(scope, - '!("' + name + '" in ' + value + ')||' + - '(' + value + '.' + name + ' in ' + STENCIL_OPS + ')', - 'invalid ' + prop + '.' + name + ', must be one of ' + Object.keys(stencilOps)); - }); +var points = 0; +var point = 0; +var lines = 1; +var line = 1; +var triangles = 4; +var triangle = 4; +var primTypes = { + points: points, + point: point, + lines: lines, + line: line, + triangles: triangles, + triangle: triangle, + "line loop": 2, + "line strip": 3, + "triangle strip": 5, + "triangle fan": 6 +}; - return scope.def( - '"', name, '" in ', value, - '?', STENCIL_OPS, '[', value, '.', name, ']:', - GL_KEEP) - } +var GL_POINTS = 0 +var GL_LINES = 1 +var GL_TRIANGLES = 4 - return [ - prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT, - read('fail'), - read('zfail'), - read('zpass') - ] - }) +var GL_BYTE$2 = 5120 +var GL_UNSIGNED_BYTE$4 = 5121 +var GL_SHORT$2 = 5122 +var GL_UNSIGNED_SHORT$2 = 5123 +var GL_INT$2 = 5124 +var GL_UNSIGNED_INT$2 = 5125 - case S_POLYGON_OFFSET_OFFSET: - return parseParam( - function (value) { - check$1.commandType(value, 'object', param, env.commandStr); - var factor = value.factor | 0; - var units = value.units | 0; - check$1.commandType(factor, 'number', param + '.factor', env.commandStr); - check$1.commandType(units, 'number', param + '.units', env.commandStr); - return [factor, units] - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - value + '&&typeof ' + value + '==="object"', - 'invalid ' + prop); - }); +var GL_ELEMENT_ARRAY_BUFFER = 34963 - var FACTOR = scope.def(value, '.factor|0'); - var UNITS = scope.def(value, '.units|0'); +var GL_STREAM_DRAW$1 = 0x88E0 +var GL_STATIC_DRAW$1 = 0x88E4 - return [FACTOR, UNITS] - }) +function wrapElementsState (gl, extensions, bufferState, stats) { + var elementSet = {} + var elementCount = 0 - case S_CULL_FACE: - return parseParam( - function (value) { - var face = 0; - if (value === 'front') { - face = GL_FRONT; - } else if (value === 'back') { - face = GL_BACK; - } - check$1.command(!!face, param, env.commandStr); - return face - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - value + '==="front"||' + - value + '==="back"', - 'invalid cull.face'); - }); - return scope.def(value, '==="front"?', GL_FRONT, ':', GL_BACK) - }) + var elementTypes = { + 'uint8': GL_UNSIGNED_BYTE$4, + 'uint16': GL_UNSIGNED_SHORT$2 + } - case S_LINE_WIDTH: - return parseParam( - function (value) { - check$1.command( - typeof value === 'number' && - value >= limits.lineWidthDims[0] && - value <= limits.lineWidthDims[1], - 'invalid line width, must positive number between ' + - limits.lineWidthDims[0] + ' and ' + limits.lineWidthDims[1], env.commandStr); - return value - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - 'typeof ' + value + '==="number"&&' + - value + '>=' + limits.lineWidthDims[0] + '&&' + - value + '<=' + limits.lineWidthDims[1], - 'invalid line width'); - }); + if (extensions.oes_element_index_uint) { + elementTypes.uint32 = GL_UNSIGNED_INT$2 + } - return value - }) + function REGLElementBuffer (buffer) { + this.id = elementCount++ + elementSet[this.id] = this + this.buffer = buffer + this.primType = GL_TRIANGLES + this.vertCount = 0 + this.type = 0 + } - case S_FRONT_FACE: - return parseParam( - function (value) { - check$1.commandParameter(value, orientationType, param, env.commandStr); - return orientationType[value] - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - value + '==="cw"||' + - value + '==="ccw"', - 'invalid frontFace, must be one of cw,ccw'); - }); - return scope.def(value + '==="cw"?' + GL_CW + ':' + GL_CCW) - }) + REGLElementBuffer.prototype.bind = function () { + this.buffer.bind() + } - case S_COLOR_MASK: - return parseParam( - function (value) { - check$1.command( - isArrayLike(value) && value.length === 4, - 'color.mask must be length 4 array', env.commandStr); - return value.map(function (v) { return !!v }) - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - env.shared.isArrayLike + '(' + value + ')&&' + - value + '.length===4', - 'invalid color.mask'); - }); - return loop(4, function (i) { - return '!!' + value + '[' + i + ']' - }) - }) + var bufferPool = [] - case S_SAMPLE_COVERAGE: - return parseParam( - function (value) { - check$1.command(typeof value === 'object' && value, param, env.commandStr); - var sampleValue = 'value' in value ? value.value : 1; - var sampleInvert = !!value.invert; - check$1.command( - typeof sampleValue === 'number' && - sampleValue >= 0 && sampleValue <= 1, - 'sample.coverage.value must be a number between 0 and 1', env.commandStr); - return [sampleValue, sampleInvert] - }, - function (env, scope, value) { - check$1.optional(function () { - env.assert(scope, - value + '&&typeof ' + value + '==="object"', - 'invalid sample.coverage'); - }); - var VALUE = scope.def( - '"value" in ', value, '?+', value, '.value:1'); - var INVERT = scope.def('!!', value, '.invert'); - return [VALUE, INVERT] - }) - } - }); + function createElementStream (data) { + var result = bufferPool.pop() + if (!result) { + result = new REGLElementBuffer(bufferState.create( + null, + GL_ELEMENT_ARRAY_BUFFER, + true, + false)._buffer) + } + initElements(result, data, GL_STREAM_DRAW$1, -1, -1, 0, 0) + return result + } - return STATE + function destroyElementStream (elements) { + bufferPool.push(elements) } - function parseUniforms (uniforms, env) { - var staticUniforms = uniforms.static; - var dynamicUniforms = uniforms.dynamic; + function initElements ( + elements, + data, + usage, + prim, + count, + byteLength, + type) { + elements.buffer.bind() + var dtype + if (data) { + var predictedType = type + if (!type && ( + !isTypedArray(data) || + (isNDArrayLike(data) && !isTypedArray(data.data)))) { + predictedType = extensions.oes_element_index_uint + ? GL_UNSIGNED_INT$2 + : GL_UNSIGNED_SHORT$2 + } + bufferState._initBuffer( + elements.buffer, + data, + usage, + predictedType, + 3) + } else { + gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, byteLength, usage) + elements.buffer.dtype = dtype || GL_UNSIGNED_BYTE$4 + elements.buffer.usage = usage + elements.buffer.dimension = 3 + elements.buffer.byteLength = byteLength + } - var UNIFORMS = {}; + dtype = type + if (!type) { + switch (elements.buffer.dtype) { + case GL_UNSIGNED_BYTE$4: + case GL_BYTE$2: + dtype = GL_UNSIGNED_BYTE$4 + break - Object.keys(staticUniforms).forEach(function (name) { - var value = staticUniforms[name]; - var result; - if (typeof value === 'number' || - typeof value === 'boolean') { - result = createStaticDecl(function () { - return value - }); - } else if (typeof value === 'function') { - var reglType = value._reglType; - if (reglType === 'texture2d' || - reglType === 'textureCube') { - result = createStaticDecl(function (env) { - return env.link(value) - }); - } else if (reglType === 'framebuffer' || - reglType === 'framebufferCube') { - check$1.command(value.color.length > 0, - 'missing color attachment for framebuffer sent to uniform "' + name + '"', env.commandStr); - result = createStaticDecl(function (env) { - return env.link(value.color[0]) - }); - } else { - check$1.commandRaise('invalid data for uniform "' + name + '"', env.commandStr); - } - } else if (isArrayLike(value)) { - result = createStaticDecl(function (env) { - var ITEM = env.global.def('[', - loop(value.length, function (i) { - check$1.command( - typeof value[i] === 'number' || - typeof value[i] === 'boolean', - 'invalid uniform ' + name, env.commandStr); - return value[i] - }), ']'); - return ITEM - }); - } else { - check$1.commandRaise('invalid or missing data for uniform "' + name + '"', env.commandStr); + case GL_UNSIGNED_SHORT$2: + case GL_SHORT$2: + dtype = GL_UNSIGNED_SHORT$2 + break + + case GL_UNSIGNED_INT$2: + case GL_INT$2: + dtype = GL_UNSIGNED_INT$2 + break + + default: + check$1.raise('unsupported type for element array') } - result.value = value; - UNIFORMS[name] = result; - }); + elements.buffer.dtype = dtype + } + elements.type = dtype - Object.keys(dynamicUniforms).forEach(function (key) { - var dyn = dynamicUniforms[key]; - UNIFORMS[key] = createDynamicDecl(dyn, function (env, scope) { - return env.invoke(scope, dyn) - }); - }); + // Check oes_element_index_uint extension + check$1( + dtype !== GL_UNSIGNED_INT$2 || + !!extensions.oes_element_index_uint, + '32 bit element buffers not supported, enable oes_element_index_uint first') - return UNIFORMS + // try to guess default primitive type and arguments + var vertCount = count + if (vertCount < 0) { + vertCount = elements.buffer.byteLength + if (dtype === GL_UNSIGNED_SHORT$2) { + vertCount >>= 1 + } else if (dtype === GL_UNSIGNED_INT$2) { + vertCount >>= 2 + } + } + elements.vertCount = vertCount + + // try to guess primitive type from cell dimension + var primType = prim + if (prim < 0) { + primType = GL_TRIANGLES + var dimension = elements.buffer.dimension + if (dimension === 1) primType = GL_POINTS + if (dimension === 2) primType = GL_LINES + if (dimension === 3) primType = GL_TRIANGLES + } + elements.primType = primType } - function parseAttributes (attributes, env) { - var staticAttributes = attributes.static; - var dynamicAttributes = attributes.dynamic; + function destroyElements (elements) { + stats.elementsCount-- - var attributeDefs = {}; + check$1(elements.buffer !== null, 'must not double destroy elements') + delete elementSet[elements.id] + elements.buffer.destroy() + elements.buffer = null + } - Object.keys(staticAttributes).forEach(function (attribute) { - var value = staticAttributes[attribute]; - var id = stringStore.id(attribute); + function createElements (options, persistent) { + var buffer = bufferState.create(null, GL_ELEMENT_ARRAY_BUFFER, true) + var elements = new REGLElementBuffer(buffer._buffer) + stats.elementsCount++ - var record = new AttributeRecord(); - if (isBufferArgs(value)) { - record.state = ATTRIB_STATE_POINTER; - record.buffer = bufferState.getBuffer( - bufferState.create(value, GL_ARRAY_BUFFER$1, false, true)); - record.type = 0; + function reglElements (options) { + if (!options) { + buffer() + elements.primType = GL_TRIANGLES + elements.vertCount = 0 + elements.type = GL_UNSIGNED_BYTE$4 + } else if (typeof options === 'number') { + buffer(options) + elements.primType = GL_TRIANGLES + elements.vertCount = options | 0 + elements.type = GL_UNSIGNED_BYTE$4 } else { - var buffer = bufferState.getBuffer(value); - if (buffer) { - record.state = ATTRIB_STATE_POINTER; - record.buffer = buffer; - record.type = 0; + var data = null + var usage = GL_STATIC_DRAW$1 + var primType = -1 + var vertCount = -1 + var byteLength = 0 + var dtype = 0 + if (Array.isArray(options) || + isTypedArray(options) || + isNDArrayLike(options)) { + data = options } else { - check$1.command(typeof value === 'object' && value, - 'invalid data for attribute ' + attribute, env.commandStr); - if (value.constant) { - var constant = value.constant; - record.buffer = 'null'; - record.state = ATTRIB_STATE_CONSTANT; - if (typeof constant === 'number') { - record.x = constant; - } else { - check$1.command( - isArrayLike(constant) && - constant.length > 0 && - constant.length <= 4, - 'invalid constant for attribute ' + attribute, env.commandStr); - CUTE_COMPONENTS.forEach(function (c, i) { - if (i < constant.length) { - record[c] = constant[i]; - } - }); - } + check$1.type(options, 'object', 'invalid arguments for elements') + if ('data' in options) { + data = options.data + check$1( + Array.isArray(data) || + isTypedArray(data) || + isNDArrayLike(data), + 'invalid data for element buffer') + } + if ('usage' in options) { + check$1.parameter( + options.usage, + usageTypes, + 'invalid element buffer usage') + usage = usageTypes[options.usage] + } + if ('primitive' in options) { + check$1.parameter( + options.primitive, + primTypes, + 'invalid element buffer primitive') + primType = primTypes[options.primitive] + } + if ('count' in options) { + check$1( + typeof options.count === 'number' && options.count >= 0, + 'invalid vertex count for elements') + vertCount = options.count | 0 + } + if ('type' in options) { + check$1.parameter( + options.type, + elementTypes, + 'invalid buffer type') + dtype = elementTypes[options.type] + } + if ('length' in options) { + byteLength = options.length | 0 } else { - if (isBufferArgs(value.buffer)) { - buffer = bufferState.getBuffer( - bufferState.create(value.buffer, GL_ARRAY_BUFFER$1, false, true)); - } else { - buffer = bufferState.getBuffer(value.buffer); + byteLength = vertCount + if (dtype === GL_UNSIGNED_SHORT$2 || dtype === GL_SHORT$2) { + byteLength *= 2 + } else if (dtype === GL_UNSIGNED_INT$2 || dtype === GL_INT$2) { + byteLength *= 4 } - check$1.command(!!buffer, 'missing buffer for attribute "' + attribute + '"', env.commandStr); + } + } + initElements( + elements, + data, + usage, + primType, + vertCount, + byteLength, + dtype) + } - var offset = value.offset | 0; - check$1.command(offset >= 0, - 'invalid offset for attribute "' + attribute + '"', env.commandStr); + return reglElements + } - var stride = value.stride | 0; - check$1.command(stride >= 0 && stride < 256, - 'invalid stride for attribute "' + attribute + '", must be integer betweeen [0, 255]', env.commandStr); + reglElements(options) - var size = value.size | 0; - check$1.command(!('size' in value) || (size > 0 && size <= 4), - 'invalid size for attribute "' + attribute + '", must be 1,2,3,4', env.commandStr); + reglElements._reglType = 'elements' + reglElements._elements = elements + reglElements.subdata = function (data, offset) { + buffer.subdata(data, offset) + return reglElements + } + reglElements.destroy = function () { + destroyElements(elements) + } - var normalized = !!value.normalized; + return reglElements + } - var type = 0; - if ('type' in value) { - check$1.commandParameter( - value.type, glTypes, - 'invalid type for attribute ' + attribute, env.commandStr); - type = glTypes[value.type]; - } + return { + create: createElements, + createStream: createElementStream, + destroyStream: destroyElementStream, + getElements: function (elements) { + if (typeof elements === 'function' && + elements._elements instanceof REGLElementBuffer) { + return elements._elements + } + return null + }, + clear: function () { + values(elementSet).forEach(destroyElements) + } + } +} - var divisor = value.divisor | 0; - if ('divisor' in value) { - check$1.command(divisor === 0 || extInstancing, - 'cannot specify divisor for attribute "' + attribute + '", instancing not supported', env.commandStr); - check$1.command(divisor >= 0, - 'invalid divisor for attribute "' + attribute + '"', env.commandStr); - } +var FLOAT = new Float32Array(1) +var INT = new Uint32Array(FLOAT.buffer) - check$1.optional(function () { - var command = env.commandStr; +var GL_UNSIGNED_SHORT$4 = 5123 - var VALID_KEYS = [ - 'buffer', - 'offset', - 'divisor', - 'normalized', - 'type', - 'size', - 'stride' - ]; +function convertToHalfFloat (array) { + var ushorts = pool.allocType(GL_UNSIGNED_SHORT$4, array.length) - Object.keys(value).forEach(function (prop) { - check$1.command( - VALID_KEYS.indexOf(prop) >= 0, - 'unknown parameter "' + prop + '" for attribute pointer "' + attribute + '" (valid parameters are ' + VALID_KEYS + ')', - command); - }); - }); + for (var i = 0; i < array.length; ++i) { + if (isNaN(array[i])) { + ushorts[i] = 0xffff + } else if (array[i] === Infinity) { + ushorts[i] = 0x7c00 + } else if (array[i] === -Infinity) { + ushorts[i] = 0xfc00 + } else { + FLOAT[0] = array[i] + var x = INT[0] - record.buffer = buffer; - record.state = ATTRIB_STATE_POINTER; - record.size = size; - record.normalized = normalized; - record.type = type || buffer.dtype; - record.offset = offset; - record.stride = stride; - record.divisor = divisor; - } - } + var sgn = (x >>> 31) << 15 + var exp = ((x << 1) >>> 24) - 127 + var frac = (x >> 13) & ((1 << 10) - 1) + + if (exp < -24) { + // round non-representable denormals to 0 + ushorts[i] = sgn + } else if (exp < -14) { + // handle denormals + var s = -14 - exp + ushorts[i] = sgn + ((frac + (1 << 10)) >> s) + } else if (exp > 15) { + // round overflow to +/- Infinity + ushorts[i] = sgn + 0x7c00 + } else { + // otherwise convert directly + ushorts[i] = sgn + ((exp + 15) << 10) + frac } + } + } - attributeDefs[attribute] = createStaticDecl(function (env, scope) { - var cache = env.attribCache; - if (id in cache) { - return cache[id] - } - var result = { - isStream: false - }; - Object.keys(record).forEach(function (key) { - result[key] = record[key]; - }); - if (record.buffer) { - result.buffer = env.link(record.buffer); - result.type = result.type || (result.buffer + '.dtype'); - } - cache[id] = result; - return result - }); - }); + return ushorts +} + +function isArrayLike (s) { + return Array.isArray(s) || isTypedArray(s) +} + +var isPow2$1 = function (v) { + return !(v & (v - 1)) && (!!v) +} - Object.keys(dynamicAttributes).forEach(function (attribute) { - var dyn = dynamicAttributes[attribute]; +var GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3 - function appendAttributeCode (env, block) { - var VALUE = env.invoke(block, dyn); +var GL_TEXTURE_2D$1 = 0x0DE1 +var GL_TEXTURE_CUBE_MAP$1 = 0x8513 +var GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 = 0x8515 - var shared = env.shared; +var GL_RGBA$1 = 0x1908 +var GL_ALPHA = 0x1906 +var GL_RGB = 0x1907 +var GL_LUMINANCE = 0x1909 +var GL_LUMINANCE_ALPHA = 0x190A - var IS_BUFFER_ARGS = shared.isBufferArgs; - var BUFFER_STATE = shared.buffer; +var GL_RGBA4 = 0x8056 +var GL_RGB5_A1 = 0x8057 +var GL_RGB565 = 0x8D62 - // Perform validation on attribute - check$1.optional(function () { - env.assert(block, - VALUE + '&&(typeof ' + VALUE + '==="object"||typeof ' + - VALUE + '==="function")&&(' + - IS_BUFFER_ARGS + '(' + VALUE + ')||' + - BUFFER_STATE + '.getBuffer(' + VALUE + ')||' + - BUFFER_STATE + '.getBuffer(' + VALUE + '.buffer)||' + - IS_BUFFER_ARGS + '(' + VALUE + '.buffer)||' + - '("constant" in ' + VALUE + - '&&(typeof ' + VALUE + '.constant==="number"||' + - shared.isArrayLike + '(' + VALUE + '.constant))))', - 'invalid dynamic attribute "' + attribute + '"'); - }); +var GL_UNSIGNED_SHORT_4_4_4_4$1 = 0x8033 +var GL_UNSIGNED_SHORT_5_5_5_1$1 = 0x8034 +var GL_UNSIGNED_SHORT_5_6_5$1 = 0x8363 +var GL_UNSIGNED_INT_24_8_WEBGL$1 = 0x84FA - // allocate names for result - var result = { - isStream: block.def(false) - }; - var defaultRecord = new AttributeRecord(); - defaultRecord.state = ATTRIB_STATE_POINTER; - Object.keys(defaultRecord).forEach(function (key) { - result[key] = block.def('' + defaultRecord[key]); - }); +var GL_DEPTH_COMPONENT = 0x1902 +var GL_DEPTH_STENCIL = 0x84F9 - var BUFFER = result.buffer; - var TYPE = result.type; - block( - 'if(', IS_BUFFER_ARGS, '(', VALUE, ')){', - result.isStream, '=true;', - BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$1, ',', VALUE, ');', - TYPE, '=', BUFFER, '.dtype;', - '}else{', - BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, ');', - 'if(', BUFFER, '){', - TYPE, '=', BUFFER, '.dtype;', - '}else if("constant" in ', VALUE, '){', - result.state, '=', ATTRIB_STATE_CONSTANT, ';', - 'if(typeof ' + VALUE + '.constant === "number"){', - result[CUTE_COMPONENTS[0]], '=', VALUE, '.constant;', - CUTE_COMPONENTS.slice(1).map(function (n) { - return result[n] - }).join('='), '=0;', - '}else{', - CUTE_COMPONENTS.map(function (name, i) { - return ( - result[name] + '=' + VALUE + '.constant.length>=' + i + - '?' + VALUE + '.constant[' + i + ']:0;' - ) - }).join(''), - '}}else{', - 'if(', IS_BUFFER_ARGS, '(', VALUE, '.buffer)){', - BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$1, ',', VALUE, '.buffer);', - '}else{', - BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, '.buffer);', - '}', - TYPE, '="type" in ', VALUE, '?', - shared.glTypes, '[', VALUE, '.type]:', BUFFER, '.dtype;', - result.normalized, '=!!', VALUE, '.normalized;'); - function emitReadRecord (name) { - block(result[name], '=', VALUE, '.', name, '|0;'); - } - emitReadRecord('size'); - emitReadRecord('offset'); - emitReadRecord('stride'); - emitReadRecord('divisor'); +var GL_SRGB_EXT = 0x8C40 +var GL_SRGB_ALPHA_EXT = 0x8C42 - block('}}'); +var GL_HALF_FLOAT_OES$1 = 0x8D61 - block.exit( - 'if(', result.isStream, '){', - BUFFER_STATE, '.destroyStream(', BUFFER, ');', - '}'); +var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0 +var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1 +var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2 +var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3 - return result - } +var GL_COMPRESSED_RGB_ATC_WEBGL = 0x8C92 +var GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93 +var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE - attributeDefs[attribute] = createDynamicDecl(dyn, appendAttributeCode); - }); +var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00 +var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01 +var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02 +var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03 - return attributeDefs - } +var GL_COMPRESSED_RGB_ETC1_WEBGL = 0x8D64 - function parseContext (context) { - var staticContext = context.static; - var dynamicContext = context.dynamic; - var result = {}; +var GL_UNSIGNED_BYTE$5 = 0x1401 +var GL_UNSIGNED_SHORT$3 = 0x1403 +var GL_UNSIGNED_INT$3 = 0x1405 +var GL_FLOAT$4 = 0x1406 - Object.keys(staticContext).forEach(function (name) { - var value = staticContext[name]; - result[name] = createStaticDecl(function (env, scope) { - if (typeof value === 'number' || typeof value === 'boolean') { - return '' + value - } else { - return env.link(value) - } - }); - }); +var GL_TEXTURE_WRAP_S = 0x2802 +var GL_TEXTURE_WRAP_T = 0x2803 - Object.keys(dynamicContext).forEach(function (name) { - var dyn = dynamicContext[name]; - result[name] = createDynamicDecl(dyn, function (env, scope) { - return env.invoke(scope, dyn) - }); - }); +var GL_REPEAT = 0x2901 +var GL_CLAMP_TO_EDGE$1 = 0x812F +var GL_MIRRORED_REPEAT = 0x8370 - return result - } +var GL_TEXTURE_MAG_FILTER = 0x2800 +var GL_TEXTURE_MIN_FILTER = 0x2801 - function parseArguments (options, attributes, uniforms, context, env) { - var staticOptions = options.static; - var dynamicOptions = options.dynamic; +var GL_NEAREST$1 = 0x2600 +var GL_LINEAR = 0x2601 +var GL_NEAREST_MIPMAP_NEAREST$1 = 0x2700 +var GL_LINEAR_MIPMAP_NEAREST$1 = 0x2701 +var GL_NEAREST_MIPMAP_LINEAR$1 = 0x2702 +var GL_LINEAR_MIPMAP_LINEAR$1 = 0x2703 - check$1.optional(function () { - var KEY_NAMES = [ - S_FRAMEBUFFER, - S_VERT, - S_FRAG, - S_ELEMENTS, - S_PRIMITIVE, - S_OFFSET, - S_COUNT, - S_INSTANCES, - S_PROFILE - ].concat(GL_STATE_NAMES); +var GL_GENERATE_MIPMAP_HINT = 0x8192 +var GL_DONT_CARE = 0x1100 +var GL_FASTEST = 0x1101 +var GL_NICEST = 0x1102 - function checkKeys (dict) { - Object.keys(dict).forEach(function (key) { - check$1.command( - KEY_NAMES.indexOf(key) >= 0, - 'unknown parameter "' + key + '"', - env.commandStr); - }); - } +var GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE - checkKeys(staticOptions); - checkKeys(dynamicOptions); - }); +var GL_UNPACK_ALIGNMENT = 0x0CF5 +var GL_UNPACK_FLIP_Y_WEBGL = 0x9240 +var GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241 +var GL_UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243 - var framebuffer = parseFramebuffer(options, env); - var viewportAndScissor = parseViewportScissor(options, framebuffer, env); - var draw = parseDraw(options, env); - var state = parseGLState(options, env); - var shader = parseProgram(options, env); +var GL_BROWSER_DEFAULT_WEBGL = 0x9244 - function copyBox (name) { - var defn = viewportAndScissor[name]; - if (defn) { - state[name] = defn; - } - } - copyBox(S_VIEWPORT); - copyBox(propName(S_SCISSOR_BOX)); +var GL_TEXTURE0$1 = 0x84C0 - var dirty = Object.keys(state).length > 0; +var MIPMAP_FILTERS = [ + GL_NEAREST_MIPMAP_NEAREST$1, + GL_NEAREST_MIPMAP_LINEAR$1, + GL_LINEAR_MIPMAP_NEAREST$1, + GL_LINEAR_MIPMAP_LINEAR$1 +] - var result = { - framebuffer: framebuffer, - draw: draw, - shader: shader, - state: state, - dirty: dirty - }; +var CHANNELS_FORMAT = [ + 0, + GL_LUMINANCE, + GL_LUMINANCE_ALPHA, + GL_RGB, + GL_RGBA$1 +] - result.profile = parseProfile(options, env); - result.uniforms = parseUniforms(uniforms, env); - result.attributes = parseAttributes(attributes, env); - result.context = parseContext(context, env); - return result +var FORMAT_CHANNELS = {} +FORMAT_CHANNELS[GL_LUMINANCE] = +FORMAT_CHANNELS[GL_ALPHA] = +FORMAT_CHANNELS[GL_DEPTH_COMPONENT] = 1 +FORMAT_CHANNELS[GL_DEPTH_STENCIL] = +FORMAT_CHANNELS[GL_LUMINANCE_ALPHA] = 2 +FORMAT_CHANNELS[GL_RGB] = +FORMAT_CHANNELS[GL_SRGB_EXT] = 3 +FORMAT_CHANNELS[GL_RGBA$1] = +FORMAT_CHANNELS[GL_SRGB_ALPHA_EXT] = 4 + +function objectName (str) { + return '[object ' + str + ']' +} + +var CANVAS_CLASS = objectName('HTMLCanvasElement') +var OFFSCREENCANVAS_CLASS = objectName('OffscreenCanvas') +var CONTEXT2D_CLASS = objectName('CanvasRenderingContext2D') +var BITMAP_CLASS = objectName('ImageBitmap') +var IMAGE_CLASS = objectName('HTMLImageElement') +var VIDEO_CLASS = objectName('HTMLVideoElement') + +var PIXEL_CLASSES = Object.keys(arrayTypes).concat([ + CANVAS_CLASS, + OFFSCREENCANVAS_CLASS, + CONTEXT2D_CLASS, + BITMAP_CLASS, + IMAGE_CLASS, + VIDEO_CLASS +]) + +// for every texture type, store +// the size in bytes. +var TYPE_SIZES = [] +TYPE_SIZES[GL_UNSIGNED_BYTE$5] = 1 +TYPE_SIZES[GL_FLOAT$4] = 4 +TYPE_SIZES[GL_HALF_FLOAT_OES$1] = 2 + +TYPE_SIZES[GL_UNSIGNED_SHORT$3] = 2 +TYPE_SIZES[GL_UNSIGNED_INT$3] = 4 + +var FORMAT_SIZES_SPECIAL = [] +FORMAT_SIZES_SPECIAL[GL_RGBA4] = 2 +FORMAT_SIZES_SPECIAL[GL_RGB5_A1] = 2 +FORMAT_SIZES_SPECIAL[GL_RGB565] = 2 +FORMAT_SIZES_SPECIAL[GL_DEPTH_STENCIL] = 4 + +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_S3TC_DXT1_EXT] = 0.5 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT] = 0.5 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT] = 1 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT] = 1 + +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ATC_WEBGL] = 0.5 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 1 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 1 + +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 0.5 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 0.25 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 0.5 +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 0.25 + +FORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ETC1_WEBGL] = 0.5 + +function isNumericArray (arr) { + return ( + Array.isArray(arr) && + (arr.length === 0 || + typeof arr[0] === 'number')) +} + +function isRectArray (arr) { + if (!Array.isArray(arr)) { + return false + } + var width = arr.length + if (width === 0 || !isArrayLike(arr[0])) { + return false } + return true +} - // =================================================== - // =================================================== - // COMMON UPDATE FUNCTIONS - // =================================================== - // =================================================== - function emitContext (env, scope, context) { - var shared = env.shared; - var CONTEXT = shared.context; +function classString (x) { + return Object.prototype.toString.call(x) +} + +function isCanvasElement (object) { + return classString(object) === CANVAS_CLASS +} - var contextEnter = env.scope(); +function isOffscreenCanvas (object) { + return classString(object) === OFFSCREENCANVAS_CLASS +} - Object.keys(context).forEach(function (name) { - scope.save(CONTEXT, '.' + name); - var defn = context[name]; - contextEnter(CONTEXT, '.', name, '=', defn.append(env, scope), ';'); - }); +function isContext2D (object) { + return classString(object) === CONTEXT2D_CLASS +} + +function isBitmap (object) { + return classString(object) === BITMAP_CLASS +} + +function isImageElement (object) { + return classString(object) === IMAGE_CLASS +} + +function isVideoElement (object) { + return classString(object) === VIDEO_CLASS +} - scope(contextEnter); +function isPixelData (object) { + if (!object) { + return false } + var className = classString(object) + if (PIXEL_CLASSES.indexOf(className) >= 0) { + return true + } + return ( + isNumericArray(object) || + isRectArray(object) || + isNDArrayLike(object)) +} - // =================================================== - // =================================================== - // COMMON DRAWING FUNCTIONS - // =================================================== - // =================================================== - function emitPollFramebuffer (env, scope, framebuffer, skipCheck) { - var shared = env.shared; +function typedArrayCode$1 (data) { + return arrayTypes[Object.prototype.toString.call(data)] | 0 +} - var GL = shared.gl; - var FRAMEBUFFER_STATE = shared.framebuffer; - var EXT_DRAW_BUFFERS; - if (extDrawBuffers) { - EXT_DRAW_BUFFERS = scope.def(shared.extensions, '.webgl_draw_buffers'); - } +function convertData (result, data) { + var n = data.length + switch (result.type) { + case GL_UNSIGNED_BYTE$5: + case GL_UNSIGNED_SHORT$3: + case GL_UNSIGNED_INT$3: + case GL_FLOAT$4: + var converted = pool.allocType(result.type, n) + converted.set(data) + result.data = converted + break - var constants = env.constants; + case GL_HALF_FLOAT_OES$1: + result.data = convertToHalfFloat(data) + break - var DRAW_BUFFERS = constants.drawBuffer; - var BACK_BUFFER = constants.backBuffer; + default: + check$1.raise('unsupported texture type, must specify a typed array') + } +} - var NEXT; - if (framebuffer) { - NEXT = framebuffer.append(env, scope); - } else { - NEXT = scope.def(FRAMEBUFFER_STATE, '.next'); - } +function preConvert (image, n) { + return pool.allocType( + image.type === GL_HALF_FLOAT_OES$1 + ? GL_FLOAT$4 + : image.type, n) +} - if (!skipCheck) { - scope('if(', NEXT, '!==', FRAMEBUFFER_STATE, '.cur){'); - } - scope( - 'if(', NEXT, '){', - GL, '.bindFramebuffer(', GL_FRAMEBUFFER$1, ',', NEXT, '.framebuffer);'); - if (extDrawBuffers) { - scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', - DRAW_BUFFERS, '[', NEXT, '.colorAttachments.length]);'); - } - scope('}else{', - GL, '.bindFramebuffer(', GL_FRAMEBUFFER$1, ',null);'); - if (extDrawBuffers) { - scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', BACK_BUFFER, ');'); - } - scope( - '}', - FRAMEBUFFER_STATE, '.cur=', NEXT, ';'); - if (!skipCheck) { - scope('}'); - } +function postConvert (image, data) { + if (image.type === GL_HALF_FLOAT_OES$1) { + image.data = convertToHalfFloat(data) + pool.freeType(data) + } else { + image.data = data } +} - function emitPollState (env, scope, args) { - var shared = env.shared; +function transposeData (image, array, strideX, strideY, strideC, offset) { + var w = image.width + var h = image.height + var c = image.channels + var n = w * h * c + var data = preConvert(image, n) + + var p = 0 + for (var i = 0; i < h; ++i) { + for (var j = 0; j < w; ++j) { + for (var k = 0; k < c; ++k) { + data[p++] = array[strideX * j + strideY * i + strideC * k + offset] + } + } + } - var GL = shared.gl; + postConvert(image, data) +} - var CURRENT_VARS = env.current; - var NEXT_VARS = env.next; - var CURRENT_STATE = shared.current; - var NEXT_STATE = shared.next; +function getTextureSize (format, type, width, height, isMipmap, isCube) { + var s + if (typeof FORMAT_SIZES_SPECIAL[format] !== 'undefined') { + // we have a special array for dealing with weird color formats such as RGB5A1 + s = FORMAT_SIZES_SPECIAL[format] + } else { + s = FORMAT_CHANNELS[format] * TYPE_SIZES[type] + } - var block = env.cond(CURRENT_STATE, '.dirty'); + if (isCube) { + s *= 6 + } - GL_STATE_NAMES.forEach(function (prop) { - var param = propName(prop); - if (param in args.state) { - return - } + if (isMipmap) { + // compute the total size of all the mipmaps. + var total = 0 - var NEXT, CURRENT; - if (param in NEXT_VARS) { - NEXT = NEXT_VARS[param]; - CURRENT = CURRENT_VARS[param]; - var parts = loop(currentState[param].length, function (i) { - return block.def(NEXT, '[', i, ']') - }); - block(env.cond(parts.map(function (p, i) { - return p + '!==' + CURRENT + '[' + i + ']' - }).join('||')) - .then( - GL, '.', GL_VARIABLES[param], '(', parts, ');', - parts.map(function (p, i) { - return CURRENT + '[' + i + ']=' + p - }).join(';'), ';')); - } else { - NEXT = block.def(NEXT_STATE, '.', param); - var ifte = env.cond(NEXT, '!==', CURRENT_STATE, '.', param); - block(ifte); - if (param in GL_FLAGS) { - ifte( - env.cond(NEXT) - .then(GL, '.enable(', GL_FLAGS[param], ');') - .else(GL, '.disable(', GL_FLAGS[param], ');'), - CURRENT_STATE, '.', param, '=', NEXT, ';'); - } else { - ifte( - GL, '.', GL_VARIABLES[param], '(', NEXT, ');', - CURRENT_STATE, '.', param, '=', NEXT, ';'); - } - } - }); - if (Object.keys(args.state).length === 0) { - block(CURRENT_STATE, '.dirty=false;'); + var w = width + while (w >= 1) { + // we can only use mipmaps on a square image, + // so we can simply use the width and ignore the height: + total += s * w * w + w /= 2 } - scope(block); + return total + } else { + return s * width * height } +} - function emitSetOptions (env, scope, options, filter) { - var shared = env.shared; - var CURRENT_VARS = env.current; - var CURRENT_STATE = shared.current; - var GL = shared.gl; - sortState(Object.keys(options)).forEach(function (param) { - var defn = options[param]; - if (filter && !filter(defn)) { - return - } - var variable = defn.append(env, scope); - if (GL_FLAGS[param]) { - var flag = GL_FLAGS[param]; - if (isStatic(defn)) { - if (variable) { - scope(GL, '.enable(', flag, ');'); - } else { - scope(GL, '.disable(', flag, ');'); - } - } else { - scope(env.cond(variable) - .then(GL, '.enable(', flag, ');') - .else(GL, '.disable(', flag, ');')); - } - scope(CURRENT_STATE, '.', param, '=', variable, ';'); - } else if (isArrayLike(variable)) { - var CURRENT = CURRENT_VARS[param]; - scope( - GL, '.', GL_VARIABLES[param], '(', variable, ');', - variable.map(function (v, i) { - return CURRENT + '[' + i + ']=' + v - }).join(';'), ';'); - } else { - scope( - GL, '.', GL_VARIABLES[param], '(', variable, ');', - CURRENT_STATE, '.', param, '=', variable, ';'); - } - }); +function createTextureSet ( + gl, extensions, limits, reglPoll, contextState, stats, config) { + // ------------------------------------------------------- + // Initialize constants and parameter tables here + // ------------------------------------------------------- + var mipmapHint = { + "don't care": GL_DONT_CARE, + 'dont care': GL_DONT_CARE, + 'nice': GL_NICEST, + 'fast': GL_FASTEST } - function injectExtensions (env, scope) { - if (extInstancing) { - env.instancing = scope.def( - env.shared.extensions, '.angle_instanced_arrays'); - } + var wrapModes = { + 'repeat': GL_REPEAT, + 'clamp': GL_CLAMP_TO_EDGE$1, + 'mirror': GL_MIRRORED_REPEAT } - function emitProfile (env, scope, args, useScope, incrementCounter) { - var shared = env.shared; - var STATS = env.stats; - var CURRENT_STATE = shared.current; - var TIMER = shared.timer; - var profileArg = args.profile; + var magFilters = { + 'nearest': GL_NEAREST$1, + 'linear': GL_LINEAR + } - function perfCounter () { - if (typeof performance === 'undefined') { - return 'Date.now()' - } else { - return 'performance.now()' - } - } + var minFilters = extend({ + 'mipmap': GL_LINEAR_MIPMAP_LINEAR$1, + 'nearest mipmap nearest': GL_NEAREST_MIPMAP_NEAREST$1, + 'linear mipmap nearest': GL_LINEAR_MIPMAP_NEAREST$1, + 'nearest mipmap linear': GL_NEAREST_MIPMAP_LINEAR$1, + 'linear mipmap linear': GL_LINEAR_MIPMAP_LINEAR$1 + }, magFilters) - var CPU_START, QUERY_COUNTER; - function emitProfileStart (block) { - CPU_START = scope.def(); - block(CPU_START, '=', perfCounter(), ';'); - if (typeof incrementCounter === 'string') { - block(STATS, '.count+=', incrementCounter, ';'); - } else { - block(STATS, '.count++;'); - } - if (timer) { - if (useScope) { - QUERY_COUNTER = scope.def(); - block(QUERY_COUNTER, '=', TIMER, '.getNumPendingQueries();'); - } else { - block(TIMER, '.beginQuery(', STATS, ');'); - } - } - } + var colorSpace = { + 'none': 0, + 'browser': GL_BROWSER_DEFAULT_WEBGL + } - function emitProfileEnd (block) { - block(STATS, '.cpuTime+=', perfCounter(), '-', CPU_START, ';'); - if (timer) { - if (useScope) { - block(TIMER, '.pushScopeStats(', - QUERY_COUNTER, ',', - TIMER, '.getNumPendingQueries(),', - STATS, ');'); - } else { - block(TIMER, '.endQuery();'); - } - } - } + var textureTypes = { + 'uint8': GL_UNSIGNED_BYTE$5, + 'rgba4': GL_UNSIGNED_SHORT_4_4_4_4$1, + 'rgb565': GL_UNSIGNED_SHORT_5_6_5$1, + 'rgb5 a1': GL_UNSIGNED_SHORT_5_5_5_1$1 + } - function scopeProfile (value) { - var prev = scope.def(CURRENT_STATE, '.profile'); - scope(CURRENT_STATE, '.profile=', value, ';'); - scope.exit(CURRENT_STATE, '.profile=', prev, ';'); - } + var textureFormats = { + 'alpha': GL_ALPHA, + 'luminance': GL_LUMINANCE, + 'luminance alpha': GL_LUMINANCE_ALPHA, + 'rgb': GL_RGB, + 'rgba': GL_RGBA$1, + 'rgba4': GL_RGBA4, + 'rgb5 a1': GL_RGB5_A1, + 'rgb565': GL_RGB565 + } - var USE_PROFILE; - if (profileArg) { - if (isStatic(profileArg)) { - if (profileArg.enable) { - emitProfileStart(scope); - emitProfileEnd(scope.exit); - scopeProfile('true'); - } else { - scopeProfile('false'); - } - return - } - USE_PROFILE = profileArg.append(env, scope); - scopeProfile(USE_PROFILE); - } else { - USE_PROFILE = scope.def(CURRENT_STATE, '.profile'); - } + var compressedTextureFormats = {} - var start = env.block(); - emitProfileStart(start); - scope('if(', USE_PROFILE, '){', start, '}'); - var end = env.block(); - emitProfileEnd(end); - scope.exit('if(', USE_PROFILE, '){', end, '}'); + if (extensions.ext_srgb) { + textureFormats.srgb = GL_SRGB_EXT + textureFormats.srgba = GL_SRGB_ALPHA_EXT } - function emitAttributes (env, scope, args, attributes, filter) { - var shared = env.shared; + if (extensions.oes_texture_float) { + textureTypes.float32 = textureTypes.float = GL_FLOAT$4 + } - function typeLength (x) { - switch (x) { - case GL_FLOAT_VEC2: - case GL_INT_VEC2: - case GL_BOOL_VEC2: - return 2 - case GL_FLOAT_VEC3: - case GL_INT_VEC3: - case GL_BOOL_VEC3: - return 3 - case GL_FLOAT_VEC4: - case GL_INT_VEC4: - case GL_BOOL_VEC4: - return 4 - default: - return 1 - } - } + if (extensions.oes_texture_half_float) { + textureTypes['float16'] = textureTypes['half float'] = GL_HALF_FLOAT_OES$1 + } - function emitBindAttribute (ATTRIBUTE, size, record) { - var GL = shared.gl; + if (extensions.webgl_depth_texture) { + extend(textureFormats, { + 'depth': GL_DEPTH_COMPONENT, + 'depth stencil': GL_DEPTH_STENCIL + }) - var LOCATION = scope.def(ATTRIBUTE, '.location'); - var BINDING = scope.def(shared.attributes, '[', LOCATION, ']'); + extend(textureTypes, { + 'uint16': GL_UNSIGNED_SHORT$3, + 'uint32': GL_UNSIGNED_INT$3, + 'depth stencil': GL_UNSIGNED_INT_24_8_WEBGL$1 + }) + } - var STATE = record.state; - var BUFFER = record.buffer; - var CONST_COMPONENTS = [ - record.x, - record.y, - record.z, - record.w - ]; + if (extensions.webgl_compressed_texture_s3tc) { + extend(compressedTextureFormats, { + 'rgb s3tc dxt1': GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + 'rgba s3tc dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + 'rgba s3tc dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + 'rgba s3tc dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT + }) + } - var COMMON_KEYS = [ - 'buffer', - 'normalized', - 'offset', - 'stride' - ]; + if (extensions.webgl_compressed_texture_atc) { + extend(compressedTextureFormats, { + 'rgb atc': GL_COMPRESSED_RGB_ATC_WEBGL, + 'rgba atc explicit alpha': GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, + 'rgba atc interpolated alpha': GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL + }) + } - function emitBuffer () { - scope( - 'if(!', BINDING, '.buffer){', - GL, '.enableVertexAttribArray(', LOCATION, ');}'); + if (extensions.webgl_compressed_texture_pvrtc) { + extend(compressedTextureFormats, { + 'rgb pvrtc 4bppv1': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, + 'rgb pvrtc 2bppv1': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, + 'rgba pvrtc 4bppv1': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, + 'rgba pvrtc 2bppv1': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG + }) + } - var TYPE = record.type; - var SIZE; - if (!record.size) { - SIZE = size; - } else { - SIZE = scope.def(record.size, '||', size); - } + if (extensions.webgl_compressed_texture_etc1) { + compressedTextureFormats['rgb etc1'] = GL_COMPRESSED_RGB_ETC1_WEBGL + } - scope('if(', - BINDING, '.type!==', TYPE, '||', - BINDING, '.size!==', SIZE, '||', - COMMON_KEYS.map(function (key) { - return BINDING + '.' + key + '!==' + record[key] - }).join('||'), - '){', - GL, '.bindBuffer(', GL_ARRAY_BUFFER$1, ',', BUFFER, '.buffer);', - GL, '.vertexAttribPointer(', [ - LOCATION, - SIZE, - TYPE, - record.normalized, - record.stride, - record.offset - ], ');', - BINDING, '.type=', TYPE, ';', - BINDING, '.size=', SIZE, ';', - COMMON_KEYS.map(function (key) { - return BINDING + '.' + key + '=' + record[key] + ';' - }).join(''), - '}'); + // Copy over all texture formats + var supportedCompressedFormats = Array.prototype.slice.call( + gl.getParameter(GL_COMPRESSED_TEXTURE_FORMATS)) + Object.keys(compressedTextureFormats).forEach(function (name) { + var format = compressedTextureFormats[name] + if (supportedCompressedFormats.indexOf(format) >= 0) { + textureFormats[name] = format + } + }) + + var supportedFormats = Object.keys(textureFormats) + limits.textureFormats = supportedFormats + + // associate with every format string its + // corresponding GL-value. + var textureFormatsInvert = [] + Object.keys(textureFormats).forEach(function (key) { + var val = textureFormats[key] + textureFormatsInvert[val] = key + }) - if (extInstancing) { - var DIVISOR = record.divisor; - scope( - 'if(', BINDING, '.divisor!==', DIVISOR, '){', - env.instancing, '.vertexAttribDivisorANGLE(', [LOCATION, DIVISOR], ');', - BINDING, '.divisor=', DIVISOR, ';}'); - } - } + // associate with every type string its + // corresponding GL-value. + var textureTypesInvert = [] + Object.keys(textureTypes).forEach(function (key) { + var val = textureTypes[key] + textureTypesInvert[val] = key + }) - function emitConstant () { - scope( - 'if(', BINDING, '.buffer){', - GL, '.disableVertexAttribArray(', LOCATION, ');', - '}if(', CUTE_COMPONENTS.map(function (c, i) { - return BINDING + '.' + c + '!==' + CONST_COMPONENTS[i] - }).join('||'), '){', - GL, '.vertexAttrib4f(', LOCATION, ',', CONST_COMPONENTS, ');', - CUTE_COMPONENTS.map(function (c, i) { - return BINDING + '.' + c + '=' + CONST_COMPONENTS[i] + ';' - }).join(''), - '}'); - } + var magFiltersInvert = [] + Object.keys(magFilters).forEach(function (key) { + var val = magFilters[key] + magFiltersInvert[val] = key + }) - if (STATE === ATTRIB_STATE_POINTER) { - emitBuffer(); - } else if (STATE === ATTRIB_STATE_CONSTANT) { - emitConstant(); - } else { - scope('if(', STATE, '===', ATTRIB_STATE_POINTER, '){'); - emitBuffer(); - scope('}else{'); - emitConstant(); - scope('}'); - } + var minFiltersInvert = [] + Object.keys(minFilters).forEach(function (key) { + var val = minFilters[key] + minFiltersInvert[val] = key + }) + + var wrapModesInvert = [] + Object.keys(wrapModes).forEach(function (key) { + var val = wrapModes[key] + wrapModesInvert[val] = key + }) + + // colorFormats[] gives the format (channels) associated to an + // internalformat + var colorFormats = supportedFormats.reduce(function (color, key) { + var glenum = textureFormats[key] + if (glenum === GL_LUMINANCE || + glenum === GL_ALPHA || + glenum === GL_LUMINANCE || + glenum === GL_LUMINANCE_ALPHA || + glenum === GL_DEPTH_COMPONENT || + glenum === GL_DEPTH_STENCIL || + (extensions.ext_srgb && + (glenum === GL_SRGB_EXT || + glenum === GL_SRGB_ALPHA_EXT))) { + color[glenum] = glenum + } else if (glenum === GL_RGB5_A1 || key.indexOf('rgba') >= 0) { + color[glenum] = GL_RGBA$1 + } else { + color[glenum] = GL_RGB } + return color + }, {}) - attributes.forEach(function (attribute) { - var name = attribute.name; - var arg = args.attributes[name]; - var record; - if (arg) { - if (!filter(arg)) { - return - } - record = arg.append(env, scope); - } else { - if (!filter(SCOPE_DECL)) { - return - } - var scopeAttrib = env.scopeAttrib(name); - check$1.optional(function () { - env.assert(scope, - scopeAttrib + '.state', - 'missing attribute ' + name); - }); - record = {}; - Object.keys(new AttributeRecord()).forEach(function (key) { - record[key] = scope.def(scopeAttrib, '.', key); - }); - } - emitBindAttribute( - env.link(attribute), typeLength(attribute.info.type), record); - }); + function TexFlags () { + // format info + this.internalformat = GL_RGBA$1 + this.format = GL_RGBA$1 + this.type = GL_UNSIGNED_BYTE$5 + this.compressed = false + + // pixel storage + this.premultiplyAlpha = false + this.flipY = false + this.unpackAlignment = 1 + this.colorSpace = GL_BROWSER_DEFAULT_WEBGL + + // shape info + this.width = 0 + this.height = 0 + this.channels = 0 } - function emitUniforms (env, scope, args, uniforms, filter) { - var shared = env.shared; - var GL = shared.gl; + function copyFlags (result, other) { + result.internalformat = other.internalformat + result.format = other.format + result.type = other.type + result.compressed = other.compressed - var infix; - for (var i = 0; i < uniforms.length; ++i) { - var uniform = uniforms[i]; - var name = uniform.name; - var type = uniform.info.type; - var arg = args.uniforms[name]; - var UNIFORM = env.link(uniform); - var LOCATION = UNIFORM + '.location'; - - var VALUE; - if (arg) { - if (!filter(arg)) { - continue - } - if (isStatic(arg)) { - var value = arg.value; - check$1.command( - value !== null && typeof value !== 'undefined', - 'missing uniform "' + name + '"', env.commandStr); - if (type === GL_SAMPLER_2D || type === GL_SAMPLER_CUBE) { - check$1.command( - typeof value === 'function' && - ((type === GL_SAMPLER_2D && - (value._reglType === 'texture2d' || - value._reglType === 'framebuffer')) || - (type === GL_SAMPLER_CUBE && - (value._reglType === 'textureCube' || - value._reglType === 'framebufferCube'))), - 'invalid texture for uniform ' + name, env.commandStr); - var TEX_VALUE = env.link(value._texture || value.color[0]._texture); - scope(GL, '.uniform1i(', LOCATION, ',', TEX_VALUE + '.bind());'); - scope.exit(TEX_VALUE, '.unbind();'); - } else if ( - type === GL_FLOAT_MAT2 || - type === GL_FLOAT_MAT3 || - type === GL_FLOAT_MAT4) { - check$1.optional(function () { - check$1.command(isArrayLike(value), - 'invalid matrix for uniform ' + name, env.commandStr); - check$1.command( - (type === GL_FLOAT_MAT2 && value.length === 4) || - (type === GL_FLOAT_MAT3 && value.length === 9) || - (type === GL_FLOAT_MAT4 && value.length === 16), - 'invalid length for matrix uniform ' + name, env.commandStr); - }); - var MAT_VALUE = env.global.def('new Float32Array([' + - Array.prototype.slice.call(value) + '])'); - var dim = 2; - if (type === GL_FLOAT_MAT3) { - dim = 3; - } else if (type === GL_FLOAT_MAT4) { - dim = 4; - } - scope( - GL, '.uniformMatrix', dim, 'fv(', - LOCATION, ',false,', MAT_VALUE, ');'); - } else { - switch (type) { - case GL_FLOAT$7: - check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr); - infix = '1f'; - break - case GL_FLOAT_VEC2: - check$1.command( - isArrayLike(value) && value.length === 2, - 'uniform ' + name, env.commandStr); - infix = '2f'; - break - case GL_FLOAT_VEC3: - check$1.command( - isArrayLike(value) && value.length === 3, - 'uniform ' + name, env.commandStr); - infix = '3f'; - break - case GL_FLOAT_VEC4: - check$1.command( - isArrayLike(value) && value.length === 4, - 'uniform ' + name, env.commandStr); - infix = '4f'; - break - case GL_BOOL: - check$1.commandType(value, 'boolean', 'uniform ' + name, env.commandStr); - infix = '1i'; - break - case GL_INT$3: - check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr); - infix = '1i'; - break - case GL_BOOL_VEC2: - check$1.command( - isArrayLike(value) && value.length === 2, - 'uniform ' + name, env.commandStr); - infix = '2i'; - break - case GL_INT_VEC2: - check$1.command( - isArrayLike(value) && value.length === 2, - 'uniform ' + name, env.commandStr); - infix = '2i'; - break - case GL_BOOL_VEC3: - check$1.command( - isArrayLike(value) && value.length === 3, - 'uniform ' + name, env.commandStr); - infix = '3i'; - break - case GL_INT_VEC3: - check$1.command( - isArrayLike(value) && value.length === 3, - 'uniform ' + name, env.commandStr); - infix = '3i'; - break - case GL_BOOL_VEC4: - check$1.command( - isArrayLike(value) && value.length === 4, - 'uniform ' + name, env.commandStr); - infix = '4i'; - break - case GL_INT_VEC4: - check$1.command( - isArrayLike(value) && value.length === 4, - 'uniform ' + name, env.commandStr); - infix = '4i'; - break - } - scope(GL, '.uniform', infix, '(', LOCATION, ',', - isArrayLike(value) ? Array.prototype.slice.call(value) : value, - ');'); - } - continue - } else { - VALUE = arg.append(env, scope); - } - } else { - if (!filter(SCOPE_DECL)) { - continue - } - VALUE = scope.def(shared.uniforms, '[', stringStore.id(name), ']'); - } + result.premultiplyAlpha = other.premultiplyAlpha + result.flipY = other.flipY + result.unpackAlignment = other.unpackAlignment + result.colorSpace = other.colorSpace - if (type === GL_SAMPLER_2D) { - scope( - 'if(', VALUE, '&&', VALUE, '._reglType==="framebuffer"){', - VALUE, '=', VALUE, '.color[0];', - '}'); - } else if (type === GL_SAMPLER_CUBE) { - scope( - 'if(', VALUE, '&&', VALUE, '._reglType==="framebufferCube"){', - VALUE, '=', VALUE, '.color[0];', - '}'); - } + result.width = other.width + result.height = other.height + result.channels = other.channels + } - // perform type validation - check$1.optional(function () { - function check (pred, message) { - env.assert(scope, pred, - 'bad data or missing for uniform "' + name + '". ' + message); - } + function parseFlags (flags, options) { + if (typeof options !== 'object' || !options) { + return + } - function checkType (type) { - check( - 'typeof ' + VALUE + '==="' + type + '"', - 'invalid type, expected ' + type); - } + if ('premultiplyAlpha' in options) { + check$1.type(options.premultiplyAlpha, 'boolean', + 'invalid premultiplyAlpha') + flags.premultiplyAlpha = options.premultiplyAlpha + } - function checkVector (n, type) { - check( - shared.isArrayLike + '(' + VALUE + ')&&' + VALUE + '.length===' + n, - 'invalid vector, should have length ' + n, env.commandStr); - } + if ('flipY' in options) { + check$1.type(options.flipY, 'boolean', + 'invalid texture flip') + flags.flipY = options.flipY + } - function checkTexture (target) { - check( - 'typeof ' + VALUE + '==="function"&&' + - VALUE + '._reglType==="texture' + - (target === GL_TEXTURE_2D$2 ? '2d' : 'Cube') + '"', - 'invalid texture type', env.commandStr); - } + if ('alignment' in options) { + check$1.oneOf(options.alignment, [1, 2, 4, 8], + 'invalid texture unpack alignment') + flags.unpackAlignment = options.alignment + } - switch (type) { - case GL_INT$3: - checkType('number'); - break - case GL_INT_VEC2: - checkVector(2, 'number'); - break - case GL_INT_VEC3: - checkVector(3, 'number'); - break - case GL_INT_VEC4: - checkVector(4, 'number'); - break - case GL_FLOAT$7: - checkType('number'); - break - case GL_FLOAT_VEC2: - checkVector(2, 'number'); - break - case GL_FLOAT_VEC3: - checkVector(3, 'number'); - break - case GL_FLOAT_VEC4: - checkVector(4, 'number'); - break - case GL_BOOL: - checkType('boolean'); - break - case GL_BOOL_VEC2: - checkVector(2, 'boolean'); - break - case GL_BOOL_VEC3: - checkVector(3, 'boolean'); - break - case GL_BOOL_VEC4: - checkVector(4, 'boolean'); - break - case GL_FLOAT_MAT2: - checkVector(4, 'number'); - break - case GL_FLOAT_MAT3: - checkVector(9, 'number'); - break - case GL_FLOAT_MAT4: - checkVector(16, 'number'); - break - case GL_SAMPLER_2D: - checkTexture(GL_TEXTURE_2D$2); - break - case GL_SAMPLER_CUBE: - checkTexture(GL_TEXTURE_CUBE_MAP$1); - break - } - }); + if ('colorSpace' in options) { + check$1.parameter(options.colorSpace, colorSpace, + 'invalid colorSpace') + flags.colorSpace = colorSpace[options.colorSpace] + } - var unroll = 1; - switch (type) { - case GL_SAMPLER_2D: - case GL_SAMPLER_CUBE: - var TEX = scope.def(VALUE, '._texture'); - scope(GL, '.uniform1i(', LOCATION, ',', TEX, '.bind());'); - scope.exit(TEX, '.unbind();'); - continue + if ('type' in options) { + var type = options.type + check$1(extensions.oes_texture_float || + !(type === 'float' || type === 'float32'), + 'you must enable the OES_texture_float extension in order to use floating point textures.') + check$1(extensions.oes_texture_half_float || + !(type === 'half float' || type === 'float16'), + 'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.') + check$1(extensions.webgl_depth_texture || + !(type === 'uint16' || type === 'uint32' || type === 'depth stencil'), + 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.') + check$1.parameter(type, textureTypes, + 'invalid texture type') + flags.type = textureTypes[type] + } + + var w = flags.width + var h = flags.height + var c = flags.channels + var hasChannels = false + if ('shape' in options) { + check$1(Array.isArray(options.shape) && options.shape.length >= 2, + 'shape must be an array') + w = options.shape[0] + h = options.shape[1] + if (options.shape.length === 3) { + c = options.shape[2] + check$1(c > 0 && c <= 4, 'invalid number of channels') + hasChannels = true + } + check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width') + check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height') + } else { + if ('radius' in options) { + w = h = options.radius + check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid radius') + } + if ('width' in options) { + w = options.width + check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width') + } + if ('height' in options) { + h = options.height + check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height') + } + if ('channels' in options) { + c = options.channels + check$1(c > 0 && c <= 4, 'invalid number of channels') + hasChannels = true + } + } + flags.width = w | 0 + flags.height = h | 0 + flags.channels = c | 0 - case GL_INT$3: - case GL_BOOL: - infix = '1i'; - break + var hasFormat = false + if ('format' in options) { + var formatStr = options.format + check$1(extensions.webgl_depth_texture || + !(formatStr === 'depth' || formatStr === 'depth stencil'), + 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.') + check$1.parameter(formatStr, textureFormats, + 'invalid texture format') + var internalformat = flags.internalformat = textureFormats[formatStr] + flags.format = colorFormats[internalformat] + if (formatStr in textureTypes) { + if (!('type' in options)) { + flags.type = textureTypes[formatStr] + } + } + if (formatStr in compressedTextureFormats) { + flags.compressed = true + } + hasFormat = true + } - case GL_INT_VEC2: - case GL_BOOL_VEC2: - infix = '2i'; - unroll = 2; - break + // Reconcile channels and format + if (!hasChannels && hasFormat) { + flags.channels = FORMAT_CHANNELS[flags.format] + } else if (hasChannels && !hasFormat) { + if (flags.channels !== CHANNELS_FORMAT[flags.format]) { + flags.format = flags.internalformat = CHANNELS_FORMAT[flags.channels] + } + } else if (hasFormat && hasChannels) { + check$1( + flags.channels === FORMAT_CHANNELS[flags.format], + 'number of channels inconsistent with specified format') + } + } - case GL_INT_VEC3: - case GL_BOOL_VEC3: - infix = '3i'; - unroll = 3; - break + function setFlags (flags) { + gl.pixelStorei(GL_UNPACK_FLIP_Y_WEBGL, flags.flipY) + gl.pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL, flags.premultiplyAlpha) + gl.pixelStorei(GL_UNPACK_COLORSPACE_CONVERSION_WEBGL, flags.colorSpace) + gl.pixelStorei(GL_UNPACK_ALIGNMENT, flags.unpackAlignment) + } - case GL_INT_VEC4: - case GL_BOOL_VEC4: - infix = '4i'; - unroll = 4; - break + // ------------------------------------------------------- + // Tex image data + // ------------------------------------------------------- + function TexImage () { + TexFlags.call(this) - case GL_FLOAT$7: - infix = '1f'; - break + this.xOffset = 0 + this.yOffset = 0 - case GL_FLOAT_VEC2: - infix = '2f'; - unroll = 2; - break + // data + this.data = null + this.needsFree = false - case GL_FLOAT_VEC3: - infix = '3f'; - unroll = 3; - break + // html element + this.element = null - case GL_FLOAT_VEC4: - infix = '4f'; - unroll = 4; - break + // copyTexImage info + this.needsCopy = false + } - case GL_FLOAT_MAT2: - infix = 'Matrix2fv'; - break + function parseImage (image, options) { + var data = null + if (isPixelData(options)) { + data = options + } else if (options) { + check$1.type(options, 'object', 'invalid pixel data type') + parseFlags(image, options) + if ('x' in options) { + image.xOffset = options.x | 0 + } + if ('y' in options) { + image.yOffset = options.y | 0 + } + if (isPixelData(options.data)) { + data = options.data + } + } - case GL_FLOAT_MAT3: - infix = 'Matrix3fv'; - break + check$1( + !image.compressed || + data instanceof Uint8Array, + 'compressed texture data must be stored in a uint8array') - case GL_FLOAT_MAT4: - infix = 'Matrix4fv'; - break + if (options.copy) { + check$1(!data, 'can not specify copy and data field for the same texture') + var viewW = contextState.viewportWidth + var viewH = contextState.viewportHeight + image.width = image.width || (viewW - image.xOffset) + image.height = image.height || (viewH - image.yOffset) + image.needsCopy = true + check$1(image.xOffset >= 0 && image.xOffset < viewW && + image.yOffset >= 0 && image.yOffset < viewH && + image.width > 0 && image.width <= viewW && + image.height > 0 && image.height <= viewH, + 'copy texture read out of bounds') + } else if (!data) { + image.width = image.width || 1 + image.height = image.height || 1 + image.channels = image.channels || 4 + } else if (isTypedArray(data)) { + image.channels = image.channels || 4 + image.data = data + if (!('type' in options) && image.type === GL_UNSIGNED_BYTE$5) { + image.type = typedArrayCode$1(data) } - - scope(GL, '.uniform', infix, '(', LOCATION, ','); - if (infix.charAt(0) === 'M') { - var matSize = Math.pow(type - GL_FLOAT_MAT2 + 2, 2); - var STORAGE = env.global.def('new Float32Array(', matSize, ')'); - scope( - 'false,(Array.isArray(', VALUE, ')||', VALUE, ' instanceof Float32Array)?', VALUE, ':(', - loop(matSize, function (i) { - return STORAGE + '[' + i + ']=' + VALUE + '[' + i + ']' - }), ',', STORAGE, ')'); - } else if (unroll > 1) { - scope(loop(unroll, function (i) { - return VALUE + '[' + i + ']' - })); + } else if (isNumericArray(data)) { + image.channels = image.channels || 4 + convertData(image, data) + image.alignment = 1 + image.needsFree = true + } else if (isNDArrayLike(data)) { + var array = data.data + if (!Array.isArray(array) && image.type === GL_UNSIGNED_BYTE$5) { + image.type = typedArrayCode$1(array) + } + var shape = data.shape + var stride = data.stride + var shapeX, shapeY, shapeC, strideX, strideY, strideC + if (shape.length === 3) { + shapeC = shape[2] + strideC = stride[2] + } else { + check$1(shape.length === 2, 'invalid ndarray pixel data, must be 2 or 3D') + shapeC = 1 + strideC = 1 + } + shapeX = shape[0] + shapeY = shape[1] + strideX = stride[0] + strideY = stride[1] + image.alignment = 1 + image.width = shapeX + image.height = shapeY + image.channels = shapeC + image.format = image.internalformat = CHANNELS_FORMAT[shapeC] + image.needsFree = true + transposeData(image, array, strideX, strideY, strideC, data.offset) + } else if (isCanvasElement(data) || isOffscreenCanvas(data) || isContext2D(data)) { + if (isCanvasElement(data) || isOffscreenCanvas(data)) { + image.element = data } else { - scope(VALUE); + image.element = data.canvas + } + image.width = image.element.width + image.height = image.element.height + image.channels = 4 + } else if (isBitmap(data)) { + image.element = data + image.width = data.width + image.height = data.height + image.channels = 4 + } else if (isImageElement(data)) { + image.element = data + image.width = data.naturalWidth + image.height = data.naturalHeight + image.channels = 4 + } else if (isVideoElement(data)) { + image.element = data + image.width = data.videoWidth + image.height = data.videoHeight + image.channels = 4 + } else if (isRectArray(data)) { + var w = image.width || data[0].length + var h = image.height || data.length + var c = image.channels + if (isArrayLike(data[0][0])) { + c = c || data[0][0].length + } else { + c = c || 1 + } + var arrayShape = flattenUtils.shape(data) + var n = 1 + for (var dd = 0; dd < arrayShape.length; ++dd) { + n *= arrayShape[dd] } - scope(');'); + var allocData = preConvert(image, n) + flattenUtils.flatten(data, arrayShape, '', allocData) + postConvert(image, allocData) + image.alignment = 1 + image.width = w + image.height = h + image.channels = c + image.format = image.internalformat = CHANNELS_FORMAT[c] + image.needsFree = true + } + + if (image.type === GL_FLOAT$4) { + check$1(limits.extensions.indexOf('oes_texture_float') >= 0, + 'oes_texture_float extension not enabled') + } else if (image.type === GL_HALF_FLOAT_OES$1) { + check$1(limits.extensions.indexOf('oes_texture_half_float') >= 0, + 'oes_texture_half_float extension not enabled') } + + // do compressed texture validation here. } - function emitDraw (env, outer, inner, args) { - var shared = env.shared; - var GL = shared.gl; - var DRAW_STATE = shared.draw; + function setImage (info, target, miplevel) { + var element = info.element + var data = info.data + var internalformat = info.internalformat + var format = info.format + var type = info.type + var width = info.width + var height = info.height - var drawOptions = args.draw; + setFlags(info) - function emitElements () { - var defn = drawOptions.elements; - var ELEMENTS; - var scope = outer; - if (defn) { - if ((defn.contextDep && args.contextDynamic) || defn.propDep) { - scope = inner; - } - ELEMENTS = defn.append(env, scope); - } else { - ELEMENTS = scope.def(DRAW_STATE, '.', S_ELEMENTS); - } - if (ELEMENTS) { - scope( - 'if(' + ELEMENTS + ')' + - GL + '.bindBuffer(' + GL_ELEMENT_ARRAY_BUFFER$1 + ',' + ELEMENTS + '.buffer.buffer);'); - } - return ELEMENTS + if (element) { + gl.texImage2D(target, miplevel, format, format, type, element) + } else if (info.compressed) { + gl.compressedTexImage2D(target, miplevel, internalformat, width, height, 0, data) + } else if (info.needsCopy) { + reglPoll() + gl.copyTexImage2D( + target, miplevel, format, info.xOffset, info.yOffset, width, height, 0) + } else { + gl.texImage2D(target, miplevel, format, width, height, 0, format, type, data || null) } + } - function emitCount () { - var defn = drawOptions.count; - var COUNT; - var scope = outer; - if (defn) { - if ((defn.contextDep && args.contextDynamic) || defn.propDep) { - scope = inner; - } - COUNT = defn.append(env, scope); - check$1.optional(function () { - if (defn.MISSING) { - env.assert(outer, 'false', 'missing vertex count'); - } - if (defn.DYNAMIC) { - env.assert(scope, COUNT + '>=0', 'missing vertex count'); - } - }); - } else { - COUNT = scope.def(DRAW_STATE, '.', S_COUNT); - check$1.optional(function () { - env.assert(scope, COUNT + '>=0', 'missing vertex count'); - }); - } - return COUNT + function setSubImage (info, target, x, y, miplevel) { + var element = info.element + var data = info.data + var internalformat = info.internalformat + var format = info.format + var type = info.type + var width = info.width + var height = info.height + + setFlags(info) + + if (element) { + gl.texSubImage2D( + target, miplevel, x, y, format, type, element) + } else if (info.compressed) { + gl.compressedTexSubImage2D( + target, miplevel, x, y, internalformat, width, height, data) + } else if (info.needsCopy) { + reglPoll() + gl.copyTexSubImage2D( + target, miplevel, x, y, info.xOffset, info.yOffset, width, height) + } else { + gl.texSubImage2D( + target, miplevel, x, y, width, height, format, type, data) } + } - var ELEMENTS = emitElements(); - function emitValue (name) { - var defn = drawOptions[name]; - if (defn) { - if ((defn.contextDep && args.contextDynamic) || defn.propDep) { - return defn.append(env, inner) - } else { - return defn.append(env, outer) + // texImage pool + var imagePool = [] + + function allocImage () { + return imagePool.pop() || new TexImage() + } + + function freeImage (image) { + if (image.needsFree) { + pool.freeType(image.data) + } + TexImage.call(image) + imagePool.push(image) + } + + // ------------------------------------------------------- + // Mip map + // ------------------------------------------------------- + function MipMap () { + TexFlags.call(this) + + this.genMipmaps = false + this.mipmapHint = GL_DONT_CARE + this.mipmask = 0 + this.images = Array(16) + } + + function parseMipMapFromShape (mipmap, width, height) { + var img = mipmap.images[0] = allocImage() + mipmap.mipmask = 1 + img.width = mipmap.width = width + img.height = mipmap.height = height + img.channels = mipmap.channels = 4 + } + + function parseMipMapFromObject (mipmap, options) { + var imgData = null + if (isPixelData(options)) { + imgData = mipmap.images[0] = allocImage() + copyFlags(imgData, mipmap) + parseImage(imgData, options) + mipmap.mipmask = 1 + } else { + parseFlags(mipmap, options) + if (Array.isArray(options.mipmap)) { + var mipData = options.mipmap + for (var i = 0; i < mipData.length; ++i) { + imgData = mipmap.images[i] = allocImage() + copyFlags(imgData, mipmap) + imgData.width >>= i + imgData.height >>= i + parseImage(imgData, mipData[i]) + mipmap.mipmask |= (1 << i) } } else { - return outer.def(DRAW_STATE, '.', name) + imgData = mipmap.images[0] = allocImage() + copyFlags(imgData, mipmap) + parseImage(imgData, options) + mipmap.mipmask = 1 } } + copyFlags(mipmap, mipmap.images[0]) + + // For textures of the compressed format WEBGL_compressed_texture_s3tc + // we must have that + // + // "When level equals zero width and height must be a multiple of 4. + // When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. " + // + // but we do not yet support having multiple mipmap levels for compressed textures, + // so we only test for level zero. - var PRIMITIVE = emitValue(S_PRIMITIVE); - var OFFSET = emitValue(S_OFFSET); + if ( + mipmap.compressed && + ( + mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT || + mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || + mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT || + mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT + ) + ) { + check$1(mipmap.width % 4 === 0 && mipmap.height % 4 === 0, + 'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4') + } + } - var COUNT = emitCount(); - if (typeof COUNT === 'number') { - if (COUNT === 0) { + function setMipMap (mipmap, target) { + var images = mipmap.images + for (var i = 0; i < images.length; ++i) { + if (!images[i]) { return } - } else { - inner('if(', COUNT, '){'); - inner.exit('}'); + setImage(images[i], target, i) + } + } + + var mipPool = [] + + function allocMipMap () { + var result = mipPool.pop() || new MipMap() + TexFlags.call(result) + result.mipmask = 0 + for (var i = 0; i < 16; ++i) { + result.images[i] = null } + return result + } - var INSTANCES, EXT_INSTANCING; - if (extInstancing) { - INSTANCES = emitValue(S_INSTANCES); - EXT_INSTANCING = env.instancing; + function freeMipMap (mipmap) { + var images = mipmap.images + for (var i = 0; i < images.length; ++i) { + if (images[i]) { + freeImage(images[i]) + } + images[i] = null } + mipPool.push(mipmap) + } + + // ------------------------------------------------------- + // Tex info + // ------------------------------------------------------- + function TexInfo () { + this.minFilter = GL_NEAREST$1 + this.magFilter = GL_NEAREST$1 - var ELEMENT_TYPE = ELEMENTS + '.type'; + this.wrapS = GL_CLAMP_TO_EDGE$1 + this.wrapT = GL_CLAMP_TO_EDGE$1 - var elementsStatic = drawOptions.elements && isStatic(drawOptions.elements); + this.anisotropic = 1 - function emitInstancing () { - function drawElements () { - inner(EXT_INSTANCING, '.drawElementsInstancedANGLE(', [ - PRIMITIVE, - COUNT, - ELEMENT_TYPE, - OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$7 + ')>>1)', - INSTANCES - ], ');'); - } + this.genMipmaps = false + this.mipmapHint = GL_DONT_CARE + } - function drawArrays () { - inner(EXT_INSTANCING, '.drawArraysInstancedANGLE(', - [PRIMITIVE, OFFSET, COUNT, INSTANCES], ');'); + function parseTexInfo (info, options) { + if ('min' in options) { + var minFilter = options.min + check$1.parameter(minFilter, minFilters) + info.minFilter = minFilters[minFilter] + if (MIPMAP_FILTERS.indexOf(info.minFilter) >= 0 && !('faces' in options)) { + info.genMipmaps = true } + } - if (ELEMENTS) { - if (!elementsStatic) { - inner('if(', ELEMENTS, '){'); - drawElements(); - inner('}else{'); - drawArrays(); - inner('}'); - } else { - drawElements(); - } - } else { - drawArrays(); - } + if ('mag' in options) { + var magFilter = options.mag + check$1.parameter(magFilter, magFilters) + info.magFilter = magFilters[magFilter] } - function emitRegular () { - function drawElements () { - inner(GL + '.drawElements(' + [ - PRIMITIVE, - COUNT, - ELEMENT_TYPE, - OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$7 + ')>>1)' - ] + ');'); + var wrapS = info.wrapS + var wrapT = info.wrapT + if ('wrap' in options) { + var wrap = options.wrap + if (typeof wrap === 'string') { + check$1.parameter(wrap, wrapModes) + wrapS = wrapT = wrapModes[wrap] + } else if (Array.isArray(wrap)) { + check$1.parameter(wrap[0], wrapModes) + check$1.parameter(wrap[1], wrapModes) + wrapS = wrapModes[wrap[0]] + wrapT = wrapModes[wrap[1]] } - - function drawArrays () { - inner(GL + '.drawArrays(' + [PRIMITIVE, OFFSET, COUNT] + ');'); + } else { + if ('wrapS' in options) { + var optWrapS = options.wrapS + check$1.parameter(optWrapS, wrapModes) + wrapS = wrapModes[optWrapS] } - - if (ELEMENTS) { - if (!elementsStatic) { - inner('if(', ELEMENTS, '){'); - drawElements(); - inner('}else{'); - drawArrays(); - inner('}'); - } else { - drawElements(); - } - } else { - drawArrays(); + if ('wrapT' in options) { + var optWrapT = options.wrapT + check$1.parameter(optWrapT, wrapModes) + wrapT = wrapModes[optWrapT] } } + info.wrapS = wrapS + info.wrapT = wrapT - if (extInstancing && (typeof INSTANCES !== 'number' || INSTANCES >= 0)) { - if (typeof INSTANCES === 'string') { - inner('if(', INSTANCES, '>0){'); - emitInstancing(); - inner('}else if(', INSTANCES, '<0){'); - emitRegular(); - inner('}'); - } else { - emitInstancing(); + if ('anisotropic' in options) { + var anisotropic = options.anisotropic + check$1(typeof anisotropic === 'number' && + anisotropic >= 1 && anisotropic <= limits.maxAnisotropic, + 'aniso samples must be between 1 and ') + info.anisotropic = options.anisotropic + } + + if ('mipmap' in options) { + var hasMipMap = false + switch (typeof options.mipmap) { + case 'string': + check$1.parameter(options.mipmap, mipmapHint, + 'invalid mipmap hint') + info.mipmapHint = mipmapHint[options.mipmap] + info.genMipmaps = true + hasMipMap = true + break + + case 'boolean': + hasMipMap = info.genMipmaps = options.mipmap + break + + case 'object': + check$1(Array.isArray(options.mipmap), 'invalid mipmap type') + info.genMipmaps = false + hasMipMap = true + break + + default: + check$1.raise('invalid mipmap type') + } + if (hasMipMap && !('min' in options)) { + info.minFilter = GL_NEAREST_MIPMAP_NEAREST$1 } - } else { - emitRegular(); } } - function createBody (emitBody, parentEnv, args, program, count) { - var env = createREGLEnvironment(); - var scope = env.proc('body', count); - check$1.optional(function () { - env.commandStr = parentEnv.commandStr; - env.command = env.link(parentEnv.commandStr); - }); - if (extInstancing) { - env.instancing = scope.def( - env.shared.extensions, '.angle_instanced_arrays'); + function setTexInfo (info, target) { + gl.texParameteri(target, GL_TEXTURE_MIN_FILTER, info.minFilter) + gl.texParameteri(target, GL_TEXTURE_MAG_FILTER, info.magFilter) + gl.texParameteri(target, GL_TEXTURE_WRAP_S, info.wrapS) + gl.texParameteri(target, GL_TEXTURE_WRAP_T, info.wrapT) + if (extensions.ext_texture_filter_anisotropic) { + gl.texParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, info.anisotropic) + } + if (info.genMipmaps) { + gl.hint(GL_GENERATE_MIPMAP_HINT, info.mipmapHint) + gl.generateMipmap(target) } - emitBody(env, scope, args, program); - return env.compile().body } - // =================================================== - // =================================================== - // DRAW PROC - // =================================================== - // =================================================== - function emitDrawBody (env, draw, args, program) { - injectExtensions(env, draw); - emitAttributes(env, draw, args, program.attributes, function () { - return true - }); - emitUniforms(env, draw, args, program.uniforms, function () { - return true - }); - emitDraw(env, draw, draw, args); - } + // ------------------------------------------------------- + // Full texture object + // ------------------------------------------------------- + var textureCount = 0 + var textureSet = {} + var numTexUnits = limits.maxTextureUnits + var textureUnits = Array(numTexUnits).map(function () { + return null + }) - function emitDrawProc (env, args) { - var draw = env.proc('draw', 1); + function REGLTexture (target) { + TexFlags.call(this) + this.mipmask = 0 + this.internalformat = GL_RGBA$1 - injectExtensions(env, draw); + this.id = textureCount++ - emitContext(env, draw, args.context); - emitPollFramebuffer(env, draw, args.framebuffer); + this.refCount = 1 - emitPollState(env, draw, args); - emitSetOptions(env, draw, args.state); + this.target = target + this.texture = gl.createTexture() - emitProfile(env, draw, args, false, true); + this.unit = -1 + this.bindCount = 0 - var program = args.shader.progVar.append(env, draw); - draw(env.shared.gl, '.useProgram(', program, '.program);'); + this.texInfo = new TexInfo() - if (args.shader.program) { - emitDrawBody(env, draw, args, args.shader.program); - } else { - var drawCache = env.global.def('{}'); - var PROG_ID = draw.def(program, '.id'); - var CACHED_PROC = draw.def(drawCache, '[', PROG_ID, ']'); - draw( - env.cond(CACHED_PROC) - .then(CACHED_PROC, '.call(this,a0);') - .else( - CACHED_PROC, '=', drawCache, '[', PROG_ID, ']=', - env.link(function (program) { - return createBody(emitDrawBody, env, args, program, 1) - }), '(', program, ');', - CACHED_PROC, '.call(this,a0);')); + if (config.profile) { + this.stats = { size: 0 } } + } - if (Object.keys(args.state).length > 0) { - draw(env.shared.current, '.dirty=true;'); + function tempBind (texture) { + gl.activeTexture(GL_TEXTURE0$1) + gl.bindTexture(texture.target, texture.texture) + } + + function tempRestore () { + var prev = textureUnits[0] + if (prev) { + gl.bindTexture(prev.target, prev.texture) + } else { + gl.bindTexture(GL_TEXTURE_2D$1, null) } } - // =================================================== - // =================================================== - // BATCH PROC - // =================================================== - // =================================================== + function destroy (texture) { + var handle = texture.texture + check$1(handle, 'must not double destroy texture') + var unit = texture.unit + var target = texture.target + if (unit >= 0) { + gl.activeTexture(GL_TEXTURE0$1 + unit) + gl.bindTexture(target, null) + textureUnits[unit] = null + } + gl.deleteTexture(handle) + texture.texture = null + texture.params = null + texture.pixels = null + texture.refCount = 0 + delete textureSet[texture.id] + stats.textureCount-- + } - function emitBatchDynamicShaderBody (env, scope, args, program) { - env.batchId = 'a1'; + extend(REGLTexture.prototype, { + bind: function () { + var texture = this + texture.bindCount += 1 + var unit = texture.unit + if (unit < 0) { + for (var i = 0; i < numTexUnits; ++i) { + var other = textureUnits[i] + if (other) { + if (other.bindCount > 0) { + continue + } + other.unit = -1 + } + textureUnits[i] = texture + unit = i + break + } + if (unit >= numTexUnits) { + check$1.raise('insufficient number of texture units') + } + if (config.profile && stats.maxTextureUnits < (unit + 1)) { + stats.maxTextureUnits = unit + 1 // +1, since the units are zero-based + } + texture.unit = unit + gl.activeTexture(GL_TEXTURE0$1 + unit) + gl.bindTexture(texture.target, texture.texture) + } + return unit + }, - injectExtensions(env, scope); + unbind: function () { + this.bindCount -= 1 + }, - function all () { - return true + decRef: function () { + if (--this.refCount <= 0) { + destroy(this) + } } + }) - emitAttributes(env, scope, args, program.attributes, all); - emitUniforms(env, scope, args, program.uniforms, all); - emitDraw(env, scope, scope, args); - } + function createTexture2D (a, b) { + var texture = new REGLTexture(GL_TEXTURE_2D$1) + textureSet[texture.id] = texture + stats.textureCount++ - function emitBatchBody (env, scope, args, program) { - injectExtensions(env, scope); + function reglTexture2D (a, b) { + var texInfo = texture.texInfo + TexInfo.call(texInfo) + var mipData = allocMipMap() + + if (typeof a === 'number') { + if (typeof b === 'number') { + parseMipMapFromShape(mipData, a | 0, b | 0) + } else { + parseMipMapFromShape(mipData, a | 0, a | 0) + } + } else if (a) { + check$1.type(a, 'object', 'invalid arguments to regl.texture') + parseTexInfo(texInfo, a) + parseMipMapFromObject(mipData, a) + } else { + // empty textures get assigned a default shape of 1x1 + parseMipMapFromShape(mipData, 1, 1) + } - var contextDynamic = args.contextDep; + if (texInfo.genMipmaps) { + mipData.mipmask = (mipData.width << 1) - 1 + } + texture.mipmask = mipData.mipmask - var BATCH_ID = scope.def(); - var PROP_LIST = 'a0'; - var NUM_PROPS = 'a1'; - var PROPS = scope.def(); - env.shared.props = PROPS; - env.batchId = BATCH_ID; + copyFlags(texture, mipData) - var outer = env.scope(); - var inner = env.scope(); + check$1.texture2D(texInfo, mipData, limits) + texture.internalformat = mipData.internalformat - scope( - outer.entry, - 'for(', BATCH_ID, '=0;', BATCH_ID, '<', NUM_PROPS, ';++', BATCH_ID, '){', - PROPS, '=', PROP_LIST, '[', BATCH_ID, '];', - inner, - '}', - outer.exit); + reglTexture2D.width = mipData.width + reglTexture2D.height = mipData.height - function isInnerDefn (defn) { - return ((defn.contextDep && contextDynamic) || defn.propDep) - } + tempBind(texture) + setMipMap(mipData, GL_TEXTURE_2D$1) + setTexInfo(texInfo, GL_TEXTURE_2D$1) + tempRestore() - function isOuterDefn (defn) { - return !isInnerDefn(defn) - } + freeMipMap(mipData) - if (args.needsContext) { - emitContext(env, inner, args.context); - } - if (args.needsFramebuffer) { - emitPollFramebuffer(env, inner, args.framebuffer); - } - emitSetOptions(env, inner, args.state, isInnerDefn); + if (config.profile) { + texture.stats.size = getTextureSize( + texture.internalformat, + texture.type, + mipData.width, + mipData.height, + texInfo.genMipmaps, + false) + } + reglTexture2D.format = textureFormatsInvert[texture.internalformat] + reglTexture2D.type = textureTypesInvert[texture.type] - if (args.profile && isInnerDefn(args.profile)) { - emitProfile(env, inner, args, false, true); - } + reglTexture2D.mag = magFiltersInvert[texInfo.magFilter] + reglTexture2D.min = minFiltersInvert[texInfo.minFilter] - if (!program) { - var progCache = env.global.def('{}'); - var PROGRAM = args.shader.progVar.append(env, inner); - var PROG_ID = inner.def(PROGRAM, '.id'); - var CACHED_PROC = inner.def(progCache, '[', PROG_ID, ']'); - inner( - env.shared.gl, '.useProgram(', PROGRAM, '.program);', - 'if(!', CACHED_PROC, '){', - CACHED_PROC, '=', progCache, '[', PROG_ID, ']=', - env.link(function (program) { - return createBody( - emitBatchDynamicShaderBody, env, args, program, 2) - }), '(', PROGRAM, ');}', - CACHED_PROC, '.call(this,a0[', BATCH_ID, '],', BATCH_ID, ');'); - } else { - emitAttributes(env, outer, args, program.attributes, isOuterDefn); - emitAttributes(env, inner, args, program.attributes, isInnerDefn); - emitUniforms(env, outer, args, program.uniforms, isOuterDefn); - emitUniforms(env, inner, args, program.uniforms, isInnerDefn); - emitDraw(env, outer, inner, args); + reglTexture2D.wrapS = wrapModesInvert[texInfo.wrapS] + reglTexture2D.wrapT = wrapModesInvert[texInfo.wrapT] + + return reglTexture2D } - } - function emitBatchProc (env, args) { - var batch = env.proc('batch', 2); - env.batchId = '0'; + function subimage (image, x_, y_, level_) { + check$1(!!image, 'must specify image data') - injectExtensions(env, batch); + var x = x_ | 0 + var y = y_ | 0 + var level = level_ | 0 - // Check if any context variables depend on props - var contextDynamic = false; - var needsContext = true; - Object.keys(args.context).forEach(function (name) { - contextDynamic = contextDynamic || args.context[name].propDep; - }); - if (!contextDynamic) { - emitContext(env, batch, args.context); - needsContext = false; - } + var imageData = allocImage() + copyFlags(imageData, texture) + imageData.width = 0 + imageData.height = 0 + parseImage(imageData, image) + imageData.width = imageData.width || ((texture.width >> level) - x) + imageData.height = imageData.height || ((texture.height >> level) - y) - // framebuffer state affects framebufferWidth/height context vars - var framebuffer = args.framebuffer; - var needsFramebuffer = false; - if (framebuffer) { - if (framebuffer.propDep) { - contextDynamic = needsFramebuffer = true; - } else if (framebuffer.contextDep && contextDynamic) { - needsFramebuffer = true; - } - if (!needsFramebuffer) { - emitPollFramebuffer(env, batch, framebuffer); - } - } else { - emitPollFramebuffer(env, batch, null); - } + check$1( + texture.type === imageData.type && + texture.format === imageData.format && + texture.internalformat === imageData.internalformat, + 'incompatible format for texture.subimage') + check$1( + x >= 0 && y >= 0 && + x + imageData.width <= texture.width && + y + imageData.height <= texture.height, + 'texture.subimage write out of bounds') + check$1( + texture.mipmask & (1 << level), + 'missing mipmap data') + check$1( + imageData.data || imageData.element || imageData.needsCopy, + 'missing image data') - // viewport is weird because it can affect context vars - if (args.state.viewport && args.state.viewport.propDep) { - contextDynamic = true; - } + tempBind(texture) + setSubImage(imageData, GL_TEXTURE_2D$1, x, y, level) + tempRestore() - function isInnerDefn (defn) { - return (defn.contextDep && contextDynamic) || defn.propDep + freeImage(imageData) + + return reglTexture2D } - // set webgl options - emitPollState(env, batch, args); - emitSetOptions(env, batch, args.state, function (defn) { - return !isInnerDefn(defn) - }); + function resize (w_, h_) { + var w = w_ | 0 + var h = (h_ | 0) || w + if (w === texture.width && h === texture.height) { + return reglTexture2D + } - if (!args.profile || !isInnerDefn(args.profile)) { - emitProfile(env, batch, args, false, 'a1'); - } + reglTexture2D.width = texture.width = w + reglTexture2D.height = texture.height = h - // Save these values to args so that the batch body routine can use them - args.contextDep = contextDynamic; - args.needsContext = needsContext; - args.needsFramebuffer = needsFramebuffer; + tempBind(texture) - // determine if shader is dynamic - var progDefn = args.shader.progVar; - if ((progDefn.contextDep && contextDynamic) || progDefn.propDep) { - emitBatchBody( - env, - batch, - args, - null); - } else { - var PROGRAM = progDefn.append(env, batch); - batch(env.shared.gl, '.useProgram(', PROGRAM, '.program);'); - if (args.shader.program) { - emitBatchBody( - env, - batch, - args, - args.shader.program); - } else { - var batchCache = env.global.def('{}'); - var PROG_ID = batch.def(PROGRAM, '.id'); - var CACHED_PROC = batch.def(batchCache, '[', PROG_ID, ']'); - batch( - env.cond(CACHED_PROC) - .then(CACHED_PROC, '.call(this,a0,a1);') - .else( - CACHED_PROC, '=', batchCache, '[', PROG_ID, ']=', - env.link(function (program) { - return createBody(emitBatchBody, env, args, program, 2) - }), '(', PROGRAM, ');', - CACHED_PROC, '.call(this,a0,a1);')); + for (var i = 0; texture.mipmask >> i; ++i) { + var _w = w >> i + var _h = h >> i + if (!_w || !_h) break + gl.texImage2D( + GL_TEXTURE_2D$1, + i, + texture.format, + _w, + _h, + 0, + texture.format, + texture.type, + null) + } + tempRestore() + + // also, recompute the texture size. + if (config.profile) { + texture.stats.size = getTextureSize( + texture.internalformat, + texture.type, + w, + h, + false, + false) } - } - if (Object.keys(args.state).length > 0) { - batch(env.shared.current, '.dirty=true;'); + return reglTexture2D } - } - // =================================================== - // =================================================== - // SCOPE COMMAND - // =================================================== - // =================================================== - function emitScopeProc (env, args) { - var scope = env.proc('scope', 3); - env.batchId = 'a2'; + reglTexture2D(a, b) + + reglTexture2D.subimage = subimage + reglTexture2D.resize = resize + reglTexture2D._reglType = 'texture2d' + reglTexture2D._texture = texture + if (config.profile) { + reglTexture2D.stats = texture.stats + } + reglTexture2D.destroy = function () { + texture.decRef() + } - var shared = env.shared; - var CURRENT_STATE = shared.current; + return reglTexture2D + } - emitContext(env, scope, args.context); + function createTextureCube (a0, a1, a2, a3, a4, a5) { + var texture = new REGLTexture(GL_TEXTURE_CUBE_MAP$1) + textureSet[texture.id] = texture + stats.cubeCount++ - if (args.framebuffer) { - args.framebuffer.append(env, scope); - } + var faces = new Array(6) - sortState(Object.keys(args.state)).forEach(function (name) { - var defn = args.state[name]; - var value = defn.append(env, scope); - if (isArrayLike(value)) { - value.forEach(function (v, i) { - scope.set(env.next[name], '[' + i + ']', v); - }); - } else { - scope.set(shared.next, '.' + name, value); + function reglTextureCube (a0, a1, a2, a3, a4, a5) { + var i + var texInfo = texture.texInfo + TexInfo.call(texInfo) + for (i = 0; i < 6; ++i) { + faces[i] = allocMipMap() } - }); - - emitProfile(env, scope, args, true, true) - ;[S_ELEMENTS, S_OFFSET, S_COUNT, S_INSTANCES, S_PRIMITIVE].forEach( - function (opt) { - var variable = args.draw[opt]; - if (!variable) { - return + if (typeof a0 === 'number' || !a0) { + var s = (a0 | 0) || 1 + for (i = 0; i < 6; ++i) { + parseMipMapFromShape(faces[i], s, s) } - scope.set(shared.draw, '.' + opt, '' + variable.append(env, scope)); - }); + } else if (typeof a0 === 'object') { + if (a1) { + parseMipMapFromObject(faces[0], a0) + parseMipMapFromObject(faces[1], a1) + parseMipMapFromObject(faces[2], a2) + parseMipMapFromObject(faces[3], a3) + parseMipMapFromObject(faces[4], a4) + parseMipMapFromObject(faces[5], a5) + } else { + parseTexInfo(texInfo, a0) + parseFlags(texture, a0) + if ('faces' in a0) { + var faceInput = a0.faces + check$1(Array.isArray(faceInput) && faceInput.length === 6, + 'cube faces must be a length 6 array') + for (i = 0; i < 6; ++i) { + check$1(typeof faceInput[i] === 'object' && !!faceInput[i], + 'invalid input for cube map face') + copyFlags(faces[i], texture) + parseMipMapFromObject(faces[i], faceInput[i]) + } + } else { + for (i = 0; i < 6; ++i) { + parseMipMapFromObject(faces[i], a0) + } + } + } + } else { + check$1.raise('invalid arguments to cube map') + } - Object.keys(args.uniforms).forEach(function (opt) { - scope.set( - shared.uniforms, - '[' + stringStore.id(opt) + ']', - args.uniforms[opt].append(env, scope)); - }); + copyFlags(texture, faces[0]) - Object.keys(args.attributes).forEach(function (name) { - var record = args.attributes[name].append(env, scope); - var scopeAttrib = env.scopeAttrib(name); - Object.keys(new AttributeRecord()).forEach(function (prop) { - scope.set(scopeAttrib, '.' + prop, record[prop]); - }); - }); + if (!limits.npotTextureCube) { + check$1(isPow2$1(texture.width) && isPow2$1(texture.height), 'your browser does not support non power or two texture dimensions') + } - function saveShader (name) { - var shader = args.shader[name]; - if (shader) { - scope.set(shared.shader, '.' + name, shader.append(env, scope)); + if (texInfo.genMipmaps) { + texture.mipmask = (faces[0].width << 1) - 1 + } else { + texture.mipmask = faces[0].mipmask } - } - saveShader(S_VERT); - saveShader(S_FRAG); - if (Object.keys(args.state).length > 0) { - scope(CURRENT_STATE, '.dirty=true;'); - scope.exit(CURRENT_STATE, '.dirty=true;'); - } + check$1.textureCube(texture, texInfo, faces, limits) + texture.internalformat = faces[0].internalformat - scope('a1(', env.shared.context, ',a0,', env.batchId, ');'); - } + reglTextureCube.width = faces[0].width + reglTextureCube.height = faces[0].height - function isDynamicObject (object) { - if (typeof object !== 'object' || isArrayLike(object)) { - return - } - var props = Object.keys(object); - for (var i = 0; i < props.length; ++i) { - if (dynamic.isDynamic(object[props[i]])) { - return true + tempBind(texture) + for (i = 0; i < 6; ++i) { + setMipMap(faces[i], GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i) } - } - return false - } - - function splatObject (env, options, name) { - var object = options.static[name]; - if (!object || !isDynamicObject(object)) { - return - } + setTexInfo(texInfo, GL_TEXTURE_CUBE_MAP$1) + tempRestore() - var globals = env.global; - var keys = Object.keys(object); - var thisDep = false; - var contextDep = false; - var propDep = false; - var objectRef = env.global.def('{}'); - keys.forEach(function (key) { - var value = object[key]; - if (dynamic.isDynamic(value)) { - if (typeof value === 'function') { - value = object[key] = dynamic.unbox(value); - } - var deps = createDynamicDecl(value, null); - thisDep = thisDep || deps.thisDep; - propDep = propDep || deps.propDep; - contextDep = contextDep || deps.contextDep; - } else { - globals(objectRef, '.', key, '='); - switch (typeof value) { - case 'number': - globals(value); - break - case 'string': - globals('"', value, '"'); - break - case 'object': - if (Array.isArray(value)) { - globals('[', value.join(), ']'); - } - break - default: - globals(env.link(value)); - break - } - globals(';'); + if (config.profile) { + texture.stats.size = getTextureSize( + texture.internalformat, + texture.type, + reglTextureCube.width, + reglTextureCube.height, + texInfo.genMipmaps, + true) } - }); - function appendBlock (env, block) { - keys.forEach(function (key) { - var value = object[key]; - if (!dynamic.isDynamic(value)) { - return - } - var ref = env.invoke(block, value); - block(objectRef, '.', key, '=', ref, ';'); - }); - } + reglTextureCube.format = textureFormatsInvert[texture.internalformat] + reglTextureCube.type = textureTypesInvert[texture.type] - options.dynamic[name] = new dynamic.DynamicVariable(DYN_THUNK, { - thisDep: thisDep, - contextDep: contextDep, - propDep: propDep, - ref: objectRef, - append: appendBlock - }); - delete options.static[name]; - } + reglTextureCube.mag = magFiltersInvert[texInfo.magFilter] + reglTextureCube.min = minFiltersInvert[texInfo.minFilter] - // =========================================================================== - // =========================================================================== - // MAIN DRAW COMMAND - // =========================================================================== - // =========================================================================== - function compileCommand (options, attributes, uniforms, context, stats) { - var env = createREGLEnvironment(); + reglTextureCube.wrapS = wrapModesInvert[texInfo.wrapS] + reglTextureCube.wrapT = wrapModesInvert[texInfo.wrapT] - // link stats, so that we can easily access it in the program. - env.stats = env.link(stats); + for (i = 0; i < 6; ++i) { + freeMipMap(faces[i]) + } - // splat options and attributes to allow for dynamic nested properties - Object.keys(attributes.static).forEach(function (key) { - splatObject(env, attributes, key); - }); - NESTED_OPTIONS.forEach(function (name) { - splatObject(env, options, name); - }); + return reglTextureCube + } - var args = parseArguments(options, attributes, uniforms, context, env); + function subimage (face, image, x_, y_, level_) { + check$1(!!image, 'must specify image data') + check$1(typeof face === 'number' && face === (face | 0) && + face >= 0 && face < 6, 'invalid face') - emitDrawProc(env, args); - emitScopeProc(env, args); - emitBatchProc(env, args); + var x = x_ | 0 + var y = y_ | 0 + var level = level_ | 0 - return env.compile() - } + var imageData = allocImage() + copyFlags(imageData, texture) + imageData.width = 0 + imageData.height = 0 + parseImage(imageData, image) + imageData.width = imageData.width || ((texture.width >> level) - x) + imageData.height = imageData.height || ((texture.height >> level) - y) - // =========================================================================== - // =========================================================================== - // POLL / REFRESH - // =========================================================================== - // =========================================================================== - return { - next: nextState, - current: currentState, - procs: (function () { - var env = createREGLEnvironment(); - var poll = env.proc('poll'); - var refresh = env.proc('refresh'); - var common = env.block(); - poll(common); - refresh(common); + check$1( + texture.type === imageData.type && + texture.format === imageData.format && + texture.internalformat === imageData.internalformat, + 'incompatible format for texture.subimage') + check$1( + x >= 0 && y >= 0 && + x + imageData.width <= texture.width && + y + imageData.height <= texture.height, + 'texture.subimage write out of bounds') + check$1( + texture.mipmask & (1 << level), + 'missing mipmap data') + check$1( + imageData.data || imageData.element || imageData.needsCopy, + 'missing image data') - var shared = env.shared; - var GL = shared.gl; - var NEXT_STATE = shared.next; - var CURRENT_STATE = shared.current; + tempBind(texture) + setSubImage(imageData, GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + face, x, y, level) + tempRestore() - common(CURRENT_STATE, '.dirty=false;'); + freeImage(imageData) - emitPollFramebuffer(env, poll); - emitPollFramebuffer(env, refresh, null, true); + return reglTextureCube + } - // Refresh updates all attribute state changes - var extInstancing = gl.getExtension('angle_instanced_arrays'); - var INSTANCING; - if (extInstancing) { - INSTANCING = env.link(extInstancing); + function resize (radius_) { + var radius = radius_ | 0 + if (radius === texture.width) { + return } - for (var i = 0; i < limits.maxAttributes; ++i) { - var BINDING = refresh.def(shared.attributes, '[', i, ']'); - var ifte = env.cond(BINDING, '.buffer'); - ifte.then( - GL, '.enableVertexAttribArray(', i, ');', - GL, '.bindBuffer(', - GL_ARRAY_BUFFER$1, ',', - BINDING, '.buffer.buffer);', - GL, '.vertexAttribPointer(', - i, ',', - BINDING, '.size,', - BINDING, '.type,', - BINDING, '.normalized,', - BINDING, '.stride,', - BINDING, '.offset);' - ).else( - GL, '.disableVertexAttribArray(', i, ');', - GL, '.vertexAttrib4f(', - i, ',', - BINDING, '.x,', - BINDING, '.y,', - BINDING, '.z,', - BINDING, '.w);', - BINDING, '.buffer=null;'); - refresh(ifte); - if (extInstancing) { - refresh( - INSTANCING, '.vertexAttribDivisorANGLE(', - i, ',', - BINDING, '.divisor);'); + + reglTextureCube.width = texture.width = radius + reglTextureCube.height = texture.height = radius + + tempBind(texture) + for (var i = 0; i < 6; ++i) { + for (var j = 0; texture.mipmask >> j; ++j) { + gl.texImage2D( + GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i, + j, + texture.format, + radius >> j, + radius >> j, + 0, + texture.format, + texture.type, + null) } } + tempRestore() - Object.keys(GL_FLAGS).forEach(function (flag) { - var cap = GL_FLAGS[flag]; - var NEXT = common.def(NEXT_STATE, '.', flag); - var block = env.block(); - block('if(', NEXT, '){', - GL, '.enable(', cap, ')}else{', - GL, '.disable(', cap, ')}', - CURRENT_STATE, '.', flag, '=', NEXT, ';'); - refresh(block); - poll( - 'if(', NEXT, '!==', CURRENT_STATE, '.', flag, '){', - block, - '}'); - }); + if (config.profile) { + texture.stats.size = getTextureSize( + texture.internalformat, + texture.type, + reglTextureCube.width, + reglTextureCube.height, + false, + true) + } - Object.keys(GL_VARIABLES).forEach(function (name) { - var func = GL_VARIABLES[name]; - var init = currentState[name]; - var NEXT, CURRENT; - var block = env.block(); - block(GL, '.', func, '('); - if (isArrayLike(init)) { - var n = init.length; - NEXT = env.global.def(NEXT_STATE, '.', name); - CURRENT = env.global.def(CURRENT_STATE, '.', name); - block( - loop(n, function (i) { - return NEXT + '[' + i + ']' - }), ');', - loop(n, function (i) { - return CURRENT + '[' + i + ']=' + NEXT + '[' + i + '];' - }).join('')); - poll( - 'if(', loop(n, function (i) { - return NEXT + '[' + i + ']!==' + CURRENT + '[' + i + ']' - }).join('||'), '){', - block, - '}'); + return reglTextureCube + } + + reglTextureCube(a0, a1, a2, a3, a4, a5) + + reglTextureCube.subimage = subimage + reglTextureCube.resize = resize + reglTextureCube._reglType = 'textureCube' + reglTextureCube._texture = texture + if (config.profile) { + reglTextureCube.stats = texture.stats + } + reglTextureCube.destroy = function () { + texture.decRef() + } + + return reglTextureCube + } + + // Called when regl is destroyed + function destroyTextures () { + for (var i = 0; i < numTexUnits; ++i) { + gl.activeTexture(GL_TEXTURE0$1 + i) + gl.bindTexture(GL_TEXTURE_2D$1, null) + textureUnits[i] = null + } + values(textureSet).forEach(destroy) + + stats.cubeCount = 0 + stats.textureCount = 0 + } + + if (config.profile) { + stats.getTotalTextureSize = function () { + var total = 0 + Object.keys(textureSet).forEach(function (key) { + total += textureSet[key].stats.size + }) + return total + } + } + + function restoreTextures () { + for (var i = 0; i < numTexUnits; ++i) { + var tex = textureUnits[i] + if (tex) { + tex.bindCount = 0 + tex.unit = -1 + textureUnits[i] = null + } + } + + values(textureSet).forEach(function (texture) { + texture.texture = gl.createTexture() + gl.bindTexture(texture.target, texture.texture) + for (var i = 0; i < 32; ++i) { + if ((texture.mipmask & (1 << i)) === 0) { + continue + } + if (texture.target === GL_TEXTURE_2D$1) { + gl.texImage2D(GL_TEXTURE_2D$1, + i, + texture.internalformat, + texture.width >> i, + texture.height >> i, + 0, + texture.internalformat, + texture.type, + null) } else { - NEXT = common.def(NEXT_STATE, '.', name); - CURRENT = common.def(CURRENT_STATE, '.', name); - block( - NEXT, ');', - CURRENT_STATE, '.', name, '=', NEXT, ';'); - poll( - 'if(', NEXT, '!==', CURRENT, '){', - block, - '}'); + for (var j = 0; j < 6; ++j) { + gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + j, + i, + texture.internalformat, + texture.width >> i, + texture.height >> i, + 0, + texture.internalformat, + texture.type, + null) + } } - refresh(block); - }); + } + setTexInfo(texture.texInfo, texture.target) + }) + } - return env.compile() - })(), - compile: compileCommand + function refreshTextures () { + for (var i = 0; i < numTexUnits; ++i) { + var tex = textureUnits[i] + if (tex) { + tex.bindCount = 0 + tex.unit = -1 + textureUnits[i] = null + } + gl.activeTexture(GL_TEXTURE0$1 + i) + gl.bindTexture(GL_TEXTURE_2D$1, null) + gl.bindTexture(GL_TEXTURE_CUBE_MAP$1, null) + } } -} -function stats () { return { - bufferCount: 0, - elementsCount: 0, - framebufferCount: 0, - shaderCount: 0, - textureCount: 0, - cubeCount: 0, - renderbufferCount: 0, - - maxTextureUnits: 0 + create2D: createTexture2D, + createCube: createTextureCube, + clear: destroyTextures, + getTexture: function (wrapper) { + return null + }, + restore: restoreTextures, + refresh: refreshTextures } } -var GL_QUERY_RESULT_EXT = 0x8866; -var GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867; -var GL_TIME_ELAPSED_EXT = 0x88BF; +var GL_RENDERBUFFER = 0x8D41 -var createTimer = function (gl, extensions) { - var extTimer = extensions.ext_disjoint_timer_query; +var GL_RGBA4$1 = 0x8056 +var GL_RGB5_A1$1 = 0x8057 +var GL_RGB565$1 = 0x8D62 +var GL_DEPTH_COMPONENT16 = 0x81A5 +var GL_STENCIL_INDEX8 = 0x8D48 +var GL_DEPTH_STENCIL$1 = 0x84F9 - if (!extTimer) { - return null - } +var GL_SRGB8_ALPHA8_EXT = 0x8C43 - // QUERY POOL BEGIN - var queryPool = []; - function allocQuery () { - return queryPool.pop() || extTimer.createQueryEXT() - } - function freeQuery (query) { - queryPool.push(query); - } - // QUERY POOL END +var GL_RGBA32F_EXT = 0x8814 - var pendingQueries = []; - function beginQuery (stats) { - var query = allocQuery(); - extTimer.beginQueryEXT(GL_TIME_ELAPSED_EXT, query); - pendingQueries.push(query); - pushScopeStats(pendingQueries.length - 1, pendingQueries.length, stats); - } +var GL_RGBA16F_EXT = 0x881A +var GL_RGB16F_EXT = 0x881B - function endQuery () { - extTimer.endQueryEXT(GL_TIME_ELAPSED_EXT); - } +var FORMAT_SIZES = [] - // - // Pending stats pool. - // - function PendingStats () { - this.startQueryIndex = -1; - this.endQueryIndex = -1; - this.sum = 0; - this.stats = null; +FORMAT_SIZES[GL_RGBA4$1] = 2 +FORMAT_SIZES[GL_RGB5_A1$1] = 2 +FORMAT_SIZES[GL_RGB565$1] = 2 + +FORMAT_SIZES[GL_DEPTH_COMPONENT16] = 2 +FORMAT_SIZES[GL_STENCIL_INDEX8] = 1 +FORMAT_SIZES[GL_DEPTH_STENCIL$1] = 4 + +FORMAT_SIZES[GL_SRGB8_ALPHA8_EXT] = 4 +FORMAT_SIZES[GL_RGBA32F_EXT] = 16 +FORMAT_SIZES[GL_RGBA16F_EXT] = 8 +FORMAT_SIZES[GL_RGB16F_EXT] = 6 + +function getRenderbufferSize (format, width, height) { + return FORMAT_SIZES[format] * width * height +} + +var wrapRenderbuffers = function (gl, extensions, limits, stats, config) { + var formatTypes = { + 'rgba4': GL_RGBA4$1, + 'rgb565': GL_RGB565$1, + 'rgb5 a1': GL_RGB5_A1$1, + 'depth': GL_DEPTH_COMPONENT16, + 'stencil': GL_STENCIL_INDEX8, + 'depth stencil': GL_DEPTH_STENCIL$1 } - var pendingStatsPool = []; - function allocPendingStats () { - return pendingStatsPool.pop() || new PendingStats() + + if (extensions.ext_srgb) { + formatTypes['srgba'] = GL_SRGB8_ALPHA8_EXT } - function freePendingStats (pendingStats) { - pendingStatsPool.push(pendingStats); + + if (extensions.ext_color_buffer_half_float) { + formatTypes['rgba16f'] = GL_RGBA16F_EXT + formatTypes['rgb16f'] = GL_RGB16F_EXT } - // Pending stats pool end - var pendingStats = []; - function pushScopeStats (start, end, stats) { - var ps = allocPendingStats(); - ps.startQueryIndex = start; - ps.endQueryIndex = end; - ps.sum = 0; - ps.stats = stats; - pendingStats.push(ps); + if (extensions.webgl_color_buffer_float) { + formatTypes['rgba32f'] = GL_RGBA32F_EXT } - // we should call this at the beginning of the frame, - // in order to update gpuTime - var timeSum = []; - var queryPtr = []; - function update () { - var ptr, i; + var formatTypesInvert = [] + Object.keys(formatTypes).forEach(function (key) { + var val = formatTypes[key] + formatTypesInvert[val] = key + }) - var n = pendingQueries.length; - if (n === 0) { - return - } + var renderbufferCount = 0 + var renderbufferSet = {} - // Reserve space - queryPtr.length = Math.max(queryPtr.length, n + 1); - timeSum.length = Math.max(timeSum.length, n + 1); - timeSum[0] = 0; - queryPtr[0] = 0; + function REGLRenderbuffer (renderbuffer) { + this.id = renderbufferCount++ + this.refCount = 1 - // Update all pending timer queries - var queryTime = 0; - ptr = 0; - for (i = 0; i < pendingQueries.length; ++i) { - var query = pendingQueries[i]; - if (extTimer.getQueryObjectEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT)) { - queryTime += extTimer.getQueryObjectEXT(query, GL_QUERY_RESULT_EXT); - freeQuery(query); - } else { - pendingQueries[ptr++] = query; - } - timeSum[i + 1] = queryTime; - queryPtr[i + 1] = ptr; - } - pendingQueries.length = ptr; + this.renderbuffer = renderbuffer - // Update all pending stat queries - ptr = 0; - for (i = 0; i < pendingStats.length; ++i) { - var stats = pendingStats[i]; - var start = stats.startQueryIndex; - var end = stats.endQueryIndex; - stats.sum += timeSum[end] - timeSum[start]; - var startPtr = queryPtr[start]; - var endPtr = queryPtr[end]; - if (endPtr === startPtr) { - stats.stats.gpuTime += stats.sum / 1e6; - freePendingStats(stats); - } else { - stats.startQueryIndex = startPtr; - stats.endQueryIndex = endPtr; - pendingStats[ptr++] = stats; - } + this.format = GL_RGBA4$1 + this.width = 0 + this.height = 0 + + if (config.profile) { + this.stats = { size: 0 } } - pendingStats.length = ptr; } - return { - beginQuery: beginQuery, - endQuery: endQuery, - pushScopeStats: pushScopeStats, - update: update, - getNumPendingQueries: function () { - return pendingQueries.length - }, - clear: function () { - queryPool.push.apply(queryPool, pendingQueries); - for (var i = 0; i < queryPool.length; i++) { - extTimer.deleteQueryEXT(queryPool[i]); - } - pendingQueries.length = 0; - queryPool.length = 0; - }, - restore: function () { - pendingQueries.length = 0; - queryPool.length = 0; + REGLRenderbuffer.prototype.decRef = function () { + if (--this.refCount <= 0) { + destroy(this) } } -}; -var GL_COLOR_BUFFER_BIT = 16384; -var GL_DEPTH_BUFFER_BIT = 256; -var GL_STENCIL_BUFFER_BIT = 1024; + function destroy (rb) { + var handle = rb.renderbuffer + check$1(handle, 'must not double destroy renderbuffer') + gl.bindRenderbuffer(GL_RENDERBUFFER, null) + gl.deleteRenderbuffer(handle) + rb.renderbuffer = null + rb.refCount = 0 + delete renderbufferSet[rb.id] + stats.renderbufferCount-- + } -var GL_ARRAY_BUFFER = 34962; + function createRenderbuffer (a, b) { + var renderbuffer = new REGLRenderbuffer(gl.createRenderbuffer()) + renderbufferSet[renderbuffer.id] = renderbuffer + stats.renderbufferCount++ -var CONTEXT_LOST_EVENT = 'webglcontextlost'; -var CONTEXT_RESTORED_EVENT = 'webglcontextrestored'; + function reglRenderbuffer (a, b) { + var w = 0 + var h = 0 + var format = GL_RGBA4$1 -var DYN_PROP = 1; -var DYN_CONTEXT = 2; -var DYN_STATE = 3; + if (typeof a === 'object' && a) { + var options = a + if ('shape' in options) { + var shape = options.shape + check$1(Array.isArray(shape) && shape.length >= 2, + 'invalid renderbuffer shape') + w = shape[0] | 0 + h = shape[1] | 0 + } else { + if ('radius' in options) { + w = h = options.radius | 0 + } + if ('width' in options) { + w = options.width | 0 + } + if ('height' in options) { + h = options.height | 0 + } + } + if ('format' in options) { + check$1.parameter(options.format, formatTypes, + 'invalid renderbuffer format') + format = formatTypes[options.format] + } + } else if (typeof a === 'number') { + w = a | 0 + if (typeof b === 'number') { + h = b | 0 + } else { + h = w + } + } else if (!a) { + w = h = 1 + } else { + check$1.raise('invalid arguments to renderbuffer constructor') + } -function find (haystack, needle) { - for (var i = 0; i < haystack.length; ++i) { - if (haystack[i] === needle) { - return i - } - } - return -1 -} + // check shape + check$1( + w > 0 && h > 0 && + w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize, + 'invalid renderbuffer size') -function wrapREGL (args) { - var config = parseArgs(args); - if (!config) { - return null - } + if (w === renderbuffer.width && + h === renderbuffer.height && + format === renderbuffer.format) { + return + } - var gl = config.gl; - var glAttributes = gl.getContextAttributes(); - var contextLost = gl.isContextLost(); + reglRenderbuffer.width = renderbuffer.width = w + reglRenderbuffer.height = renderbuffer.height = h + renderbuffer.format = format - var extensionState = createExtensionCache(gl, config); - if (!extensionState) { - return null - } + gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer) + gl.renderbufferStorage(GL_RENDERBUFFER, format, w, h) - var stringStore = createStringStore(); - var stats$$1 = stats(); - var extensions = extensionState.extensions; - var timer = createTimer(gl, extensions); + check$1( + gl.getError() === 0, + 'invalid render buffer format') - var START_TIME = clock(); - var WIDTH = gl.drawingBufferWidth; - var HEIGHT = gl.drawingBufferHeight; + if (config.profile) { + renderbuffer.stats.size = getRenderbufferSize(renderbuffer.format, renderbuffer.width, renderbuffer.height) + } + reglRenderbuffer.format = formatTypesInvert[renderbuffer.format] - var contextState = { - tick: 0, - time: 0, - viewportWidth: WIDTH, - viewportHeight: HEIGHT, - framebufferWidth: WIDTH, - framebufferHeight: HEIGHT, - drawingBufferWidth: WIDTH, - drawingBufferHeight: HEIGHT, - pixelRatio: config.pixelRatio - }; - var uniformState = {}; - var drawState = { - elements: null, - primitive: 4, // GL_TRIANGLES - count: -1, - offset: 0, - instances: -1 - }; + return reglRenderbuffer + } - var limits = wrapLimits(gl, extensions); - var bufferState = wrapBufferState(gl, stats$$1, config); - var elementState = wrapElementsState(gl, extensions, bufferState, stats$$1); - var attributeState = wrapAttributeState( - gl, - extensions, - limits, - bufferState, - stringStore); - var shaderState = wrapShaderState(gl, stringStore, stats$$1, config); - var textureState = createTextureSet( - gl, - extensions, - limits, - function () { core.procs.poll(); }, - contextState, - stats$$1, - config); - var renderbufferState = wrapRenderbuffers(gl, extensions, limits, stats$$1, config); - var framebufferState = wrapFBOState( - gl, - extensions, - limits, - textureState, - renderbufferState, - stats$$1); - var core = reglCore( - gl, - stringStore, - extensions, - limits, - bufferState, - elementState, - textureState, - framebufferState, - uniformState, - attributeState, - shaderState, - drawState, - contextState, - timer, - config); - var readPixels = wrapReadPixels( - gl, - framebufferState, - core.procs.poll, - contextState, - glAttributes, extensions); + function resize (w_, h_) { + var w = w_ | 0 + var h = (h_ | 0) || w + + if (w === renderbuffer.width && h === renderbuffer.height) { + return reglRenderbuffer + } + + // check shape + check$1( + w > 0 && h > 0 && + w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize, + 'invalid renderbuffer size') - var nextState = core.next; - var canvas = gl.canvas; + reglRenderbuffer.width = renderbuffer.width = w + reglRenderbuffer.height = renderbuffer.height = h - var rafCallbacks = []; - var lossCallbacks = []; - var restoreCallbacks = []; - var destroyCallbacks = [config.onDestroy]; + gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer) + gl.renderbufferStorage(GL_RENDERBUFFER, renderbuffer.format, w, h) - var activeRAF = null; - function handleRAF () { - if (rafCallbacks.length === 0) { - if (timer) { - timer.update(); + check$1( + gl.getError() === 0, + 'invalid render buffer format') + + // also, recompute size. + if (config.profile) { + renderbuffer.stats.size = getRenderbufferSize( + renderbuffer.format, renderbuffer.width, renderbuffer.height) } - activeRAF = null; - return - } - // schedule next animation frame - activeRAF = raf.next(handleRAF); + return reglRenderbuffer + } - // poll for changes - poll(); + reglRenderbuffer(a, b) - // fire a callback for all pending rafs - for (var i = rafCallbacks.length - 1; i >= 0; --i) { - var cb = rafCallbacks[i]; - if (cb) { - cb(contextState, null, 0); - } + reglRenderbuffer.resize = resize + reglRenderbuffer._reglType = 'renderbuffer' + reglRenderbuffer._renderbuffer = renderbuffer + if (config.profile) { + reglRenderbuffer.stats = renderbuffer.stats + } + reglRenderbuffer.destroy = function () { + renderbuffer.decRef() } - // flush all pending webgl calls - gl.flush(); + return reglRenderbuffer + } - // poll GPU timers *after* gl.flush so we don't delay command dispatch - if (timer) { - timer.update(); + if (config.profile) { + stats.getTotalRenderbufferSize = function () { + var total = 0 + Object.keys(renderbufferSet).forEach(function (key) { + total += renderbufferSet[key].stats.size + }) + return total } } - function startRAF () { - if (!activeRAF && rafCallbacks.length > 0) { - activeRAF = raf.next(handleRAF); - } + function restoreRenderbuffers () { + values(renderbufferSet).forEach(function (rb) { + rb.renderbuffer = gl.createRenderbuffer() + gl.bindRenderbuffer(GL_RENDERBUFFER, rb.renderbuffer) + gl.renderbufferStorage(GL_RENDERBUFFER, rb.format, rb.width, rb.height) + }) + gl.bindRenderbuffer(GL_RENDERBUFFER, null) } - function stopRAF () { - if (activeRAF) { - raf.cancel(handleRAF); - activeRAF = null; - } + return { + create: createRenderbuffer, + clear: function () { + values(renderbufferSet).forEach(destroy) + }, + restore: restoreRenderbuffers } +} - function handleContextLoss (event) { - event.preventDefault(); +// We store these constants so that the minifier can inline them +var GL_FRAMEBUFFER$1 = 0x8D40 +var GL_RENDERBUFFER$1 = 0x8D41 - // set context lost flag - contextLost = true; +var GL_TEXTURE_2D$2 = 0x0DE1 +var GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 = 0x8515 - // pause request animation frame - stopRAF(); +var GL_COLOR_ATTACHMENT0$1 = 0x8CE0 +var GL_DEPTH_ATTACHMENT = 0x8D00 +var GL_STENCIL_ATTACHMENT = 0x8D20 +var GL_DEPTH_STENCIL_ATTACHMENT = 0x821A - // lose context - lossCallbacks.forEach(function (cb) { - cb(); - }); - } +var GL_FRAMEBUFFER_COMPLETE$1 = 0x8CD5 +var GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6 +var GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7 +var GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9 +var GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD - function handleContextRestored (event) { - // clear error code - gl.getError(); +var GL_HALF_FLOAT_OES$2 = 0x8D61 +var GL_UNSIGNED_BYTE$6 = 0x1401 +var GL_FLOAT$5 = 0x1406 - // clear context lost flag - contextLost = false; +var GL_RGB$1 = 0x1907 +var GL_RGBA$2 = 0x1908 - // refresh state - extensionState.restore(); - shaderState.restore(); - bufferState.restore(); - textureState.restore(); - renderbufferState.restore(); - framebufferState.restore(); - if (timer) { - timer.restore(); - } +var GL_DEPTH_COMPONENT$1 = 0x1902 - // refresh state - core.procs.refresh(); +var colorTextureFormatEnums = [ + GL_RGB$1, + GL_RGBA$2 +] - // restart RAF - startRAF(); +// for every texture format, store +// the number of channels +var textureFormatChannels = [] +textureFormatChannels[GL_RGBA$2] = 4 +textureFormatChannels[GL_RGB$1] = 3 - // restore context - restoreCallbacks.forEach(function (cb) { - cb(); - }); - } +// for every texture type, store +// the size in bytes. +var textureTypeSizes = [] +textureTypeSizes[GL_UNSIGNED_BYTE$6] = 1 +textureTypeSizes[GL_FLOAT$5] = 4 +textureTypeSizes[GL_HALF_FLOAT_OES$2] = 2 - if (canvas) { - canvas.addEventListener(CONTEXT_LOST_EVENT, handleContextLoss, false); - canvas.addEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored, false); - } +var GL_RGBA4$2 = 0x8056 +var GL_RGB5_A1$2 = 0x8057 +var GL_RGB565$2 = 0x8D62 +var GL_DEPTH_COMPONENT16$1 = 0x81A5 +var GL_STENCIL_INDEX8$1 = 0x8D48 +var GL_DEPTH_STENCIL$2 = 0x84F9 - function destroy () { - rafCallbacks.length = 0; - stopRAF(); +var GL_SRGB8_ALPHA8_EXT$1 = 0x8C43 - if (canvas) { - canvas.removeEventListener(CONTEXT_LOST_EVENT, handleContextLoss); - canvas.removeEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored); - } +var GL_RGBA32F_EXT$1 = 0x8814 - shaderState.clear(); - framebufferState.clear(); - renderbufferState.clear(); - textureState.clear(); - elementState.clear(); - bufferState.clear(); +var GL_RGBA16F_EXT$1 = 0x881A +var GL_RGB16F_EXT$1 = 0x881B - if (timer) { - timer.clear(); - } +var colorRenderbufferFormatEnums = [ + GL_RGBA4$2, + GL_RGB5_A1$2, + GL_RGB565$2, + GL_SRGB8_ALPHA8_EXT$1, + GL_RGBA16F_EXT$1, + GL_RGB16F_EXT$1, + GL_RGBA32F_EXT$1 +] - destroyCallbacks.forEach(function (cb) { - cb(); - }); +var statusCode = {} +statusCode[GL_FRAMEBUFFER_COMPLETE$1] = 'complete' +statusCode[GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT] = 'incomplete attachment' +statusCode[GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS] = 'incomplete dimensions' +statusCode[GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT] = 'incomplete, missing attachment' +statusCode[GL_FRAMEBUFFER_UNSUPPORTED] = 'unsupported' + +function wrapFBOState ( + gl, + extensions, + limits, + textureState, + renderbufferState, + stats) { + var framebufferState = { + cur: null, + next: null, + dirty: false, + setFBO: null } - function compileProcedure (options) { - check$1(!!options, 'invalid args to regl({...})'); - check$1.type(options, 'object', 'invalid args to regl({...})'); + var colorTextureFormats = ['rgba'] + var colorRenderbufferFormats = ['rgba4', 'rgb565', 'rgb5 a1'] - function flattenNestedOptions (options) { - var result = extend({}, options); - delete result.uniforms; - delete result.attributes; - delete result.context; + if (extensions.ext_srgb) { + colorRenderbufferFormats.push('srgba') + } - if ('stencil' in result && result.stencil.op) { - result.stencil.opBack = result.stencil.opFront = result.stencil.op; - delete result.stencil.op; - } + if (extensions.ext_color_buffer_half_float) { + colorRenderbufferFormats.push('rgba16f', 'rgb16f') + } - function merge (name) { - if (name in result) { - var child = result[name]; - delete result[name]; - Object.keys(child).forEach(function (prop) { - result[name + '.' + prop] = child[prop]; - }); - } - } - merge('blend'); - merge('depth'); - merge('cull'); - merge('stencil'); - merge('polygonOffset'); - merge('scissor'); - merge('sample'); + if (extensions.webgl_color_buffer_float) { + colorRenderbufferFormats.push('rgba32f') + } - return result + var colorTypes = ['uint8'] + if (extensions.oes_texture_half_float) { + colorTypes.push('half float', 'float16') + } + if (extensions.oes_texture_float) { + colorTypes.push('float', 'float32') + } + + function FramebufferAttachment (target, texture, renderbuffer) { + this.target = target + this.texture = texture + this.renderbuffer = renderbuffer + + var w = 0 + var h = 0 + if (texture) { + w = texture.width + h = texture.height + } else if (renderbuffer) { + w = renderbuffer.width + h = renderbuffer.height } + this.width = w + this.height = h + } - function separateDynamic (object) { - var staticItems = {}; - var dynamicItems = {}; - Object.keys(object).forEach(function (option) { - var value = object[option]; - if (dynamic.isDynamic(value)) { - dynamicItems[option] = dynamic.unbox(value, option); - } else { - staticItems[option] = value; - } - }); - return { - dynamic: dynamicItems, - static: staticItems + function decRef (attachment) { + if (attachment) { + if (attachment.texture) { + attachment.texture._texture.decRef() + } + if (attachment.renderbuffer) { + attachment.renderbuffer._renderbuffer.decRef() } } + } - // Treat context variables separate from other dynamic variables - var context = separateDynamic(options.context || {}); - var uniforms = separateDynamic(options.uniforms || {}); - var attributes = separateDynamic(options.attributes || {}); - var opts = separateDynamic(flattenNestedOptions(options)); - - var stats$$1 = { - gpuTime: 0.0, - cpuTime: 0.0, - count: 0 - }; - - var compiled = core.compile(opts, attributes, uniforms, context, stats$$1); - - var draw = compiled.draw; - var batch = compiled.batch; - var scope = compiled.scope; - - // FIXME: we should modify code generation for batch commands so this - // isn't necessary - var EMPTY_ARRAY = []; - function reserve (count) { - while (EMPTY_ARRAY.length < count) { - EMPTY_ARRAY.push(null); - } - return EMPTY_ARRAY + function incRefAndCheckShape (attachment, width, height) { + if (!attachment) { + return + } + if (attachment.texture) { + var texture = attachment.texture._texture + var tw = Math.max(1, texture.width) + var th = Math.max(1, texture.height) + check$1(tw === width && th === height, + 'inconsistent width/height for supplied texture') + texture.refCount += 1 + } else { + var renderbuffer = attachment.renderbuffer._renderbuffer + check$1( + renderbuffer.width === width && renderbuffer.height === height, + 'inconsistent width/height for renderbuffer') + renderbuffer.refCount += 1 } + } - function REGLCommand (args, body) { - var i; - if (contextLost) { - check$1.raise('context lost'); - } - if (typeof args === 'function') { - return scope.call(this, null, args, 0) - } else if (typeof body === 'function') { - if (typeof args === 'number') { - for (i = 0; i < args; ++i) { - scope.call(this, null, body, i); - } - return - } else if (Array.isArray(args)) { - for (i = 0; i < args.length; ++i) { - scope.call(this, args[i], body, i); - } - return - } else { - return scope.call(this, args, body, 0) - } - } else if (typeof args === 'number') { - if (args > 0) { - return batch.call(this, reserve(args | 0), args | 0) - } - } else if (Array.isArray(args)) { - if (args.length) { - return batch.call(this, args, args.length) - } + function attach (location, attachment) { + if (attachment) { + if (attachment.texture) { + gl.framebufferTexture2D( + GL_FRAMEBUFFER$1, + location, + attachment.target, + attachment.texture._texture.texture, + 0) } else { - return draw.call(this, args) + gl.framebufferRenderbuffer( + GL_FRAMEBUFFER$1, + location, + GL_RENDERBUFFER$1, + attachment.renderbuffer._renderbuffer.renderbuffer) } } - - return extend(REGLCommand, { - stats: stats$$1 - }) } - var setFBO = framebufferState.setFBO = compileProcedure({ - framebuffer: dynamic.define.call(null, DYN_PROP, 'framebuffer') - }); - - function clearImpl (_, options) { - var clearFlags = 0; - core.procs.poll(); + function parseAttachment (attachment) { + var target = GL_TEXTURE_2D$2 + var texture = null + var renderbuffer = null - var c = options.color; - if (c) { - gl.clearColor(+c[0] || 0, +c[1] || 0, +c[2] || 0, +c[3] || 0); - clearFlags |= GL_COLOR_BUFFER_BIT; - } - if ('depth' in options) { - gl.clearDepth(+options.depth); - clearFlags |= GL_DEPTH_BUFFER_BIT; + var data = attachment + if (typeof attachment === 'object') { + data = attachment.data + if ('target' in attachment) { + target = attachment.target | 0 + } } - if ('stencil' in options) { - gl.clearStencil(options.stencil | 0); - clearFlags |= GL_STENCIL_BUFFER_BIT; + + check$1.type(data, 'function', 'invalid attachment data') + + var type = data._reglType + if (type === 'texture2d') { + texture = data + check$1(target === GL_TEXTURE_2D$2) + } else if (type === 'textureCube') { + texture = data + check$1( + target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 && + target < GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 + 6, + 'invalid cube map target') + } else if (type === 'renderbuffer') { + renderbuffer = data + target = GL_RENDERBUFFER$1 + } else { + check$1.raise('invalid regl object for attachment') } - check$1(!!clearFlags, 'called regl.clear with no buffer specified'); - gl.clear(clearFlags); + return new FramebufferAttachment(target, texture, renderbuffer) } - function clear (options) { - check$1( - typeof options === 'object' && options, - 'regl.clear() takes an object as input'); - if ('framebuffer' in options) { - if (options.framebuffer && - options.framebuffer_reglType === 'framebufferCube') { - for (var i = 0; i < 6; ++i) { - setFBO(extend({ - framebuffer: options.framebuffer.faces[i] - }, options), clearImpl); - } - } else { - setFBO(options, clearImpl); - } + function allocAttachment ( + width, + height, + isTexture, + format, + type) { + if (isTexture) { + var texture = textureState.create2D({ + width: width, + height: height, + format: format, + type: type + }) + texture._texture.refCount = 0 + return new FramebufferAttachment(GL_TEXTURE_2D$2, texture, null) } else { - clearImpl(null, options); + var rb = renderbufferState.create({ + width: width, + height: height, + format: format + }) + rb._renderbuffer.refCount = 0 + return new FramebufferAttachment(GL_RENDERBUFFER$1, null, rb) } } - function frame (cb) { - check$1.type(cb, 'function', 'regl.frame() callback must be a function'); - rafCallbacks.push(cb); + function unwrapAttachment (attachment) { + return attachment && (attachment.texture || attachment.renderbuffer) + } - function cancel () { - // FIXME: should we check something other than equals cb here? - // what if a user calls frame twice with the same callback... - // - var i = find(rafCallbacks, cb); - check$1(i >= 0, 'cannot cancel a frame twice'); - function pendingCancel () { - var index = find(rafCallbacks, pendingCancel); - rafCallbacks[index] = rafCallbacks[rafCallbacks.length - 1]; - rafCallbacks.length -= 1; - if (rafCallbacks.length <= 0) { - stopRAF(); - } + function resizeAttachment (attachment, w, h) { + if (attachment) { + if (attachment.texture) { + attachment.texture.resize(w, h) + } else if (attachment.renderbuffer) { + attachment.renderbuffer.resize(w, h) } - rafCallbacks[i] = pendingCancel; + attachment.width = w + attachment.height = h } + } - startRAF(); + var framebufferCount = 0 + var framebufferSet = {} - return { - cancel: cancel - } - } + function REGLFramebuffer () { + this.id = framebufferCount++ + framebufferSet[this.id] = this - // poll viewport - function pollViewport () { - var viewport = nextState.viewport; - var scissorBox = nextState.scissor_box; - viewport[0] = viewport[1] = scissorBox[0] = scissorBox[1] = 0; - contextState.viewportWidth = - contextState.framebufferWidth = - contextState.drawingBufferWidth = - viewport[2] = - scissorBox[2] = gl.drawingBufferWidth; - contextState.viewportHeight = - contextState.framebufferHeight = - contextState.drawingBufferHeight = - viewport[3] = - scissorBox[3] = gl.drawingBufferHeight; - } + this.framebuffer = gl.createFramebuffer() + this.width = 0 + this.height = 0 - function poll () { - contextState.tick += 1; - contextState.time = now(); - pollViewport(); - core.procs.poll(); + this.colorAttachments = [] + this.depthAttachment = null + this.stencilAttachment = null + this.depthStencilAttachment = null } - function refresh () { - pollViewport(); - core.procs.refresh(); - if (timer) { - timer.update(); - } + function decFBORefs (framebuffer) { + framebuffer.colorAttachments.forEach(decRef) + decRef(framebuffer.depthAttachment) + decRef(framebuffer.stencilAttachment) + decRef(framebuffer.depthStencilAttachment) } - function now () { - return (clock() - START_TIME) / 1000.0 + function destroy (framebuffer) { + var handle = framebuffer.framebuffer + check$1(handle, 'must not double destroy framebuffer') + gl.deleteFramebuffer(handle) + framebuffer.framebuffer = null + stats.framebufferCount-- + delete framebufferSet[framebuffer.id] } - refresh(); - - function addListener (event, callback) { - check$1.type(callback, 'function', 'listener callback must be a function'); + function updateFramebuffer (framebuffer) { + var i - var callbacks; - switch (event) { - case 'frame': - return frame(callback) - case 'lost': - callbacks = lossCallbacks; - break - case 'restore': - callbacks = restoreCallbacks; - break - case 'destroy': - callbacks = destroyCallbacks; - break - default: - check$1.raise('invalid event, must be one of frame,lost,restore,destroy'); + gl.bindFramebuffer(GL_FRAMEBUFFER$1, framebuffer.framebuffer) + var colorAttachments = framebuffer.colorAttachments + for (i = 0; i < colorAttachments.length; ++i) { + attach(GL_COLOR_ATTACHMENT0$1 + i, colorAttachments[i]) } - - callbacks.push(callback); - return { - cancel: function () { - for (var i = 0; i < callbacks.length; ++i) { - if (callbacks[i] === callback) { - callbacks[i] = callbacks[callbacks.length - 1]; - callbacks.pop(); - return - } - } - } + for (i = colorAttachments.length; i < limits.maxColorAttachments; ++i) { + gl.framebufferTexture2D( + GL_FRAMEBUFFER$1, + GL_COLOR_ATTACHMENT0$1 + i, + GL_TEXTURE_2D$2, + null, + 0) } - } - var regl = extend(compileProcedure, { - // Clear current FBO - clear: clear, + gl.framebufferTexture2D( + GL_FRAMEBUFFER$1, + GL_DEPTH_STENCIL_ATTACHMENT, + GL_TEXTURE_2D$2, + null, + 0) + gl.framebufferTexture2D( + GL_FRAMEBUFFER$1, + GL_DEPTH_ATTACHMENT, + GL_TEXTURE_2D$2, + null, + 0) + gl.framebufferTexture2D( + GL_FRAMEBUFFER$1, + GL_STENCIL_ATTACHMENT, + GL_TEXTURE_2D$2, + null, + 0) - // Short cuts for dynamic variables - prop: dynamic.define.bind(null, DYN_PROP), - context: dynamic.define.bind(null, DYN_CONTEXT), - this: dynamic.define.bind(null, DYN_STATE), + attach(GL_DEPTH_ATTACHMENT, framebuffer.depthAttachment) + attach(GL_STENCIL_ATTACHMENT, framebuffer.stencilAttachment) + attach(GL_DEPTH_STENCIL_ATTACHMENT, framebuffer.depthStencilAttachment) - // executes an empty draw command - draw: compileProcedure({}), + // Check status code + var status = gl.checkFramebufferStatus(GL_FRAMEBUFFER$1) + if (!gl.isContextLost() && status !== GL_FRAMEBUFFER_COMPLETE$1) { + check$1.raise('framebuffer configuration not supported, status = ' + + statusCode[status]) + } - // Resources - buffer: function (options) { - return bufferState.create(options, GL_ARRAY_BUFFER, false, false) - }, - elements: function (options) { - return elementState.create(options, false) - }, - texture: textureState.create2D, - cube: textureState.createCube, - renderbuffer: renderbufferState.create, - framebuffer: framebufferState.create, - framebufferCube: framebufferState.createCube, + gl.bindFramebuffer(GL_FRAMEBUFFER$1, framebufferState.next ? framebufferState.next.framebuffer : null) + framebufferState.cur = framebufferState.next - // Expose context attributes - attributes: glAttributes, + // FIXME: Clear error code here. This is a work around for a bug in + // headless-gl + gl.getError() + } - // Frame rendering - frame: frame, - on: addListener, + function createFBO (a0, a1) { + var framebuffer = new REGLFramebuffer() + stats.framebufferCount++ - // System limits - limits: limits, - hasExtension: function (name) { - return limits.extensions.indexOf(name.toLowerCase()) >= 0 - }, + function reglFramebuffer (a, b) { + var i - // Read pixels - read: readPixels, + check$1(framebufferState.next !== framebuffer, + 'can not update framebuffer which is currently in use') - // Destroy regl and all associated resources - destroy: destroy, + var width = 0 + var height = 0 - // Direct GL state manipulation - _gl: gl, - _refresh: refresh, + var needsDepth = true + var needsStencil = true - poll: function () { - poll(); - if (timer) { - timer.update(); - } - }, + var colorBuffer = null + var colorTexture = true + var colorFormat = 'rgba' + var colorType = 'uint8' + var colorCount = 1 - // Current time - now: now, + var depthBuffer = null + var stencilBuffer = null + var depthStencilBuffer = null + var depthStencilTexture = false - // regl Statistics Information - stats: stats$$1 - }); + if (typeof a === 'number') { + width = a | 0 + height = (b | 0) || width + } else if (!a) { + width = height = 1 + } else { + check$1.type(a, 'object', 'invalid arguments for framebuffer') + var options = a - config.onDone(null, regl); + if ('shape' in options) { + var shape = options.shape + check$1(Array.isArray(shape) && shape.length >= 2, + 'invalid shape for framebuffer') + width = shape[0] + height = shape[1] + } else { + if ('radius' in options) { + width = height = options.radius + } + if ('width' in options) { + width = options.width + } + if ('height' in options) { + height = options.height + } + } - return regl -} + if ('color' in options || + 'colors' in options) { + colorBuffer = + options.color || + options.colors + if (Array.isArray(colorBuffer)) { + check$1( + colorBuffer.length === 1 || extensions.webgl_draw_buffers, + 'multiple render targets not supported') + } + } -return wrapREGL; + if (!colorBuffer) { + if ('colorCount' in options) { + colorCount = options.colorCount | 0 + check$1(colorCount > 0, 'invalid color buffer count') + } -}))); -//# sourceMappingURL=regl.js.map + if ('colorTexture' in options) { + colorTexture = !!options.colorTexture + colorFormat = 'rgba4' + } + if ('colorType' in options) { + colorType = options.colorType + if (!colorTexture) { + if (colorType === 'half float' || colorType === 'float16') { + check$1(extensions.ext_color_buffer_half_float, + 'you must enable EXT_color_buffer_half_float to use 16-bit render buffers') + colorFormat = 'rgba16f' + } else if (colorType === 'float' || colorType === 'float32') { + check$1(extensions.webgl_color_buffer_float, + 'you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers') + colorFormat = 'rgba32f' + } + } else { + check$1(extensions.oes_texture_float || + !(colorType === 'float' || colorType === 'float32'), + 'you must enable OES_texture_float in order to use floating point framebuffer objects') + check$1(extensions.oes_texture_half_float || + !(colorType === 'half float' || colorType === 'float16'), + 'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects') + } + check$1.oneOf(colorType, colorTypes, 'invalid color type') + } -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { + if ('colorFormat' in options) { + colorFormat = options.colorFormat + if (colorTextureFormats.indexOf(colorFormat) >= 0) { + colorTexture = true + } else if (colorRenderbufferFormats.indexOf(colorFormat) >= 0) { + colorTexture = false + } else { + if (colorTexture) { + check$1.oneOf( + options.colorFormat, colorTextureFormats, + 'invalid color format for texture') + } else { + check$1.oneOf( + options.colorFormat, colorRenderbufferFormats, + 'invalid color format for renderbuffer') + } + } + } + } -var Emitter = __webpack_require__(24) + if ('depthTexture' in options || 'depthStencilTexture' in options) { + depthStencilTexture = !!(options.depthTexture || + options.depthStencilTexture) + check$1(!depthStencilTexture || extensions.webgl_depth_texture, + 'webgl_depth_texture extension not supported') + } -module.exports = attach + if ('depth' in options) { + if (typeof options.depth === 'boolean') { + needsDepth = options.depth + } else { + depthBuffer = options.depth + needsStencil = false + } + } -function attach(element, listener) { - var position = new Emitter + if ('stencil' in options) { + if (typeof options.stencil === 'boolean') { + needsStencil = options.stencil + } else { + stencilBuffer = options.stencil + needsDepth = false + } + } - position[0] = 0 - position[1] = 0 - position.prev = [0, 0] - position.flush = flush + if ('depthStencil' in options) { + if (typeof options.depthStencil === 'boolean') { + needsDepth = needsStencil = options.depthStencil + } else { + depthStencilBuffer = options.depthStencil + needsDepth = false + needsStencil = false + } + } + } - if (typeof window === 'undefined') { - return position - } + // parse attachments + var colorAttachments = null + var depthAttachment = null + var stencilAttachment = null + var depthStencilAttachment = null - listener = listener || element || window - element = element || document.body - listener.addEventListener('mousemove', ( - element === document.body - || element === window - ) ? function(e) { - position.prev[0] = position[0] - position.prev[1] = position[1] - position[0] = e.clientX - position[1] = e.clientY - position.emit('move', e) - } - : function(e) { - position.prev[0] = position[0] - position.prev[1] = position[1] - var bounds = element.getBoundingClientRect() - position[0] = e.clientX - bounds.left - position[1] = e.clientY - bounds.top - position.emit('move', e) - } - , false) + // Set up color attachments + if (Array.isArray(colorBuffer)) { + colorAttachments = colorBuffer.map(parseAttachment) + } else if (colorBuffer) { + colorAttachments = [parseAttachment(colorBuffer)] + } else { + colorAttachments = new Array(colorCount) + for (i = 0; i < colorCount; ++i) { + colorAttachments[i] = allocAttachment( + width, + height, + colorTexture, + colorFormat, + colorType) + } + } - return position + check$1(extensions.webgl_draw_buffers || colorAttachments.length <= 1, + 'you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers.') + check$1(colorAttachments.length <= limits.maxColorAttachments, + 'too many color attachments, not supported') - function flush() { - position.prev[0] = position[0] - position.prev[1] = position[1] - } -} + width = width || colorAttachments[0].width + height = height || colorAttachments[0].height + if (depthBuffer) { + depthAttachment = parseAttachment(depthBuffer) + } else if (needsDepth && !needsStencil) { + depthAttachment = allocAttachment( + width, + height, + depthStencilTexture, + 'depth', + 'uint32') + } -/***/ }), -/* 24 */ -/***/ (function(module, exports) { + if (stencilBuffer) { + stencilAttachment = parseAttachment(stencilBuffer) + } else if (needsStencil && !needsDepth) { + stencilAttachment = allocAttachment( + width, + height, + false, + 'stencil', + 'uint8') + } -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. + if (depthStencilBuffer) { + depthStencilAttachment = parseAttachment(depthStencilBuffer) + } else if (!depthBuffer && !stencilBuffer && needsStencil && needsDepth) { + depthStencilAttachment = allocAttachment( + width, + height, + depthStencilTexture, + 'depth stencil', + 'depth stencil') + } -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; + check$1( + (!!depthBuffer) + (!!stencilBuffer) + (!!depthStencilBuffer) <= 1, + 'invalid framebuffer configuration, can specify exactly one depth/stencil attachment') -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; + var commonColorAttachmentSize = null -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; + for (i = 0; i < colorAttachments.length; ++i) { + incRefAndCheckShape(colorAttachments[i], width, height) + check$1(!colorAttachments[i] || + (colorAttachments[i].texture && + colorTextureFormatEnums.indexOf(colorAttachments[i].texture._texture.format) >= 0) || + (colorAttachments[i].renderbuffer && + colorRenderbufferFormatEnums.indexOf(colorAttachments[i].renderbuffer._renderbuffer.format) >= 0), + 'framebuffer color attachment ' + i + ' is invalid') -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; + if (colorAttachments[i] && colorAttachments[i].texture) { + var colorAttachmentSize = + textureFormatChannels[colorAttachments[i].texture._texture.format] * + textureTypeSizes[colorAttachments[i].texture._texture.type] -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; + if (commonColorAttachmentSize === null) { + commonColorAttachmentSize = colorAttachmentSize + } else { + // We need to make sure that all color attachments have the same number of bitplanes + // (that is, the same numer of bits per pixel) + // This is required by the GLES2.0 standard. See the beginning of Chapter 4 in that document. + check$1(commonColorAttachmentSize === colorAttachmentSize, + 'all color attachments much have the same number of bits per pixel.') + } + } + } + incRefAndCheckShape(depthAttachment, width, height) + check$1(!depthAttachment || + (depthAttachment.texture && + depthAttachment.texture._texture.format === GL_DEPTH_COMPONENT$1) || + (depthAttachment.renderbuffer && + depthAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_COMPONENT16$1), + 'invalid depth attachment for framebuffer object') + incRefAndCheckShape(stencilAttachment, width, height) + check$1(!stencilAttachment || + (stencilAttachment.renderbuffer && + stencilAttachment.renderbuffer._renderbuffer.format === GL_STENCIL_INDEX8$1), + 'invalid stencil attachment for framebuffer object') + incRefAndCheckShape(depthStencilAttachment, width, height) + check$1(!depthStencilAttachment || + (depthStencilAttachment.texture && + depthStencilAttachment.texture._texture.format === GL_DEPTH_STENCIL$2) || + (depthStencilAttachment.renderbuffer && + depthStencilAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_STENCIL$2), + 'invalid depth-stencil attachment for framebuffer object') -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; + // decrement references + decFBORefs(framebuffer) - if (!this._events) - this._events = {}; + framebuffer.width = width + framebuffer.height = height - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } + framebuffer.colorAttachments = colorAttachments + framebuffer.depthAttachment = depthAttachment + framebuffer.stencilAttachment = stencilAttachment + framebuffer.depthStencilAttachment = depthStencilAttachment - handler = this._events[type]; + reglFramebuffer.color = colorAttachments.map(unwrapAttachment) + reglFramebuffer.depth = unwrapAttachment(depthAttachment) + reglFramebuffer.stencil = unwrapAttachment(stencilAttachment) + reglFramebuffer.depthStencil = unwrapAttachment(depthStencilAttachment) - if (isUndefined(handler)) - return false; + reglFramebuffer.width = framebuffer.width + reglFramebuffer.height = framebuffer.height - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } + updateFramebuffer(framebuffer) - return true; -}; + return reglFramebuffer + } -EventEmitter.prototype.addListener = function(type, listener) { - var m; + function resize (w_, h_) { + check$1(framebufferState.next !== framebuffer, + 'can not resize a framebuffer which is currently in use') - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + var w = Math.max(w_ | 0, 1) + var h = Math.max((h_ | 0) || w, 1) + if (w === framebuffer.width && h === framebuffer.height) { + return reglFramebuffer + } - if (!this._events) - this._events = {}; + // resize all buffers + var colorAttachments = framebuffer.colorAttachments + for (var i = 0; i < colorAttachments.length; ++i) { + resizeAttachment(colorAttachments[i], w, h) + } + resizeAttachment(framebuffer.depthAttachment, w, h) + resizeAttachment(framebuffer.stencilAttachment, w, h) + resizeAttachment(framebuffer.depthStencilAttachment, w, h) - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); + framebuffer.width = reglFramebuffer.width = w + framebuffer.height = reglFramebuffer.height = h - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; + updateFramebuffer(framebuffer) - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; + return reglFramebuffer } - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); + reglFramebuffer(a0, a1) + + return extend(reglFramebuffer, { + resize: resize, + _reglType: 'framebuffer', + _framebuffer: framebuffer, + destroy: function () { + destroy(framebuffer) + decFBORefs(framebuffer) + }, + use: function (block) { + framebufferState.setFBO({ + framebuffer: reglFramebuffer + }, block) } - } + }) } - return this; -}; + function createCubeFBO (options) { + var faces = Array(6) -EventEmitter.prototype.on = EventEmitter.prototype.addListener; + function reglFramebufferCube (a) { + var i -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + check$1(faces.indexOf(framebufferState.next) < 0, + 'can not update framebuffer which is currently in use') - var fired = false; + var params = { + color: null + } - function g() { - this.removeListener(type, g); + var radius = 0 - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } + var colorBuffer = null + var colorFormat = 'rgba' + var colorType = 'uint8' + var colorCount = 1 - g.listener = listener; - this.on(type, g); + if (typeof a === 'number') { + radius = a | 0 + } else if (!a) { + radius = 1 + } else { + check$1.type(a, 'object', 'invalid arguments for framebuffer') + var options = a - return this; -}; + if ('shape' in options) { + var shape = options.shape + check$1( + Array.isArray(shape) && shape.length >= 2, + 'invalid shape for framebuffer') + check$1( + shape[0] === shape[1], + 'cube framebuffer must be square') + radius = shape[0] + } else { + if ('radius' in options) { + radius = options.radius | 0 + } + if ('width' in options) { + radius = options.width | 0 + if ('height' in options) { + check$1(options.height === radius, 'must be square') + } + } else if ('height' in options) { + radius = options.height | 0 + } + } + + if ('color' in options || + 'colors' in options) { + colorBuffer = + options.color || + options.colors + if (Array.isArray(colorBuffer)) { + check$1( + colorBuffer.length === 1 || extensions.webgl_draw_buffers, + 'multiple render targets not supported') + } + } + + if (!colorBuffer) { + if ('colorCount' in options) { + colorCount = options.colorCount | 0 + check$1(colorCount > 0, 'invalid color buffer count') + } + + if ('colorType' in options) { + check$1.oneOf( + options.colorType, colorTypes, + 'invalid color type') + colorType = options.colorType + } -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; + if ('colorFormat' in options) { + colorFormat = options.colorFormat + check$1.oneOf( + options.colorFormat, colorTextureFormats, + 'invalid color format for texture') + } + } - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + if ('depth' in options) { + params.depth = options.depth + } - if (!this._events || !this._events[type]) - return this; + if ('stencil' in options) { + params.stencil = options.stencil + } - list = this._events[type]; - length = list.length; - position = -1; + if ('depthStencil' in options) { + params.depthStencil = options.depthStencil + } + } - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); + var colorCubes + if (colorBuffer) { + if (Array.isArray(colorBuffer)) { + colorCubes = [] + for (i = 0; i < colorBuffer.length; ++i) { + colorCubes[i] = colorBuffer[i] + } + } else { + colorCubes = [ colorBuffer ] + } + } else { + colorCubes = Array(colorCount) + var cubeMapParams = { + radius: radius, + format: colorFormat, + type: colorType + } + for (i = 0; i < colorCount; ++i) { + colorCubes[i] = textureState.createCube(cubeMapParams) + } + } - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; + // Check color cubes + params.color = Array(colorCubes.length) + for (i = 0; i < colorCubes.length; ++i) { + var cube = colorCubes[i] + check$1( + typeof cube === 'function' && cube._reglType === 'textureCube', + 'invalid cube map') + radius = radius || cube.width + check$1( + cube.width === radius && cube.height === radius, + 'invalid cube map shape') + params.color[i] = { + target: GL_TEXTURE_CUBE_MAP_POSITIVE_X$2, + data: colorCubes[i] + } } - } - if (position < 0) - return this; + for (i = 0; i < 6; ++i) { + for (var j = 0; j < colorCubes.length; ++j) { + params.color[j].target = GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 + i + } + // reuse depth-stencil attachments across all cube maps + if (i > 0) { + params.depth = faces[0].depth + params.stencil = faces[0].stencil + params.depthStencil = faces[0].depthStencil + } + if (faces[i]) { + (faces[i])(params) + } else { + faces[i] = createFBO(params) + } + } - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); + return extend(reglFramebufferCube, { + width: radius, + height: radius, + color: colorCubes + }) } - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } + function resize (radius_) { + var i + var radius = radius_ | 0 + check$1(radius > 0 && radius <= limits.maxCubeMapSize, + 'invalid radius for cube fbo') - return this; -}; + if (radius === reglFramebufferCube.width) { + return reglFramebufferCube + } -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; + var colors = reglFramebufferCube.color + for (i = 0; i < colors.length; ++i) { + colors[i].resize(radius) + } - if (!this._events) - return this; + for (i = 0; i < 6; ++i) { + faces[i].resize(radius) + } - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } + reglFramebufferCube.width = reglFramebufferCube.height = radius - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); + return reglFramebufferCube } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - listeners = this._events[type]; + reglFramebufferCube(options) - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); + return extend(reglFramebufferCube, { + faces: faces, + resize: resize, + _reglType: 'framebufferCube', + destroy: function () { + faces.forEach(function (f) { + f.destroy() + }) + } + }) } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; + function restoreFramebuffers () { + framebufferState.cur = null + framebufferState.next = null + framebufferState.dirty = true + values(framebufferSet).forEach(function (fb) { + fb.framebuffer = gl.createFramebuffer() + updateFramebuffer(fb) + }) } - return 0; -}; -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; + return extend(framebufferState, { + getFramebuffer: function (object) { + if (typeof object === 'function' && object._reglType === 'framebuffer') { + var fbo = object._framebuffer + if (fbo instanceof REGLFramebuffer) { + return fbo + } + } + return null + }, + create: createFBO, + createCube: createCubeFBO, + clear: function () { + values(framebufferSet).forEach(destroy) + }, + restore: restoreFramebuffers + }) } -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} +var GL_FLOAT$6 = 5126 +var GL_ARRAY_BUFFER$1 = 34962 -function isUndefined(arg) { - return arg === void 0; +function AttributeRecord () { + this.state = 0 + + this.x = 0.0 + this.y = 0.0 + this.z = 0.0 + this.w = 0.0 + + this.buffer = null + this.size = 0 + this.normalized = false + this.type = GL_FLOAT$6 + this.offset = 0 + this.stride = 0 + this.divisor = 0 } +function wrapAttributeState ( + gl, + extensions, + limits, + stats, + bufferState) { + var NUM_ATTRIBUTES = limits.maxAttributes + var attributeBindings = new Array(NUM_ATTRIBUTES) + for (var i = 0; i < NUM_ATTRIBUTES; ++i) { + attributeBindings[i] = new AttributeRecord() + } + var vaoCount = 0 + var vaoSet = {} -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - -var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */ -/** - * Copyright 2012-2017 Craig Campbell - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Mousetrap is a simple keyboard shortcut library for Javascript with - * no external dependencies - * - * @version 1.6.1 - * @url craig.is/killing/mice - */ -(function(window, document, undefined) { + var state = { + Record: AttributeRecord, + scope: {}, + state: attributeBindings, + currentVAO: null, + targetVAO: null, + restore: extVAO() ? restoreVAO : function () {}, + createVAO: createVAO, + getVAO: getVAO, + destroyBuffer: destroyBuffer, + setVAO: extVAO() ? setVAOEXT : setVAOEmulated, + clear: extVAO() ? destroyVAOEXT : function () {} + } - // Check if mousetrap is used inside browser, if not, return - if (!window) { - return; + function destroyBuffer (buffer) { + for (var i = 0; i < attributeBindings.length; ++i) { + var record = attributeBindings[i] + if (record.buffer === buffer) { + gl.disableVertexAttribArray(i) + record.buffer = null + } } + } - /** - * mapping of special keycodes to their corresponding keys - * - * everything in this dictionary cannot use keypress events - * so it has to be here to map to the correct keycodes for - * keyup/keydown events - * - * @type {Object} - */ - var _MAP = { - 8: 'backspace', - 9: 'tab', - 13: 'enter', - 16: 'shift', - 17: 'ctrl', - 18: 'alt', - 20: 'capslock', - 27: 'esc', - 32: 'space', - 33: 'pageup', - 34: 'pagedown', - 35: 'end', - 36: 'home', - 37: 'left', - 38: 'up', - 39: 'right', - 40: 'down', - 45: 'ins', - 46: 'del', - 91: 'meta', - 93: 'meta', - 224: 'meta' - }; - - /** - * mapping for special characters so they can support - * - * this dictionary is only used incase you want to bind a - * keyup or keydown event to one of these keys - * - * @type {Object} - */ - var _KEYCODE_MAP = { - 106: '*', - 107: '+', - 109: '-', - 110: '.', - 111 : '/', - 186: ';', - 187: '=', - 188: ',', - 189: '-', - 190: '.', - 191: '/', - 192: '`', - 219: '[', - 220: '\\', - 221: ']', - 222: '\'' - }; - - /** - * this is a mapping of keys that require shift on a US keypad - * back to the non shift equivelents - * - * this is so you can use keyup events with these keys - * - * note that this will only work reliably on US keyboards - * - * @type {Object} - */ - var _SHIFT_MAP = { - '~': '`', - '!': '1', - '@': '2', - '#': '3', - '$': '4', - '%': '5', - '^': '6', - '&': '7', - '*': '8', - '(': '9', - ')': '0', - '_': '-', - '+': '=', - ':': ';', - '\"': '\'', - '<': ',', - '>': '.', - '?': '/', - '|': '\\' - }; - - /** - * this is a list of special strings you can use to map - * to modifier keys when you specify your keyboard shortcuts - * - * @type {Object} - */ - var _SPECIAL_ALIASES = { - 'option': 'alt', - 'command': 'meta', - 'return': 'enter', - 'escape': 'esc', - 'plus': '+', - 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl' - }; + function extVAO () { + return extensions.oes_vertex_array_object + } - /** - * variable to store the flipped version of _MAP from above - * needed to check if we should use keypress or not when no action - * is specified - * - * @type {Object|undefined} - */ - var _REVERSE_MAP; + function extInstanced () { + return extensions.angle_instanced_arrays + } - /** - * loop through the f keys, f1 to f19 and add them to the map - * programatically - */ - for (var i = 1; i < 20; ++i) { - _MAP[111 + i] = 'f' + i; + function getVAO (vao) { + if (typeof vao === 'function' && vao._vao) { + return vao._vao } + return null + } - /** - * loop through to map numbers on the numeric keypad - */ - for (i = 0; i <= 9; ++i) { - - // This needs to use a string cause otherwise since 0 is falsey - // mousetrap will never fire for numpad 0 pressed as part of a keydown - // event. - // - // @see https://github.com/ccampbell/mousetrap/pull/258 - _MAP[i + 96] = i.toString(); + function setVAOEXT (vao) { + if (vao === state.currentVAO) { + return + } + var ext = extVAO() + if (vao) { + ext.bindVertexArrayOES(vao.vao) + } else { + ext.bindVertexArrayOES(null) } + state.currentVAO = vao + } - /** - * cross browser add event method - * - * @param {Element|HTMLDocument} object - * @param {string} type - * @param {Function} callback - * @returns void - */ - function _addEvent(object, type, callback) { - if (object.addEventListener) { - object.addEventListener(type, callback, false); - return; + function setVAOEmulated (vao) { + if (vao === state.currentVAO) { + return + } + if (vao) { + vao.bindAttrs() + } else { + var exti = extInstanced() + for (var i = 0; i < attributeBindings.length; ++i) { + var binding = attributeBindings[i] + if (binding.buffer) { + gl.enableVertexAttribArray(i) + gl.vertexAttribPointer(i, binding.size, binding.type, binding.normalized, binding.stride, binding.offfset) + if (exti && binding.divisor) { + exti.vertexAttribDivisorANGLE(i, binding.divisor) + } + } else { + gl.disableVertexAttribArray(i) + gl.vertexAttrib4f(i, binding.x, binding.y, binding.z, binding.w) } + } + } + state.currentVAO = vao + } + + function destroyVAOEXT () { + values(vaoSet).forEach(function (vao) { + vao.destroy() + }) + } - object.attachEvent('on' + type, callback); + function REGLVAO () { + this.id = ++vaoCount + this.attributes = [] + var extension = extVAO() + if (extension) { + this.vao = extension.createVertexArrayOES() + } else { + this.vao = null } + vaoSet[this.id] = this + this.buffers = [] + } - /** - * takes the event and returns the key character - * - * @param {Event} e - * @return {string} - */ - function _characterFromEvent(e) { + REGLVAO.prototype.bindAttrs = function () { + var exti = extInstanced() + var attributes = this.attributes + for (var i = 0; i < attributes.length; ++i) { + var attr = attributes[i] + if (attr.buffer) { + gl.enableVertexAttribArray(i) + gl.bindBuffer(GL_ARRAY_BUFFER$1, attr.buffer.buffer) + gl.vertexAttribPointer(i, attr.size, attr.type, attr.normalized, attr.stride, attr.offset) + if (exti && attr.divisor) { + exti.vertexAttribDivisorANGLE(i, attr.divisor) + } + } else { + gl.disableVertexAttribArray(i) + gl.vertexAttrib4f(i, attr.x, attr.y, attr.z, attr.w) + } + } + for (var j = attributes.length; j < NUM_ATTRIBUTES; ++j) { + gl.disableVertexAttribArray(j) + } + } - // for keypress events we should return the character as is - if (e.type == 'keypress') { - var character = String.fromCharCode(e.which); + REGLVAO.prototype.refresh = function () { + var ext = extVAO() + if (ext) { + ext.bindVertexArrayOES(this.vao) + this.bindAttrs() + state.currentVAO = this + } + } - // if the shift key is not pressed then it is safe to assume - // that we want the character to be lowercase. this means if - // you accidentally have caps lock on then your key bindings - // will continue to work - // - // the only side effect that might not be desired is if you - // bind something like 'A' cause you want to trigger an - // event when capital A is pressed caps lock will no longer - // trigger the event. shift+a will though. - if (!e.shiftKey) { - character = character.toLowerCase(); - } + REGLVAO.prototype.destroy = function () { + if (this.vao) { + var extension = extVAO() + if (this === state.currentVAO) { + state.currentVAO = null + extension.bindVertexArrayOES(null) + } + extension.deleteVertexArrayOES(this.vao) + this.vao = null + } + if (vaoSet[this.id]) { + delete vaoSet[this.id] + stats.vaoCount -= 1 + } + } - return character; - } + function restoreVAO () { + var ext = extVAO() + if (ext) { + values(vaoSet).forEach(function (vao) { + vao.refresh() + }) + } + } - // for non keypress events the special maps are needed - if (_MAP[e.which]) { - return _MAP[e.which]; + function createVAO (_attr) { + var vao = new REGLVAO() + stats.vaoCount += 1 + + function updateVAO (attributes) { + check$1(Array.isArray(attributes), 'arguments to vertex array constructor must be an array') + check$1(attributes.length < NUM_ATTRIBUTES, 'too many attributes') + check$1(attributes.length > 0, 'must specify at least one attribute') + + var bufUpdated = {} + var nattributes = vao.attributes + nattributes.length = attributes.length + for (var i = 0; i < attributes.length; ++i) { + var spec = attributes[i] + var rec = nattributes[i] = new AttributeRecord() + var data = spec.data || spec + if (Array.isArray(data) || isTypedArray(data) || isNDArrayLike(data)) { + var buf + if (vao.buffers[i]) { + buf = vao.buffers[i] + if (isTypedArray(data) && buf._buffer.byteLength >= data.byteLength) { + buf.subdata(data) + } else { + buf.destroy() + vao.buffers[i] = null + } + } + if (!vao.buffers[i]) { + buf = vao.buffers[i] = bufferState.create(spec, GL_ARRAY_BUFFER$1, false, true) + } + rec.buffer = bufferState.getBuffer(buf) + rec.size = rec.buffer.dimension | 0 + rec.normalized = false + rec.type = rec.buffer.dtype + rec.offset = 0 + rec.stride = 0 + rec.divisor = 0 + rec.state = 1 + bufUpdated[i] = 1 + } else if (bufferState.getBuffer(spec)) { + rec.buffer = bufferState.getBuffer(spec) + rec.size = rec.buffer.dimension | 0 + rec.normalized = false + rec.type = rec.buffer.dtype + rec.offset = 0 + rec.stride = 0 + rec.divisor = 0 + rec.state = 1 + } else if (bufferState.getBuffer(spec.buffer)) { + rec.buffer = bufferState.getBuffer(spec.buffer) + rec.size = ((+spec.size) || rec.buffer.dimension) | 0 + rec.normalized = !!spec.normalized || false + if ('type' in spec) { + check$1.parameter(spec.type, glTypes, 'invalid buffer type') + rec.type = glTypes[spec.type] + } else { + rec.type = rec.buffer.dtype + } + rec.offset = (spec.offset || 0) | 0 + rec.stride = (spec.stride || 0) | 0 + rec.divisor = (spec.divisor || 0) | 0 + rec.state = 1 + + check$1(rec.size >= 1 && rec.size <= 4, 'size must be between 1 and 4') + check$1(rec.offset >= 0, 'invalid offset') + check$1(rec.stride >= 0 && rec.stride <= 255, 'stride must be between 0 and 255') + check$1(rec.divisor >= 0, 'divisor must be positive') + check$1(!rec.divisor || !!extensions.angle_instanced_arrays, 'ANGLE_instanced_arrays must be enabled to use divisor') + } else if ('x' in spec) { + check$1(i > 0, 'first attribute must not be a constant') + rec.x = +spec.x || 0 + rec.y = +spec.y || 0 + rec.z = +spec.z || 0 + rec.w = +spec.w || 0 + rec.state = 2 + } else { + check$1(false, 'invalid attribute spec for location ' + i) } + } - if (_KEYCODE_MAP[e.which]) { - return _KEYCODE_MAP[e.which]; + // retire unused buffers + for (var j = 0; j < vao.buffers.length; ++j) { + if (!bufUpdated[j] && vao.buffers[j]) { + vao.buffers[j].destroy() + vao.buffers[j] = null } + } - // if it is not in the special map - - // with keydown and keyup events the character seems to always - // come in as an uppercase character whether you are pressing shift - // or not. we should make sure it is always lowercase for comparisons - return String.fromCharCode(e.which).toLowerCase(); + vao.refresh() + return updateVAO } - /** - * checks if two arrays are equal - * - * @param {Array} modifiers1 - * @param {Array} modifiers2 - * @returns {boolean} - */ - function _modifiersMatch(modifiers1, modifiers2) { - return modifiers1.sort().join(',') === modifiers2.sort().join(','); + updateVAO.destroy = function () { + for (var j = 0; j < vao.buffers.length; ++j) { + if (vao.buffers[j]) { + vao.buffers[j].destroy() + } + } + vao.buffers.length = 0 + vao.destroy() } - /** - * takes a key event and figures out what the modifiers are - * - * @param {Event} e - * @returns {Array} - */ - function _eventModifiers(e) { - var modifiers = []; + updateVAO._vao = vao + updateVAO._reglType = 'vao' - if (e.shiftKey) { - modifiers.push('shift'); - } + return updateVAO(_attr) + } - if (e.altKey) { - modifiers.push('alt'); - } + return state +} - if (e.ctrlKey) { - modifiers.push('ctrl'); - } +var GL_FRAGMENT_SHADER = 35632 +var GL_VERTEX_SHADER = 35633 - if (e.metaKey) { - modifiers.push('meta'); - } +var GL_ACTIVE_UNIFORMS = 0x8B86 +var GL_ACTIVE_ATTRIBUTES = 0x8B89 - return modifiers; - } +function wrapShaderState (gl, stringStore, stats, config) { + // =================================================== + // glsl compilation and linking + // =================================================== + var fragShaders = {} + var vertShaders = {} - /** - * prevents default for this event - * - * @param {Event} e - * @returns void - */ - function _preventDefault(e) { - if (e.preventDefault) { - e.preventDefault(); - return; - } + function ActiveInfo (name, id, location, info) { + this.name = name + this.id = id + this.location = location + this.info = info + } - e.returnValue = false; + function insertActiveInfo (list, info) { + for (var i = 0; i < list.length; ++i) { + if (list[i].id === info.id) { + list[i].location = info.location + return + } } + list.push(info) + } - /** - * stops propogation for this event - * - * @param {Event} e - * @returns void - */ - function _stopPropagation(e) { - if (e.stopPropagation) { - e.stopPropagation(); - return; - } + function getShader (type, id, command) { + var cache = type === GL_FRAGMENT_SHADER ? fragShaders : vertShaders + var shader = cache[id] - e.cancelBubble = true; + if (!shader) { + var source = stringStore.str(id) + shader = gl.createShader(type) + gl.shaderSource(shader, source) + gl.compileShader(shader) + check$1.shaderError(gl, shader, source, type, command) + cache[id] = shader } - /** - * determines if the keycode specified is a modifier key or not - * - * @param {string} key - * @returns {boolean} - */ - function _isModifier(key) { - return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta'; + return shader + } + + // =================================================== + // program linking + // =================================================== + var programCache = {} + var programList = [] + + var PROGRAM_COUNTER = 0 + + function REGLProgram (fragId, vertId) { + this.id = PROGRAM_COUNTER++ + this.fragId = fragId + this.vertId = vertId + this.program = null + this.uniforms = [] + this.attributes = [] + this.refCount = 1 + + if (config.profile) { + this.stats = { + uniformsCount: 0, + attributesCount: 0 + } } + } - /** - * reverses the map lookup so that we can look for specific keys - * to see what can and can't use keypress - * - * @return {Object} - */ - function _getReverseMap() { - if (!_REVERSE_MAP) { - _REVERSE_MAP = {}; - for (var key in _MAP) { + function linkProgram (desc, command, attributeLocations) { + var i, info - // pull out the numeric keypad from here cause keypress should - // be able to detect the keys from the character - if (key > 95 && key < 112) { - continue; - } + // ------------------------------- + // compile & link + // ------------------------------- + var fragShader = getShader(GL_FRAGMENT_SHADER, desc.fragId) + var vertShader = getShader(GL_VERTEX_SHADER, desc.vertId) - if (_MAP.hasOwnProperty(key)) { - _REVERSE_MAP[_MAP[key]] = key; - } - } - } - return _REVERSE_MAP; + var program = desc.program = gl.createProgram() + gl.attachShader(program, fragShader) + gl.attachShader(program, vertShader) + if (attributeLocations) { + for (i = 0; i < attributeLocations.length; ++i) { + var binding = attributeLocations[i] + gl.bindAttribLocation(program, binding[0], binding[1]) + } } - /** - * picks the best action based on the key combination - * - * @param {string} key - character for key - * @param {Array} modifiers - * @param {string=} action passed in - */ - function _pickBestAction(key, modifiers, action) { + gl.linkProgram(program) + check$1.linkError( + gl, + program, + stringStore.str(desc.fragId), + stringStore.str(desc.vertId), + command) - // if no action was picked in we should try to pick the one - // that we think would work best for this key - if (!action) { - action = _getReverseMap()[key] ? 'keydown' : 'keypress'; + // ------------------------------- + // grab uniforms + // ------------------------------- + var numUniforms = gl.getProgramParameter(program, GL_ACTIVE_UNIFORMS) + if (config.profile) { + desc.stats.uniformsCount = numUniforms + } + var uniforms = desc.uniforms + for (i = 0; i < numUniforms; ++i) { + info = gl.getActiveUniform(program, i) + if (info) { + if (info.size > 1) { + for (var j = 0; j < info.size; ++j) { + var name = info.name.replace('[0]', '[' + j + ']') + insertActiveInfo(uniforms, new ActiveInfo( + name, + stringStore.id(name), + gl.getUniformLocation(program, name), + info)) + } + } else { + insertActiveInfo(uniforms, new ActiveInfo( + info.name, + stringStore.id(info.name), + gl.getUniformLocation(program, info.name), + info)) } + } + } - // modifier keys don't work as expected with keypress, - // switch to keydown - if (action == 'keypress' && modifiers.length) { - action = 'keydown'; - } + // ------------------------------- + // grab attributes + // ------------------------------- + var numAttributes = gl.getProgramParameter(program, GL_ACTIVE_ATTRIBUTES) + if (config.profile) { + desc.stats.attributesCount = numAttributes + } - return action; + var attributes = desc.attributes + for (i = 0; i < numAttributes; ++i) { + info = gl.getActiveAttrib(program, i) + if (info) { + insertActiveInfo(attributes, new ActiveInfo( + info.name, + stringStore.id(info.name), + gl.getAttribLocation(program, info.name), + info)) + } } + } - /** - * Converts from a string key combination to an array - * - * @param {string} combination like "command+shift+l" - * @return {Array} - */ - function _keysFromString(combination) { - if (combination === '+') { - return ['+']; + if (config.profile) { + stats.getMaxUniformsCount = function () { + var m = 0 + programList.forEach(function (desc) { + if (desc.stats.uniformsCount > m) { + m = desc.stats.uniformsCount } + }) + return m + } - combination = combination.replace(/\+{2}/g, '+plus'); - return combination.split('+'); + stats.getMaxAttributesCount = function () { + var m = 0 + programList.forEach(function (desc) { + if (desc.stats.attributesCount > m) { + m = desc.stats.attributesCount + } + }) + return m } + } - /** - * Gets info for a specific key combination - * - * @param {string} combination key combination ("command+s" or "a" or "*") - * @param {string=} action - * @returns {Object} - */ - function _getKeyInfo(combination, action) { - var keys; - var key; - var i; - var modifiers = []; + function restoreShaders () { + fragShaders = {} + vertShaders = {} + for (var i = 0; i < programList.length; ++i) { + linkProgram(programList[i], null, programList[i].attributes.map(function (info) { + return [info.location, info.name] + })) + } + } - // take the keys from this pattern and figure out what the actual - // pattern is all about - keys = _keysFromString(combination); + return { + clear: function () { + var deleteShader = gl.deleteShader.bind(gl) + values(fragShaders).forEach(deleteShader) + fragShaders = {} + values(vertShaders).forEach(deleteShader) + vertShaders = {} - for (i = 0; i < keys.length; ++i) { - key = keys[i]; + programList.forEach(function (desc) { + gl.deleteProgram(desc.program) + }) + programList.length = 0 + programCache = {} - // normalize key names - if (_SPECIAL_ALIASES[key]) { - key = _SPECIAL_ALIASES[key]; - } + stats.shaderCount = 0 + }, - // if this is not a keypress event then we should - // be smart about using shift keys - // this will only work for US keyboards however - if (action && action != 'keypress' && _SHIFT_MAP[key]) { - key = _SHIFT_MAP[key]; - modifiers.push('shift'); - } + program: function (vertId, fragId, command, attribLocations) { + check$1.command(vertId >= 0, 'missing vertex shader', command) + check$1.command(fragId >= 0, 'missing fragment shader', command) - // if this key is a modifier then add it to the list of modifiers - if (_isModifier(key)) { - modifiers.push(key); - } + var cache = programCache[fragId] + if (!cache) { + cache = programCache[fragId] = {} + } + var prevProgram = cache[vertId] + if (prevProgram) { + prevProgram.refCount++ + if (!attribLocations) { + return prevProgram + } + } + var program = new REGLProgram(fragId, vertId) + stats.shaderCount++ + linkProgram(program, command, attribLocations) + if (!prevProgram) { + cache[vertId] = program + } + programList.push(program) + return extend(program, { + destroy: function () { + program.refCount-- + if (program.refCount <= 0) { + gl.deleteProgram(program.program) + var idx = programList.indexOf(program) + programList.splice(idx, 1) + stats.shaderCount-- + } + // no program is linked to this vert anymore + if (cache[program.vertId].refCount <= 0) { + gl.deleteShader(vertShaders[program.vertId]) + delete vertShaders[program.vertId] + delete programCache[program.fragId][program.vertId] + } + // no program is linked to this frag anymore + if (!Object.keys(programCache[program.fragId]).length) { + gl.deleteShader(fragShaders[program.fragId]) + delete fragShaders[program.fragId] + delete programCache[program.fragId] + } } + }) + }, - // depending on what the key combination is - // we will try to pick the best event for it - action = _pickBestAction(key, modifiers, action); + restore: restoreShaders, - return { - key: key, - modifiers: modifiers, - action: action - }; - } + shader: getShader, - function _belongsTo(element, ancestor) { - if (element === null || element === document) { - return false; - } + frag: -1, + vert: -1 + } +} - if (element === ancestor) { - return true; - } +var GL_RGBA$3 = 6408 +var GL_UNSIGNED_BYTE$7 = 5121 +var GL_PACK_ALIGNMENT = 0x0D05 +var GL_FLOAT$7 = 0x1406 // 5126 - return _belongsTo(element.parentNode, ancestor); +function wrapReadPixels ( + gl, + framebufferState, + reglPoll, + context, + glAttributes, + extensions, + limits) { + function readPixelsImpl (input) { + var type + if (framebufferState.next === null) { + check$1( + glAttributes.preserveDrawingBuffer, + 'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer') + type = GL_UNSIGNED_BYTE$7 + } else { + check$1( + framebufferState.next.colorAttachments[0].texture !== null, + 'You cannot read from a renderbuffer') + type = framebufferState.next.colorAttachments[0].texture._texture.type + + if (extensions.oes_texture_float) { + check$1( + type === GL_UNSIGNED_BYTE$7 || type === GL_FLOAT$7, + 'Reading from a framebuffer is only allowed for the types \'uint8\' and \'float\'') + + if (type === GL_FLOAT$7) { + check$1(limits.readFloat, 'Reading \'float\' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float') + } + } else { + check$1( + type === GL_UNSIGNED_BYTE$7, + 'Reading from a framebuffer is only allowed for the type \'uint8\'') + } } - function Mousetrap(targetElement) { - var self = this; + var x = 0 + var y = 0 + var width = context.framebufferWidth + var height = context.framebufferHeight + var data = null - targetElement = targetElement || document; + if (isTypedArray(input)) { + data = input + } else if (input) { + check$1.type(input, 'object', 'invalid arguments to regl.read()') + x = input.x | 0 + y = input.y | 0 + check$1( + x >= 0 && x < context.framebufferWidth, + 'invalid x offset for regl.read') + check$1( + y >= 0 && y < context.framebufferHeight, + 'invalid y offset for regl.read') + width = (input.width || (context.framebufferWidth - x)) | 0 + height = (input.height || (context.framebufferHeight - y)) | 0 + data = input.data || null + } - if (!(self instanceof Mousetrap)) { - return new Mousetrap(targetElement); - } + // sanity check input.data + if (data) { + if (type === GL_UNSIGNED_BYTE$7) { + check$1( + data instanceof Uint8Array, + 'buffer must be \'Uint8Array\' when reading from a framebuffer of type \'uint8\'') + } else if (type === GL_FLOAT$7) { + check$1( + data instanceof Float32Array, + 'buffer must be \'Float32Array\' when reading from a framebuffer of type \'float\'') + } + } - /** - * element to attach key events to - * - * @type {Element} - */ - self.target = targetElement; + check$1( + width > 0 && width + x <= context.framebufferWidth, + 'invalid width for read pixels') + check$1( + height > 0 && height + y <= context.framebufferHeight, + 'invalid height for read pixels') - /** - * a list of all the callbacks setup via Mousetrap.bind() - * - * @type {Object} - */ - self._callbacks = {}; + // Update WebGL state + reglPoll() - /** - * direct map of string combinations to callbacks used for trigger() - * - * @type {Object} - */ - self._directMap = {}; + // Compute size + var size = width * height * 4 - /** - * keeps track of what level each sequence is at since multiple - * sequences can start out with the same sequence - * - * @type {Object} - */ - var _sequenceLevels = {}; + // Allocate data + if (!data) { + if (type === GL_UNSIGNED_BYTE$7) { + data = new Uint8Array(size) + } else if (type === GL_FLOAT$7) { + data = data || new Float32Array(size) + } + } - /** - * variable to store the setTimeout call - * - * @type {null|number} - */ - var _resetTimer; + // Type check + check$1.isTypedArray(data, 'data buffer for regl.read() must be a typedarray') + check$1(data.byteLength >= size, 'data buffer for regl.read() too small') - /** - * temporary state where we will ignore the next keyup - * - * @type {boolean|string} - */ - var _ignoreNextKeyup = false; + // Run read pixels + gl.pixelStorei(GL_PACK_ALIGNMENT, 4) + gl.readPixels(x, y, width, height, GL_RGBA$3, + type, + data) - /** - * temporary state where we will ignore the next keypress - * - * @type {boolean} - */ - var _ignoreNextKeypress = false; + return data + } - /** - * are we currently inside of a sequence? - * type of action ("keyup" or "keydown" or "keypress") or false - * - * @type {boolean|string} - */ - var _nextExpectedAction = false; + function readPixelsFBO (options) { + var result + framebufferState.setFBO({ + framebuffer: options.framebuffer + }, function () { + result = readPixelsImpl(options) + }) + return result + } - /** - * resets all sequence counters except for the ones passed in - * - * @param {Object} doNotReset - * @returns void - */ - function _resetSequences(doNotReset) { - doNotReset = doNotReset || {}; + function readPixels (options) { + if (!options || !('framebuffer' in options)) { + return readPixelsImpl(options) + } else { + return readPixelsFBO(options) + } + } - var activeSequences = false, - key; + return readPixels +} - for (key in _sequenceLevels) { - if (doNotReset[key]) { - activeSequences = true; - continue; - } - _sequenceLevels[key] = 0; - } +function slice (x) { + return Array.prototype.slice.call(x) +} - if (!activeSequences) { - _nextExpectedAction = false; - } - } +function join (x) { + return slice(x).join('') +} - /** - * finds all callbacks that match based on the keycode, modifiers, - * and action - * - * @param {string} character - * @param {Array} modifiers - * @param {Event|Object} e - * @param {string=} sequenceName - name of the sequence we are looking for - * @param {string=} combination - * @param {number=} level - * @returns {Array} - */ - function _getMatches(character, modifiers, e, sequenceName, combination, level) { - var i; - var callback; - var matches = []; - var action = e.type; +function createEnvironment () { + // Unique variable id counter + var varCounter = 0 + + // Linked values are passed from this scope into the generated code block + // Calling link() passes a value into the generated scope and returns + // the variable name which it is bound to + var linkedNames = [] + var linkedValues = [] + function link (value) { + for (var i = 0; i < linkedValues.length; ++i) { + if (linkedValues[i] === value) { + return linkedNames[i] + } + } - // if there are no events related to this keycode - if (!self._callbacks[character]) { - return []; - } + var name = 'g' + (varCounter++) + linkedNames.push(name) + linkedValues.push(value) + return name + } - // if a modifier key is coming up on its own we should allow it - if (action == 'keyup' && _isModifier(character)) { - modifiers = [character]; - } + // create a code block + function block () { + var code = [] + function push () { + code.push.apply(code, slice(arguments)) + } - // loop through all callbacks for the key that was pressed - // and see if any of them match - for (i = 0; i < self._callbacks[character].length; ++i) { - callback = self._callbacks[character][i]; + var vars = [] + function def () { + var name = 'v' + (varCounter++) + vars.push(name) - // if a sequence name is not specified, but this is a sequence at - // the wrong level then move onto the next match - if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { - continue; - } + if (arguments.length > 0) { + code.push(name, '=') + code.push.apply(code, slice(arguments)) + code.push(';') + } - // if the action we are looking for doesn't match the action we got - // then we should keep going - if (action != callback.action) { - continue; - } + return name + } - // if this is a keypress event and the meta key and control key - // are not pressed that means that we need to only look at the - // character, otherwise check the modifiers as well - // - // chrome will not fire a keypress if meta or control is down - // safari will fire a keypress if meta or meta+shift is down - // firefox will fire a keypress if meta or control is down - if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) { + return extend(push, { + def: def, + toString: function () { + return join([ + (vars.length > 0 ? 'var ' + vars.join(',') + ';' : ''), + join(code) + ]) + } + }) + } - // when you bind a combination or sequence a second time it - // should overwrite the first one. if a sequenceName or - // combination is specified in this call it does just that - // - // @todo make deleting its own method? - var deleteCombo = !sequenceName && callback.combo == combination; - var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; - if (deleteCombo || deleteSequence) { - self._callbacks[character].splice(i, 1); - } + function scope () { + var entry = block() + var exit = block() - matches.push(callback); - } - } + var entryToString = entry.toString + var exitToString = exit.toString - return matches; - } + function save (object, prop) { + exit(object, prop, '=', entry.def(object, prop), ';') + } - /** - * actually calls the callback function - * - * if your callback function returns false this will use the jquery - * convention - prevent default and stop propogation on the event - * - * @param {Function} callback - * @param {Event} e - * @returns void - */ - function _fireCallback(callback, e, combo, sequence) { + return extend(function () { + entry.apply(entry, slice(arguments)) + }, { + def: entry.def, + entry: entry, + exit: exit, + save: save, + set: function (object, prop, value) { + save(object, prop) + entry(object, prop, '=', value, ';') + }, + toString: function () { + return entryToString() + exitToString() + } + }) + } - // if this event should not happen stop here - if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { - return; - } + function conditional () { + var pred = join(arguments) + var thenBlock = scope() + var elseBlock = scope() - if (callback(e, combo) === false) { - _preventDefault(e); - _stopPropagation(e); - } + var thenToString = thenBlock.toString + var elseToString = elseBlock.toString + + return extend(thenBlock, { + then: function () { + thenBlock.apply(thenBlock, slice(arguments)) + return this + }, + else: function () { + elseBlock.apply(elseBlock, slice(arguments)) + return this + }, + toString: function () { + var elseClause = elseToString() + if (elseClause) { + elseClause = 'else{' + elseClause + '}' } + return join([ + 'if(', pred, '){', + thenToString(), + '}', elseClause + ]) + } + }) + } - /** - * handles a character key event - * - * @param {string} character - * @param {Array} modifiers - * @param {Event} e - * @returns void - */ - self._handleKey = function(character, modifiers, e) { - var callbacks = _getMatches(character, modifiers, e); - var i; - var doNotReset = {}; - var maxLevel = 0; - var processedSequenceCallback = false; + // procedure list + var globalBlock = block() + var procedures = {} + function proc (name, count) { + var args = [] + function arg () { + var name = 'a' + args.length + args.push(name) + return name + } - // Calculate the maxLevel for sequences so we can only execute the longest callback sequence - for (i = 0; i < callbacks.length; ++i) { - if (callbacks[i].seq) { - maxLevel = Math.max(maxLevel, callbacks[i].level); - } - } + count = count || 0 + for (var i = 0; i < count; ++i) { + arg() + } - // loop through matching callbacks for this key event - for (i = 0; i < callbacks.length; ++i) { + var body = scope() + var bodyToString = body.toString - // fire for all sequence callbacks - // this is because if for example you have multiple sequences - // bound such as "g i" and "g t" they both need to fire the - // callback for matching g cause otherwise you can only ever - // match the first one - if (callbacks[i].seq) { + var result = procedures[name] = extend(body, { + arg: arg, + toString: function () { + return join([ + 'function(', args.join(), '){', + bodyToString(), + '}' + ]) + } + }) - // only fire callbacks for the maxLevel to prevent - // subsequences from also firing - // - // for example 'a option b' should not cause 'option b' to fire - // even though 'option b' is part of the other sequence - // - // any sequences that do not match here will be discarded - // below by the _resetSequences call - if (callbacks[i].level != maxLevel) { - continue; - } + return result + } - processedSequenceCallback = true; + function compile () { + var code = ['"use strict";', + globalBlock, + 'return {'] + Object.keys(procedures).forEach(function (name) { + code.push('"', name, '":', procedures[name].toString(), ',') + }) + code.push('}') + var src = join(code) + .replace(/;/g, ';\n') + .replace(/}/g, '}\n') + .replace(/{/g, '{\n') + var proc = Function.apply(null, linkedNames.concat(src)) + return proc.apply(null, linkedValues) + } - // keep a list of which sequences were matches for later - doNotReset[callbacks[i].seq] = 1; - _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq); - continue; - } + return { + global: globalBlock, + link: link, + block: block, + proc: proc, + scope: scope, + cond: conditional, + compile: compile + } +} + +// "cute" names for vector components +var CUTE_COMPONENTS = 'xyzw'.split('') + +var GL_UNSIGNED_BYTE$8 = 5121 + +var ATTRIB_STATE_POINTER = 1 +var ATTRIB_STATE_CONSTANT = 2 + +var DYN_FUNC$1 = 0 +var DYN_PROP$1 = 1 +var DYN_CONTEXT$1 = 2 +var DYN_STATE$1 = 3 +var DYN_THUNK = 4 +var DYN_CONSTANT$1 = 5 +var DYN_ARRAY$1 = 6 + +var S_DITHER = 'dither' +var S_BLEND_ENABLE = 'blend.enable' +var S_BLEND_COLOR = 'blend.color' +var S_BLEND_EQUATION = 'blend.equation' +var S_BLEND_FUNC = 'blend.func' +var S_DEPTH_ENABLE = 'depth.enable' +var S_DEPTH_FUNC = 'depth.func' +var S_DEPTH_RANGE = 'depth.range' +var S_DEPTH_MASK = 'depth.mask' +var S_COLOR_MASK = 'colorMask' +var S_CULL_ENABLE = 'cull.enable' +var S_CULL_FACE = 'cull.face' +var S_FRONT_FACE = 'frontFace' +var S_LINE_WIDTH = 'lineWidth' +var S_POLYGON_OFFSET_ENABLE = 'polygonOffset.enable' +var S_POLYGON_OFFSET_OFFSET = 'polygonOffset.offset' +var S_SAMPLE_ALPHA = 'sample.alpha' +var S_SAMPLE_ENABLE = 'sample.enable' +var S_SAMPLE_COVERAGE = 'sample.coverage' +var S_STENCIL_ENABLE = 'stencil.enable' +var S_STENCIL_MASK = 'stencil.mask' +var S_STENCIL_FUNC = 'stencil.func' +var S_STENCIL_OPFRONT = 'stencil.opFront' +var S_STENCIL_OPBACK = 'stencil.opBack' +var S_SCISSOR_ENABLE = 'scissor.enable' +var S_SCISSOR_BOX = 'scissor.box' +var S_VIEWPORT = 'viewport' + +var S_PROFILE = 'profile' + +var S_FRAMEBUFFER = 'framebuffer' +var S_VERT = 'vert' +var S_FRAG = 'frag' +var S_ELEMENTS = 'elements' +var S_PRIMITIVE = 'primitive' +var S_COUNT = 'count' +var S_OFFSET = 'offset' +var S_INSTANCES = 'instances' +var S_VAO = 'vao' + +var SUFFIX_WIDTH = 'Width' +var SUFFIX_HEIGHT = 'Height' + +var S_FRAMEBUFFER_WIDTH = S_FRAMEBUFFER + SUFFIX_WIDTH +var S_FRAMEBUFFER_HEIGHT = S_FRAMEBUFFER + SUFFIX_HEIGHT +var S_VIEWPORT_WIDTH = S_VIEWPORT + SUFFIX_WIDTH +var S_VIEWPORT_HEIGHT = S_VIEWPORT + SUFFIX_HEIGHT +var S_DRAWINGBUFFER = 'drawingBuffer' +var S_DRAWINGBUFFER_WIDTH = S_DRAWINGBUFFER + SUFFIX_WIDTH +var S_DRAWINGBUFFER_HEIGHT = S_DRAWINGBUFFER + SUFFIX_HEIGHT + +var NESTED_OPTIONS = [ + S_BLEND_FUNC, + S_BLEND_EQUATION, + S_STENCIL_FUNC, + S_STENCIL_OPFRONT, + S_STENCIL_OPBACK, + S_SAMPLE_COVERAGE, + S_VIEWPORT, + S_SCISSOR_BOX, + S_POLYGON_OFFSET_OFFSET +] + +var GL_ARRAY_BUFFER$2 = 34962 +var GL_ELEMENT_ARRAY_BUFFER$1 = 34963 + +var GL_FRAGMENT_SHADER$1 = 35632 +var GL_VERTEX_SHADER$1 = 35633 + +var GL_TEXTURE_2D$3 = 0x0DE1 +var GL_TEXTURE_CUBE_MAP$2 = 0x8513 + +var GL_CULL_FACE = 0x0B44 +var GL_BLEND = 0x0BE2 +var GL_DITHER = 0x0BD0 +var GL_STENCIL_TEST = 0x0B90 +var GL_DEPTH_TEST = 0x0B71 +var GL_SCISSOR_TEST = 0x0C11 +var GL_POLYGON_OFFSET_FILL = 0x8037 +var GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E +var GL_SAMPLE_COVERAGE = 0x80A0 + +var GL_FLOAT$8 = 5126 +var GL_FLOAT_VEC2 = 35664 +var GL_FLOAT_VEC3 = 35665 +var GL_FLOAT_VEC4 = 35666 +var GL_INT$3 = 5124 +var GL_INT_VEC2 = 35667 +var GL_INT_VEC3 = 35668 +var GL_INT_VEC4 = 35669 +var GL_BOOL = 35670 +var GL_BOOL_VEC2 = 35671 +var GL_BOOL_VEC3 = 35672 +var GL_BOOL_VEC4 = 35673 +var GL_FLOAT_MAT2 = 35674 +var GL_FLOAT_MAT3 = 35675 +var GL_FLOAT_MAT4 = 35676 +var GL_SAMPLER_2D = 35678 +var GL_SAMPLER_CUBE = 35680 + +var GL_TRIANGLES$1 = 4 + +var GL_FRONT = 1028 +var GL_BACK = 1029 +var GL_CW = 0x0900 +var GL_CCW = 0x0901 +var GL_MIN_EXT = 0x8007 +var GL_MAX_EXT = 0x8008 +var GL_ALWAYS = 519 +var GL_KEEP = 7680 +var GL_ZERO = 0 +var GL_ONE = 1 +var GL_FUNC_ADD = 0x8006 +var GL_LESS = 513 + +var GL_FRAMEBUFFER$2 = 0x8D40 +var GL_COLOR_ATTACHMENT0$2 = 0x8CE0 + +var blendFuncs = { + '0': 0, + '1': 1, + 'zero': 0, + 'one': 1, + 'src color': 768, + 'one minus src color': 769, + 'src alpha': 770, + 'one minus src alpha': 771, + 'dst color': 774, + 'one minus dst color': 775, + 'dst alpha': 772, + 'one minus dst alpha': 773, + 'constant color': 32769, + 'one minus constant color': 32770, + 'constant alpha': 32771, + 'one minus constant alpha': 32772, + 'src alpha saturate': 776 +} + +// There are invalid values for srcRGB and dstRGB. See: +// https://www.khronos.org/registry/webgl/specs/1.0/#6.13 +// https://github.com/KhronosGroup/WebGL/blob/0d3201f5f7ec3c0060bc1f04077461541f1987b9/conformance-suites/1.0.3/conformance/misc/webgl-specific.html#L56 +var invalidBlendCombinations = [ + 'constant color, constant alpha', + 'one minus constant color, constant alpha', + 'constant color, one minus constant alpha', + 'one minus constant color, one minus constant alpha', + 'constant alpha, constant color', + 'constant alpha, one minus constant color', + 'one minus constant alpha, constant color', + 'one minus constant alpha, one minus constant color' +] + +var compareFuncs = { + 'never': 512, + 'less': 513, + '<': 513, + 'equal': 514, + '=': 514, + '==': 514, + '===': 514, + 'lequal': 515, + '<=': 515, + 'greater': 516, + '>': 516, + 'notequal': 517, + '!=': 517, + '!==': 517, + 'gequal': 518, + '>=': 518, + 'always': 519 +} - // if there were no sequence matches but we are still here - // that means this is a regular match so we should fire that - if (!processedSequenceCallback) { - _fireCallback(callbacks[i].callback, e, callbacks[i].combo); - } - } +var stencilOps = { + '0': 0, + 'zero': 0, + 'keep': 7680, + 'replace': 7681, + 'increment': 7682, + 'decrement': 7683, + 'increment wrap': 34055, + 'decrement wrap': 34056, + 'invert': 5386 +} - // if the key you pressed matches the type of sequence without - // being a modifier (ie "keyup" or "keypress") then we should - // reset all sequences that were not matched by this event - // - // this is so, for example, if you have the sequence "h a t" and you - // type "h e a r t" it does not match. in this case the "e" will - // cause the sequence to reset - // - // modifier keys are ignored because you can have a sequence - // that contains modifiers such as "enter ctrl+space" and in most - // cases the modifier key will be pressed before the next key - // - // also if you have a sequence such as "ctrl+b a" then pressing the - // "b" key will trigger a "keypress" and a "keydown" - // - // the "keydown" is expected when there is a modifier, but the - // "keypress" ends up matching the _nextExpectedAction since it occurs - // after and that causes the sequence to reset - // - // we ignore keypresses in a sequence that directly follow a keydown - // for the same character - var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress; - if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { - _resetSequences(doNotReset); - } +var shaderType = { + 'frag': GL_FRAGMENT_SHADER$1, + 'vert': GL_VERTEX_SHADER$1 +} - _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown'; - }; +var orientationType = { + 'cw': GL_CW, + 'ccw': GL_CCW +} - /** - * handles a keydown event - * - * @param {Event} e - * @returns void - */ - function _handleKeyEvent(e) { +function isBufferArgs (x) { + return Array.isArray(x) || + isTypedArray(x) || + isNDArrayLike(x) +} - // normalize e.which for key events - // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion - if (typeof e.which !== 'number') { - e.which = e.keyCode; - } +// Make sure viewport is processed first +function sortState (state) { + return state.sort(function (a, b) { + if (a === S_VIEWPORT) { + return -1 + } else if (b === S_VIEWPORT) { + return 1 + } + return (a < b) ? -1 : 1 + }) +} - var character = _characterFromEvent(e); +function Declaration (thisDep, contextDep, propDep, append) { + this.thisDep = thisDep + this.contextDep = contextDep + this.propDep = propDep + this.append = append +} - // no character found then stop - if (!character) { - return; - } +function isStatic (decl) { + return decl && !(decl.thisDep || decl.contextDep || decl.propDep) +} - // need to use === for the character check because the character can be 0 - if (e.type == 'keyup' && _ignoreNextKeyup === character) { - _ignoreNextKeyup = false; - return; - } +function createStaticDecl (append) { + return new Declaration(false, false, false, append) +} - self.handleKey(character, _eventModifiers(e), e); - } +function createDynamicDecl (dyn, append) { + var type = dyn.type + if (type === DYN_FUNC$1) { + var numArgs = dyn.data.length + return new Declaration( + true, + numArgs >= 1, + numArgs >= 2, + append) + } else if (type === DYN_THUNK) { + var data = dyn.data + return new Declaration( + data.thisDep, + data.contextDep, + data.propDep, + append) + } else if (type === DYN_CONSTANT$1) { + return new Declaration( + false, + false, + false, + append) + } else if (type === DYN_ARRAY$1) { + var thisDep = false + var contextDep = false + var propDep = false + for (var i = 0; i < dyn.data.length; ++i) { + var subDyn = dyn.data[i] + if (subDyn.type === DYN_PROP$1) { + propDep = true + } else if (subDyn.type === DYN_CONTEXT$1) { + contextDep = true + } else if (subDyn.type === DYN_STATE$1) { + thisDep = true + } else if (subDyn.type === DYN_FUNC$1) { + thisDep = true + var subArgs = subDyn.data + if (subArgs >= 1) { + contextDep = true + } + if (subArgs >= 2) { + propDep = true + } + } else if (subDyn.type === DYN_THUNK) { + thisDep = thisDep || subDyn.data.thisDep + contextDep = contextDep || subDyn.data.contextDep + propDep = propDep || subDyn.data.propDep + } + } + return new Declaration( + thisDep, + contextDep, + propDep, + append) + } else { + return new Declaration( + type === DYN_STATE$1, + type === DYN_CONTEXT$1, + type === DYN_PROP$1, + append) + } +} - /** - * called to set a 1 second timeout on the specified sequence - * - * this is so after each key press in the sequence you have 1 second - * to press the next key before you have to start over - * - * @returns void - */ - function _resetSequenceTimer() { - clearTimeout(_resetTimer); - _resetTimer = setTimeout(_resetSequences, 1000); - } +var SCOPE_DECL = new Declaration(false, false, false, function () {}) - /** - * binds a key sequence to an event - * - * @param {string} combo - combo specified in bind call - * @param {Array} keys - * @param {Function} callback - * @param {string=} action - * @returns void - */ - function _bindSequence(combo, keys, callback, action) { +function reglCore ( + gl, + stringStore, + extensions, + limits, + bufferState, + elementState, + textureState, + framebufferState, + uniformState, + attributeState, + shaderState, + drawState, + contextState, + timer, + config) { + var AttributeRecord = attributeState.Record - // start off by adding a sequence level record for this combination - // and setting the level to 0 - _sequenceLevels[combo] = 0; + var blendEquations = { + 'add': 32774, + 'subtract': 32778, + 'reverse subtract': 32779 + } + if (extensions.ext_blend_minmax) { + blendEquations.min = GL_MIN_EXT + blendEquations.max = GL_MAX_EXT + } - /** - * callback to increase the sequence level for this sequence and reset - * all other sequences that were active - * - * @param {string} nextAction - * @returns {Function} - */ - function _increaseSequence(nextAction) { - return function() { - _nextExpectedAction = nextAction; - ++_sequenceLevels[combo]; - _resetSequenceTimer(); - }; - } + var extInstancing = extensions.angle_instanced_arrays + var extDrawBuffers = extensions.webgl_draw_buffers - /** - * wraps the specified callback inside of another function in order - * to reset all sequence counters as soon as this sequence is done - * - * @param {Event} e - * @returns void - */ - function _callbackAndReset(e) { - _fireCallback(callback, e, combo); + // =================================================== + // =================================================== + // WEBGL STATE + // =================================================== + // =================================================== + var currentState = { + dirty: true, + profile: config.profile + } + var nextState = {} + var GL_STATE_NAMES = [] + var GL_FLAGS = {} + var GL_VARIABLES = {} - // we should ignore the next key up if the action is key down - // or keypress. this is so if you finish a sequence and - // release the key the final key will not trigger a keyup - if (action !== 'keyup') { - _ignoreNextKeyup = _characterFromEvent(e); - } + function propName (name) { + return name.replace('.', '_') + } - // weird race condition if a sequence ends with the key - // another sequence begins with - setTimeout(_resetSequences, 10); - } + function stateFlag (sname, cap, init) { + var name = propName(sname) + GL_STATE_NAMES.push(sname) + nextState[name] = currentState[name] = !!init + GL_FLAGS[name] = cap + } - // loop through keys one at a time and bind the appropriate callback - // function. for any key leading up to the final one it should - // increase the sequence. after the final, it should reset all sequences - // - // if an action is specified in the original bind call then that will - // be used throughout. otherwise we will pass the action that the - // next key in the sequence should match. this allows a sequence - // to mix and match keypress and keydown events depending on which - // ones are better suited to the key provided - for (var i = 0; i < keys.length; ++i) { - var isFinal = i + 1 === keys.length; - var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action); - _bindSingle(keys[i], wrappedCallback, action, combo, i); - } - } + function stateVariable (sname, func, init) { + var name = propName(sname) + GL_STATE_NAMES.push(sname) + if (Array.isArray(init)) { + currentState[name] = init.slice() + nextState[name] = init.slice() + } else { + currentState[name] = nextState[name] = init + } + GL_VARIABLES[name] = func + } - /** - * binds a single keyboard combination - * - * @param {string} combination - * @param {Function} callback - * @param {string=} action - * @param {string=} sequenceName - name of sequence if part of sequence - * @param {number=} level - what part of the sequence the command is - * @returns void - */ - function _bindSingle(combination, callback, action, sequenceName, level) { + // Dithering + stateFlag(S_DITHER, GL_DITHER) - // store a direct mapped reference for use with Mousetrap.trigger - self._directMap[combination + ':' + action] = callback; + // Blending + stateFlag(S_BLEND_ENABLE, GL_BLEND) + stateVariable(S_BLEND_COLOR, 'blendColor', [0, 0, 0, 0]) + stateVariable(S_BLEND_EQUATION, 'blendEquationSeparate', + [GL_FUNC_ADD, GL_FUNC_ADD]) + stateVariable(S_BLEND_FUNC, 'blendFuncSeparate', + [GL_ONE, GL_ZERO, GL_ONE, GL_ZERO]) - // make sure multiple spaces in a row become a single space - combination = combination.replace(/\s+/g, ' '); + // Depth + stateFlag(S_DEPTH_ENABLE, GL_DEPTH_TEST, true) + stateVariable(S_DEPTH_FUNC, 'depthFunc', GL_LESS) + stateVariable(S_DEPTH_RANGE, 'depthRange', [0, 1]) + stateVariable(S_DEPTH_MASK, 'depthMask', true) - var sequence = combination.split(' '); - var info; + // Color mask + stateVariable(S_COLOR_MASK, S_COLOR_MASK, [true, true, true, true]) - // if this pattern is a sequence of keys then run through this method - // to reprocess each pattern one key at a time - if (sequence.length > 1) { - _bindSequence(combination, sequence, callback, action); - return; - } + // Face culling + stateFlag(S_CULL_ENABLE, GL_CULL_FACE) + stateVariable(S_CULL_FACE, 'cullFace', GL_BACK) - info = _getKeyInfo(combination, action); + // Front face orientation + stateVariable(S_FRONT_FACE, S_FRONT_FACE, GL_CCW) - // make sure to initialize array if this is the first time - // a callback is added for this key - self._callbacks[info.key] = self._callbacks[info.key] || []; + // Line width + stateVariable(S_LINE_WIDTH, S_LINE_WIDTH, 1) - // remove an existing match if there is one - _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level); + // Polygon offset + stateFlag(S_POLYGON_OFFSET_ENABLE, GL_POLYGON_OFFSET_FILL) + stateVariable(S_POLYGON_OFFSET_OFFSET, 'polygonOffset', [0, 0]) - // add this call back to the array - // if it is a sequence put it at the beginning - // if not put it at the end - // - // this is important because the way these are processed expects - // the sequence ones to come first - self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({ - callback: callback, - modifiers: info.modifiers, - action: info.action, - seq: sequenceName, - level: level, - combo: combination - }); - } + // Sample coverage + stateFlag(S_SAMPLE_ALPHA, GL_SAMPLE_ALPHA_TO_COVERAGE) + stateFlag(S_SAMPLE_ENABLE, GL_SAMPLE_COVERAGE) + stateVariable(S_SAMPLE_COVERAGE, 'sampleCoverage', [1, false]) - /** - * binds multiple combinations to the same callback - * - * @param {Array} combinations - * @param {Function} callback - * @param {string|undefined} action - * @returns void - */ - self._bindMultiple = function(combinations, callback, action) { - for (var i = 0; i < combinations.length; ++i) { - _bindSingle(combinations[i], callback, action); - } - }; + // Stencil + stateFlag(S_STENCIL_ENABLE, GL_STENCIL_TEST) + stateVariable(S_STENCIL_MASK, 'stencilMask', -1) + stateVariable(S_STENCIL_FUNC, 'stencilFunc', [GL_ALWAYS, 0, -1]) + stateVariable(S_STENCIL_OPFRONT, 'stencilOpSeparate', + [GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP]) + stateVariable(S_STENCIL_OPBACK, 'stencilOpSeparate', + [GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP]) - // start! - _addEvent(targetElement, 'keypress', _handleKeyEvent); - _addEvent(targetElement, 'keydown', _handleKeyEvent); - _addEvent(targetElement, 'keyup', _handleKeyEvent); - } + // Scissor + stateFlag(S_SCISSOR_ENABLE, GL_SCISSOR_TEST) + stateVariable(S_SCISSOR_BOX, 'scissor', + [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]) - /** - * binds an event to mousetrap - * - * can be a single key, a combination of keys separated with +, - * an array of keys, or a sequence of keys separated by spaces - * - * be sure to list the modifier keys first to make sure that the - * correct key ends up getting bound (the last key in the pattern) - * - * @param {string|Array} keys - * @param {Function} callback - * @param {string=} action - 'keypress', 'keydown', or 'keyup' - * @returns void - */ - Mousetrap.prototype.bind = function(keys, callback, action) { - var self = this; - keys = keys instanceof Array ? keys : [keys]; - self._bindMultiple.call(self, keys, callback, action); - return self; - }; + // Viewport + stateVariable(S_VIEWPORT, S_VIEWPORT, + [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]) - /** - * unbinds an event to mousetrap - * - * the unbinding sets the callback function of the specified key combo - * to an empty function and deletes the corresponding key in the - * _directMap dict. - * - * TODO: actually remove this from the _callbacks dictionary instead - * of binding an empty function - * - * the keycombo+action has to be exactly the same as - * it was defined in the bind method - * - * @param {string|Array} keys - * @param {string} action - * @returns void - */ - Mousetrap.prototype.unbind = function(keys, action) { - var self = this; - return self.bind.call(self, keys, function() {}, action); - }; + // =================================================== + // =================================================== + // ENVIRONMENT + // =================================================== + // =================================================== + var sharedState = { + gl: gl, + context: contextState, + strings: stringStore, + next: nextState, + current: currentState, + draw: drawState, + elements: elementState, + buffer: bufferState, + shader: shaderState, + attributes: attributeState.state, + vao: attributeState, + uniforms: uniformState, + framebuffer: framebufferState, + extensions: extensions, - /** - * triggers an event that has already been bound - * - * @param {string} keys - * @param {string=} action - * @returns void - */ - Mousetrap.prototype.trigger = function(keys, action) { - var self = this; - if (self._directMap[keys + ':' + action]) { - self._directMap[keys + ':' + action]({}, keys); - } - return self; - }; + timer: timer, + isBufferArgs: isBufferArgs + } - /** - * resets the library back to its initial state. this is useful - * if you want to clear out the current keyboard shortcuts and bind - * new ones - for example if you switch to another page - * - * @returns void - */ - Mousetrap.prototype.reset = function() { - var self = this; - self._callbacks = {}; - self._directMap = {}; - return self; - }; + var sharedConstants = { + primTypes: primTypes, + compareFuncs: compareFuncs, + blendFuncs: blendFuncs, + blendEquations: blendEquations, + stencilOps: stencilOps, + glTypes: glTypes, + orientationType: orientationType + } - /** - * should we stop this event before firing off callbacks - * - * @param {Event} e - * @param {Element} element - * @return {boolean} - */ - Mousetrap.prototype.stopCallback = function(e, element) { - var self = this; + check$1.optional(function () { + sharedState.isArrayLike = isArrayLike + }) - // if the element has the class "mousetrap" then no need to stop - if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) { - return false; - } + if (extDrawBuffers) { + sharedConstants.backBuffer = [GL_BACK] + sharedConstants.drawBuffer = loop(limits.maxDrawbuffers, function (i) { + if (i === 0) { + return [0] + } + return loop(i, function (j) { + return GL_COLOR_ATTACHMENT0$2 + j + }) + }) + } - if (_belongsTo(element, self.target)) { - return false; - } + var drawCallCounter = 0 + function createREGLEnvironment () { + var env = createEnvironment() + var link = env.link + var global = env.global + env.id = drawCallCounter++ - // stop for input, select, and textarea - return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable; - }; + env.batchId = '0' - /** - * exposes _handleKey publicly so it can be overwritten by extensions - */ - Mousetrap.prototype.handleKey = function() { - var self = this; - return self._handleKey.apply(self, arguments); - }; + // link shared state + var SHARED = link(sharedState) + var shared = env.shared = { + props: 'a0' + } + Object.keys(sharedState).forEach(function (prop) { + shared[prop] = global.def(SHARED, '.', prop) + }) + + // Inject runtime assertion stuff for debug builds + check$1.optional(function () { + env.CHECK = link(check$1) + env.commandStr = check$1.guessCommand() + env.command = link(env.commandStr) + env.assert = function (block, pred, message) { + block( + 'if(!(', pred, '))', + this.CHECK, '.commandRaise(', link(message), ',', this.command, ');') + } + + sharedConstants.invalidBlendCombinations = invalidBlendCombinations + }) + + // Copy GL state variables over + var nextVars = env.next = {} + var currentVars = env.current = {} + Object.keys(GL_VARIABLES).forEach(function (variable) { + if (Array.isArray(currentState[variable])) { + nextVars[variable] = global.def(shared.next, '.', variable) + currentVars[variable] = global.def(shared.current, '.', variable) + } + }) + + // Initialize shared constants + var constants = env.constants = {} + Object.keys(sharedConstants).forEach(function (name) { + constants[name] = global.def(JSON.stringify(sharedConstants[name])) + }) + + // Helper function for calling a block + env.invoke = function (block, x) { + switch (x.type) { + case DYN_FUNC$1: + var argList = [ + 'this', + shared.context, + shared.props, + env.batchId + ] + return block.def( + link(x.data), '.call(', + argList.slice(0, Math.max(x.data.length + 1, 4)), + ')') + case DYN_PROP$1: + return block.def(shared.props, x.data) + case DYN_CONTEXT$1: + return block.def(shared.context, x.data) + case DYN_STATE$1: + return block.def('this', x.data) + case DYN_THUNK: + x.data.append(env, block) + return x.data.ref + case DYN_CONSTANT$1: + return x.data.toString() + case DYN_ARRAY$1: + return x.data.map(function (y) { + return env.invoke(block, y) + }) + } + } - /** - * allow custom key mappings - */ - Mousetrap.addKeycodes = function(object) { - for (var key in object) { - if (object.hasOwnProperty(key)) { - _MAP[key] = object[key]; - } - } - _REVERSE_MAP = null; - }; + env.attribCache = {} - /** - * Init the global mousetrap functions - * - * This method is needed to allow the global mousetrap functions to work - * now that mousetrap is a constructor function. - */ - Mousetrap.init = function() { - var documentMousetrap = Mousetrap(document); - for (var method in documentMousetrap) { - if (method.charAt(0) !== '_') { - Mousetrap[method] = (function(method) { - return function() { - return documentMousetrap[method].apply(documentMousetrap, arguments); - }; - } (method)); - } - } - }; + var scopeAttribs = {} + env.scopeAttrib = function (name) { + var id = stringStore.id(name) + if (id in scopeAttribs) { + return scopeAttribs[id] + } + var binding = attributeState.scope[id] + if (!binding) { + binding = attributeState.scope[id] = new AttributeRecord() + } + var result = scopeAttribs[id] = link(binding) + return result + } - Mousetrap.init(); + return env + } - // expose mousetrap to the global object - window.Mousetrap = Mousetrap; + // =================================================== + // =================================================== + // PARSING + // =================================================== + // =================================================== + function parseProfile (options) { + var staticOptions = options.static + var dynamicOptions = options.dynamic - // expose as a common js module - if (typeof module !== 'undefined' && module.exports) { - module.exports = Mousetrap; + var profileEnable + if (S_PROFILE in staticOptions) { + var value = !!staticOptions[S_PROFILE] + profileEnable = createStaticDecl(function (env, scope) { + return value + }) + profileEnable.enable = value + } else if (S_PROFILE in dynamicOptions) { + var dyn = dynamicOptions[S_PROFILE] + profileEnable = createDynamicDecl(dyn, function (env, scope) { + return env.invoke(scope, dyn) + }) } - // expose mousetrap as an AMD module - if (true) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { - return Mousetrap; - }.call(exports, __webpack_require__, exports, module), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } -}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null); + return profileEnable + } + function parseFramebuffer (options, env) { + var staticOptions = options.static + var dynamicOptions = options.dynamic -/***/ }), -/* 26 */ -/***/ (function(module, exports, __webpack_require__) { + if (S_FRAMEBUFFER in staticOptions) { + var framebuffer = staticOptions[S_FRAMEBUFFER] + if (framebuffer) { + framebuffer = framebufferState.getFramebuffer(framebuffer) + check$1.command(framebuffer, 'invalid framebuffer object') + return createStaticDecl(function (env, block) { + var FRAMEBUFFER = env.link(framebuffer) + var shared = env.shared + block.set( + shared.framebuffer, + '.next', + FRAMEBUFFER) + var CONTEXT = shared.context + block.set( + CONTEXT, + '.' + S_FRAMEBUFFER_WIDTH, + FRAMEBUFFER + '.width') + block.set( + CONTEXT, + '.' + S_FRAMEBUFFER_HEIGHT, + FRAMEBUFFER + '.height') + return FRAMEBUFFER + }) + } else { + return createStaticDecl(function (env, scope) { + var shared = env.shared + scope.set( + shared.framebuffer, + '.next', + 'null') + var CONTEXT = shared.context + scope.set( + CONTEXT, + '.' + S_FRAMEBUFFER_WIDTH, + CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH) + scope.set( + CONTEXT, + '.' + S_FRAMEBUFFER_HEIGHT, + CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT) + return 'null' + }) + } + } else if (S_FRAMEBUFFER in dynamicOptions) { + var dyn = dynamicOptions[S_FRAMEBUFFER] + return createDynamicDecl(dyn, function (env, scope) { + var FRAMEBUFFER_FUNC = env.invoke(scope, dyn) + var shared = env.shared + var FRAMEBUFFER_STATE = shared.framebuffer + var FRAMEBUFFER = scope.def( + FRAMEBUFFER_STATE, '.getFramebuffer(', FRAMEBUFFER_FUNC, ')') -"use strict"; + check$1.optional(function () { + env.assert(scope, + '!' + FRAMEBUFFER_FUNC + '||' + FRAMEBUFFER, + 'invalid framebuffer object') + }) -var isWebSocket = function (constructor) { - return constructor && constructor.CLOSING === 2; -}; -var isGlobalWebSocket = function () { - return typeof WebSocket !== 'undefined' && isWebSocket(WebSocket); -}; -var getDefaultOptions = function () { return ({ - constructor: isGlobalWebSocket() ? WebSocket : null, - maxReconnectionDelay: 10000, - minReconnectionDelay: 1500, - reconnectionDelayGrowFactor: 1.3, - connectionTimeout: 4000, - maxRetries: Infinity, - debug: false, -}); }; -var bypassProperty = function (src, dst, name) { - Object.defineProperty(dst, name, { - get: function () { return src[name]; }, - set: function (value) { src[name] = value; }, - enumerable: true, - configurable: true, - }); -}; -var initReconnectionDelay = function (config) { - return (config.minReconnectionDelay + Math.random() * config.minReconnectionDelay); -}; -var updateReconnectionDelay = function (config, previousDelay) { - var newDelay = previousDelay * config.reconnectionDelayGrowFactor; - return (newDelay > config.maxReconnectionDelay) - ? config.maxReconnectionDelay - : newDelay; -}; -var LEVEL_0_EVENTS = ['onopen', 'onclose', 'onmessage', 'onerror']; -var reassignEventListeners = function (ws, oldWs, listeners) { - Object.keys(listeners).forEach(function (type) { - listeners[type].forEach(function (_a) { - var listener = _a[0], options = _a[1]; - ws.addEventListener(type, listener, options); - }); - }); - if (oldWs) { - LEVEL_0_EVENTS.forEach(function (name) { ws[name] = oldWs[name]; }); - } -}; -var ReconnectingWebsocket = function (url, protocols, options) { - var _this = this; - if (options === void 0) { options = {}; } - var ws; - var connectingTimeout; - var reconnectDelay = 0; - var retriesCount = 0; - var shouldRetry = true; - var savedOnClose = null; - var listeners = {}; - // require new to construct - if (!(this instanceof ReconnectingWebsocket)) { - throw new TypeError("Failed to construct 'ReconnectingWebSocket': Please use the 'new' operator"); - } - // Set config. Not using `Object.assign` because of IE11 - var config = getDefaultOptions(); - Object.keys(config) - .filter(function (key) { return options.hasOwnProperty(key); }) - .forEach(function (key) { return config[key] = options[key]; }); - if (!isWebSocket(config.constructor)) { - throw new TypeError('Invalid WebSocket constructor. Set `options.constructor`'); - } - var log = config.debug ? function () { - var params = []; - for (var _i = 0; _i < arguments.length; _i++) { - params[_i - 0] = arguments[_i]; - } - return console.log.apply(console, ['RWS:'].concat(params)); - } : function () { }; - /** - * Not using dispatchEvent, otherwise we must use a DOM Event object - * Deferred because we want to handle the close event before this - */ - var emitError = function (code, msg) { return setTimeout(function () { - var err = new Error(msg); - err.code = code; - if (Array.isArray(listeners.error)) { - listeners.error.forEach(function (_a) { - var fn = _a[0]; - return fn(err); - }); - } - if (ws.onerror) { - ws.onerror(err); - } - }, 0); }; - var handleClose = function () { - log('close'); - retriesCount++; - log('retries count:', retriesCount); - if (retriesCount > config.maxRetries) { - emitError('EHOSTDOWN', 'Too many failed connection attempts'); - return; - } - if (!reconnectDelay) { - reconnectDelay = initReconnectionDelay(config); - } - else { - reconnectDelay = updateReconnectionDelay(config, reconnectDelay); - } - log('reconnectDelay:', reconnectDelay); - if (shouldRetry) { - setTimeout(connect, reconnectDelay); - } - }; - var connect = function () { - log('connect'); - var oldWs = ws; - ws = new config.constructor(url, protocols); - connectingTimeout = setTimeout(function () { - log('timeout'); - ws.close(); - emitError('ETIMEDOUT', 'Connection timeout'); - }, config.connectionTimeout); - log('bypass properties'); - for (var key in ws) { - // @todo move to constant - if (['addEventListener', 'removeEventListener', 'close', 'send'].indexOf(key) < 0) { - bypassProperty(ws, _this, key); - } + scope.set( + FRAMEBUFFER_STATE, + '.next', + FRAMEBUFFER) + var CONTEXT = shared.context + scope.set( + CONTEXT, + '.' + S_FRAMEBUFFER_WIDTH, + FRAMEBUFFER + '?' + FRAMEBUFFER + '.width:' + + CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH) + scope.set( + CONTEXT, + '.' + S_FRAMEBUFFER_HEIGHT, + FRAMEBUFFER + + '?' + FRAMEBUFFER + '.height:' + + CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT) + return FRAMEBUFFER + }) + } else { + return null + } + } + + function parseViewportScissor (options, framebuffer, env) { + var staticOptions = options.static + var dynamicOptions = options.dynamic + + function parseBox (param) { + if (param in staticOptions) { + var box = staticOptions[param] + check$1.commandType(box, 'object', 'invalid ' + param, env.commandStr) + + var isStatic = true + var x = box.x | 0 + var y = box.y | 0 + var w, h + if ('width' in box) { + w = box.width | 0 + check$1.command(w >= 0, 'invalid ' + param, env.commandStr) + } else { + isStatic = false } - ws.addEventListener('open', function () { - clearTimeout(connectingTimeout); - log('open'); - reconnectDelay = initReconnectionDelay(config); - log('reconnectDelay:', reconnectDelay); - retriesCount = 0; - }); - ws.addEventListener('close', handleClose); - reassignEventListeners(ws, oldWs, listeners); - // because when closing with fastClose=true, it is saved and set to null to avoid double calls - ws.onclose = ws.onclose || savedOnClose; - savedOnClose = null; - }; - log('init'); - connect(); - this.close = function (code, reason, _a) { - if (code === void 0) { code = 1000; } - if (reason === void 0) { reason = ''; } - var _b = _a === void 0 ? {} : _a, _c = _b.keepClosed, keepClosed = _c === void 0 ? false : _c, _d = _b.fastClose, fastClose = _d === void 0 ? true : _d, _e = _b.delay, delay = _e === void 0 ? 0 : _e; - if (delay) { - reconnectDelay = delay; + if ('height' in box) { + h = box.height | 0 + check$1.command(h >= 0, 'invalid ' + param, env.commandStr) + } else { + isStatic = false } - shouldRetry = !keepClosed; - ws.close(code, reason); - if (fastClose) { - var fakeCloseEvent_1 = { - code: code, - reason: reason, - wasClean: true, - }; - // execute close listeners soon with a fake closeEvent - // and remove them from the WS instance so they - // don't get fired on the real close. - handleClose(); - ws.removeEventListener('close', handleClose); - // run and remove level2 - if (Array.isArray(listeners.close)) { - listeners.close.forEach(function (_a) { - var listener = _a[0], options = _a[1]; - listener(fakeCloseEvent_1); - ws.removeEventListener('close', listener, options); - }); - } - // run and remove level0 - if (ws.onclose) { - savedOnClose = ws.onclose; - ws.onclose(fakeCloseEvent_1); - ws.onclose = null; + + return new Declaration( + !isStatic && framebuffer && framebuffer.thisDep, + !isStatic && framebuffer && framebuffer.contextDep, + !isStatic && framebuffer && framebuffer.propDep, + function (env, scope) { + var CONTEXT = env.shared.context + var BOX_W = w + if (!('width' in box)) { + BOX_W = scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', x) } - } - }; - this.send = function (data) { - ws.send(data); - }; - this.addEventListener = function (type, listener, options) { - if (Array.isArray(listeners[type])) { - if (!listeners[type].some(function (_a) { - var l = _a[0]; - return l === listener; - })) { - listeners[type].push([listener, options]); + var BOX_H = h + if (!('height' in box)) { + BOX_H = scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', y) } + return [x, y, BOX_W, BOX_H] + }) + } else if (param in dynamicOptions) { + var dynBox = dynamicOptions[param] + var result = createDynamicDecl(dynBox, function (env, scope) { + var BOX = env.invoke(scope, dynBox) + + check$1.optional(function () { + env.assert(scope, + BOX + '&&typeof ' + BOX + '==="object"', + 'invalid ' + param) + }) + + var CONTEXT = env.shared.context + var BOX_X = scope.def(BOX, '.x|0') + var BOX_Y = scope.def(BOX, '.y|0') + var BOX_W = scope.def( + '"width" in ', BOX, '?', BOX, '.width|0:', + '(', CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', BOX_X, ')') + var BOX_H = scope.def( + '"height" in ', BOX, '?', BOX, '.height|0:', + '(', CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', BOX_Y, ')') + + check$1.optional(function () { + env.assert(scope, + BOX_W + '>=0&&' + + BOX_H + '>=0', + 'invalid ' + param) + }) + + return [BOX_X, BOX_Y, BOX_W, BOX_H] + }) + if (framebuffer) { + result.thisDep = result.thisDep || framebuffer.thisDep + result.contextDep = result.contextDep || framebuffer.contextDep + result.propDep = result.propDep || framebuffer.propDep } - else { - listeners[type] = [[listener, options]]; - } - ws.addEventListener(type, listener, options); - }; - this.removeEventListener = function (type, listener, options) { - if (Array.isArray(listeners[type])) { - listeners[type] = listeners[type].filter(function (_a) { - var l = _a[0]; - return l !== listener; - }); + return result + } else if (framebuffer) { + return new Declaration( + framebuffer.thisDep, + framebuffer.contextDep, + framebuffer.propDep, + function (env, scope) { + var CONTEXT = env.shared.context + return [ + 0, 0, + scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH), + scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT)] + }) + } else { + return null + } + } + + var viewport = parseBox(S_VIEWPORT) + + if (viewport) { + var prevViewport = viewport + viewport = new Declaration( + viewport.thisDep, + viewport.contextDep, + viewport.propDep, + function (env, scope) { + var VIEWPORT = prevViewport.append(env, scope) + var CONTEXT = env.shared.context + scope.set( + CONTEXT, + '.' + S_VIEWPORT_WIDTH, + VIEWPORT[2]) + scope.set( + CONTEXT, + '.' + S_VIEWPORT_HEIGHT, + VIEWPORT[3]) + return VIEWPORT + }) + } + + return { + viewport: viewport, + scissor_box: parseBox(S_SCISSOR_BOX) + } + } + + function parseAttribLocations (options, attributes) { + var staticOptions = options.static + var staticProgram = + typeof staticOptions[S_FRAG] === 'string' && + typeof staticOptions[S_VERT] === 'string' + if (staticProgram) { + if (Object.keys(attributes.dynamic).length > 0) { + return null + } + var staticAttributes = attributes.static + var sAttributes = Object.keys(staticAttributes) + if (sAttributes.length > 0 && typeof staticAttributes[sAttributes[0]] === 'number') { + var bindings = [] + for (var i = 0; i < sAttributes.length; ++i) { + check$1(typeof staticAttributes[sAttributes[i]] === 'number', 'must specify all vertex attribute locations when using vaos') + bindings.push([staticAttributes[sAttributes[i]] | 0, sAttributes[i]]) } - ws.removeEventListener(type, listener, options); - }; -}; -module.exports = ReconnectingWebsocket; + return bindings + } + } + return null + } + function parseProgram (options, env, attribLocations) { + var staticOptions = options.static + var dynamicOptions = options.dynamic -/***/ }), -/* 27 */ -/***/ (function(module, exports) { + function parseShader (name) { + if (name in staticOptions) { + var id = stringStore.id(staticOptions[name]) + check$1.optional(function () { + shaderState.shader(shaderType[name], id, check$1.guessCommand()) + }) + var result = createStaticDecl(function () { + return id + }) + result.id = id + return result + } else if (name in dynamicOptions) { + var dyn = dynamicOptions[name] + return createDynamicDecl(dyn, function (env, scope) { + var str = env.invoke(scope, dyn) + var id = scope.def(env.shared.strings, '.id(', str, ')') + check$1.optional(function () { + scope( + env.shared.shader, '.shader(', + shaderType[name], ',', + id, ',', + env.command, ');') + }) + return id + }) + } + return null + } -module.exports = jQuery; + var frag = parseShader(S_FRAG) + var vert = parseShader(S_VERT) -/***/ }), -/* 28 */ -/***/ (function(module, exports, __webpack_require__) { + var program = null + var progVar + if (isStatic(frag) && isStatic(vert)) { + program = shaderState.program(vert.id, frag.id, null, attribLocations) + progVar = createStaticDecl(function (env, scope) { + return env.link(program) + }) + } else { + progVar = new Declaration( + (frag && frag.thisDep) || (vert && vert.thisDep), + (frag && frag.contextDep) || (vert && vert.contextDep), + (frag && frag.propDep) || (vert && vert.propDep), + function (env, scope) { + var SHADER_STATE = env.shared.shader + var fragId + if (frag) { + fragId = frag.append(env, scope) + } else { + fragId = scope.def(SHADER_STATE, '.', S_FRAG) + } + var vertId + if (vert) { + vertId = vert.append(env, scope) + } else { + vertId = scope.def(SHADER_STATE, '.', S_VERT) + } + var progDef = SHADER_STATE + '.program(' + vertId + ',' + fragId + check$1.optional(function () { + progDef += ',' + env.command + }) + return scope.def(progDef + ')') + }) + } -(function(exports) { + return { + frag: frag, + vert: vert, + progVar: progVar, + program: program + } + } - // Complementary error function - // From Numerical Recipes in C 2e p221 - var erfc = function(x) { - var z = Math.abs(x); - var t = 1 / (1 + z / 2); - var r = t * Math.exp(-z * z - 1.26551223 + t * (1.00002368 + - t * (0.37409196 + t * (0.09678418 + t * (-0.18628806 + - t * (0.27886807 + t * (-1.13520398 + t * (1.48851587 + - t * (-0.82215223 + t * 0.17087277))))))))) - return x >= 0 ? r : 2 - r; - }; + function parseDraw (options, env) { + var staticOptions = options.static + var dynamicOptions = options.dynamic + + function parseElements () { + if (S_ELEMENTS in staticOptions) { + var elements = staticOptions[S_ELEMENTS] + if (isBufferArgs(elements)) { + elements = elementState.getElements(elementState.create(elements, true)) + } else if (elements) { + elements = elementState.getElements(elements) + check$1.command(elements, 'invalid elements', env.commandStr) + } + var result = createStaticDecl(function (env, scope) { + if (elements) { + var result = env.link(elements) + env.ELEMENTS = result + return result + } + env.ELEMENTS = null + return null + }) + result.value = elements + return result + } else if (S_ELEMENTS in dynamicOptions) { + var dyn = dynamicOptions[S_ELEMENTS] + return createDynamicDecl(dyn, function (env, scope) { + var shared = env.shared + + var IS_BUFFER_ARGS = shared.isBufferArgs + var ELEMENT_STATE = shared.elements + + var elementDefn = env.invoke(scope, dyn) + var elements = scope.def('null') + var elementStream = scope.def(IS_BUFFER_ARGS, '(', elementDefn, ')') + + var ifte = env.cond(elementStream) + .then(elements, '=', ELEMENT_STATE, '.createStream(', elementDefn, ');') + .else(elements, '=', ELEMENT_STATE, '.getElements(', elementDefn, ');') + + check$1.optional(function () { + env.assert(ifte.else, + '!' + elementDefn + '||' + elements, + 'invalid elements') + }) - // Inverse complementary error function - // From Numerical Recipes 3e p265 - var ierfc = function(x) { - if (x >= 2) { return -100; } - if (x <= 0) { return 100; } + scope.entry(ifte) + scope.exit( + env.cond(elementStream) + .then(ELEMENT_STATE, '.destroyStream(', elements, ');')) - var xx = (x < 1) ? x : 2 - x; - var t = Math.sqrt(-2 * Math.log(xx / 2)); + env.ELEMENTS = elements - var r = -0.70711 * ((2.30753 + t * 0.27061) / - (1 + t * (0.99229 + t * 0.04481)) - t); + return elements + }) + } - for (var j = 0; j < 2; j++) { - var err = erfc(r) - xx; - r += err / (1.12837916709551257 * Math.exp(-(r * r)) - r * err); + return null } - return (x < 1) ? r : -r; - }; + var elements = parseElements() - // Models the normal distribution - var Gaussian = function(mean, variance) { - if (variance <= 0) { - throw new Error('Variance must be > 0 (but was ' + variance + ')'); + function parsePrimitive () { + if (S_PRIMITIVE in staticOptions) { + var primitive = staticOptions[S_PRIMITIVE] + check$1.commandParameter(primitive, primTypes, 'invalid primitve', env.commandStr) + return createStaticDecl(function (env, scope) { + return primTypes[primitive] + }) + } else if (S_PRIMITIVE in dynamicOptions) { + var dynPrimitive = dynamicOptions[S_PRIMITIVE] + return createDynamicDecl(dynPrimitive, function (env, scope) { + var PRIM_TYPES = env.constants.primTypes + var prim = env.invoke(scope, dynPrimitive) + check$1.optional(function () { + env.assert(scope, + prim + ' in ' + PRIM_TYPES, + 'invalid primitive, must be one of ' + Object.keys(primTypes)) + }) + return scope.def(PRIM_TYPES, '[', prim, ']') + }) + } else if (elements) { + if (isStatic(elements)) { + if (elements.value) { + return createStaticDecl(function (env, scope) { + return scope.def(env.ELEMENTS, '.primType') + }) + } else { + return createStaticDecl(function () { + return GL_TRIANGLES$1 + }) + } + } else { + return new Declaration( + elements.thisDep, + elements.contextDep, + elements.propDep, + function (env, scope) { + var elements = env.ELEMENTS + return scope.def(elements, '?', elements, '.primType:', GL_TRIANGLES$1) + }) + } + } + return null } - this.mean = mean; - this.variance = variance; - this.standardDeviation = Math.sqrt(variance); - } - // Probability density function - Gaussian.prototype.pdf = function(x) { - var m = this.standardDeviation * Math.sqrt(2 * Math.PI); - var e = Math.exp(-Math.pow(x - this.mean, 2) / (2 * this.variance)); - return e / m; - }; + function parseParam (param, isOffset) { + if (param in staticOptions) { + var value = staticOptions[param] | 0 + check$1.command(!isOffset || value >= 0, 'invalid ' + param, env.commandStr) + return createStaticDecl(function (env, scope) { + if (isOffset) { + env.OFFSET = value + } + return value + }) + } else if (param in dynamicOptions) { + var dynValue = dynamicOptions[param] + return createDynamicDecl(dynValue, function (env, scope) { + var result = env.invoke(scope, dynValue) + if (isOffset) { + env.OFFSET = result + check$1.optional(function () { + env.assert(scope, + result + '>=0', + 'invalid ' + param) + }) + } + return result + }) + } else if (isOffset && elements) { + return createStaticDecl(function (env, scope) { + env.OFFSET = '0' + return 0 + }) + } + return null + } - // Cumulative density function - Gaussian.prototype.cdf = function(x) { - return 0.5 * erfc(-(x - this.mean) / (this.standardDeviation * Math.sqrt(2))); - }; + var OFFSET = parseParam(S_OFFSET, true) - // Percent point function - Gaussian.prototype.ppf = function(x) { - return this.mean - this.standardDeviation * Math.sqrt(2) * ierfc(2 * x); - }; + function parseVertCount () { + if (S_COUNT in staticOptions) { + var count = staticOptions[S_COUNT] | 0 + check$1.command( + typeof count === 'number' && count >= 0, 'invalid vertex count', env.commandStr) + return createStaticDecl(function () { + return count + }) + } else if (S_COUNT in dynamicOptions) { + var dynCount = dynamicOptions[S_COUNT] + return createDynamicDecl(dynCount, function (env, scope) { + var result = env.invoke(scope, dynCount) + check$1.optional(function () { + env.assert(scope, + 'typeof ' + result + '==="number"&&' + + result + '>=0&&' + + result + '===(' + result + '|0)', + 'invalid vertex count') + }) + return result + }) + } else if (elements) { + if (isStatic(elements)) { + if (elements) { + if (OFFSET) { + return new Declaration( + OFFSET.thisDep, + OFFSET.contextDep, + OFFSET.propDep, + function (env, scope) { + var result = scope.def( + env.ELEMENTS, '.vertCount-', env.OFFSET) - // Product distribution of this and d (scale for constant) - Gaussian.prototype.mul = function(d) { - if (typeof(d) === "number") { - return this.scale(d); + check$1.optional(function () { + env.assert(scope, + result + '>=0', + 'invalid vertex offset/element buffer too small') + }) + + return result + }) + } else { + return createStaticDecl(function (env, scope) { + return scope.def(env.ELEMENTS, '.vertCount') + }) + } + } else { + var result = createStaticDecl(function () { + return -1 + }) + check$1.optional(function () { + result.MISSING = true + }) + return result + } + } else { + var variable = new Declaration( + elements.thisDep || OFFSET.thisDep, + elements.contextDep || OFFSET.contextDep, + elements.propDep || OFFSET.propDep, + function (env, scope) { + var elements = env.ELEMENTS + if (env.OFFSET) { + return scope.def(elements, '?', elements, '.vertCount-', + env.OFFSET, ':-1') + } + return scope.def(elements, '?', elements, '.vertCount:-1') + }) + check$1.optional(function () { + variable.DYNAMIC = true + }) + return variable + } + } + return null } - var precision = 1 / this.variance; - var dprecision = 1 / d.variance; - return fromPrecisionMean( - precision + dprecision, - precision * this.mean + dprecision * d.mean); - }; - // Quotient distribution of this and d (scale for constant) - Gaussian.prototype.div = function(d) { - if (typeof(d) === "number") { - return this.scale(1 / d); + return { + elements: elements, + primitive: parsePrimitive(), + count: parseVertCount(), + instances: parseParam(S_INSTANCES, false), + offset: OFFSET } - var precision = 1 / this.variance; - var dprecision = 1 / d.variance; - return fromPrecisionMean( - precision - dprecision, - precision * this.mean - dprecision * d.mean); - }; + } - // Addition of this and d - Gaussian.prototype.add = function(d) { - return gaussian(this.mean + d.mean, this.variance + d.variance); - }; + function parseGLState (options, env) { + var staticOptions = options.static + var dynamicOptions = options.dynamic - // Subtraction of this and d - Gaussian.prototype.sub = function(d) { - return gaussian(this.mean - d.mean, this.variance + d.variance); - }; + var STATE = {} - // Scale this by constant c - Gaussian.prototype.scale = function(c) { - return gaussian(this.mean * c, this.variance * c * c); - }; + GL_STATE_NAMES.forEach(function (prop) { + var param = propName(prop) - var gaussian = function(mean, variance) { - return new Gaussian(mean, variance); - }; + function parseParam (parseStatic, parseDynamic) { + if (prop in staticOptions) { + var value = parseStatic(staticOptions[prop]) + STATE[param] = createStaticDecl(function () { + return value + }) + } else if (prop in dynamicOptions) { + var dyn = dynamicOptions[prop] + STATE[param] = createDynamicDecl(dyn, function (env, scope) { + return parseDynamic(env, scope, env.invoke(scope, dyn)) + }) + } + } + + switch (prop) { + case S_CULL_ENABLE: + case S_BLEND_ENABLE: + case S_DITHER: + case S_STENCIL_ENABLE: + case S_DEPTH_ENABLE: + case S_SCISSOR_ENABLE: + case S_POLYGON_OFFSET_ENABLE: + case S_SAMPLE_ALPHA: + case S_SAMPLE_ENABLE: + case S_DEPTH_MASK: + return parseParam( + function (value) { + check$1.commandType(value, 'boolean', prop, env.commandStr) + return value + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + 'typeof ' + value + '==="boolean"', + 'invalid flag ' + prop, env.commandStr) + }) + return value + }) + + case S_DEPTH_FUNC: + return parseParam( + function (value) { + check$1.commandParameter(value, compareFuncs, 'invalid ' + prop, env.commandStr) + return compareFuncs[value] + }, + function (env, scope, value) { + var COMPARE_FUNCS = env.constants.compareFuncs + check$1.optional(function () { + env.assert(scope, + value + ' in ' + COMPARE_FUNCS, + 'invalid ' + prop + ', must be one of ' + Object.keys(compareFuncs)) + }) + return scope.def(COMPARE_FUNCS, '[', value, ']') + }) - var fromPrecisionMean = function(precision, precisionmean) { - return gaussian(precisionmean / precision, 1 / precision); - }; + case S_DEPTH_RANGE: + return parseParam( + function (value) { + check$1.command( + isArrayLike(value) && + value.length === 2 && + typeof value[0] === 'number' && + typeof value[1] === 'number' && + value[0] <= value[1], + 'depth range is 2d array', + env.commandStr) + return value + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + env.shared.isArrayLike + '(' + value + ')&&' + + value + '.length===2&&' + + 'typeof ' + value + '[0]==="number"&&' + + 'typeof ' + value + '[1]==="number"&&' + + value + '[0]<=' + value + '[1]', + 'depth range must be a 2d array') + }) - exports(gaussian); -}) -( true - ? function(e) { module.exports = e; } - : function(e) { this["gaussian"] = e; }); + var Z_NEAR = scope.def('+', value, '[0]') + var Z_FAR = scope.def('+', value, '[1]') + return [Z_NEAR, Z_FAR] + }) + case S_BLEND_FUNC: + return parseParam( + function (value) { + check$1.commandType(value, 'object', 'blend.func', env.commandStr) + var srcRGB = ('srcRGB' in value ? value.srcRGB : value.src) + var srcAlpha = ('srcAlpha' in value ? value.srcAlpha : value.src) + var dstRGB = ('dstRGB' in value ? value.dstRGB : value.dst) + var dstAlpha = ('dstAlpha' in value ? value.dstAlpha : value.dst) + check$1.commandParameter(srcRGB, blendFuncs, param + '.srcRGB', env.commandStr) + check$1.commandParameter(srcAlpha, blendFuncs, param + '.srcAlpha', env.commandStr) + check$1.commandParameter(dstRGB, blendFuncs, param + '.dstRGB', env.commandStr) + check$1.commandParameter(dstAlpha, blendFuncs, param + '.dstAlpha', env.commandStr) -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { + check$1.command( + (invalidBlendCombinations.indexOf(srcRGB + ', ' + dstRGB) === -1), + 'unallowed blending combination (srcRGB, dstRGB) = (' + srcRGB + ', ' + dstRGB + ')', env.commandStr) -"use strict"; + return [ + blendFuncs[srcRGB], + blendFuncs[dstRGB], + blendFuncs[srcAlpha], + blendFuncs[dstAlpha] + ] + }, + function (env, scope, value) { + var BLEND_FUNCS = env.constants.blendFuncs + check$1.optional(function () { + env.assert(scope, + value + '&&typeof ' + value + '==="object"', + 'invalid blend func, must be an object') + }) -var colorString = __webpack_require__(30); -var convert = __webpack_require__(33); + function read (prefix, suffix) { + var func = scope.def( + '"', prefix, suffix, '" in ', value, + '?', value, '.', prefix, suffix, + ':', value, '.', prefix) -var _slice = [].slice; + check$1.optional(function () { + env.assert(scope, + func + ' in ' + BLEND_FUNCS, + 'invalid ' + prop + '.' + prefix + suffix + ', must be one of ' + Object.keys(blendFuncs)) + }) -var skippedModels = [ - // to be honest, I don't really feel like keyword belongs in color convert, but eh. - 'keyword', + return func + } - // gray conflicts with some method names, and has its own method defined. - 'gray', + var srcRGB = read('src', 'RGB') + var dstRGB = read('dst', 'RGB') - // shouldn't really be in color-convert either... - 'hex' -]; + check$1.optional(function () { + var INVALID_BLEND_COMBINATIONS = env.constants.invalidBlendCombinations -var hashedModelKeys = {}; -Object.keys(convert).forEach(function (model) { - hashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model; -}); + env.assert(scope, + INVALID_BLEND_COMBINATIONS + + '.indexOf(' + srcRGB + '+", "+' + dstRGB + ') === -1 ', + 'unallowed blending combination for (srcRGB, dstRGB)' + ) + }) -var limiters = {}; + var SRC_RGB = scope.def(BLEND_FUNCS, '[', srcRGB, ']') + var SRC_ALPHA = scope.def(BLEND_FUNCS, '[', read('src', 'Alpha'), ']') + var DST_RGB = scope.def(BLEND_FUNCS, '[', dstRGB, ']') + var DST_ALPHA = scope.def(BLEND_FUNCS, '[', read('dst', 'Alpha'), ']') -function Color(obj, model) { - if (!(this instanceof Color)) { - return new Color(obj, model); - } + return [SRC_RGB, DST_RGB, SRC_ALPHA, DST_ALPHA] + }) - if (model && model in skippedModels) { - model = null; - } + case S_BLEND_EQUATION: + return parseParam( + function (value) { + if (typeof value === 'string') { + check$1.commandParameter(value, blendEquations, 'invalid ' + prop, env.commandStr) + return [ + blendEquations[value], + blendEquations[value] + ] + } else if (typeof value === 'object') { + check$1.commandParameter( + value.rgb, blendEquations, prop + '.rgb', env.commandStr) + check$1.commandParameter( + value.alpha, blendEquations, prop + '.alpha', env.commandStr) + return [ + blendEquations[value.rgb], + blendEquations[value.alpha] + ] + } else { + check$1.commandRaise('invalid blend.equation', env.commandStr) + } + }, + function (env, scope, value) { + var BLEND_EQUATIONS = env.constants.blendEquations - if (model && !(model in convert)) { - throw new Error('Unknown model: ' + model); - } + var RGB = scope.def() + var ALPHA = scope.def() - var i; - var channels; + var ifte = env.cond('typeof ', value, '==="string"') - if (!obj) { - this.model = 'rgb'; - this.color = [0, 0, 0]; - this.valpha = 1; - } else if (obj instanceof Color) { - this.model = obj.model; - this.color = obj.color.slice(); - this.valpha = obj.valpha; - } else if (typeof obj === 'string') { - var result = colorString.get(obj); - if (result === null) { - throw new Error('Unable to parse color from string: ' + obj); - } + check$1.optional(function () { + function checkProp (block, name, value) { + env.assert(block, + value + ' in ' + BLEND_EQUATIONS, + 'invalid ' + name + ', must be one of ' + Object.keys(blendEquations)) + } + checkProp(ifte.then, prop, value) - this.model = result.model; - channels = convert[this.model].channels; - this.color = result.value.slice(0, channels); - this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1; - } else if (obj.length) { - this.model = model || 'rgb'; - channels = convert[this.model].channels; - var newArr = _slice.call(obj, 0, channels); - this.color = zeroArray(newArr, channels); - this.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1; - } else if (typeof obj === 'number') { - // this is always RGB - can be converted later on. - obj &= 0xFFFFFF; - this.model = 'rgb'; - this.color = [ - (obj >> 16) & 0xFF, - (obj >> 8) & 0xFF, - obj & 0xFF - ]; - this.valpha = 1; - } else { - this.valpha = 1; + env.assert(ifte.else, + value + '&&typeof ' + value + '==="object"', + 'invalid ' + prop) + checkProp(ifte.else, prop + '.rgb', value + '.rgb') + checkProp(ifte.else, prop + '.alpha', value + '.alpha') + }) - var keys = Object.keys(obj); - if ('alpha' in obj) { - keys.splice(keys.indexOf('alpha'), 1); - this.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0; - } + ifte.then( + RGB, '=', ALPHA, '=', BLEND_EQUATIONS, '[', value, '];') + ifte.else( + RGB, '=', BLEND_EQUATIONS, '[', value, '.rgb];', + ALPHA, '=', BLEND_EQUATIONS, '[', value, '.alpha];') - var hashedKeys = keys.sort().join(''); - if (!(hashedKeys in hashedModelKeys)) { - throw new Error('Unable to parse color from object: ' + JSON.stringify(obj)); - } + scope(ifte) - this.model = hashedModelKeys[hashedKeys]; + return [RGB, ALPHA] + }) - var labels = convert[this.model].labels; - var color = []; - for (i = 0; i < labels.length; i++) { - color.push(obj[labels[i]]); - } + case S_BLEND_COLOR: + return parseParam( + function (value) { + check$1.command( + isArrayLike(value) && + value.length === 4, + 'blend.color must be a 4d array', env.commandStr) + return loop(4, function (i) { + return +value[i] + }) + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + env.shared.isArrayLike + '(' + value + ')&&' + + value + '.length===4', + 'blend.color must be a 4d array') + }) + return loop(4, function (i) { + return scope.def('+', value, '[', i, ']') + }) + }) - this.color = zeroArray(color); - } + case S_STENCIL_MASK: + return parseParam( + function (value) { + check$1.commandType(value, 'number', param, env.commandStr) + return value | 0 + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + 'typeof ' + value + '==="number"', + 'invalid stencil.mask') + }) + return scope.def(value, '|0') + }) - // perform limitations (clamping, etc.) - if (limiters[this.model]) { - channels = convert[this.model].channels; - for (i = 0; i < channels; i++) { - var limit = limiters[this.model][i]; - if (limit) { - this.color[i] = limit(this.color[i]); - } - } - } + case S_STENCIL_FUNC: + return parseParam( + function (value) { + check$1.commandType(value, 'object', param, env.commandStr) + var cmp = value.cmp || 'keep' + var ref = value.ref || 0 + var mask = 'mask' in value ? value.mask : -1 + check$1.commandParameter(cmp, compareFuncs, prop + '.cmp', env.commandStr) + check$1.commandType(ref, 'number', prop + '.ref', env.commandStr) + check$1.commandType(mask, 'number', prop + '.mask', env.commandStr) + return [ + compareFuncs[cmp], + ref, + mask + ] + }, + function (env, scope, value) { + var COMPARE_FUNCS = env.constants.compareFuncs + check$1.optional(function () { + function assert () { + env.assert(scope, + Array.prototype.join.call(arguments, ''), + 'invalid stencil.func') + } + assert(value + '&&typeof ', value, '==="object"') + assert('!("cmp" in ', value, ')||(', + value, '.cmp in ', COMPARE_FUNCS, ')') + }) + var cmp = scope.def( + '"cmp" in ', value, + '?', COMPARE_FUNCS, '[', value, '.cmp]', + ':', GL_KEEP) + var ref = scope.def(value, '.ref|0') + var mask = scope.def( + '"mask" in ', value, + '?', value, '.mask|0:-1') + return [cmp, ref, mask] + }) + + case S_STENCIL_OPFRONT: + case S_STENCIL_OPBACK: + return parseParam( + function (value) { + check$1.commandType(value, 'object', param, env.commandStr) + var fail = value.fail || 'keep' + var zfail = value.zfail || 'keep' + var zpass = value.zpass || 'keep' + check$1.commandParameter(fail, stencilOps, prop + '.fail', env.commandStr) + check$1.commandParameter(zfail, stencilOps, prop + '.zfail', env.commandStr) + check$1.commandParameter(zpass, stencilOps, prop + '.zpass', env.commandStr) + return [ + prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT, + stencilOps[fail], + stencilOps[zfail], + stencilOps[zpass] + ] + }, + function (env, scope, value) { + var STENCIL_OPS = env.constants.stencilOps - this.valpha = Math.max(0, Math.min(1, this.valpha)); + check$1.optional(function () { + env.assert(scope, + value + '&&typeof ' + value + '==="object"', + 'invalid ' + prop) + }) - if (Object.freeze) { - Object.freeze(this); - } -} + function read (name) { + check$1.optional(function () { + env.assert(scope, + '!("' + name + '" in ' + value + ')||' + + '(' + value + '.' + name + ' in ' + STENCIL_OPS + ')', + 'invalid ' + prop + '.' + name + ', must be one of ' + Object.keys(stencilOps)) + }) -Color.prototype = { - toString: function () { - return this.string(); - }, + return scope.def( + '"', name, '" in ', value, + '?', STENCIL_OPS, '[', value, '.', name, ']:', + GL_KEEP) + } - toJSON: function () { - return this[this.model](); - }, + return [ + prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT, + read('fail'), + read('zfail'), + read('zpass') + ] + }) - string: function (places) { - var self = this.model in colorString.to ? this : this.rgb(); - self = self.round(typeof places === 'number' ? places : 1); - var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha); - return colorString.to[self.model](args); - }, + case S_POLYGON_OFFSET_OFFSET: + return parseParam( + function (value) { + check$1.commandType(value, 'object', param, env.commandStr) + var factor = value.factor | 0 + var units = value.units | 0 + check$1.commandType(factor, 'number', param + '.factor', env.commandStr) + check$1.commandType(units, 'number', param + '.units', env.commandStr) + return [factor, units] + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + value + '&&typeof ' + value + '==="object"', + 'invalid ' + prop) + }) - percentString: function (places) { - var self = this.rgb().round(typeof places === 'number' ? places : 1); - var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha); - return colorString.to.rgb.percent(args); - }, + var FACTOR = scope.def(value, '.factor|0') + var UNITS = scope.def(value, '.units|0') - array: function () { - return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha); - }, + return [FACTOR, UNITS] + }) - object: function () { - var result = {}; - var channels = convert[this.model].channels; - var labels = convert[this.model].labels; + case S_CULL_FACE: + return parseParam( + function (value) { + var face = 0 + if (value === 'front') { + face = GL_FRONT + } else if (value === 'back') { + face = GL_BACK + } + check$1.command(!!face, param, env.commandStr) + return face + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + value + '==="front"||' + + value + '==="back"', + 'invalid cull.face') + }) + return scope.def(value, '==="front"?', GL_FRONT, ':', GL_BACK) + }) - for (var i = 0; i < channels; i++) { - result[labels[i]] = this.color[i]; - } + case S_LINE_WIDTH: + return parseParam( + function (value) { + check$1.command( + typeof value === 'number' && + value >= limits.lineWidthDims[0] && + value <= limits.lineWidthDims[1], + 'invalid line width, must be a positive number between ' + + limits.lineWidthDims[0] + ' and ' + limits.lineWidthDims[1], env.commandStr) + return value + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + 'typeof ' + value + '==="number"&&' + + value + '>=' + limits.lineWidthDims[0] + '&&' + + value + '<=' + limits.lineWidthDims[1], + 'invalid line width') + }) - if (this.valpha !== 1) { - result.alpha = this.valpha; - } + return value + }) - return result; - }, + case S_FRONT_FACE: + return parseParam( + function (value) { + check$1.commandParameter(value, orientationType, param, env.commandStr) + return orientationType[value] + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + value + '==="cw"||' + + value + '==="ccw"', + 'invalid frontFace, must be one of cw,ccw') + }) + return scope.def(value + '==="cw"?' + GL_CW + ':' + GL_CCW) + }) - unitArray: function () { - var rgb = this.rgb().color; - rgb[0] /= 255; - rgb[1] /= 255; - rgb[2] /= 255; + case S_COLOR_MASK: + return parseParam( + function (value) { + check$1.command( + isArrayLike(value) && value.length === 4, + 'color.mask must be length 4 array', env.commandStr) + return value.map(function (v) { return !!v }) + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + env.shared.isArrayLike + '(' + value + ')&&' + + value + '.length===4', + 'invalid color.mask') + }) + return loop(4, function (i) { + return '!!' + value + '[' + i + ']' + }) + }) - if (this.valpha !== 1) { - rgb.push(this.valpha); - } + case S_SAMPLE_COVERAGE: + return parseParam( + function (value) { + check$1.command(typeof value === 'object' && value, param, env.commandStr) + var sampleValue = 'value' in value ? value.value : 1 + var sampleInvert = !!value.invert + check$1.command( + typeof sampleValue === 'number' && + sampleValue >= 0 && sampleValue <= 1, + 'sample.coverage.value must be a number between 0 and 1', env.commandStr) + return [sampleValue, sampleInvert] + }, + function (env, scope, value) { + check$1.optional(function () { + env.assert(scope, + value + '&&typeof ' + value + '==="object"', + 'invalid sample.coverage') + }) + var VALUE = scope.def( + '"value" in ', value, '?+', value, '.value:1') + var INVERT = scope.def('!!', value, '.invert') + return [VALUE, INVERT] + }) + } + }) - return rgb; - }, + return STATE + } - unitObject: function () { - var rgb = this.rgb().object(); - rgb.r /= 255; - rgb.g /= 255; - rgb.b /= 255; + function parseUniforms (uniforms, env) { + var staticUniforms = uniforms.static + var dynamicUniforms = uniforms.dynamic - if (this.valpha !== 1) { - rgb.alpha = this.valpha; - } + var UNIFORMS = {} - return rgb; - }, + Object.keys(staticUniforms).forEach(function (name) { + var value = staticUniforms[name] + var result + if (typeof value === 'number' || + typeof value === 'boolean') { + result = createStaticDecl(function () { + return value + }) + } else if (typeof value === 'function') { + var reglType = value._reglType + if (reglType === 'texture2d' || + reglType === 'textureCube') { + result = createStaticDecl(function (env) { + return env.link(value) + }) + } else if (reglType === 'framebuffer' || + reglType === 'framebufferCube') { + check$1.command(value.color.length > 0, + 'missing color attachment for framebuffer sent to uniform "' + name + '"', env.commandStr) + result = createStaticDecl(function (env) { + return env.link(value.color[0]) + }) + } else { + check$1.commandRaise('invalid data for uniform "' + name + '"', env.commandStr) + } + } else if (isArrayLike(value)) { + result = createStaticDecl(function (env) { + var ITEM = env.global.def('[', + loop(value.length, function (i) { + check$1.command( + typeof value[i] === 'number' || + typeof value[i] === 'boolean', + 'invalid uniform ' + name, env.commandStr) + return value[i] + }), ']') + return ITEM + }) + } else { + check$1.commandRaise('invalid or missing data for uniform "' + name + '"', env.commandStr) + } + result.value = value + UNIFORMS[name] = result + }) - round: function (places) { - places = Math.max(places || 0, 0); - return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model); - }, + Object.keys(dynamicUniforms).forEach(function (key) { + var dyn = dynamicUniforms[key] + UNIFORMS[key] = createDynamicDecl(dyn, function (env, scope) { + return env.invoke(scope, dyn) + }) + }) - alpha: function (val) { - if (arguments.length) { - return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model); - } + return UNIFORMS + } - return this.valpha; - }, + function parseAttributes (attributes, env) { + var staticAttributes = attributes.static + var dynamicAttributes = attributes.dynamic - // rgb - red: getset('rgb', 0, maxfn(255)), - green: getset('rgb', 1, maxfn(255)), - blue: getset('rgb', 2, maxfn(255)), + var attributeDefs = {} + + Object.keys(staticAttributes).forEach(function (attribute) { + var value = staticAttributes[attribute] + var id = stringStore.id(attribute) + + var record = new AttributeRecord() + if (isBufferArgs(value)) { + record.state = ATTRIB_STATE_POINTER + record.buffer = bufferState.getBuffer( + bufferState.create(value, GL_ARRAY_BUFFER$2, false, true)) + record.type = 0 + } else { + var buffer = bufferState.getBuffer(value) + if (buffer) { + record.state = ATTRIB_STATE_POINTER + record.buffer = buffer + record.type = 0 + } else { + check$1.command(typeof value === 'object' && value, + 'invalid data for attribute ' + attribute, env.commandStr) + if ('constant' in value) { + var constant = value.constant + record.buffer = 'null' + record.state = ATTRIB_STATE_CONSTANT + if (typeof constant === 'number') { + record.x = constant + } else { + check$1.command( + isArrayLike(constant) && + constant.length > 0 && + constant.length <= 4, + 'invalid constant for attribute ' + attribute, env.commandStr) + CUTE_COMPONENTS.forEach(function (c, i) { + if (i < constant.length) { + record[c] = constant[i] + } + }) + } + } else { + if (isBufferArgs(value.buffer)) { + buffer = bufferState.getBuffer( + bufferState.create(value.buffer, GL_ARRAY_BUFFER$2, false, true)) + } else { + buffer = bufferState.getBuffer(value.buffer) + } + check$1.command(!!buffer, 'missing buffer for attribute "' + attribute + '"', env.commandStr) - hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style + var offset = value.offset | 0 + check$1.command(offset >= 0, + 'invalid offset for attribute "' + attribute + '"', env.commandStr) - saturationl: getset('hsl', 1, maxfn(100)), - lightness: getset('hsl', 2, maxfn(100)), + var stride = value.stride | 0 + check$1.command(stride >= 0 && stride < 256, + 'invalid stride for attribute "' + attribute + '", must be integer betweeen [0, 255]', env.commandStr) - saturationv: getset('hsv', 1, maxfn(100)), - value: getset('hsv', 2, maxfn(100)), + var size = value.size | 0 + check$1.command(!('size' in value) || (size > 0 && size <= 4), + 'invalid size for attribute "' + attribute + '", must be 1,2,3,4', env.commandStr) - chroma: getset('hcg', 1, maxfn(100)), - gray: getset('hcg', 2, maxfn(100)), + var normalized = !!value.normalized - white: getset('hwb', 1, maxfn(100)), - wblack: getset('hwb', 2, maxfn(100)), + var type = 0 + if ('type' in value) { + check$1.commandParameter( + value.type, glTypes, + 'invalid type for attribute ' + attribute, env.commandStr) + type = glTypes[value.type] + } - cyan: getset('cmyk', 0, maxfn(100)), - magenta: getset('cmyk', 1, maxfn(100)), - yellow: getset('cmyk', 2, maxfn(100)), - black: getset('cmyk', 3, maxfn(100)), + var divisor = value.divisor | 0 + if ('divisor' in value) { + check$1.command(divisor === 0 || extInstancing, + 'cannot specify divisor for attribute "' + attribute + '", instancing not supported', env.commandStr) + check$1.command(divisor >= 0, + 'invalid divisor for attribute "' + attribute + '"', env.commandStr) + } - x: getset('xyz', 0, maxfn(100)), - y: getset('xyz', 1, maxfn(100)), - z: getset('xyz', 2, maxfn(100)), + check$1.optional(function () { + var command = env.commandStr - l: getset('lab', 0, maxfn(100)), - a: getset('lab', 1), - b: getset('lab', 2), + var VALID_KEYS = [ + 'buffer', + 'offset', + 'divisor', + 'normalized', + 'type', + 'size', + 'stride' + ] - keyword: function (val) { - if (arguments.length) { - return new Color(val); - } + Object.keys(value).forEach(function (prop) { + check$1.command( + VALID_KEYS.indexOf(prop) >= 0, + 'unknown parameter "' + prop + '" for attribute pointer "' + attribute + '" (valid parameters are ' + VALID_KEYS + ')', + command) + }) + }) - return convert[this.model].keyword(this.color); - }, + record.buffer = buffer + record.state = ATTRIB_STATE_POINTER + record.size = size + record.normalized = normalized + record.type = type || buffer.dtype + record.offset = offset + record.stride = stride + record.divisor = divisor + } + } + } - hex: function (val) { - if (arguments.length) { - return new Color(val); - } + attributeDefs[attribute] = createStaticDecl(function (env, scope) { + var cache = env.attribCache + if (id in cache) { + return cache[id] + } + var result = { + isStream: false + } + Object.keys(record).forEach(function (key) { + result[key] = record[key] + }) + if (record.buffer) { + result.buffer = env.link(record.buffer) + result.type = result.type || (result.buffer + '.dtype') + } + cache[id] = result + return result + }) + }) - return colorString.to.hex(this.rgb().round().color); - }, + Object.keys(dynamicAttributes).forEach(function (attribute) { + var dyn = dynamicAttributes[attribute] - rgbNumber: function () { - var rgb = this.rgb().color; - return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF); - }, + function appendAttributeCode (env, block) { + var VALUE = env.invoke(block, dyn) - luminosity: function () { - // http://www.w3.org/TR/WCAG20/#relativeluminancedef - var rgb = this.rgb().color; + var shared = env.shared + var constants = env.constants - var lum = []; - for (var i = 0; i < rgb.length; i++) { - var chan = rgb[i] / 255; - lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4); - } + var IS_BUFFER_ARGS = shared.isBufferArgs + var BUFFER_STATE = shared.buffer - return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2]; - }, + // Perform validation on attribute + check$1.optional(function () { + env.assert(block, + VALUE + '&&(typeof ' + VALUE + '==="object"||typeof ' + + VALUE + '==="function")&&(' + + IS_BUFFER_ARGS + '(' + VALUE + ')||' + + BUFFER_STATE + '.getBuffer(' + VALUE + ')||' + + BUFFER_STATE + '.getBuffer(' + VALUE + '.buffer)||' + + IS_BUFFER_ARGS + '(' + VALUE + '.buffer)||' + + '("constant" in ' + VALUE + + '&&(typeof ' + VALUE + '.constant==="number"||' + + shared.isArrayLike + '(' + VALUE + '.constant))))', + 'invalid dynamic attribute "' + attribute + '"') + }) - contrast: function (color2) { - // http://www.w3.org/TR/WCAG20/#contrast-ratiodef - var lum1 = this.luminosity(); - var lum2 = color2.luminosity(); + // allocate names for result + var result = { + isStream: block.def(false) + } + var defaultRecord = new AttributeRecord() + defaultRecord.state = ATTRIB_STATE_POINTER + Object.keys(defaultRecord).forEach(function (key) { + result[key] = block.def('' + defaultRecord[key]) + }) - if (lum1 > lum2) { - return (lum1 + 0.05) / (lum2 + 0.05); - } + var BUFFER = result.buffer + var TYPE = result.type + block( + 'if(', IS_BUFFER_ARGS, '(', VALUE, ')){', + result.isStream, '=true;', + BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$2, ',', VALUE, ');', + TYPE, '=', BUFFER, '.dtype;', + '}else{', + BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, ');', + 'if(', BUFFER, '){', + TYPE, '=', BUFFER, '.dtype;', + '}else if("constant" in ', VALUE, '){', + result.state, '=', ATTRIB_STATE_CONSTANT, ';', + 'if(typeof ' + VALUE + '.constant === "number"){', + result[CUTE_COMPONENTS[0]], '=', VALUE, '.constant;', + CUTE_COMPONENTS.slice(1).map(function (n) { + return result[n] + }).join('='), '=0;', + '}else{', + CUTE_COMPONENTS.map(function (name, i) { + return ( + result[name] + '=' + VALUE + '.constant.length>' + i + + '?' + VALUE + '.constant[' + i + ']:0;' + ) + }).join(''), + '}}else{', + 'if(', IS_BUFFER_ARGS, '(', VALUE, '.buffer)){', + BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$2, ',', VALUE, '.buffer);', + '}else{', + BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, '.buffer);', + '}', + TYPE, '="type" in ', VALUE, '?', + constants.glTypes, '[', VALUE, '.type]:', BUFFER, '.dtype;', + result.normalized, '=!!', VALUE, '.normalized;') + function emitReadRecord (name) { + block(result[name], '=', VALUE, '.', name, '|0;') + } + emitReadRecord('size') + emitReadRecord('offset') + emitReadRecord('stride') + emitReadRecord('divisor') - return (lum2 + 0.05) / (lum1 + 0.05); - }, + block('}}') - level: function (color2) { - var contrastRatio = this.contrast(color2); - if (contrastRatio >= 7.1) { - return 'AAA'; - } + block.exit( + 'if(', result.isStream, '){', + BUFFER_STATE, '.destroyStream(', BUFFER, ');', + '}') - return (contrastRatio >= 4.5) ? 'AA' : ''; - }, + return result + } - dark: function () { - // YIQ equation from http://24ways.org/2010/calculating-color-contrast - var rgb = this.rgb().color; - var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000; - return yiq < 128; - }, + attributeDefs[attribute] = createDynamicDecl(dyn, appendAttributeCode) + }) - light: function () { - return !this.dark(); - }, + return attributeDefs + } - negate: function () { - var rgb = this.rgb(); - for (var i = 0; i < 3; i++) { - rgb.color[i] = 255 - rgb.color[i]; - } - return rgb; - }, + function parseVAO (options, env) { + var staticOptions = options.static + var dynamicOptions = options.dynamic + if (S_VAO in staticOptions) { + var vao = staticOptions[S_VAO] + if (vao !== null && attributeState.getVAO(vao) === null) { + vao = attributeState.createVAO(vao) + } + return createStaticDecl(function (env) { + return env.link(attributeState.getVAO(vao)) + }) + } else if (S_VAO in dynamicOptions) { + var dyn = dynamicOptions[S_VAO] + return createDynamicDecl(dyn, function (env, scope) { + var vaoRef = env.invoke(scope, dyn) + return scope.def(env.shared.vao + '.getVAO(' + vaoRef + ')') + }) + } + return null + } - lighten: function (ratio) { - var hsl = this.hsl(); - hsl.color[2] += hsl.color[2] * ratio; - return hsl; - }, + function parseContext (context) { + var staticContext = context.static + var dynamicContext = context.dynamic + var result = {} - darken: function (ratio) { - var hsl = this.hsl(); - hsl.color[2] -= hsl.color[2] * ratio; - return hsl; - }, + Object.keys(staticContext).forEach(function (name) { + var value = staticContext[name] + result[name] = createStaticDecl(function (env, scope) { + if (typeof value === 'number' || typeof value === 'boolean') { + return '' + value + } else { + return env.link(value) + } + }) + }) - saturate: function (ratio) { - var hsl = this.hsl(); - hsl.color[1] += hsl.color[1] * ratio; - return hsl; - }, + Object.keys(dynamicContext).forEach(function (name) { + var dyn = dynamicContext[name] + result[name] = createDynamicDecl(dyn, function (env, scope) { + return env.invoke(scope, dyn) + }) + }) - desaturate: function (ratio) { - var hsl = this.hsl(); - hsl.color[1] -= hsl.color[1] * ratio; - return hsl; - }, + return result + } - whiten: function (ratio) { - var hwb = this.hwb(); - hwb.color[1] += hwb.color[1] * ratio; - return hwb; - }, + function parseArguments (options, attributes, uniforms, context, env) { + var staticOptions = options.static + var dynamicOptions = options.dynamic - blacken: function (ratio) { - var hwb = this.hwb(); - hwb.color[2] += hwb.color[2] * ratio; - return hwb; - }, + check$1.optional(function () { + var KEY_NAMES = [ + S_FRAMEBUFFER, + S_VERT, + S_FRAG, + S_ELEMENTS, + S_PRIMITIVE, + S_OFFSET, + S_COUNT, + S_INSTANCES, + S_PROFILE, + S_VAO + ].concat(GL_STATE_NAMES) - grayscale: function () { - // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale - var rgb = this.rgb().color; - var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11; - return Color.rgb(val, val, val); - }, + function checkKeys (dict) { + Object.keys(dict).forEach(function (key) { + check$1.command( + KEY_NAMES.indexOf(key) >= 0, + 'unknown parameter "' + key + '"', + env.commandStr) + }) + } + + checkKeys(staticOptions) + checkKeys(dynamicOptions) + }) - fade: function (ratio) { - return this.alpha(this.valpha - (this.valpha * ratio)); - }, + var attribLocations = parseAttribLocations(options, attributes) - opaquer: function (ratio) { - return this.alpha(this.valpha + (this.valpha * ratio)); - }, + var framebuffer = parseFramebuffer(options, env) + var viewportAndScissor = parseViewportScissor(options, framebuffer, env) + var draw = parseDraw(options, env) + var state = parseGLState(options, env) + var shader = parseProgram(options, env, attribLocations) - rotate: function (degrees) { - var hsl = this.hsl(); - var hue = hsl.color[0]; - hue = (hue + degrees) % 360; - hue = hue < 0 ? 360 + hue : hue; - hsl.color[0] = hue; - return hsl; - }, + function copyBox (name) { + var defn = viewportAndScissor[name] + if (defn) { + state[name] = defn + } + } + copyBox(S_VIEWPORT) + copyBox(propName(S_SCISSOR_BOX)) - mix: function (mixinColor, weight) { - // ported from sass implementation in C - // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209 - var color1 = mixinColor.rgb(); - var color2 = this.rgb(); - var p = weight === undefined ? 0.5 : weight; + var dirty = Object.keys(state).length > 0 - var w = 2 * p - 1; - var a = color1.alpha() - color2.alpha(); + var result = { + framebuffer: framebuffer, + draw: draw, + shader: shader, + state: state, + dirty: dirty, + scopeVAO: null, + drawVAO: null, + useVAO: false, + attributes: {} + } + + result.profile = parseProfile(options, env) + result.uniforms = parseUniforms(uniforms, env) + result.drawVAO = result.scopeVAO = parseVAO(options, env) + // special case: check if we can statically allocate a vertex array object for this program + if (!result.drawVAO && shader.program && !attribLocations && extensions.angle_instanced_arrays) { + var useVAO = true + var staticBindings = shader.program.attributes.map(function (attr) { + var binding = attributes.static[attr] + useVAO = useVAO && !!binding + return binding + }) + if (useVAO && staticBindings.length > 0) { + var vao = attributeState.getVAO(attributeState.createVAO(staticBindings)) + result.drawVAO = new Declaration(null, null, null, function (env, scope) { + return env.link(vao) + }) + result.useVAO = true + } + } + if (attribLocations) { + result.useVAO = true + } else { + result.attributes = parseAttributes(attributes, env) + } + result.context = parseContext(context, env) + return result + } - var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; - var w2 = 1 - w1; + // =================================================== + // =================================================== + // COMMON UPDATE FUNCTIONS + // =================================================== + // =================================================== + function emitContext (env, scope, context) { + var shared = env.shared + var CONTEXT = shared.context - return Color.rgb( - w1 * color1.red() + w2 * color2.red(), - w1 * color1.green() + w2 * color2.green(), - w1 * color1.blue() + w2 * color2.blue(), - color1.alpha() * p + color2.alpha() * (1 - p)); - } -}; + var contextEnter = env.scope() -// model conversion methods and static constructors -Object.keys(convert).forEach(function (model) { - if (skippedModels.indexOf(model) !== -1) { - return; - } + Object.keys(context).forEach(function (name) { + scope.save(CONTEXT, '.' + name) + var defn = context[name] + var value = defn.append(env, scope) + if (Array.isArray(value)) { + contextEnter(CONTEXT, '.', name, '=[', value.join(), '];') + } else { + contextEnter(CONTEXT, '.', name, '=', value, ';') + } + }) - var channels = convert[model].channels; + scope(contextEnter) + } - // conversion methods - Color.prototype[model] = function () { - if (this.model === model) { - return new Color(this); - } + // =================================================== + // =================================================== + // COMMON DRAWING FUNCTIONS + // =================================================== + // =================================================== + function emitPollFramebuffer (env, scope, framebuffer, skipCheck) { + var shared = env.shared - if (arguments.length) { - return new Color(arguments, model); - } + var GL = shared.gl + var FRAMEBUFFER_STATE = shared.framebuffer + var EXT_DRAW_BUFFERS + if (extDrawBuffers) { + EXT_DRAW_BUFFERS = scope.def(shared.extensions, '.webgl_draw_buffers') + } - var newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha; - return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model); - }; + var constants = env.constants - // 'static' construction methods - Color[model] = function (color) { - if (typeof color === 'number') { - color = zeroArray(_slice.call(arguments), channels); - } - return new Color(color, model); - }; -}); + var DRAW_BUFFERS = constants.drawBuffer + var BACK_BUFFER = constants.backBuffer -function roundTo(num, places) { - return Number(num.toFixed(places)); -} + var NEXT + if (framebuffer) { + NEXT = framebuffer.append(env, scope) + } else { + NEXT = scope.def(FRAMEBUFFER_STATE, '.next') + } -function roundToPlace(places) { - return function (num) { - return roundTo(num, places); - }; -} + if (!skipCheck) { + scope('if(', NEXT, '!==', FRAMEBUFFER_STATE, '.cur){') + } + scope( + 'if(', NEXT, '){', + GL, '.bindFramebuffer(', GL_FRAMEBUFFER$2, ',', NEXT, '.framebuffer);') + if (extDrawBuffers) { + scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', + DRAW_BUFFERS, '[', NEXT, '.colorAttachments.length]);') + } + scope('}else{', + GL, '.bindFramebuffer(', GL_FRAMEBUFFER$2, ',null);') + if (extDrawBuffers) { + scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', BACK_BUFFER, ');') + } + scope( + '}', + FRAMEBUFFER_STATE, '.cur=', NEXT, ';') + if (!skipCheck) { + scope('}') + } + } -function getset(model, channel, modifier) { - model = Array.isArray(model) ? model : [model]; + function emitPollState (env, scope, args) { + var shared = env.shared - model.forEach(function (m) { - (limiters[m] || (limiters[m] = []))[channel] = modifier; - }); + var GL = shared.gl - model = model[0]; + var CURRENT_VARS = env.current + var NEXT_VARS = env.next + var CURRENT_STATE = shared.current + var NEXT_STATE = shared.next - return function (val) { - var result; + var block = env.cond(CURRENT_STATE, '.dirty') - if (arguments.length) { - if (modifier) { - val = modifier(val); - } + GL_STATE_NAMES.forEach(function (prop) { + var param = propName(prop) + if (param in args.state) { + return + } - result = this[model](); - result.color[channel] = val; - return result; - } + var NEXT, CURRENT + if (param in NEXT_VARS) { + NEXT = NEXT_VARS[param] + CURRENT = CURRENT_VARS[param] + var parts = loop(currentState[param].length, function (i) { + return block.def(NEXT, '[', i, ']') + }) + block(env.cond(parts.map(function (p, i) { + return p + '!==' + CURRENT + '[' + i + ']' + }).join('||')) + .then( + GL, '.', GL_VARIABLES[param], '(', parts, ');', + parts.map(function (p, i) { + return CURRENT + '[' + i + ']=' + p + }).join(';'), ';')) + } else { + NEXT = block.def(NEXT_STATE, '.', param) + var ifte = env.cond(NEXT, '!==', CURRENT_STATE, '.', param) + block(ifte) + if (param in GL_FLAGS) { + ifte( + env.cond(NEXT) + .then(GL, '.enable(', GL_FLAGS[param], ');') + .else(GL, '.disable(', GL_FLAGS[param], ');'), + CURRENT_STATE, '.', param, '=', NEXT, ';') + } else { + ifte( + GL, '.', GL_VARIABLES[param], '(', NEXT, ');', + CURRENT_STATE, '.', param, '=', NEXT, ';') + } + } + }) + if (Object.keys(args.state).length === 0) { + block(CURRENT_STATE, '.dirty=false;') + } + scope(block) + } - result = this[model]().color[channel]; - if (modifier) { - result = modifier(result); - } + function emitSetOptions (env, scope, options, filter) { + var shared = env.shared + var CURRENT_VARS = env.current + var CURRENT_STATE = shared.current + var GL = shared.gl + sortState(Object.keys(options)).forEach(function (param) { + var defn = options[param] + if (filter && !filter(defn)) { + return + } + var variable = defn.append(env, scope) + if (GL_FLAGS[param]) { + var flag = GL_FLAGS[param] + if (isStatic(defn)) { + if (variable) { + scope(GL, '.enable(', flag, ');') + } else { + scope(GL, '.disable(', flag, ');') + } + } else { + scope(env.cond(variable) + .then(GL, '.enable(', flag, ');') + .else(GL, '.disable(', flag, ');')) + } + scope(CURRENT_STATE, '.', param, '=', variable, ';') + } else if (isArrayLike(variable)) { + var CURRENT = CURRENT_VARS[param] + scope( + GL, '.', GL_VARIABLES[param], '(', variable, ');', + variable.map(function (v, i) { + return CURRENT + '[' + i + ']=' + v + }).join(';'), ';') + } else { + scope( + GL, '.', GL_VARIABLES[param], '(', variable, ');', + CURRENT_STATE, '.', param, '=', variable, ';') + } + }) + } - return result; - }; -} + function injectExtensions (env, scope) { + if (extInstancing) { + env.instancing = scope.def( + env.shared.extensions, '.angle_instanced_arrays') + } + } -function maxfn(max) { - return function (v) { - return Math.max(0, Math.min(max, v)); - }; -} + function emitProfile (env, scope, args, useScope, incrementCounter) { + var shared = env.shared + var STATS = env.stats + var CURRENT_STATE = shared.current + var TIMER = shared.timer + var profileArg = args.profile -function assertArray(val) { - return Array.isArray(val) ? val : [val]; -} + function perfCounter () { + if (typeof performance === 'undefined') { + return 'Date.now()' + } else { + return 'performance.now()' + } + } -function zeroArray(arr, length) { - for (var i = 0; i < length; i++) { - if (typeof arr[i] !== 'number') { - arr[i] = 0; - } - } + var CPU_START, QUERY_COUNTER + function emitProfileStart (block) { + CPU_START = scope.def() + block(CPU_START, '=', perfCounter(), ';') + if (typeof incrementCounter === 'string') { + block(STATS, '.count+=', incrementCounter, ';') + } else { + block(STATS, '.count++;') + } + if (timer) { + if (useScope) { + QUERY_COUNTER = scope.def() + block(QUERY_COUNTER, '=', TIMER, '.getNumPendingQueries();') + } else { + block(TIMER, '.beginQuery(', STATS, ');') + } + } + } - return arr; -} + function emitProfileEnd (block) { + block(STATS, '.cpuTime+=', perfCounter(), '-', CPU_START, ';') + if (timer) { + if (useScope) { + block(TIMER, '.pushScopeStats(', + QUERY_COUNTER, ',', + TIMER, '.getNumPendingQueries(),', + STATS, ');') + } else { + block(TIMER, '.endQuery();') + } + } + } + + function scopeProfile (value) { + var prev = scope.def(CURRENT_STATE, '.profile') + scope(CURRENT_STATE, '.profile=', value, ';') + scope.exit(CURRENT_STATE, '.profile=', prev, ';') + } + + var USE_PROFILE + if (profileArg) { + if (isStatic(profileArg)) { + if (profileArg.enable) { + emitProfileStart(scope) + emitProfileEnd(scope.exit) + scopeProfile('true') + } else { + scopeProfile('false') + } + return + } + USE_PROFILE = profileArg.append(env, scope) + scopeProfile(USE_PROFILE) + } else { + USE_PROFILE = scope.def(CURRENT_STATE, '.profile') + } -module.exports = Color; + var start = env.block() + emitProfileStart(start) + scope('if(', USE_PROFILE, '){', start, '}') + var end = env.block() + emitProfileEnd(end) + scope.exit('if(', USE_PROFILE, '){', end, '}') + } + function emitAttributes (env, scope, args, attributes, filter) { + var shared = env.shared -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { + function typeLength (x) { + switch (x) { + case GL_FLOAT_VEC2: + case GL_INT_VEC2: + case GL_BOOL_VEC2: + return 2 + case GL_FLOAT_VEC3: + case GL_INT_VEC3: + case GL_BOOL_VEC3: + return 3 + case GL_FLOAT_VEC4: + case GL_INT_VEC4: + case GL_BOOL_VEC4: + return 4 + default: + return 1 + } + } -/* MIT license */ -var colorNames = __webpack_require__(6); -var swizzle = __webpack_require__(31); + function emitBindAttribute (ATTRIBUTE, size, record) { + var GL = shared.gl -var reverseNames = {}; + var LOCATION = scope.def(ATTRIBUTE, '.location') + var BINDING = scope.def(shared.attributes, '[', LOCATION, ']') -// create a list of reverse color names -for (var name in colorNames) { - if (colorNames.hasOwnProperty(name)) { - reverseNames[colorNames[name]] = name; - } -} + var STATE = record.state + var BUFFER = record.buffer + var CONST_COMPONENTS = [ + record.x, + record.y, + record.z, + record.w + ] -var cs = module.exports = { - to: {} -}; + var COMMON_KEYS = [ + 'buffer', + 'normalized', + 'offset', + 'stride' + ] -cs.get = function (string) { - var prefix = string.substring(0, 3).toLowerCase(); - var val; - var model; - switch (prefix) { - case 'hsl': - val = cs.get.hsl(string); - model = 'hsl'; - break; - case 'hwb': - val = cs.get.hwb(string); - model = 'hwb'; - break; - default: - val = cs.get.rgb(string); - model = 'rgb'; - break; - } + function emitBuffer () { + scope( + 'if(!', BINDING, '.buffer){', + GL, '.enableVertexAttribArray(', LOCATION, ');}') - if (!val) { - return null; - } + var TYPE = record.type + var SIZE + if (!record.size) { + SIZE = size + } else { + SIZE = scope.def(record.size, '||', size) + } - return {model: model, value: val}; -}; + scope('if(', + BINDING, '.type!==', TYPE, '||', + BINDING, '.size!==', SIZE, '||', + COMMON_KEYS.map(function (key) { + return BINDING + '.' + key + '!==' + record[key] + }).join('||'), + '){', + GL, '.bindBuffer(', GL_ARRAY_BUFFER$2, ',', BUFFER, '.buffer);', + GL, '.vertexAttribPointer(', [ + LOCATION, + SIZE, + TYPE, + record.normalized, + record.stride, + record.offset + ], ');', + BINDING, '.type=', TYPE, ';', + BINDING, '.size=', SIZE, ';', + COMMON_KEYS.map(function (key) { + return BINDING + '.' + key + '=' + record[key] + ';' + }).join(''), + '}') -cs.get.rgb = function (string) { - if (!string) { - return null; - } + if (extInstancing) { + var DIVISOR = record.divisor + scope( + 'if(', BINDING, '.divisor!==', DIVISOR, '){', + env.instancing, '.vertexAttribDivisorANGLE(', [LOCATION, DIVISOR], ');', + BINDING, '.divisor=', DIVISOR, ';}') + } + } - var abbr = /^#([a-f0-9]{3,4})$/i; - var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i; - var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; - var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; - var keyword = /(\D+)/; + function emitConstant () { + scope( + 'if(', BINDING, '.buffer){', + GL, '.disableVertexAttribArray(', LOCATION, ');', + BINDING, '.buffer=null;', + '}if(', CUTE_COMPONENTS.map(function (c, i) { + return BINDING + '.' + c + '!==' + CONST_COMPONENTS[i] + }).join('||'), '){', + GL, '.vertexAttrib4f(', LOCATION, ',', CONST_COMPONENTS, ');', + CUTE_COMPONENTS.map(function (c, i) { + return BINDING + '.' + c + '=' + CONST_COMPONENTS[i] + ';' + }).join(''), + '}') + } - var rgb = [0, 0, 0, 1]; - var match; - var i; - var hexAlpha; + if (STATE === ATTRIB_STATE_POINTER) { + emitBuffer() + } else if (STATE === ATTRIB_STATE_CONSTANT) { + emitConstant() + } else { + scope('if(', STATE, '===', ATTRIB_STATE_POINTER, '){') + emitBuffer() + scope('}else{') + emitConstant() + scope('}') + } + } - if (match = string.match(hex)) { - hexAlpha = match[2]; - match = match[1]; + attributes.forEach(function (attribute) { + var name = attribute.name + var arg = args.attributes[name] + var record + if (arg) { + if (!filter(arg)) { + return + } + record = arg.append(env, scope) + } else { + if (!filter(SCOPE_DECL)) { + return + } + var scopeAttrib = env.scopeAttrib(name) + check$1.optional(function () { + env.assert(scope, + scopeAttrib + '.state', + 'missing attribute ' + name) + }) + record = {} + Object.keys(new AttributeRecord()).forEach(function (key) { + record[key] = scope.def(scopeAttrib, '.', key) + }) + } + emitBindAttribute( + env.link(attribute), typeLength(attribute.info.type), record) + }) + } - for (i = 0; i < 3; i++) { - // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19 - var i2 = i * 2; - rgb[i] = parseInt(match.slice(i2, i2 + 2), 16); - } + function emitUniforms (env, scope, args, uniforms, filter) { + var shared = env.shared + var GL = shared.gl - if (hexAlpha) { - rgb[3] = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100; - } - } else if (match = string.match(abbr)) { - match = match[1]; - hexAlpha = match[3]; + var infix + for (var i = 0; i < uniforms.length; ++i) { + var uniform = uniforms[i] + var name = uniform.name + var type = uniform.info.type + var arg = args.uniforms[name] + var UNIFORM = env.link(uniform) + var LOCATION = UNIFORM + '.location' + + var VALUE + if (arg) { + if (!filter(arg)) { + continue + } + if (isStatic(arg)) { + var value = arg.value + check$1.command( + value !== null && typeof value !== 'undefined', + 'missing uniform "' + name + '"', env.commandStr) + if (type === GL_SAMPLER_2D || type === GL_SAMPLER_CUBE) { + check$1.command( + typeof value === 'function' && + ((type === GL_SAMPLER_2D && + (value._reglType === 'texture2d' || + value._reglType === 'framebuffer')) || + (type === GL_SAMPLER_CUBE && + (value._reglType === 'textureCube' || + value._reglType === 'framebufferCube'))), + 'invalid texture for uniform ' + name, env.commandStr) + var TEX_VALUE = env.link(value._texture || value.color[0]._texture) + scope(GL, '.uniform1i(', LOCATION, ',', TEX_VALUE + '.bind());') + scope.exit(TEX_VALUE, '.unbind();') + } else if ( + type === GL_FLOAT_MAT2 || + type === GL_FLOAT_MAT3 || + type === GL_FLOAT_MAT4) { + check$1.optional(function () { + check$1.command(isArrayLike(value), + 'invalid matrix for uniform ' + name, env.commandStr) + check$1.command( + (type === GL_FLOAT_MAT2 && value.length === 4) || + (type === GL_FLOAT_MAT3 && value.length === 9) || + (type === GL_FLOAT_MAT4 && value.length === 16), + 'invalid length for matrix uniform ' + name, env.commandStr) + }) + var MAT_VALUE = env.global.def('new Float32Array([' + + Array.prototype.slice.call(value) + '])') + var dim = 2 + if (type === GL_FLOAT_MAT3) { + dim = 3 + } else if (type === GL_FLOAT_MAT4) { + dim = 4 + } + scope( + GL, '.uniformMatrix', dim, 'fv(', + LOCATION, ',false,', MAT_VALUE, ');') + } else { + switch (type) { + case GL_FLOAT$8: + check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr) + infix = '1f' + break + case GL_FLOAT_VEC2: + check$1.command( + isArrayLike(value) && value.length === 2, + 'uniform ' + name, env.commandStr) + infix = '2f' + break + case GL_FLOAT_VEC3: + check$1.command( + isArrayLike(value) && value.length === 3, + 'uniform ' + name, env.commandStr) + infix = '3f' + break + case GL_FLOAT_VEC4: + check$1.command( + isArrayLike(value) && value.length === 4, + 'uniform ' + name, env.commandStr) + infix = '4f' + break + case GL_BOOL: + check$1.commandType(value, 'boolean', 'uniform ' + name, env.commandStr) + infix = '1i' + break + case GL_INT$3: + check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr) + infix = '1i' + break + case GL_BOOL_VEC2: + check$1.command( + isArrayLike(value) && value.length === 2, + 'uniform ' + name, env.commandStr) + infix = '2i' + break + case GL_INT_VEC2: + check$1.command( + isArrayLike(value) && value.length === 2, + 'uniform ' + name, env.commandStr) + infix = '2i' + break + case GL_BOOL_VEC3: + check$1.command( + isArrayLike(value) && value.length === 3, + 'uniform ' + name, env.commandStr) + infix = '3i' + break + case GL_INT_VEC3: + check$1.command( + isArrayLike(value) && value.length === 3, + 'uniform ' + name, env.commandStr) + infix = '3i' + break + case GL_BOOL_VEC4: + check$1.command( + isArrayLike(value) && value.length === 4, + 'uniform ' + name, env.commandStr) + infix = '4i' + break + case GL_INT_VEC4: + check$1.command( + isArrayLike(value) && value.length === 4, + 'uniform ' + name, env.commandStr) + infix = '4i' + break + } + scope(GL, '.uniform', infix, '(', LOCATION, ',', + isArrayLike(value) ? Array.prototype.slice.call(value) : value, + ');') + } + continue + } else { + VALUE = arg.append(env, scope) + } + } else { + if (!filter(SCOPE_DECL)) { + continue + } + VALUE = scope.def(shared.uniforms, '[', stringStore.id(name), ']') + } - for (i = 0; i < 3; i++) { - rgb[i] = parseInt(match[i] + match[i], 16); - } + if (type === GL_SAMPLER_2D) { + check$1(!Array.isArray(VALUE), 'must specify a scalar prop for textures') + scope( + 'if(', VALUE, '&&', VALUE, '._reglType==="framebuffer"){', + VALUE, '=', VALUE, '.color[0];', + '}') + } else if (type === GL_SAMPLER_CUBE) { + check$1(!Array.isArray(VALUE), 'must specify a scalar prop for cube maps') + scope( + 'if(', VALUE, '&&', VALUE, '._reglType==="framebufferCube"){', + VALUE, '=', VALUE, '.color[0];', + '}') + } - if (hexAlpha) { - rgb[3] = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100; - } - } else if (match = string.match(rgba)) { - for (i = 0; i < 3; i++) { - rgb[i] = parseInt(match[i + 1], 0); - } + // perform type validation + check$1.optional(function () { + function emitCheck (pred, message) { + env.assert(scope, pred, + 'bad data or missing for uniform "' + name + '". ' + message) + } - if (match[4]) { - rgb[3] = parseFloat(match[4]); - } - } else if (match = string.match(per)) { - for (i = 0; i < 3; i++) { - rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55); - } + function checkType (type) { + check$1(!Array.isArray(VALUE), 'must not specify an array type for uniform') + emitCheck( + 'typeof ' + VALUE + '==="' + type + '"', + 'invalid type, expected ' + type) + } - if (match[4]) { - rgb[3] = parseFloat(match[4]); - } - } else if (match = string.match(keyword)) { - if (match[1] === 'transparent') { - return [0, 0, 0, 0]; - } + function checkVector (n, type) { + if (Array.isArray(VALUE)) { + check$1(VALUE.length === n, 'must have length ' + n) + } else { + emitCheck( + shared.isArrayLike + '(' + VALUE + ')&&' + VALUE + '.length===' + n, + 'invalid vector, should have length ' + n, env.commandStr) + } + } - rgb = colorNames[match[1]]; + function checkTexture (target) { + check$1(!Array.isArray(VALUE), 'must not specify a value type') + emitCheck( + 'typeof ' + VALUE + '==="function"&&' + + VALUE + '._reglType==="texture' + + (target === GL_TEXTURE_2D$3 ? '2d' : 'Cube') + '"', + 'invalid texture type', env.commandStr) + } - if (!rgb) { - return null; - } + switch (type) { + case GL_INT$3: + checkType('number') + break + case GL_INT_VEC2: + checkVector(2, 'number') + break + case GL_INT_VEC3: + checkVector(3, 'number') + break + case GL_INT_VEC4: + checkVector(4, 'number') + break + case GL_FLOAT$8: + checkType('number') + break + case GL_FLOAT_VEC2: + checkVector(2, 'number') + break + case GL_FLOAT_VEC3: + checkVector(3, 'number') + break + case GL_FLOAT_VEC4: + checkVector(4, 'number') + break + case GL_BOOL: + checkType('boolean') + break + case GL_BOOL_VEC2: + checkVector(2, 'boolean') + break + case GL_BOOL_VEC3: + checkVector(3, 'boolean') + break + case GL_BOOL_VEC4: + checkVector(4, 'boolean') + break + case GL_FLOAT_MAT2: + checkVector(4, 'number') + break + case GL_FLOAT_MAT3: + checkVector(9, 'number') + break + case GL_FLOAT_MAT4: + checkVector(16, 'number') + break + case GL_SAMPLER_2D: + checkTexture(GL_TEXTURE_2D$3) + break + case GL_SAMPLER_CUBE: + checkTexture(GL_TEXTURE_CUBE_MAP$2) + break + } + }) - rgb[3] = 1; + var unroll = 1 + switch (type) { + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + var TEX = scope.def(VALUE, '._texture') + scope(GL, '.uniform1i(', LOCATION, ',', TEX, '.bind());') + scope.exit(TEX, '.unbind();') + continue - return rgb; - } else { - return null; - } + case GL_INT$3: + case GL_BOOL: + infix = '1i' + break - for (i = 0; i < 3; i++) { - rgb[i] = clamp(rgb[i], 0, 255); - } - rgb[3] = clamp(rgb[3], 0, 1); + case GL_INT_VEC2: + case GL_BOOL_VEC2: + infix = '2i' + unroll = 2 + break - return rgb; -}; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + infix = '3i' + unroll = 3 + break -cs.get.hsl = function (string) { - if (!string) { - return null; - } + case GL_INT_VEC4: + case GL_BOOL_VEC4: + infix = '4i' + unroll = 4 + break - var hsl = /^hsla?\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; - var match = string.match(hsl); + case GL_FLOAT$8: + infix = '1f' + break - if (match) { - var alpha = parseFloat(match[4]); - var h = ((parseFloat(match[1]) % 360) + 360) % 360; - var s = clamp(parseFloat(match[2]), 0, 100); - var l = clamp(parseFloat(match[3]), 0, 100); - var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1); + case GL_FLOAT_VEC2: + infix = '2f' + unroll = 2 + break - return [h, s, l, a]; - } + case GL_FLOAT_VEC3: + infix = '3f' + unroll = 3 + break - return null; -}; + case GL_FLOAT_VEC4: + infix = '4f' + unroll = 4 + break -cs.get.hwb = function (string) { - if (!string) { - return null; - } + case GL_FLOAT_MAT2: + infix = 'Matrix2fv' + break - var hwb = /^hwb\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; - var match = string.match(hwb); + case GL_FLOAT_MAT3: + infix = 'Matrix3fv' + break - if (match) { - var alpha = parseFloat(match[4]); - var h = ((parseFloat(match[1]) % 360) + 360) % 360; - var w = clamp(parseFloat(match[2]), 0, 100); - var b = clamp(parseFloat(match[3]), 0, 100); - var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1); - return [h, w, b, a]; - } + case GL_FLOAT_MAT4: + infix = 'Matrix4fv' + break + } - return null; -}; + scope(GL, '.uniform', infix, '(', LOCATION, ',') + if (infix.charAt(0) === 'M') { + var matSize = Math.pow(type - GL_FLOAT_MAT2 + 2, 2) + var STORAGE = env.global.def('new Float32Array(', matSize, ')') + if (Array.isArray(VALUE)) { + scope( + 'false,(', + loop(matSize, function (i) { + return STORAGE + '[' + i + ']=' + VALUE[i] + }), ',', STORAGE, ')') + } else { + scope( + 'false,(Array.isArray(', VALUE, ')||', VALUE, ' instanceof Float32Array)?', VALUE, ':(', + loop(matSize, function (i) { + return STORAGE + '[' + i + ']=' + VALUE + '[' + i + ']' + }), ',', STORAGE, ')') + } + } else if (unroll > 1) { + scope(loop(unroll, function (i) { + return Array.isArray(VALUE) ? VALUE[i] : VALUE + '[' + i + ']' + })) + } else { + check$1(!Array.isArray(VALUE), 'uniform value must not be an array') + scope(VALUE) + } + scope(');') + } + } -cs.to.hex = function () { - var rgba = swizzle(arguments); + function emitDraw (env, outer, inner, args) { + var shared = env.shared + var GL = shared.gl + var DRAW_STATE = shared.draw - return ( - '#' + - hexDouble(rgba[0]) + - hexDouble(rgba[1]) + - hexDouble(rgba[2]) + - (rgba[3] < 1 - ? (hexDouble(Math.round(rgba[3] * 255))) - : '') - ); -}; + var drawOptions = args.draw -cs.to.rgb = function () { - var rgba = swizzle(arguments); + function emitElements () { + var defn = drawOptions.elements + var ELEMENTS + var scope = outer + if (defn) { + if ((defn.contextDep && args.contextDynamic) || defn.propDep) { + scope = inner + } + ELEMENTS = defn.append(env, scope) + } else { + ELEMENTS = scope.def(DRAW_STATE, '.', S_ELEMENTS) + } + if (ELEMENTS) { + scope( + 'if(' + ELEMENTS + ')' + + GL + '.bindBuffer(' + GL_ELEMENT_ARRAY_BUFFER$1 + ',' + ELEMENTS + '.buffer.buffer);') + } + return ELEMENTS + } - return rgba.length < 4 || rgba[3] === 1 - ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')' - : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')'; -}; + function emitCount () { + var defn = drawOptions.count + var COUNT + var scope = outer + if (defn) { + if ((defn.contextDep && args.contextDynamic) || defn.propDep) { + scope = inner + } + COUNT = defn.append(env, scope) + check$1.optional(function () { + if (defn.MISSING) { + env.assert(outer, 'false', 'missing vertex count') + } + if (defn.DYNAMIC) { + env.assert(scope, COUNT + '>=0', 'missing vertex count') + } + }) + } else { + COUNT = scope.def(DRAW_STATE, '.', S_COUNT) + check$1.optional(function () { + env.assert(scope, COUNT + '>=0', 'missing vertex count') + }) + } + return COUNT + } -cs.to.rgb.percent = function () { - var rgba = swizzle(arguments); + var ELEMENTS = emitElements() + function emitValue (name) { + var defn = drawOptions[name] + if (defn) { + if ((defn.contextDep && args.contextDynamic) || defn.propDep) { + return defn.append(env, inner) + } else { + return defn.append(env, outer) + } + } else { + return outer.def(DRAW_STATE, '.', name) + } + } - var r = Math.round(rgba[0] / 255 * 100); - var g = Math.round(rgba[1] / 255 * 100); - var b = Math.round(rgba[2] / 255 * 100); + var PRIMITIVE = emitValue(S_PRIMITIVE) + var OFFSET = emitValue(S_OFFSET) - return rgba.length < 4 || rgba[3] === 1 - ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)' - : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')'; -}; + var COUNT = emitCount() + if (typeof COUNT === 'number') { + if (COUNT === 0) { + return + } + } else { + inner('if(', COUNT, '){') + inner.exit('}') + } -cs.to.hsl = function () { - var hsla = swizzle(arguments); - return hsla.length < 4 || hsla[3] === 1 - ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)' - : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')'; -}; + var INSTANCES, EXT_INSTANCING + if (extInstancing) { + INSTANCES = emitValue(S_INSTANCES) + EXT_INSTANCING = env.instancing + } -// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax -// (hwb have alpha optional & 1 is default value) -cs.to.hwb = function () { - var hwba = swizzle(arguments); + var ELEMENT_TYPE = ELEMENTS + '.type' - var a = ''; - if (hwba.length >= 4 && hwba[3] !== 1) { - a = ', ' + hwba[3]; - } + var elementsStatic = drawOptions.elements && isStatic(drawOptions.elements) - return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')'; -}; + function emitInstancing () { + function drawElements () { + inner(EXT_INSTANCING, '.drawElementsInstancedANGLE(', [ + PRIMITIVE, + COUNT, + ELEMENT_TYPE, + OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$8 + ')>>1)', + INSTANCES + ], ');') + } -cs.to.keyword = function (rgb) { - return reverseNames[rgb.slice(0, 3)]; -}; + function drawArrays () { + inner(EXT_INSTANCING, '.drawArraysInstancedANGLE(', + [PRIMITIVE, OFFSET, COUNT, INSTANCES], ');') + } -// helpers -function clamp(num, min, max) { - return Math.min(Math.max(min, num), max); -} + if (ELEMENTS) { + if (!elementsStatic) { + inner('if(', ELEMENTS, '){') + drawElements() + inner('}else{') + drawArrays() + inner('}') + } else { + drawElements() + } + } else { + drawArrays() + } + } -function hexDouble(num) { - var str = num.toString(16).toUpperCase(); - return (str.length < 2) ? '0' + str : str; -} + function emitRegular () { + function drawElements () { + inner(GL + '.drawElements(' + [ + PRIMITIVE, + COUNT, + ELEMENT_TYPE, + OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$8 + ')>>1)' + ] + ');') + } + function drawArrays () { + inner(GL + '.drawArrays(' + [PRIMITIVE, OFFSET, COUNT] + ');') + } -/***/ }), -/* 31 */ -/***/ (function(module, exports, __webpack_require__) { + if (ELEMENTS) { + if (!elementsStatic) { + inner('if(', ELEMENTS, '){') + drawElements() + inner('}else{') + drawArrays() + inner('}') + } else { + drawElements() + } + } else { + drawArrays() + } + } -"use strict"; + if (extInstancing && (typeof INSTANCES !== 'number' || INSTANCES >= 0)) { + if (typeof INSTANCES === 'string') { + inner('if(', INSTANCES, '>0){') + emitInstancing() + inner('}else if(', INSTANCES, '<0){') + emitRegular() + inner('}') + } else { + emitInstancing() + } + } else { + emitRegular() + } + } + function createBody (emitBody, parentEnv, args, program, count) { + var env = createREGLEnvironment() + var scope = env.proc('body', count) + check$1.optional(function () { + env.commandStr = parentEnv.commandStr + env.command = env.link(parentEnv.commandStr) + }) + if (extInstancing) { + env.instancing = scope.def( + env.shared.extensions, '.angle_instanced_arrays') + } + emitBody(env, scope, args, program) + return env.compile().body + } -var isArrayish = __webpack_require__(32); + // =================================================== + // =================================================== + // DRAW PROC + // =================================================== + // =================================================== + function emitDrawBody (env, draw, args, program) { + injectExtensions(env, draw) + if (args.useVAO) { + if (args.drawVAO) { + draw(env.shared.vao, '.setVAO(', args.drawVAO.append(env, draw), ');') + } else { + draw(env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);') + } + } else { + draw(env.shared.vao, '.setVAO(null);') + emitAttributes(env, draw, args, program.attributes, function () { + return true + }) + } + emitUniforms(env, draw, args, program.uniforms, function () { + return true + }) + emitDraw(env, draw, draw, args) + } -var concat = Array.prototype.concat; -var slice = Array.prototype.slice; + function emitDrawProc (env, args) { + var draw = env.proc('draw', 1) -var swizzle = module.exports = function swizzle(args) { - var results = []; + injectExtensions(env, draw) - for (var i = 0, len = args.length; i < len; i++) { - var arg = args[i]; + emitContext(env, draw, args.context) + emitPollFramebuffer(env, draw, args.framebuffer) - if (isArrayish(arg)) { - // http://jsperf.com/javascript-array-concat-vs-push/98 - results = concat.call(results, slice.call(arg)); - } else { - results.push(arg); - } - } + emitPollState(env, draw, args) + emitSetOptions(env, draw, args.state) - return results; -}; + emitProfile(env, draw, args, false, true) -swizzle.wrap = function (fn) { - return function () { - return fn(swizzle(arguments)); - }; -}; + var program = args.shader.progVar.append(env, draw) + draw(env.shared.gl, '.useProgram(', program, '.program);') + if (args.shader.program) { + emitDrawBody(env, draw, args, args.shader.program) + } else { + draw(env.shared.vao, '.setVAO(null);') + var drawCache = env.global.def('{}') + var PROG_ID = draw.def(program, '.id') + var CACHED_PROC = draw.def(drawCache, '[', PROG_ID, ']') + draw( + env.cond(CACHED_PROC) + .then(CACHED_PROC, '.call(this,a0);') + .else( + CACHED_PROC, '=', drawCache, '[', PROG_ID, ']=', + env.link(function (program) { + return createBody(emitDrawBody, env, args, program, 1) + }), '(', program, ');', + CACHED_PROC, '.call(this,a0);')) + } -/***/ }), -/* 32 */ -/***/ (function(module, exports, __webpack_require__) { + if (Object.keys(args.state).length > 0) { + draw(env.shared.current, '.dirty=true;') + } + } -"use strict"; + // =================================================== + // =================================================== + // BATCH PROC + // =================================================== + // =================================================== + function emitBatchDynamicShaderBody (env, scope, args, program) { + env.batchId = 'a1' -module.exports = function isArrayish(obj) { - if (!obj || typeof obj === 'string') { - return false; - } + injectExtensions(env, scope) - return obj instanceof Array || Array.isArray(obj) || - (obj.length >= 0 && (obj.splice instanceof Function || - (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String'))); -}; + function all () { + return true + } + emitAttributes(env, scope, args, program.attributes, all) + emitUniforms(env, scope, args, program.uniforms, all) + emitDraw(env, scope, scope, args) + } -/***/ }), -/* 33 */ -/***/ (function(module, exports, __webpack_require__) { + function emitBatchBody (env, scope, args, program) { + injectExtensions(env, scope) -var conversions = __webpack_require__(7); -var route = __webpack_require__(34); + var contextDynamic = args.contextDep -var convert = {}; + var BATCH_ID = scope.def() + var PROP_LIST = 'a0' + var NUM_PROPS = 'a1' + var PROPS = scope.def() + env.shared.props = PROPS + env.batchId = BATCH_ID -var models = Object.keys(conversions); + var outer = env.scope() + var inner = env.scope() -function wrapRaw(fn) { - var wrappedFn = function (args) { - if (args === undefined || args === null) { - return args; - } + scope( + outer.entry, + 'for(', BATCH_ID, '=0;', BATCH_ID, '<', NUM_PROPS, ';++', BATCH_ID, '){', + PROPS, '=', PROP_LIST, '[', BATCH_ID, '];', + inner, + '}', + outer.exit) - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } + function isInnerDefn (defn) { + return ((defn.contextDep && contextDynamic) || defn.propDep) + } - return fn(args); - }; + function isOuterDefn (defn) { + return !isInnerDefn(defn) + } - // preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } + if (args.needsContext) { + emitContext(env, inner, args.context) + } + if (args.needsFramebuffer) { + emitPollFramebuffer(env, inner, args.framebuffer) + } + emitSetOptions(env, inner, args.state, isInnerDefn) - return wrappedFn; -} + if (args.profile && isInnerDefn(args.profile)) { + emitProfile(env, inner, args, false, true) + } -function wrapRounded(fn) { - var wrappedFn = function (args) { - if (args === undefined || args === null) { - return args; - } + if (!program) { + var progCache = env.global.def('{}') + var PROGRAM = args.shader.progVar.append(env, inner) + var PROG_ID = inner.def(PROGRAM, '.id') + var CACHED_PROC = inner.def(progCache, '[', PROG_ID, ']') + inner( + env.shared.gl, '.useProgram(', PROGRAM, '.program);', + 'if(!', CACHED_PROC, '){', + CACHED_PROC, '=', progCache, '[', PROG_ID, ']=', + env.link(function (program) { + return createBody( + emitBatchDynamicShaderBody, env, args, program, 2) + }), '(', PROGRAM, ');}', + CACHED_PROC, '.call(this,a0[', BATCH_ID, '],', BATCH_ID, ');') + } else { + if (args.useVAO) { + if (args.drawVAO) { + if (isInnerDefn(args.drawVAO)) { + // vao is a prop + inner(env.shared.vao, '.setVAO(', args.drawVAO.append(env, inner), ');') + } else { + // vao is invariant + outer(env.shared.vao, '.setVAO(', args.drawVAO.append(env, outer), ');') + } + } else { + // scoped vao binding + outer(env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);') + } + } else { + outer(env.shared.vao, '.setVAO(null);') + emitAttributes(env, outer, args, program.attributes, isOuterDefn) + emitAttributes(env, inner, args, program.attributes, isInnerDefn) + } + emitUniforms(env, outer, args, program.uniforms, isOuterDefn) + emitUniforms(env, inner, args, program.uniforms, isInnerDefn) + emitDraw(env, outer, inner, args) + } + } - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } + function emitBatchProc (env, args) { + var batch = env.proc('batch', 2) + env.batchId = '0' - var result = fn(args); + injectExtensions(env, batch) - // we're assuming the result is an array here. - // see notice in conversions.js; don't use box types - // in conversion functions. - if (typeof result === 'object') { - for (var len = result.length, i = 0; i < len; i++) { - result[i] = Math.round(result[i]); - } - } + // Check if any context variables depend on props + var contextDynamic = false + var needsContext = true + Object.keys(args.context).forEach(function (name) { + contextDynamic = contextDynamic || args.context[name].propDep + }) + if (!contextDynamic) { + emitContext(env, batch, args.context) + needsContext = false + } - return result; - }; + // framebuffer state affects framebufferWidth/height context vars + var framebuffer = args.framebuffer + var needsFramebuffer = false + if (framebuffer) { + if (framebuffer.propDep) { + contextDynamic = needsFramebuffer = true + } else if (framebuffer.contextDep && contextDynamic) { + needsFramebuffer = true + } + if (!needsFramebuffer) { + emitPollFramebuffer(env, batch, framebuffer) + } + } else { + emitPollFramebuffer(env, batch, null) + } - // preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } + // viewport is weird because it can affect context vars + if (args.state.viewport && args.state.viewport.propDep) { + contextDynamic = true + } - return wrappedFn; -} + function isInnerDefn (defn) { + return (defn.contextDep && contextDynamic) || defn.propDep + } -models.forEach(function (fromModel) { - convert[fromModel] = {}; + // set webgl options + emitPollState(env, batch, args) + emitSetOptions(env, batch, args.state, function (defn) { + return !isInnerDefn(defn) + }) - Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); - Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); + if (!args.profile || !isInnerDefn(args.profile)) { + emitProfile(env, batch, args, false, 'a1') + } - var routes = route(fromModel); - var routeModels = Object.keys(routes); + // Save these values to args so that the batch body routine can use them + args.contextDep = contextDynamic + args.needsContext = needsContext + args.needsFramebuffer = needsFramebuffer - routeModels.forEach(function (toModel) { - var fn = routes[toModel]; + // determine if shader is dynamic + var progDefn = args.shader.progVar + if ((progDefn.contextDep && contextDynamic) || progDefn.propDep) { + emitBatchBody( + env, + batch, + args, + null) + } else { + var PROGRAM = progDefn.append(env, batch) + batch(env.shared.gl, '.useProgram(', PROGRAM, '.program);') + if (args.shader.program) { + emitBatchBody( + env, + batch, + args, + args.shader.program) + } else { + batch(env.shared.vao, '.setVAO(null);') + var batchCache = env.global.def('{}') + var PROG_ID = batch.def(PROGRAM, '.id') + var CACHED_PROC = batch.def(batchCache, '[', PROG_ID, ']') + batch( + env.cond(CACHED_PROC) + .then(CACHED_PROC, '.call(this,a0,a1);') + .else( + CACHED_PROC, '=', batchCache, '[', PROG_ID, ']=', + env.link(function (program) { + return createBody(emitBatchBody, env, args, program, 2) + }), '(', PROGRAM, ');', + CACHED_PROC, '.call(this,a0,a1);')) + } + } - convert[fromModel][toModel] = wrapRounded(fn); - convert[fromModel][toModel].raw = wrapRaw(fn); - }); -}); + if (Object.keys(args.state).length > 0) { + batch(env.shared.current, '.dirty=true;') + } + } -module.exports = convert; + // =================================================== + // =================================================== + // SCOPE COMMAND + // =================================================== + // =================================================== + function emitScopeProc (env, args) { + var scope = env.proc('scope', 3) + env.batchId = 'a2' + var shared = env.shared + var CURRENT_STATE = shared.current -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { + emitContext(env, scope, args.context) -var conversions = __webpack_require__(7); + if (args.framebuffer) { + args.framebuffer.append(env, scope) + } -/* - this function routes a model to all other models. + sortState(Object.keys(args.state)).forEach(function (name) { + var defn = args.state[name] + var value = defn.append(env, scope) + if (isArrayLike(value)) { + value.forEach(function (v, i) { + scope.set(env.next[name], '[' + i + ']', v) + }) + } else { + scope.set(shared.next, '.' + name, value) + } + }) - all functions that are routed have a property `.conversion` attached - to the returned synthetic function. This property is an array - of strings, each with the steps in between the 'from' and 'to' - color models (inclusive). + emitProfile(env, scope, args, true, true) - conversions that are not possible simply are not included. -*/ + ;[S_ELEMENTS, S_OFFSET, S_COUNT, S_INSTANCES, S_PRIMITIVE].forEach( + function (opt) { + var variable = args.draw[opt] + if (!variable) { + return + } + scope.set(shared.draw, '.' + opt, '' + variable.append(env, scope)) + }) -// https://jsperf.com/object-keys-vs-for-in-with-closure/3 -var models = Object.keys(conversions); + Object.keys(args.uniforms).forEach(function (opt) { + var value = args.uniforms[opt].append(env, scope) + if (Array.isArray(value)) { + value = '[' + value.join() + ']' + } + scope.set( + shared.uniforms, + '[' + stringStore.id(opt) + ']', + value) + }) -function buildGraph() { - var graph = {}; + Object.keys(args.attributes).forEach(function (name) { + var record = args.attributes[name].append(env, scope) + var scopeAttrib = env.scopeAttrib(name) + Object.keys(new AttributeRecord()).forEach(function (prop) { + scope.set(scopeAttrib, '.' + prop, record[prop]) + }) + }) - for (var len = models.length, i = 0; i < len; i++) { - graph[models[i]] = { - // http://jsperf.com/1-vs-infinity - // micro-opt, but this is simple. - distance: -1, - parent: null - }; - } + if (args.scopeVAO) { + scope.set(shared.vao, '.targetVAO', args.scopeVAO.append(env, scope)) + } - return graph; -} + function saveShader (name) { + var shader = args.shader[name] + if (shader) { + scope.set(shared.shader, '.' + name, shader.append(env, scope)) + } + } + saveShader(S_VERT) + saveShader(S_FRAG) -// https://en.wikipedia.org/wiki/Breadth-first_search -function deriveBFS(fromModel) { - var graph = buildGraph(); - var queue = [fromModel]; // unshift -> queue -> pop + if (Object.keys(args.state).length > 0) { + scope(CURRENT_STATE, '.dirty=true;') + scope.exit(CURRENT_STATE, '.dirty=true;') + } - graph[fromModel].distance = 0; + scope('a1(', env.shared.context, ',a0,', env.batchId, ');') + } - while (queue.length) { - var current = queue.pop(); - var adjacents = Object.keys(conversions[current]); + function isDynamicObject (object) { + if (typeof object !== 'object' || isArrayLike(object)) { + return + } + var props = Object.keys(object) + for (var i = 0; i < props.length; ++i) { + if (dynamic.isDynamic(object[props[i]])) { + return true + } + } + return false + } - for (var len = adjacents.length, i = 0; i < len; i++) { - var adjacent = adjacents[i]; - var node = graph[adjacent]; + function splatObject (env, options, name) { + var object = options.static[name] + if (!object || !isDynamicObject(object)) { + return + } - if (node.distance === -1) { - node.distance = graph[current].distance + 1; - node.parent = current; - queue.unshift(adjacent); - } - } - } + var globals = env.global + var keys = Object.keys(object) + var thisDep = false + var contextDep = false + var propDep = false + var objectRef = env.global.def('{}') + keys.forEach(function (key) { + var value = object[key] + if (dynamic.isDynamic(value)) { + if (typeof value === 'function') { + value = object[key] = dynamic.unbox(value) + } + var deps = createDynamicDecl(value, null) + thisDep = thisDep || deps.thisDep + propDep = propDep || deps.propDep + contextDep = contextDep || deps.contextDep + } else { + globals(objectRef, '.', key, '=') + switch (typeof value) { + case 'number': + globals(value) + break + case 'string': + globals('"', value, '"') + break + case 'object': + if (Array.isArray(value)) { + globals('[', value.join(), ']') + } + break + default: + globals(env.link(value)) + break + } + globals(';') + } + }) - return graph; -} + function appendBlock (env, block) { + keys.forEach(function (key) { + var value = object[key] + if (!dynamic.isDynamic(value)) { + return + } + var ref = env.invoke(block, value) + block(objectRef, '.', key, '=', ref, ';') + }) + } -function link(from, to) { - return function (args) { - return to(from(args)); - }; -} + options.dynamic[name] = new dynamic.DynamicVariable(DYN_THUNK, { + thisDep: thisDep, + contextDep: contextDep, + propDep: propDep, + ref: objectRef, + append: appendBlock + }) + delete options.static[name] + } -function wrapConversion(toModel, graph) { - var path = [graph[toModel].parent, toModel]; - var fn = conversions[graph[toModel].parent][toModel]; + // =========================================================================== + // =========================================================================== + // MAIN DRAW COMMAND + // =========================================================================== + // =========================================================================== + function compileCommand (options, attributes, uniforms, context, stats) { + var env = createREGLEnvironment() - var cur = graph[toModel].parent; - while (graph[cur].parent) { - path.unshift(graph[cur].parent); - fn = link(conversions[graph[cur].parent][cur], fn); - cur = graph[cur].parent; - } + // link stats, so that we can easily access it in the program. + env.stats = env.link(stats) - fn.conversion = path; - return fn; -} + // splat options and attributes to allow for dynamic nested properties + Object.keys(attributes.static).forEach(function (key) { + splatObject(env, attributes, key) + }) + NESTED_OPTIONS.forEach(function (name) { + splatObject(env, options, name) + }) -module.exports = function (fromModel) { - var graph = deriveBFS(fromModel); - var conversion = {}; + var args = parseArguments(options, attributes, uniforms, context, env) - var models = Object.keys(graph); - for (var len = models.length, i = 0; i < len; i++) { - var toModel = models[i]; - var node = graph[toModel]; + emitDrawProc(env, args) + emitScopeProc(env, args) + emitBatchProc(env, args) - if (node.parent === null) { - // no possible conversion, or this node is the source model. - continue; - } + return extend(env.compile(), { + destroy: function () { + args.shader.program.destroy() + } + }) + } - conversion[toModel] = wrapConversion(toModel, graph); - } + // =========================================================================== + // =========================================================================== + // POLL / REFRESH + // =========================================================================== + // =========================================================================== + return { + next: nextState, + current: currentState, + procs: (function () { + var env = createREGLEnvironment() + var poll = env.proc('poll') + var refresh = env.proc('refresh') + var common = env.block() + poll(common) + refresh(common) - return conversion; -}; + var shared = env.shared + var GL = shared.gl + var NEXT_STATE = shared.next + var CURRENT_STATE = shared.current + common(CURRENT_STATE, '.dirty=false;') + emitPollFramebuffer(env, poll) + emitPollFramebuffer(env, refresh, null, true) -/***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { + // Refresh updates all attribute state changes + var INSTANCING + if (extInstancing) { + INSTANCING = env.link(extInstancing) + } -/** - * Identicon.js 2.3.1 - * http://github.com/stewartlord/identicon.js - * - * PNGLib required for PNG output - * http://www.xarg.org/download/pnglib.js - * - * Copyright 2017, Stewart Lord - * Released under the BSD license - * http://www.opensource.org/licenses/bsd-license.php - */ + // update vertex array bindings + if (extensions.oes_vertex_array_object) { + refresh(env.link(extensions.oes_vertex_array_object), '.bindVertexArrayOES(null);') + } + for (var i = 0; i < limits.maxAttributes; ++i) { + var BINDING = refresh.def(shared.attributes, '[', i, ']') + var ifte = env.cond(BINDING, '.buffer') + ifte.then( + GL, '.enableVertexAttribArray(', i, ');', + GL, '.bindBuffer(', + GL_ARRAY_BUFFER$2, ',', + BINDING, '.buffer.buffer);', + GL, '.vertexAttribPointer(', + i, ',', + BINDING, '.size,', + BINDING, '.type,', + BINDING, '.normalized,', + BINDING, '.stride,', + BINDING, '.offset);' + ).else( + GL, '.disableVertexAttribArray(', i, ');', + GL, '.vertexAttrib4f(', + i, ',', + BINDING, '.x,', + BINDING, '.y,', + BINDING, '.z,', + BINDING, '.w);', + BINDING, '.buffer=null;') + refresh(ifte) + if (extInstancing) { + refresh( + INSTANCING, '.vertexAttribDivisorANGLE(', + i, ',', + BINDING, '.divisor);') + } + } + refresh( + env.shared.vao, '.currentVAO=null;', + env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);') -(function() { - var PNGlib; - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - PNGlib = __webpack_require__(36); - } else { - PNGlib = window.PNGlib; - } + Object.keys(GL_FLAGS).forEach(function (flag) { + var cap = GL_FLAGS[flag] + var NEXT = common.def(NEXT_STATE, '.', flag) + var block = env.block() + block('if(', NEXT, '){', + GL, '.enable(', cap, ')}else{', + GL, '.disable(', cap, ')}', + CURRENT_STATE, '.', flag, '=', NEXT, ';') + refresh(block) + poll( + 'if(', NEXT, '!==', CURRENT_STATE, '.', flag, '){', + block, + '}') + }) - var Identicon = function(hash, options){ - if (typeof(hash) !== 'string' || hash.length < 15) { - throw 'A hash of at least 15 characters is required.'; + Object.keys(GL_VARIABLES).forEach(function (name) { + var func = GL_VARIABLES[name] + var init = currentState[name] + var NEXT, CURRENT + var block = env.block() + block(GL, '.', func, '(') + if (isArrayLike(init)) { + var n = init.length + NEXT = env.global.def(NEXT_STATE, '.', name) + CURRENT = env.global.def(CURRENT_STATE, '.', name) + block( + loop(n, function (i) { + return NEXT + '[' + i + ']' + }), ');', + loop(n, function (i) { + return CURRENT + '[' + i + ']=' + NEXT + '[' + i + '];' + }).join('')) + poll( + 'if(', loop(n, function (i) { + return NEXT + '[' + i + ']!==' + CURRENT + '[' + i + ']' + }).join('||'), '){', + block, + '}') + } else { + NEXT = common.def(NEXT_STATE, '.', name) + CURRENT = common.def(CURRENT_STATE, '.', name) + block( + NEXT, ');', + CURRENT_STATE, '.', name, '=', NEXT, ';') + poll( + 'if(', NEXT, '!==', CURRENT, '){', + block, + '}') } + refresh(block) + }) - this.defaults = { - background: [240, 240, 240, 255], - margin: 0.08, - size: 64, - saturation: 0.7, - brightness: 0.5, - format: 'png' - }; + return env.compile() + })(), + compile: compileCommand + } +} - this.options = typeof(options) === 'object' ? options : this.defaults; +function stats () { + return { + vaoCount: 0, + bufferCount: 0, + elementsCount: 0, + framebufferCount: 0, + shaderCount: 0, + textureCount: 0, + cubeCount: 0, + renderbufferCount: 0, + maxTextureUnits: 0 + } +} - // backward compatibility with old constructor (hash, size, margin) - if (typeof(arguments[1]) === 'number') { this.options.size = arguments[1]; } - if (arguments[2]) { this.options.margin = arguments[2]; } +var GL_QUERY_RESULT_EXT = 0x8866 +var GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867 +var GL_TIME_ELAPSED_EXT = 0x88BF - this.hash = hash - this.background = this.options.background || this.defaults.background; - this.size = this.options.size || this.defaults.size; - this.format = this.options.format || this.defaults.format; - this.margin = this.options.margin !== undefined ? this.options.margin : this.defaults.margin; +var createTimer = function (gl, extensions) { + if (!extensions.ext_disjoint_timer_query) { + return null + } - // foreground defaults to last 7 chars as hue at 70% saturation, 50% brightness - var hue = parseInt(this.hash.substr(-7), 16) / 0xfffffff; - var saturation = this.options.saturation || this.defaults.saturation; - var brightness = this.options.brightness || this.defaults.brightness; - this.foreground = this.options.foreground || this.hsl2rgb(hue, saturation, brightness); - }; + // QUERY POOL BEGIN + var queryPool = [] + function allocQuery () { + return queryPool.pop() || extensions.ext_disjoint_timer_query.createQueryEXT() + } + function freeQuery (query) { + queryPool.push(query) + } + // QUERY POOL END - Identicon.prototype = { - background: null, - foreground: null, - hash: null, - margin: null, - size: null, - format: null, + var pendingQueries = [] + function beginQuery (stats) { + var query = allocQuery() + extensions.ext_disjoint_timer_query.beginQueryEXT(GL_TIME_ELAPSED_EXT, query) + pendingQueries.push(query) + pushScopeStats(pendingQueries.length - 1, pendingQueries.length, stats) + } - image: function(){ - return this.isSvg() - ? new Svg(this.size, this.foreground, this.background) - : new PNGlib(this.size, this.size, 256); - }, + function endQuery () { + extensions.ext_disjoint_timer_query.endQueryEXT(GL_TIME_ELAPSED_EXT) + } - render: function(){ - var image = this.image(), - size = this.size, - baseMargin = Math.floor(size * this.margin), - cell = Math.floor((size - (baseMargin * 2)) / 5), - margin = Math.floor((size - cell * 5) / 2), - bg = image.color.apply(image, this.background), - fg = image.color.apply(image, this.foreground); + // + // Pending stats pool. + // + function PendingStats () { + this.startQueryIndex = -1 + this.endQueryIndex = -1 + this.sum = 0 + this.stats = null + } + var pendingStatsPool = [] + function allocPendingStats () { + return pendingStatsPool.pop() || new PendingStats() + } + function freePendingStats (pendingStats) { + pendingStatsPool.push(pendingStats) + } + // Pending stats pool end - // the first 15 characters of the hash control the pixels (even/odd) - // they are drawn down the middle first, then mirrored outwards - var i, color; - for (i = 0; i < 15; i++) { - color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg; - if (i < 5) { - this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image); - } else if (i < 10) { - this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); - this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image); - } else if (i < 15) { - this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); - this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image); - } - } + var pendingStats = [] + function pushScopeStats (start, end, stats) { + var ps = allocPendingStats() + ps.startQueryIndex = start + ps.endQueryIndex = end + ps.sum = 0 + ps.stats = stats + pendingStats.push(ps) + } - return image; - }, + // we should call this at the beginning of the frame, + // in order to update gpuTime + var timeSum = [] + var queryPtr = [] + function update () { + var ptr, i - rectangle: function(x, y, w, h, color, image){ - if (this.isSvg()) { - image.rectangles.push({x: x, y: y, w: w, h: h, color: color}); - } else { - var i, j; - for (i = x; i < x + w; i++) { - for (j = y; j < y + h; j++) { - image.buffer[image.index(i, j)] = color; - } - } - } - }, + var n = pendingQueries.length + if (n === 0) { + return + } - // adapted from: https://gist.github.com/aemkei/1325937 - hsl2rgb: function(h, s, b){ - h *= 6; - s = [ - b += s *= b < .5 ? b : 1 - b, - b - h % 1 * s * 2, - b -= s *= 2, - b, - b + h % 1 * s, - b + s - ]; + // Reserve space + queryPtr.length = Math.max(queryPtr.length, n + 1) + timeSum.length = Math.max(timeSum.length, n + 1) + timeSum[0] = 0 + queryPtr[0] = 0 - return[ - s[ ~~h % 6 ] * 255, // red - s[ (h|16) % 6 ] * 255, // green - s[ (h|8) % 6 ] * 255 // blue - ]; - }, + // Update all pending timer queries + var queryTime = 0 + ptr = 0 + for (i = 0; i < pendingQueries.length; ++i) { + var query = pendingQueries[i] + if (extensions.ext_disjoint_timer_query.getQueryObjectEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT)) { + queryTime += extensions.ext_disjoint_timer_query.getQueryObjectEXT(query, GL_QUERY_RESULT_EXT) + freeQuery(query) + } else { + pendingQueries[ptr++] = query + } + timeSum[i + 1] = queryTime + queryPtr[i + 1] = ptr + } + pendingQueries.length = ptr - toString: function(raw){ - // backward compatibility with old toString, default to base64 - if (raw) { - return this.render().getDump(); - } else { - return this.render().getBase64(); - } - }, + // Update all pending stat queries + ptr = 0 + for (i = 0; i < pendingStats.length; ++i) { + var stats = pendingStats[i] + var start = stats.startQueryIndex + var end = stats.endQueryIndex + stats.sum += timeSum[end] - timeSum[start] + var startPtr = queryPtr[start] + var endPtr = queryPtr[end] + if (endPtr === startPtr) { + stats.stats.gpuTime += stats.sum / 1e6 + freePendingStats(stats) + } else { + stats.startQueryIndex = startPtr + stats.endQueryIndex = endPtr + pendingStats[ptr++] = stats + } + } + pendingStats.length = ptr + } - isSvg: function(){ - return this.format.match(/svg/i) - } - }; + return { + beginQuery: beginQuery, + endQuery: endQuery, + pushScopeStats: pushScopeStats, + update: update, + getNumPendingQueries: function () { + return pendingQueries.length + }, + clear: function () { + queryPool.push.apply(queryPool, pendingQueries) + for (var i = 0; i < queryPool.length; i++) { + extensions.ext_disjoint_timer_query.deleteQueryEXT(queryPool[i]) + } + pendingQueries.length = 0 + queryPool.length = 0 + }, + restore: function () { + pendingQueries.length = 0 + queryPool.length = 0 + } + } +} - var Svg = function(size, foreground, background){ - this.size = size; - this.foreground = this.color.apply(this, foreground); - this.background = this.color.apply(this, background); - this.rectangles = []; - }; +var GL_COLOR_BUFFER_BIT = 16384 +var GL_DEPTH_BUFFER_BIT = 256 +var GL_STENCIL_BUFFER_BIT = 1024 - Svg.prototype = { - size: null, - foreground: null, - background: null, - rectangles: null, +var GL_ARRAY_BUFFER = 34962 - color: function(r, g, b, a){ - var values = [r, g, b].map(Math.round); - values.push((a >= 0) && (a <= 255) ? a/255 : 1); - return 'rgba(' + values.join(',') + ')'; - }, +var CONTEXT_LOST_EVENT = 'webglcontextlost' +var CONTEXT_RESTORED_EVENT = 'webglcontextrestored' - getDump: function(){ - var i, - xml, - rect, - fg = this.foreground, - bg = this.background, - stroke = this.size * 0.005; +var DYN_PROP = 1 +var DYN_CONTEXT = 2 +var DYN_STATE = 3 - xml = "<svg xmlns='http://www.w3.org/2000/svg'" - + " width='" + this.size + "' height='" + this.size + "'" - + " style='background-color:" + bg + ";'>" - + "<g style='fill:" + fg + "; stroke:" + fg + "; stroke-width:" + stroke + ";'>"; +function find (haystack, needle) { + for (var i = 0; i < haystack.length; ++i) { + if (haystack[i] === needle) { + return i + } + } + return -1 +} - for (i = 0; i < this.rectangles.length; i++) { - rect = this.rectangles[i]; - if (rect.color == bg) continue; - xml += "<rect " - + " x='" + rect.x + "'" - + " y='" + rect.y + "'" - + " width='" + rect.w + "'" - + " height='" + rect.h + "'" - + "/>"; - } - xml += "</g></svg>" +function wrapREGL (args) { + var config = parseArgs(args) + if (!config) { + return null + } - return xml; - }, + var gl = config.gl + var glAttributes = gl.getContextAttributes() + var contextLost = gl.isContextLost() - getBase64: function(){ - return btoa(this.getDump()); - } - }; + var extensionState = createExtensionCache(gl, config) + if (!extensionState) { + return null + } - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = Identicon; - } else { - window.Identicon = Identicon; - } -})(); + var stringStore = createStringStore() + var stats$$1 = stats() + var extensions = extensionState.extensions + var timer = createTimer(gl, extensions) -/***/ }), -/* 36 */ -/***/ (function(module, exports) { + var START_TIME = clock() + var WIDTH = gl.drawingBufferWidth + var HEIGHT = gl.drawingBufferHeight -/** -* A handy class to calculate color values. -* -* @version 1.0 -* @author Robert Eisele <robert@xarg.org> -* @copyright Copyright (c) 2010, Robert Eisele -* @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/ -* @license http://www.opensource.org/licenses/bsd-license.php BSD License -* -*/ + var contextState = { + tick: 0, + time: 0, + viewportWidth: WIDTH, + viewportHeight: HEIGHT, + framebufferWidth: WIDTH, + framebufferHeight: HEIGHT, + drawingBufferWidth: WIDTH, + drawingBufferHeight: HEIGHT, + pixelRatio: config.pixelRatio + } + var uniformState = {} + var drawState = { + elements: null, + primitive: 4, // GL_TRIANGLES + count: -1, + offset: 0, + instances: -1 + } -(function() { - - // helper functions for that ctx - function write(buffer, offs) { - for (var i = 2; i < arguments.length; i++) { - for (var j = 0; j < arguments[i].length; j++) { - buffer[offs++] = arguments[i].charAt(j); - } - } - } - - function byte2(w) { - return String.fromCharCode((w >> 8) & 255, w & 255); - } - - function byte4(w) { - return String.fromCharCode((w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w & 255); - } - - function byte2lsb(w) { - return String.fromCharCode(w & 255, (w >> 8) & 255); - } - - // modified from original source to support NPM - var PNGlib = function(width,height,depth) { - - this.width = width; - this.height = height; - this.depth = depth; - - // pixel data and row filter identifier size - this.pix_size = height * (width + 1); - - // deflate header, pix_size, block headers, adler32 checksum - this.data_size = 2 + this.pix_size + 5 * Math.floor((0xfffe + this.pix_size) / 0xffff) + 4; - - // offsets and sizes of Png chunks - this.ihdr_offs = 0; // IHDR offset and size - this.ihdr_size = 4 + 4 + 13 + 4; - this.plte_offs = this.ihdr_offs + this.ihdr_size; // PLTE offset and size - this.plte_size = 4 + 4 + 3 * depth + 4; - this.trns_offs = this.plte_offs + this.plte_size; // tRNS offset and size - this.trns_size = 4 + 4 + depth + 4; - this.idat_offs = this.trns_offs + this.trns_size; // IDAT offset and size - this.idat_size = 4 + 4 + this.data_size + 4; - this.iend_offs = this.idat_offs + this.idat_size; // IEND offset and size - this.iend_size = 4 + 4 + 4; - this.buffer_size = this.iend_offs + this.iend_size; // total PNG size - - this.buffer = new Array(); - this.palette = new Object(); - this.pindex = 0; - - var _crc32 = new Array(); - - // initialize buffer with zero bytes - for (var i = 0; i < this.buffer_size; i++) { - this.buffer[i] = "\x00"; - } - - // initialize non-zero elements - write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), 'IHDR', byte4(width), byte4(height), "\x08\x03"); - write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), 'PLTE'); - write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), 'tRNS'); - write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), 'IDAT'); - write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), 'IEND'); - - // initialize deflate header - var header = ((8 + (7 << 4)) << 8) | (3 << 6); - header+= 31 - (header % 31); - - write(this.buffer, this.idat_offs + 8, byte2(header)); - - // initialize deflate block headers - for (var i = 0; (i << 16) - 1 < this.pix_size; i++) { - var size, bits; - if (i + 0xffff < this.pix_size) { - size = 0xffff; - bits = "\x00"; - } else { - size = this.pix_size - (i << 16) - i; - bits = "\x01"; - } - write(this.buffer, this.idat_offs + 8 + 2 + (i << 16) + (i << 2), bits, byte2lsb(size), byte2lsb(~size)); - } - - /* Create crc32 lookup table */ - for (var i = 0; i < 256; i++) { - var c = i; - for (var j = 0; j < 8; j++) { - if (c & 1) { - c = -306674912 ^ ((c >> 1) & 0x7fffffff); - } else { - c = (c >> 1) & 0x7fffffff; - } - } - _crc32[i] = c; - } - - // compute the index into a png for a given pixel - this.index = function(x,y) { - var i = y * (this.width + 1) + x + 1; - var j = this.idat_offs + 8 + 2 + 5 * Math.floor((i / 0xffff) + 1) + i; - return j; - } - - // convert a color and build up the palette - this.color = function(red, green, blue, alpha) { - - alpha = alpha >= 0 ? alpha : 255; - var color = (((((alpha << 8) | red) << 8) | green) << 8) | blue; - - if (typeof this.palette[color] == "undefined") { - if (this.pindex == this.depth) return "\x00"; - - var ndx = this.plte_offs + 8 + 3 * this.pindex; - - this.buffer[ndx + 0] = String.fromCharCode(red); - this.buffer[ndx + 1] = String.fromCharCode(green); - this.buffer[ndx + 2] = String.fromCharCode(blue); - this.buffer[this.trns_offs+8+this.pindex] = String.fromCharCode(alpha); - - this.palette[color] = String.fromCharCode(this.pindex++); - } - return this.palette[color]; - } - - // output a PNG string, Base64 encoded - this.getBase64 = function() { - - var s = this.getDump(); - - var ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var c1, c2, c3, e1, e2, e3, e4; - var l = s.length; - var i = 0; - var r = ""; - - do { - c1 = s.charCodeAt(i); - e1 = c1 >> 2; - c2 = s.charCodeAt(i+1); - e2 = ((c1 & 3) << 4) | (c2 >> 4); - c3 = s.charCodeAt(i+2); - if (l < i+2) { e3 = 64; } else { e3 = ((c2 & 0xf) << 2) | (c3 >> 6); } - if (l < i+3) { e4 = 64; } else { e4 = c3 & 0x3f; } - r+= ch.charAt(e1) + ch.charAt(e2) + ch.charAt(e3) + ch.charAt(e4); - } while ((i+= 3) < l); - return r; - } - - // output a PNG string - this.getDump = function() { - - // compute adler32 of output pixels + row filter bytes - var BASE = 65521; /* largest prime smaller than 65536 */ - var NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - var s1 = 1; - var s2 = 0; - var n = NMAX; - - for (var y = 0; y < this.height; y++) { - for (var x = -1; x < this.width; x++) { - s1+= this.buffer[this.index(x, y)].charCodeAt(0); - s2+= s1; - if ((n-= 1) == 0) { - s1%= BASE; - s2%= BASE; - n = NMAX; - } - } - } - s1%= BASE; - s2%= BASE; - write(this.buffer, this.idat_offs + this.idat_size - 8, byte4((s2 << 16) | s1)); - - // compute crc32 of the PNG chunks - function crc32(png, offs, size) { - var crc = -1; - for (var i = 4; i < size-4; i += 1) { - crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff); - } - write(png, offs+size-4, byte4(crc ^ -1)); - } - - crc32(this.buffer, this.ihdr_offs, this.ihdr_size); - crc32(this.buffer, this.plte_offs, this.plte_size); - crc32(this.buffer, this.trns_offs, this.trns_size); - crc32(this.buffer, this.idat_offs, this.idat_size); - crc32(this.buffer, this.iend_offs, this.iend_size); - - // convert PNG to string - return "\x89PNG\r\n\x1a\n"+this.buffer.join(''); + var limits = wrapLimits(gl, extensions) + var bufferState = wrapBufferState( + gl, + stats$$1, + config, + destroyBuffer) + var attributeState = wrapAttributeState( + gl, + extensions, + limits, + stats$$1, + bufferState) + function destroyBuffer (buffer) { + return attributeState.destroyBuffer(buffer) + } + var elementState = wrapElementsState(gl, extensions, bufferState, stats$$1) + var shaderState = wrapShaderState(gl, stringStore, stats$$1, config) + var textureState = createTextureSet( + gl, + extensions, + limits, + function () { core.procs.poll() }, + contextState, + stats$$1, + config) + var renderbufferState = wrapRenderbuffers(gl, extensions, limits, stats$$1, config) + var framebufferState = wrapFBOState( + gl, + extensions, + limits, + textureState, + renderbufferState, + stats$$1) + var core = reglCore( + gl, + stringStore, + extensions, + limits, + bufferState, + elementState, + textureState, + framebufferState, + uniformState, + attributeState, + shaderState, + drawState, + contextState, + timer, + config) + var readPixels = wrapReadPixels( + gl, + framebufferState, + core.procs.poll, + contextState, + glAttributes, extensions, limits) + + var nextState = core.next + var canvas = gl.canvas + + var rafCallbacks = [] + var lossCallbacks = [] + var restoreCallbacks = [] + var destroyCallbacks = [config.onDestroy] + + var activeRAF = null + function handleRAF () { + if (rafCallbacks.length === 0) { + if (timer) { + timer.update() + } + activeRAF = null + return + } + + // schedule next animation frame + activeRAF = raf.next(handleRAF) + + // poll for changes + poll() + + // fire a callback for all pending rafs + for (var i = rafCallbacks.length - 1; i >= 0; --i) { + var cb = rafCallbacks[i] + if (cb) { + cb(contextState, null, 0) + } + } + + // flush all pending webgl calls + gl.flush() + + // poll GPU timers *after* gl.flush so we don't delay command dispatch + if (timer) { + timer.update() + } + } + + function startRAF () { + if (!activeRAF && rafCallbacks.length > 0) { + activeRAF = raf.next(handleRAF) + } + } + + function stopRAF () { + if (activeRAF) { + raf.cancel(handleRAF) + activeRAF = null + } + } + + function handleContextLoss (event) { + event.preventDefault() + + // set context lost flag + contextLost = true + + // pause request animation frame + stopRAF() + + // lose context + lossCallbacks.forEach(function (cb) { + cb() + }) + } + + function handleContextRestored (event) { + // clear error code + gl.getError() + + // clear context lost flag + contextLost = false + + // refresh state + extensionState.restore() + shaderState.restore() + bufferState.restore() + textureState.restore() + renderbufferState.restore() + framebufferState.restore() + attributeState.restore() + if (timer) { + timer.restore() + } + + // refresh state + core.procs.refresh() + + // restart RAF + startRAF() + + // restore context + restoreCallbacks.forEach(function (cb) { + cb() + }) + } + + if (canvas) { + canvas.addEventListener(CONTEXT_LOST_EVENT, handleContextLoss, false) + canvas.addEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored, false) + } + + function destroy () { + rafCallbacks.length = 0 + stopRAF() + + if (canvas) { + canvas.removeEventListener(CONTEXT_LOST_EVENT, handleContextLoss) + canvas.removeEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored) + } + + shaderState.clear() + framebufferState.clear() + renderbufferState.clear() + textureState.clear() + elementState.clear() + bufferState.clear() + attributeState.clear() + + if (timer) { + timer.clear() + } + + destroyCallbacks.forEach(function (cb) { + cb() + }) + } + + function compileProcedure (options) { + check$1(!!options, 'invalid args to regl({...})') + check$1.type(options, 'object', 'invalid args to regl({...})') + + function flattenNestedOptions (options) { + var result = extend({}, options) + delete result.uniforms + delete result.attributes + delete result.context + delete result.vao + + if ('stencil' in result && result.stencil.op) { + result.stencil.opBack = result.stencil.opFront = result.stencil.op + delete result.stencil.op + } + + function merge (name) { + if (name in result) { + var child = result[name] + delete result[name] + Object.keys(child).forEach(function (prop) { + result[name + '.' + prop] = child[prop] + }) + } + } + merge('blend') + merge('depth') + merge('cull') + merge('stencil') + merge('polygonOffset') + merge('scissor') + merge('sample') + + if ('vao' in options) { + result.vao = options.vao + } + + return result + } + + function separateDynamic (object, useArrays) { + var staticItems = {} + var dynamicItems = {} + Object.keys(object).forEach(function (option) { + var value = object[option] + if (dynamic.isDynamic(value)) { + dynamicItems[option] = dynamic.unbox(value, option) + return + } else if (useArrays && Array.isArray(value)) { + for (var i = 0; i < value.length; ++i) { + if (dynamic.isDynamic(value[i])) { + dynamicItems[option] = dynamic.unbox(value, option) + return } + } } - - // modified from original source to support NPM - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = PNGlib; + staticItems[option] = value + }) + return { + dynamic: dynamicItems, + static: staticItems + } + } + + // Treat context variables separate from other dynamic variables + var context = separateDynamic(options.context || {}, true) + var uniforms = separateDynamic(options.uniforms || {}, true) + var attributes = separateDynamic(options.attributes || {}, false) + var opts = separateDynamic(flattenNestedOptions(options), false) + + var stats$$1 = { + gpuTime: 0.0, + cpuTime: 0.0, + count: 0 + } + + var compiled = core.compile(opts, attributes, uniforms, context, stats$$1) + + var draw = compiled.draw + var batch = compiled.batch + var scope = compiled.scope + + // FIXME: we should modify code generation for batch commands so this + // isn't necessary + var EMPTY_ARRAY = [] + function reserve (count) { + while (EMPTY_ARRAY.length < count) { + EMPTY_ARRAY.push(null) + } + return EMPTY_ARRAY + } + + function REGLCommand (args, body) { + var i + if (contextLost) { + check$1.raise('context lost') + } + if (typeof args === 'function') { + return scope.call(this, null, args, 0) + } else if (typeof body === 'function') { + if (typeof args === 'number') { + for (i = 0; i < args; ++i) { + scope.call(this, null, body, i) + } + } else if (Array.isArray(args)) { + for (i = 0; i < args.length; ++i) { + scope.call(this, args[i], body, i) + } } else { - window.PNGlib = PNGlib; + return scope.call(this, args, body, 0) } - })(); + } else if (typeof args === 'number') { + if (args > 0) { + return batch.call(this, reserve(args | 0), args | 0) + } + } else if (Array.isArray(args)) { + if (args.length) { + return batch.call(this, args, args.length) + } + } else { + return draw.call(this, args) + } + } -/***/ }), -/* 37 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + return extend(REGLCommand, { + stats: stats$$1, + destroy: function () { + compiled.destroy() + } + }) + } -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/** - * Representation of a game item, which for the moment is limited to a - * simple Food type. - */ + var setFBO = framebufferState.setFBO = compileProcedure({ + framebuffer: dynamic.define.call(null, DYN_PROP, 'framebuffer') + }) -class Item { - constructor(id, itemId, maturity, remainingUses) { - this.id = id; - this.itemId = itemId; - this.maturity = maturity; - this.remainingUses = remainingUses; + function clearImpl (_, options) { + var clearFlags = 0 + core.procs.poll() - // XXX Maybe we can avoid this copy of every shared value - // to every instance, but going with it for now. - Object.assign(this, settings.item_config[this.itemId]); - } + var c = options.color + if (c) { + gl.clearColor(+c[0] || 0, +c[1] || 0, +c[2] || 0, +c[3] || 0) + clearFlags |= GL_COLOR_BUFFER_BIT + } + if ('depth' in options) { + gl.clearDepth(+options.depth) + clearFlags |= GL_DEPTH_BUFFER_BIT + } + if ('stencil' in options) { + gl.clearStencil(options.stencil | 0) + clearFlags |= GL_STENCIL_BUFFER_BIT + } - /** - * Calculate a color based on sprite definition and maturity - */ - get color() { - let immature, mature; + check$1(!!clearFlags, 'called regl.clear with no buffer specified') + gl.clear(clearFlags) + } - if (this.sprite.includes(",")) { - [immature, mature] = this.sprite.split(","); - // For now, assume these are hex colors + function clear (options) { + check$1( + typeof options === 'object' && options, + 'regl.clear() takes an object as input') + if ('framebuffer' in options) { + if (options.framebuffer && + options.framebuffer_reglType === 'framebufferCube') { + for (var i = 0; i < 6; ++i) { + setFBO(extend({ + framebuffer: options.framebuffer.faces[i] + }, options), clearImpl) + } + } else { + setFBO(options, clearImpl) + } } else { - immature = mature = this.sprite; + clearImpl(null, options) } - - return rgbOnScale( - hexToRgbPercentages(immature), - hexToRgbPercentages(mature), - this.maturity - ); } -} -/* harmony export (immutable) */ __webpack_exports__["Item"] = Item; + function frame (cb) { + check$1.type(cb, 'function', 'regl.frame() callback must be a function') + rafCallbacks.push(cb) + + function cancel () { + // FIXME: should we check something other than equals cb here? + // what if a user calls frame twice with the same callback... + // + var i = find(rafCallbacks, cb) + check$1(i >= 0, 'cannot cancel a frame twice') + function pendingCancel () { + var index = find(rafCallbacks, pendingCancel) + rafCallbacks[index] = rafCallbacks[rafCallbacks.length - 1] + rafCallbacks.length -= 1 + if (rafCallbacks.length <= 0) { + stopRAF() + } + } + rafCallbacks[i] = pendingCancel + } + + startRAF() -/** - * Manages Items that sit on the grid. - * - * Items currently being carried by a Player are not included. - * These are instead held by reference in the Play instances, - * (named `current_item`). - */ -class GridItems { - constructor() { - this._itemsByPosition = new Map(); - this._positionsById = new Map(); + return { + cancel: cancel + } } - add(item, position) { - this._itemsByPosition.set(JSON.stringify(position), item); - this._positionsById.set(item.id, JSON.stringify(position)); + // poll viewport + function pollViewport () { + var viewport = nextState.viewport + var scissorBox = nextState.scissor_box + viewport[0] = viewport[1] = scissorBox[0] = scissorBox[1] = 0 + contextState.viewportWidth = + contextState.framebufferWidth = + contextState.drawingBufferWidth = + viewport[2] = + scissorBox[2] = gl.drawingBufferWidth + contextState.viewportHeight = + contextState.framebufferHeight = + contextState.drawingBufferHeight = + viewport[3] = + scissorBox[3] = gl.drawingBufferHeight } - atPosition(position) { - const key = JSON.stringify(position); - return this._itemsByPosition.get(key) || null; + function poll () { + contextState.tick += 1 + contextState.time = now() + pollViewport() + core.procs.poll() } - positionOf(item) { - if (this._positionsById.has(item.id)) { - return JSON.parse(this._positionsById.get(item.id)); + function refresh () { + textureState.refresh() + pollViewport() + core.procs.refresh() + if (timer) { + timer.update() } + } - return undefined; + function now () { + return (clock() - START_TIME) / 1000.0 } - remove(position) { - const item = this.atPosition(position); + refresh() - if (item) { - this._itemsByPosition.delete(JSON.stringify(position)); - this._positionsById.delete(item.id); + function addListener (event, callback) { + check$1.type(callback, 'function', 'listener callback must be a function') + + var callbacks + switch (event) { + case 'frame': + return frame(callback) + case 'lost': + callbacks = lossCallbacks + break + case 'restore': + callbacks = restoreCallbacks + break + case 'destroy': + callbacks = destroyCallbacks + break + default: + check$1.raise('invalid event, must be one of frame,lost,restore,destroy') } - } - /** - * Retrieve pairs of positions and Item objects (like Python's dict.items()) - * @returns Map.prototype[@@iterator] of[position, Item] pairs - */ - *entries() { - for (const [itemPosition, currentItem] of this._itemsByPosition.entries()) { - yield [JSON.parse(itemPosition), currentItem]; + callbacks.push(callback) + return { + cancel: function () { + for (var i = 0; i < callbacks.length; ++i) { + if (callbacks[i] === callback) { + callbacks[i] = callbacks[callbacks.length - 1] + callbacks.pop() + return + } + } + } } } -} -/* harmony export (immutable) */ __webpack_exports__["GridItems"] = GridItems; + var regl = extend(compileProcedure, { + // Clear current FBO + clear: clear, -function hexToRgbPercentages(hexColor) { - if (hexColor.startsWith("#")) { - hexColor = hexColor.substring(1); - } + // Short cuts for dynamic variables + prop: dynamic.define.bind(null, DYN_PROP), + context: dynamic.define.bind(null, DYN_CONTEXT), + this: dynamic.define.bind(null, DYN_STATE), - // Check if the hex color has a valid length (either 3 or 6 characters) - if (hexColor.length !== 3 && hexColor.length !== 6) { - throw new Error( - "Invalid hex color format. It should be either 3 or 6 characters long." - ); - } + // executes an empty draw command + draw: compileProcedure({}), - // If the hex color is 3 characters long, expand it to 6 characters by - // duplicating each character - if (hexColor.length === 3) { - hexColor = hexColor - .split("") - .map((char) => char + char) - .join(""); - } + // Resources + buffer: function (options) { + return bufferState.create(options, GL_ARRAY_BUFFER, false, false) + }, + elements: function (options) { + return elementState.create(options, false) + }, + texture: textureState.create2D, + cube: textureState.createCube, + renderbuffer: renderbufferState.create, + framebuffer: framebufferState.create, + framebufferCube: framebufferState.createCube, + vao: attributeState.createVAO, - // Convert the hex color to RGB percentage values - const red = parseInt(hexColor.substring(0, 2), 16) / 255; - const green = parseInt(hexColor.substring(2, 4), 16) / 255; - const blue = parseInt(hexColor.substring(4, 6), 16) / 255; + // Expose context attributes + attributes: glAttributes, - return [red, green, blue]; -} + // Frame rendering + frame: frame, + on: addListener, -function rgbOnScale(startColor, endColor, percentage) { - const result = []; - for (let i = 0; i < 3; i++) { - result[i] = endColor[i] + percentage * (startColor[i] - endColor[i]); - } + // System limits + limits: limits, + hasExtension: function (name) { + return limits.extensions.indexOf(name.toLowerCase()) >= 0 + }, - return result; + // Read pixels + read: readPixels, + + // Destroy regl and all associated resources + destroy: destroy, + + // Direct GL state manipulation + _gl: gl, + _refresh: refresh, + + poll: function () { + poll() + if (timer) { + timer.update() + } + }, + + // Current time + now: now, + + // regl Statistics Information + stats: stats$$1 + }) + + config.onDone(null, regl) + + return regl } +return wrapREGL; + +}))); +//# sourceMappingURL=regl.js.map + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var isArrayish = __webpack_require__(33); + +var concat = Array.prototype.concat; +var slice = Array.prototype.slice; + +var swizzle = module.exports = function swizzle(args) { + var results = []; + + for (var i = 0, len = args.length; i < len; i++) { + var arg = args[i]; + + if (isArrayish(arg)) { + // http://jsperf.com/javascript-array-concat-vs-push/98 + results = concat.call(results, slice.call(arg)); + } else { + results.push(arg); + } + } + + return results; +}; + +swizzle.wrap = function (fn) { + return function () { + return fn(swizzle(arguments)); + }; +}; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + +module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if(!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; +}; + /***/ }) /******/ ]); diff --git a/dlgr/griduniverse/static/scripts/dist/bundle.js.map b/dlgr/griduniverse/static/scripts/dist/bundle.js.map index 66ef5b22..af70a027 100644 --- a/dlgr/griduniverse/static/scripts/dist/bundle.js.map +++ b/dlgr/griduniverse/static/scripts/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 511c53b79451de123aa5","webpack:///./node_modules/parse-color/index.js","webpack:///./node_modules/is-number/index.js","webpack:///./node_modules/is-string/index.js","webpack:///./node_modules/is-array/index.js","webpack:///./dlgr/griduniverse/static/scripts/util/md5.js","webpack:///./node_modules/color-name/index.js","webpack:///./node_modules/color-convert/conversions.js","webpack:///./dlgr/griduniverse/static/scripts/demo.js","webpack:///./dlgr/griduniverse/static/scripts/index.js","webpack:///./node_modules/parse-color/node_modules/color-convert/index.js","webpack:///./node_modules/parse-color/node_modules/color-convert/conversions.js","webpack:///./node_modules/kind-of/index.js","webpack:///./node_modules/is-buffer/index.js","webpack:///./dlgr/griduniverse/static/scripts/util/convert.js","webpack:///./node_modules/lodash/lodash.js","webpack:///(webpack)/buildin/global.js","webpack:///(webpack)/buildin/module.js","webpack:///./dlgr/griduniverse/static/scripts/util/layout.js","webpack:///./dlgr/griduniverse/static/scripts/util/texcoord.js","webpack:///./dlgr/griduniverse/static/scripts/util/range.js","webpack:///./dlgr/griduniverse/static/scripts/util/pixdenticon.js","webpack:///./node_modules/regl/dist/regl.js","webpack:///./node_modules/mouse-position/index.js","webpack:///./node_modules/events/events.js","webpack:///./node_modules/mousetrap/mousetrap.js","webpack:///./node_modules/reconnecting-websocket/dist/index.js","webpack:///external \"jQuery\"","webpack:///./node_modules/gaussian/lib/gaussian.js","webpack:///./node_modules/color/index.js","webpack:///./node_modules/color-string/index.js","webpack:///./node_modules/simple-swizzle/index.js","webpack:///./node_modules/is-arrayish/index.js","webpack:///./node_modules/color-convert/index.js","webpack:///./node_modules/color-convert/route.js","webpack:///./dlgr/griduniverse/static/scripts/util/identicon.js","webpack:///./dlgr/griduniverse/static/scripts/util/pnglib.js","webpack:///./dlgr/griduniverse/static/scripts/items.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;AC7DA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,oCAAoC;;AAE7C;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;AClFA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AClBA;;AAEA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAiC,aAAa;AAC9C,iCAAiC,cAAc;AAC/C;AACA;;;;;;;;AClBA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,YAAY;AACZ;;AAEA;AACA;AACA;;;;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,CAAC;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA,eAAe,aAAa;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AAAA;AACL,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA,CAAC,O;;;;;;ACxRD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;;;;;;ACrJA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,QAAQ,4BAA4B;AACpC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,6BAA6B;AACpC,WAAW,iCAAiC;AAC5C,UAAU,gCAAgC;AAC1C,WAAW,iCAAiC;AAC5C,OAAO,qCAAqC;AAC5C,SAAS,2CAA2C;AACpD,QAAQ;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qDAAqD,gBAAgB;AACrE,mDAAmD,cAAc;AACjE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,uBAAuB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO,QAAQ;AAC/B,gBAAgB,OAAO,QAAQ;AAC/B,iBAAiB,OAAO,OAAO;AAC/B,iBAAiB,OAAO,OAAO;AAC/B,gBAAgB,QAAQ,OAAO;AAC/B,gBAAgB,QAAQ,OAAO;AAC/B;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,sEAAsE;;AAEtE;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,+CAA+C,EAAE,UAAU,EAAE;AAC7D;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA,EAAE;AACF;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa;AAC5B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;AC51BA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC,qBAAqB,kBAAkB;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,eAAe;AAClC,qBAAqB,kBAAkB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,mBAAmB;AAClC,iBAAiB,sBAAsB;AACvC;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,4BAA4B,uCAAuC;AACnE;AACA;AACA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,iBAAiB,2BAA2B;AAC5C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA,OAAO;;AAEP;AACA,gBAAgB;AAChB,OAAO;AACP;;AAEA;AACA;;AAEA;AACA,2BAA2B,qDAAqD;AAChF,OAAO;;AAEP;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;AACA,yBAAyB,oBAAoB;;AAE7C;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2BAA2B,KAAK;AAChC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,6BAA6B;AAC7B;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;;AAEA,2BAA2B,gBAAgB,EAAE;AAC7C,2BAA2B,mBAAmB,EAAE;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,aAAa,gBAAgB,KAAK,gBAAgB,MAAM,cAAc,KAAK,cAAc;AACzF;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAe,wBAAwB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wBAAwB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,wBAAwB;AAClD;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uGAAuG;AACvG,GAAG;AACH,sFAAsF;AACtF;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,4BAA4B;AAC5D,eAAe,yBAAyB;AACxC;AACA;AACA,4JAA4J;AAC5J;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,0BAA0B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,wBAAwB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA,CAAC;;AAED,CAAC;;;;;;;ACj6CD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,eAAe,iBAAiB;AAChC;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,UAAU;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,+FAA+F;AAChH;AACA;AACA,eAAe;AACf,GAAG;;AAEH;AACA,gBAAgB,mBAAmB;AACnC,kBAAkB,OAAO;AACzB;AACA;AACA;;AAEA,gBAAgB;;AAEhB;AACA,gBAAgB,uCAAuC;AACvD,aAAa,2DAA2D;AACxE;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,gBAAgB,mBAAmB;AACnC,kBAAkB,OAAO;AACzB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC/JA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA,uD;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB;;AAEnB,qBAAqB,gBAAgB;AACrC;AACA;AACA;AACA,GAAG;AACH;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gD;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,CAAC;;AAED,yB;;;;;;AC3FA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;;AAExB;AACA;AACA;AACA,kBAAkB,OAAO,QAAQ;AACjC,kBAAkB,OAAO,QAAQ;AACjC,mBAAmB,OAAO,OAAO;AACjC,mBAAmB,OAAO,OAAO;AACjC,kBAAkB,QAAQ,OAAO;AACjC,kBAAkB,QAAQ,OAAO;AACjC;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACzrBA;AACA;;AAEA;AACA;AACA;AACA,YAAY,EAAE;AACd,YAAY,EAAE;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACpBA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;;AAEA;AACA;;AAEA;;;;;;;sDC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2CAA2C;AAC3C;AACA,2DAA2D;;AAE3D;AACA,+CAA+C;AAC/C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;;AAEA;AACA;AACA;AACA;;AAEA;AACA,yBAAyB;AACzB,yBAAyB;AACzB;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,0BAA0B,MAAM,aAAa,OAAO;;AAEpD;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAiD,EAAE;AACnD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C,GAAG;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf,cAAc;AACd,cAAc;AACd,gBAAgB;AAChB,eAAe;AACf;;AAEA;AACA;AACA,UAAU;AACV,SAAS;AACT,SAAS;AACT,WAAW;AACX,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,EAAE;AACf,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,MAAM;AACnB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,SAAS;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,QAAQ;AACrB;AACA,eAAe,EAAE;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,QAAQ;AACrB;AACA,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,aAAa,SAAS;AACtB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,EAAE;AACf,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,QAAQ;AACrB;AACA,aAAa,SAAS;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,eAAe,EAAE;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA,cAAc,2BAA2B;AACzC;AACA;AACA,mBAAmB,gCAAgC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,6BAA6B;AAC9D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW;AACX;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,cAAc;AAC/B;AACA;AACA;AACA;AACA;AACA,oCAAoC,6BAA6B,EAAE;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,EAAE;AACnB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,6BAA6B;AAC5C,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT,gBAAgB;AAChB,OAAO;;AAEP;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qEAAqE;AACrE;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,aAAa;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,YAAY;AAC3B,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,mBAAmB;AAClC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,gBAAgB,QAAQ;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,gBAAgB,QAAQ;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,OAAO,WAAW;AACjC,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,4BAA4B;;AAE5B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,WAAW;AACjC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,WAAW;AACjC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,+CAA+C;AACpF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,oEAAoE;AACpE;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,0CAA0C;AAC1C,wCAAwC;AACxC,+DAA+D;AAC/D,iEAAiE;AACjE;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C;AAC7C;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,cAAc;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,cAAc;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,MAAM;AACvB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,SAAS,GAAG,SAAS,KAAK,SAAS;AAC3D,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D;AACA,mCAAmC,iBAAiB;AACpD,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,oCAAoC;AAC9C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,4CAA4C,kBAAkB,EAAE;AAChE;AACA;AACA;AACA,gCAAgC,qCAAqC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,uCAAuC,kBAAkB,EAAE;AAC3D;AACA;AACA;AACA,2BAA2B,oCAAoC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,uCAAuC,2BAA2B,EAAE;AACpE;AACA;AACA;AACA,2BAA2B,kCAAkC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,oCAAoC;AAC9C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,2CAA2C,4BAA4B,EAAE;AACzE;AACA;AACA;AACA,+BAA+B,mCAAmC;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,SAAS,KAAK,SAAS,GAAG,SAAS;AAC7D,eAAe,SAAS;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D,sBAAsB,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,qBAAqB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;AAClE;AACA,4BAA4B,SAAS,GAAG,SAAS;AACjD;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,qBAAqB,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB;AAC9E;AACA,8BAA8B,iBAAiB;AAC/C;AACA,eAAe,iBAAiB,GAAG,iBAAiB;AACpD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,qBAAqB;AACpC,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,iCAAiC,SAAS,eAAe,YAAY,EAAE;AACvE;AACA;AACA;AACA,iCAAiC,SAAS;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,qCAAqC,SAAS,eAAe,YAAY,EAAE;AAC3E;AACA;AACA;AACA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,oCAAoC;AAC9C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,4CAA4C,kBAAkB,EAAE;AAChE;AACA;AACA;AACA,gCAAgC,qCAAqC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,uCAAuC,kBAAkB,EAAE;AAC3D;AACA;AACA;AACA,2BAA2B,oCAAoC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS,KAAK,SAAS,GAAG,SAAS;AACtD,eAAe,SAAS,GAAG,SAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D,sBAAsB,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA,eAAe,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB;AACxE;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS,GAAG,SAAS,GAAG,SAAS;AACnD,eAAe,SAAS,GAAG,SAAS;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB;AAChF;AACA;AACA,eAAe,iBAAiB,GAAG,iBAAiB;AACpD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,KAAK,SAAS,GAAG,SAAS;AACpD,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D,sBAAsB,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA,eAAe,iBAAiB,GAAG,iBAAiB;AACpD;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc,OAAO,QAAQ,SAAS,GAAG,SAAS,GAAG;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,+BAA+B;AACzC,UAAU,+BAA+B;AACzC,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,8BAA8B;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,8BAA8B;AACxC,UAAU;AACV;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA,cAAc;AACd;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,gBAAgB,OAAO;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,+CAA+C;AACzD,UAAU;AACV;AACA;AACA;AACA,uBAAuB,oCAAoC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,UAAU,8CAA8C;AACxD,UAAU;AACV;AACA;AACA,oCAAoC,kBAAkB,EAAE;AACxD;AACA;AACA;AACA,wBAAwB,4BAA4B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA,UAAU,+CAA+C;AACzD,UAAU,gDAAgD;AAC1D,UAAU;AACV;AACA;AACA,kCAAkC,mBAAmB,EAAE;AACvD;AACA;AACA;AACA,sBAAsB,2BAA2B;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,sBAAsB;AACrC;AACA,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,4BAA4B;AACtC,UAAU;AACV;AACA;AACA;AACA;AACA,QAAQ;AACR,cAAc,OAAO,4BAA4B,QAAQ,8BAA8B;AACvF;AACA;AACA,cAAc,UAAU,4BAA4B,YAAY,8BAA8B;AAC9F;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA;AACA,UAAU,mBAAmB;AAC7B,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,qCAAqC;AACpD;AACA,eAAe,SAAS;AACxB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,gDAAgD;AAC1D,UAAU,+CAA+C;AACzD,UAAU;AACV;AACA;AACA,uCAAuC,iBAAiB,EAAE;AAC1D;AACA;AACA;AACA,2BAA2B,4BAA4B;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,cAAc,iBAAiB,EAAE;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,iBAAiB,yBAAyB;AAC1C;AACA;AACA,QAAQ,IAAI;AACZ,cAAc,8BAA8B;AAC5C;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,UAAU,+CAA+C;AACzD,UAAU;AACV;AACA;AACA,oCAAoC,kBAAkB,EAAE;AACxD;AACA;AACA;AACA,wBAAwB,4BAA4B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,gBAAgB,OAAO;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,mCAAmC;AAC7C,UAAU;AACV;AACA;AACA;AACA,sBAAsB,oCAAoC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,yBAAyB;AACxC;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU;AACV;AACA;AACA,qCAAqC,eAAe,EAAE;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,oBAAoB,iCAAiC;AACrD,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,QAAQ;AACvB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,QAAQ;AACvB;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,kDAAkD,kBAAkB;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,KAAK;AACpB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,qBAAqB;AACpC,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD,oBAAoB;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA,oBAAoB,SAAS;AAC7B,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB;AACA,6BAA6B,mBAAmB,cAAc,EAAE,EAAE;AAClE;AACA;AACA,6BAA6B,mBAAmB,cAAc,EAAE,EAAE;AAClE;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA,iCAAiC,kBAAkB,EAAE;AACrD;AACA;AACA;AACA;AACA;AACA,kDAAkD,kBAAkB,EAAE;AACtE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB;AACA,0BAA0B,SAAS;AACnC;AACA;AACA,0BAA0B,SAAS;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,MAAM;AACvB;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B,cAAc;AACd;AACA,iBAAiB,SAAS;AAC1B,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,GAAG,SAAS,GAAG,SAAS;AAClD,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,GAAG,SAAS,GAAG,SAAS;AAClD,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,MAAM;AACvB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,mBAAmB,SAAS,GAAG,SAAS,GAAG,SAAS;AACpD,cAAc;AACd;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,uBAAuB,OAAO,SAAS,EAAE,GAAG,OAAO,iBAAiB,EAAE;AACtE,cAAc,OAAO,iBAAiB;AACtC;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA,qBAAqB,4BAA4B;AACjD,qBAAqB,6BAA6B;AAClD,qBAAqB;AACrB;AACA;AACA,qCAAqC,mBAAmB,EAAE;AAC1D;AACA;AACA;AACA,yBAAyB,2BAA2B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA,qBAAqB,4BAA4B;AACjD,qBAAqB,6BAA6B;AAClD,qBAAqB;AACrB;AACA;AACA,yCAAyC,mBAAmB,EAAE;AAC9D;AACA;AACA;AACA,6BAA6B,4BAA4B;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB,OAAO,SAAS;AACrC,6BAA6B,gBAAgB,SAAS,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA,8BAA8B,gBAAgB,SAAS,GAAG;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ;AACR,cAAc;AACd;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,KAAK;AACpB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB,QAAQ,OAAO,oBAAoB,EAAE;AAC1D;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA,QAAQ;AACR,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,qBAAqB,+BAA+B;AACpD,qBAAqB;AACrB;AACA;AACA,uCAAuC,cAAc,EAAE;AACvD,cAAc,2BAA2B;AACzC;AACA;AACA;AACA,cAAc,2BAA2B;AACzC;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,gBAAgB,SAAS,GAAG,SAAS;AACrC;AACA;AACA;AACA,gBAAgB,SAAS,GAAG,SAAS;AACrC;AACA;AACA;AACA,cAAc,QAAQ,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA,gCAAgC;AAChC,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB,QAAQ,OAAO,+BAA+B,EAAE;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc,OAAO,WAAW;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,oBAAoB,yBAAyB;AAC7C;AACA,QAAQ,IAAI;AACZ,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA,cAAc,QAAQ,QAAQ,EAAE;AAChC;AACA;AACA;AACA;AACA;AACA,cAAc,QAAQ,QAAQ,EAAE;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA,iDAAiD,cAAc,EAAE;AACjE;AACA;AACA;AACA,iDAAiD,sBAAsB,EAAE;AACzE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc,OAAO,WAAW;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kCAAkC,KAAK;AACvC;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,eAAe,gBAAgB;AAC/B,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA,iBAAiB,sBAAsB;AACvC,qBAAqB,UAAU;AAC/B;AACA;AACA,sEAAsE,2BAA2B,EAAE;AACnG,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA,4DAA4D;AAC5D,iBAAiB,mBAAmB;AACpC;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA,qDAAqD,2BAA2B,EAAE;AAClF,wCAAwC,aAAa,eAAe,EAAE;AACtE,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA,wDAAwD,qCAAqC;AAC7F;AACA;AACA;AACA;AACA,0DAA0D,qBAAqB;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,YAAY;AACvD,0CAA0C,QAAQ;AAClD,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,+BAA+B;;AAE/B,mCAAmC;AACnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,wBAAwB;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;;AAEP,mBAAmB;;AAEnB;AACA;AACA;AACA;AACA,8BAA8B,mBAAmB;AACjD;AACA;AACA;AACA;AACA,4CAA4C;;AAE5C;AACA,uDAAuD;AACvD;AACA;AACA,6BAA6B,EAAE;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C,+BAA+B,iCAAiC;AAChE,cAAc;AACd;AACA;AACA,sBAAsB;;AAEtB;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAiC;AACjC,aAAa,QAAQ,QAAQ,UAAU,aAAa;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,qBAAqB,SAAS;AAC9B,sBAAsB,kBAAkB;AACxC;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA,aAAa,qBAAqB;AAClC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,iBAAiB;AAC3B,UAAU;AACV;AACA;AACA,qCAAqC,mBAAmB,cAAc,EAAE,EAAE;AAC1E,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA,4CAA4C,SAAS;AACrD;AACA;AACA,eAAe,SAAS,GAAG,SAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,8CAA8C;AACxD,UAAU;AACV;AACA;AACA;AACA,mCAAmC,mCAAmC;AACtE,eAAe,8CAA8C;AAC7D;AACA;AACA;AACA,eAAe,4BAA4B;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,yBAAyB;AACnC,UAAU;AACV;AACA;AACA,oCAAoC,iBAAiB;AACrD,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,yBAAyB;AACnC,UAAU;AACV;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,OAAO,qBAAqB,EAAE;AACxC,UAAU,OAAO,qBAAqB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,QAAQ;AACvB,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,mBAAmB,GAAG,iBAAiB;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,4BAA4B,qDAAqD;AACjF;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,OAAO,SAAS,EAAE;AAC5B,UAAU,OAAO,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,gBAAgB,IAAI;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,qCAAqC,YAAY,EAAE;AACnD,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;AACpE;AACA,sCAAsC,YAAY,EAAE;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,qCAAqC,YAAY,EAAE;AACnD,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;AACpE;AACA,qCAAqC,YAAY,EAAE;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK,MAAM,iBAAiB;;AAE5B;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mCAAmC,4DAA4D;AAC/F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB,yCAAyC;AAC7D;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AAAA;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;AC3rhBD;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;;;;;;ACrBA;AACA;;AAEA,iBAAiB,UAAU;AAC3B,mBAAmB,aAAa;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;;;;;;;ACxBA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,UAAU;AAC3B,mBAAmB,aAAa;AAChC;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;;;;;;;AC1BA,sB;AACA;AACA;AACA,kCAAkC,cAAc,EAAE,E;AAClD;;;;AAIA;;;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA,mBAAmB,WAAW;AAC9B,uBAAuB,WAAW;AAClC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,eAAe,UAAU;AACzB;AACA,mBAAmB,UAAU;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;AAGA;;;;;;;ACpGA;AACA;AACA;AACA;AACA,CAAC,qBAAqB;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,6EAA6E,0BAA0B;;AAEvG;AACA;AACA,yEAAyE;AACzE,4CAA4C,yBAAyB;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,0BAA0B;AAC7C;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB;AACrB,qBAAqB,4BAA4B;AACjD;AACA,sBAAsB;AACtB;AACA;;AAEA;AACA;AACA,iBAAiB;AACjB,iBAAiB;;AAEjB;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,8CAA8C,kBAAkB;AAChE;;AAEA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,eAAe;AACf;AACA,eAAe;AACf;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,mBAAmB,QAAQ;AAC3B;AACA,qBAAqB,QAAQ;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,yBAAyB,kBAAkB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;AACA,GAAG;AACH,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,cAAc;AACxC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;;AAEvB;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,mBAAmB,YAAY;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,kBAAkB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,iBAAiB;;AAEvD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA,iBAAiB,kBAAkB;AACnC;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,OAAO;AACxB,mBAAmB,OAAO;AAC1B,qBAAqB,OAAO;AAC5B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG,IAAI;;AAEP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,uBAAuB,oBAAoB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,uBAAuB,OAAO;AAC9B;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,qBAAqB,OAAO;AAC5B,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qBAAqB,QAAQ;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,yBAAyB,OAAO;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,eAAe,6BAA6B;AAC5C;AACA;AACA,qCAAqC,gCAAgC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,iBAAiB,6BAA6B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qBAAqB,6BAA6B;AAClD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qBAAqB,wBAAwB;AAC7C;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,uBAAuB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,OAAO;AACxB,uBAAuB,uBAAuB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,mBAAmB;AACpC;AACA;;AAEA,iBAAiB,OAAO;AACxB;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA,yBAAyB,eAAe;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,wBAAwB;AAC3C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB;AACpB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,yDAAyD;AACzD;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,6BAA6B,mBAAmB;AAChD;AACA;AACA,0BAA0B;AAC1B;AACA,YAAY;AACZ;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,WAAW;AAC9B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA,YAAY;AACZ;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,8BAA8B;AAC9B;AACA,eAAe;AACf;AACA;AACA,KAAK;AACL,gBAAgB;AAChB;AACA,iBAAiB,MAAM;AACvB,iBAAiB,MAAM;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oEAAoE;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6EAA6E;AAC7E;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,OAAO;AACP;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,kFAAkF;AAClF,iFAAiF;;AAEjF;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA;AACA;AACA,mEAAmE;;AAEnE;;AAEA;AACA,SAAS;AACT;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,aAAa;AACb,WAAW;AACX;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB;;AAEnB;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,eAAe;AACf;AACA,WAAW;AACX;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA;AACA,WAAW;AACX;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB;;AAEjB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;;AAEA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA,sEAAsE;AACtE;AACA,8DAA8D;AAC9D,kEAAkE;;AAElE;;AAEA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe;AACf,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;AAEjB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;;AAEA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,aAAa;AAC1D,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe;AACf,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,WAAW;AACX;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA,iDAAiD;AACjD,kCAAkC;AAClC,yFAAyF;AACzF,qCAAqC;AACrC,YAAY,KAAK;AACjB,8DAA8D;AAC9D,4BAA4B;AAC5B,qCAAqC;AACrC,YAAY,mCAAmC;AAC/C,sDAAsD;AACtD,0DAA0D;AAC1D,6DAA6D;AAC7D;AACA;AACA,WAAW,iBAAiB;AAC5B,YAAY,KAAK;AACjB;AACA;AACA;AACA,oDAAoD;AACpD;AACA,WAAW;AACX,aAAa,KAAK;AAClB,wDAAwD;AACxD,gGAAgG;AAChG,YAAY,KAAK;AACjB,qEAAqE;AACrE,YAAY;AACZ;AACA,iEAAiE;AACjE,wDAAwD;AACxD;AACA,yDAAyD;AACzD;AACA;AACA;AACA;AACA;;AAEA,iBAAiB;;AAEjB;AACA,qCAAqC;AACrC,sDAAsD;AACtD,YAAY;;AAEZ;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,uEAAuE;AACvE,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA,0DAA0D;AAC1D;AACA;AACA,sBAAsB;AACtB,2EAA2E;AAC3E;AACA;AACA,6DAA6D;AAC7D;AACA,YAAY,KAAK;AACjB,yDAAyD;AACzD;AACA,oEAAoE;AACpE;AACA;AACA,QAAQ;AACR,0CAA0C;AAC1C;AACA,cAAc;AACd;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA,yDAAyD;AACzD;AACA;AACA,aAAa,SAAS,MAAM;AAC5B,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D;AAC1D,2DAA2D;AAC3D,oDAAoD;AACpD,SAAS;AACT;AACA,wDAAwD;AACxD,oDAAoD;AACpD;AACA;AACA,KAAK;AACL;AACA,yCAAyC;AACzC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C,WAAW;AACX,4CAA4C;AAC5C;AACA,SAAS;AACT;AACA,2CAA2C;AAC3C,4CAA4C;AAC5C;AACA,0DAA0D;AAC1D,OAAO;AACP;AACA;AACA,0DAA0D;AAC1D;AACA;AACA,WAAW,SAAS,MAAM;AAC1B,OAAO;AACP;AACA,0DAA0D;AAC1D,sDAAsD;AACtD;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,6CAA6C;AAC7C;AACA,qDAAqD;AACrD,OAAO;AACP,+BAA+B;AAC/B;AACA;AACA;AACA;AACA,oEAAoE;AACpE,SAAS;AACT,iDAAiD;AACjD;AACA;AACA;;AAEA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB,SAAS;AACT,oCAAoC;AACpC;AACA;AACA;;AAEA;AACA;AACA,iDAAiD;AACjD,qDAAqD;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,iCAAiC,YAAY;AAC7C;AACA;AACA,sCAAsC,UAAU;AAChD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qCAAqC;AACrC,yDAAyD;;AAEzD;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,aAAa;AACb,wEAAwE;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,qCAAqC;AACrC,qCAAqC;AACrC;AACA,+DAA+D;AAC/D,WAAW;AACX,YAAY;;AAEZ;AACA;AACA;AACA,uDAAuD;AACvD,kFAAkF;AAClF,8CAA8C;AAC9C;AACA;;AAEA;AACA;AACA,oCAAoC;AACpC,yDAAyD;AACzD,YAAY;AACZ;AACA,WAAW,iBAAiB;AAC5B,sEAAsE;AACtE;AACA,qEAAqE;AACrE,WAAW;AACX,YAAY;AACZ;;AAEA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP,4DAA4D;AAC5D;AACA,gBAAgB,KAAK;AACrB;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA,mBAAmB,qBAAqB;AACxC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E;AAC1E,6CAA6C;AAC7C,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,iDAAiD;AACjD,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kEAAkE;AAClE,wCAAwC;AACxC,YAAY;AACZ,OAAO;AACP;AACA,sEAAsE;AACtE,wCAAwC;AACxC,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA,iEAAiE;AACjE,qCAAqC;AACrC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,OAAO;AACP;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA,eAAe;AACf;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,8FAA8F;AAC9F;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,6BAA6B;AAC7B,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA,oDAAoD;AACpD;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA,kBAAkB,KAAK;AACvB;AACA,kBAAkB;AAClB,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;;AAEA;AACA,oEAAoE;AACpE;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA,kBAAkB,KAAK;AACvB;AACA,kBAAkB;AAClB,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA,qCAAqC;AACrC;AACA,gBAAgB,2BAA2B;AAC3C;AACA,gBAAgB;AAChB,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,4DAA4D;;AAE5D;AACA;AACA,KAAK;AACL,wCAAwC;AACxC;AACA;AACA;AACA;AACA,6CAA6C;AAC7C;AACA;AACA;AACA;AACA,aAAa,oBAAoB;AACjC,yCAAyC;AACzC;;AAEA;AACA,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,4BAA4B,+BAA+B,kBAAkB;AAC7E,+CAA+C;AAC/C;AACA,QAAQ;AACR;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wCAAwC;AACxC;AACA;AACA;AACA;AACA,2DAA2D;AAC3D,gCAAgC;AAChC;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,oEAAoE;AACpE,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,+DAA+D;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,2CAA2C;AAC3C;AACA;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,8CAA8C;AAC9C;AACA;;AAEA;AACA,6CAA6C;AAC7C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA,KAAK;;AAEL;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wCAAwC;AACxC,6CAA6C;AAC7C;;AAEA,6DAA6D;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,0CAA0C;;AAE1C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,0BAA0B;AAC/C;AACA;AACA;AACA,iDAAiD;AACjD;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA,kDAAkD;AAClD;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;;AAEA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B,kCAAkC,KAAK;AACvC,mCAAmC;AACnC,iDAAiD;AACjD;AACA;AACA,2DAA2D;AAC3D;AACA,YAAY;AACZ,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA,oEAAoE;AACpE,aAAa;AACb;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA,cAAc;AACd,SAAS;AACT;AACA;AACA;AACA,qBAAqB;AACrB,mDAAmD;AACnD;AACA,4CAA4C;AAC5C;AACA,cAAc;AACd;AACA;AACA,OAAO;;AAEP;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,2BAA2B;AAC1C;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,mBAAmB,EAAE;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,yCAAyC,QAAQ;AACjD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C,IAAI;AAClD,2DAA2D,IAAI;;AAE/D;AACA,4BAA4B;AAC5B;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA,uDAAuD;AACvD,yDAAyD;AACzD,6DAA6D;AAC7D;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,qBAAqB,UAAU;AAC/B;AACA;AACA;AACA,SAAS;AACT,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B;AACA;AACA,WAAW;AACX;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B;;AAE7B;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;;AAEA;AACA;;AAEA;;AAEA,CAAC;AACD;;;;;;;AC9xSA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;AC5CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,GAAG;AACH,oBAAoB,SAAS;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;AC7SA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;;AAEA;AACA;AACA;AACA,eAAe,QAAQ;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,qBAAqB;AACpC,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB;AACjB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA,8CAA8C,EAAE;AAChD;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ;AACxB,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB,iBAAiB;AACpC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,MAAM;AACzB,mBAAmB,aAAa;AAChC,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,uCAAuC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B,mBAAmB,MAAM;AACzB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,MAAM;AACzB,mBAAmB,MAAM;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;;AAEA;AACA,uBAAuB,sBAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,MAAM;AACzB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,MAAM;AACzB,mBAAmB,SAAS;AAC5B,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,MAAM;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,SAAS;AAC5B,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,mDAAmD,kBAAkB;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;AACA;AACA,mBAAmB,MAAM;AACzB,mBAAmB,SAAS;AAC5B,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA,2BAA2B,yBAAyB;AACpD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,uDAAuD;AACvD;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB,gBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AAAA;AACT;AACA,CAAC;;;;;;;;ACnhCD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,EAAE;AACH;AACA;AACA,0BAA0B,kBAAkB,EAAE;AAC9C,+BAA+B,mBAAmB,EAAE;AACpD;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,gDAAgD,wBAAwB,EAAE;AAC1E;AACA;AACA;AACA;AACA,6BAA6B,cAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,oCAAoC,EAAE;AACtE,iCAAiC,mCAAmC,EAAE;AACtE;AACA;AACA;AACA;AACA;AACA,wBAAwB,uBAAuB;AAC/C;AACA;AACA;AACA,KAAK,gBAAgB;AACrB;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK,KAAK;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,aAAa;AAC3C,gCAAgC,aAAa;AAC7C,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;;;;;;;AC5MA,wB;;;;;;ACAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,aAAa;AAC9B,iBAAiB,YAAY;;AAE7B;AACA;;AAEA;AACA;;AAEA,mBAAmB,OAAO;AAC1B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,CAAC;AACD;AACA,mBAAmB,oBAAoB;AACvC,mBAAmB,sBAAsB,EAAE;;;;;;;;AChH3C;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,aAAa,mBAAmB;AAChC;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,cAAc;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA,qEAAqE,kCAAkC,EAAE;;AAEzG;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;;AAEF;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,gBAAgB,YAAY;AAC5B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC9dA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA,yBAAyB,IAAI;AAC7B,wBAAwB,EAAE,WAAW,EAAE;AACvC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,EAAE;AACF;AACA;;AAEA,YAAY,OAAO;AACnB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;ACxOA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA,mCAAmC,SAAS;AAC5C;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;AC5BA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACVA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,wDAAwD,uCAAuC;AAC/F,sDAAsD,qCAAqC;;AAE3F;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;AACF,CAAC;;AAED;;;;;;;AC7EA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB;;AAEzB;;AAEA;AACA;AACA;;AAEA,yCAAyC,SAAS;AAClD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,qCAAqC,SAAS;AAC9C;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,gDAAgD,oCAAoC;AACpF,gDAAgD,oCAAoC;;AAEpF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uBAAuB,QAAQ;AAC/B;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA,SAAS;;AAET;AACA;AACA,uCAAuC,qCAAqC;AAC5E,aAAa;AACb;AACA,2BAA2B,WAAW;AACtC,+BAA+B,WAAW;AAC1C;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD;AACvD,6CAA6C,mBAAmB,6BAA6B;;AAE7F,uBAAuB,4BAA4B;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,CAAC,I;;;;;;ACtMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,2BAA2B,sBAAsB;AACjD,+BAA+B,yBAAyB;AACxD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,+BAA+B;AAC/B;AACA,6DAA6D;AAC7D;AACA,6DAA6D;AAC7D;AACA,6DAA6D;AAC7D;AACA,6DAA6D;AAC7D;AACA,gEAAgE;;AAEhE;AACA;AACA;;AAEA;;AAEA;AACA,2BAA2B,sBAAsB;AACjD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,2BAA2B,+BAA+B;AAC1D;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B,SAAS;AACpC;AACA,+BAA+B,OAAO;AACtC;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,SAAS,EAAE,OAAO,oCAAoC;AACxF,kCAAkC,SAAS,EAAE,OAAO,gBAAgB;AACpE;AACA,iBAAiB;AACjB;AACA;;AAEA;AACA;;AAEA;AACA,iCAAiC;AACjC,gCAAgC;AAChC;AACA;AACA;;AAEA,+BAA+B,iBAAiB;AAChD,oCAAoC,gBAAgB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mCAAmC,YAAY;AAC/C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK,I;;;;;;;ACrNL;AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA","file":"scripts/dist/bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 8);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 511c53b79451de123aa5","var convert = require('color-convert');\n\nmodule.exports = function (cstr) {\n var m, conv, parts, alpha;\n if (m = /^((?:rgb|hs[lv]|cmyk|xyz|lab)a?)\\s*\\(([^\\)]*)\\)/.exec(cstr)) {\n var name = m[1];\n var base = name.replace(/a$/, '');\n var size = base === 'cmyk' ? 4 : 3;\n conv = convert[base];\n \n parts = m[2].replace(/^\\s+|\\s+$/g, '')\n .split(/\\s*,\\s*/)\n .map(function (x, i) {\n if (/%$/.test(x) && i === size) {\n return parseFloat(x) / 100;\n }\n else if (/%$/.test(x)) {\n return parseFloat(x);\n }\n return parseFloat(x);\n })\n ;\n if (name === base) parts.push(1);\n alpha = parts[size] === undefined ? 1 : parts[size];\n parts = parts.slice(0, size);\n \n conv[base] = function () { return parts };\n }\n else if (/^#[A-Fa-f0-9]+$/.test(cstr)) {\n var base = cstr.replace(/^#/,'');\n var size = base.length;\n conv = convert.rgb;\n parts = base.split(size === 3 ? /(.)/ : /(..)/);\n parts = parts.filter(Boolean)\n .map(function (x) {\n if (size === 3) {\n return parseInt(x + x, 16);\n }\n else {\n return parseInt(x, 16)\n }\n })\n ;\n alpha = 1;\n conv.rgb = function () { return parts };\n if (!parts[0]) parts[0] = 0;\n if (!parts[1]) parts[1] = 0;\n if (!parts[2]) parts[2] = 0;\n }\n else {\n conv = convert.keyword;\n conv.keyword = function () { return cstr };\n parts = cstr;\n alpha = 1;\n }\n \n var res = {\n rgb: undefined,\n hsl: undefined,\n hsv: undefined,\n cmyk: undefined,\n keyword: undefined,\n hex: undefined\n };\n try { res.rgb = conv.rgb(parts) } catch (e) {}\n try { res.hsl = conv.hsl(parts) } catch (e) {}\n try { res.hsv = conv.hsv(parts) } catch (e) {}\n try { res.cmyk = conv.cmyk(parts) } catch (e) {}\n try { res.keyword = conv.keyword(parts) } catch (e) {}\n \n if (res.rgb) res.hex = '#' + res.rgb.map(function (x) {\n var s = x.toString(16);\n if (s.length === 1) return '0' + s;\n return s;\n }).join('');\n \n if (res.rgb) res.rgba = res.rgb.concat(alpha);\n if (res.hsl) res.hsla = res.hsl.concat(alpha);\n if (res.hsv) res.hsva = res.hsv.concat(alpha);\n if (res.cmyk) res.cmyka = res.cmyk.concat(alpha);\n \n return res;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/parse-color/index.js\n// module id = 1\n// module chunks = 0","/*!\n * is-number <https://github.com/jonschlinkert/is-number>\n *\n * Copyright (c) 2014-2015, Jon Schlinkert.\n * Licensed under the MIT License.\n */\n\n'use strict';\n\nvar typeOf = require('kind-of');\n\nmodule.exports = function isNumber(num) {\n var type = typeOf(num);\n if (type !== 'number' && type !== 'string') {\n return false;\n }\n var n = +num;\n return (n - n + 1) >= 0 && num !== '';\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/is-number/index.js\n// module id = 2\n// module chunks = 0","'use strict';\n\nvar strValue = String.prototype.valueOf;\nvar tryStringObject = function tryStringObject(value) {\n\ttry {\n\t\tstrValue.call(value);\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n};\nvar toStr = Object.prototype.toString;\nvar strClass = '[object String]';\nvar hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';\n\nmodule.exports = function isString(value) {\n\tif (typeof value === 'string') { return true; }\n\tif (typeof value !== 'object') { return false; }\n\treturn hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/is-string/index.js\n// module id = 3\n// module chunks = 0","\n/**\n * isArray\n */\n\nvar isArray = Array.isArray;\n\n/**\n * toString\n */\n\nvar str = Object.prototype.toString;\n\n/**\n * Whether or not the given `val`\n * is an array.\n *\n * example:\n *\n * isArray([]);\n * // > true\n * isArray(arguments);\n * // > false\n * isArray('');\n * // > false\n *\n * @param {mixed} val\n * @return {bool}\n */\n\nmodule.exports = isArray || function (val) {\n return !! val && '[object Array]' == str.call(val);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/is-array/index.js\n// module id = 4\n// module chunks = 0","/*\n * JavaScript MD5\n * https://github.com/blueimp/JavaScript-MD5\n *\n * Copyright 2011, Sebastian Tschan\n * https://blueimp.net\n *\n * Licensed under the MIT license:\n * https://opensource.org/licenses/MIT\n *\n * Based on\n * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message\n * Digest Algorithm, as defined in RFC 1321.\n * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for more info.\n */\n\n/* global define */\n\n;(function ($) {\n 'use strict'\n\n /*\n * Add integers, wrapping at 2^32. This uses 16-bit operations internally\n * to work around bugs in some JS interpreters.\n */\n function safeAdd (x, y) {\n var lsw = (x & 0xFFFF) + (y & 0xFFFF)\n var msw = (x >> 16) + (y >> 16) + (lsw >> 16)\n return (msw << 16) | (lsw & 0xFFFF)\n }\n\n /*\n * Bitwise rotate a 32-bit number to the left.\n */\n function bitRotateLeft (num, cnt) {\n return (num << cnt) | (num >>> (32 - cnt))\n }\n\n /*\n * These functions implement the four basic operations the algorithm uses.\n */\n function md5cmn (q, a, b, x, s, t) {\n return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)\n }\n function md5ff (a, b, c, d, x, s, t) {\n return md5cmn((b & c) | ((~b) & d), a, b, x, s, t)\n }\n function md5gg (a, b, c, d, x, s, t) {\n return md5cmn((b & d) | (c & (~d)), a, b, x, s, t)\n }\n function md5hh (a, b, c, d, x, s, t) {\n return md5cmn(b ^ c ^ d, a, b, x, s, t)\n }\n function md5ii (a, b, c, d, x, s, t) {\n return md5cmn(c ^ (b | (~d)), a, b, x, s, t)\n }\n\n /*\n * Calculate the MD5 of an array of little-endian words, and a bit length.\n */\n function binlMD5 (x, len) {\n /* append padding */\n x[len >> 5] |= 0x80 << (len % 32)\n x[(((len + 64) >>> 9) << 4) + 14] = len\n\n var i\n var olda\n var oldb\n var oldc\n var oldd\n var a = 1732584193\n var b = -271733879\n var c = -1732584194\n var d = 271733878\n\n for (i = 0; i < x.length; i += 16) {\n olda = a\n oldb = b\n oldc = c\n oldd = d\n\n a = md5ff(a, b, c, d, x[i], 7, -680876936)\n d = md5ff(d, a, b, c, x[i + 1], 12, -389564586)\n c = md5ff(c, d, a, b, x[i + 2], 17, 606105819)\n b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330)\n a = md5ff(a, b, c, d, x[i + 4], 7, -176418897)\n d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426)\n c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341)\n b = md5ff(b, c, d, a, x[i + 7], 22, -45705983)\n a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416)\n d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417)\n c = md5ff(c, d, a, b, x[i + 10], 17, -42063)\n b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162)\n a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682)\n d = md5ff(d, a, b, c, x[i + 13], 12, -40341101)\n c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290)\n b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329)\n\n a = md5gg(a, b, c, d, x[i + 1], 5, -165796510)\n d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632)\n c = md5gg(c, d, a, b, x[i + 11], 14, 643717713)\n b = md5gg(b, c, d, a, x[i], 20, -373897302)\n a = md5gg(a, b, c, d, x[i + 5], 5, -701558691)\n d = md5gg(d, a, b, c, x[i + 10], 9, 38016083)\n c = md5gg(c, d, a, b, x[i + 15], 14, -660478335)\n b = md5gg(b, c, d, a, x[i + 4], 20, -405537848)\n a = md5gg(a, b, c, d, x[i + 9], 5, 568446438)\n d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690)\n c = md5gg(c, d, a, b, x[i + 3], 14, -187363961)\n b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501)\n a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467)\n d = md5gg(d, a, b, c, x[i + 2], 9, -51403784)\n c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473)\n b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734)\n\n a = md5hh(a, b, c, d, x[i + 5], 4, -378558)\n d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463)\n c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562)\n b = md5hh(b, c, d, a, x[i + 14], 23, -35309556)\n a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060)\n d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353)\n c = md5hh(c, d, a, b, x[i + 7], 16, -155497632)\n b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640)\n a = md5hh(a, b, c, d, x[i + 13], 4, 681279174)\n d = md5hh(d, a, b, c, x[i], 11, -358537222)\n c = md5hh(c, d, a, b, x[i + 3], 16, -722521979)\n b = md5hh(b, c, d, a, x[i + 6], 23, 76029189)\n a = md5hh(a, b, c, d, x[i + 9], 4, -640364487)\n d = md5hh(d, a, b, c, x[i + 12], 11, -421815835)\n c = md5hh(c, d, a, b, x[i + 15], 16, 530742520)\n b = md5hh(b, c, d, a, x[i + 2], 23, -995338651)\n\n a = md5ii(a, b, c, d, x[i], 6, -198630844)\n d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415)\n c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905)\n b = md5ii(b, c, d, a, x[i + 5], 21, -57434055)\n a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571)\n d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606)\n c = md5ii(c, d, a, b, x[i + 10], 15, -1051523)\n b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799)\n a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359)\n d = md5ii(d, a, b, c, x[i + 15], 10, -30611744)\n c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380)\n b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649)\n a = md5ii(a, b, c, d, x[i + 4], 6, -145523070)\n d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379)\n c = md5ii(c, d, a, b, x[i + 2], 15, 718787259)\n b = md5ii(b, c, d, a, x[i + 9], 21, -343485551)\n\n a = safeAdd(a, olda)\n b = safeAdd(b, oldb)\n c = safeAdd(c, oldc)\n d = safeAdd(d, oldd)\n }\n return [a, b, c, d]\n }\n\n /*\n * Convert an array of little-endian words to a string\n */\n function binl2rstr (input) {\n var i\n var output = ''\n var length32 = input.length * 32\n for (i = 0; i < length32; i += 8) {\n output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF)\n }\n return output\n }\n\n /*\n * Convert a raw string to an array of little-endian words\n * Characters >255 have their high-byte silently ignored.\n */\n function rstr2binl (input) {\n var i\n var output = []\n output[(input.length >> 2) - 1] = undefined\n for (i = 0; i < output.length; i += 1) {\n output[i] = 0\n }\n var length8 = input.length * 8\n for (i = 0; i < length8; i += 8) {\n output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32)\n }\n return output\n }\n\n /*\n * Calculate the MD5 of a raw string\n */\n function rstrMD5 (s) {\n return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))\n }\n\n /*\n * Calculate the HMAC-MD5, of a key and some data (raw strings)\n */\n function rstrHMACMD5 (key, data) {\n var i\n var bkey = rstr2binl(key)\n var ipad = []\n var opad = []\n var hash\n ipad[15] = opad[15] = undefined\n if (bkey.length > 16) {\n bkey = binlMD5(bkey, key.length * 8)\n }\n for (i = 0; i < 16; i += 1) {\n ipad[i] = bkey[i] ^ 0x36363636\n opad[i] = bkey[i] ^ 0x5C5C5C5C\n }\n hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8)\n return binl2rstr(binlMD5(opad.concat(hash), 512 + 128))\n }\n\n /*\n * Convert a raw string to a hex string\n */\n function rstr2hex (input) {\n var hexTab = '0123456789abcdef'\n var output = ''\n var x\n var i\n for (i = 0; i < input.length; i += 1) {\n x = input.charCodeAt(i)\n output += hexTab.charAt((x >>> 4) & 0x0F) +\n hexTab.charAt(x & 0x0F)\n }\n return output\n }\n\n /*\n * Encode a string as utf-8\n */\n function str2rstrUTF8 (input) {\n return unescape(encodeURIComponent(input))\n }\n\n /*\n * Take string arguments and return either raw or hex encoded strings\n */\n function rawMD5 (s) {\n return rstrMD5(str2rstrUTF8(s))\n }\n function hexMD5 (s) {\n return rstr2hex(rawMD5(s))\n }\n function rawHMACMD5 (k, d) {\n return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d))\n }\n function hexHMACMD5 (k, d) {\n return rstr2hex(rawHMACMD5(k, d))\n }\n\n function md5 (string, key, raw) {\n if (!key) {\n if (!raw) {\n return hexMD5(string)\n }\n return rawMD5(string)\n }\n if (!raw) {\n return hexHMACMD5(key, string)\n }\n return rawHMACMD5(key, string)\n }\n\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return md5\n })\n } else if (typeof module === 'object' && module.exports) {\n module.exports = md5\n } else {\n $.md5 = md5\n }\n}(this))\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/md5.js\n// module id = 5\n// module chunks = 0","module.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/color-name/index.js\n// module id = 6\n// module chunks = 0","/* MIT license */\nvar cssKeywords = require('color-name');\n\n// NOTE: conversions should only return primitive values (i.e. arrays, or\n// values that give correct `typeof` results).\n// do not use box values types (i.e. Number(), String(), etc.)\n\nvar reverseKeywords = {};\nfor (var key in cssKeywords) {\n\tif (cssKeywords.hasOwnProperty(key)) {\n\t\treverseKeywords[cssKeywords[key]] = key;\n\t}\n}\n\nvar convert = module.exports = {\n\trgb: {channels: 3, labels: 'rgb'},\n\thsl: {channels: 3, labels: 'hsl'},\n\thsv: {channels: 3, labels: 'hsv'},\n\thwb: {channels: 3, labels: 'hwb'},\n\tcmyk: {channels: 4, labels: 'cmyk'},\n\txyz: {channels: 3, labels: 'xyz'},\n\tlab: {channels: 3, labels: 'lab'},\n\tlch: {channels: 3, labels: 'lch'},\n\thex: {channels: 1, labels: ['hex']},\n\tkeyword: {channels: 1, labels: ['keyword']},\n\tansi16: {channels: 1, labels: ['ansi16']},\n\tansi256: {channels: 1, labels: ['ansi256']},\n\thcg: {channels: 3, labels: ['h', 'c', 'g']},\n\tapple: {channels: 3, labels: ['r16', 'g16', 'b16']},\n\tgray: {channels: 1, labels: ['gray']}\n};\n\n// hide .channels and .labels properties\nfor (var model in convert) {\n\tif (convert.hasOwnProperty(model)) {\n\t\tif (!('channels' in convert[model])) {\n\t\t\tthrow new Error('missing channels property: ' + model);\n\t\t}\n\n\t\tif (!('labels' in convert[model])) {\n\t\t\tthrow new Error('missing channel labels property: ' + model);\n\t\t}\n\n\t\tif (convert[model].labels.length !== convert[model].channels) {\n\t\t\tthrow new Error('channel and label counts mismatch: ' + model);\n\t\t}\n\n\t\tvar channels = convert[model].channels;\n\t\tvar labels = convert[model].labels;\n\t\tdelete convert[model].channels;\n\t\tdelete convert[model].labels;\n\t\tObject.defineProperty(convert[model], 'channels', {value: channels});\n\t\tObject.defineProperty(convert[model], 'labels', {value: labels});\n\t}\n}\n\nconvert.rgb.hsl = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar min = Math.min(r, g, b);\n\tvar max = Math.max(r, g, b);\n\tvar delta = max - min;\n\tvar h;\n\tvar s;\n\tvar l;\n\n\tif (max === min) {\n\t\th = 0;\n\t} else if (r === max) {\n\t\th = (g - b) / delta;\n\t} else if (g === max) {\n\t\th = 2 + (b - r) / delta;\n\t} else if (b === max) {\n\t\th = 4 + (r - g) / delta;\n\t}\n\n\th = Math.min(h * 60, 360);\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tl = (min + max) / 2;\n\n\tif (max === min) {\n\t\ts = 0;\n\t} else if (l <= 0.5) {\n\t\ts = delta / (max + min);\n\t} else {\n\t\ts = delta / (2 - max - min);\n\t}\n\n\treturn [h, s * 100, l * 100];\n};\n\nconvert.rgb.hsv = function (rgb) {\n\tvar r = rgb[0];\n\tvar g = rgb[1];\n\tvar b = rgb[2];\n\tvar min = Math.min(r, g, b);\n\tvar max = Math.max(r, g, b);\n\tvar delta = max - min;\n\tvar h;\n\tvar s;\n\tvar v;\n\n\tif (max === 0) {\n\t\ts = 0;\n\t} else {\n\t\ts = (delta / max * 1000) / 10;\n\t}\n\n\tif (max === min) {\n\t\th = 0;\n\t} else if (r === max) {\n\t\th = (g - b) / delta;\n\t} else if (g === max) {\n\t\th = 2 + (b - r) / delta;\n\t} else if (b === max) {\n\t\th = 4 + (r - g) / delta;\n\t}\n\n\th = Math.min(h * 60, 360);\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tv = ((max / 255) * 1000) / 10;\n\n\treturn [h, s, v];\n};\n\nconvert.rgb.hwb = function (rgb) {\n\tvar r = rgb[0];\n\tvar g = rgb[1];\n\tvar b = rgb[2];\n\tvar h = convert.rgb.hsl(rgb)[0];\n\tvar w = 1 / 255 * Math.min(r, Math.min(g, b));\n\n\tb = 1 - 1 / 255 * Math.max(r, Math.max(g, b));\n\n\treturn [h, w * 100, b * 100];\n};\n\nconvert.rgb.cmyk = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar c;\n\tvar m;\n\tvar y;\n\tvar k;\n\n\tk = Math.min(1 - r, 1 - g, 1 - b);\n\tc = (1 - r - k) / (1 - k) || 0;\n\tm = (1 - g - k) / (1 - k) || 0;\n\ty = (1 - b - k) / (1 - k) || 0;\n\n\treturn [c * 100, m * 100, y * 100, k * 100];\n};\n\n/**\n * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance\n * */\nfunction comparativeDistance(x, y) {\n\treturn (\n\t\tMath.pow(x[0] - y[0], 2) +\n\t\tMath.pow(x[1] - y[1], 2) +\n\t\tMath.pow(x[2] - y[2], 2)\n\t);\n}\n\nconvert.rgb.keyword = function (rgb) {\n\tvar reversed = reverseKeywords[rgb];\n\tif (reversed) {\n\t\treturn reversed;\n\t}\n\n\tvar currentClosestDistance = Infinity;\n\tvar currentClosestKeyword;\n\n\tfor (var keyword in cssKeywords) {\n\t\tif (cssKeywords.hasOwnProperty(keyword)) {\n\t\t\tvar value = cssKeywords[keyword];\n\n\t\t\t// Compute comparative distance\n\t\t\tvar distance = comparativeDistance(rgb, value);\n\n\t\t\t// Check if its less, if so set as closest\n\t\t\tif (distance < currentClosestDistance) {\n\t\t\t\tcurrentClosestDistance = distance;\n\t\t\t\tcurrentClosestKeyword = keyword;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn currentClosestKeyword;\n};\n\nconvert.keyword.rgb = function (keyword) {\n\treturn cssKeywords[keyword];\n};\n\nconvert.rgb.xyz = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\n\t// assume sRGB\n\tr = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n\tvar x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n\tvar y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n\tvar z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n\n\treturn [x * 100, y * 100, z * 100];\n};\n\nconvert.rgb.lab = function (rgb) {\n\tvar xyz = convert.rgb.xyz(rgb);\n\tvar x = xyz[0];\n\tvar y = xyz[1];\n\tvar z = xyz[2];\n\tvar l;\n\tvar a;\n\tvar b;\n\n\tx /= 95.047;\n\ty /= 100;\n\tz /= 108.883;\n\n\tx = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);\n\ty = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);\n\tz = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);\n\n\tl = (116 * y) - 16;\n\ta = 500 * (x - y);\n\tb = 200 * (y - z);\n\n\treturn [l, a, b];\n};\n\nconvert.hsl.rgb = function (hsl) {\n\tvar h = hsl[0] / 360;\n\tvar s = hsl[1] / 100;\n\tvar l = hsl[2] / 100;\n\tvar t1;\n\tvar t2;\n\tvar t3;\n\tvar rgb;\n\tvar val;\n\n\tif (s === 0) {\n\t\tval = l * 255;\n\t\treturn [val, val, val];\n\t}\n\n\tif (l < 0.5) {\n\t\tt2 = l * (1 + s);\n\t} else {\n\t\tt2 = l + s - l * s;\n\t}\n\n\tt1 = 2 * l - t2;\n\n\trgb = [0, 0, 0];\n\tfor (var i = 0; i < 3; i++) {\n\t\tt3 = h + 1 / 3 * -(i - 1);\n\t\tif (t3 < 0) {\n\t\t\tt3++;\n\t\t}\n\t\tif (t3 > 1) {\n\t\t\tt3--;\n\t\t}\n\n\t\tif (6 * t3 < 1) {\n\t\t\tval = t1 + (t2 - t1) * 6 * t3;\n\t\t} else if (2 * t3 < 1) {\n\t\t\tval = t2;\n\t\t} else if (3 * t3 < 2) {\n\t\t\tval = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n\t\t} else {\n\t\t\tval = t1;\n\t\t}\n\n\t\trgb[i] = val * 255;\n\t}\n\n\treturn rgb;\n};\n\nconvert.hsl.hsv = function (hsl) {\n\tvar h = hsl[0];\n\tvar s = hsl[1] / 100;\n\tvar l = hsl[2] / 100;\n\tvar smin = s;\n\tvar lmin = Math.max(l, 0.01);\n\tvar sv;\n\tvar v;\n\n\tl *= 2;\n\ts *= (l <= 1) ? l : 2 - l;\n\tsmin *= lmin <= 1 ? lmin : 2 - lmin;\n\tv = (l + s) / 2;\n\tsv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);\n\n\treturn [h, sv * 100, v * 100];\n};\n\nconvert.hsv.rgb = function (hsv) {\n\tvar h = hsv[0] / 60;\n\tvar s = hsv[1] / 100;\n\tvar v = hsv[2] / 100;\n\tvar hi = Math.floor(h) % 6;\n\n\tvar f = h - Math.floor(h);\n\tvar p = 255 * v * (1 - s);\n\tvar q = 255 * v * (1 - (s * f));\n\tvar t = 255 * v * (1 - (s * (1 - f)));\n\tv *= 255;\n\n\tswitch (hi) {\n\t\tcase 0:\n\t\t\treturn [v, t, p];\n\t\tcase 1:\n\t\t\treturn [q, v, p];\n\t\tcase 2:\n\t\t\treturn [p, v, t];\n\t\tcase 3:\n\t\t\treturn [p, q, v];\n\t\tcase 4:\n\t\t\treturn [t, p, v];\n\t\tcase 5:\n\t\t\treturn [v, p, q];\n\t}\n};\n\nconvert.hsv.hsl = function (hsv) {\n\tvar h = hsv[0];\n\tvar s = hsv[1] / 100;\n\tvar v = hsv[2] / 100;\n\tvar vmin = Math.max(v, 0.01);\n\tvar lmin;\n\tvar sl;\n\tvar l;\n\n\tl = (2 - s) * v;\n\tlmin = (2 - s) * vmin;\n\tsl = s * vmin;\n\tsl /= (lmin <= 1) ? lmin : 2 - lmin;\n\tsl = sl || 0;\n\tl /= 2;\n\n\treturn [h, sl * 100, l * 100];\n};\n\n// http://dev.w3.org/csswg/css-color/#hwb-to-rgb\nconvert.hwb.rgb = function (hwb) {\n\tvar h = hwb[0] / 360;\n\tvar wh = hwb[1] / 100;\n\tvar bl = hwb[2] / 100;\n\tvar ratio = wh + bl;\n\tvar i;\n\tvar v;\n\tvar f;\n\tvar n;\n\n\t// wh + bl cant be > 1\n\tif (ratio > 1) {\n\t\twh /= ratio;\n\t\tbl /= ratio;\n\t}\n\n\ti = Math.floor(6 * h);\n\tv = 1 - bl;\n\tf = 6 * h - i;\n\n\tif ((i & 0x01) !== 0) {\n\t\tf = 1 - f;\n\t}\n\n\tn = wh + f * (v - wh); // linear interpolation\n\n\tvar r;\n\tvar g;\n\tvar b;\n\tswitch (i) {\n\t\tdefault:\n\t\tcase 6:\n\t\tcase 0: r = v; g = n; b = wh; break;\n\t\tcase 1: r = n; g = v; b = wh; break;\n\t\tcase 2: r = wh; g = v; b = n; break;\n\t\tcase 3: r = wh; g = n; b = v; break;\n\t\tcase 4: r = n; g = wh; b = v; break;\n\t\tcase 5: r = v; g = wh; b = n; break;\n\t}\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.cmyk.rgb = function (cmyk) {\n\tvar c = cmyk[0] / 100;\n\tvar m = cmyk[1] / 100;\n\tvar y = cmyk[2] / 100;\n\tvar k = cmyk[3] / 100;\n\tvar r;\n\tvar g;\n\tvar b;\n\n\tr = 1 - Math.min(1, c * (1 - k) + k);\n\tg = 1 - Math.min(1, m * (1 - k) + k);\n\tb = 1 - Math.min(1, y * (1 - k) + k);\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.xyz.rgb = function (xyz) {\n\tvar x = xyz[0] / 100;\n\tvar y = xyz[1] / 100;\n\tvar z = xyz[2] / 100;\n\tvar r;\n\tvar g;\n\tvar b;\n\n\tr = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n\tg = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n\tb = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n\t// assume sRGB\n\tr = r > 0.0031308\n\t\t? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)\n\t\t: r * 12.92;\n\n\tg = g > 0.0031308\n\t\t? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)\n\t\t: g * 12.92;\n\n\tb = b > 0.0031308\n\t\t? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)\n\t\t: b * 12.92;\n\n\tr = Math.min(Math.max(0, r), 1);\n\tg = Math.min(Math.max(0, g), 1);\n\tb = Math.min(Math.max(0, b), 1);\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.xyz.lab = function (xyz) {\n\tvar x = xyz[0];\n\tvar y = xyz[1];\n\tvar z = xyz[2];\n\tvar l;\n\tvar a;\n\tvar b;\n\n\tx /= 95.047;\n\ty /= 100;\n\tz /= 108.883;\n\n\tx = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);\n\ty = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);\n\tz = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);\n\n\tl = (116 * y) - 16;\n\ta = 500 * (x - y);\n\tb = 200 * (y - z);\n\n\treturn [l, a, b];\n};\n\nconvert.lab.xyz = function (lab) {\n\tvar l = lab[0];\n\tvar a = lab[1];\n\tvar b = lab[2];\n\tvar x;\n\tvar y;\n\tvar z;\n\n\ty = (l + 16) / 116;\n\tx = a / 500 + y;\n\tz = y - b / 200;\n\n\tvar y2 = Math.pow(y, 3);\n\tvar x2 = Math.pow(x, 3);\n\tvar z2 = Math.pow(z, 3);\n\ty = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;\n\tx = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;\n\tz = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;\n\n\tx *= 95.047;\n\ty *= 100;\n\tz *= 108.883;\n\n\treturn [x, y, z];\n};\n\nconvert.lab.lch = function (lab) {\n\tvar l = lab[0];\n\tvar a = lab[1];\n\tvar b = lab[2];\n\tvar hr;\n\tvar h;\n\tvar c;\n\n\thr = Math.atan2(b, a);\n\th = hr * 360 / 2 / Math.PI;\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tc = Math.sqrt(a * a + b * b);\n\n\treturn [l, c, h];\n};\n\nconvert.lch.lab = function (lch) {\n\tvar l = lch[0];\n\tvar c = lch[1];\n\tvar h = lch[2];\n\tvar a;\n\tvar b;\n\tvar hr;\n\n\thr = h / 360 * 2 * Math.PI;\n\ta = c * Math.cos(hr);\n\tb = c * Math.sin(hr);\n\n\treturn [l, a, b];\n};\n\nconvert.rgb.ansi16 = function (args) {\n\tvar r = args[0];\n\tvar g = args[1];\n\tvar b = args[2];\n\tvar value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization\n\n\tvalue = Math.round(value / 50);\n\n\tif (value === 0) {\n\t\treturn 30;\n\t}\n\n\tvar ansi = 30\n\t\t+ ((Math.round(b / 255) << 2)\n\t\t| (Math.round(g / 255) << 1)\n\t\t| Math.round(r / 255));\n\n\tif (value === 2) {\n\t\tansi += 60;\n\t}\n\n\treturn ansi;\n};\n\nconvert.hsv.ansi16 = function (args) {\n\t// optimization here; we already know the value and don't need to get\n\t// it converted for us.\n\treturn convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);\n};\n\nconvert.rgb.ansi256 = function (args) {\n\tvar r = args[0];\n\tvar g = args[1];\n\tvar b = args[2];\n\n\t// we use the extended greyscale palette here, with the exception of\n\t// black and white. normal palette only has 4 greyscale shades.\n\tif (r === g && g === b) {\n\t\tif (r < 8) {\n\t\t\treturn 16;\n\t\t}\n\n\t\tif (r > 248) {\n\t\t\treturn 231;\n\t\t}\n\n\t\treturn Math.round(((r - 8) / 247) * 24) + 232;\n\t}\n\n\tvar ansi = 16\n\t\t+ (36 * Math.round(r / 255 * 5))\n\t\t+ (6 * Math.round(g / 255 * 5))\n\t\t+ Math.round(b / 255 * 5);\n\n\treturn ansi;\n};\n\nconvert.ansi16.rgb = function (args) {\n\tvar color = args % 10;\n\n\t// handle greyscale\n\tif (color === 0 || color === 7) {\n\t\tif (args > 50) {\n\t\t\tcolor += 3.5;\n\t\t}\n\n\t\tcolor = color / 10.5 * 255;\n\n\t\treturn [color, color, color];\n\t}\n\n\tvar mult = (~~(args > 50) + 1) * 0.5;\n\tvar r = ((color & 1) * mult) * 255;\n\tvar g = (((color >> 1) & 1) * mult) * 255;\n\tvar b = (((color >> 2) & 1) * mult) * 255;\n\n\treturn [r, g, b];\n};\n\nconvert.ansi256.rgb = function (args) {\n\t// handle greyscale\n\tif (args >= 232) {\n\t\tvar c = (args - 232) * 10 + 8;\n\t\treturn [c, c, c];\n\t}\n\n\targs -= 16;\n\n\tvar rem;\n\tvar r = Math.floor(args / 36) / 5 * 255;\n\tvar g = Math.floor((rem = args % 36) / 6) / 5 * 255;\n\tvar b = (rem % 6) / 5 * 255;\n\n\treturn [r, g, b];\n};\n\nconvert.rgb.hex = function (args) {\n\tvar integer = ((Math.round(args[0]) & 0xFF) << 16)\n\t\t+ ((Math.round(args[1]) & 0xFF) << 8)\n\t\t+ (Math.round(args[2]) & 0xFF);\n\n\tvar string = integer.toString(16).toUpperCase();\n\treturn '000000'.substring(string.length) + string;\n};\n\nconvert.hex.rgb = function (args) {\n\tvar match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);\n\tif (!match) {\n\t\treturn [0, 0, 0];\n\t}\n\n\tvar colorString = match[0];\n\n\tif (match[0].length === 3) {\n\t\tcolorString = colorString.split('').map(function (char) {\n\t\t\treturn char + char;\n\t\t}).join('');\n\t}\n\n\tvar integer = parseInt(colorString, 16);\n\tvar r = (integer >> 16) & 0xFF;\n\tvar g = (integer >> 8) & 0xFF;\n\tvar b = integer & 0xFF;\n\n\treturn [r, g, b];\n};\n\nconvert.rgb.hcg = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar max = Math.max(Math.max(r, g), b);\n\tvar min = Math.min(Math.min(r, g), b);\n\tvar chroma = (max - min);\n\tvar grayscale;\n\tvar hue;\n\n\tif (chroma < 1) {\n\t\tgrayscale = min / (1 - chroma);\n\t} else {\n\t\tgrayscale = 0;\n\t}\n\n\tif (chroma <= 0) {\n\t\thue = 0;\n\t} else\n\tif (max === r) {\n\t\thue = ((g - b) / chroma) % 6;\n\t} else\n\tif (max === g) {\n\t\thue = 2 + (b - r) / chroma;\n\t} else {\n\t\thue = 4 + (r - g) / chroma + 4;\n\t}\n\n\thue /= 6;\n\thue %= 1;\n\n\treturn [hue * 360, chroma * 100, grayscale * 100];\n};\n\nconvert.hsl.hcg = function (hsl) {\n\tvar s = hsl[1] / 100;\n\tvar l = hsl[2] / 100;\n\tvar c = 1;\n\tvar f = 0;\n\n\tif (l < 0.5) {\n\t\tc = 2.0 * s * l;\n\t} else {\n\t\tc = 2.0 * s * (1.0 - l);\n\t}\n\n\tif (c < 1.0) {\n\t\tf = (l - 0.5 * c) / (1.0 - c);\n\t}\n\n\treturn [hsl[0], c * 100, f * 100];\n};\n\nconvert.hsv.hcg = function (hsv) {\n\tvar s = hsv[1] / 100;\n\tvar v = hsv[2] / 100;\n\n\tvar c = s * v;\n\tvar f = 0;\n\n\tif (c < 1.0) {\n\t\tf = (v - c) / (1 - c);\n\t}\n\n\treturn [hsv[0], c * 100, f * 100];\n};\n\nconvert.hcg.rgb = function (hcg) {\n\tvar h = hcg[0] / 360;\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\n\tif (c === 0.0) {\n\t\treturn [g * 255, g * 255, g * 255];\n\t}\n\n\tvar pure = [0, 0, 0];\n\tvar hi = (h % 1) * 6;\n\tvar v = hi % 1;\n\tvar w = 1 - v;\n\tvar mg = 0;\n\n\tswitch (Math.floor(hi)) {\n\t\tcase 0:\n\t\t\tpure[0] = 1; pure[1] = v; pure[2] = 0; break;\n\t\tcase 1:\n\t\t\tpure[0] = w; pure[1] = 1; pure[2] = 0; break;\n\t\tcase 2:\n\t\t\tpure[0] = 0; pure[1] = 1; pure[2] = v; break;\n\t\tcase 3:\n\t\t\tpure[0] = 0; pure[1] = w; pure[2] = 1; break;\n\t\tcase 4:\n\t\t\tpure[0] = v; pure[1] = 0; pure[2] = 1; break;\n\t\tdefault:\n\t\t\tpure[0] = 1; pure[1] = 0; pure[2] = w;\n\t}\n\n\tmg = (1.0 - c) * g;\n\n\treturn [\n\t\t(c * pure[0] + mg) * 255,\n\t\t(c * pure[1] + mg) * 255,\n\t\t(c * pure[2] + mg) * 255\n\t];\n};\n\nconvert.hcg.hsv = function (hcg) {\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\n\tvar v = c + g * (1.0 - c);\n\tvar f = 0;\n\n\tif (v > 0.0) {\n\t\tf = c / v;\n\t}\n\n\treturn [hcg[0], f * 100, v * 100];\n};\n\nconvert.hcg.hsl = function (hcg) {\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\n\tvar l = g * (1.0 - c) + 0.5 * c;\n\tvar s = 0;\n\n\tif (l > 0.0 && l < 0.5) {\n\t\ts = c / (2 * l);\n\t} else\n\tif (l >= 0.5 && l < 1.0) {\n\t\ts = c / (2 * (1 - l));\n\t}\n\n\treturn [hcg[0], s * 100, l * 100];\n};\n\nconvert.hcg.hwb = function (hcg) {\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\tvar v = c + g * (1.0 - c);\n\treturn [hcg[0], (v - c) * 100, (1 - v) * 100];\n};\n\nconvert.hwb.hcg = function (hwb) {\n\tvar w = hwb[1] / 100;\n\tvar b = hwb[2] / 100;\n\tvar v = 1 - b;\n\tvar c = v - w;\n\tvar g = 0;\n\n\tif (c < 1) {\n\t\tg = (v - c) / (1 - c);\n\t}\n\n\treturn [hwb[0], c * 100, g * 100];\n};\n\nconvert.apple.rgb = function (apple) {\n\treturn [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];\n};\n\nconvert.rgb.apple = function (rgb) {\n\treturn [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];\n};\n\nconvert.gray.rgb = function (args) {\n\treturn [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];\n};\n\nconvert.gray.hsl = convert.gray.hsv = function (args) {\n\treturn [0, 0, args[0]];\n};\n\nconvert.gray.hwb = function (gray) {\n\treturn [0, 100, gray[0]];\n};\n\nconvert.gray.cmyk = function (gray) {\n\treturn [0, 0, 0, gray[0]];\n};\n\nconvert.gray.lab = function (gray) {\n\treturn [gray[0], 0, 0];\n};\n\nconvert.gray.hex = function (gray) {\n\tvar val = Math.round(gray[0] / 100 * 255) & 0xFF;\n\tvar integer = (val << 16) + (val << 8) + val;\n\n\tvar string = integer.toString(16).toUpperCase();\n\treturn '000000'.substring(string.length) + string;\n};\n\nconvert.rgb.gray = function (rgb) {\n\tvar val = (rgb[0] + rgb[1] + rgb[2]) / 3;\n\treturn [val / 255 * 100];\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/color-convert/conversions.js\n// module id = 7\n// module chunks = 0","/*global dallinger, require, settings */\n/*jshint esversion: 6 */\n\n(function (dallinger, require, settings) {\n\nvar grid = require(\"./index\");\nvar position = require(\"mouse-position\");\nvar Mousetrap = require(\"mousetrap\");\nvar ReconnectingWebSocket = require(\"reconnecting-websocket\");\nvar $ = require(\"jquery\");\nvar gaussian = require(\"gaussian\");\nvar Color = require('color');\nvar Identicon = require('./util/identicon');\nvar md5 = require('./util/md5');\nvar itemlib = require (\"./items\");\n\nfunction coordsToIdx(x, y, columns) {\n return y * columns + x;\n}\n\nfunction animateColor(color) {\n if (settings.background_animation) {\n rand = Math.random() * 0.02;\n } else {\n rand = 0.01;\n }\n return [\n color[0] * 0.95 + rand,\n color[1] * 0.95 + rand,\n color[2] * 0.95 + rand\n ];\n}\n\nfunction positionsAreEqual(a, b) {\n // Items with null positions are never co-located\n if (a === null || b === null) {\n return false;\n }\n return a[0] === b[0] && a[1] === b[1];\n}\n\nclass Section {\n // Represents the currently visible section (window) of the grid\n\n constructor(data, left, top) {\n this.left = left;\n this.top = top;\n this.columns = settings.window_columns;\n this.rows = settings.window_rows;\n this.data = [];\n this.textures = [];\n // build data array for just this section\n for (var j = 0; j < this.rows; j++) {\n for (var i = 0; i < this.columns; i++) {\n this.data.push(data[this.sectionCoordsToGridIdx(i, j)]);\n this.textures.push(0);\n }\n }\n }\n\n gridCoordsToSectionIdx(x, y) {\n // Convert grid coordinates to section data array index\n return (y - this.top) * this.columns + (x - this.left);\n }\n\n sectionCoordsToGridIdx(x, y) {\n // Convert section coordinates to grid data array index\n return coordsToIdx(this.left + x, this.top + y, settings.columns);\n }\n\n plot(x, y, color, texture) {\n // Set color at position (x, y) in full-grid coordinates.\n if (x >= this.left && x < this.left + this.columns) {\n if (y >= this.top && y < this.top + this.rows) {\n this.data[this.gridCoordsToSectionIdx(x, y)] = color;\n if (texture !== undefined ){\n this.textures[this.gridCoordsToSectionIdx(x, y)] = texture;\n }\n background[coordsToIdx(x, y, settings.columns)] = color;\n }\n }\n }\n\n map(func) {\n // For each cell, call func with (x, y, color) to get the new color\n for (var j = 0; j < this.rows; j++) {\n for (var i = 0; i < this.columns; i++) {\n var idx = coordsToIdx(i, j, this.columns);\n this.data[idx] = Reflect.apply(\n func, this, [this.left + i, this.top + j, this.data[idx]]);\n }\n }\n }\n}\n\nvar background = [], color;\nfor (var j = 0; j < settings.rows; j++) {\n for (var i = 0; i < settings.columns; i++) {\n color = [0, 0, 0];\n for (var k = 0; k < 15; k++) {\n color = animateColor(color);\n }\n background.push(color);\n }\n}\n\nvar initialSection = new Section(background, 0, 0);\n\nvar INVISIBLE_COLOR = [0.66, 0.66, 0.66];\nvar CHANNEL = \"griduniverse\";\nvar CONTROL_CHANNEL = \"griduniverse_ctrl\";\n\nvar pixels = grid(initialSection.data, initialSection.textures, {\n rows: settings.window_rows,\n columns: settings.window_columns,\n size: settings.block_size,\n padding: settings.padding,\n background: [0.1, 0.1, 0.1],\n formatted: true\n});\n\nvar mouse = position(pixels.canvas);\n\nvar isSpectator = false;\nvar start = performance.now();\nvar gridItems = new itemlib.GridItems();\nvar walls = [];\nvar wall_map = {};\nvar transitionsSeen = new Set();\nvar rand;\n\nvar name2idx = function (name) {\n var names = settings.player_color_names;\n for (var idx=0; idx < names.length; idx++) {\n if (names[idx] === name) {\n return idx;\n }\n }\n};\n\nvar color2idx = function (color) {\n var colors = settings.player_colors;\n var value = color.join(',');\n for (var idx=0; idx < colors.length; idx++) {\n if (colors[idx].join(',') === value) {\n return idx;\n }\n }\n};\n\nvar color2name = function (color) {\n var idx = color2idx(color);\n return settings.player_color_names[idx];\n}\n\n\nvar Wall = function (settings) {\n if (!(this instanceof Wall)) {\n return new Wall();\n }\n this.position = settings.position;\n this.color = settings.color;\n return this;\n};\n\nvar Player = function (settings, dimness) {\n if (!(this instanceof Player)) {\n return new Player();\n }\n this.id = settings.id;\n this.position = settings.position;\n this.positionInSync = true;\n this.color = settings.color;\n this.motion_auto = settings.motion_auto;\n this.motion_direction = settings.motion_direction;\n this.motion_speed_limit = settings.motion_speed_limit;\n this.motion_timestamp = settings.motion_timestamp;\n this.score = settings.score;\n this.payoff = settings.payoff;\n this.name = settings.name;\n this.identity_visible = settings.identity_visible;\n this.dimness = dimness;\n this.replaceItem(settings.current_item);\n return this;\n};\n\nPlayer.prototype.move = function(direction) {\n\n function _isCrossable(position) {\n const hasWall = ! _.isUndefined(wall_map[[position[1], position[0]]]);\n if (hasWall) {\n return false;\n }\n const itemHere = gridItems.atPosition(position);\n return _.isNull(itemHere) || itemHere.crossable;\n }\n\n this.motion_direction = direction;\n\n var ts = performance.now() - start,\n waitTime = 1000 / this.motion_speed_limit;\n\n if (ts > this.motion_timestamp + waitTime) {\n var newPosition = this.position.slice();\n\n switch (direction) {\n case \"up\":\n if (this.position[0] > 0) {\n newPosition[0] -= 1;\n }\n break;\n\n case \"down\":\n if (this.position[0] < settings.rows - 1) {\n newPosition[0] += 1;\n }\n break;\n\n case \"left\":\n if (this.position[1] > 0) {\n newPosition[1] -= 1;\n }\n break;\n\n case \"right\":\n if (this.position[1] < settings.columns - 1) {\n newPosition[1] += 1;\n }\n break;\n\n default:\n console.log(\"Direction not recognized.\");\n }\n\n if (_isCrossable(newPosition) && (!players.isPlayerAt(newPosition) || settings.player_overlap)) {\n this.position = newPosition;\n this.motion_timestamp = ts;\n return true;\n }\n }\n return false;\n};\n\n\nPlayer.prototype.replaceItem = function(item) {\n if (item && !(item instanceof itemlib.Item)) {\n item = new itemlib.Item(item.id, item.item_id, item.maturity, item.remaining_uses)\n }\n this.current_item = item;\n displayWhatEgoPlayerIsCarrying(item);\n};\n\nPlayer.prototype.getTransition = function () {\n var transition;\n var player_item = this.current_item;\n var position = this.position;\n var item_at_pos = gridItems.atPosition(position);\n var transition_id = (player_item && player_item.itemId || '') + '|' + (item_at_pos && item_at_pos.itemId || '');\n var last_transition_id = 'last_' + transition_id;\n if (item_at_pos && item_at_pos.remaining_uses == 1) {\n transition = settings.transition_config[last_transition_id];\n if (transition) {\n transition_id = last_transition_id;\n }\n }\n if (!transition) {\n transition = settings.transition_config[transition_id];\n }\n if (!transition) {\n return null;\n }\n return {id: transition_id, transition: transition};\n}\n\nvar playerSet = (function () {\n\n var PlayerSet = function (settings) {\n if (!(this instanceof PlayerSet)) {\n return new PlayerSet(settings);\n }\n\n this._players = {};\n this.ego_id = settings.ego_id;\n };\n\n PlayerSet.prototype.isPlayerAt = function (position) {\n var id, player;\n\n for (id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n player = this._players[id];\n if (positionsAreEqual(position, player.position)) {\n return true;\n }\n }\n }\n return false;\n };\n\n PlayerSet.prototype.drawToGrid = function (grid) {\n var player,\n id,\n minScore,\n maxScore,\n d,\n color,\n player_color;\n if (settings.score_visible) {\n minScore = this.minScore();\n maxScore = this.maxScore();\n }\n\n for (id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n player = this._players[id];\n /* It's unlikely that auto motion will keep identical pace to server-side auto-motion */\n /* this should be implemented either all on server or all on client */\n if (player.motion_auto) {\n player.move(player.motion_direction);\n }\n if (id === this.ego_id || settings.others_visible) {\n player_color = settings.player_colors[name2idx(player.color)];\n if (player.identity_visible) {\n color = player_color;\n } else {\n color = (id === this.ego_id) ? Color.rgb(player_color).desaturate(0.6).rgb().array() : INVISIBLE_COLOR;\n }\n if (settings.score_visible) {\n if (maxScore-minScore > 0) {\n d = 0.75 * (1 - (player.score-minScore)/(maxScore-minScore));\n } else {\n d = 0.375;\n }\n color = Color.rgb(player_color).desaturate(d).rgb().array();\n } else {\n color = player_color;\n }\n var texture = 0;\n if (settings.use_identicons) {\n texture = parseInt(id, 10);\n }\n grid.plot(player.position[1], player.position[0], color, texture);\n if (id === this.ego_id) {\n store.set(\"color\", color2name(color));\n }\n }\n }\n }\n };\n\n PlayerSet.prototype.nearest = function (row, column) {\n var distances = [],\n distance,\n player,\n id;\n\n for (id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n player = this._players[id];\n if (player.hasOwnProperty('position')) {\n distance = Math.abs(row - player.position[0]) + Math.abs(column - player.position[1]);\n distances.push({\"player\": player, \"distance\": distance});\n }\n }\n }\n\n distances.sort(function (a, b) {\n return a.distance - b.distance;\n });\n\n return distances[0].player;\n };\n\n PlayerSet.prototype.ego = function () {\n return this.get(this.ego_id);\n };\n\n PlayerSet.prototype.get = function (id) {\n return this._players[id];\n };\n\n PlayerSet.prototype.count = function () {\n return Object.keys(this._players).length;\n };\n\n PlayerSet.prototype.update = function (allPlayersData) {\n var freshPlayerData,\n existingPlayer,\n i;\n\n for (i = 0; i < allPlayersData.length; i++) {\n freshPlayerData = allPlayersData[i];\n existingPlayer = this._players[freshPlayerData.id];\n if (existingPlayer && existingPlayer.id === this.ego_id) {\n\n /* Don't override current player motion timestamp */\n freshPlayerData.motion_timestamp = existingPlayer.motion_timestamp;\n\n // Only override position from server if tremble is enabled,\n // or if we know the Player's position is out of sync with the server.\n // Otherwise, the ego player's motion is constantly jittery.\n if (settings.motion_tremble_rate === 0 && existingPlayer.positionInSync) {\n freshPlayerData.position = existingPlayer.position;\n } else {\n console.log(\"Overriding position from server!\");\n }\n }\n var last_dimness = 1;\n if (this._players[freshPlayerData.id] !== undefined) {\n last_dimness = this._players[freshPlayerData.id].dimness;\n }\n this._players[freshPlayerData.id] = new Player(freshPlayerData, last_dimness);\n }\n };\n\n PlayerSet.prototype.startScheduledAutosyncOfEgoPosition = function () {\n var self = this;\n setInterval(function () {\n var ego = self.ego();\n if (ego) {\n ego.positionInSync = false;\n console.log(\"Scheduled marking of (\" + ego.id + \") as out of sync with server.\");\n }\n }, 5000);\n };\n\n PlayerSet.prototype.maxScore = function () {\n var id,\n maxScore = 0;\n for (id in this._players) {\n if (this._players[id].score > maxScore) {\n maxScore = this._players[id].score;\n }\n }\n return maxScore;\n };\n\n PlayerSet.prototype.minScore = function () {\n var id,\n minScore = Infinity;\n for (id in this._players) {\n if (this._players[id].score < minScore) {\n minScore = this._players[id].score;\n }\n }\n return minScore;\n };\n\n PlayerSet.prototype.each = function (callback) {\n var i = 0;\n for (var id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n callback(i, this._players[id]);\n i++;\n }\n }\n };\n\n PlayerSet.prototype.group_scores = function () {\n var group_scores = {};\n\n this.each(function (i, player) {\n var color_name = player.color;\n var cur_score = group_scores[color_name] || 0;\n group_scores[color_name] = cur_score + Math.round(player.score);\n });\n\n var group_order = Object.keys(group_scores).sort(function (a, b) {\n return group_scores[a] > group_scores[b] ? -1 : (group_scores[a] < group_scores[b] ? 1 : 0);\n });\n\n return group_order.map(function(color_name) {\n return {name: color_name, score: group_scores[color_name]};\n });\n };\n\n PlayerSet.prototype.player_scores = function () {\n var player_order = [];\n\n this.each(function(i, player) {\n player_order.push({id: player.id, name: player.name, score:player.score});\n });\n\n player_order = player_order.sort(function (a, b) {\n return a.score > b.score ? -1 : (a.score < b.score ? 1 : 0);\n });\n\n return player_order;\n };\n\n return PlayerSet;\n}());\n\nvar GUSocket = (function () {\n var makeSocket = function (endpoint, channel, tolerance) {\n var ws_scheme = (window.location.protocol === \"https:\") ? 'wss://' : 'ws://',\n app_root = ws_scheme + location.host + '/',\n socket;\n\n socket = new ReconnectingWebSocket(\n app_root + endpoint + \"?channel=\" + channel + \"&tolerance=\" + tolerance\n );\n socket.debug = true;\n\n return socket;\n };\n\n var dispatch = function (self, event) {\n var marker = self.broadcastChannel + ':';\n if (event.data.indexOf(marker) !== 0) {\n console.log(\n \"Message was not on channel \" + self.broadcastChannel + \". Ignoring.\");\n return;\n }\n var msg = JSON.parse(event.data.substring(marker.length));\n\n var callback = self.callbackMap[msg.type];\n if (typeof callback !== 'undefined') {\n callback(msg);\n } else {\n console.log(\"Unrecognized message type \" + msg.type + ' from backend.');\n }\n };\n\n /*\n * Public API\n */\n var Socket = function (settings) {\n if (!(this instanceof Socket)) {\n return new Socket(settings);\n }\n\n var self = this,\n isOpen = $.Deferred(),\n tolerance = typeof(settings.lagTolerance) !== 'undefined' ? settings.lagTolerance : 0.1;\n\n this.broadcastChannel = settings.broadcast;\n this.controlChannel = settings.control;\n this.callbackMap = settings.callbackMap;\n\n\n this.socket = makeSocket(\n settings.endpoint, this.broadcastChannel, tolerance);\n\n this.socket.onmessage = function (event) {\n dispatch(self, event);\n };\n };\n\n Socket.prototype.open = function () {\n var isOpen = $.Deferred();\n\n this.socket.onopen = function (event) {\n isOpen.resolve();\n };\n\n return isOpen;\n };\n\n Socket.prototype.send = function (data) {\n var msg = JSON.stringify(data),\n channel = this.controlChannel;\n\n console.log(\"Sending message to the \" + channel + \" channel: \" + msg);\n this.socket.send(channel + ':' + msg);\n };\n\n Socket.prototype.broadcast = function (data) {\n var msg = JSON.stringify(data),\n channel = this.broadcastChannel;\n\n console.log(\"Broadcasting message to the \" + channel + \" channel: \" + msg);\n this.socket.send(channel + ':' + msg);\n };\n\n return Socket;\n}());\n\n// ego will be updated on page load\nvar players = playerSet({'ego_id': undefined});\n\npixels.canvas.style.marginLeft = window.innerWidth * 0.03 / 2 + \"px\";\npixels.canvas.style.marginTop = window.innerHeight * 0.04 / 2 + \"px\";\ndocument.body.style.transition = \"0.3s all\";\ndocument.body.style.background = \"#ffffff\";\n\nvar startTime = performance.now();\n\npixels.frame(function() {\n // Update the background.\n var ego = players.ego(),\n w = getWindowPosition(),\n section = new Section(background, w.left, w.top),\n dimness,\n rescaling,\n x, y;\n\n // Animate background for each visible cell\n section.map(function(x, y, color) {\n var newColor = animateColor(color);\n background[coordsToIdx(x, y, settings.columns)] = newColor;\n return newColor;\n });\n\n for (const [position, item] of gridItems.entries()) {\n if (players.isPlayerAt(position)) {\n if (!item.interactive) {\n // Non-interactive items get consumed immediately\n gridItems.remove(position);\n }\n } else {\n section.plot(position[1], position[0], item.color);\n }\n }\n\n // Draw the players:\n players.drawToGrid(section);\n\n // Show info about the item the current player\n // is sharing a square with:\n if (! _.isUndefined(ego)) {\n updateItemInfoWindow(ego, gridItems);\n }\n\n // Add the Gaussian mask.\n var elapsedTime = performance.now() - startTime;\n var visibilityNow = clamp(\n (settings.visibility * elapsedTime) / (1000 * settings.visibility_ramp_time),\n 3,\n settings.visibility\n );\n if (settings.highlightEgo) {\n visibilityNow = Math.min(visibilityNow, 4);\n }\n var g = gaussian(0, Math.pow(visibilityNow, 2));\n rescaling = 1 / g.pdf(0);\n\n if (typeof ego !== \"undefined\") {\n x = ego.position[1];\n y = ego.position[0];\n } else {\n x = 1e100;\n y = 1e100;\n }\n section.map(function(i, j, color) {\n var newColor;\n // Draw walls\n if (settings.walls_visible) {\n color = wall_map[[i,j]] || color;\n }\n // Add Blur\n players.each(function (i, player) {\n dimness = g.pdf(distance(y, x, player.position[0], player.position[1])) * rescaling;\n player[\"dimness\"] = dimness;\n });\n newColor = color;\n if (!isSpectator) {\n dimness = g.pdf(distance(x, y, i, j)) * rescaling;\n newColor = [\n color[0] * dimness,\n color[1] * dimness,\n color[2] * dimness\n ];\n }\n return newColor;\n });\n pixels.update(section.data, section.textures);\n});\n\nfunction clamp(val, min, max) {\n return Math.max(min, Math.min(max, val));\n}\n\nfunction distance(x, y, xx, yy) {\n return Math.sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y));\n}\n\nfunction arraysEqual(arr1, arr2) {\n for (var i = arr1.length; i--; ) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction arraySearch(arr, val) {\n for (var i = 0; i < arr.length; i++) {\n if (arraysEqual(arr[i], val)) {\n return i;\n }\n }\n return false;\n}\n\nfunction getWindowPosition() {\n var ego = players.ego(),\n w = {\n left: 0,\n top: 0,\n columns: settings.window_columns,\n rows: settings.window_rows\n };\n\n if (typeof ego !== 'undefined') {\n w.left = clamp(\n ego.position[1] - Math.floor(settings.window_columns / 2),\n 0, settings.columns - settings.window_columns);\n w.top = clamp(\n ego.position[0] - Math.floor(settings.window_rows / 2),\n 0, settings.rows - settings.window_rows);\n }\n return w;\n}\n\nfunction bindGameKeys(socket) {\n var directions = [\"up\", \"down\", \"left\", \"right\"],\n repeatDelayMS = 1000 / settings.motion_speed_limit,\n lastDirection = null,\n repeatIntervalId = null,\n highlightEgo = false;\n\n function moveInDir(direction) {\n var ego = players.ego();\n if (ego.move(direction) ) {\n var msg = {\n type: \"move\",\n player_id: ego.id,\n move: direction,\n timestamp: ego.motion_timestamp\n };\n socket.send(msg);\n }\n }\n\n directions.forEach(function(direction) {\n Mousetrap.bind(\n direction,\n function(e) {\n e.preventDefault();\n if (direction === lastDirection) {\n return;\n }\n\n // New direction may be pressed before previous dir key is released\n if (repeatIntervalId) {\n clearInterval(repeatIntervalId);\n }\n\n moveInDir(direction); // Move once immediately so there's no lag\n lastDirection = direction;\n repeatIntervalId = setInterval(moveInDir, repeatDelayMS, direction);\n },\n 'keydown'\n );\n\n Mousetrap.bind(\n direction,\n function(e) {\n e.preventDefault();\n if (direction) {\n clearInterval(repeatIntervalId);\n lastDirection = null;\n }\n },\n \"keyup\"\n );\n\n });\n\n Mousetrap.bind(\"space\", function () {\n var msg_type;\n var ego = players.ego();\n var position = ego.position;\n var item_at_pos = gridItems.atPosition(position);\n var player_item = ego.current_item;\n var transition = ego.getTransition();\n if (!item_at_pos && !player_item) {\n // If there's nothing here, we try to plant food GU 1.0 style\n msg_type = \"plant_food\";\n } else if (transition) {\n // Check for a transition between objects. For now we don't do anything\n // client-side other checking that it exists. We could optimize display\n // updates later\n msg_type = \"item_transition\";\n transitionsSeen.add(transition.id);\n } else if (player_item && player_item.calories) {\n // If there's nothing here to transition with and we're holding something\n // edible, consume it.\n msg_type = \"item_consume\";\n player_item.remainingUses = player_item.remainingUses - 1;\n if (player_item.remainingUses < 1) {\n ego.replaceItem(null);\n }\n } else if (!player_item && item_at_pos && item_at_pos.portable) {\n // If there's a portable item here and we don't something in hand, pick it up.\n msg_type = \"item_pick_up\";\n gridItems.remove(position);\n ego.replaceItem(item_at_pos);\n }\n if (!msg_type) {\n return;\n }\n var msg = {\n type: msg_type,\n player_id: ego.id,\n position: position\n };\n socket.send(msg);\n });\n\n Mousetrap.bind(\"d\", function () {\n var ego = players.ego();\n var position = ego.position;\n var current_item = ego.current_item;\n if (!current_item || gridItems.atPosition(position)) {\n return;\n }\n var msg = {\n type: \"item_drop\",\n player_id: ego.id,\n position: position\n };\n socket.send(msg);\n ego.replaceItem(null);\n gridItems.add(current_item, position);\n });\n\n if (settings.mutable_colors) {\n Mousetrap.bind('c', function () {\n var keys = settings.player_color_names,\n index = arraySearch(keys, players.ego().color),\n nextItem = keys[(index + 1) % keys.length],\n msg;\n\n players.ego().color = nextItem;\n msg = {\n type: \"change_color\",\n player_id: players.ego().id,\n color: players.ego().color\n };\n socket.send(msg);\n });\n }\n\n if (settings.identity_signaling) {\n Mousetrap.bind(\"v\", function () {\n var ego = players.ego(),\n msg;\n\n ego.identity_visible = !ego.identity_visible;\n msg = {\n type: \"toggle_visible\",\n player_id: ego.id,\n identity_visible: ego.identity_visible\n };\n socket.send(msg);\n });\n }\n\n if (settings.build_walls) {\n Mousetrap.bind(\"w\", function () {\n var msg = {\n type: \"build_wall\",\n player_id: players.ego().id,\n position: players.ego().position\n };\n socket.send(msg);\n });\n }\n\n Mousetrap.bind(\"h\", function () {\n settings.highlightEgo = !settings.highlightEgo;\n });\n}\n\nfunction chatName(player_id) {\n var ego = players.ego(),\n entry = \"<span class='name'>\",\n id = parseInt(player_id) - 1,\n salt = $(\"#grid\").data(\"identicon-salt\"),\n fg = settings.player_colors[name2idx(players.get(player_id).color)].concat(1),\n bg,\n identicon,\n name,\n options;\n\n if (id === ego) {\n name = \"You\";\n } else if (settings.pseudonyms) {\n name = players.get(player_id).name;\n } else if (player_id % 1 === 0) {\n name = \"Player \" + player_id;\n } else {\n // Non-integer player_id\n return '<span class=\"name\">' + player_id + '</span>';\n }\n\n fg = fg.map(function(x) { return x * 255; });\n bg = fg.map(function(x) { return (x * 0.66); });\n bg[3] = 255;\n options = {\n size: 10,\n foreground: fg,\n background: bg,\n format: 'svg'\n };\n\n identicon = new Identicon(md5(salt + id), options).toString();\n if (settings.use_identicons) {\n entry = entry + \" <img src='data:image/svg+xml;base64,\" + identicon + \"' />\";\n }\n entry = entry + \" \" + name + \"</span> \";\n return entry;\n}\n\nfunction onChatMessage(msg) {\n var entry = chatName(msg.player_id);\n if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) {\n return;\n }\n $(\"#messages\").append(($(\"<li>\").text(\": \" + msg.contents)).prepend(entry));\n $(\"#chatlog\").scrollTop($(\"#chatlog\")[0].scrollHeight);\n}\n\nfunction onColorChanged(msg) {\n store.set(\"color\", msg.new_color);\n if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) {\n return;\n }\n pushMessage(\"<span class='name'>Moderator:</span> \" + chatName(msg.player_id) + ' changed from team ' + msg.old_color + ' to team ' + msg.new_color + '.');\n}\n\nfunction onMoveRejected(msg) {\n var offendingPlayerId = msg.player_id,\n ego = players.ego();\n\n if (ego && offendingPlayerId === ego.id) {\n ego.positionInSync = false;\n console.log(\"Marking your player (\" + ego.id + \") as out of sync with server. Should sync on next state update\");\n }\n}\n\nfunction onDonationProcessed(msg) {\n var donor = players.get(msg.donor_id),\n recipient_id = msg.recipient_id,\n team_idx,\n donor_name,\n recipient_name,\n donated_points,\n received_points,\n entry;\n\n donor_name = chatName(msg.donor_id);\n\n if (recipient_id === 'all') {\n recipient_name = '<span class=\"name\">All players</span>';\n } else if (recipient_id.indexOf('group:') === 0) {\n team_idx = +recipient_id.substring(6);\n recipient_name = 'Everyone in <span class=\"name\">' + settings.player_color_names[team_idx] + '</span>';\n } else {\n recipient_name = chatName(recipient_id);\n }\n\n if (msg.amount === 1) {\n donated_points = msg.amount + ' point.';\n } else {\n donated_points = msg.amount + ' points.';\n }\n\n if (msg.received === 1) {\n received_points = msg.received + ' point.';\n } else {\n received_points = msg.received + ' points.';\n }\n\n entry = donor_name + \" contributed \" + donated_points + \" \" + recipient_name + \" received \" + received_points;\n\n $(\"#messages\").append($(\"<li>\").html(entry));\n $(\"#chatlog\").scrollTop($(\"#chatlog\")[0].scrollHeight);\n $('#individual-donate, #group-donate').addClass('button-outline');\n $('#donate label').text($('#donate label').data('orig-text'));\n settings.donation_type = null;\n}\n\nfunction updateDonationStatus(donation_is_active) {\n // If alternating donation/consumption rounds, announce round type\n if (settings.alternate_consumption_donation && (settings.donation_active !== donation_is_active)) {\n if (donation_is_active) {\n pushMessage(\"<span class='name'>Moderator:</span> Starting a donation round. Players cannot move, only donate.\");\n } else {\n pushMessage(\"<span class='name'>Moderator:</span> Starting a consumption round. Players have to consume as much food as possible.\");\n }\n }\n // Update donation status\n settings.donation_active = donation_is_active;\n}\n\n\nfunction renderTransition(transition) {\n if (! transition) {\n return \"\";\n }\n const states = [\n transition.transition.actor_start,\n transition.transition.actor_end,\n transition.transition.target_start,\n transition.transition.target_end\n ];\n\n const [aStartItem, aEndItem, tStartItem, tEndItem] = states.map(\n (state) => settings.item_config[state]\n );\n\n return `✋${aStartItem.name} + ${tStartItem.name} → ✋${aEndItem.name} + ${tEndItem.name}`;\n}\n/**\n * If the current player is sharing a grid position with an interactive\n * item, we show information about it on the page.\n *\n * @param {Player} egoPlayer the current Player\n * @param {itemlib.GridItems} gridItems the collection of all Items on the grid\n */\nfunction updateItemInfoWindow(egoPlayer, gridItems) {\n const inspectedItem = gridItems.atPosition(egoPlayer.position),\n transition = egoPlayer.getTransition(),\n $square = $(\"#location-contents-item\"),\n $transition = $(\"#transition-details\");\n\n if (! inspectedItem) {\n $square.empty();\n } else {\n $square.html(inspectedItem.name);\n }\n\n if (! transition) {\n $transition.empty();\n } else {\n $transition.html(renderTransition(transition));\n }\n}\n\nfunction displayWhatEgoPlayerIsCarrying(item) {\n $('#inventory-item').text(item ? item.name : '');\n}\n\nfunction onGameStateChange(msg) {\n var $donationButtons = $('#individual-donate, #group-donate, #public-donate, #ingroup-donate'),\n $timeElement = $(\"#time\"),\n $loading = $('.grid-loading'),\n cur_wall,\n ego,\n state,\n j,\n k;\n\n performance.mark('state_start');\n if ($loading.is(':visible')) $loading.fadeOut();\n\n if (settings.paused_game) {\n $timeElement.html(0);\n return;\n }\n\n // Update remaining time.\n $timeElement.html(Math.max(Math.round(msg.remaining_time), 0));\n\n // Update round.\n if (settings.num_rounds > 1) {\n $(\"#round\").html(msg.round + 1);\n }\n\n // Update players.\n state = JSON.parse(msg.grid);\n players.update(state.players);\n ego = players.ego();\n\n updateDonationStatus(state.donation_active);\n\n // Update gridItems\n if (state.items !== undefined && state.items !== null) {\n gridItems = new itemlib.GridItems();\n for (j = 0; j < state.items.length; j++) {\n\n gridItems.add(\n new itemlib.Item(\n state.items[j].id,\n state.items[j].item_id,\n state.items[j].maturity,\n state.items[j].remaining_uses,\n ),\n state.items[j].position\n );\n }\n }\n // Update walls if they haven't been created yet.\n if (state.walls !== undefined && walls.length === 0) {\n for (k = 0; k < state.walls.length; k++) {\n cur_wall = state.walls[k];\n if (cur_wall instanceof Array) {\n cur_wall = {\n position: cur_wall,\n color: [0.5, 0.5, 0.5]\n };\n }\n walls.push(\n new Wall({\n position: cur_wall.position,\n color: cur_wall.color\n })\n );\n wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color;\n }\n }\n\n // If new walls have been added, draw them\n if (state.walls !== undefined && walls.length < state.walls.length) {\n for (k = walls.length; k < state.walls.length; k++) {\n cur_wall = state.walls[k];\n walls.push(\n new Wall({\n position: cur_wall.position,\n color: cur_wall.color\n })\n );\n wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color;\n }\n }\n\n // Update displayed score, set donation info.\n if (ego !== undefined) {\n $(\"#score\").html(Math.round(ego.score));\n $(\"#dollars\").html(ego.payoff.toFixed(2));\n window.state = msg.grid;\n window.ego = ego.id;\n if (settings.donation_active &&\n ego.score >= settings.donation_amount &&\n players.count() > 1\n ) {\n $donationButtons.prop('disabled', false);\n } else {\n $('#donation-instructions').text('');\n $donationButtons.prop('disabled', true);\n }\n }\n}\n\nfunction addWall(msg) {\n var wall = msg.wall;\n if (wall) {\n walls.push(\n new Wall({\n position: wall.position,\n color: wall.color\n })\n );\n wall_map[[wall.position[1], wall.position[0]]] = wall.color;\n }\n}\n\nfunction pushMessage(html) {\n $(\"#messages\").append(($(\"<li>\").html(html)));\n $(\"#chatlog\").scrollTop($(\"#chatlog\")[0].scrollHeight);\n}\n\nfunction displayLeaderboards(msg, callback) {\n if (!settings.leaderboard_group && !settings.leaderboard_individual) {\n if (callback) {\n callback();\n }\n return;\n }\n var i;\n if (msg.type === 'new_round') {\n pushMessage(\"<span class='name'>Moderator:</span> the round \" + msg.round + ' standings are…');\n } else {\n pushMessage(\"<span class='name'>Moderator:</span> the final standings are …\");\n }\n if (settings.leaderboard_group) {\n if (settings.leaderboard_individual) {\n pushMessage('<em>Group</em>');\n }\n var group_scores = players.group_scores();\n var rgb_map = function (e) { return Math.round(e * 255); };\n for (i = 0; i < group_scores.length; i++) {\n var group = group_scores[i];\n var color = settings.player_colors[name2idx(group.name)].map(rgb_map);\n pushMessage('<span class=\"GroupScore\">' + group.score + '</span><span class=\"GroupIndicator\" style=\"background-color:' + Color.rgb(color).string() +';\"></span>');\n }\n }\n if (settings.leaderboard_individual) {\n if (settings.leaderboard_group) {\n pushMessage('<em>Individual</em>');\n }\n var player_scores = players.player_scores();\n var ego_id = players.ego_id;\n for (i = 0; i < player_scores.length; i++) {\n var player = player_scores[i];\n var player_name = chatName(player.id);\n pushMessage('<span class=\"PlayerScore\">' + Math.round(player.score) + '</span><span class=\"PlayerName\">' + player_name + '</span>');\n }\n }\n if (settings.leaderboard_time) {\n settings.paused_game = true;\n setTimeout(function () {\n settings.paused_game = false;\n if (callback) {\n callback();\n }\n }, 1000 * settings.leaderboard_time);\n } else if (callback) {\n callback();\n }\n}\n\nfunction gameOverHandler(player_id) {\n var callback;\n if (!isSpectator) {\n callback = function () {\n $(\"#dashboard\").hide();\n $(\"#instructions\").hide();\n $(\"#chat\").hide();\n if (player_id) {\n window.location.href = \"/questionnaire?participant_id=\" + player_id;\n }\n };\n pixels.canvas.style.display = \"none\";\n }\n return function (msg) {\n $(\"#game-over\").show();\n return displayLeaderboards(msg, callback);\n };\n}\n\n$(document).ready(function() {\n var player_id = dallinger.getUrlParameter('participant_id');\n isSpectator = typeof player_id === 'undefined';\n var socketSettings = {\n 'endpoint': 'chat',\n 'broadcast': CHANNEL,\n 'control': CONTROL_CHANNEL,\n 'lagTolerance': 0.001,\n 'callbackMap': {\n 'chat': onChatMessage,\n 'donation_processed': onDonationProcessed,\n 'color_changed': onColorChanged,\n 'state': onGameStateChange,\n 'new_round': displayLeaderboards,\n 'stop': gameOverHandler(player_id),\n 'wall_built': addWall,\n 'move_rejection': onMoveRejected\n }\n };\n var socket = new GUSocket(socketSettings);\n\n socket.open().done(function () {\n var data = {\n type: 'connect',\n player_id: isSpectator ? 'spectator' : player_id\n };\n socket.send(data);\n });\n\n players.ego_id = player_id;\n players.startScheduledAutosyncOfEgoPosition();\n $('#donate label').data('orig-text', $('#donate label').text());\n\n setInterval(function () {\n var delays = [],\n start_marks = performance.getEntriesByName('state_start', 'mark');\n for (var i = 0; i < start_marks.length; i++) {\n if (start_marks.length > i + 2) {\n delays.push(start_marks[i+1].startTime - start_marks[i].startTime);\n }\n }\n if (delays.length) {\n var average_delay = delays.reduce(function(sum, value){\n return sum + value;\n }, 0) / delays.length;\n console.log('Average delay between state updates: ' + average_delay + 'ms.');\n }\n }, 5000);\n\n // Append the canvas.\n $(\"#grid\").append(pixels.canvas);\n\n // Opt out of the experiment.\n $(\"#opt-out\").click(function() {\n window.location.href = \"/questionnaire?participant_id=\" + player_id;\n });\n\n if (isSpectator) {\n $(\".for-players\").hide();\n }\n\n // Consent to the experiment.\n $(\"#go-to-experiment\").click(function() {\n window.location.href = \"/exp\";\n });\n\n // Submit the questionnaire.\n $(\"#submit-questionnaire\").click(function() {\n dallinger.submitResponses();\n });\n\n if (settings.show_grid) {\n pixels.canvas.style.display = \"inline\";\n }\n\n if (settings.show_chatroom) {\n $(\"#chat form\").show();\n }\n\n var donateToClicked = function() {\n var w = getWindowPosition(),\n row = w.top + pixels2cells(mouse[1]),\n column = w.left + pixels2cells(mouse[0]),\n recipient = players.nearest(row, column),\n donor = players.ego(),\n amt = settings.donation_amount,\n recipient_id,\n msg;\n\n if (!settings.donation_active) {\n return;\n }\n\n if (amt > donor.score) {\n return;\n }\n\n if (settings.donation_type === 'individual') {\n recipient_id = recipient.id;\n } else if (settings.donation_type === 'group') {\n recipient_id = 'group:' + name2idx(recipient.color).toString();\n } else {\n return;\n }\n\n if (recipient_id !== donor.id) {\n msg = {\n type: \"donation_submitted\",\n recipient_id: recipient_id,\n donor_id: donor.id,\n amount: amt\n };\n socket.send(msg);\n }\n };\n\n var donateToAll = function() {\n var donor = players.ego(),\n amt = settings.donation_amount,\n msg;\n\n msg = {\n type: \"donation_submitted\",\n recipient_id: 'all',\n donor_id: donor.id,\n amount: amt\n };\n socket.send(msg);\n };\n\n var donateToInGroup = function () {\n var donor = players.ego(),\n amt = settings.donation_amount,\n recipientId = 'group:' + name2idx(donor.color).toString(),\n msg;\n\n msg = {\n type: \"donation_submitted\",\n recipient_id: recipientId,\n donor_id: donor.id,\n amount: amt\n };\n socket.send(msg);\n };\n\n var pixels2cells = function(pix) {\n return Math.floor(pix / (settings.block_size + settings.padding));\n };\n\n $(\"form\").submit(function() {\n var chatmessage = $(\"#message\").val().trim(),\n msg;\n\n if (! chatmessage) {\n return false;\n }\n\n try {\n msg = {\n type: 'chat',\n contents: chatmessage,\n player_id: players.ego().id,\n timestamp: performance.now() - start,\n broadcast: true\n };\n // send directly to all clients\n socket.broadcast(msg);\n // Also send to the server for logging\n socket.send(msg);\n } catch(err) {\n console.error(err);\n } finally {\n $(\"#message\").val(\"\");\n return false;\n }\n });\n\n if (!isSpectator) {\n // Main game keys:\n bindGameKeys(socket);\n // Donation click events:\n $(pixels.canvas).click(function (e) {\n donateToClicked();\n });\n $('#public-donate').click(donateToAll);\n $('#ingroup-donate').click(donateToInGroup);\n $('#group-donate').click(function () {\n if (settings.donation_group) {\n $('#donate label').text('Click on a color');\n settings.donation_type = 'group';\n $(this).prop('disabled', false);\n $(this).removeClass('button-outline');\n $('#individual-donate').addClass('button-outline');\n }\n });\n $('#individual-donate').click(function () {\n if (settings.donation_individual) {\n $('#donate label').text('Click on a player');\n settings.donation_type = 'individual';\n $(this).removeClass('button-outline');\n $('#group-donate').addClass('button-outline');\n }\n });\n }\n\n});\n\n}(dallinger, require, window.settings));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/demo.js\n// module id = 8\n// module chunks = 0","var parse = require(\"parse-color\");\nvar isnumber = require(\"is-number\");\nvar isstring = require(\"is-string\");\nvar isarray = require(\"is-array\");\nvar convert = require(\"./util/convert\");\nvar layout = require(\"./util/layout\");\nvar texcoord = require(\"./util/texcoord\");\nvar range = require(\"./util/range\");\nvar pixdenticon = require(\"./util/pixdenticon\");\nvar md5 = require(\"./util/md5\");\n\nfunction Pixels(data, textures, opts) {\n if (!(this instanceof Pixels)) return new Pixels(data, textures, opts);\n var self = this;\n opts = opts || {};\n this.opts = opts;\n var num_identicons = 100;\n\n opts.background = opts.background || [ 0.5, 0.5, 0.5 ];\n opts.size = isnumber(opts.size) ? opts.size : 10;\n opts.padding = isnumber(opts.padding) ? opts.padding : 2;\n\n if (isstring(opts.background))\n opts.background = parse(opts.background).rgb.map(function(c) {\n return c / 255;\n });\n\n if (isarray(data[0]) && data[0].length !== 3) {\n opts.rows = data.length;\n opts.columns = data[0].length;\n }\n\n if (!opts.rows || !opts.columns) {\n opts.rows = opts.columns = Math.round(Math.sqrt(data.length));\n }\n\n var width = opts.columns * opts.size + (opts.columns + 1) * opts.padding;\n var height = opts.rows * opts.size + (opts.rows + 1) * opts.padding;\n\n var canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n if (opts.root) opts.root.appendChild(canvas);\n\n var colors = opts.formatted ? data : convert(data);\n var texcoords = texcoord(\n opts.rows,\n opts.columns,\n textures,\n num_identicons\n );\n\n var positions = layout(\n opts.rows,\n opts.columns,\n 2 * opts.padding / width,\n 2 * opts.size / width,\n width / height\n );\n\n var regl = require(\"regl\")(canvas);\n\n var initial_texture = [];\n for (row = 0; row < opts.size; row++) {\n rowdata = []\n for (col = 0; col < opts.size; col++) {\n rowdata.push([255, 255, 255]);\n }\n initial_texture.push(rowdata);\n }\n var salt = $(\"#grid\").data(\"identicon-salt\");\n for (var i = 0; i < num_identicons; i++) {\n texture = new pixdenticon(md5(salt + i), opts.size).render().buffer;\n for (row = 0; row < opts.size; row++) {\n initial_texture.push(texture[row]);\n }\n }\n\n var texture = regl.texture(initial_texture);\n\n var squares = regl({\n vert: `\n precision mediump float;\n attribute vec2 position;\n attribute vec2 texcoords;\n attribute vec3 color;\n varying vec3 vcolor;\n varying vec2 v_texcoords;\n void main() {\n gl_PointSize = float(${opts.size});\n gl_Position = vec4(position.x, position.y, 0.0, 1.0);\n v_texcoords = texcoords;\n vcolor = color;\n }\n `,\n frag: `\n precision mediump float;\n varying vec3 vcolor;\n varying vec2 v_texcoords;\n uniform sampler2D vtexture;\n void main() {\n vec4 texture;\n texture = texture2D(vtexture, v_texcoords);\n gl_FragColor = texture * vec4(vcolor.r, vcolor.g, vcolor.b, 1.0);\n }\n `,\n attributes: { position: regl.prop(\"position\"), texcoords: regl.prop(\"texcoords\"), color: regl.prop(\"color\")},\n primitive: \"triangles\",\n count: colors.length * 6,\n uniforms: { vtexture: texture }\n });\n\n var expanded_colors = [];\n for(var i = 0; i < colors.length; ++i){\n for(var n = 0; n < 6; ++n) {\n expanded_colors.push(colors[i]);\n }\n }\n\n var buffer = { position: regl.buffer(positions), texcoords: regl.buffer(texcoords), color: regl.buffer(expanded_colors)};\n\n var draw = function(positions, texcoords, colors) {\n regl.clear({ color: opts.background.concat([ 1 ]) });\n squares({ position: positions, texcoords: texcoords, color: colors });\n };\n\n draw(buffer.position, buffer.texcoords, buffer.color);\n\n self._buffer = buffer;\n self._draw = draw;\n self._formatted = opts.formatted;\n self.canvas = canvas;\n self.frame = regl.frame;\n}\n\nPixels.prototype.update = function(data, textures) {\n var self = this;\n var colors = self._formatted ? data : convert(data);\n var expanded_colors = [];\n\n for(var i = 0; i < colors.length; ++i){\n for(var n = 0; n < 6; ++n) {\n expanded_colors.push(colors[i]);\n }\n }\n\n var opts = this.opts;\n var num_identicons = 100;\n\n var texcoords = texcoord(\n opts.rows,\n opts.columns,\n textures,\n num_identicons\n );\n\n self._draw(self._buffer.position, self._buffer.texcoords(texcoords), self._buffer.color(expanded_colors));\n};\n\nmodule.exports = Pixels;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/index.js\n// module id = 9\n// module chunks = 0","var conversions = require(\"./conversions\");\n\nvar convert = function() {\n return new Converter();\n}\n\nfor (var func in conversions) {\n // export Raw versions\n convert[func + \"Raw\"] = (function(func) {\n // accept array or plain args\n return function(arg) {\n if (typeof arg == \"number\")\n arg = Array.prototype.slice.call(arguments);\n return conversions[func](arg);\n }\n })(func);\n\n var pair = /(\\w+)2(\\w+)/.exec(func),\n from = pair[1],\n to = pair[2];\n\n // export rgb2hsl and [\"rgb\"][\"hsl\"]\n convert[from] = convert[from] || {};\n\n convert[from][to] = convert[func] = (function(func) { \n return function(arg) {\n if (typeof arg == \"number\")\n arg = Array.prototype.slice.call(arguments);\n \n var val = conversions[func](arg);\n if (typeof val == \"string\" || val === undefined)\n return val; // keyword\n\n for (var i = 0; i < val.length; i++)\n val[i] = Math.round(val[i]);\n return val;\n }\n })(func);\n}\n\n\n/* Converter does lazy conversion and caching */\nvar Converter = function() {\n this.convs = {};\n};\n\n/* Either get the values for a space or\n set the values for a space, depending on args */\nConverter.prototype.routeSpace = function(space, args) {\n var values = args[0];\n if (values === undefined) {\n // color.rgb()\n return this.getValues(space);\n }\n // color.rgb(10, 10, 10)\n if (typeof values == \"number\") {\n values = Array.prototype.slice.call(args); \n }\n\n return this.setValues(space, values);\n};\n \n/* Set the values for a space, invalidating cache */\nConverter.prototype.setValues = function(space, values) {\n this.space = space;\n this.convs = {};\n this.convs[space] = values;\n return this;\n};\n\n/* Get the values for a space. If there's already\n a conversion for the space, fetch it, otherwise\n compute it */\nConverter.prototype.getValues = function(space) {\n var vals = this.convs[space];\n if (!vals) {\n var fspace = this.space,\n from = this.convs[fspace];\n vals = convert[fspace][space](from);\n\n this.convs[space] = vals;\n }\n return vals;\n};\n\n[\"rgb\", \"hsl\", \"hsv\", \"cmyk\", \"keyword\"].forEach(function(space) {\n Converter.prototype[space] = function(vals) {\n return this.routeSpace(space, arguments);\n }\n});\n\nmodule.exports = convert;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/parse-color/node_modules/color-convert/index.js\n// module id = 10\n// module chunks = 0","/* MIT license */\n\nmodule.exports = {\n rgb2hsl: rgb2hsl,\n rgb2hsv: rgb2hsv,\n rgb2hwb: rgb2hwb,\n rgb2cmyk: rgb2cmyk,\n rgb2keyword: rgb2keyword,\n rgb2xyz: rgb2xyz,\n rgb2lab: rgb2lab,\n rgb2lch: rgb2lch,\n\n hsl2rgb: hsl2rgb,\n hsl2hsv: hsl2hsv,\n hsl2hwb: hsl2hwb,\n hsl2cmyk: hsl2cmyk,\n hsl2keyword: hsl2keyword,\n\n hsv2rgb: hsv2rgb,\n hsv2hsl: hsv2hsl,\n hsv2hwb: hsv2hwb,\n hsv2cmyk: hsv2cmyk,\n hsv2keyword: hsv2keyword,\n\n hwb2rgb: hwb2rgb,\n hwb2hsl: hwb2hsl,\n hwb2hsv: hwb2hsv,\n hwb2cmyk: hwb2cmyk,\n hwb2keyword: hwb2keyword,\n\n cmyk2rgb: cmyk2rgb,\n cmyk2hsl: cmyk2hsl,\n cmyk2hsv: cmyk2hsv,\n cmyk2hwb: cmyk2hwb,\n cmyk2keyword: cmyk2keyword,\n\n keyword2rgb: keyword2rgb,\n keyword2hsl: keyword2hsl,\n keyword2hsv: keyword2hsv,\n keyword2hwb: keyword2hwb,\n keyword2cmyk: keyword2cmyk,\n keyword2lab: keyword2lab,\n keyword2xyz: keyword2xyz,\n\n xyz2rgb: xyz2rgb,\n xyz2lab: xyz2lab,\n xyz2lch: xyz2lch,\n\n lab2xyz: lab2xyz,\n lab2rgb: lab2rgb,\n lab2lch: lab2lch,\n\n lch2lab: lch2lab,\n lch2xyz: lch2xyz,\n lch2rgb: lch2rgb\n}\n\n\nfunction rgb2hsl(rgb) {\n var r = rgb[0]/255,\n g = rgb[1]/255,\n b = rgb[2]/255,\n min = Math.min(r, g, b),\n max = Math.max(r, g, b),\n delta = max - min,\n h, s, l;\n\n if (max == min)\n h = 0;\n else if (r == max)\n h = (g - b) / delta;\n else if (g == max)\n h = 2 + (b - r) / delta;\n else if (b == max)\n h = 4 + (r - g)/ delta;\n\n h = Math.min(h * 60, 360);\n\n if (h < 0)\n h += 360;\n\n l = (min + max) / 2;\n\n if (max == min)\n s = 0;\n else if (l <= 0.5)\n s = delta / (max + min);\n else\n s = delta / (2 - max - min);\n\n return [h, s * 100, l * 100];\n}\n\nfunction rgb2hsv(rgb) {\n var r = rgb[0],\n g = rgb[1],\n b = rgb[2],\n min = Math.min(r, g, b),\n max = Math.max(r, g, b),\n delta = max - min,\n h, s, v;\n\n if (max == 0)\n s = 0;\n else\n s = (delta/max * 1000)/10;\n\n if (max == min)\n h = 0;\n else if (r == max)\n h = (g - b) / delta;\n else if (g == max)\n h = 2 + (b - r) / delta;\n else if (b == max)\n h = 4 + (r - g) / delta;\n\n h = Math.min(h * 60, 360);\n\n if (h < 0)\n h += 360;\n\n v = ((max / 255) * 1000) / 10;\n\n return [h, s, v];\n}\n\nfunction rgb2hwb(rgb) {\n var r = rgb[0],\n g = rgb[1],\n b = rgb[2],\n h = rgb2hsl(rgb)[0],\n w = 1/255 * Math.min(r, Math.min(g, b)),\n b = 1 - 1/255 * Math.max(r, Math.max(g, b));\n\n return [h, w * 100, b * 100];\n}\n\nfunction rgb2cmyk(rgb) {\n var r = rgb[0] / 255,\n g = rgb[1] / 255,\n b = rgb[2] / 255,\n c, m, y, k;\n\n k = Math.min(1 - r, 1 - g, 1 - b);\n c = (1 - r - k) / (1 - k) || 0;\n m = (1 - g - k) / (1 - k) || 0;\n y = (1 - b - k) / (1 - k) || 0;\n return [c * 100, m * 100, y * 100, k * 100];\n}\n\nfunction rgb2keyword(rgb) {\n return reverseKeywords[JSON.stringify(rgb)];\n}\n\nfunction rgb2xyz(rgb) {\n var r = rgb[0] / 255,\n g = rgb[1] / 255,\n b = rgb[2] / 255;\n\n // assume sRGB\n r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n\n return [x * 100, y *100, z * 100];\n}\n\nfunction rgb2lab(rgb) {\n var xyz = rgb2xyz(rgb),\n x = xyz[0],\n y = xyz[1],\n z = xyz[2],\n l, a, b;\n\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n\n x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);\n y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);\n z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);\n\n l = (116 * y) - 16;\n a = 500 * (x - y);\n b = 200 * (y - z);\n\n return [l, a, b];\n}\n\nfunction rgb2lch(args) {\n return lab2lch(rgb2lab(args));\n}\n\nfunction hsl2rgb(hsl) {\n var h = hsl[0] / 360,\n s = hsl[1] / 100,\n l = hsl[2] / 100,\n t1, t2, t3, rgb, val;\n\n if (s == 0) {\n val = l * 255;\n return [val, val, val];\n }\n\n if (l < 0.5)\n t2 = l * (1 + s);\n else\n t2 = l + s - l * s;\n t1 = 2 * l - t2;\n\n rgb = [0, 0, 0];\n for (var i = 0; i < 3; i++) {\n t3 = h + 1 / 3 * - (i - 1);\n t3 < 0 && t3++;\n t3 > 1 && t3--;\n\n if (6 * t3 < 1)\n val = t1 + (t2 - t1) * 6 * t3;\n else if (2 * t3 < 1)\n val = t2;\n else if (3 * t3 < 2)\n val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n else\n val = t1;\n\n rgb[i] = val * 255;\n }\n\n return rgb;\n}\n\nfunction hsl2hsv(hsl) {\n var h = hsl[0],\n s = hsl[1] / 100,\n l = hsl[2] / 100,\n sv, v;\n\n if(l === 0) {\n // no need to do calc on black\n // also avoids divide by 0 error\n return [0, 0, 0];\n }\n\n l *= 2;\n s *= (l <= 1) ? l : 2 - l;\n v = (l + s) / 2;\n sv = (2 * s) / (l + s);\n return [h, sv * 100, v * 100];\n}\n\nfunction hsl2hwb(args) {\n return rgb2hwb(hsl2rgb(args));\n}\n\nfunction hsl2cmyk(args) {\n return rgb2cmyk(hsl2rgb(args));\n}\n\nfunction hsl2keyword(args) {\n return rgb2keyword(hsl2rgb(args));\n}\n\n\nfunction hsv2rgb(hsv) {\n var h = hsv[0] / 60,\n s = hsv[1] / 100,\n v = hsv[2] / 100,\n hi = Math.floor(h) % 6;\n\n var f = h - Math.floor(h),\n p = 255 * v * (1 - s),\n q = 255 * v * (1 - (s * f)),\n t = 255 * v * (1 - (s * (1 - f))),\n v = 255 * v;\n\n switch(hi) {\n case 0:\n return [v, t, p];\n case 1:\n return [q, v, p];\n case 2:\n return [p, v, t];\n case 3:\n return [p, q, v];\n case 4:\n return [t, p, v];\n case 5:\n return [v, p, q];\n }\n}\n\nfunction hsv2hsl(hsv) {\n var h = hsv[0],\n s = hsv[1] / 100,\n v = hsv[2] / 100,\n sl, l;\n\n l = (2 - s) * v;\n sl = s * v;\n sl /= (l <= 1) ? l : 2 - l;\n sl = sl || 0;\n l /= 2;\n return [h, sl * 100, l * 100];\n}\n\nfunction hsv2hwb(args) {\n return rgb2hwb(hsv2rgb(args))\n}\n\nfunction hsv2cmyk(args) {\n return rgb2cmyk(hsv2rgb(args));\n}\n\nfunction hsv2keyword(args) {\n return rgb2keyword(hsv2rgb(args));\n}\n\n// http://dev.w3.org/csswg/css-color/#hwb-to-rgb\nfunction hwb2rgb(hwb) {\n var h = hwb[0] / 360,\n wh = hwb[1] / 100,\n bl = hwb[2] / 100,\n ratio = wh + bl,\n i, v, f, n;\n\n // wh + bl cant be > 1\n if (ratio > 1) {\n wh /= ratio;\n bl /= ratio;\n }\n\n i = Math.floor(6 * h);\n v = 1 - bl;\n f = 6 * h - i;\n if ((i & 0x01) != 0) {\n f = 1 - f;\n }\n n = wh + f * (v - wh); // linear interpolation\n\n switch (i) {\n default:\n case 6:\n case 0: r = v; g = n; b = wh; break;\n case 1: r = n; g = v; b = wh; break;\n case 2: r = wh; g = v; b = n; break;\n case 3: r = wh; g = n; b = v; break;\n case 4: r = n; g = wh; b = v; break;\n case 5: r = v; g = wh; b = n; break;\n }\n\n return [r * 255, g * 255, b * 255];\n}\n\nfunction hwb2hsl(args) {\n return rgb2hsl(hwb2rgb(args));\n}\n\nfunction hwb2hsv(args) {\n return rgb2hsv(hwb2rgb(args));\n}\n\nfunction hwb2cmyk(args) {\n return rgb2cmyk(hwb2rgb(args));\n}\n\nfunction hwb2keyword(args) {\n return rgb2keyword(hwb2rgb(args));\n}\n\nfunction cmyk2rgb(cmyk) {\n var c = cmyk[0] / 100,\n m = cmyk[1] / 100,\n y = cmyk[2] / 100,\n k = cmyk[3] / 100,\n r, g, b;\n\n r = 1 - Math.min(1, c * (1 - k) + k);\n g = 1 - Math.min(1, m * (1 - k) + k);\n b = 1 - Math.min(1, y * (1 - k) + k);\n return [r * 255, g * 255, b * 255];\n}\n\nfunction cmyk2hsl(args) {\n return rgb2hsl(cmyk2rgb(args));\n}\n\nfunction cmyk2hsv(args) {\n return rgb2hsv(cmyk2rgb(args));\n}\n\nfunction cmyk2hwb(args) {\n return rgb2hwb(cmyk2rgb(args));\n}\n\nfunction cmyk2keyword(args) {\n return rgb2keyword(cmyk2rgb(args));\n}\n\n\nfunction xyz2rgb(xyz) {\n var x = xyz[0] / 100,\n y = xyz[1] / 100,\n z = xyz[2] / 100,\n r, g, b;\n\n r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n // assume sRGB\n r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)\n : r = (r * 12.92);\n\n g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)\n : g = (g * 12.92);\n\n b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)\n : b = (b * 12.92);\n\n r = Math.min(Math.max(0, r), 1);\n g = Math.min(Math.max(0, g), 1);\n b = Math.min(Math.max(0, b), 1);\n\n return [r * 255, g * 255, b * 255];\n}\n\nfunction xyz2lab(xyz) {\n var x = xyz[0],\n y = xyz[1],\n z = xyz[2],\n l, a, b;\n\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n\n x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);\n y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);\n z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);\n\n l = (116 * y) - 16;\n a = 500 * (x - y);\n b = 200 * (y - z);\n\n return [l, a, b];\n}\n\nfunction xyz2lch(args) {\n return lab2lch(xyz2lab(args));\n}\n\nfunction lab2xyz(lab) {\n var l = lab[0],\n a = lab[1],\n b = lab[2],\n x, y, z, y2;\n\n if (l <= 8) {\n y = (l * 100) / 903.3;\n y2 = (7.787 * (y / 100)) + (16 / 116);\n } else {\n y = 100 * Math.pow((l + 16) / 116, 3);\n y2 = Math.pow(y / 100, 1/3);\n }\n\n x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);\n\n z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);\n\n return [x, y, z];\n}\n\nfunction lab2lch(lab) {\n var l = lab[0],\n a = lab[1],\n b = lab[2],\n hr, h, c;\n\n hr = Math.atan2(b, a);\n h = hr * 360 / 2 / Math.PI;\n if (h < 0) {\n h += 360;\n }\n c = Math.sqrt(a * a + b * b);\n return [l, c, h];\n}\n\nfunction lab2rgb(args) {\n return xyz2rgb(lab2xyz(args));\n}\n\nfunction lch2lab(lch) {\n var l = lch[0],\n c = lch[1],\n h = lch[2],\n a, b, hr;\n\n hr = h / 360 * 2 * Math.PI;\n a = c * Math.cos(hr);\n b = c * Math.sin(hr);\n return [l, a, b];\n}\n\nfunction lch2xyz(args) {\n return lab2xyz(lch2lab(args));\n}\n\nfunction lch2rgb(args) {\n return lab2rgb(lch2lab(args));\n}\n\nfunction keyword2rgb(keyword) {\n return cssKeywords[keyword];\n}\n\nfunction keyword2hsl(args) {\n return rgb2hsl(keyword2rgb(args));\n}\n\nfunction keyword2hsv(args) {\n return rgb2hsv(keyword2rgb(args));\n}\n\nfunction keyword2hwb(args) {\n return rgb2hwb(keyword2rgb(args));\n}\n\nfunction keyword2cmyk(args) {\n return rgb2cmyk(keyword2rgb(args));\n}\n\nfunction keyword2lab(args) {\n return rgb2lab(keyword2rgb(args));\n}\n\nfunction keyword2xyz(args) {\n return rgb2xyz(keyword2rgb(args));\n}\n\nvar cssKeywords = {\n aliceblue: [240,248,255],\n antiquewhite: [250,235,215],\n aqua: [0,255,255],\n aquamarine: [127,255,212],\n azure: [240,255,255],\n beige: [245,245,220],\n bisque: [255,228,196],\n black: [0,0,0],\n blanchedalmond: [255,235,205],\n blue: [0,0,255],\n blueviolet: [138,43,226],\n brown: [165,42,42],\n burlywood: [222,184,135],\n cadetblue: [95,158,160],\n chartreuse: [127,255,0],\n chocolate: [210,105,30],\n coral: [255,127,80],\n cornflowerblue: [100,149,237],\n cornsilk: [255,248,220],\n crimson: [220,20,60],\n cyan: [0,255,255],\n darkblue: [0,0,139],\n darkcyan: [0,139,139],\n darkgoldenrod: [184,134,11],\n darkgray: [169,169,169],\n darkgreen: [0,100,0],\n darkgrey: [169,169,169],\n darkkhaki: [189,183,107],\n darkmagenta: [139,0,139],\n darkolivegreen: [85,107,47],\n darkorange: [255,140,0],\n darkorchid: [153,50,204],\n darkred: [139,0,0],\n darksalmon: [233,150,122],\n darkseagreen: [143,188,143],\n darkslateblue: [72,61,139],\n darkslategray: [47,79,79],\n darkslategrey: [47,79,79],\n darkturquoise: [0,206,209],\n darkviolet: [148,0,211],\n deeppink: [255,20,147],\n deepskyblue: [0,191,255],\n dimgray: [105,105,105],\n dimgrey: [105,105,105],\n dodgerblue: [30,144,255],\n firebrick: [178,34,34],\n floralwhite: [255,250,240],\n forestgreen: [34,139,34],\n fuchsia: [255,0,255],\n gainsboro: [220,220,220],\n ghostwhite: [248,248,255],\n gold: [255,215,0],\n goldenrod: [218,165,32],\n gray: [128,128,128],\n green: [0,128,0],\n greenyellow: [173,255,47],\n grey: [128,128,128],\n honeydew: [240,255,240],\n hotpink: [255,105,180],\n indianred: [205,92,92],\n indigo: [75,0,130],\n ivory: [255,255,240],\n khaki: [240,230,140],\n lavender: [230,230,250],\n lavenderblush: [255,240,245],\n lawngreen: [124,252,0],\n lemonchiffon: [255,250,205],\n lightblue: [173,216,230],\n lightcoral: [240,128,128],\n lightcyan: [224,255,255],\n lightgoldenrodyellow: [250,250,210],\n lightgray: [211,211,211],\n lightgreen: [144,238,144],\n lightgrey: [211,211,211],\n lightpink: [255,182,193],\n lightsalmon: [255,160,122],\n lightseagreen: [32,178,170],\n lightskyblue: [135,206,250],\n lightslategray: [119,136,153],\n lightslategrey: [119,136,153],\n lightsteelblue: [176,196,222],\n lightyellow: [255,255,224],\n lime: [0,255,0],\n limegreen: [50,205,50],\n linen: [250,240,230],\n magenta: [255,0,255],\n maroon: [128,0,0],\n mediumaquamarine: [102,205,170],\n mediumblue: [0,0,205],\n mediumorchid: [186,85,211],\n mediumpurple: [147,112,219],\n mediumseagreen: [60,179,113],\n mediumslateblue: [123,104,238],\n mediumspringgreen: [0,250,154],\n mediumturquoise: [72,209,204],\n mediumvioletred: [199,21,133],\n midnightblue: [25,25,112],\n mintcream: [245,255,250],\n mistyrose: [255,228,225],\n moccasin: [255,228,181],\n navajowhite: [255,222,173],\n navy: [0,0,128],\n oldlace: [253,245,230],\n olive: [128,128,0],\n olivedrab: [107,142,35],\n orange: [255,165,0],\n orangered: [255,69,0],\n orchid: [218,112,214],\n palegoldenrod: [238,232,170],\n palegreen: [152,251,152],\n paleturquoise: [175,238,238],\n palevioletred: [219,112,147],\n papayawhip: [255,239,213],\n peachpuff: [255,218,185],\n peru: [205,133,63],\n pink: [255,192,203],\n plum: [221,160,221],\n powderblue: [176,224,230],\n purple: [128,0,128],\n rebeccapurple: [102, 51, 153],\n red: [255,0,0],\n rosybrown: [188,143,143],\n royalblue: [65,105,225],\n saddlebrown: [139,69,19],\n salmon: [250,128,114],\n sandybrown: [244,164,96],\n seagreen: [46,139,87],\n seashell: [255,245,238],\n sienna: [160,82,45],\n silver: [192,192,192],\n skyblue: [135,206,235],\n slateblue: [106,90,205],\n slategray: [112,128,144],\n slategrey: [112,128,144],\n snow: [255,250,250],\n springgreen: [0,255,127],\n steelblue: [70,130,180],\n tan: [210,180,140],\n teal: [0,128,128],\n thistle: [216,191,216],\n tomato: [255,99,71],\n turquoise: [64,224,208],\n violet: [238,130,238],\n wheat: [245,222,179],\n white: [255,255,255],\n whitesmoke: [245,245,245],\n yellow: [255,255,0],\n yellowgreen: [154,205,50]\n};\n\nvar reverseKeywords = {};\nfor (var key in cssKeywords) {\n reverseKeywords[JSON.stringify(cssKeywords[key])] = key;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/parse-color/node_modules/color-convert/conversions.js\n// module id = 11\n// module chunks = 0","var isBuffer = require('is-buffer');\nvar toString = Object.prototype.toString;\n\n/**\n * Get the native `typeof` a value.\n *\n * @param {*} `val`\n * @return {*} Native javascript type\n */\n\nmodule.exports = function kindOf(val) {\n // primitivies\n if (typeof val === 'undefined') {\n return 'undefined';\n }\n if (val === null) {\n return 'null';\n }\n if (val === true || val === false || val instanceof Boolean) {\n return 'boolean';\n }\n if (typeof val === 'string' || val instanceof String) {\n return 'string';\n }\n if (typeof val === 'number' || val instanceof Number) {\n return 'number';\n }\n\n // functions\n if (typeof val === 'function' || val instanceof Function) {\n return 'function';\n }\n\n // array\n if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {\n return 'array';\n }\n\n // check for instances of RegExp and Date before calling `toString`\n if (val instanceof RegExp) {\n return 'regexp';\n }\n if (val instanceof Date) {\n return 'date';\n }\n\n // other objects\n var type = toString.call(val);\n\n if (type === '[object RegExp]') {\n return 'regexp';\n }\n if (type === '[object Date]') {\n return 'date';\n }\n if (type === '[object Arguments]') {\n return 'arguments';\n }\n if (type === '[object Error]') {\n return 'error';\n }\n\n // buffer\n if (isBuffer(val)) {\n return 'buffer';\n }\n\n // es6: Map, WeakMap, Set, WeakSet\n if (type === '[object Set]') {\n return 'set';\n }\n if (type === '[object WeakSet]') {\n return 'weakset';\n }\n if (type === '[object Map]') {\n return 'map';\n }\n if (type === '[object WeakMap]') {\n return 'weakmap';\n }\n if (type === '[object Symbol]') {\n return 'symbol';\n }\n\n // typed arrays\n if (type === '[object Int8Array]') {\n return 'int8array';\n }\n if (type === '[object Uint8Array]') {\n return 'uint8array';\n }\n if (type === '[object Uint8ClampedArray]') {\n return 'uint8clampedarray';\n }\n if (type === '[object Int16Array]') {\n return 'int16array';\n }\n if (type === '[object Uint16Array]') {\n return 'uint16array';\n }\n if (type === '[object Int32Array]') {\n return 'int32array';\n }\n if (type === '[object Uint32Array]') {\n return 'uint32array';\n }\n if (type === '[object Float32Array]') {\n return 'float32array';\n }\n if (type === '[object Float64Array]') {\n return 'float64array';\n }\n\n // must be a plain object\n return 'object';\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/kind-of/index.js\n// module id = 12\n// module chunks = 0","/*!\n * Determine if an object is a Buffer\n *\n * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>\n * @license MIT\n */\n\n// The _isBuffer check is for Safari 5-7 support, because it's missing\n// Object.prototype.constructor. Remove this eventually\nmodule.exports = function (obj) {\n return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n}\n\nfunction isBuffer (obj) {\n return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n}\n\n// For Node v0.10 support. Remove this eventually.\nfunction isSlowBuffer (obj) {\n return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/is-buffer/index.js\n// module id = 13\n// module chunks = 0","var lodash = require(\"lodash\");\nvar isarray = require(\"is-array\");\nvar isnumber = require(\"is-number\");\nvar isstring = require(\"is-string\");\nvar parse = require(\"parse-color\");\n\nfunction convert(data) {\n data = isarray(data[0]) && data[0].length !== 3 ? lodash.flatten(data, 1) : data;\n\n if (isnumber(data[0])) {\n data = data.map(function(d) {\n return [ d, d, d ];\n });\n }\n\n if (isstring(data[0])) {\n data = data.map(function(d) {\n return parse(d).rgb.map(function(c) {\n return c / 255;\n });\n });\n }\n\n return data;\n}\n\nmodule.exports = convert;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/convert.js\n// module id = 14\n// module chunks = 0","/**\n * @license\n * Lodash <https://lodash.com/>\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n;(function() {\n\n /** Used as a safe reference for `undefined` in pre-ES5 environments. */\n var undefined;\n\n /** Used as the semantic version number. */\n var VERSION = '4.17.4';\n\n /** Used as the size to enable large array optimizations. */\n var LARGE_ARRAY_SIZE = 200;\n\n /** Error message constants. */\n var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',\n FUNC_ERROR_TEXT = 'Expected a function';\n\n /** Used to stand-in for `undefined` hash values. */\n var HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n /** Used as the maximum memoize cache size. */\n var MAX_MEMOIZE_SIZE = 500;\n\n /** Used as the internal argument placeholder. */\n var PLACEHOLDER = '__lodash_placeholder__';\n\n /** Used to compose bitmasks for cloning. */\n var CLONE_DEEP_FLAG = 1,\n CLONE_FLAT_FLAG = 2,\n CLONE_SYMBOLS_FLAG = 4;\n\n /** Used to compose bitmasks for value comparisons. */\n var COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n /** Used to compose bitmasks for function metadata. */\n var WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_BOUND_FLAG = 4,\n WRAP_CURRY_FLAG = 8,\n WRAP_CURRY_RIGHT_FLAG = 16,\n WRAP_PARTIAL_FLAG = 32,\n WRAP_PARTIAL_RIGHT_FLAG = 64,\n WRAP_ARY_FLAG = 128,\n WRAP_REARG_FLAG = 256,\n WRAP_FLIP_FLAG = 512;\n\n /** Used as default options for `_.truncate`. */\n var DEFAULT_TRUNC_LENGTH = 30,\n DEFAULT_TRUNC_OMISSION = '...';\n\n /** Used to detect hot functions by number of calls within a span of milliseconds. */\n var HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n /** Used to indicate the type of lazy iteratees. */\n var LAZY_FILTER_FLAG = 1,\n LAZY_MAP_FLAG = 2,\n LAZY_WHILE_FLAG = 3;\n\n /** Used as references for various `Number` constants. */\n var INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n /** Used as references for the maximum length and index of an array. */\n var MAX_ARRAY_LENGTH = 4294967295,\n MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,\n HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;\n\n /** Used to associate wrap methods with their bit flags. */\n var wrapFlags = [\n ['ary', WRAP_ARY_FLAG],\n ['bind', WRAP_BIND_FLAG],\n ['bindKey', WRAP_BIND_KEY_FLAG],\n ['curry', WRAP_CURRY_FLAG],\n ['curryRight', WRAP_CURRY_RIGHT_FLAG],\n ['flip', WRAP_FLIP_FLAG],\n ['partial', WRAP_PARTIAL_FLAG],\n ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],\n ['rearg', WRAP_REARG_FLAG]\n ];\n\n /** `Object#toString` result references. */\n var argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n asyncTag = '[object AsyncFunction]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n domExcTag = '[object DOMException]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n nullTag = '[object Null]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n proxyTag = '[object Proxy]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n undefinedTag = '[object Undefined]',\n weakMapTag = '[object WeakMap]',\n weakSetTag = '[object WeakSet]';\n\n var arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n /** Used to match empty string literals in compiled template source. */\n var reEmptyStringLeading = /\\b__p \\+= '';/g,\n reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n\n /** Used to match HTML entities and HTML characters. */\n var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,\n reUnescapedHtml = /[&<>\"']/g,\n reHasEscapedHtml = RegExp(reEscapedHtml.source),\n reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n /** Used to match template delimiters. */\n var reEscape = /<%-([\\s\\S]+?)%>/g,\n reEvaluate = /<%([\\s\\S]+?)%>/g,\n reInterpolate = /<%=([\\s\\S]+?)%>/g;\n\n /** Used to match property names within property paths. */\n var reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/,\n reLeadingDot = /^\\./,\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n /**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\n var reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g,\n reHasRegExpChar = RegExp(reRegExpChar.source);\n\n /** Used to match leading and trailing whitespace. */\n var reTrim = /^\\s+|\\s+$/g,\n reTrimStart = /^\\s+/,\n reTrimEnd = /\\s+$/;\n\n /** Used to match wrap detail comments. */\n var reWrapComment = /\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/,\n reWrapDetails = /\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,\n reSplitDetails = /,? & /;\n\n /** Used to match words composed of alphanumeric characters. */\n var reAsciiWord = /[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+/g;\n\n /** Used to match backslashes in property paths. */\n var reEscapeChar = /\\\\(\\\\)?/g;\n\n /**\n * Used to match\n * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).\n */\n var reEsTemplate = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n\n /** Used to match `RegExp` flags from their coerced string values. */\n var reFlags = /\\w*$/;\n\n /** Used to detect bad signed hexadecimal string values. */\n var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n /** Used to detect binary string values. */\n var reIsBinary = /^0b[01]+$/i;\n\n /** Used to detect host constructors (Safari). */\n var reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n /** Used to detect octal string values. */\n var reIsOctal = /^0o[0-7]+$/i;\n\n /** Used to detect unsigned integer values. */\n var reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n /** Used to match Latin Unicode letters (excluding mathematical operators). */\n var reLatin = /[\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\xff\\u0100-\\u017f]/g;\n\n /** Used to ensure capturing order of template delimiters. */\n var reNoMatch = /($^)/;\n\n /** Used to match unescaped characters in compiled string literals. */\n var reUnescapedString = /['\\n\\r\\u2028\\u2029\\\\]/g;\n\n /** Used to compose unicode character classes. */\n var rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsDingbatRange = '\\\\u2700-\\\\u27bf',\n rsLowerRange = 'a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff',\n rsMathOpRange = '\\\\xac\\\\xb1\\\\xd7\\\\xf7',\n rsNonCharRange = '\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf',\n rsPunctuationRange = '\\\\u2000-\\\\u206f',\n rsSpaceRange = ' \\\\t\\\\x0b\\\\f\\\\xa0\\\\ufeff\\\\n\\\\r\\\\u2028\\\\u2029\\\\u1680\\\\u180e\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200a\\\\u202f\\\\u205f\\\\u3000',\n rsUpperRange = 'A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde',\n rsVarRange = '\\\\ufe0e\\\\ufe0f',\n rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;\n\n /** Used to compose unicode capture groups. */\n var rsApos = \"['\\u2019]\",\n rsAstral = '[' + rsAstralRange + ']',\n rsBreak = '[' + rsBreakRange + ']',\n rsCombo = '[' + rsComboRange + ']',\n rsDigits = '\\\\d+',\n rsDingbat = '[' + rsDingbatRange + ']',\n rsLower = '[' + rsLowerRange + ']',\n rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',\n rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n rsNonAstral = '[^' + rsAstralRange + ']',\n rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n rsUpper = '[' + rsUpperRange + ']',\n rsZWJ = '\\\\u200d';\n\n /** Used to compose unicode regexes. */\n var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',\n rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',\n rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',\n rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',\n reOptMod = rsModifier + '?',\n rsOptVar = '[' + rsVarRange + ']?',\n rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n rsOrdLower = '\\\\d*(?:(?:1st|2nd|3rd|(?![123])\\\\dth)\\\\b)',\n rsOrdUpper = '\\\\d*(?:(?:1ST|2ND|3RD|(?![123])\\\\dTH)\\\\b)',\n rsSeq = rsOptVar + reOptMod + rsOptJoin,\n rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,\n rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n\n /** Used to match apostrophes. */\n var reApos = RegExp(rsApos, 'g');\n\n /**\n * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and\n * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).\n */\n var reComboMark = RegExp(rsCombo, 'g');\n\n /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */\n var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');\n\n /** Used to match complex or compound words. */\n var reUnicodeWord = RegExp([\n rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',\n rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',\n rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,\n rsUpper + '+' + rsOptContrUpper,\n rsOrdUpper,\n rsOrdLower,\n rsDigits,\n rsEmoji\n ].join('|'), 'g');\n\n /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */\n var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');\n\n /** Used to detect strings that need a more robust regexp to match words. */\n var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;\n\n /** Used to assign default `context` object properties. */\n var contextProps = [\n 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',\n 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',\n 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',\n 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',\n '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'\n ];\n\n /** Used to make template sourceURLs easier to identify. */\n var templateCounter = -1;\n\n /** Used to identify `toStringTag` values of typed arrays. */\n var typedArrayTags = {};\n typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\n typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\n typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\n typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\n typedArrayTags[uint32Tag] = true;\n typedArrayTags[argsTag] = typedArrayTags[arrayTag] =\n typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\n typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\n typedArrayTags[errorTag] = typedArrayTags[funcTag] =\n typedArrayTags[mapTag] = typedArrayTags[numberTag] =\n typedArrayTags[objectTag] = typedArrayTags[regexpTag] =\n typedArrayTags[setTag] = typedArrayTags[stringTag] =\n typedArrayTags[weakMapTag] = false;\n\n /** Used to identify `toStringTag` values supported by `_.clone`. */\n var cloneableTags = {};\n cloneableTags[argsTag] = cloneableTags[arrayTag] =\n cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =\n cloneableTags[boolTag] = cloneableTags[dateTag] =\n cloneableTags[float32Tag] = cloneableTags[float64Tag] =\n cloneableTags[int8Tag] = cloneableTags[int16Tag] =\n cloneableTags[int32Tag] = cloneableTags[mapTag] =\n cloneableTags[numberTag] = cloneableTags[objectTag] =\n cloneableTags[regexpTag] = cloneableTags[setTag] =\n cloneableTags[stringTag] = cloneableTags[symbolTag] =\n cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =\n cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;\n cloneableTags[errorTag] = cloneableTags[funcTag] =\n cloneableTags[weakMapTag] = false;\n\n /** Used to map Latin Unicode letters to basic Latin letters. */\n var deburredLetters = {\n // Latin-1 Supplement block.\n '\\xc0': 'A', '\\xc1': 'A', '\\xc2': 'A', '\\xc3': 'A', '\\xc4': 'A', '\\xc5': 'A',\n '\\xe0': 'a', '\\xe1': 'a', '\\xe2': 'a', '\\xe3': 'a', '\\xe4': 'a', '\\xe5': 'a',\n '\\xc7': 'C', '\\xe7': 'c',\n '\\xd0': 'D', '\\xf0': 'd',\n '\\xc8': 'E', '\\xc9': 'E', '\\xca': 'E', '\\xcb': 'E',\n '\\xe8': 'e', '\\xe9': 'e', '\\xea': 'e', '\\xeb': 'e',\n '\\xcc': 'I', '\\xcd': 'I', '\\xce': 'I', '\\xcf': 'I',\n '\\xec': 'i', '\\xed': 'i', '\\xee': 'i', '\\xef': 'i',\n '\\xd1': 'N', '\\xf1': 'n',\n '\\xd2': 'O', '\\xd3': 'O', '\\xd4': 'O', '\\xd5': 'O', '\\xd6': 'O', '\\xd8': 'O',\n '\\xf2': 'o', '\\xf3': 'o', '\\xf4': 'o', '\\xf5': 'o', '\\xf6': 'o', '\\xf8': 'o',\n '\\xd9': 'U', '\\xda': 'U', '\\xdb': 'U', '\\xdc': 'U',\n '\\xf9': 'u', '\\xfa': 'u', '\\xfb': 'u', '\\xfc': 'u',\n '\\xdd': 'Y', '\\xfd': 'y', '\\xff': 'y',\n '\\xc6': 'Ae', '\\xe6': 'ae',\n '\\xde': 'Th', '\\xfe': 'th',\n '\\xdf': 'ss',\n // Latin Extended-A block.\n '\\u0100': 'A', '\\u0102': 'A', '\\u0104': 'A',\n '\\u0101': 'a', '\\u0103': 'a', '\\u0105': 'a',\n '\\u0106': 'C', '\\u0108': 'C', '\\u010a': 'C', '\\u010c': 'C',\n '\\u0107': 'c', '\\u0109': 'c', '\\u010b': 'c', '\\u010d': 'c',\n '\\u010e': 'D', '\\u0110': 'D', '\\u010f': 'd', '\\u0111': 'd',\n '\\u0112': 'E', '\\u0114': 'E', '\\u0116': 'E', '\\u0118': 'E', '\\u011a': 'E',\n '\\u0113': 'e', '\\u0115': 'e', '\\u0117': 'e', '\\u0119': 'e', '\\u011b': 'e',\n '\\u011c': 'G', '\\u011e': 'G', '\\u0120': 'G', '\\u0122': 'G',\n '\\u011d': 'g', '\\u011f': 'g', '\\u0121': 'g', '\\u0123': 'g',\n '\\u0124': 'H', '\\u0126': 'H', '\\u0125': 'h', '\\u0127': 'h',\n '\\u0128': 'I', '\\u012a': 'I', '\\u012c': 'I', '\\u012e': 'I', '\\u0130': 'I',\n '\\u0129': 'i', '\\u012b': 'i', '\\u012d': 'i', '\\u012f': 'i', '\\u0131': 'i',\n '\\u0134': 'J', '\\u0135': 'j',\n '\\u0136': 'K', '\\u0137': 'k', '\\u0138': 'k',\n '\\u0139': 'L', '\\u013b': 'L', '\\u013d': 'L', '\\u013f': 'L', '\\u0141': 'L',\n '\\u013a': 'l', '\\u013c': 'l', '\\u013e': 'l', '\\u0140': 'l', '\\u0142': 'l',\n '\\u0143': 'N', '\\u0145': 'N', '\\u0147': 'N', '\\u014a': 'N',\n '\\u0144': 'n', '\\u0146': 'n', '\\u0148': 'n', '\\u014b': 'n',\n '\\u014c': 'O', '\\u014e': 'O', '\\u0150': 'O',\n '\\u014d': 'o', '\\u014f': 'o', '\\u0151': 'o',\n '\\u0154': 'R', '\\u0156': 'R', '\\u0158': 'R',\n '\\u0155': 'r', '\\u0157': 'r', '\\u0159': 'r',\n '\\u015a': 'S', '\\u015c': 'S', '\\u015e': 'S', '\\u0160': 'S',\n '\\u015b': 's', '\\u015d': 's', '\\u015f': 's', '\\u0161': 's',\n '\\u0162': 'T', '\\u0164': 'T', '\\u0166': 'T',\n '\\u0163': 't', '\\u0165': 't', '\\u0167': 't',\n '\\u0168': 'U', '\\u016a': 'U', '\\u016c': 'U', '\\u016e': 'U', '\\u0170': 'U', '\\u0172': 'U',\n '\\u0169': 'u', '\\u016b': 'u', '\\u016d': 'u', '\\u016f': 'u', '\\u0171': 'u', '\\u0173': 'u',\n '\\u0174': 'W', '\\u0175': 'w',\n '\\u0176': 'Y', '\\u0177': 'y', '\\u0178': 'Y',\n '\\u0179': 'Z', '\\u017b': 'Z', '\\u017d': 'Z',\n '\\u017a': 'z', '\\u017c': 'z', '\\u017e': 'z',\n '\\u0132': 'IJ', '\\u0133': 'ij',\n '\\u0152': 'Oe', '\\u0153': 'oe',\n '\\u0149': \"'n\", '\\u017f': 's'\n };\n\n /** Used to map characters to HTML entities. */\n var htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n\n /** Used to map HTML entities to characters. */\n var htmlUnescapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\"\n };\n\n /** Used to escape characters for inclusion in compiled string literals. */\n var stringEscapes = {\n '\\\\': '\\\\',\n \"'\": \"'\",\n '\\n': 'n',\n '\\r': 'r',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n };\n\n /** Built-in method references without a dependency on `root`. */\n var freeParseFloat = parseFloat,\n freeParseInt = parseInt;\n\n /** Detect free variable `global` from Node.js. */\n var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n /** Detect free variable `self`. */\n var freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n /** Used as a reference to the global object. */\n var root = freeGlobal || freeSelf || Function('return this')();\n\n /** Detect free variable `exports`. */\n var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n /** Detect free variable `module`. */\n var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n /** Detect the popular CommonJS extension `module.exports`. */\n var moduleExports = freeModule && freeModule.exports === freeExports;\n\n /** Detect free variable `process` from Node.js. */\n var freeProcess = moduleExports && freeGlobal.process;\n\n /** Used to access faster Node.js helpers. */\n var nodeUtil = (function() {\n try {\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n }());\n\n /* Node.js helper references. */\n var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,\n nodeIsDate = nodeUtil && nodeUtil.isDate,\n nodeIsMap = nodeUtil && nodeUtil.isMap,\n nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,\n nodeIsSet = nodeUtil && nodeUtil.isSet,\n nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Adds the key-value `pair` to `map`.\n *\n * @private\n * @param {Object} map The map to modify.\n * @param {Array} pair The key-value pair to add.\n * @returns {Object} Returns `map`.\n */\n function addMapEntry(map, pair) {\n // Don't return `map.set` because it's not chainable in IE 11.\n map.set(pair[0], pair[1]);\n return map;\n }\n\n /**\n * Adds `value` to `set`.\n *\n * @private\n * @param {Object} set The set to modify.\n * @param {*} value The value to add.\n * @returns {Object} Returns `set`.\n */\n function addSetEntry(set, value) {\n // Don't return `set.add` because it's not chainable in IE 11.\n set.add(value);\n return set;\n }\n\n /**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\n function apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n }\n\n /**\n * A specialized version of `baseAggregator` for arrays.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform keys.\n * @param {Object} accumulator The initial aggregated object.\n * @returns {Function} Returns `accumulator`.\n */\n function arrayAggregator(array, setter, iteratee, accumulator) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n var value = array[index];\n setter(accumulator, value, iteratee(value), array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.forEach` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\n function arrayEach(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (iteratee(array[index], index, array) === false) {\n break;\n }\n }\n return array;\n }\n\n /**\n * A specialized version of `_.forEachRight` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\n function arrayEachRight(array, iteratee) {\n var length = array == null ? 0 : array.length;\n\n while (length--) {\n if (iteratee(array[length], length, array) === false) {\n break;\n }\n }\n return array;\n }\n\n /**\n * A specialized version of `_.every` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`.\n */\n function arrayEvery(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (!predicate(array[index], index, array)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\n function arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.includes` for arrays without support for\n * specifying an index to search from.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\n function arrayIncludes(array, value) {\n var length = array == null ? 0 : array.length;\n return !!length && baseIndexOf(array, value, 0) > -1;\n }\n\n /**\n * This function is like `arrayIncludes` except that it accepts a comparator.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\n function arrayIncludesWith(array, value, comparator) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (comparator(value, array[index])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\n function arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n }\n\n /**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\n function arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n }\n\n /**\n * A specialized version of `_.reduce` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initAccum] Specify using the first element of `array` as\n * the initial value.\n * @returns {*} Returns the accumulated value.\n */\n function arrayReduce(array, iteratee, accumulator, initAccum) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n if (initAccum && length) {\n accumulator = array[++index];\n }\n while (++index < length) {\n accumulator = iteratee(accumulator, array[index], index, array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.reduceRight` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initAccum] Specify using the last element of `array` as\n * the initial value.\n * @returns {*} Returns the accumulated value.\n */\n function arrayReduceRight(array, iteratee, accumulator, initAccum) {\n var length = array == null ? 0 : array.length;\n if (initAccum && length) {\n accumulator = array[--length];\n }\n while (length--) {\n accumulator = iteratee(accumulator, array[length], length, array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\n function arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Gets the size of an ASCII `string`.\n *\n * @private\n * @param {string} string The string inspect.\n * @returns {number} Returns the string size.\n */\n var asciiSize = baseProperty('length');\n\n /**\n * Converts an ASCII `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\n function asciiToArray(string) {\n return string.split('');\n }\n\n /**\n * Splits an ASCII `string` into an array of its words.\n *\n * @private\n * @param {string} The string to inspect.\n * @returns {Array} Returns the words of `string`.\n */\n function asciiWords(string) {\n return string.match(reAsciiWord) || [];\n }\n\n /**\n * The base implementation of methods like `_.findKey` and `_.findLastKey`,\n * without support for iteratee shorthands, which iterates over `collection`\n * using `eachFunc`.\n *\n * @private\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @returns {*} Returns the found element or its key, else `undefined`.\n */\n function baseFindKey(collection, predicate, eachFunc) {\n var result;\n eachFunc(collection, function(value, key, collection) {\n if (predicate(value, key, collection)) {\n result = key;\n return false;\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseIndexOf(array, value, fromIndex) {\n return value === value\n ? strictIndexOf(array, value, fromIndex)\n : baseFindIndex(array, baseIsNaN, fromIndex);\n }\n\n /**\n * This function is like `baseIndexOf` except that it accepts a comparator.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseIndexOfWith(array, value, fromIndex, comparator) {\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (comparator(array[index], value)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * The base implementation of `_.isNaN` without support for number objects.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n */\n function baseIsNaN(value) {\n return value !== value;\n }\n\n /**\n * The base implementation of `_.mean` and `_.meanBy` without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the mean.\n */\n function baseMean(array, iteratee) {\n var length = array == null ? 0 : array.length;\n return length ? (baseSum(array, iteratee) / length) : NAN;\n }\n\n /**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\n function baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n }\n\n /**\n * The base implementation of `_.propertyOf` without support for deep paths.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n */\n function basePropertyOf(object) {\n return function(key) {\n return object == null ? undefined : object[key];\n };\n }\n\n /**\n * The base implementation of `_.reduce` and `_.reduceRight`, without support\n * for iteratee shorthands, which iterates over `collection` using `eachFunc`.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} accumulator The initial value.\n * @param {boolean} initAccum Specify using the first or last element of\n * `collection` as the initial value.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @returns {*} Returns the accumulated value.\n */\n function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {\n eachFunc(collection, function(value, index, collection) {\n accumulator = initAccum\n ? (initAccum = false, value)\n : iteratee(accumulator, value, index, collection);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `_.sortBy` which uses `comparer` to define the\n * sort order of `array` and replaces criteria objects with their corresponding\n * values.\n *\n * @private\n * @param {Array} array The array to sort.\n * @param {Function} comparer The function to define sort order.\n * @returns {Array} Returns `array`.\n */\n function baseSortBy(array, comparer) {\n var length = array.length;\n\n array.sort(comparer);\n while (length--) {\n array[length] = array[length].value;\n }\n return array;\n }\n\n /**\n * The base implementation of `_.sum` and `_.sumBy` without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the sum.\n */\n function baseSum(array, iteratee) {\n var result,\n index = -1,\n length = array.length;\n\n while (++index < length) {\n var current = iteratee(array[index]);\n if (current !== undefined) {\n result = result === undefined ? current : (result + current);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\n function baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n }\n\n /**\n * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array\n * of key-value pairs for `object` corresponding to the property names of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the key-value pairs.\n */\n function baseToPairs(object, props) {\n return arrayMap(props, function(key) {\n return [key, object[key]];\n });\n }\n\n /**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\n function baseUnary(func) {\n return function(value) {\n return func(value);\n };\n }\n\n /**\n * The base implementation of `_.values` and `_.valuesIn` which creates an\n * array of `object` property values corresponding to the property names\n * of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the array of property values.\n */\n function baseValues(object, props) {\n return arrayMap(props, function(key) {\n return object[key];\n });\n }\n\n /**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function cacheHas(cache, key) {\n return cache.has(key);\n }\n\n /**\n * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the first unmatched string symbol.\n */\n function charsStartIndex(strSymbols, chrSymbols) {\n var index = -1,\n length = strSymbols.length;\n\n while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n }\n\n /**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the last unmatched string symbol.\n */\n function charsEndIndex(strSymbols, chrSymbols) {\n var index = strSymbols.length;\n\n while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n }\n\n /**\n * Gets the number of `placeholder` occurrences in `array`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} placeholder The placeholder to search for.\n * @returns {number} Returns the placeholder count.\n */\n function countHolders(array, placeholder) {\n var length = array.length,\n result = 0;\n\n while (length--) {\n if (array[length] === placeholder) {\n ++result;\n }\n }\n return result;\n }\n\n /**\n * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A\n * letters to basic Latin letters.\n *\n * @private\n * @param {string} letter The matched letter to deburr.\n * @returns {string} Returns the deburred letter.\n */\n var deburrLetter = basePropertyOf(deburredLetters);\n\n /**\n * Used by `_.escape` to convert characters to HTML entities.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\n var escapeHtmlChar = basePropertyOf(htmlEscapes);\n\n /**\n * Used by `_.template` to escape characters for inclusion in compiled string literals.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\n function escapeStringChar(chr) {\n return '\\\\' + stringEscapes[chr];\n }\n\n /**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\n function getValue(object, key) {\n return object == null ? undefined : object[key];\n }\n\n /**\n * Checks if `string` contains Unicode symbols.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {boolean} Returns `true` if a symbol is found, else `false`.\n */\n function hasUnicode(string) {\n return reHasUnicode.test(string);\n }\n\n /**\n * Checks if `string` contains a word composed of Unicode symbols.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {boolean} Returns `true` if a word is found, else `false`.\n */\n function hasUnicodeWord(string) {\n return reHasUnicodeWord.test(string);\n }\n\n /**\n * Converts `iterator` to an array.\n *\n * @private\n * @param {Object} iterator The iterator to convert.\n * @returns {Array} Returns the converted array.\n */\n function iteratorToArray(iterator) {\n var data,\n result = [];\n\n while (!(data = iterator.next()).done) {\n result.push(data.value);\n }\n return result;\n }\n\n /**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\n function mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n }\n\n /**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\n function overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n }\n\n /**\n * Replaces all `placeholder` elements in `array` with an internal placeholder\n * and returns an array of their indexes.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {*} placeholder The placeholder to replace.\n * @returns {Array} Returns the new array of placeholder indexes.\n */\n function replaceHolders(array, placeholder) {\n var index = -1,\n length = array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value === placeholder || value === PLACEHOLDER) {\n array[index] = PLACEHOLDER;\n result[resIndex++] = index;\n }\n }\n return result;\n }\n\n /**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\n function setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n }\n\n /**\n * Converts `set` to its value-value pairs.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the value-value pairs.\n */\n function setToPairs(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = [value, value];\n });\n return result;\n }\n\n /**\n * A specialized version of `_.indexOf` which performs strict equality\n * comparisons of values, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function strictIndexOf(array, value, fromIndex) {\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * A specialized version of `_.lastIndexOf` which performs strict equality\n * comparisons of values, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function strictLastIndexOf(array, value, fromIndex) {\n var index = fromIndex + 1;\n while (index--) {\n if (array[index] === value) {\n return index;\n }\n }\n return index;\n }\n\n /**\n * Gets the number of symbols in `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the string size.\n */\n function stringSize(string) {\n return hasUnicode(string)\n ? unicodeSize(string)\n : asciiSize(string);\n }\n\n /**\n * Converts `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\n function stringToArray(string) {\n return hasUnicode(string)\n ? unicodeToArray(string)\n : asciiToArray(string);\n }\n\n /**\n * Used by `_.unescape` to convert HTML entities to characters.\n *\n * @private\n * @param {string} chr The matched character to unescape.\n * @returns {string} Returns the unescaped character.\n */\n var unescapeHtmlChar = basePropertyOf(htmlUnescapes);\n\n /**\n * Gets the size of a Unicode `string`.\n *\n * @private\n * @param {string} string The string inspect.\n * @returns {number} Returns the string size.\n */\n function unicodeSize(string) {\n var result = reUnicode.lastIndex = 0;\n while (reUnicode.test(string)) {\n ++result;\n }\n return result;\n }\n\n /**\n * Converts a Unicode `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\n function unicodeToArray(string) {\n return string.match(reUnicode) || [];\n }\n\n /**\n * Splits a Unicode `string` into an array of its words.\n *\n * @private\n * @param {string} The string to inspect.\n * @returns {Array} Returns the words of `string`.\n */\n function unicodeWords(string) {\n return string.match(reUnicodeWord) || [];\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Create a new pristine `lodash` function using the `context` object.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Util\n * @param {Object} [context=root] The context object.\n * @returns {Function} Returns a new `lodash` function.\n * @example\n *\n * _.mixin({ 'foo': _.constant('foo') });\n *\n * var lodash = _.runInContext();\n * lodash.mixin({ 'bar': lodash.constant('bar') });\n *\n * _.isFunction(_.foo);\n * // => true\n * _.isFunction(_.bar);\n * // => false\n *\n * lodash.isFunction(lodash.foo);\n * // => false\n * lodash.isFunction(lodash.bar);\n * // => true\n *\n * // Create a suped-up `defer` in Node.js.\n * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;\n */\n var runInContext = (function runInContext(context) {\n context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));\n\n /** Built-in constructor references. */\n var Array = context.Array,\n Date = context.Date,\n Error = context.Error,\n Function = context.Function,\n Math = context.Math,\n Object = context.Object,\n RegExp = context.RegExp,\n String = context.String,\n TypeError = context.TypeError;\n\n /** Used for built-in method references. */\n var arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n /** Used to detect overreaching core-js shims. */\n var coreJsData = context['__core-js_shared__'];\n\n /** Used to resolve the decompiled source of functions. */\n var funcToString = funcProto.toString;\n\n /** Used to check objects for own properties. */\n var hasOwnProperty = objectProto.hasOwnProperty;\n\n /** Used to generate unique IDs. */\n var idCounter = 0;\n\n /** Used to detect methods masquerading as native. */\n var maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n }());\n\n /**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\n var nativeObjectToString = objectProto.toString;\n\n /** Used to infer the `Object` constructor. */\n var objectCtorString = funcToString.call(Object);\n\n /** Used to restore the original `_` reference in `_.noConflict`. */\n var oldDash = root._;\n\n /** Used to detect if a method is native. */\n var reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n );\n\n /** Built-in value references. */\n var Buffer = moduleExports ? context.Buffer : undefined,\n Symbol = context.Symbol,\n Uint8Array = context.Uint8Array,\n allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,\n getPrototype = overArg(Object.getPrototypeOf, Object),\n objectCreate = Object.create,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice,\n spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,\n symIterator = Symbol ? Symbol.iterator : undefined,\n symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n var defineProperty = (function() {\n try {\n var func = getNative(Object, 'defineProperty');\n func({}, '', {});\n return func;\n } catch (e) {}\n }());\n\n /** Mocked built-ins. */\n var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,\n ctxNow = Date && Date.now !== root.Date.now && Date.now,\n ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;\n\n /* Built-in method references for those with the same name as other `lodash` methods. */\n var nativeCeil = Math.ceil,\n nativeFloor = Math.floor,\n nativeGetSymbols = Object.getOwnPropertySymbols,\n nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,\n nativeIsFinite = context.isFinite,\n nativeJoin = arrayProto.join,\n nativeKeys = overArg(Object.keys, Object),\n nativeMax = Math.max,\n nativeMin = Math.min,\n nativeNow = Date.now,\n nativeParseInt = context.parseInt,\n nativeRandom = Math.random,\n nativeReverse = arrayProto.reverse;\n\n /* Built-in method references that are verified to be native. */\n var DataView = getNative(context, 'DataView'),\n Map = getNative(context, 'Map'),\n Promise = getNative(context, 'Promise'),\n Set = getNative(context, 'Set'),\n WeakMap = getNative(context, 'WeakMap'),\n nativeCreate = getNative(Object, 'create');\n\n /** Used to store function metadata. */\n var metaMap = WeakMap && new WeakMap;\n\n /** Used to lookup unminified function names. */\n var realNames = {};\n\n /** Used to detect maps, sets, and weakmaps. */\n var dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n /** Used to convert symbols to primitives and strings. */\n var symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a `lodash` object which wraps `value` to enable implicit method\n * chain sequences. Methods that operate on and return arrays, collections,\n * and functions can be chained together. Methods that retrieve a single value\n * or may return a primitive value will automatically end the chain sequence\n * and return the unwrapped value. Otherwise, the value must be unwrapped\n * with `_#value`.\n *\n * Explicit chain sequences, which must be unwrapped with `_#value`, may be\n * enabled using `_.chain`.\n *\n * The execution of chained methods is lazy, that is, it's deferred until\n * `_#value` is implicitly or explicitly called.\n *\n * Lazy evaluation allows several methods to support shortcut fusion.\n * Shortcut fusion is an optimization to merge iteratee calls; this avoids\n * the creation of intermediate arrays and can greatly reduce the number of\n * iteratee executions. Sections of a chain sequence qualify for shortcut\n * fusion if the section is applied to an array and iteratees accept only\n * one argument. The heuristic for whether a section qualifies for shortcut\n * fusion is subject to change.\n *\n * Chaining is supported in custom builds as long as the `_#value` method is\n * directly or indirectly included in the build.\n *\n * In addition to lodash methods, wrappers have `Array` and `String` methods.\n *\n * The wrapper `Array` methods are:\n * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`\n *\n * The wrapper `String` methods are:\n * `replace` and `split`\n *\n * The wrapper methods that support shortcut fusion are:\n * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,\n * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,\n * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`\n *\n * The chainable wrapper methods are:\n * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,\n * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,\n * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,\n * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,\n * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,\n * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,\n * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,\n * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,\n * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,\n * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,\n * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,\n * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,\n * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,\n * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,\n * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,\n * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,\n * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,\n * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,\n * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,\n * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,\n * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,\n * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,\n * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,\n * `zipObject`, `zipObjectDeep`, and `zipWith`\n *\n * The wrapper methods that are **not** chainable by default are:\n * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,\n * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,\n * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,\n * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,\n * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,\n * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,\n * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,\n * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,\n * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,\n * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,\n * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,\n * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,\n * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,\n * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,\n * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,\n * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,\n * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,\n * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,\n * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,\n * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,\n * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,\n * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,\n * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,\n * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,\n * `upperFirst`, `value`, and `words`\n *\n * @name _\n * @constructor\n * @category Seq\n * @param {*} value The value to wrap in a `lodash` instance.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var wrapped = _([1, 2, 3]);\n *\n * // Returns an unwrapped value.\n * wrapped.reduce(_.add);\n * // => 6\n *\n * // Returns a wrapped value.\n * var squares = wrapped.map(square);\n *\n * _.isArray(squares);\n * // => false\n *\n * _.isArray(squares.value());\n * // => true\n */\n function lodash(value) {\n if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {\n if (value instanceof LodashWrapper) {\n return value;\n }\n if (hasOwnProperty.call(value, '__wrapped__')) {\n return wrapperClone(value);\n }\n }\n return new LodashWrapper(value);\n }\n\n /**\n * The base implementation of `_.create` without support for assigning\n * properties to the created object.\n *\n * @private\n * @param {Object} proto The object to inherit from.\n * @returns {Object} Returns the new object.\n */\n var baseCreate = (function() {\n function object() {}\n return function(proto) {\n if (!isObject(proto)) {\n return {};\n }\n if (objectCreate) {\n return objectCreate(proto);\n }\n object.prototype = proto;\n var result = new object;\n object.prototype = undefined;\n return result;\n };\n }());\n\n /**\n * The function whose prototype chain sequence wrappers inherit from.\n *\n * @private\n */\n function baseLodash() {\n // No operation performed.\n }\n\n /**\n * The base constructor for creating `lodash` wrapper objects.\n *\n * @private\n * @param {*} value The value to wrap.\n * @param {boolean} [chainAll] Enable explicit method chain sequences.\n */\n function LodashWrapper(value, chainAll) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__chain__ = !!chainAll;\n this.__index__ = 0;\n this.__values__ = undefined;\n }\n\n /**\n * By default, the template delimiters used by lodash are like those in\n * embedded Ruby (ERB) as well as ES2015 template strings. Change the\n * following template settings to use alternative delimiters.\n *\n * @static\n * @memberOf _\n * @type {Object}\n */\n lodash.templateSettings = {\n\n /**\n * Used to detect `data` property values to be HTML-escaped.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'escape': reEscape,\n\n /**\n * Used to detect code to be evaluated.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'evaluate': reEvaluate,\n\n /**\n * Used to detect `data` property values to inject.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'interpolate': reInterpolate,\n\n /**\n * Used to reference the data object in the template text.\n *\n * @memberOf _.templateSettings\n * @type {string}\n */\n 'variable': '',\n\n /**\n * Used to import variables into the compiled template.\n *\n * @memberOf _.templateSettings\n * @type {Object}\n */\n 'imports': {\n\n /**\n * A reference to the `lodash` function.\n *\n * @memberOf _.templateSettings.imports\n * @type {Function}\n */\n '_': lodash\n }\n };\n\n // Ensure wrappers are instances of `baseLodash`.\n lodash.prototype = baseLodash.prototype;\n lodash.prototype.constructor = lodash;\n\n LodashWrapper.prototype = baseCreate(baseLodash.prototype);\n LodashWrapper.prototype.constructor = LodashWrapper;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.\n *\n * @private\n * @constructor\n * @param {*} value The value to wrap.\n */\n function LazyWrapper(value) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__dir__ = 1;\n this.__filtered__ = false;\n this.__iteratees__ = [];\n this.__takeCount__ = MAX_ARRAY_LENGTH;\n this.__views__ = [];\n }\n\n /**\n * Creates a clone of the lazy wrapper object.\n *\n * @private\n * @name clone\n * @memberOf LazyWrapper\n * @returns {Object} Returns the cloned `LazyWrapper` object.\n */\n function lazyClone() {\n var result = new LazyWrapper(this.__wrapped__);\n result.__actions__ = copyArray(this.__actions__);\n result.__dir__ = this.__dir__;\n result.__filtered__ = this.__filtered__;\n result.__iteratees__ = copyArray(this.__iteratees__);\n result.__takeCount__ = this.__takeCount__;\n result.__views__ = copyArray(this.__views__);\n return result;\n }\n\n /**\n * Reverses the direction of lazy iteration.\n *\n * @private\n * @name reverse\n * @memberOf LazyWrapper\n * @returns {Object} Returns the new reversed `LazyWrapper` object.\n */\n function lazyReverse() {\n if (this.__filtered__) {\n var result = new LazyWrapper(this);\n result.__dir__ = -1;\n result.__filtered__ = true;\n } else {\n result = this.clone();\n result.__dir__ *= -1;\n }\n return result;\n }\n\n /**\n * Extracts the unwrapped value from its lazy wrapper.\n *\n * @private\n * @name value\n * @memberOf LazyWrapper\n * @returns {*} Returns the unwrapped value.\n */\n function lazyValue() {\n var array = this.__wrapped__.value(),\n dir = this.__dir__,\n isArr = isArray(array),\n isRight = dir < 0,\n arrLength = isArr ? array.length : 0,\n view = getView(0, arrLength, this.__views__),\n start = view.start,\n end = view.end,\n length = end - start,\n index = isRight ? end : (start - 1),\n iteratees = this.__iteratees__,\n iterLength = iteratees.length,\n resIndex = 0,\n takeCount = nativeMin(length, this.__takeCount__);\n\n if (!isArr || (!isRight && arrLength == length && takeCount == length)) {\n return baseWrapperValue(array, this.__actions__);\n }\n var result = [];\n\n outer:\n while (length-- && resIndex < takeCount) {\n index += dir;\n\n var iterIndex = -1,\n value = array[index];\n\n while (++iterIndex < iterLength) {\n var data = iteratees[iterIndex],\n iteratee = data.iteratee,\n type = data.type,\n computed = iteratee(value);\n\n if (type == LAZY_MAP_FLAG) {\n value = computed;\n } else if (!computed) {\n if (type == LAZY_FILTER_FLAG) {\n continue outer;\n } else {\n break outer;\n }\n }\n }\n result[resIndex++] = value;\n }\n return result;\n }\n\n // Ensure `LazyWrapper` is an instance of `baseLodash`.\n LazyWrapper.prototype = baseCreate(baseLodash.prototype);\n LazyWrapper.prototype.constructor = LazyWrapper;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n /**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\n function hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n }\n\n /**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n }\n\n /**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n }\n\n /**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n }\n\n /**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\n function hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n }\n\n // Add methods to `Hash`.\n Hash.prototype.clear = hashClear;\n Hash.prototype['delete'] = hashDelete;\n Hash.prototype.get = hashGet;\n Hash.prototype.has = hashHas;\n Hash.prototype.set = hashSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n /**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\n function listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n }\n\n /**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n }\n\n /**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n }\n\n /**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n }\n\n /**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\n function listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n }\n\n // Add methods to `ListCache`.\n ListCache.prototype.clear = listCacheClear;\n ListCache.prototype['delete'] = listCacheDelete;\n ListCache.prototype.get = listCacheGet;\n ListCache.prototype.has = listCacheHas;\n ListCache.prototype.set = listCacheSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n /**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\n function mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n }\n\n /**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n }\n\n /**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function mapCacheGet(key) {\n return getMapData(this, key).get(key);\n }\n\n /**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function mapCacheHas(key) {\n return getMapData(this, key).has(key);\n }\n\n /**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\n function mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n }\n\n // Add methods to `MapCache`.\n MapCache.prototype.clear = mapCacheClear;\n MapCache.prototype['delete'] = mapCacheDelete;\n MapCache.prototype.get = mapCacheGet;\n MapCache.prototype.has = mapCacheHas;\n MapCache.prototype.set = mapCacheSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\n function SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n }\n\n /**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\n function setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n }\n\n /**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\n function setCacheHas(value) {\n return this.__data__.has(value);\n }\n\n // Add methods to `SetCache`.\n SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\n SetCache.prototype.has = setCacheHas;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n }\n\n /**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\n function stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n }\n\n /**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n }\n\n /**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function stackGet(key) {\n return this.__data__.get(key);\n }\n\n /**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function stackHas(key) {\n return this.__data__.has(key);\n }\n\n /**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\n function stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n }\n\n // Add methods to `Stack`.\n Stack.prototype.clear = stackClear;\n Stack.prototype['delete'] = stackDelete;\n Stack.prototype.get = stackGet;\n Stack.prototype.has = stackHas;\n Stack.prototype.set = stackSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\n function arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.sample` for arrays.\n *\n * @private\n * @param {Array} array The array to sample.\n * @returns {*} Returns the random element.\n */\n function arraySample(array) {\n var length = array.length;\n return length ? array[baseRandom(0, length - 1)] : undefined;\n }\n\n /**\n * A specialized version of `_.sampleSize` for arrays.\n *\n * @private\n * @param {Array} array The array to sample.\n * @param {number} n The number of elements to sample.\n * @returns {Array} Returns the random elements.\n */\n function arraySampleSize(array, n) {\n return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));\n }\n\n /**\n * A specialized version of `_.shuffle` for arrays.\n *\n * @private\n * @param {Array} array The array to shuffle.\n * @returns {Array} Returns the new shuffled array.\n */\n function arrayShuffle(array) {\n return shuffleSelf(copyArray(array));\n }\n\n /**\n * This function is like `assignValue` except that it doesn't assign\n * `undefined` values.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\n function assignMergeValue(object, key, value) {\n if ((value !== undefined && !eq(object[key], value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n }\n\n /**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\n function assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n }\n\n /**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n }\n\n /**\n * Aggregates elements of `collection` on `accumulator` with keys transformed\n * by `iteratee` and values set by `setter`.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform keys.\n * @param {Object} accumulator The initial aggregated object.\n * @returns {Function} Returns `accumulator`.\n */\n function baseAggregator(collection, setter, iteratee, accumulator) {\n baseEach(collection, function(value, key, collection) {\n setter(accumulator, value, iteratee(value), collection);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `_.assign` without support for multiple sources\n * or `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\n function baseAssign(object, source) {\n return object && copyObject(source, keys(source), object);\n }\n\n /**\n * The base implementation of `_.assignIn` without support for multiple sources\n * or `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\n function baseAssignIn(object, source) {\n return object && copyObject(source, keysIn(source), object);\n }\n\n /**\n * The base implementation of `assignValue` and `assignMergeValue` without\n * value checks.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\n function baseAssignValue(object, key, value) {\n if (key == '__proto__' && defineProperty) {\n defineProperty(object, key, {\n 'configurable': true,\n 'enumerable': true,\n 'value': value,\n 'writable': true\n });\n } else {\n object[key] = value;\n }\n }\n\n /**\n * The base implementation of `_.at` without support for individual paths.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {string[]} paths The property paths to pick.\n * @returns {Array} Returns the picked elements.\n */\n function baseAt(object, paths) {\n var index = -1,\n length = paths.length,\n result = Array(length),\n skip = object == null;\n\n while (++index < length) {\n result[index] = skip ? undefined : get(object, paths[index]);\n }\n return result;\n }\n\n /**\n * The base implementation of `_.clamp` which doesn't coerce arguments.\n *\n * @private\n * @param {number} number The number to clamp.\n * @param {number} [lower] The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the clamped number.\n */\n function baseClamp(number, lower, upper) {\n if (number === number) {\n if (upper !== undefined) {\n number = number <= upper ? number : upper;\n }\n if (lower !== undefined) {\n number = number >= lower ? number : lower;\n }\n }\n return number;\n }\n\n /**\n * The base implementation of `_.clone` and `_.cloneDeep` which tracks\n * traversed objects.\n *\n * @private\n * @param {*} value The value to clone.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Deep clone\n * 2 - Flatten inherited properties\n * 4 - Clone symbols\n * @param {Function} [customizer] The function to customize cloning.\n * @param {string} [key] The key of `value`.\n * @param {Object} [object] The parent object of `value`.\n * @param {Object} [stack] Tracks traversed objects and their clone counterparts.\n * @returns {*} Returns the cloned value.\n */\n function baseClone(value, bitmask, customizer, key, object, stack) {\n var result,\n isDeep = bitmask & CLONE_DEEP_FLAG,\n isFlat = bitmask & CLONE_FLAT_FLAG,\n isFull = bitmask & CLONE_SYMBOLS_FLAG;\n\n if (customizer) {\n result = object ? customizer(value, key, object, stack) : customizer(value);\n }\n if (result !== undefined) {\n return result;\n }\n if (!isObject(value)) {\n return value;\n }\n var isArr = isArray(value);\n if (isArr) {\n result = initCloneArray(value);\n if (!isDeep) {\n return copyArray(value, result);\n }\n } else {\n var tag = getTag(value),\n isFunc = tag == funcTag || tag == genTag;\n\n if (isBuffer(value)) {\n return cloneBuffer(value, isDeep);\n }\n if (tag == objectTag || tag == argsTag || (isFunc && !object)) {\n result = (isFlat || isFunc) ? {} : initCloneObject(value);\n if (!isDeep) {\n return isFlat\n ? copySymbolsIn(value, baseAssignIn(result, value))\n : copySymbols(value, baseAssign(result, value));\n }\n } else {\n if (!cloneableTags[tag]) {\n return object ? value : {};\n }\n result = initCloneByTag(value, tag, baseClone, isDeep);\n }\n }\n // Check for circular references and return its corresponding clone.\n stack || (stack = new Stack);\n var stacked = stack.get(value);\n if (stacked) {\n return stacked;\n }\n stack.set(value, result);\n\n var keysFunc = isFull\n ? (isFlat ? getAllKeysIn : getAllKeys)\n : (isFlat ? keysIn : keys);\n\n var props = isArr ? undefined : keysFunc(value);\n arrayEach(props || value, function(subValue, key) {\n if (props) {\n key = subValue;\n subValue = value[key];\n }\n // Recursively populate clone (susceptible to call stack limits).\n assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));\n });\n return result;\n }\n\n /**\n * The base implementation of `_.conforms` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property predicates to conform to.\n * @returns {Function} Returns the new spec function.\n */\n function baseConforms(source) {\n var props = keys(source);\n return function(object) {\n return baseConformsTo(object, source, props);\n };\n }\n\n /**\n * The base implementation of `_.conformsTo` which accepts `props` to check.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property predicates to conform to.\n * @returns {boolean} Returns `true` if `object` conforms, else `false`.\n */\n function baseConformsTo(object, source, props) {\n var length = props.length;\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (length--) {\n var key = props[length],\n predicate = source[key],\n value = object[key];\n\n if ((value === undefined && !(key in object)) || !predicate(value)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * The base implementation of `_.delay` and `_.defer` which accepts `args`\n * to provide to `func`.\n *\n * @private\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @param {Array} args The arguments to provide to `func`.\n * @returns {number|Object} Returns the timer id or timeout object.\n */\n function baseDelay(func, wait, args) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return setTimeout(function() { func.apply(undefined, args); }, wait);\n }\n\n /**\n * The base implementation of methods like `_.difference` without support\n * for excluding multiple arrays or iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Array} values The values to exclude.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n */\n function baseDifference(array, values, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n isCommon = true,\n length = array.length,\n result = [],\n valuesLength = values.length;\n\n if (!length) {\n return result;\n }\n if (iteratee) {\n values = arrayMap(values, baseUnary(iteratee));\n }\n if (comparator) {\n includes = arrayIncludesWith;\n isCommon = false;\n }\n else if (values.length >= LARGE_ARRAY_SIZE) {\n includes = cacheHas;\n isCommon = false;\n values = new SetCache(values);\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee == null ? value : iteratee(value);\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var valuesIndex = valuesLength;\n while (valuesIndex--) {\n if (values[valuesIndex] === computed) {\n continue outer;\n }\n }\n result.push(value);\n }\n else if (!includes(values, computed, comparator)) {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.forEach` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n */\n var baseEach = createBaseEach(baseForOwn);\n\n /**\n * The base implementation of `_.forEachRight` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n */\n var baseEachRight = createBaseEach(baseForOwnRight, true);\n\n /**\n * The base implementation of `_.every` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`\n */\n function baseEvery(collection, predicate) {\n var result = true;\n baseEach(collection, function(value, index, collection) {\n result = !!predicate(value, index, collection);\n return result;\n });\n return result;\n }\n\n /**\n * The base implementation of methods like `_.max` and `_.min` which accepts a\n * `comparator` to determine the extremum value.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The iteratee invoked per iteration.\n * @param {Function} comparator The comparator used to compare values.\n * @returns {*} Returns the extremum value.\n */\n function baseExtremum(array, iteratee, comparator) {\n var index = -1,\n length = array.length;\n\n while (++index < length) {\n var value = array[index],\n current = iteratee(value);\n\n if (current != null && (computed === undefined\n ? (current === current && !isSymbol(current))\n : comparator(current, computed)\n )) {\n var computed = current,\n result = value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.fill` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to fill.\n * @param {*} value The value to fill `array` with.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns `array`.\n */\n function baseFill(array, value, start, end) {\n var length = array.length;\n\n start = toInteger(start);\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = (end === undefined || end > length) ? length : toInteger(end);\n if (end < 0) {\n end += length;\n }\n end = start > end ? 0 : toLength(end);\n while (start < end) {\n array[start++] = value;\n }\n return array;\n }\n\n /**\n * The base implementation of `_.filter` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\n function baseFilter(collection, predicate) {\n var result = [];\n baseEach(collection, function(value, index, collection) {\n if (predicate(value, index, collection)) {\n result.push(value);\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.flatten` with support for restricting flattening.\n *\n * @private\n * @param {Array} array The array to flatten.\n * @param {number} depth The maximum recursion depth.\n * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.\n * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.\n * @param {Array} [result=[]] The initial result value.\n * @returns {Array} Returns the new flattened array.\n */\n function baseFlatten(array, depth, predicate, isStrict, result) {\n var index = -1,\n length = array.length;\n\n predicate || (predicate = isFlattenable);\n result || (result = []);\n\n while (++index < length) {\n var value = array[index];\n if (depth > 0 && predicate(value)) {\n if (depth > 1) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, depth - 1, predicate, isStrict, result);\n } else {\n arrayPush(result, value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `baseForOwn` which iterates over `object`\n * properties returned by `keysFunc` and invokes `iteratee` for each property.\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\n var baseFor = createBaseFor();\n\n /**\n * This function is like `baseFor` except that it iterates over properties\n * in the opposite order.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\n var baseForRight = createBaseFor(true);\n\n /**\n * The base implementation of `_.forOwn` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForOwn(object, iteratee) {\n return object && baseFor(object, iteratee, keys);\n }\n\n /**\n * The base implementation of `_.forOwnRight` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForOwnRight(object, iteratee) {\n return object && baseForRight(object, iteratee, keys);\n }\n\n /**\n * The base implementation of `_.functions` which creates an array of\n * `object` function property names filtered from `props`.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Array} props The property names to filter.\n * @returns {Array} Returns the function names.\n */\n function baseFunctions(object, props) {\n return arrayFilter(props, function(key) {\n return isFunction(object[key]);\n });\n }\n\n /**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\n function baseGet(object, path) {\n path = castPath(path, object);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n }\n\n /**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\n function baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n }\n\n /**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\n function baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n }\n\n /**\n * The base implementation of `_.gt` which doesn't coerce arguments.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than `other`,\n * else `false`.\n */\n function baseGt(value, other) {\n return value > other;\n }\n\n /**\n * The base implementation of `_.has` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\n function baseHas(object, key) {\n return object != null && hasOwnProperty.call(object, key);\n }\n\n /**\n * The base implementation of `_.hasIn` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\n function baseHasIn(object, key) {\n return object != null && key in Object(object);\n }\n\n /**\n * The base implementation of `_.inRange` which doesn't coerce arguments.\n *\n * @private\n * @param {number} number The number to check.\n * @param {number} start The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n */\n function baseInRange(number, start, end) {\n return number >= nativeMin(start, end) && number < nativeMax(start, end);\n }\n\n /**\n * The base implementation of methods like `_.intersection`, without support\n * for iteratee shorthands, that accepts an array of arrays to inspect.\n *\n * @private\n * @param {Array} arrays The arrays to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of shared values.\n */\n function baseIntersection(arrays, iteratee, comparator) {\n var includes = comparator ? arrayIncludesWith : arrayIncludes,\n length = arrays[0].length,\n othLength = arrays.length,\n othIndex = othLength,\n caches = Array(othLength),\n maxLength = Infinity,\n result = [];\n\n while (othIndex--) {\n var array = arrays[othIndex];\n if (othIndex && iteratee) {\n array = arrayMap(array, baseUnary(iteratee));\n }\n maxLength = nativeMin(array.length, maxLength);\n caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))\n ? new SetCache(othIndex && array)\n : undefined;\n }\n array = arrays[0];\n\n var index = -1,\n seen = caches[0];\n\n outer:\n while (++index < length && result.length < maxLength) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (!(seen\n ? cacheHas(seen, computed)\n : includes(result, computed, comparator)\n )) {\n othIndex = othLength;\n while (--othIndex) {\n var cache = caches[othIndex];\n if (!(cache\n ? cacheHas(cache, computed)\n : includes(arrays[othIndex], computed, comparator))\n ) {\n continue outer;\n }\n }\n if (seen) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.invert` and `_.invertBy` which inverts\n * `object` with values transformed by `iteratee` and set by `setter`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform values.\n * @param {Object} accumulator The initial inverted object.\n * @returns {Function} Returns `accumulator`.\n */\n function baseInverter(object, setter, iteratee, accumulator) {\n baseForOwn(object, function(value, key, object) {\n setter(accumulator, iteratee(value), key, object);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `_.invoke` without support for individual\n * method arguments.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the method to invoke.\n * @param {Array} args The arguments to invoke the method with.\n * @returns {*} Returns the result of the invoked method.\n */\n function baseInvoke(object, path, args) {\n path = castPath(path, object);\n object = parent(object, path);\n var func = object == null ? object : object[toKey(last(path))];\n return func == null ? undefined : apply(func, object, args);\n }\n\n /**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\n function baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n }\n\n /**\n * The base implementation of `_.isArrayBuffer` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.\n */\n function baseIsArrayBuffer(value) {\n return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;\n }\n\n /**\n * The base implementation of `_.isDate` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n */\n function baseIsDate(value) {\n return isObjectLike(value) && baseGetTag(value) == dateTag;\n }\n\n /**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\n function baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n }\n\n /**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n }\n\n /**\n * The base implementation of `_.isMap` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n */\n function baseIsMap(value) {\n return isObjectLike(value) && getTag(value) == mapTag;\n }\n\n /**\n * The base implementation of `_.isMatch` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Array} matchData The property names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\n function baseIsMatch(object, source, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var stack = new Stack;\n if (customizer) {\n var result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\n function baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n }\n\n /**\n * The base implementation of `_.isRegExp` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.\n */\n function baseIsRegExp(value) {\n return isObjectLike(value) && baseGetTag(value) == regexpTag;\n }\n\n /**\n * The base implementation of `_.isSet` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n */\n function baseIsSet(value) {\n return isObjectLike(value) && getTag(value) == setTag;\n }\n\n /**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\n function baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n }\n\n /**\n * The base implementation of `_.iteratee`.\n *\n * @private\n * @param {*} [value=_.identity] The value to convert to an iteratee.\n * @returns {Function} Returns the iteratee.\n */\n function baseIteratee(value) {\n // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return identity;\n }\n if (typeof value == 'object') {\n return isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n }\n\n /**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.lt` which doesn't coerce arguments.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than `other`,\n * else `false`.\n */\n function baseLt(value, other) {\n return value < other;\n }\n\n /**\n * The base implementation of `_.map` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\n function baseMap(collection, iteratee) {\n var index = -1,\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value, key, collection) {\n result[++index] = iteratee(value, key, collection);\n });\n return result;\n }\n\n /**\n * The base implementation of `_.matches` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n */\n function baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return function(object) {\n return object === source || baseIsMatch(object, source, matchData);\n };\n }\n\n /**\n * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\n function baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return function(object) {\n var objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);\n };\n }\n\n /**\n * The base implementation of `_.merge` without support for multiple sources.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\n function baseMerge(object, source, srcIndex, customizer, stack) {\n if (object === source) {\n return;\n }\n baseFor(source, function(srcValue, key) {\n if (isObject(srcValue)) {\n stack || (stack = new Stack);\n baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n }\n else {\n var newValue = customizer\n ? customizer(object[key], srcValue, (key + ''), object, source, stack)\n : undefined;\n\n if (newValue === undefined) {\n newValue = srcValue;\n }\n assignMergeValue(object, key, newValue);\n }\n }, keysIn);\n }\n\n /**\n * A specialized version of `baseMerge` for arrays and objects which performs\n * deep merges and tracks traversed objects enabling objects with circular\n * references to be merged.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {string} key The key of the value to merge.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} mergeFunc The function to merge values.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\n function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {\n var objValue = object[key],\n srcValue = source[key],\n stacked = stack.get(srcValue);\n\n if (stacked) {\n assignMergeValue(object, key, stacked);\n return;\n }\n var newValue = customizer\n ? customizer(objValue, srcValue, (key + ''), object, source, stack)\n : undefined;\n\n var isCommon = newValue === undefined;\n\n if (isCommon) {\n var isArr = isArray(srcValue),\n isBuff = !isArr && isBuffer(srcValue),\n isTyped = !isArr && !isBuff && isTypedArray(srcValue);\n\n newValue = srcValue;\n if (isArr || isBuff || isTyped) {\n if (isArray(objValue)) {\n newValue = objValue;\n }\n else if (isArrayLikeObject(objValue)) {\n newValue = copyArray(objValue);\n }\n else if (isBuff) {\n isCommon = false;\n newValue = cloneBuffer(srcValue, true);\n }\n else if (isTyped) {\n isCommon = false;\n newValue = cloneTypedArray(srcValue, true);\n }\n else {\n newValue = [];\n }\n }\n else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n newValue = objValue;\n if (isArguments(objValue)) {\n newValue = toPlainObject(objValue);\n }\n else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {\n newValue = initCloneObject(srcValue);\n }\n }\n else {\n isCommon = false;\n }\n }\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, newValue);\n mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n stack['delete'](srcValue);\n }\n assignMergeValue(object, key, newValue);\n }\n\n /**\n * The base implementation of `_.nth` which doesn't coerce arguments.\n *\n * @private\n * @param {Array} array The array to query.\n * @param {number} n The index of the element to return.\n * @returns {*} Returns the nth element of `array`.\n */\n function baseNth(array, n) {\n var length = array.length;\n if (!length) {\n return;\n }\n n += n < 0 ? length : 0;\n return isIndex(n, length) ? array[n] : undefined;\n }\n\n /**\n * The base implementation of `_.orderBy` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {string[]} orders The sort orders of `iteratees`.\n * @returns {Array} Returns the new sorted array.\n */\n function baseOrderBy(collection, iteratees, orders) {\n var index = -1;\n iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));\n\n var result = baseMap(collection, function(value, key, collection) {\n var criteria = arrayMap(iteratees, function(iteratee) {\n return iteratee(value);\n });\n return { 'criteria': criteria, 'index': ++index, 'value': value };\n });\n\n return baseSortBy(result, function(object, other) {\n return compareMultiple(object, other, orders);\n });\n }\n\n /**\n * The base implementation of `_.pick` without support for individual\n * property identifiers.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} paths The property paths to pick.\n * @returns {Object} Returns the new object.\n */\n function basePick(object, paths) {\n return basePickBy(object, paths, function(value, path) {\n return hasIn(object, path);\n });\n }\n\n /**\n * The base implementation of `_.pickBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} paths The property paths to pick.\n * @param {Function} predicate The function invoked per property.\n * @returns {Object} Returns the new object.\n */\n function basePickBy(object, paths, predicate) {\n var index = -1,\n length = paths.length,\n result = {};\n\n while (++index < length) {\n var path = paths[index],\n value = baseGet(object, path);\n\n if (predicate(value, path)) {\n baseSet(result, castPath(path, object), value);\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\n function basePropertyDeep(path) {\n return function(object) {\n return baseGet(object, path);\n };\n }\n\n /**\n * The base implementation of `_.pullAllBy` without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns `array`.\n */\n function basePullAll(array, values, iteratee, comparator) {\n var indexOf = comparator ? baseIndexOfWith : baseIndexOf,\n index = -1,\n length = values.length,\n seen = array;\n\n if (array === values) {\n values = copyArray(values);\n }\n if (iteratee) {\n seen = arrayMap(array, baseUnary(iteratee));\n }\n while (++index < length) {\n var fromIndex = 0,\n value = values[index],\n computed = iteratee ? iteratee(value) : value;\n\n while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {\n if (seen !== array) {\n splice.call(seen, fromIndex, 1);\n }\n splice.call(array, fromIndex, 1);\n }\n }\n return array;\n }\n\n /**\n * The base implementation of `_.pullAt` without support for individual\n * indexes or capturing the removed elements.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {number[]} indexes The indexes of elements to remove.\n * @returns {Array} Returns `array`.\n */\n function basePullAt(array, indexes) {\n var length = array ? indexes.length : 0,\n lastIndex = length - 1;\n\n while (length--) {\n var index = indexes[length];\n if (length == lastIndex || index !== previous) {\n var previous = index;\n if (isIndex(index)) {\n splice.call(array, index, 1);\n } else {\n baseUnset(array, index);\n }\n }\n }\n return array;\n }\n\n /**\n * The base implementation of `_.random` without support for returning\n * floating-point numbers.\n *\n * @private\n * @param {number} lower The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the random number.\n */\n function baseRandom(lower, upper) {\n return lower + nativeFloor(nativeRandom() * (upper - lower + 1));\n }\n\n /**\n * The base implementation of `_.range` and `_.rangeRight` which doesn't\n * coerce arguments.\n *\n * @private\n * @param {number} start The start of the range.\n * @param {number} end The end of the range.\n * @param {number} step The value to increment or decrement by.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Array} Returns the range of numbers.\n */\n function baseRange(start, end, step, fromRight) {\n var index = -1,\n length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),\n result = Array(length);\n\n while (length--) {\n result[fromRight ? length : ++index] = start;\n start += step;\n }\n return result;\n }\n\n /**\n * The base implementation of `_.repeat` which doesn't coerce arguments.\n *\n * @private\n * @param {string} string The string to repeat.\n * @param {number} n The number of times to repeat the string.\n * @returns {string} Returns the repeated string.\n */\n function baseRepeat(string, n) {\n var result = '';\n if (!string || n < 1 || n > MAX_SAFE_INTEGER) {\n return result;\n }\n // Leverage the exponentiation by squaring algorithm for a faster repeat.\n // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.\n do {\n if (n % 2) {\n result += string;\n }\n n = nativeFloor(n / 2);\n if (n) {\n string += string;\n }\n } while (n);\n\n return result;\n }\n\n /**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\n function baseRest(func, start) {\n return setToString(overRest(func, start, identity), func + '');\n }\n\n /**\n * The base implementation of `_.sample`.\n *\n * @private\n * @param {Array|Object} collection The collection to sample.\n * @returns {*} Returns the random element.\n */\n function baseSample(collection) {\n return arraySample(values(collection));\n }\n\n /**\n * The base implementation of `_.sampleSize` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to sample.\n * @param {number} n The number of elements to sample.\n * @returns {Array} Returns the random elements.\n */\n function baseSampleSize(collection, n) {\n var array = values(collection);\n return shuffleSelf(array, baseClamp(n, 0, array.length));\n }\n\n /**\n * The base implementation of `_.set`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @param {Function} [customizer] The function to customize path creation.\n * @returns {Object} Returns `object`.\n */\n function baseSet(object, path, value, customizer) {\n if (!isObject(object)) {\n return object;\n }\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n lastIndex = length - 1,\n nested = object;\n\n while (nested != null && ++index < length) {\n var key = toKey(path[index]),\n newValue = value;\n\n if (index != lastIndex) {\n var objValue = nested[key];\n newValue = customizer ? customizer(objValue, key, nested) : undefined;\n if (newValue === undefined) {\n newValue = isObject(objValue)\n ? objValue\n : (isIndex(path[index + 1]) ? [] : {});\n }\n }\n assignValue(nested, key, newValue);\n nested = nested[key];\n }\n return object;\n }\n\n /**\n * The base implementation of `setData` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\n var baseSetData = !metaMap ? identity : function(func, data) {\n metaMap.set(func, data);\n return func;\n };\n\n /**\n * The base implementation of `setToString` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\n var baseSetToString = !defineProperty ? identity : function(func, string) {\n return defineProperty(func, 'toString', {\n 'configurable': true,\n 'enumerable': false,\n 'value': constant(string),\n 'writable': true\n });\n };\n\n /**\n * The base implementation of `_.shuffle`.\n *\n * @private\n * @param {Array|Object} collection The collection to shuffle.\n * @returns {Array} Returns the new shuffled array.\n */\n function baseShuffle(collection) {\n return shuffleSelf(values(collection));\n }\n\n /**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\n function baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n }\n\n /**\n * The base implementation of `_.some` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\n function baseSome(collection, predicate) {\n var result;\n\n baseEach(collection, function(value, index, collection) {\n result = predicate(value, index, collection);\n return !result;\n });\n return !!result;\n }\n\n /**\n * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which\n * performs a binary search of `array` to determine the index at which `value`\n * should be inserted into `array` in order to maintain its sort order.\n *\n * @private\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n */\n function baseSortedIndex(array, value, retHighest) {\n var low = 0,\n high = array == null ? low : array.length;\n\n if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {\n while (low < high) {\n var mid = (low + high) >>> 1,\n computed = array[mid];\n\n if (computed !== null && !isSymbol(computed) &&\n (retHighest ? (computed <= value) : (computed < value))) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return high;\n }\n return baseSortedIndexBy(array, value, identity, retHighest);\n }\n\n /**\n * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`\n * which invokes `iteratee` for `value` and each element of `array` to compute\n * their sort ranking. The iteratee is invoked with one argument; (value).\n *\n * @private\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} iteratee The iteratee invoked per element.\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n */\n function baseSortedIndexBy(array, value, iteratee, retHighest) {\n value = iteratee(value);\n\n var low = 0,\n high = array == null ? 0 : array.length,\n valIsNaN = value !== value,\n valIsNull = value === null,\n valIsSymbol = isSymbol(value),\n valIsUndefined = value === undefined;\n\n while (low < high) {\n var mid = nativeFloor((low + high) / 2),\n computed = iteratee(array[mid]),\n othIsDefined = computed !== undefined,\n othIsNull = computed === null,\n othIsReflexive = computed === computed,\n othIsSymbol = isSymbol(computed);\n\n if (valIsNaN) {\n var setLow = retHighest || othIsReflexive;\n } else if (valIsUndefined) {\n setLow = othIsReflexive && (retHighest || othIsDefined);\n } else if (valIsNull) {\n setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);\n } else if (valIsSymbol) {\n setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);\n } else if (othIsNull || othIsSymbol) {\n setLow = false;\n } else {\n setLow = retHighest ? (computed <= value) : (computed < value);\n }\n if (setLow) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return nativeMin(high, MAX_ARRAY_INDEX);\n }\n\n /**\n * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n */\n function baseSortedUniq(array, iteratee) {\n var index = -1,\n length = array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n if (!index || !eq(computed, seen)) {\n var seen = computed;\n result[resIndex++] = value === 0 ? 0 : value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.toNumber` which doesn't ensure correct\n * conversions of binary, hexadecimal, or octal string values.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n */\n function baseToNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n return +value;\n }\n\n /**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\n function baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n }\n\n /**\n * The base implementation of `_.uniqBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n */\n function baseUniq(array, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n length = array.length,\n isCommon = true,\n result = [],\n seen = result;\n\n if (comparator) {\n isCommon = false;\n includes = arrayIncludesWith;\n }\n else if (length >= LARGE_ARRAY_SIZE) {\n var set = iteratee ? null : createSet(array);\n if (set) {\n return setToArray(set);\n }\n isCommon = false;\n includes = cacheHas;\n seen = new SetCache;\n }\n else {\n seen = iteratee ? [] : result;\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var seenIndex = seen.length;\n while (seenIndex--) {\n if (seen[seenIndex] === computed) {\n continue outer;\n }\n }\n if (iteratee) {\n seen.push(computed);\n }\n result.push(value);\n }\n else if (!includes(seen, computed, comparator)) {\n if (seen !== result) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.unset`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The property path to unset.\n * @returns {boolean} Returns `true` if the property is deleted, else `false`.\n */\n function baseUnset(object, path) {\n path = castPath(path, object);\n object = parent(object, path);\n return object == null || delete object[toKey(last(path))];\n }\n\n /**\n * The base implementation of `_.update`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to update.\n * @param {Function} updater The function to produce the updated value.\n * @param {Function} [customizer] The function to customize path creation.\n * @returns {Object} Returns `object`.\n */\n function baseUpdate(object, path, updater, customizer) {\n return baseSet(object, path, updater(baseGet(object, path)), customizer);\n }\n\n /**\n * The base implementation of methods like `_.dropWhile` and `_.takeWhile`\n * without support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to query.\n * @param {Function} predicate The function invoked per iteration.\n * @param {boolean} [isDrop] Specify dropping elements instead of taking them.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Array} Returns the slice of `array`.\n */\n function baseWhile(array, predicate, isDrop, fromRight) {\n var length = array.length,\n index = fromRight ? length : -1;\n\n while ((fromRight ? index-- : ++index < length) &&\n predicate(array[index], index, array)) {}\n\n return isDrop\n ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))\n : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));\n }\n\n /**\n * The base implementation of `wrapperValue` which returns the result of\n * performing a sequence of actions on the unwrapped `value`, where each\n * successive action is supplied the return value of the previous.\n *\n * @private\n * @param {*} value The unwrapped value.\n * @param {Array} actions Actions to perform to resolve the unwrapped value.\n * @returns {*} Returns the resolved value.\n */\n function baseWrapperValue(value, actions) {\n var result = value;\n if (result instanceof LazyWrapper) {\n result = result.value();\n }\n return arrayReduce(actions, function(result, action) {\n return action.func.apply(action.thisArg, arrayPush([result], action.args));\n }, result);\n }\n\n /**\n * The base implementation of methods like `_.xor`, without support for\n * iteratee shorthands, that accepts an array of arrays to inspect.\n *\n * @private\n * @param {Array} arrays The arrays to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of values.\n */\n function baseXor(arrays, iteratee, comparator) {\n var length = arrays.length;\n if (length < 2) {\n return length ? baseUniq(arrays[0]) : [];\n }\n var index = -1,\n result = Array(length);\n\n while (++index < length) {\n var array = arrays[index],\n othIndex = -1;\n\n while (++othIndex < length) {\n if (othIndex != index) {\n result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);\n }\n }\n }\n return baseUniq(baseFlatten(result, 1), iteratee, comparator);\n }\n\n /**\n * This base implementation of `_.zipObject` which assigns values using `assignFunc`.\n *\n * @private\n * @param {Array} props The property identifiers.\n * @param {Array} values The property values.\n * @param {Function} assignFunc The function to assign values.\n * @returns {Object} Returns the new object.\n */\n function baseZipObject(props, values, assignFunc) {\n var index = -1,\n length = props.length,\n valsLength = values.length,\n result = {};\n\n while (++index < length) {\n var value = index < valsLength ? values[index] : undefined;\n assignFunc(result, props[index], value);\n }\n return result;\n }\n\n /**\n * Casts `value` to an empty array if it's not an array like object.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Array|Object} Returns the cast array-like object.\n */\n function castArrayLikeObject(value) {\n return isArrayLikeObject(value) ? value : [];\n }\n\n /**\n * Casts `value` to `identity` if it's not a function.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Function} Returns cast function.\n */\n function castFunction(value) {\n return typeof value == 'function' ? value : identity;\n }\n\n /**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\n function castPath(value, object) {\n if (isArray(value)) {\n return value;\n }\n return isKey(value, object) ? [value] : stringToPath(toString(value));\n }\n\n /**\n * A `baseRest` alias which can be replaced with `identity` by module\n * replacement plugins.\n *\n * @private\n * @type {Function}\n * @param {Function} func The function to apply a rest parameter to.\n * @returns {Function} Returns the new function.\n */\n var castRest = baseRest;\n\n /**\n * Casts `array` to a slice if it's needed.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {number} start The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the cast slice.\n */\n function castSlice(array, start, end) {\n var length = array.length;\n end = end === undefined ? length : end;\n return (!start && end >= length) ? array : baseSlice(array, start, end);\n }\n\n /**\n * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).\n *\n * @private\n * @param {number|Object} id The timer id or timeout object of the timer to clear.\n */\n var clearTimeout = ctxClearTimeout || function(id) {\n return root.clearTimeout(id);\n };\n\n /**\n * Creates a clone of `buffer`.\n *\n * @private\n * @param {Buffer} buffer The buffer to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Buffer} Returns the cloned buffer.\n */\n function cloneBuffer(buffer, isDeep) {\n if (isDeep) {\n return buffer.slice();\n }\n var length = buffer.length,\n result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);\n\n buffer.copy(result);\n return result;\n }\n\n /**\n * Creates a clone of `arrayBuffer`.\n *\n * @private\n * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\n * @returns {ArrayBuffer} Returns the cloned array buffer.\n */\n function cloneArrayBuffer(arrayBuffer) {\n var result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n return result;\n }\n\n /**\n * Creates a clone of `dataView`.\n *\n * @private\n * @param {Object} dataView The data view to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned data view.\n */\n function cloneDataView(dataView, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;\n return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);\n }\n\n /**\n * Creates a clone of `map`.\n *\n * @private\n * @param {Object} map The map to clone.\n * @param {Function} cloneFunc The function to clone values.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned map.\n */\n function cloneMap(map, isDeep, cloneFunc) {\n var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);\n return arrayReduce(array, addMapEntry, new map.constructor);\n }\n\n /**\n * Creates a clone of `regexp`.\n *\n * @private\n * @param {Object} regexp The regexp to clone.\n * @returns {Object} Returns the cloned regexp.\n */\n function cloneRegExp(regexp) {\n var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));\n result.lastIndex = regexp.lastIndex;\n return result;\n }\n\n /**\n * Creates a clone of `set`.\n *\n * @private\n * @param {Object} set The set to clone.\n * @param {Function} cloneFunc The function to clone values.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned set.\n */\n function cloneSet(set, isDeep, cloneFunc) {\n var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);\n return arrayReduce(array, addSetEntry, new set.constructor);\n }\n\n /**\n * Creates a clone of the `symbol` object.\n *\n * @private\n * @param {Object} symbol The symbol object to clone.\n * @returns {Object} Returns the cloned symbol object.\n */\n function cloneSymbol(symbol) {\n return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};\n }\n\n /**\n * Creates a clone of `typedArray`.\n *\n * @private\n * @param {Object} typedArray The typed array to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned typed array.\n */\n function cloneTypedArray(typedArray, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n }\n\n /**\n * Compares values to sort them in ascending order.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {number} Returns the sort order indicator for `value`.\n */\n function compareAscending(value, other) {\n if (value !== other) {\n var valIsDefined = value !== undefined,\n valIsNull = value === null,\n valIsReflexive = value === value,\n valIsSymbol = isSymbol(value);\n\n var othIsDefined = other !== undefined,\n othIsNull = other === null,\n othIsReflexive = other === other,\n othIsSymbol = isSymbol(other);\n\n if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||\n (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||\n (valIsNull && othIsDefined && othIsReflexive) ||\n (!valIsDefined && othIsReflexive) ||\n !valIsReflexive) {\n return 1;\n }\n if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||\n (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||\n (othIsNull && valIsDefined && valIsReflexive) ||\n (!othIsDefined && valIsReflexive) ||\n !othIsReflexive) {\n return -1;\n }\n }\n return 0;\n }\n\n /**\n * Used by `_.orderBy` to compare multiple properties of a value to another\n * and stable sort them.\n *\n * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,\n * specify an order of \"desc\" for descending or \"asc\" for ascending sort order\n * of corresponding values.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {boolean[]|string[]} orders The order to sort by for each property.\n * @returns {number} Returns the sort order indicator for `object`.\n */\n function compareMultiple(object, other, orders) {\n var index = -1,\n objCriteria = object.criteria,\n othCriteria = other.criteria,\n length = objCriteria.length,\n ordersLength = orders.length;\n\n while (++index < length) {\n var result = compareAscending(objCriteria[index], othCriteria[index]);\n if (result) {\n if (index >= ordersLength) {\n return result;\n }\n var order = orders[index];\n return result * (order == 'desc' ? -1 : 1);\n }\n }\n // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications\n // that causes it, under certain circumstances, to provide the same value for\n // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247\n // for more details.\n //\n // This also ensures a stable sort in V8 and other engines.\n // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.\n return object.index - other.index;\n }\n\n /**\n * Creates an array that is the composition of partially applied arguments,\n * placeholders, and provided arguments into a single array of arguments.\n *\n * @private\n * @param {Array} args The provided arguments.\n * @param {Array} partials The arguments to prepend to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @params {boolean} [isCurried] Specify composing for a curried function.\n * @returns {Array} Returns the new array of composed arguments.\n */\n function composeArgs(args, partials, holders, isCurried) {\n var argsIndex = -1,\n argsLength = args.length,\n holdersLength = holders.length,\n leftIndex = -1,\n leftLength = partials.length,\n rangeLength = nativeMax(argsLength - holdersLength, 0),\n result = Array(leftLength + rangeLength),\n isUncurried = !isCurried;\n\n while (++leftIndex < leftLength) {\n result[leftIndex] = partials[leftIndex];\n }\n while (++argsIndex < holdersLength) {\n if (isUncurried || argsIndex < argsLength) {\n result[holders[argsIndex]] = args[argsIndex];\n }\n }\n while (rangeLength--) {\n result[leftIndex++] = args[argsIndex++];\n }\n return result;\n }\n\n /**\n * This function is like `composeArgs` except that the arguments composition\n * is tailored for `_.partialRight`.\n *\n * @private\n * @param {Array} args The provided arguments.\n * @param {Array} partials The arguments to append to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @params {boolean} [isCurried] Specify composing for a curried function.\n * @returns {Array} Returns the new array of composed arguments.\n */\n function composeArgsRight(args, partials, holders, isCurried) {\n var argsIndex = -1,\n argsLength = args.length,\n holdersIndex = -1,\n holdersLength = holders.length,\n rightIndex = -1,\n rightLength = partials.length,\n rangeLength = nativeMax(argsLength - holdersLength, 0),\n result = Array(rangeLength + rightLength),\n isUncurried = !isCurried;\n\n while (++argsIndex < rangeLength) {\n result[argsIndex] = args[argsIndex];\n }\n var offset = argsIndex;\n while (++rightIndex < rightLength) {\n result[offset + rightIndex] = partials[rightIndex];\n }\n while (++holdersIndex < holdersLength) {\n if (isUncurried || argsIndex < argsLength) {\n result[offset + holders[holdersIndex]] = args[argsIndex++];\n }\n }\n return result;\n }\n\n /**\n * Copies the values of `source` to `array`.\n *\n * @private\n * @param {Array} source The array to copy values from.\n * @param {Array} [array=[]] The array to copy values to.\n * @returns {Array} Returns `array`.\n */\n function copyArray(source, array) {\n var index = -1,\n length = source.length;\n\n array || (array = Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n }\n\n /**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\n function copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n }\n\n /**\n * Copies own symbols of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy symbols from.\n * @param {Object} [object={}] The object to copy symbols to.\n * @returns {Object} Returns `object`.\n */\n function copySymbols(source, object) {\n return copyObject(source, getSymbols(source), object);\n }\n\n /**\n * Copies own and inherited symbols of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy symbols from.\n * @param {Object} [object={}] The object to copy symbols to.\n * @returns {Object} Returns `object`.\n */\n function copySymbolsIn(source, object) {\n return copyObject(source, getSymbolsIn(source), object);\n }\n\n /**\n * Creates a function like `_.groupBy`.\n *\n * @private\n * @param {Function} setter The function to set accumulator values.\n * @param {Function} [initializer] The accumulator object initializer.\n * @returns {Function} Returns the new aggregator function.\n */\n function createAggregator(setter, initializer) {\n return function(collection, iteratee) {\n var func = isArray(collection) ? arrayAggregator : baseAggregator,\n accumulator = initializer ? initializer() : {};\n\n return func(collection, setter, getIteratee(iteratee, 2), accumulator);\n };\n }\n\n /**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\n function createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n }\n\n /**\n * Creates a `baseEach` or `baseEachRight` function.\n *\n * @private\n * @param {Function} eachFunc The function to iterate over a collection.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\n function createBaseEach(eachFunc, fromRight) {\n return function(collection, iteratee) {\n if (collection == null) {\n return collection;\n }\n if (!isArrayLike(collection)) {\n return eachFunc(collection, iteratee);\n }\n var length = collection.length,\n index = fromRight ? length : -1,\n iterable = Object(collection);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (iteratee(iterable[index], index, iterable) === false) {\n break;\n }\n }\n return collection;\n };\n }\n\n /**\n * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\n function createBaseFor(fromRight) {\n return function(object, iteratee, keysFunc) {\n var index = -1,\n iterable = Object(object),\n props = keysFunc(object),\n length = props.length;\n\n while (length--) {\n var key = props[fromRight ? length : ++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n }\n\n /**\n * Creates a function that wraps `func` to invoke it with the optional `this`\n * binding of `thisArg`.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createBind(func, bitmask, thisArg) {\n var isBind = bitmask & WRAP_BIND_FLAG,\n Ctor = createCtor(func);\n\n function wrapper() {\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return fn.apply(isBind ? thisArg : this, arguments);\n }\n return wrapper;\n }\n\n /**\n * Creates a function like `_.lowerFirst`.\n *\n * @private\n * @param {string} methodName The name of the `String` case method to use.\n * @returns {Function} Returns the new case function.\n */\n function createCaseFirst(methodName) {\n return function(string) {\n string = toString(string);\n\n var strSymbols = hasUnicode(string)\n ? stringToArray(string)\n : undefined;\n\n var chr = strSymbols\n ? strSymbols[0]\n : string.charAt(0);\n\n var trailing = strSymbols\n ? castSlice(strSymbols, 1).join('')\n : string.slice(1);\n\n return chr[methodName]() + trailing;\n };\n }\n\n /**\n * Creates a function like `_.camelCase`.\n *\n * @private\n * @param {Function} callback The function to combine each word.\n * @returns {Function} Returns the new compounder function.\n */\n function createCompounder(callback) {\n return function(string) {\n return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');\n };\n }\n\n /**\n * Creates a function that produces an instance of `Ctor` regardless of\n * whether it was invoked as part of a `new` expression or by `call` or `apply`.\n *\n * @private\n * @param {Function} Ctor The constructor to wrap.\n * @returns {Function} Returns the new wrapped function.\n */\n function createCtor(Ctor) {\n return function() {\n // Use a `switch` statement to work with class constructors. See\n // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist\n // for more details.\n var args = arguments;\n switch (args.length) {\n case 0: return new Ctor;\n case 1: return new Ctor(args[0]);\n case 2: return new Ctor(args[0], args[1]);\n case 3: return new Ctor(args[0], args[1], args[2]);\n case 4: return new Ctor(args[0], args[1], args[2], args[3]);\n case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);\n case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);\n case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);\n }\n var thisBinding = baseCreate(Ctor.prototype),\n result = Ctor.apply(thisBinding, args);\n\n // Mimic the constructor's `return` behavior.\n // See https://es5.github.io/#x13.2.2 for more details.\n return isObject(result) ? result : thisBinding;\n };\n }\n\n /**\n * Creates a function that wraps `func` to enable currying.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {number} arity The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createCurry(func, bitmask, arity) {\n var Ctor = createCtor(func);\n\n function wrapper() {\n var length = arguments.length,\n args = Array(length),\n index = length,\n placeholder = getHolder(wrapper);\n\n while (index--) {\n args[index] = arguments[index];\n }\n var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)\n ? []\n : replaceHolders(args, placeholder);\n\n length -= holders.length;\n if (length < arity) {\n return createRecurry(\n func, bitmask, createHybrid, wrapper.placeholder, undefined,\n args, holders, undefined, undefined, arity - length);\n }\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return apply(fn, this, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a `_.find` or `_.findLast` function.\n *\n * @private\n * @param {Function} findIndexFunc The function to find the collection index.\n * @returns {Function} Returns the new find function.\n */\n function createFind(findIndexFunc) {\n return function(collection, predicate, fromIndex) {\n var iterable = Object(collection);\n if (!isArrayLike(collection)) {\n var iteratee = getIteratee(predicate, 3);\n collection = keys(collection);\n predicate = function(key) { return iteratee(iterable[key], key, iterable); };\n }\n var index = findIndexFunc(collection, predicate, fromIndex);\n return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;\n };\n }\n\n /**\n * Creates a `_.flow` or `_.flowRight` function.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new flow function.\n */\n function createFlow(fromRight) {\n return flatRest(function(funcs) {\n var length = funcs.length,\n index = length,\n prereq = LodashWrapper.prototype.thru;\n\n if (fromRight) {\n funcs.reverse();\n }\n while (index--) {\n var func = funcs[index];\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (prereq && !wrapper && getFuncName(func) == 'wrapper') {\n var wrapper = new LodashWrapper([], true);\n }\n }\n index = wrapper ? index : length;\n while (++index < length) {\n func = funcs[index];\n\n var funcName = getFuncName(func),\n data = funcName == 'wrapper' ? getData(func) : undefined;\n\n if (data && isLaziable(data[0]) &&\n data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&\n !data[4].length && data[9] == 1\n ) {\n wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);\n } else {\n wrapper = (func.length == 1 && isLaziable(func))\n ? wrapper[funcName]()\n : wrapper.thru(func);\n }\n }\n return function() {\n var args = arguments,\n value = args[0];\n\n if (wrapper && args.length == 1 && isArray(value)) {\n return wrapper.plant(value).value();\n }\n var index = 0,\n result = length ? funcs[index].apply(this, args) : value;\n\n while (++index < length) {\n result = funcs[index].call(this, result);\n }\n return result;\n };\n });\n }\n\n /**\n * Creates a function that wraps `func` to invoke it with optional `this`\n * binding of `thisArg`, partial application, and currying.\n *\n * @private\n * @param {Function|string} func The function or method name to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to\n * the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [partialsRight] The arguments to append to those provided\n * to the new function.\n * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {\n var isAry = bitmask & WRAP_ARY_FLAG,\n isBind = bitmask & WRAP_BIND_FLAG,\n isBindKey = bitmask & WRAP_BIND_KEY_FLAG,\n isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),\n isFlip = bitmask & WRAP_FLIP_FLAG,\n Ctor = isBindKey ? undefined : createCtor(func);\n\n function wrapper() {\n var length = arguments.length,\n args = Array(length),\n index = length;\n\n while (index--) {\n args[index] = arguments[index];\n }\n if (isCurried) {\n var placeholder = getHolder(wrapper),\n holdersCount = countHolders(args, placeholder);\n }\n if (partials) {\n args = composeArgs(args, partials, holders, isCurried);\n }\n if (partialsRight) {\n args = composeArgsRight(args, partialsRight, holdersRight, isCurried);\n }\n length -= holdersCount;\n if (isCurried && length < arity) {\n var newHolders = replaceHolders(args, placeholder);\n return createRecurry(\n func, bitmask, createHybrid, wrapper.placeholder, thisArg,\n args, newHolders, argPos, ary, arity - length\n );\n }\n var thisBinding = isBind ? thisArg : this,\n fn = isBindKey ? thisBinding[func] : func;\n\n length = args.length;\n if (argPos) {\n args = reorder(args, argPos);\n } else if (isFlip && length > 1) {\n args.reverse();\n }\n if (isAry && ary < length) {\n args.length = ary;\n }\n if (this && this !== root && this instanceof wrapper) {\n fn = Ctor || createCtor(fn);\n }\n return fn.apply(thisBinding, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a function like `_.invertBy`.\n *\n * @private\n * @param {Function} setter The function to set accumulator values.\n * @param {Function} toIteratee The function to resolve iteratees.\n * @returns {Function} Returns the new inverter function.\n */\n function createInverter(setter, toIteratee) {\n return function(object, iteratee) {\n return baseInverter(object, setter, toIteratee(iteratee), {});\n };\n }\n\n /**\n * Creates a function that performs a mathematical operation on two values.\n *\n * @private\n * @param {Function} operator The function to perform the operation.\n * @param {number} [defaultValue] The value used for `undefined` arguments.\n * @returns {Function} Returns the new mathematical operation function.\n */\n function createMathOperation(operator, defaultValue) {\n return function(value, other) {\n var result;\n if (value === undefined && other === undefined) {\n return defaultValue;\n }\n if (value !== undefined) {\n result = value;\n }\n if (other !== undefined) {\n if (result === undefined) {\n return other;\n }\n if (typeof value == 'string' || typeof other == 'string') {\n value = baseToString(value);\n other = baseToString(other);\n } else {\n value = baseToNumber(value);\n other = baseToNumber(other);\n }\n result = operator(value, other);\n }\n return result;\n };\n }\n\n /**\n * Creates a function like `_.over`.\n *\n * @private\n * @param {Function} arrayFunc The function to iterate over iteratees.\n * @returns {Function} Returns the new over function.\n */\n function createOver(arrayFunc) {\n return flatRest(function(iteratees) {\n iteratees = arrayMap(iteratees, baseUnary(getIteratee()));\n return baseRest(function(args) {\n var thisArg = this;\n return arrayFunc(iteratees, function(iteratee) {\n return apply(iteratee, thisArg, args);\n });\n });\n });\n }\n\n /**\n * Creates the padding for `string` based on `length`. The `chars` string\n * is truncated if the number of characters exceeds `length`.\n *\n * @private\n * @param {number} length The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padding for `string`.\n */\n function createPadding(length, chars) {\n chars = chars === undefined ? ' ' : baseToString(chars);\n\n var charsLength = chars.length;\n if (charsLength < 2) {\n return charsLength ? baseRepeat(chars, length) : chars;\n }\n var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));\n return hasUnicode(chars)\n ? castSlice(stringToArray(result), 0, length).join('')\n : result.slice(0, length);\n }\n\n /**\n * Creates a function that wraps `func` to invoke it with the `this` binding\n * of `thisArg` and `partials` prepended to the arguments it receives.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} partials The arguments to prepend to those provided to\n * the new function.\n * @returns {Function} Returns the new wrapped function.\n */\n function createPartial(func, bitmask, thisArg, partials) {\n var isBind = bitmask & WRAP_BIND_FLAG,\n Ctor = createCtor(func);\n\n function wrapper() {\n var argsIndex = -1,\n argsLength = arguments.length,\n leftIndex = -1,\n leftLength = partials.length,\n args = Array(leftLength + argsLength),\n fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n\n while (++leftIndex < leftLength) {\n args[leftIndex] = partials[leftIndex];\n }\n while (argsLength--) {\n args[leftIndex++] = arguments[++argsIndex];\n }\n return apply(fn, isBind ? thisArg : this, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a `_.range` or `_.rangeRight` function.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new range function.\n */\n function createRange(fromRight) {\n return function(start, end, step) {\n if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {\n end = step = undefined;\n }\n // Ensure the sign of `-0` is preserved.\n start = toFinite(start);\n if (end === undefined) {\n end = start;\n start = 0;\n } else {\n end = toFinite(end);\n }\n step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);\n return baseRange(start, end, step, fromRight);\n };\n }\n\n /**\n * Creates a function that performs a relational operation on two values.\n *\n * @private\n * @param {Function} operator The function to perform the operation.\n * @returns {Function} Returns the new relational operation function.\n */\n function createRelationalOperation(operator) {\n return function(value, other) {\n if (!(typeof value == 'string' && typeof other == 'string')) {\n value = toNumber(value);\n other = toNumber(other);\n }\n return operator(value, other);\n };\n }\n\n /**\n * Creates a function that wraps `func` to continue currying.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {Function} wrapFunc The function to create the `func` wrapper.\n * @param {*} placeholder The placeholder value.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to\n * the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {\n var isCurry = bitmask & WRAP_CURRY_FLAG,\n newHolders = isCurry ? holders : undefined,\n newHoldersRight = isCurry ? undefined : holders,\n newPartials = isCurry ? partials : undefined,\n newPartialsRight = isCurry ? undefined : partials;\n\n bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);\n bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);\n\n if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {\n bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);\n }\n var newData = [\n func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,\n newHoldersRight, argPos, ary, arity\n ];\n\n var result = wrapFunc.apply(undefined, newData);\n if (isLaziable(func)) {\n setData(result, newData);\n }\n result.placeholder = placeholder;\n return setWrapToString(result, func, bitmask);\n }\n\n /**\n * Creates a function like `_.round`.\n *\n * @private\n * @param {string} methodName The name of the `Math` method to use when rounding.\n * @returns {Function} Returns the new round function.\n */\n function createRound(methodName) {\n var func = Math[methodName];\n return function(number, precision) {\n number = toNumber(number);\n precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);\n if (precision) {\n // Shift with exponential notation to avoid floating-point issues.\n // See [MDN](https://mdn.io/round#Examples) for more details.\n var pair = (toString(number) + 'e').split('e'),\n value = func(pair[0] + 'e' + (+pair[1] + precision));\n\n pair = (toString(value) + 'e').split('e');\n return +(pair[0] + 'e' + (+pair[1] - precision));\n }\n return func(number);\n };\n }\n\n /**\n * Creates a set object of `values`.\n *\n * @private\n * @param {Array} values The values to add to the set.\n * @returns {Object} Returns the new set.\n */\n var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {\n return new Set(values);\n };\n\n /**\n * Creates a `_.toPairs` or `_.toPairsIn` function.\n *\n * @private\n * @param {Function} keysFunc The function to get the keys of a given object.\n * @returns {Function} Returns the new pairs function.\n */\n function createToPairs(keysFunc) {\n return function(object) {\n var tag = getTag(object);\n if (tag == mapTag) {\n return mapToArray(object);\n }\n if (tag == setTag) {\n return setToPairs(object);\n }\n return baseToPairs(object, keysFunc(object));\n };\n }\n\n /**\n * Creates a function that either curries or invokes `func` with optional\n * `this` binding and partially applied arguments.\n *\n * @private\n * @param {Function|string} func The function or method name to wrap.\n * @param {number} bitmask The bitmask flags.\n * 1 - `_.bind`\n * 2 - `_.bindKey`\n * 4 - `_.curry` or `_.curryRight` of a bound function\n * 8 - `_.curry`\n * 16 - `_.curryRight`\n * 32 - `_.partial`\n * 64 - `_.partialRight`\n * 128 - `_.rearg`\n * 256 - `_.ary`\n * 512 - `_.flip`\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to be partially applied.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {\n var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;\n if (!isBindKey && typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var length = partials ? partials.length : 0;\n if (!length) {\n bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);\n partials = holders = undefined;\n }\n ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);\n arity = arity === undefined ? arity : toInteger(arity);\n length -= holders ? holders.length : 0;\n\n if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {\n var partialsRight = partials,\n holdersRight = holders;\n\n partials = holders = undefined;\n }\n var data = isBindKey ? undefined : getData(func);\n\n var newData = [\n func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,\n argPos, ary, arity\n ];\n\n if (data) {\n mergeData(newData, data);\n }\n func = newData[0];\n bitmask = newData[1];\n thisArg = newData[2];\n partials = newData[3];\n holders = newData[4];\n arity = newData[9] = newData[9] === undefined\n ? (isBindKey ? 0 : func.length)\n : nativeMax(newData[9] - length, 0);\n\n if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {\n bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);\n }\n if (!bitmask || bitmask == WRAP_BIND_FLAG) {\n var result = createBind(func, bitmask, thisArg);\n } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {\n result = createCurry(func, bitmask, arity);\n } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {\n result = createPartial(func, bitmask, thisArg, partials);\n } else {\n result = createHybrid.apply(undefined, newData);\n }\n var setter = data ? baseSetData : setData;\n return setWrapToString(setter(result, newData), func, bitmask);\n }\n\n /**\n * Used by `_.defaults` to customize its `_.assignIn` use to assign properties\n * of source objects to the destination object for all destination properties\n * that resolve to `undefined`.\n *\n * @private\n * @param {*} objValue The destination value.\n * @param {*} srcValue The source value.\n * @param {string} key The key of the property to assign.\n * @param {Object} object The parent object of `objValue`.\n * @returns {*} Returns the value to assign.\n */\n function customDefaultsAssignIn(objValue, srcValue, key, object) {\n if (objValue === undefined ||\n (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n return srcValue;\n }\n return objValue;\n }\n\n /**\n * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source\n * objects into destination objects that are passed thru.\n *\n * @private\n * @param {*} objValue The destination value.\n * @param {*} srcValue The source value.\n * @param {string} key The key of the property to merge.\n * @param {Object} object The parent object of `objValue`.\n * @param {Object} source The parent object of `srcValue`.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n * @returns {*} Returns the value to assign.\n */\n function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {\n if (isObject(objValue) && isObject(srcValue)) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, objValue);\n baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);\n stack['delete'](srcValue);\n }\n return objValue;\n }\n\n /**\n * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain\n * objects.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {string} key The key of the property to inspect.\n * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.\n */\n function customOmitClone(value) {\n return isPlainObject(value) ? undefined : value;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\n function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(array);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n }\n\n /**\n * A specialized version of `baseRest` which flattens the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @returns {Function} Returns the new function.\n */\n function flatRest(func) {\n return setToString(overRest(func, undefined, flatten), func + '');\n }\n\n /**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\n function getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n }\n\n /**\n * Creates an array of own and inherited enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\n function getAllKeysIn(object) {\n return baseGetAllKeys(object, keysIn, getSymbolsIn);\n }\n\n /**\n * Gets metadata for `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {*} Returns the metadata for `func`.\n */\n var getData = !metaMap ? noop : function(func) {\n return metaMap.get(func);\n };\n\n /**\n * Gets the name of `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {string} Returns the function name.\n */\n function getFuncName(func) {\n var result = (func.name + ''),\n array = realNames[result],\n length = hasOwnProperty.call(realNames, result) ? array.length : 0;\n\n while (length--) {\n var data = array[length],\n otherFunc = data.func;\n if (otherFunc == null || otherFunc == func) {\n return data.name;\n }\n }\n return result;\n }\n\n /**\n * Gets the argument placeholder value for `func`.\n *\n * @private\n * @param {Function} func The function to inspect.\n * @returns {*} Returns the placeholder value.\n */\n function getHolder(func) {\n var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;\n return object.placeholder;\n }\n\n /**\n * Gets the appropriate \"iteratee\" function. If `_.iteratee` is customized,\n * this function returns the custom method, otherwise it returns `baseIteratee`.\n * If arguments are provided, the chosen function is invoked with them and\n * its result is returned.\n *\n * @private\n * @param {*} [value] The value to convert to an iteratee.\n * @param {number} [arity] The arity of the created iteratee.\n * @returns {Function} Returns the chosen function or its result.\n */\n function getIteratee() {\n var result = lodash.iteratee || iteratee;\n result = result === iteratee ? baseIteratee : result;\n return arguments.length ? result(arguments[0], arguments[1]) : result;\n }\n\n /**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\n function getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n }\n\n /**\n * Gets the property names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\n function getMatchData(object) {\n var result = keys(object),\n length = result.length;\n\n while (length--) {\n var key = result[length],\n value = object[key];\n\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n }\n\n /**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\n function getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n }\n\n /**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\n function getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n }\n\n /**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\n var getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n };\n\n /**\n * Creates an array of the own and inherited enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\n var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {\n var result = [];\n while (object) {\n arrayPush(result, getSymbols(object));\n object = getPrototype(object);\n }\n return result;\n };\n\n /**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\n var getTag = baseGetTag;\n\n // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\n if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n }\n\n /**\n * Gets the view, applying any `transforms` to the `start` and `end` positions.\n *\n * @private\n * @param {number} start The start of the view.\n * @param {number} end The end of the view.\n * @param {Array} transforms The transformations to apply to the view.\n * @returns {Object} Returns an object containing the `start` and `end`\n * positions of the view.\n */\n function getView(start, end, transforms) {\n var index = -1,\n length = transforms.length;\n\n while (++index < length) {\n var data = transforms[index],\n size = data.size;\n\n switch (data.type) {\n case 'drop': start += size; break;\n case 'dropRight': end -= size; break;\n case 'take': end = nativeMin(end, start + size); break;\n case 'takeRight': start = nativeMax(start, end - size); break;\n }\n }\n return { 'start': start, 'end': end };\n }\n\n /**\n * Extracts wrapper details from the `source` body comment.\n *\n * @private\n * @param {string} source The source to inspect.\n * @returns {Array} Returns the wrapper details.\n */\n function getWrapDetails(source) {\n var match = source.match(reWrapDetails);\n return match ? match[1].split(reSplitDetails) : [];\n }\n\n /**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\n function hasPath(object, path, hasFunc) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n result = false;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result || ++index != length) {\n return result;\n }\n length = object == null ? 0 : object.length;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n }\n\n /**\n * Initializes an array clone.\n *\n * @private\n * @param {Array} array The array to clone.\n * @returns {Array} Returns the initialized clone.\n */\n function initCloneArray(array) {\n var length = array.length,\n result = array.constructor(length);\n\n // Add properties assigned by `RegExp#exec`.\n if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {\n result.index = array.index;\n result.input = array.input;\n }\n return result;\n }\n\n /**\n * Initializes an object clone.\n *\n * @private\n * @param {Object} object The object to clone.\n * @returns {Object} Returns the initialized clone.\n */\n function initCloneObject(object) {\n return (typeof object.constructor == 'function' && !isPrototype(object))\n ? baseCreate(getPrototype(object))\n : {};\n }\n\n /**\n * Initializes an object clone based on its `toStringTag`.\n *\n * **Note:** This function only supports cloning values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to clone.\n * @param {string} tag The `toStringTag` of the object to clone.\n * @param {Function} cloneFunc The function to clone values.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the initialized clone.\n */\n function initCloneByTag(object, tag, cloneFunc, isDeep) {\n var Ctor = object.constructor;\n switch (tag) {\n case arrayBufferTag:\n return cloneArrayBuffer(object);\n\n case boolTag:\n case dateTag:\n return new Ctor(+object);\n\n case dataViewTag:\n return cloneDataView(object, isDeep);\n\n case float32Tag: case float64Tag:\n case int8Tag: case int16Tag: case int32Tag:\n case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:\n return cloneTypedArray(object, isDeep);\n\n case mapTag:\n return cloneMap(object, isDeep, cloneFunc);\n\n case numberTag:\n case stringTag:\n return new Ctor(object);\n\n case regexpTag:\n return cloneRegExp(object);\n\n case setTag:\n return cloneSet(object, isDeep, cloneFunc);\n\n case symbolTag:\n return cloneSymbol(object);\n }\n }\n\n /**\n * Inserts wrapper `details` in a comment at the top of the `source` body.\n *\n * @private\n * @param {string} source The source to modify.\n * @returns {Array} details The details to insert.\n * @returns {string} Returns the modified source.\n */\n function insertWrapDetails(source, details) {\n var length = details.length;\n if (!length) {\n return source;\n }\n var lastIndex = length - 1;\n details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];\n details = details.join(length > 2 ? ', ' : ' ');\n return source.replace(reWrapComment, '{\\n/* [wrapped with ' + details + '] */\\n');\n }\n\n /**\n * Checks if `value` is a flattenable `arguments` object or array.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.\n */\n function isFlattenable(value) {\n return isArray(value) || isArguments(value) ||\n !!(spreadableSymbol && value && value[spreadableSymbol]);\n }\n\n /**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\n function isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n }\n\n /**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\n function isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n }\n\n /**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\n function isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n }\n\n /**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\n function isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n }\n\n /**\n * Checks if `func` has a lazy counterpart.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` has a lazy counterpart,\n * else `false`.\n */\n function isLaziable(func) {\n var funcName = getFuncName(func),\n other = lodash[funcName];\n\n if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {\n return false;\n }\n if (func === other) {\n return true;\n }\n var data = getData(other);\n return !!data && func === data[0];\n }\n\n /**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\n function isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n }\n\n /**\n * Checks if `func` is capable of being masked.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `func` is maskable, else `false`.\n */\n var isMaskable = coreJsData ? isFunction : stubFalse;\n\n /**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\n function isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n }\n\n /**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\n function isStrictComparable(value) {\n return value === value && !isObject(value);\n }\n\n /**\n * A specialized version of `matchesProperty` for source values suitable\n * for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\n function matchesStrictComparable(key, srcValue) {\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n }\n\n /**\n * A specialized version of `_.memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\n function memoizeCapped(func) {\n var result = memoize(func, function(key) {\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n var cache = result.cache;\n return result;\n }\n\n /**\n * Merges the function metadata of `source` into `data`.\n *\n * Merging metadata reduces the number of wrappers used to invoke a function.\n * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`\n * may be applied regardless of execution order. Methods like `_.ary` and\n * `_.rearg` modify function arguments, making the order in which they are\n * executed important, preventing the merging of metadata. However, we make\n * an exception for a safe combined case where curried functions have `_.ary`\n * and or `_.rearg` applied.\n *\n * @private\n * @param {Array} data The destination metadata.\n * @param {Array} source The source metadata.\n * @returns {Array} Returns `data`.\n */\n function mergeData(data, source) {\n var bitmask = data[1],\n srcBitmask = source[1],\n newBitmask = bitmask | srcBitmask,\n isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);\n\n var isCombo =\n ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||\n ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||\n ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));\n\n // Exit early if metadata can't be merged.\n if (!(isCommon || isCombo)) {\n return data;\n }\n // Use source `thisArg` if available.\n if (srcBitmask & WRAP_BIND_FLAG) {\n data[2] = source[2];\n // Set when currying a bound function.\n newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;\n }\n // Compose partial arguments.\n var value = source[3];\n if (value) {\n var partials = data[3];\n data[3] = partials ? composeArgs(partials, value, source[4]) : value;\n data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];\n }\n // Compose partial right arguments.\n value = source[5];\n if (value) {\n partials = data[5];\n data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;\n data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];\n }\n // Use source `argPos` if available.\n value = source[7];\n if (value) {\n data[7] = value;\n }\n // Use source `ary` if it's smaller.\n if (srcBitmask & WRAP_ARY_FLAG) {\n data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);\n }\n // Use source `arity` if one is not provided.\n if (data[9] == null) {\n data[9] = source[9];\n }\n // Use source `func` and merge bitmasks.\n data[0] = source[0];\n data[1] = newBitmask;\n\n return data;\n }\n\n /**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\n function objectToString(value) {\n return nativeObjectToString.call(value);\n }\n\n /**\n * A specialized version of `baseRest` which transforms the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @param {Function} transform The rest array transform.\n * @returns {Function} Returns the new function.\n */\n function overRest(func, start, transform) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = transform(array);\n return apply(func, this, otherArgs);\n };\n }\n\n /**\n * Gets the parent value at `path` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path to get the parent value of.\n * @returns {*} Returns the parent value.\n */\n function parent(object, path) {\n return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));\n }\n\n /**\n * Reorder `array` according to the specified indexes where the element at\n * the first index is assigned as the first element, the element at\n * the second index is assigned as the second element, and so on.\n *\n * @private\n * @param {Array} array The array to reorder.\n * @param {Array} indexes The arranged array indexes.\n * @returns {Array} Returns `array`.\n */\n function reorder(array, indexes) {\n var arrLength = array.length,\n length = nativeMin(indexes.length, arrLength),\n oldArray = copyArray(array);\n\n while (length--) {\n var index = indexes[length];\n array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;\n }\n return array;\n }\n\n /**\n * Sets metadata for `func`.\n *\n * **Note:** If this function becomes hot, i.e. is invoked a lot in a short\n * period of time, it will trip its breaker and transition to an identity\n * function to avoid garbage collection pauses in V8. See\n * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)\n * for more details.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\n var setData = shortOut(baseSetData);\n\n /**\n * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).\n *\n * @private\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @returns {number|Object} Returns the timer id or timeout object.\n */\n var setTimeout = ctxSetTimeout || function(func, wait) {\n return root.setTimeout(func, wait);\n };\n\n /**\n * Sets the `toString` method of `func` to return `string`.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\n var setToString = shortOut(baseSetToString);\n\n /**\n * Sets the `toString` method of `wrapper` to mimic the source of `reference`\n * with wrapper details in a comment at the top of the source body.\n *\n * @private\n * @param {Function} wrapper The function to modify.\n * @param {Function} reference The reference function.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @returns {Function} Returns `wrapper`.\n */\n function setWrapToString(wrapper, reference, bitmask) {\n var source = (reference + '');\n return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));\n }\n\n /**\n * Creates a function that'll short out and invoke `identity` instead\n * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n * milliseconds.\n *\n * @private\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new shortable function.\n */\n function shortOut(func) {\n var count = 0,\n lastCalled = 0;\n\n return function() {\n var stamp = nativeNow(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return arguments[0];\n }\n } else {\n count = 0;\n }\n return func.apply(undefined, arguments);\n };\n }\n\n /**\n * A specialized version of `_.shuffle` which mutates and sets the size of `array`.\n *\n * @private\n * @param {Array} array The array to shuffle.\n * @param {number} [size=array.length] The size of `array`.\n * @returns {Array} Returns `array`.\n */\n function shuffleSelf(array, size) {\n var index = -1,\n length = array.length,\n lastIndex = length - 1;\n\n size = size === undefined ? length : size;\n while (++index < size) {\n var rand = baseRandom(index, lastIndex),\n value = array[rand];\n\n array[rand] = array[index];\n array[index] = value;\n }\n array.length = size;\n return array;\n }\n\n /**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\n var stringToPath = memoizeCapped(function(string) {\n var result = [];\n if (reLeadingDot.test(string)) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, string) {\n result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n });\n\n /**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\n function toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n }\n\n /**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\n function toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n }\n\n /**\n * Updates wrapper `details` based on `bitmask` flags.\n *\n * @private\n * @returns {Array} details The details to modify.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @returns {Array} Returns `details`.\n */\n function updateWrapDetails(details, bitmask) {\n arrayEach(wrapFlags, function(pair) {\n var value = '_.' + pair[0];\n if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {\n details.push(value);\n }\n });\n return details.sort();\n }\n\n /**\n * Creates a clone of `wrapper`.\n *\n * @private\n * @param {Object} wrapper The wrapper to clone.\n * @returns {Object} Returns the cloned wrapper.\n */\n function wrapperClone(wrapper) {\n if (wrapper instanceof LazyWrapper) {\n return wrapper.clone();\n }\n var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);\n result.__actions__ = copyArray(wrapper.__actions__);\n result.__index__ = wrapper.__index__;\n result.__values__ = wrapper.__values__;\n return result;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\n function chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array == null ? 0 : array.length;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n }\n\n /**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\n function compact(array) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n }\n\n /**\n * Creates a new array concatenating `array` with any additional arrays\n * and/or values.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to concatenate.\n * @param {...*} [values] The values to concatenate.\n * @returns {Array} Returns the new concatenated array.\n * @example\n *\n * var array = [1];\n * var other = _.concat(array, 2, [3], [[4]]);\n *\n * console.log(other);\n * // => [1, 2, 3, [4]]\n *\n * console.log(array);\n * // => [1]\n */\n function concat() {\n var length = arguments.length;\n if (!length) {\n return [];\n }\n var args = Array(length - 1),\n array = arguments[0],\n index = length;\n\n while (index--) {\n args[index - 1] = arguments[index];\n }\n return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));\n }\n\n /**\n * Creates an array of `array` values not included in the other given arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. The order and references of result values are\n * determined by the first array.\n *\n * **Note:** Unlike `_.pullAll`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.without, _.xor\n * @example\n *\n * _.difference([2, 1], [2, 3]);\n * // => [1]\n */\n var difference = baseRest(function(array, values) {\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))\n : [];\n });\n\n /**\n * This method is like `_.difference` except that it accepts `iteratee` which\n * is invoked for each element of `array` and `values` to generate the criterion\n * by which they're compared. The order and references of result values are\n * determined by the first array. The iteratee is invoked with one argument:\n * (value).\n *\n * **Note:** Unlike `_.pullAllBy`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // => [1.2]\n *\n * // The `_.property` iteratee shorthand.\n * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');\n * // => [{ 'x': 2 }]\n */\n var differenceBy = baseRest(function(array, values) {\n var iteratee = last(values);\n if (isArrayLikeObject(iteratee)) {\n iteratee = undefined;\n }\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))\n : [];\n });\n\n /**\n * This method is like `_.difference` except that it accepts `comparator`\n * which is invoked to compare elements of `array` to `values`. The order and\n * references of result values are determined by the first array. The comparator\n * is invoked with two arguments: (arrVal, othVal).\n *\n * **Note:** Unlike `_.pullAllWith`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n *\n * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);\n * // => [{ 'x': 2, 'y': 1 }]\n */\n var differenceWith = baseRest(function(array, values) {\n var comparator = last(values);\n if (isArrayLikeObject(comparator)) {\n comparator = undefined;\n }\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)\n : [];\n });\n\n /**\n * Creates a slice of `array` with `n` elements dropped from the beginning.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to drop.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.drop([1, 2, 3]);\n * // => [2, 3]\n *\n * _.drop([1, 2, 3], 2);\n * // => [3]\n *\n * _.drop([1, 2, 3], 5);\n * // => []\n *\n * _.drop([1, 2, 3], 0);\n * // => [1, 2, 3]\n */\n function drop(array, n, guard) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n return baseSlice(array, n < 0 ? 0 : n, length);\n }\n\n /**\n * Creates a slice of `array` with `n` elements dropped from the end.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to drop.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.dropRight([1, 2, 3]);\n * // => [1, 2]\n *\n * _.dropRight([1, 2, 3], 2);\n * // => [1]\n *\n * _.dropRight([1, 2, 3], 5);\n * // => []\n *\n * _.dropRight([1, 2, 3], 0);\n * // => [1, 2, 3]\n */\n function dropRight(array, n, guard) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n n = length - n;\n return baseSlice(array, 0, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` excluding elements dropped from the end.\n * Elements are dropped until `predicate` returns falsey. The predicate is\n * invoked with three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.dropRightWhile(users, function(o) { return !o.active; });\n * // => objects for ['barney']\n *\n * // The `_.matches` iteratee shorthand.\n * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });\n * // => objects for ['barney', 'fred']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.dropRightWhile(users, ['active', false]);\n * // => objects for ['barney']\n *\n * // The `_.property` iteratee shorthand.\n * _.dropRightWhile(users, 'active');\n * // => objects for ['barney', 'fred', 'pebbles']\n */\n function dropRightWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3), true, true)\n : [];\n }\n\n /**\n * Creates a slice of `array` excluding elements dropped from the beginning.\n * Elements are dropped until `predicate` returns falsey. The predicate is\n * invoked with three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.dropWhile(users, function(o) { return !o.active; });\n * // => objects for ['pebbles']\n *\n * // The `_.matches` iteratee shorthand.\n * _.dropWhile(users, { 'user': 'barney', 'active': false });\n * // => objects for ['fred', 'pebbles']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.dropWhile(users, ['active', false]);\n * // => objects for ['pebbles']\n *\n * // The `_.property` iteratee shorthand.\n * _.dropWhile(users, 'active');\n * // => objects for ['barney', 'fred', 'pebbles']\n */\n function dropWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3), true)\n : [];\n }\n\n /**\n * Fills elements of `array` with `value` from `start` up to, but not\n * including, `end`.\n *\n * **Note:** This method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 3.2.0\n * @category Array\n * @param {Array} array The array to fill.\n * @param {*} value The value to fill `array` with.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _.fill(array, 'a');\n * console.log(array);\n * // => ['a', 'a', 'a']\n *\n * _.fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * _.fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n */\n function fill(array, value, start, end) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {\n start = 0;\n end = length;\n }\n return baseFill(array, value, start, end);\n }\n\n /**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(o) { return o.user == 'barney'; });\n * // => 0\n *\n * // The `_.matches` iteratee shorthand.\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findIndex(users, ['active', false]);\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.findIndex(users, 'active');\n * // => 2\n */\n function findIndex(array, predicate, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseFindIndex(array, getIteratee(predicate, 3), index);\n }\n\n /**\n * This method is like `_.findIndex` except that it iterates over elements\n * of `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=array.length-1] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });\n * // => 2\n *\n * // The `_.matches` iteratee shorthand.\n * _.findLastIndex(users, { 'user': 'barney', 'active': true });\n * // => 0\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findLastIndex(users, ['active', false]);\n * // => 2\n *\n * // The `_.property` iteratee shorthand.\n * _.findLastIndex(users, 'active');\n * // => 0\n */\n function findLastIndex(array, predicate, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = length - 1;\n if (fromIndex !== undefined) {\n index = toInteger(fromIndex);\n index = fromIndex < 0\n ? nativeMax(length + index, 0)\n : nativeMin(index, length - 1);\n }\n return baseFindIndex(array, getIteratee(predicate, 3), index, true);\n }\n\n /**\n * Flattens `array` a single level deep.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flatten([1, [2, [3, [4]], 5]]);\n * // => [1, 2, [3, [4]], 5]\n */\n function flatten(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, 1) : [];\n }\n\n /**\n * Recursively flattens `array`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flattenDeep([1, [2, [3, [4]], 5]]);\n * // => [1, 2, 3, 4, 5]\n */\n function flattenDeep(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, INFINITY) : [];\n }\n\n /**\n * Recursively flatten `array` up to `depth` times.\n *\n * @static\n * @memberOf _\n * @since 4.4.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @param {number} [depth=1] The maximum recursion depth.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * var array = [1, [2, [3, [4]], 5]];\n *\n * _.flattenDepth(array, 1);\n * // => [1, 2, [3, [4]], 5]\n *\n * _.flattenDepth(array, 2);\n * // => [1, 2, 3, [4], 5]\n */\n function flattenDepth(array, depth) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n depth = depth === undefined ? 1 : toInteger(depth);\n return baseFlatten(array, depth);\n }\n\n /**\n * The inverse of `_.toPairs`; this method returns an object composed\n * from key-value `pairs`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} pairs The key-value pairs.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.fromPairs([['a', 1], ['b', 2]]);\n * // => { 'a': 1, 'b': 2 }\n */\n function fromPairs(pairs) {\n var index = -1,\n length = pairs == null ? 0 : pairs.length,\n result = {};\n\n while (++index < length) {\n var pair = pairs[index];\n result[pair[0]] = pair[1];\n }\n return result;\n }\n\n /**\n * Gets the first element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @alias first\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the first element of `array`.\n * @example\n *\n * _.head([1, 2, 3]);\n * // => 1\n *\n * _.head([]);\n * // => undefined\n */\n function head(array) {\n return (array && array.length) ? array[0] : undefined;\n }\n\n /**\n * Gets the index at which the first occurrence of `value` is found in `array`\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. If `fromIndex` is negative, it's used as the\n * offset from the end of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.indexOf([1, 2, 1, 2], 2);\n * // => 1\n *\n * // Search from the `fromIndex`.\n * _.indexOf([1, 2, 1, 2], 2, 2);\n * // => 3\n */\n function indexOf(array, value, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseIndexOf(array, value, index);\n }\n\n /**\n * Gets all but the last element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.initial([1, 2, 3]);\n * // => [1, 2]\n */\n function initial(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseSlice(array, 0, -1) : [];\n }\n\n /**\n * Creates an array of unique values that are included in all given arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. The order and references of result values are\n * determined by the first array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * _.intersection([2, 1], [2, 3]);\n * // => [2]\n */\n var intersection = baseRest(function(arrays) {\n var mapped = arrayMap(arrays, castArrayLikeObject);\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped)\n : [];\n });\n\n /**\n * This method is like `_.intersection` except that it accepts `iteratee`\n * which is invoked for each element of each `arrays` to generate the criterion\n * by which they're compared. The order and references of result values are\n * determined by the first array. The iteratee is invoked with one argument:\n * (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // => [2.1]\n *\n * // The `_.property` iteratee shorthand.\n * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }]\n */\n var intersectionBy = baseRest(function(arrays) {\n var iteratee = last(arrays),\n mapped = arrayMap(arrays, castArrayLikeObject);\n\n if (iteratee === last(mapped)) {\n iteratee = undefined;\n } else {\n mapped.pop();\n }\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped, getIteratee(iteratee, 2))\n : [];\n });\n\n /**\n * This method is like `_.intersection` except that it accepts `comparator`\n * which is invoked to compare elements of `arrays`. The order and references\n * of result values are determined by the first array. The comparator is\n * invoked with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.intersectionWith(objects, others, _.isEqual);\n * // => [{ 'x': 1, 'y': 2 }]\n */\n var intersectionWith = baseRest(function(arrays) {\n var comparator = last(arrays),\n mapped = arrayMap(arrays, castArrayLikeObject);\n\n comparator = typeof comparator == 'function' ? comparator : undefined;\n if (comparator) {\n mapped.pop();\n }\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped, undefined, comparator)\n : [];\n });\n\n /**\n * Converts all elements in `array` into a string separated by `separator`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to convert.\n * @param {string} [separator=','] The element separator.\n * @returns {string} Returns the joined string.\n * @example\n *\n * _.join(['a', 'b', 'c'], '~');\n * // => 'a~b~c'\n */\n function join(array, separator) {\n return array == null ? '' : nativeJoin.call(array, separator);\n }\n\n /**\n * Gets the last element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the last element of `array`.\n * @example\n *\n * _.last([1, 2, 3]);\n * // => 3\n */\n function last(array) {\n var length = array == null ? 0 : array.length;\n return length ? array[length - 1] : undefined;\n }\n\n /**\n * This method is like `_.indexOf` except that it iterates over elements of\n * `array` from right to left.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=array.length-1] The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.lastIndexOf([1, 2, 1, 2], 2);\n * // => 3\n *\n * // Search from the `fromIndex`.\n * _.lastIndexOf([1, 2, 1, 2], 2, 2);\n * // => 1\n */\n function lastIndexOf(array, value, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = length;\n if (fromIndex !== undefined) {\n index = toInteger(fromIndex);\n index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);\n }\n return value === value\n ? strictLastIndexOf(array, value, index)\n : baseFindIndex(array, baseIsNaN, index, true);\n }\n\n /**\n * Gets the element at index `n` of `array`. If `n` is negative, the nth\n * element from the end is returned.\n *\n * @static\n * @memberOf _\n * @since 4.11.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=0] The index of the element to return.\n * @returns {*} Returns the nth element of `array`.\n * @example\n *\n * var array = ['a', 'b', 'c', 'd'];\n *\n * _.nth(array, 1);\n * // => 'b'\n *\n * _.nth(array, -2);\n * // => 'c';\n */\n function nth(array, n) {\n return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;\n }\n\n /**\n * Removes all given values from `array` using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`\n * to remove elements from an array by predicate.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {...*} [values] The values to remove.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = ['a', 'b', 'c', 'a', 'b', 'c'];\n *\n * _.pull(array, 'a', 'c');\n * console.log(array);\n * // => ['b', 'b']\n */\n var pull = baseRest(pullAll);\n\n /**\n * This method is like `_.pull` except that it accepts an array of values to remove.\n *\n * **Note:** Unlike `_.difference`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = ['a', 'b', 'c', 'a', 'b', 'c'];\n *\n * _.pullAll(array, ['a', 'c']);\n * console.log(array);\n * // => ['b', 'b']\n */\n function pullAll(array, values) {\n return (array && array.length && values && values.length)\n ? basePullAll(array, values)\n : array;\n }\n\n /**\n * This method is like `_.pullAll` except that it accepts `iteratee` which is\n * invoked for each element of `array` and `values` to generate the criterion\n * by which they're compared. The iteratee is invoked with one argument: (value).\n *\n * **Note:** Unlike `_.differenceBy`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];\n *\n * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');\n * console.log(array);\n * // => [{ 'x': 2 }]\n */\n function pullAllBy(array, values, iteratee) {\n return (array && array.length && values && values.length)\n ? basePullAll(array, values, getIteratee(iteratee, 2))\n : array;\n }\n\n /**\n * This method is like `_.pullAll` except that it accepts `comparator` which\n * is invoked to compare elements of `array` to `values`. The comparator is\n * invoked with two arguments: (arrVal, othVal).\n *\n * **Note:** Unlike `_.differenceWith`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 4.6.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];\n *\n * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);\n * console.log(array);\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]\n */\n function pullAllWith(array, values, comparator) {\n return (array && array.length && values && values.length)\n ? basePullAll(array, values, undefined, comparator)\n : array;\n }\n\n /**\n * Removes elements from `array` corresponding to `indexes` and returns an\n * array of removed elements.\n *\n * **Note:** Unlike `_.at`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {...(number|number[])} [indexes] The indexes of elements to remove.\n * @returns {Array} Returns the new array of removed elements.\n * @example\n *\n * var array = ['a', 'b', 'c', 'd'];\n * var pulled = _.pullAt(array, [1, 3]);\n *\n * console.log(array);\n * // => ['a', 'c']\n *\n * console.log(pulled);\n * // => ['b', 'd']\n */\n var pullAt = flatRest(function(array, indexes) {\n var length = array == null ? 0 : array.length,\n result = baseAt(array, indexes);\n\n basePullAt(array, arrayMap(indexes, function(index) {\n return isIndex(index, length) ? +index : index;\n }).sort(compareAscending));\n\n return result;\n });\n\n /**\n * Removes all elements from `array` that `predicate` returns truthy for\n * and returns an array of the removed elements. The predicate is invoked\n * with three arguments: (value, index, array).\n *\n * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`\n * to pull elements from an array by value.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new array of removed elements.\n * @example\n *\n * var array = [1, 2, 3, 4];\n * var evens = _.remove(array, function(n) {\n * return n % 2 == 0;\n * });\n *\n * console.log(array);\n * // => [1, 3]\n *\n * console.log(evens);\n * // => [2, 4]\n */\n function remove(array, predicate) {\n var result = [];\n if (!(array && array.length)) {\n return result;\n }\n var index = -1,\n indexes = [],\n length = array.length;\n\n predicate = getIteratee(predicate, 3);\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result.push(value);\n indexes.push(index);\n }\n }\n basePullAt(array, indexes);\n return result;\n }\n\n /**\n * Reverses `array` so that the first element becomes the last, the second\n * element becomes the second to last, and so on.\n *\n * **Note:** This method mutates `array` and is based on\n * [`Array#reverse`](https://mdn.io/Array/reverse).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _.reverse(array);\n * // => [3, 2, 1]\n *\n * console.log(array);\n * // => [3, 2, 1]\n */\n function reverse(array) {\n return array == null ? array : nativeReverse.call(array);\n }\n\n /**\n * Creates a slice of `array` from `start` up to, but not including, `end`.\n *\n * **Note:** This method is used instead of\n * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are\n * returned.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\n function slice(array, start, end) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {\n start = 0;\n end = length;\n }\n else {\n start = start == null ? 0 : toInteger(start);\n end = end === undefined ? length : toInteger(end);\n }\n return baseSlice(array, start, end);\n }\n\n /**\n * Uses a binary search to determine the lowest index at which `value`\n * should be inserted into `array` in order to maintain its sort order.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * _.sortedIndex([30, 50], 40);\n * // => 1\n */\n function sortedIndex(array, value) {\n return baseSortedIndex(array, value);\n }\n\n /**\n * This method is like `_.sortedIndex` except that it accepts `iteratee`\n * which is invoked for `value` and each element of `array` to compute their\n * sort ranking. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * var objects = [{ 'x': 4 }, { 'x': 5 }];\n *\n * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.sortedIndexBy(objects, { 'x': 4 }, 'x');\n * // => 0\n */\n function sortedIndexBy(array, value, iteratee) {\n return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));\n }\n\n /**\n * This method is like `_.indexOf` except that it performs a binary\n * search on a sorted `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.sortedIndexOf([4, 5, 5, 5, 6], 5);\n * // => 1\n */\n function sortedIndexOf(array, value) {\n var length = array == null ? 0 : array.length;\n if (length) {\n var index = baseSortedIndex(array, value);\n if (index < length && eq(array[index], value)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * This method is like `_.sortedIndex` except that it returns the highest\n * index at which `value` should be inserted into `array` in order to\n * maintain its sort order.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * _.sortedLastIndex([4, 5, 5, 5, 6], 5);\n * // => 4\n */\n function sortedLastIndex(array, value) {\n return baseSortedIndex(array, value, true);\n }\n\n /**\n * This method is like `_.sortedLastIndex` except that it accepts `iteratee`\n * which is invoked for `value` and each element of `array` to compute their\n * sort ranking. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * var objects = [{ 'x': 4 }, { 'x': 5 }];\n *\n * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });\n * // => 1\n *\n * // The `_.property` iteratee shorthand.\n * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');\n * // => 1\n */\n function sortedLastIndexBy(array, value, iteratee) {\n return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);\n }\n\n /**\n * This method is like `_.lastIndexOf` except that it performs a binary\n * search on a sorted `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);\n * // => 3\n */\n function sortedLastIndexOf(array, value) {\n var length = array == null ? 0 : array.length;\n if (length) {\n var index = baseSortedIndex(array, value, true) - 1;\n if (eq(array[index], value)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * This method is like `_.uniq` except that it's designed and optimized\n * for sorted arrays.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.sortedUniq([1, 1, 2]);\n * // => [1, 2]\n */\n function sortedUniq(array) {\n return (array && array.length)\n ? baseSortedUniq(array)\n : [];\n }\n\n /**\n * This method is like `_.uniqBy` except that it's designed and optimized\n * for sorted arrays.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);\n * // => [1.1, 2.3]\n */\n function sortedUniqBy(array, iteratee) {\n return (array && array.length)\n ? baseSortedUniq(array, getIteratee(iteratee, 2))\n : [];\n }\n\n /**\n * Gets all but the first element of `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.tail([1, 2, 3]);\n * // => [2, 3]\n */\n function tail(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseSlice(array, 1, length) : [];\n }\n\n /**\n * Creates a slice of `array` with `n` elements taken from the beginning.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to take.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.take([1, 2, 3]);\n * // => [1]\n *\n * _.take([1, 2, 3], 2);\n * // => [1, 2]\n *\n * _.take([1, 2, 3], 5);\n * // => [1, 2, 3]\n *\n * _.take([1, 2, 3], 0);\n * // => []\n */\n function take(array, n, guard) {\n if (!(array && array.length)) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n return baseSlice(array, 0, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` with `n` elements taken from the end.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to take.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.takeRight([1, 2, 3]);\n * // => [3]\n *\n * _.takeRight([1, 2, 3], 2);\n * // => [2, 3]\n *\n * _.takeRight([1, 2, 3], 5);\n * // => [1, 2, 3]\n *\n * _.takeRight([1, 2, 3], 0);\n * // => []\n */\n function takeRight(array, n, guard) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n n = length - n;\n return baseSlice(array, n < 0 ? 0 : n, length);\n }\n\n /**\n * Creates a slice of `array` with elements taken from the end. Elements are\n * taken until `predicate` returns falsey. The predicate is invoked with\n * three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.takeRightWhile(users, function(o) { return !o.active; });\n * // => objects for ['fred', 'pebbles']\n *\n * // The `_.matches` iteratee shorthand.\n * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });\n * // => objects for ['pebbles']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.takeRightWhile(users, ['active', false]);\n * // => objects for ['fred', 'pebbles']\n *\n * // The `_.property` iteratee shorthand.\n * _.takeRightWhile(users, 'active');\n * // => []\n */\n function takeRightWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3), false, true)\n : [];\n }\n\n /**\n * Creates a slice of `array` with elements taken from the beginning. Elements\n * are taken until `predicate` returns falsey. The predicate is invoked with\n * three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.takeWhile(users, function(o) { return !o.active; });\n * // => objects for ['barney', 'fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.takeWhile(users, { 'user': 'barney', 'active': false });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.takeWhile(users, ['active', false]);\n * // => objects for ['barney', 'fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.takeWhile(users, 'active');\n * // => []\n */\n function takeWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3))\n : [];\n }\n\n /**\n * Creates an array of unique values, in order, from all given arrays using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * _.union([2], [1, 2]);\n * // => [2, 1]\n */\n var union = baseRest(function(arrays) {\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));\n });\n\n /**\n * This method is like `_.union` except that it accepts `iteratee` which is\n * invoked for each element of each `arrays` to generate the criterion by\n * which uniqueness is computed. Result values are chosen from the first\n * array in which the value occurs. The iteratee is invoked with one argument:\n * (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * _.unionBy([2.1], [1.2, 2.3], Math.floor);\n * // => [2.1, 1.2]\n *\n * // The `_.property` iteratee shorthand.\n * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }, { 'x': 2 }]\n */\n var unionBy = baseRest(function(arrays) {\n var iteratee = last(arrays);\n if (isArrayLikeObject(iteratee)) {\n iteratee = undefined;\n }\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));\n });\n\n /**\n * This method is like `_.union` except that it accepts `comparator` which\n * is invoked to compare elements of `arrays`. Result values are chosen from\n * the first array in which the value occurs. The comparator is invoked\n * with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.unionWith(objects, others, _.isEqual);\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]\n */\n var unionWith = baseRest(function(arrays) {\n var comparator = last(arrays);\n comparator = typeof comparator == 'function' ? comparator : undefined;\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);\n });\n\n /**\n * Creates a duplicate-free version of an array, using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons, in which only the first occurrence of each element\n * is kept. The order of result values is determined by the order they occur\n * in the array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.uniq([2, 1, 2]);\n * // => [2, 1]\n */\n function uniq(array) {\n return (array && array.length) ? baseUniq(array) : [];\n }\n\n /**\n * This method is like `_.uniq` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * uniqueness is computed. The order of result values is determined by the\n * order they occur in the array. The iteratee is invoked with one argument:\n * (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.uniqBy([2.1, 1.2, 2.3], Math.floor);\n * // => [2.1, 1.2]\n *\n * // The `_.property` iteratee shorthand.\n * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }, { 'x': 2 }]\n */\n function uniqBy(array, iteratee) {\n return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];\n }\n\n /**\n * This method is like `_.uniq` except that it accepts `comparator` which\n * is invoked to compare elements of `array`. The order of result values is\n * determined by the order they occur in the array.The comparator is invoked\n * with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.uniqWith(objects, _.isEqual);\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]\n */\n function uniqWith(array, comparator) {\n comparator = typeof comparator == 'function' ? comparator : undefined;\n return (array && array.length) ? baseUniq(array, undefined, comparator) : [];\n }\n\n /**\n * This method is like `_.zip` except that it accepts an array of grouped\n * elements and creates an array regrouping the elements to their pre-zip\n * configuration.\n *\n * @static\n * @memberOf _\n * @since 1.2.0\n * @category Array\n * @param {Array} array The array of grouped elements to process.\n * @returns {Array} Returns the new array of regrouped elements.\n * @example\n *\n * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);\n * // => [['a', 1, true], ['b', 2, false]]\n *\n * _.unzip(zipped);\n * // => [['a', 'b'], [1, 2], [true, false]]\n */\n function unzip(array) {\n if (!(array && array.length)) {\n return [];\n }\n var length = 0;\n array = arrayFilter(array, function(group) {\n if (isArrayLikeObject(group)) {\n length = nativeMax(group.length, length);\n return true;\n }\n });\n return baseTimes(length, function(index) {\n return arrayMap(array, baseProperty(index));\n });\n }\n\n /**\n * This method is like `_.unzip` except that it accepts `iteratee` to specify\n * how regrouped values should be combined. The iteratee is invoked with the\n * elements of each group: (...group).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Array\n * @param {Array} array The array of grouped elements to process.\n * @param {Function} [iteratee=_.identity] The function to combine\n * regrouped values.\n * @returns {Array} Returns the new array of regrouped elements.\n * @example\n *\n * var zipped = _.zip([1, 2], [10, 20], [100, 200]);\n * // => [[1, 10, 100], [2, 20, 200]]\n *\n * _.unzipWith(zipped, _.add);\n * // => [3, 30, 300]\n */\n function unzipWith(array, iteratee) {\n if (!(array && array.length)) {\n return [];\n }\n var result = unzip(array);\n if (iteratee == null) {\n return result;\n }\n return arrayMap(result, function(group) {\n return apply(iteratee, undefined, group);\n });\n }\n\n /**\n * Creates an array excluding all given values using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * **Note:** Unlike `_.pull`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...*} [values] The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.difference, _.xor\n * @example\n *\n * _.without([2, 1, 2, 3], 1, 2);\n * // => [3]\n */\n var without = baseRest(function(array, values) {\n return isArrayLikeObject(array)\n ? baseDifference(array, values)\n : [];\n });\n\n /**\n * Creates an array of unique values that is the\n * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)\n * of the given arrays. The order of result values is determined by the order\n * they occur in the arrays.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.difference, _.without\n * @example\n *\n * _.xor([2, 1], [2, 3]);\n * // => [1, 3]\n */\n var xor = baseRest(function(arrays) {\n return baseXor(arrayFilter(arrays, isArrayLikeObject));\n });\n\n /**\n * This method is like `_.xor` except that it accepts `iteratee` which is\n * invoked for each element of each `arrays` to generate the criterion by\n * which by which they're compared. The order of result values is determined\n * by the order they occur in the arrays. The iteratee is invoked with one\n * argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // => [1.2, 3.4]\n *\n * // The `_.property` iteratee shorthand.\n * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 2 }]\n */\n var xorBy = baseRest(function(arrays) {\n var iteratee = last(arrays);\n if (isArrayLikeObject(iteratee)) {\n iteratee = undefined;\n }\n return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));\n });\n\n /**\n * This method is like `_.xor` except that it accepts `comparator` which is\n * invoked to compare elements of `arrays`. The order of result values is\n * determined by the order they occur in the arrays. The comparator is invoked\n * with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.xorWith(objects, others, _.isEqual);\n * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]\n */\n var xorWith = baseRest(function(arrays) {\n var comparator = last(arrays);\n comparator = typeof comparator == 'function' ? comparator : undefined;\n return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);\n });\n\n /**\n * Creates an array of grouped elements, the first of which contains the\n * first elements of the given arrays, the second of which contains the\n * second elements of the given arrays, and so on.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to process.\n * @returns {Array} Returns the new array of grouped elements.\n * @example\n *\n * _.zip(['a', 'b'], [1, 2], [true, false]);\n * // => [['a', 1, true], ['b', 2, false]]\n */\n var zip = baseRest(unzip);\n\n /**\n * This method is like `_.fromPairs` except that it accepts two arrays,\n * one of property identifiers and one of corresponding values.\n *\n * @static\n * @memberOf _\n * @since 0.4.0\n * @category Array\n * @param {Array} [props=[]] The property identifiers.\n * @param {Array} [values=[]] The property values.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.zipObject(['a', 'b'], [1, 2]);\n * // => { 'a': 1, 'b': 2 }\n */\n function zipObject(props, values) {\n return baseZipObject(props || [], values || [], assignValue);\n }\n\n /**\n * This method is like `_.zipObject` except that it supports property paths.\n *\n * @static\n * @memberOf _\n * @since 4.1.0\n * @category Array\n * @param {Array} [props=[]] The property identifiers.\n * @param {Array} [values=[]] The property values.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);\n * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n */\n function zipObjectDeep(props, values) {\n return baseZipObject(props || [], values || [], baseSet);\n }\n\n /**\n * This method is like `_.zip` except that it accepts `iteratee` to specify\n * how grouped values should be combined. The iteratee is invoked with the\n * elements of each group: (...group).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Array\n * @param {...Array} [arrays] The arrays to process.\n * @param {Function} [iteratee=_.identity] The function to combine\n * grouped values.\n * @returns {Array} Returns the new array of grouped elements.\n * @example\n *\n * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {\n * return a + b + c;\n * });\n * // => [111, 222]\n */\n var zipWith = baseRest(function(arrays) {\n var length = arrays.length,\n iteratee = length > 1 ? arrays[length - 1] : undefined;\n\n iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;\n return unzipWith(arrays, iteratee);\n });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a `lodash` wrapper instance that wraps `value` with explicit method\n * chain sequences enabled. The result of such sequences must be unwrapped\n * with `_#value`.\n *\n * @static\n * @memberOf _\n * @since 1.3.0\n * @category Seq\n * @param {*} value The value to wrap.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'pebbles', 'age': 1 }\n * ];\n *\n * var youngest = _\n * .chain(users)\n * .sortBy('age')\n * .map(function(o) {\n * return o.user + ' is ' + o.age;\n * })\n * .head()\n * .value();\n * // => 'pebbles is 1'\n */\n function chain(value) {\n var result = lodash(value);\n result.__chain__ = true;\n return result;\n }\n\n /**\n * This method invokes `interceptor` and returns `value`. The interceptor\n * is invoked with one argument; (value). The purpose of this method is to\n * \"tap into\" a method chain sequence in order to modify intermediate results.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Seq\n * @param {*} value The value to provide to `interceptor`.\n * @param {Function} interceptor The function to invoke.\n * @returns {*} Returns `value`.\n * @example\n *\n * _([1, 2, 3])\n * .tap(function(array) {\n * // Mutate input array.\n * array.pop();\n * })\n * .reverse()\n * .value();\n * // => [2, 1]\n */\n function tap(value, interceptor) {\n interceptor(value);\n return value;\n }\n\n /**\n * This method is like `_.tap` except that it returns the result of `interceptor`.\n * The purpose of this method is to \"pass thru\" values replacing intermediate\n * results in a method chain sequence.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Seq\n * @param {*} value The value to provide to `interceptor`.\n * @param {Function} interceptor The function to invoke.\n * @returns {*} Returns the result of `interceptor`.\n * @example\n *\n * _(' abc ')\n * .chain()\n * .trim()\n * .thru(function(value) {\n * return [value];\n * })\n * .value();\n * // => ['abc']\n */\n function thru(value, interceptor) {\n return interceptor(value);\n }\n\n /**\n * This method is the wrapper version of `_.at`.\n *\n * @name at\n * @memberOf _\n * @since 1.0.0\n * @category Seq\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };\n *\n * _(object).at(['a[0].b.c', 'a[1]']).value();\n * // => [3, 4]\n */\n var wrapperAt = flatRest(function(paths) {\n var length = paths.length,\n start = length ? paths[0] : 0,\n value = this.__wrapped__,\n interceptor = function(object) { return baseAt(object, paths); };\n\n if (length > 1 || this.__actions__.length ||\n !(value instanceof LazyWrapper) || !isIndex(start)) {\n return this.thru(interceptor);\n }\n value = value.slice(start, +start + (length ? 1 : 0));\n value.__actions__.push({\n 'func': thru,\n 'args': [interceptor],\n 'thisArg': undefined\n });\n return new LodashWrapper(value, this.__chain__).thru(function(array) {\n if (length && !array.length) {\n array.push(undefined);\n }\n return array;\n });\n });\n\n /**\n * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.\n *\n * @name chain\n * @memberOf _\n * @since 0.1.0\n * @category Seq\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * // A sequence without explicit chaining.\n * _(users).head();\n * // => { 'user': 'barney', 'age': 36 }\n *\n * // A sequence with explicit chaining.\n * _(users)\n * .chain()\n * .head()\n * .pick('user')\n * .value();\n * // => { 'user': 'barney' }\n */\n function wrapperChain() {\n return chain(this);\n }\n\n /**\n * Executes the chain sequence and returns the wrapped result.\n *\n * @name commit\n * @memberOf _\n * @since 3.2.0\n * @category Seq\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2];\n * var wrapped = _(array).push(3);\n *\n * console.log(array);\n * // => [1, 2]\n *\n * wrapped = wrapped.commit();\n * console.log(array);\n * // => [1, 2, 3]\n *\n * wrapped.last();\n * // => 3\n *\n * console.log(array);\n * // => [1, 2, 3]\n */\n function wrapperCommit() {\n return new LodashWrapper(this.value(), this.__chain__);\n }\n\n /**\n * Gets the next value on a wrapped object following the\n * [iterator protocol](https://mdn.io/iteration_protocols#iterator).\n *\n * @name next\n * @memberOf _\n * @since 4.0.0\n * @category Seq\n * @returns {Object} Returns the next iterator value.\n * @example\n *\n * var wrapped = _([1, 2]);\n *\n * wrapped.next();\n * // => { 'done': false, 'value': 1 }\n *\n * wrapped.next();\n * // => { 'done': false, 'value': 2 }\n *\n * wrapped.next();\n * // => { 'done': true, 'value': undefined }\n */\n function wrapperNext() {\n if (this.__values__ === undefined) {\n this.__values__ = toArray(this.value());\n }\n var done = this.__index__ >= this.__values__.length,\n value = done ? undefined : this.__values__[this.__index__++];\n\n return { 'done': done, 'value': value };\n }\n\n /**\n * Enables the wrapper to be iterable.\n *\n * @name Symbol.iterator\n * @memberOf _\n * @since 4.0.0\n * @category Seq\n * @returns {Object} Returns the wrapper object.\n * @example\n *\n * var wrapped = _([1, 2]);\n *\n * wrapped[Symbol.iterator]() === wrapped;\n * // => true\n *\n * Array.from(wrapped);\n * // => [1, 2]\n */\n function wrapperToIterator() {\n return this;\n }\n\n /**\n * Creates a clone of the chain sequence planting `value` as the wrapped value.\n *\n * @name plant\n * @memberOf _\n * @since 3.2.0\n * @category Seq\n * @param {*} value The value to plant.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var wrapped = _([1, 2]).map(square);\n * var other = wrapped.plant([3, 4]);\n *\n * other.value();\n * // => [9, 16]\n *\n * wrapped.value();\n * // => [1, 4]\n */\n function wrapperPlant(value) {\n var result,\n parent = this;\n\n while (parent instanceof baseLodash) {\n var clone = wrapperClone(parent);\n clone.__index__ = 0;\n clone.__values__ = undefined;\n if (result) {\n previous.__wrapped__ = clone;\n } else {\n result = clone;\n }\n var previous = clone;\n parent = parent.__wrapped__;\n }\n previous.__wrapped__ = value;\n return result;\n }\n\n /**\n * This method is the wrapper version of `_.reverse`.\n *\n * **Note:** This method mutates the wrapped array.\n *\n * @name reverse\n * @memberOf _\n * @since 0.1.0\n * @category Seq\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _(array).reverse().value()\n * // => [3, 2, 1]\n *\n * console.log(array);\n * // => [3, 2, 1]\n */\n function wrapperReverse() {\n var value = this.__wrapped__;\n if (value instanceof LazyWrapper) {\n var wrapped = value;\n if (this.__actions__.length) {\n wrapped = new LazyWrapper(this);\n }\n wrapped = wrapped.reverse();\n wrapped.__actions__.push({\n 'func': thru,\n 'args': [reverse],\n 'thisArg': undefined\n });\n return new LodashWrapper(wrapped, this.__chain__);\n }\n return this.thru(reverse);\n }\n\n /**\n * Executes the chain sequence to resolve the unwrapped value.\n *\n * @name value\n * @memberOf _\n * @since 0.1.0\n * @alias toJSON, valueOf\n * @category Seq\n * @returns {*} Returns the resolved unwrapped value.\n * @example\n *\n * _([1, 2, 3]).value();\n * // => [1, 2, 3]\n */\n function wrapperValue() {\n return baseWrapperValue(this.__wrapped__, this.__actions__);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The corresponding value of\n * each key is the number of times the key was returned by `iteratee`. The\n * iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.countBy([6.1, 4.2, 6.3], Math.floor);\n * // => { '4': 1, '6': 2 }\n *\n * // The `_.property` iteratee shorthand.\n * _.countBy(['one', 'two', 'three'], 'length');\n * // => { '3': 2, '5': 1 }\n */\n var countBy = createAggregator(function(result, value, key) {\n if (hasOwnProperty.call(result, key)) {\n ++result[key];\n } else {\n baseAssignValue(result, key, 1);\n }\n });\n\n /**\n * Checks if `predicate` returns truthy for **all** elements of `collection`.\n * Iteration is stopped once `predicate` returns falsey. The predicate is\n * invoked with three arguments: (value, index|key, collection).\n *\n * **Note:** This method returns `true` for\n * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because\n * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of\n * elements of empty collections.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`.\n * @example\n *\n * _.every([true, 1, null, 'yes'], Boolean);\n * // => false\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.every(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.every(users, ['active', false]);\n * // => true\n *\n * // The `_.property` iteratee shorthand.\n * _.every(users, 'active');\n * // => false\n */\n function every(collection, predicate, guard) {\n var func = isArray(collection) ? arrayEvery : baseEvery;\n if (guard && isIterateeCall(collection, predicate, guard)) {\n predicate = undefined;\n }\n return func(collection, getIteratee(predicate, 3));\n }\n\n /**\n * Iterates over elements of `collection`, returning an array of all elements\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * **Note:** Unlike `_.remove`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n * @see _.reject\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * _.filter(users, function(o) { return !o.active; });\n * // => objects for ['fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.filter(users, { 'age': 36, 'active': true });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.filter(users, ['active', false]);\n * // => objects for ['fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.filter(users, 'active');\n * // => objects for ['barney']\n */\n function filter(collection, predicate) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n return func(collection, getIteratee(predicate, 3));\n }\n\n /**\n * Iterates over elements of `collection`, returning the first element\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false },\n * { 'user': 'pebbles', 'age': 1, 'active': true }\n * ];\n *\n * _.find(users, function(o) { return o.age < 40; });\n * // => object for 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.find(users, { 'age': 1, 'active': true });\n * // => object for 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.find(users, ['active', false]);\n * // => object for 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.find(users, 'active');\n * // => object for 'barney'\n */\n var find = createFind(findIndex);\n\n /**\n * This method is like `_.find` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=collection.length-1] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * _.findLast([1, 2, 3, 4], function(n) {\n * return n % 2 == 1;\n * });\n * // => 3\n */\n var findLast = createFind(findLastIndex);\n\n /**\n * Creates a flattened array of values by running each element in `collection`\n * thru `iteratee` and flattening the mapped results. The iteratee is invoked\n * with three arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * function duplicate(n) {\n * return [n, n];\n * }\n *\n * _.flatMap([1, 2], duplicate);\n * // => [1, 1, 2, 2]\n */\n function flatMap(collection, iteratee) {\n return baseFlatten(map(collection, iteratee), 1);\n }\n\n /**\n * This method is like `_.flatMap` except that it recursively flattens the\n * mapped results.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * function duplicate(n) {\n * return [[[n, n]]];\n * }\n *\n * _.flatMapDeep([1, 2], duplicate);\n * // => [1, 1, 2, 2]\n */\n function flatMapDeep(collection, iteratee) {\n return baseFlatten(map(collection, iteratee), INFINITY);\n }\n\n /**\n * This method is like `_.flatMap` except that it recursively flattens the\n * mapped results up to `depth` times.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {number} [depth=1] The maximum recursion depth.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * function duplicate(n) {\n * return [[[n, n]]];\n * }\n *\n * _.flatMapDepth([1, 2], duplicate, 2);\n * // => [[1, 1], [2, 2]]\n */\n function flatMapDepth(collection, iteratee, depth) {\n depth = depth === undefined ? 1 : toInteger(depth);\n return baseFlatten(map(collection, iteratee), depth);\n }\n\n /**\n * Iterates over elements of `collection` and invokes `iteratee` for each element.\n * The iteratee is invoked with three arguments: (value, index|key, collection).\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * **Note:** As with other \"Collections\" methods, objects with a \"length\"\n * property are iterated like arrays. To avoid this behavior use `_.forIn`\n * or `_.forOwn` for object iteration.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @alias each\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n * @see _.forEachRight\n * @example\n *\n * _.forEach([1, 2], function(value) {\n * console.log(value);\n * });\n * // => Logs `1` then `2`.\n *\n * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a' then 'b' (iteration order is not guaranteed).\n */\n function forEach(collection, iteratee) {\n var func = isArray(collection) ? arrayEach : baseEach;\n return func(collection, getIteratee(iteratee, 3));\n }\n\n /**\n * This method is like `_.forEach` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @alias eachRight\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n * @see _.forEach\n * @example\n *\n * _.forEachRight([1, 2], function(value) {\n * console.log(value);\n * });\n * // => Logs `2` then `1`.\n */\n function forEachRight(collection, iteratee) {\n var func = isArray(collection) ? arrayEachRight : baseEachRight;\n return func(collection, getIteratee(iteratee, 3));\n }\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The order of grouped values\n * is determined by the order they occur in `collection`. The corresponding\n * value of each key is an array of elements responsible for generating the\n * key. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.groupBy([6.1, 4.2, 6.3], Math.floor);\n * // => { '4': [4.2], '6': [6.1, 6.3] }\n *\n * // The `_.property` iteratee shorthand.\n * _.groupBy(['one', 'two', 'three'], 'length');\n * // => { '3': ['one', 'two'], '5': ['three'] }\n */\n var groupBy = createAggregator(function(result, value, key) {\n if (hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n baseAssignValue(result, key, [value]);\n }\n });\n\n /**\n * Checks if `value` is in `collection`. If `collection` is a string, it's\n * checked for a substring of `value`, otherwise\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * is used for equality comparisons. If `fromIndex` is negative, it's used as\n * the offset from the end of `collection`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object|string} collection The collection to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {boolean} Returns `true` if `value` is found, else `false`.\n * @example\n *\n * _.includes([1, 2, 3], 1);\n * // => true\n *\n * _.includes([1, 2, 3], 1, 2);\n * // => false\n *\n * _.includes({ 'a': 1, 'b': 2 }, 1);\n * // => true\n *\n * _.includes('abcd', 'bc');\n * // => true\n */\n function includes(collection, value, fromIndex, guard) {\n collection = isArrayLike(collection) ? collection : values(collection);\n fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;\n\n var length = collection.length;\n if (fromIndex < 0) {\n fromIndex = nativeMax(length + fromIndex, 0);\n }\n return isString(collection)\n ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)\n : (!!length && baseIndexOf(collection, value, fromIndex) > -1);\n }\n\n /**\n * Invokes the method at `path` of each element in `collection`, returning\n * an array of the results of each invoked method. Any additional arguments\n * are provided to each invoked method. If `path` is a function, it's invoked\n * for, and `this` bound to, each element in `collection`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Array|Function|string} path The path of the method to invoke or\n * the function invoked per iteration.\n * @param {...*} [args] The arguments to invoke each method with.\n * @returns {Array} Returns the array of results.\n * @example\n *\n * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');\n * // => [[1, 5, 7], [1, 2, 3]]\n *\n * _.invokeMap([123, 456], String.prototype.split, '');\n * // => [['1', '2', '3'], ['4', '5', '6']]\n */\n var invokeMap = baseRest(function(collection, path, args) {\n var index = -1,\n isFunc = typeof path == 'function',\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value) {\n result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);\n });\n return result;\n });\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The corresponding value of\n * each key is the last element responsible for generating the key. The\n * iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * var array = [\n * { 'dir': 'left', 'code': 97 },\n * { 'dir': 'right', 'code': 100 }\n * ];\n *\n * _.keyBy(array, function(o) {\n * return String.fromCharCode(o.code);\n * });\n * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }\n *\n * _.keyBy(array, 'dir');\n * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }\n */\n var keyBy = createAggregator(function(result, value, key) {\n baseAssignValue(result, key, value);\n });\n\n /**\n * Creates an array of values by running each element in `collection` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.\n *\n * The guarded methods are:\n * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,\n * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,\n * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,\n * `template`, `trim`, `trimEnd`, `trimStart`, and `words`\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * _.map([4, 8], square);\n * // => [16, 64]\n *\n * _.map({ 'a': 4, 'b': 8 }, square);\n * // => [16, 64] (iteration order is not guaranteed)\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * // The `_.property` iteratee shorthand.\n * _.map(users, 'user');\n * // => ['barney', 'fred']\n */\n function map(collection, iteratee) {\n var func = isArray(collection) ? arrayMap : baseMap;\n return func(collection, getIteratee(iteratee, 3));\n }\n\n /**\n * This method is like `_.sortBy` except that it allows specifying the sort\n * orders of the iteratees to sort by. If `orders` is unspecified, all values\n * are sorted in ascending order. Otherwise, specify an order of \"desc\" for\n * descending or \"asc\" for ascending sort order of corresponding values.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]\n * The iteratees to sort by.\n * @param {string[]} [orders] The sort orders of `iteratees`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 34 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'barney', 'age': 36 }\n * ];\n *\n * // Sort by `user` in ascending order and by `age` in descending order.\n * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]\n */\n function orderBy(collection, iteratees, orders, guard) {\n if (collection == null) {\n return [];\n }\n if (!isArray(iteratees)) {\n iteratees = iteratees == null ? [] : [iteratees];\n }\n orders = guard ? undefined : orders;\n if (!isArray(orders)) {\n orders = orders == null ? [] : [orders];\n }\n return baseOrderBy(collection, iteratees, orders);\n }\n\n /**\n * Creates an array of elements split into two groups, the first of which\n * contains elements `predicate` returns truthy for, the second of which\n * contains elements `predicate` returns falsey for. The predicate is\n * invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the array of grouped elements.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': true },\n * { 'user': 'pebbles', 'age': 1, 'active': false }\n * ];\n *\n * _.partition(users, function(o) { return o.active; });\n * // => objects for [['fred'], ['barney', 'pebbles']]\n *\n * // The `_.matches` iteratee shorthand.\n * _.partition(users, { 'age': 1, 'active': false });\n * // => objects for [['pebbles'], ['barney', 'fred']]\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.partition(users, ['active', false]);\n * // => objects for [['barney', 'pebbles'], ['fred']]\n *\n * // The `_.property` iteratee shorthand.\n * _.partition(users, 'active');\n * // => objects for [['fred'], ['barney', 'pebbles']]\n */\n var partition = createAggregator(function(result, value, key) {\n result[key ? 0 : 1].push(value);\n }, function() { return [[], []]; });\n\n /**\n * Reduces `collection` to a value which is the accumulated result of running\n * each element in `collection` thru `iteratee`, where each successive\n * invocation is supplied the return value of the previous. If `accumulator`\n * is not given, the first element of `collection` is used as the initial\n * value. The iteratee is invoked with four arguments:\n * (accumulator, value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.reduce`, `_.reduceRight`, and `_.transform`.\n *\n * The guarded methods are:\n * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,\n * and `sortBy`\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @returns {*} Returns the accumulated value.\n * @see _.reduceRight\n * @example\n *\n * _.reduce([1, 2], function(sum, n) {\n * return sum + n;\n * }, 0);\n * // => 3\n *\n * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {\n * (result[value] || (result[value] = [])).push(key);\n * return result;\n * }, {});\n * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)\n */\n function reduce(collection, iteratee, accumulator) {\n var func = isArray(collection) ? arrayReduce : baseReduce,\n initAccum = arguments.length < 3;\n\n return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);\n }\n\n /**\n * This method is like `_.reduce` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @returns {*} Returns the accumulated value.\n * @see _.reduce\n * @example\n *\n * var array = [[0, 1], [2, 3], [4, 5]];\n *\n * _.reduceRight(array, function(flattened, other) {\n * return flattened.concat(other);\n * }, []);\n * // => [4, 5, 2, 3, 0, 1]\n */\n function reduceRight(collection, iteratee, accumulator) {\n var func = isArray(collection) ? arrayReduceRight : baseReduce,\n initAccum = arguments.length < 3;\n\n return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);\n }\n\n /**\n * The opposite of `_.filter`; this method returns the elements of `collection`\n * that `predicate` does **not** return truthy for.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n * @see _.filter\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': true }\n * ];\n *\n * _.reject(users, function(o) { return !o.active; });\n * // => objects for ['fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.reject(users, { 'age': 40, 'active': true });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.reject(users, ['active', false]);\n * // => objects for ['fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.reject(users, 'active');\n * // => objects for ['barney']\n */\n function reject(collection, predicate) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n return func(collection, negate(getIteratee(predicate, 3)));\n }\n\n /**\n * Gets a random element from `collection`.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to sample.\n * @returns {*} Returns the random element.\n * @example\n *\n * _.sample([1, 2, 3, 4]);\n * // => 2\n */\n function sample(collection) {\n var func = isArray(collection) ? arraySample : baseSample;\n return func(collection);\n }\n\n /**\n * Gets `n` random elements at unique keys from `collection` up to the\n * size of `collection`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to sample.\n * @param {number} [n=1] The number of elements to sample.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the random elements.\n * @example\n *\n * _.sampleSize([1, 2, 3], 2);\n * // => [3, 1]\n *\n * _.sampleSize([1, 2, 3], 4);\n * // => [2, 3, 1]\n */\n function sampleSize(collection, n, guard) {\n if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {\n n = 1;\n } else {\n n = toInteger(n);\n }\n var func = isArray(collection) ? arraySampleSize : baseSampleSize;\n return func(collection, n);\n }\n\n /**\n * Creates an array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to shuffle.\n * @returns {Array} Returns the new shuffled array.\n * @example\n *\n * _.shuffle([1, 2, 3, 4]);\n * // => [4, 1, 3, 2]\n */\n function shuffle(collection) {\n var func = isArray(collection) ? arrayShuffle : baseShuffle;\n return func(collection);\n }\n\n /**\n * Gets the size of `collection` by returning its length for array-like\n * values or the number of own enumerable string keyed properties for objects.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object|string} collection The collection to inspect.\n * @returns {number} Returns the collection size.\n * @example\n *\n * _.size([1, 2, 3]);\n * // => 3\n *\n * _.size({ 'a': 1, 'b': 2 });\n * // => 2\n *\n * _.size('pebbles');\n * // => 7\n */\n function size(collection) {\n if (collection == null) {\n return 0;\n }\n if (isArrayLike(collection)) {\n return isString(collection) ? stringSize(collection) : collection.length;\n }\n var tag = getTag(collection);\n if (tag == mapTag || tag == setTag) {\n return collection.size;\n }\n return baseKeys(collection).length;\n }\n\n /**\n * Checks if `predicate` returns truthy for **any** element of `collection`.\n * Iteration is stopped once `predicate` returns truthy. The predicate is\n * invoked with three arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n * @example\n *\n * _.some([null, 0, 'yes', false], Boolean);\n * // => true\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.some(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.some(users, ['active', false]);\n * // => true\n *\n * // The `_.property` iteratee shorthand.\n * _.some(users, 'active');\n * // => true\n */\n function some(collection, predicate, guard) {\n var func = isArray(collection) ? arraySome : baseSome;\n if (guard && isIterateeCall(collection, predicate, guard)) {\n predicate = undefined;\n }\n return func(collection, getIteratee(predicate, 3));\n }\n\n /**\n * Creates an array of elements, sorted in ascending order by the results of\n * running each element in a collection thru each iteratee. This method\n * performs a stable sort, that is, it preserves the original sort order of\n * equal elements. The iteratees are invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {...(Function|Function[])} [iteratees=[_.identity]]\n * The iteratees to sort by.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'barney', 'age': 34 }\n * ];\n *\n * _.sortBy(users, [function(o) { return o.user; }]);\n * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]\n *\n * _.sortBy(users, ['user', 'age']);\n * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]\n */\n var sortBy = baseRest(function(collection, iteratees) {\n if (collection == null) {\n return [];\n }\n var length = iteratees.length;\n if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {\n iteratees = [];\n } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {\n iteratees = [iteratees[0]];\n }\n return baseOrderBy(collection, baseFlatten(iteratees, 1), []);\n });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\n var now = ctxNow || function() {\n return root.Date.now();\n };\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The opposite of `_.before`; this method creates a function that invokes\n * `func` once it's called `n` or more times.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {number} n The number of calls before `func` is invoked.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var saves = ['profile', 'settings'];\n *\n * var done = _.after(saves.length, function() {\n * console.log('done saving!');\n * });\n *\n * _.forEach(saves, function(type) {\n * asyncSave({ 'type': type, 'complete': done });\n * });\n * // => Logs 'done saving!' after the two async saves have completed.\n */\n function after(n, func) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n n = toInteger(n);\n return function() {\n if (--n < 1) {\n return func.apply(this, arguments);\n }\n };\n }\n\n /**\n * Creates a function that invokes `func`, with up to `n` arguments,\n * ignoring any additional arguments.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} func The function to cap arguments for.\n * @param {number} [n=func.length] The arity cap.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the new capped function.\n * @example\n *\n * _.map(['6', '8', '10'], _.ary(parseInt, 1));\n * // => [6, 8, 10]\n */\n function ary(func, n, guard) {\n n = guard ? undefined : n;\n n = (func && n == null) ? func.length : n;\n return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);\n }\n\n /**\n * Creates a function that invokes `func`, with the `this` binding and arguments\n * of the created function, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {number} n The number of calls at which `func` is no longer invoked.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * jQuery(element).on('click', _.before(5, addContactToList));\n * // => Allows adding up to 4 contacts to the list.\n */\n function before(n, func) {\n var result;\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n n = toInteger(n);\n return function() {\n if (--n > 0) {\n result = func.apply(this, arguments);\n }\n if (n <= 1) {\n func = undefined;\n }\n return result;\n };\n }\n\n /**\n * Creates a function that invokes `func` with the `this` binding of `thisArg`\n * and `partials` prepended to the arguments it receives.\n *\n * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for partially applied arguments.\n *\n * **Note:** Unlike native `Function#bind`, this method doesn't set the \"length\"\n * property of bound functions.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to bind.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * function greet(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n *\n * var object = { 'user': 'fred' };\n *\n * var bound = _.bind(greet, object, 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * // Bound with placeholders.\n * var bound = _.bind(greet, object, _, '!');\n * bound('hi');\n * // => 'hi fred!'\n */\n var bind = baseRest(function(func, thisArg, partials) {\n var bitmask = WRAP_BIND_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, getHolder(bind));\n bitmask |= WRAP_PARTIAL_FLAG;\n }\n return createWrap(func, bitmask, thisArg, partials, holders);\n });\n\n /**\n * Creates a function that invokes the method at `object[key]` with `partials`\n * prepended to the arguments it receives.\n *\n * This method differs from `_.bind` by allowing bound functions to reference\n * methods that may be redefined or don't yet exist. See\n * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)\n * for more details.\n *\n * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * @static\n * @memberOf _\n * @since 0.10.0\n * @category Function\n * @param {Object} object The object to invoke the method on.\n * @param {string} key The key of the method.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * var object = {\n * 'user': 'fred',\n * 'greet': function(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n * };\n *\n * var bound = _.bindKey(object, 'greet', 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * object.greet = function(greeting, punctuation) {\n * return greeting + 'ya ' + this.user + punctuation;\n * };\n *\n * bound('!');\n * // => 'hiya fred!'\n *\n * // Bound with placeholders.\n * var bound = _.bindKey(object, 'greet', _, '!');\n * bound('hi');\n * // => 'hiya fred!'\n */\n var bindKey = baseRest(function(object, key, partials) {\n var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, getHolder(bindKey));\n bitmask |= WRAP_PARTIAL_FLAG;\n }\n return createWrap(key, bitmask, object, partials, holders);\n });\n\n /**\n * Creates a function that accepts arguments of `func` and either invokes\n * `func` returning its result, if at least `arity` number of arguments have\n * been provided, or returns a function that accepts the remaining `func`\n * arguments, and so on. The arity of `func` may be specified if `func.length`\n * is not sufficient.\n *\n * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for provided arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of curried functions.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Function\n * @param {Function} func The function to curry.\n * @param {number} [arity=func.length] The arity of `func`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the new curried function.\n * @example\n *\n * var abc = function(a, b, c) {\n * return [a, b, c];\n * };\n *\n * var curried = _.curry(abc);\n *\n * curried(1)(2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // Curried with placeholders.\n * curried(1)(_, 3)(2);\n * // => [1, 2, 3]\n */\n function curry(func, arity, guard) {\n arity = guard ? undefined : arity;\n var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);\n result.placeholder = curry.placeholder;\n return result;\n }\n\n /**\n * This method is like `_.curry` except that arguments are applied to `func`\n * in the manner of `_.partialRight` instead of `_.partial`.\n *\n * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for provided arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of curried functions.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} func The function to curry.\n * @param {number} [arity=func.length] The arity of `func`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the new curried function.\n * @example\n *\n * var abc = function(a, b, c) {\n * return [a, b, c];\n * };\n *\n * var curried = _.curryRight(abc);\n *\n * curried(3)(2)(1);\n * // => [1, 2, 3]\n *\n * curried(2, 3)(1);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // Curried with placeholders.\n * curried(3)(1, _)(2);\n * // => [1, 2, 3]\n */\n function curryRight(func, arity, guard) {\n arity = guard ? undefined : arity;\n var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);\n result.placeholder = curryRight.placeholder;\n return result;\n }\n\n /**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\n function debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n result = wait - timeSinceLastCall;\n\n return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n }\n\n /**\n * Defers invoking the `func` until the current call stack has cleared. Any\n * additional arguments are provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to defer.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {number} Returns the timer id.\n * @example\n *\n * _.defer(function(text) {\n * console.log(text);\n * }, 'deferred');\n * // => Logs 'deferred' after one millisecond.\n */\n var defer = baseRest(function(func, args) {\n return baseDelay(func, 1, args);\n });\n\n /**\n * Invokes `func` after `wait` milliseconds. Any additional arguments are\n * provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {number} Returns the timer id.\n * @example\n *\n * _.delay(function(text) {\n * console.log(text);\n * }, 1000, 'later');\n * // => Logs 'later' after one second.\n */\n var delay = baseRest(function(func, wait, args) {\n return baseDelay(func, toNumber(wait) || 0, args);\n });\n\n /**\n * Creates a function that invokes `func` with arguments reversed.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Function\n * @param {Function} func The function to flip arguments for.\n * @returns {Function} Returns the new flipped function.\n * @example\n *\n * var flipped = _.flip(function() {\n * return _.toArray(arguments);\n * });\n *\n * flipped('a', 'b', 'c', 'd');\n * // => ['d', 'c', 'b', 'a']\n */\n function flip(func) {\n return createWrap(func, WRAP_FLIP_FLAG);\n }\n\n /**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\n function memoize(func, resolver) {\n if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result) || cache;\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n }\n\n // Expose `MapCache`.\n memoize.Cache = MapCache;\n\n /**\n * Creates a function that negates the result of the predicate `func`. The\n * `func` predicate is invoked with the `this` binding and arguments of the\n * created function.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} predicate The predicate to negate.\n * @returns {Function} Returns the new negated function.\n * @example\n *\n * function isEven(n) {\n * return n % 2 == 0;\n * }\n *\n * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));\n * // => [1, 3, 5]\n */\n function negate(predicate) {\n if (typeof predicate != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return function() {\n var args = arguments;\n switch (args.length) {\n case 0: return !predicate.call(this);\n case 1: return !predicate.call(this, args[0]);\n case 2: return !predicate.call(this, args[0], args[1]);\n case 3: return !predicate.call(this, args[0], args[1], args[2]);\n }\n return !predicate.apply(this, args);\n };\n }\n\n /**\n * Creates a function that is restricted to invoking `func` once. Repeat calls\n * to the function return the value of the first invocation. The `func` is\n * invoked with the `this` binding and arguments of the created function.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var initialize = _.once(createApplication);\n * initialize();\n * initialize();\n * // => `createApplication` is invoked once\n */\n function once(func) {\n return before(2, func);\n }\n\n /**\n * Creates a function that invokes `func` with its arguments transformed.\n *\n * @static\n * @since 4.0.0\n * @memberOf _\n * @category Function\n * @param {Function} func The function to wrap.\n * @param {...(Function|Function[])} [transforms=[_.identity]]\n * The argument transforms.\n * @returns {Function} Returns the new function.\n * @example\n *\n * function doubled(n) {\n * return n * 2;\n * }\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var func = _.overArgs(function(x, y) {\n * return [x, y];\n * }, [square, doubled]);\n *\n * func(9, 3);\n * // => [81, 6]\n *\n * func(10, 5);\n * // => [100, 10]\n */\n var overArgs = castRest(function(func, transforms) {\n transforms = (transforms.length == 1 && isArray(transforms[0]))\n ? arrayMap(transforms[0], baseUnary(getIteratee()))\n : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));\n\n var funcsLength = transforms.length;\n return baseRest(function(args) {\n var index = -1,\n length = nativeMin(args.length, funcsLength);\n\n while (++index < length) {\n args[index] = transforms[index].call(this, args[index]);\n }\n return apply(func, this, args);\n });\n });\n\n /**\n * Creates a function that invokes `func` with `partials` prepended to the\n * arguments it receives. This method is like `_.bind` except it does **not**\n * alter the `this` binding.\n *\n * The `_.partial.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @since 0.2.0\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * var sayHelloTo = _.partial(greet, 'hello');\n * sayHelloTo('fred');\n * // => 'hello fred'\n *\n * // Partially applied with placeholders.\n * var greetFred = _.partial(greet, _, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n */\n var partial = baseRest(function(func, partials) {\n var holders = replaceHolders(partials, getHolder(partial));\n return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);\n });\n\n /**\n * This method is like `_.partial` except that partially applied arguments\n * are appended to the arguments it receives.\n *\n * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * var greetFred = _.partialRight(greet, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n *\n * // Partially applied with placeholders.\n * var sayHelloTo = _.partialRight(greet, 'hello', _);\n * sayHelloTo('fred');\n * // => 'hello fred'\n */\n var partialRight = baseRest(function(func, partials) {\n var holders = replaceHolders(partials, getHolder(partialRight));\n return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);\n });\n\n /**\n * Creates a function that invokes `func` with arguments arranged according\n * to the specified `indexes` where the argument value at the first index is\n * provided as the first argument, the argument value at the second index is\n * provided as the second argument, and so on.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} func The function to rearrange arguments for.\n * @param {...(number|number[])} indexes The arranged argument indexes.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var rearged = _.rearg(function(a, b, c) {\n * return [a, b, c];\n * }, [2, 0, 1]);\n *\n * rearged('b', 'c', 'a')\n * // => ['a', 'b', 'c']\n */\n var rearg = flatRest(function(func, indexes) {\n return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);\n });\n\n /**\n * Creates a function that invokes `func` with the `this` binding of the\n * created function and arguments from `start` and beyond provided as\n * an array.\n *\n * **Note:** This method is based on the\n * [rest parameter](https://mdn.io/rest_parameters).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Function\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var say = _.rest(function(what, names) {\n * return what + ' ' + _.initial(names).join(', ') +\n * (_.size(names) > 1 ? ', & ' : '') + _.last(names);\n * });\n *\n * say('hello', 'fred', 'barney', 'pebbles');\n * // => 'hello fred, barney, & pebbles'\n */\n function rest(func, start) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n start = start === undefined ? start : toInteger(start);\n return baseRest(func, start);\n }\n\n /**\n * Creates a function that invokes `func` with the `this` binding of the\n * create function and an array of arguments much like\n * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).\n *\n * **Note:** This method is based on the\n * [spread operator](https://mdn.io/spread_operator).\n *\n * @static\n * @memberOf _\n * @since 3.2.0\n * @category Function\n * @param {Function} func The function to spread arguments over.\n * @param {number} [start=0] The start position of the spread.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var say = _.spread(function(who, what) {\n * return who + ' says ' + what;\n * });\n *\n * say(['fred', 'hello']);\n * // => 'fred says hello'\n *\n * var numbers = Promise.all([\n * Promise.resolve(40),\n * Promise.resolve(36)\n * ]);\n *\n * numbers.then(_.spread(function(x, y) {\n * return x + y;\n * }));\n * // => a Promise of 76\n */\n function spread(func, start) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n start = start == null ? 0 : nativeMax(toInteger(start), 0);\n return baseRest(function(args) {\n var array = args[start],\n otherArgs = castSlice(args, 0, start);\n\n if (array) {\n arrayPush(otherArgs, array);\n }\n return apply(func, this, otherArgs);\n });\n }\n\n /**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\n function throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n }\n\n /**\n * Creates a function that accepts up to one argument, ignoring any\n * additional arguments.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Function\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n * @example\n *\n * _.map(['6', '8', '10'], _.unary(parseInt));\n * // => [6, 8, 10]\n */\n function unary(func) {\n return ary(func, 1);\n }\n\n /**\n * Creates a function that provides `value` to `wrapper` as its first\n * argument. Any additional arguments provided to the function are appended\n * to those provided to the `wrapper`. The wrapper is invoked with the `this`\n * binding of the created function.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {*} value The value to wrap.\n * @param {Function} [wrapper=identity] The wrapper function.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var p = _.wrap(_.escape, function(func, text) {\n * return '<p>' + func(text) + '</p>';\n * });\n *\n * p('fred, barney, & pebbles');\n * // => '<p>fred, barney, & pebbles</p>'\n */\n function wrap(value, wrapper) {\n return partial(castFunction(wrapper), value);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Casts `value` as an array if it's not one.\n *\n * @static\n * @memberOf _\n * @since 4.4.0\n * @category Lang\n * @param {*} value The value to inspect.\n * @returns {Array} Returns the cast array.\n * @example\n *\n * _.castArray(1);\n * // => [1]\n *\n * _.castArray({ 'a': 1 });\n * // => [{ 'a': 1 }]\n *\n * _.castArray('abc');\n * // => ['abc']\n *\n * _.castArray(null);\n * // => [null]\n *\n * _.castArray(undefined);\n * // => [undefined]\n *\n * _.castArray();\n * // => []\n *\n * var array = [1, 2, 3];\n * console.log(_.castArray(array) === array);\n * // => true\n */\n function castArray() {\n if (!arguments.length) {\n return [];\n }\n var value = arguments[0];\n return isArray(value) ? value : [value];\n }\n\n /**\n * Creates a shallow clone of `value`.\n *\n * **Note:** This method is loosely based on the\n * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)\n * and supports cloning arrays, array buffers, booleans, date objects, maps,\n * numbers, `Object` objects, regexes, sets, strings, symbols, and typed\n * arrays. The own enumerable properties of `arguments` objects are cloned\n * as plain objects. An empty object is returned for uncloneable values such\n * as error objects, functions, DOM nodes, and WeakMaps.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to clone.\n * @returns {*} Returns the cloned value.\n * @see _.cloneDeep\n * @example\n *\n * var objects = [{ 'a': 1 }, { 'b': 2 }];\n *\n * var shallow = _.clone(objects);\n * console.log(shallow[0] === objects[0]);\n * // => true\n */\n function clone(value) {\n return baseClone(value, CLONE_SYMBOLS_FLAG);\n }\n\n /**\n * This method is like `_.clone` except that it accepts `customizer` which\n * is invoked to produce the cloned value. If `customizer` returns `undefined`,\n * cloning is handled by the method instead. The `customizer` is invoked with\n * up to four arguments; (value [, index|key, object, stack]).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to clone.\n * @param {Function} [customizer] The function to customize cloning.\n * @returns {*} Returns the cloned value.\n * @see _.cloneDeepWith\n * @example\n *\n * function customizer(value) {\n * if (_.isElement(value)) {\n * return value.cloneNode(false);\n * }\n * }\n *\n * var el = _.cloneWith(document.body, customizer);\n *\n * console.log(el === document.body);\n * // => false\n * console.log(el.nodeName);\n * // => 'BODY'\n * console.log(el.childNodes.length);\n * // => 0\n */\n function cloneWith(value, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);\n }\n\n /**\n * This method is like `_.clone` except that it recursively clones `value`.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Lang\n * @param {*} value The value to recursively clone.\n * @returns {*} Returns the deep cloned value.\n * @see _.clone\n * @example\n *\n * var objects = [{ 'a': 1 }, { 'b': 2 }];\n *\n * var deep = _.cloneDeep(objects);\n * console.log(deep[0] === objects[0]);\n * // => false\n */\n function cloneDeep(value) {\n return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);\n }\n\n /**\n * This method is like `_.cloneWith` except that it recursively clones `value`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to recursively clone.\n * @param {Function} [customizer] The function to customize cloning.\n * @returns {*} Returns the deep cloned value.\n * @see _.cloneWith\n * @example\n *\n * function customizer(value) {\n * if (_.isElement(value)) {\n * return value.cloneNode(true);\n * }\n * }\n *\n * var el = _.cloneDeepWith(document.body, customizer);\n *\n * console.log(el === document.body);\n * // => false\n * console.log(el.nodeName);\n * // => 'BODY'\n * console.log(el.childNodes.length);\n * // => 20\n */\n function cloneDeepWith(value, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);\n }\n\n /**\n * Checks if `object` conforms to `source` by invoking the predicate\n * properties of `source` with the corresponding property values of `object`.\n *\n * **Note:** This method is equivalent to `_.conforms` when `source` is\n * partially applied.\n *\n * @static\n * @memberOf _\n * @since 4.14.0\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property predicates to conform to.\n * @returns {boolean} Returns `true` if `object` conforms, else `false`.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n *\n * _.conformsTo(object, { 'b': function(n) { return n > 1; } });\n * // => true\n *\n * _.conformsTo(object, { 'b': function(n) { return n > 2; } });\n * // => false\n */\n function conformsTo(object, source) {\n return source == null || baseConformsTo(object, source, keys(source));\n }\n\n /**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\n function eq(value, other) {\n return value === other || (value !== value && other !== other);\n }\n\n /**\n * Checks if `value` is greater than `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than `other`,\n * else `false`.\n * @see _.lt\n * @example\n *\n * _.gt(3, 1);\n * // => true\n *\n * _.gt(3, 3);\n * // => false\n *\n * _.gt(1, 3);\n * // => false\n */\n var gt = createRelationalOperation(baseGt);\n\n /**\n * Checks if `value` is greater than or equal to `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than or equal to\n * `other`, else `false`.\n * @see _.lte\n * @example\n *\n * _.gte(3, 1);\n * // => true\n *\n * _.gte(3, 3);\n * // => true\n *\n * _.gte(1, 3);\n * // => false\n */\n var gte = createRelationalOperation(function(value, other) {\n return value >= other;\n });\n\n /**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\n var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n };\n\n /**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\n var isArray = Array.isArray;\n\n /**\n * Checks if `value` is classified as an `ArrayBuffer` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.\n * @example\n *\n * _.isArrayBuffer(new ArrayBuffer(2));\n * // => true\n *\n * _.isArrayBuffer(new Array(2));\n * // => false\n */\n var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;\n\n /**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\n function isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n }\n\n /**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\n function isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n }\n\n /**\n * Checks if `value` is classified as a boolean primitive or object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.\n * @example\n *\n * _.isBoolean(false);\n * // => true\n *\n * _.isBoolean(null);\n * // => false\n */\n function isBoolean(value) {\n return value === true || value === false ||\n (isObjectLike(value) && baseGetTag(value) == boolTag);\n }\n\n /**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\n var isBuffer = nativeIsBuffer || stubFalse;\n\n /**\n * Checks if `value` is classified as a `Date` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n * @example\n *\n * _.isDate(new Date);\n * // => true\n *\n * _.isDate('Mon April 23 2012');\n * // => false\n */\n var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;\n\n /**\n * Checks if `value` is likely a DOM element.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.\n * @example\n *\n * _.isElement(document.body);\n * // => true\n *\n * _.isElement('<body>');\n * // => false\n */\n function isElement(value) {\n return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);\n }\n\n /**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * jQuery-like collections are considered empty if they have a `length` of `0`.\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is empty, else `false`.\n * @example\n *\n * _.isEmpty(null);\n * // => true\n *\n * _.isEmpty(true);\n * // => true\n *\n * _.isEmpty(1);\n * // => true\n *\n * _.isEmpty([1, 2, 3]);\n * // => false\n *\n * _.isEmpty({ 'a': 1 });\n * // => false\n */\n function isEmpty(value) {\n if (value == null) {\n return true;\n }\n if (isArrayLike(value) &&\n (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||\n isBuffer(value) || isTypedArray(value) || isArguments(value))) {\n return !value.length;\n }\n var tag = getTag(value);\n if (tag == mapTag || tag == setTag) {\n return !value.size;\n }\n if (isPrototype(value)) {\n return !baseKeys(value).length;\n }\n for (var key in value) {\n if (hasOwnProperty.call(value, key)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\n function isEqual(value, other) {\n return baseIsEqual(value, other);\n }\n\n /**\n * This method is like `_.isEqual` except that it accepts `customizer` which\n * is invoked to compare values. If `customizer` returns `undefined`, comparisons\n * are handled by the method instead. The `customizer` is invoked with up to\n * six arguments: (objValue, othValue [, index|key, object, other, stack]).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * function isGreeting(value) {\n * return /^h(?:i|ello)$/.test(value);\n * }\n *\n * function customizer(objValue, othValue) {\n * if (isGreeting(objValue) && isGreeting(othValue)) {\n * return true;\n * }\n * }\n *\n * var array = ['hello', 'goodbye'];\n * var other = ['hi', 'goodbye'];\n *\n * _.isEqualWith(array, other, customizer);\n * // => true\n */\n function isEqualWith(value, other, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n var result = customizer ? customizer(value, other) : undefined;\n return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;\n }\n\n /**\n * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,\n * `SyntaxError`, `TypeError`, or `URIError` object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an error object, else `false`.\n * @example\n *\n * _.isError(new Error);\n * // => true\n *\n * _.isError(Error);\n * // => false\n */\n function isError(value) {\n if (!isObjectLike(value)) {\n return false;\n }\n var tag = baseGetTag(value);\n return tag == errorTag || tag == domExcTag ||\n (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));\n }\n\n /**\n * Checks if `value` is a finite primitive number.\n *\n * **Note:** This method is based on\n * [`Number.isFinite`](https://mdn.io/Number/isFinite).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.\n * @example\n *\n * _.isFinite(3);\n * // => true\n *\n * _.isFinite(Number.MIN_VALUE);\n * // => true\n *\n * _.isFinite(Infinity);\n * // => false\n *\n * _.isFinite('3');\n * // => false\n */\n function isFinite(value) {\n return typeof value == 'number' && nativeIsFinite(value);\n }\n\n /**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\n function isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n }\n\n /**\n * Checks if `value` is an integer.\n *\n * **Note:** This method is based on\n * [`Number.isInteger`](https://mdn.io/Number/isInteger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an integer, else `false`.\n * @example\n *\n * _.isInteger(3);\n * // => true\n *\n * _.isInteger(Number.MIN_VALUE);\n * // => false\n *\n * _.isInteger(Infinity);\n * // => false\n *\n * _.isInteger('3');\n * // => false\n */\n function isInteger(value) {\n return typeof value == 'number' && value == toInteger(value);\n }\n\n /**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\n function isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n }\n\n /**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\n function isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n }\n\n /**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\n function isObjectLike(value) {\n return value != null && typeof value == 'object';\n }\n\n /**\n * Checks if `value` is classified as a `Map` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n * @example\n *\n * _.isMap(new Map);\n * // => true\n *\n * _.isMap(new WeakMap);\n * // => false\n */\n var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;\n\n /**\n * Performs a partial deep comparison between `object` and `source` to\n * determine if `object` contains equivalent property values.\n *\n * **Note:** This method is equivalent to `_.matches` when `source` is\n * partially applied.\n *\n * Partial comparisons will match empty array and empty object `source`\n * values against any array or object value, respectively. See `_.isEqual`\n * for a list of supported value comparisons.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n *\n * _.isMatch(object, { 'b': 2 });\n * // => true\n *\n * _.isMatch(object, { 'b': 1 });\n * // => false\n */\n function isMatch(object, source) {\n return object === source || baseIsMatch(object, source, getMatchData(source));\n }\n\n /**\n * This method is like `_.isMatch` except that it accepts `customizer` which\n * is invoked to compare values. If `customizer` returns `undefined`, comparisons\n * are handled by the method instead. The `customizer` is invoked with five\n * arguments: (objValue, srcValue, index|key, object, source).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n * @example\n *\n * function isGreeting(value) {\n * return /^h(?:i|ello)$/.test(value);\n * }\n *\n * function customizer(objValue, srcValue) {\n * if (isGreeting(objValue) && isGreeting(srcValue)) {\n * return true;\n * }\n * }\n *\n * var object = { 'greeting': 'hello' };\n * var source = { 'greeting': 'hi' };\n *\n * _.isMatchWith(object, source, customizer);\n * // => true\n */\n function isMatchWith(object, source, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return baseIsMatch(object, source, getMatchData(source), customizer);\n }\n\n /**\n * Checks if `value` is `NaN`.\n *\n * **Note:** This method is based on\n * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as\n * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for\n * `undefined` and other non-number values.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n * @example\n *\n * _.isNaN(NaN);\n * // => true\n *\n * _.isNaN(new Number(NaN));\n * // => true\n *\n * isNaN(undefined);\n * // => true\n *\n * _.isNaN(undefined);\n * // => false\n */\n function isNaN(value) {\n // An `NaN` primitive is the only value that is not equal to itself.\n // Perform the `toStringTag` check first to avoid errors with some\n // ActiveX objects in IE.\n return isNumber(value) && value != +value;\n }\n\n /**\n * Checks if `value` is a pristine native function.\n *\n * **Note:** This method can't reliably detect native functions in the presence\n * of the core-js package because core-js circumvents this kind of detection.\n * Despite multiple requests, the core-js maintainer has made it clear: any\n * attempt to fix the detection will be obstructed. As a result, we're left\n * with little choice but to throw an error. Unfortunately, this also affects\n * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),\n * which rely on core-js.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n * @example\n *\n * _.isNative(Array.prototype.push);\n * // => true\n *\n * _.isNative(_);\n * // => false\n */\n function isNative(value) {\n if (isMaskable(value)) {\n throw new Error(CORE_ERROR_TEXT);\n }\n return baseIsNative(value);\n }\n\n /**\n * Checks if `value` is `null`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `null`, else `false`.\n * @example\n *\n * _.isNull(null);\n * // => true\n *\n * _.isNull(void 0);\n * // => false\n */\n function isNull(value) {\n return value === null;\n }\n\n /**\n * Checks if `value` is `null` or `undefined`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is nullish, else `false`.\n * @example\n *\n * _.isNil(null);\n * // => true\n *\n * _.isNil(void 0);\n * // => true\n *\n * _.isNil(NaN);\n * // => false\n */\n function isNil(value) {\n return value == null;\n }\n\n /**\n * Checks if `value` is classified as a `Number` primitive or object.\n *\n * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are\n * classified as numbers, use the `_.isFinite` method.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a number, else `false`.\n * @example\n *\n * _.isNumber(3);\n * // => true\n *\n * _.isNumber(Number.MIN_VALUE);\n * // => true\n *\n * _.isNumber(Infinity);\n * // => true\n *\n * _.isNumber('3');\n * // => false\n */\n function isNumber(value) {\n return typeof value == 'number' ||\n (isObjectLike(value) && baseGetTag(value) == numberTag);\n }\n\n /**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\n function isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n }\n\n /**\n * Checks if `value` is classified as a `RegExp` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.\n * @example\n *\n * _.isRegExp(/abc/);\n * // => true\n *\n * _.isRegExp('/abc/');\n * // => false\n */\n var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;\n\n /**\n * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754\n * double precision number which isn't the result of a rounded unsafe integer.\n *\n * **Note:** This method is based on\n * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.\n * @example\n *\n * _.isSafeInteger(3);\n * // => true\n *\n * _.isSafeInteger(Number.MIN_VALUE);\n * // => false\n *\n * _.isSafeInteger(Infinity);\n * // => false\n *\n * _.isSafeInteger('3');\n * // => false\n */\n function isSafeInteger(value) {\n return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;\n }\n\n /**\n * Checks if `value` is classified as a `Set` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n * @example\n *\n * _.isSet(new Set);\n * // => true\n *\n * _.isSet(new WeakSet);\n * // => false\n */\n var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;\n\n /**\n * Checks if `value` is classified as a `String` primitive or object.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a string, else `false`.\n * @example\n *\n * _.isString('abc');\n * // => true\n *\n * _.isString(1);\n * // => false\n */\n function isString(value) {\n return typeof value == 'string' ||\n (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);\n }\n\n /**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\n function isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n }\n\n /**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\n var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\n /**\n * Checks if `value` is `undefined`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.\n * @example\n *\n * _.isUndefined(void 0);\n * // => true\n *\n * _.isUndefined(null);\n * // => false\n */\n function isUndefined(value) {\n return value === undefined;\n }\n\n /**\n * Checks if `value` is classified as a `WeakMap` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.\n * @example\n *\n * _.isWeakMap(new WeakMap);\n * // => true\n *\n * _.isWeakMap(new Map);\n * // => false\n */\n function isWeakMap(value) {\n return isObjectLike(value) && getTag(value) == weakMapTag;\n }\n\n /**\n * Checks if `value` is classified as a `WeakSet` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.\n * @example\n *\n * _.isWeakSet(new WeakSet);\n * // => true\n *\n * _.isWeakSet(new Set);\n * // => false\n */\n function isWeakSet(value) {\n return isObjectLike(value) && baseGetTag(value) == weakSetTag;\n }\n\n /**\n * Checks if `value` is less than `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than `other`,\n * else `false`.\n * @see _.gt\n * @example\n *\n * _.lt(1, 3);\n * // => true\n *\n * _.lt(3, 3);\n * // => false\n *\n * _.lt(3, 1);\n * // => false\n */\n var lt = createRelationalOperation(baseLt);\n\n /**\n * Checks if `value` is less than or equal to `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than or equal to\n * `other`, else `false`.\n * @see _.gte\n * @example\n *\n * _.lte(1, 3);\n * // => true\n *\n * _.lte(3, 3);\n * // => true\n *\n * _.lte(3, 1);\n * // => false\n */\n var lte = createRelationalOperation(function(value, other) {\n return value <= other;\n });\n\n /**\n * Converts `value` to an array.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Array} Returns the converted array.\n * @example\n *\n * _.toArray({ 'a': 1, 'b': 2 });\n * // => [1, 2]\n *\n * _.toArray('abc');\n * // => ['a', 'b', 'c']\n *\n * _.toArray(1);\n * // => []\n *\n * _.toArray(null);\n * // => []\n */\n function toArray(value) {\n if (!value) {\n return [];\n }\n if (isArrayLike(value)) {\n return isString(value) ? stringToArray(value) : copyArray(value);\n }\n if (symIterator && value[symIterator]) {\n return iteratorToArray(value[symIterator]());\n }\n var tag = getTag(value),\n func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);\n\n return func(value);\n }\n\n /**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\n function toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n }\n\n /**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\n function toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n }\n\n /**\n * Converts `value` to an integer suitable for use as the length of an\n * array-like object.\n *\n * **Note:** This method is based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toLength(3.2);\n * // => 3\n *\n * _.toLength(Number.MIN_VALUE);\n * // => 0\n *\n * _.toLength(Infinity);\n * // => 4294967295\n *\n * _.toLength('3.2');\n * // => 3\n */\n function toLength(value) {\n return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;\n }\n\n /**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\n function toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n }\n\n /**\n * Converts `value` to a plain object flattening inherited enumerable string\n * keyed properties of `value` to own properties of the plain object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Object} Returns the converted plain object.\n * @example\n *\n * function Foo() {\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.assign({ 'a': 1 }, new Foo);\n * // => { 'a': 1, 'b': 2 }\n *\n * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));\n * // => { 'a': 1, 'b': 2, 'c': 3 }\n */\n function toPlainObject(value) {\n return copyObject(value, keysIn(value));\n }\n\n /**\n * Converts `value` to a safe integer. A safe integer can be compared and\n * represented correctly.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toSafeInteger(3.2);\n * // => 3\n *\n * _.toSafeInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toSafeInteger(Infinity);\n * // => 9007199254740991\n *\n * _.toSafeInteger('3.2');\n * // => 3\n */\n function toSafeInteger(value) {\n return value\n ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)\n : (value === 0 ? value : 0);\n }\n\n /**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\n function toString(value) {\n return value == null ? '' : baseToString(value);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Assigns own enumerable string keyed properties of source objects to the\n * destination object. Source objects are applied from left to right.\n * Subsequent sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object` and is loosely based on\n * [`Object.assign`](https://mdn.io/Object/assign).\n *\n * @static\n * @memberOf _\n * @since 0.10.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.assignIn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * function Bar() {\n * this.c = 3;\n * }\n *\n * Foo.prototype.b = 2;\n * Bar.prototype.d = 4;\n *\n * _.assign({ 'a': 0 }, new Foo, new Bar);\n * // => { 'a': 1, 'c': 3 }\n */\n var assign = createAssigner(function(object, source) {\n if (isPrototype(source) || isArrayLike(source)) {\n copyObject(source, keys(source), object);\n return;\n }\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n assignValue(object, key, source[key]);\n }\n }\n });\n\n /**\n * This method is like `_.assign` except that it iterates over own and\n * inherited source properties.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias extend\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.assign\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * function Bar() {\n * this.c = 3;\n * }\n *\n * Foo.prototype.b = 2;\n * Bar.prototype.d = 4;\n *\n * _.assignIn({ 'a': 0 }, new Foo, new Bar);\n * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }\n */\n var assignIn = createAssigner(function(object, source) {\n copyObject(source, keysIn(source), object);\n });\n\n /**\n * This method is like `_.assignIn` except that it accepts `customizer`\n * which is invoked to produce the assigned values. If `customizer` returns\n * `undefined`, assignment is handled by the method instead. The `customizer`\n * is invoked with five arguments: (objValue, srcValue, key, object, source).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias extendWith\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @see _.assignWith\n * @example\n *\n * function customizer(objValue, srcValue) {\n * return _.isUndefined(objValue) ? srcValue : objValue;\n * }\n *\n * var defaults = _.partialRight(_.assignInWith, customizer);\n *\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\n var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {\n copyObject(source, keysIn(source), object, customizer);\n });\n\n /**\n * This method is like `_.assign` except that it accepts `customizer`\n * which is invoked to produce the assigned values. If `customizer` returns\n * `undefined`, assignment is handled by the method instead. The `customizer`\n * is invoked with five arguments: (objValue, srcValue, key, object, source).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @see _.assignInWith\n * @example\n *\n * function customizer(objValue, srcValue) {\n * return _.isUndefined(objValue) ? srcValue : objValue;\n * }\n *\n * var defaults = _.partialRight(_.assignWith, customizer);\n *\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\n var assignWith = createAssigner(function(object, source, srcIndex, customizer) {\n copyObject(source, keys(source), object, customizer);\n });\n\n /**\n * Creates an array of values corresponding to `paths` of `object`.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Array} Returns the picked values.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };\n *\n * _.at(object, ['a[0].b.c', 'a[1]']);\n * // => [3, 4]\n */\n var at = flatRest(baseAt);\n\n /**\n * Creates an object that inherits from the `prototype` object. If a\n * `properties` object is given, its own enumerable string keyed properties\n * are assigned to the created object.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Object\n * @param {Object} prototype The object to inherit from.\n * @param {Object} [properties] The properties to assign to the object.\n * @returns {Object} Returns the new object.\n * @example\n *\n * function Shape() {\n * this.x = 0;\n * this.y = 0;\n * }\n *\n * function Circle() {\n * Shape.call(this);\n * }\n *\n * Circle.prototype = _.create(Shape.prototype, {\n * 'constructor': Circle\n * });\n *\n * var circle = new Circle;\n * circle instanceof Circle;\n * // => true\n *\n * circle instanceof Shape;\n * // => true\n */\n function create(prototype, properties) {\n var result = baseCreate(prototype);\n return properties == null ? result : baseAssign(result, properties);\n }\n\n /**\n * Assigns own and inherited enumerable string keyed properties of source\n * objects to the destination object for all destination properties that\n * resolve to `undefined`. Source objects are applied from left to right.\n * Once a property is set, additional values of the same property are ignored.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.defaultsDeep\n * @example\n *\n * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\n var defaults = baseRest(function(args) {\n args.push(undefined, customDefaultsAssignIn);\n return apply(assignInWith, undefined, args);\n });\n\n /**\n * This method is like `_.defaults` except that it recursively assigns\n * default properties.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.defaults\n * @example\n *\n * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });\n * // => { 'a': { 'b': 2, 'c': 3 } }\n */\n var defaultsDeep = baseRest(function(args) {\n args.push(undefined, customDefaultsMerge);\n return apply(mergeWith, undefined, args);\n });\n\n /**\n * This method is like `_.find` except that it returns the key of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Object\n * @param {Object} object The object to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {string|undefined} Returns the key of the matched element,\n * else `undefined`.\n * @example\n *\n * var users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n *\n * _.findKey(users, function(o) { return o.age < 40; });\n * // => 'barney' (iteration order is not guaranteed)\n *\n * // The `_.matches` iteratee shorthand.\n * _.findKey(users, { 'age': 1, 'active': true });\n * // => 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findKey(users, ['active', false]);\n * // => 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.findKey(users, 'active');\n * // => 'barney'\n */\n function findKey(object, predicate) {\n return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);\n }\n\n /**\n * This method is like `_.findKey` except that it iterates over elements of\n * a collection in the opposite order.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Object\n * @param {Object} object The object to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {string|undefined} Returns the key of the matched element,\n * else `undefined`.\n * @example\n *\n * var users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n *\n * _.findLastKey(users, function(o) { return o.age < 40; });\n * // => returns 'pebbles' assuming `_.findKey` returns 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.findLastKey(users, { 'age': 36, 'active': true });\n * // => 'barney'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findLastKey(users, ['active', false]);\n * // => 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.findLastKey(users, 'active');\n * // => 'pebbles'\n */\n function findLastKey(object, predicate) {\n return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);\n }\n\n /**\n * Iterates over own and inherited enumerable string keyed properties of an\n * object and invokes `iteratee` for each property. The iteratee is invoked\n * with three arguments: (value, key, object). Iteratee functions may exit\n * iteration early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 0.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forInRight\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forIn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).\n */\n function forIn(object, iteratee) {\n return object == null\n ? object\n : baseFor(object, getIteratee(iteratee, 3), keysIn);\n }\n\n /**\n * This method is like `_.forIn` except that it iterates over properties of\n * `object` in the opposite order.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forIn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forInRight(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.\n */\n function forInRight(object, iteratee) {\n return object == null\n ? object\n : baseForRight(object, getIteratee(iteratee, 3), keysIn);\n }\n\n /**\n * Iterates over own enumerable string keyed properties of an object and\n * invokes `iteratee` for each property. The iteratee is invoked with three\n * arguments: (value, key, object). Iteratee functions may exit iteration\n * early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 0.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forOwnRight\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a' then 'b' (iteration order is not guaranteed).\n */\n function forOwn(object, iteratee) {\n return object && baseForOwn(object, getIteratee(iteratee, 3));\n }\n\n /**\n * This method is like `_.forOwn` except that it iterates over properties of\n * `object` in the opposite order.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forOwn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwnRight(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.\n */\n function forOwnRight(object, iteratee) {\n return object && baseForOwnRight(object, getIteratee(iteratee, 3));\n }\n\n /**\n * Creates an array of function property names from own enumerable properties\n * of `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns the function names.\n * @see _.functionsIn\n * @example\n *\n * function Foo() {\n * this.a = _.constant('a');\n * this.b = _.constant('b');\n * }\n *\n * Foo.prototype.c = _.constant('c');\n *\n * _.functions(new Foo);\n * // => ['a', 'b']\n */\n function functions(object) {\n return object == null ? [] : baseFunctions(object, keys(object));\n }\n\n /**\n * Creates an array of function property names from own and inherited\n * enumerable properties of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns the function names.\n * @see _.functions\n * @example\n *\n * function Foo() {\n * this.a = _.constant('a');\n * this.b = _.constant('b');\n * }\n *\n * Foo.prototype.c = _.constant('c');\n *\n * _.functionsIn(new Foo);\n * // => ['a', 'b', 'c']\n */\n function functionsIn(object) {\n return object == null ? [] : baseFunctions(object, keysIn(object));\n }\n\n /**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\n function get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n }\n\n /**\n * Checks if `path` is a direct property of `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = { 'a': { 'b': 2 } };\n * var other = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.has(object, 'a');\n * // => true\n *\n * _.has(object, 'a.b');\n * // => true\n *\n * _.has(object, ['a', 'b']);\n * // => true\n *\n * _.has(other, 'a');\n * // => false\n */\n function has(object, path) {\n return object != null && hasPath(object, path, baseHas);\n }\n\n /**\n * Checks if `path` is a direct or inherited property of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.hasIn(object, 'a');\n * // => true\n *\n * _.hasIn(object, 'a.b');\n * // => true\n *\n * _.hasIn(object, ['a', 'b']);\n * // => true\n *\n * _.hasIn(object, 'b');\n * // => false\n */\n function hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n }\n\n /**\n * Creates an object composed of the inverted keys and values of `object`.\n * If `object` contains duplicate values, subsequent values overwrite\n * property assignments of previous values.\n *\n * @static\n * @memberOf _\n * @since 0.7.0\n * @category Object\n * @param {Object} object The object to invert.\n * @returns {Object} Returns the new inverted object.\n * @example\n *\n * var object = { 'a': 1, 'b': 2, 'c': 1 };\n *\n * _.invert(object);\n * // => { '1': 'c', '2': 'b' }\n */\n var invert = createInverter(function(result, value, key) {\n result[value] = key;\n }, constant(identity));\n\n /**\n * This method is like `_.invert` except that the inverted object is generated\n * from the results of running each element of `object` thru `iteratee`. The\n * corresponding inverted value of each inverted key is an array of keys\n * responsible for generating the inverted value. The iteratee is invoked\n * with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.1.0\n * @category Object\n * @param {Object} object The object to invert.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Object} Returns the new inverted object.\n * @example\n *\n * var object = { 'a': 1, 'b': 2, 'c': 1 };\n *\n * _.invertBy(object);\n * // => { '1': ['a', 'c'], '2': ['b'] }\n *\n * _.invertBy(object, function(value) {\n * return 'group' + value;\n * });\n * // => { 'group1': ['a', 'c'], 'group2': ['b'] }\n */\n var invertBy = createInverter(function(result, value, key) {\n if (hasOwnProperty.call(result, value)) {\n result[value].push(key);\n } else {\n result[value] = [key];\n }\n }, getIteratee);\n\n /**\n * Invokes the method at `path` of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the method to invoke.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {*} Returns the result of the invoked method.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };\n *\n * _.invoke(object, 'a[0].b.c.slice', 1, 3);\n * // => [2, 3]\n */\n var invoke = baseRest(baseInvoke);\n\n /**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\n function keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n }\n\n /**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\n function keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n }\n\n /**\n * The opposite of `_.mapValues`; this method creates an object with the\n * same values as `object` and keys generated by running each own enumerable\n * string keyed property of `object` thru `iteratee`. The iteratee is invoked\n * with three arguments: (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapValues\n * @example\n *\n * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {\n * return key + value;\n * });\n * // => { 'a1': 1, 'b2': 2 }\n */\n function mapKeys(object, iteratee) {\n var result = {};\n iteratee = getIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, iteratee(value, key, object), value);\n });\n return result;\n }\n\n /**\n * Creates an object with the same keys as `object` and values generated\n * by running each own enumerable string keyed property of `object` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapKeys\n * @example\n *\n * var users = {\n * 'fred': { 'user': 'fred', 'age': 40 },\n * 'pebbles': { 'user': 'pebbles', 'age': 1 }\n * };\n *\n * _.mapValues(users, function(o) { return o.age; });\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n *\n * // The `_.property` iteratee shorthand.\n * _.mapValues(users, 'age');\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n */\n function mapValues(object, iteratee) {\n var result = {};\n iteratee = getIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, key, iteratee(value, key, object));\n });\n return result;\n }\n\n /**\n * This method is like `_.assign` except that it recursively merges own and\n * inherited enumerable string keyed properties of source objects into the\n * destination object. Source properties that resolve to `undefined` are\n * skipped if a destination value exists. Array and plain object properties\n * are merged recursively. Other objects and value types are overridden by\n * assignment. Source objects are applied from left to right. Subsequent\n * sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {\n * 'a': [{ 'b': 2 }, { 'd': 4 }]\n * };\n *\n * var other = {\n * 'a': [{ 'c': 3 }, { 'e': 5 }]\n * };\n *\n * _.merge(object, other);\n * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }\n */\n var merge = createAssigner(function(object, source, srcIndex) {\n baseMerge(object, source, srcIndex);\n });\n\n /**\n * This method is like `_.merge` except that it accepts `customizer` which\n * is invoked to produce the merged values of the destination and source\n * properties. If `customizer` returns `undefined`, merging is handled by the\n * method instead. The `customizer` is invoked with six arguments:\n * (objValue, srcValue, key, object, source, stack).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} customizer The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function customizer(objValue, srcValue) {\n * if (_.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * }\n *\n * var object = { 'a': [1], 'b': [2] };\n * var other = { 'a': [3], 'b': [4] };\n *\n * _.mergeWith(object, other, customizer);\n * // => { 'a': [1, 3], 'b': [2, 4] }\n */\n var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {\n baseMerge(object, source, srcIndex, customizer);\n });\n\n /**\n * The opposite of `_.pick`; this method creates an object composed of the\n * own and inherited enumerable property paths of `object` that are not omitted.\n *\n * **Note:** This method is considerably slower than `_.pick`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [paths] The property paths to omit.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.omit(object, ['a', 'c']);\n * // => { 'b': '2' }\n */\n var omit = flatRest(function(object, paths) {\n var result = {};\n if (object == null) {\n return result;\n }\n var isDeep = false;\n paths = arrayMap(paths, function(path) {\n path = castPath(path, object);\n isDeep || (isDeep = path.length > 1);\n return path;\n });\n copyObject(object, getAllKeysIn(object), result);\n if (isDeep) {\n result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);\n }\n var length = paths.length;\n while (length--) {\n baseUnset(result, paths[length]);\n }\n return result;\n });\n\n /**\n * The opposite of `_.pickBy`; this method creates an object composed of\n * the own and inherited enumerable string keyed properties of `object` that\n * `predicate` doesn't return truthy for. The predicate is invoked with two\n * arguments: (value, key).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The source object.\n * @param {Function} [predicate=_.identity] The function invoked per property.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.omitBy(object, _.isNumber);\n * // => { 'b': '2' }\n */\n function omitBy(object, predicate) {\n return pickBy(object, negate(getIteratee(predicate)));\n }\n\n /**\n * Creates an object composed of the picked `object` properties.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.pick(object, ['a', 'c']);\n * // => { 'a': 1, 'c': 3 }\n */\n var pick = flatRest(function(object, paths) {\n return object == null ? {} : basePick(object, paths);\n });\n\n /**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The source object.\n * @param {Function} [predicate=_.identity] The function invoked per property.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.pickBy(object, _.isNumber);\n * // => { 'a': 1, 'c': 3 }\n */\n function pickBy(object, predicate) {\n if (object == null) {\n return {};\n }\n var props = arrayMap(getAllKeysIn(object), function(prop) {\n return [prop];\n });\n predicate = getIteratee(predicate);\n return basePickBy(object, props, function(value, path) {\n return predicate(value, path[0]);\n });\n }\n\n /**\n * This method is like `_.get` except that if the resolved value is a\n * function it's invoked with the `this` binding of its parent object and\n * its result is returned.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to resolve.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };\n *\n * _.result(object, 'a[0].b.c1');\n * // => 3\n *\n * _.result(object, 'a[0].b.c2');\n * // => 4\n *\n * _.result(object, 'a[0].b.c3', 'default');\n * // => 'default'\n *\n * _.result(object, 'a[0].b.c3', _.constant('default'));\n * // => 'default'\n */\n function result(object, path, defaultValue) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length;\n\n // Ensure the loop is entered when path is empty.\n if (!length) {\n length = 1;\n object = undefined;\n }\n while (++index < length) {\n var value = object == null ? undefined : object[toKey(path[index])];\n if (value === undefined) {\n index = length;\n value = defaultValue;\n }\n object = isFunction(value) ? value.call(object) : value;\n }\n return object;\n }\n\n /**\n * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,\n * it's created. Arrays are created for missing index properties while objects\n * are created for all other missing properties. Use `_.setWith` to customize\n * `path` creation.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.set(object, 'a[0].b.c', 4);\n * console.log(object.a[0].b.c);\n * // => 4\n *\n * _.set(object, ['x', '0', 'y', 'z'], 5);\n * console.log(object.x[0].y.z);\n * // => 5\n */\n function set(object, path, value) {\n return object == null ? object : baseSet(object, path, value);\n }\n\n /**\n * This method is like `_.set` except that it accepts `customizer` which is\n * invoked to produce the objects of `path`. If `customizer` returns `undefined`\n * path creation is handled by the method instead. The `customizer` is invoked\n * with three arguments: (nsValue, key, nsObject).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {};\n *\n * _.setWith(object, '[0][1]', 'a', Object);\n * // => { '0': { '1': 'a' } }\n */\n function setWith(object, path, value, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return object == null ? object : baseSet(object, path, value, customizer);\n }\n\n /**\n * Creates an array of own enumerable string keyed-value pairs for `object`\n * which can be consumed by `_.fromPairs`. If `object` is a map or set, its\n * entries are returned.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias entries\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the key-value pairs.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.toPairs(new Foo);\n * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)\n */\n var toPairs = createToPairs(keys);\n\n /**\n * Creates an array of own and inherited enumerable string keyed-value pairs\n * for `object` which can be consumed by `_.fromPairs`. If `object` is a map\n * or set, its entries are returned.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias entriesIn\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the key-value pairs.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.toPairsIn(new Foo);\n * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)\n */\n var toPairsIn = createToPairs(keysIn);\n\n /**\n * An alternative to `_.reduce`; this method transforms `object` to a new\n * `accumulator` object which is the result of running each of its own\n * enumerable string keyed properties thru `iteratee`, with each invocation\n * potentially mutating the `accumulator` object. If `accumulator` is not\n * provided, a new object with the same `[[Prototype]]` will be used. The\n * iteratee is invoked with four arguments: (accumulator, value, key, object).\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 1.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The custom accumulator value.\n * @returns {*} Returns the accumulated value.\n * @example\n *\n * _.transform([2, 3, 4], function(result, n) {\n * result.push(n *= n);\n * return n % 2 == 0;\n * }, []);\n * // => [4, 9]\n *\n * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {\n * (result[value] || (result[value] = [])).push(key);\n * }, {});\n * // => { '1': ['a', 'c'], '2': ['b'] }\n */\n function transform(object, iteratee, accumulator) {\n var isArr = isArray(object),\n isArrLike = isArr || isBuffer(object) || isTypedArray(object);\n\n iteratee = getIteratee(iteratee, 4);\n if (accumulator == null) {\n var Ctor = object && object.constructor;\n if (isArrLike) {\n accumulator = isArr ? new Ctor : [];\n }\n else if (isObject(object)) {\n accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};\n }\n else {\n accumulator = {};\n }\n }\n (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {\n return iteratee(accumulator, value, index, object);\n });\n return accumulator;\n }\n\n /**\n * Removes the property at `path` of `object`.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to unset.\n * @returns {boolean} Returns `true` if the property is deleted, else `false`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 7 } }] };\n * _.unset(object, 'a[0].b.c');\n * // => true\n *\n * console.log(object);\n * // => { 'a': [{ 'b': {} }] };\n *\n * _.unset(object, ['a', '0', 'b', 'c']);\n * // => true\n *\n * console.log(object);\n * // => { 'a': [{ 'b': {} }] };\n */\n function unset(object, path) {\n return object == null ? true : baseUnset(object, path);\n }\n\n /**\n * This method is like `_.set` except that accepts `updater` to produce the\n * value to set. Use `_.updateWith` to customize `path` creation. The `updater`\n * is invoked with one argument: (value).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.6.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {Function} updater The function to produce the updated value.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.update(object, 'a[0].b.c', function(n) { return n * n; });\n * console.log(object.a[0].b.c);\n * // => 9\n *\n * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });\n * console.log(object.x[0].y.z);\n * // => 0\n */\n function update(object, path, updater) {\n return object == null ? object : baseUpdate(object, path, castFunction(updater));\n }\n\n /**\n * This method is like `_.update` except that it accepts `customizer` which is\n * invoked to produce the objects of `path`. If `customizer` returns `undefined`\n * path creation is handled by the method instead. The `customizer` is invoked\n * with three arguments: (nsValue, key, nsObject).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.6.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {Function} updater The function to produce the updated value.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {};\n *\n * _.updateWith(object, '[0][1]', _.constant('a'), Object);\n * // => { '0': { '1': 'a' } }\n */\n function updateWith(object, path, updater, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);\n }\n\n /**\n * Creates an array of the own enumerable string keyed property values of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.values(new Foo);\n * // => [1, 2] (iteration order is not guaranteed)\n *\n * _.values('hi');\n * // => ['h', 'i']\n */\n function values(object) {\n return object == null ? [] : baseValues(object, keys(object));\n }\n\n /**\n * Creates an array of the own and inherited enumerable string keyed property\n * values of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.valuesIn(new Foo);\n * // => [1, 2, 3] (iteration order is not guaranteed)\n */\n function valuesIn(object) {\n return object == null ? [] : baseValues(object, keysIn(object));\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Clamps `number` within the inclusive `lower` and `upper` bounds.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Number\n * @param {number} number The number to clamp.\n * @param {number} [lower] The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the clamped number.\n * @example\n *\n * _.clamp(-10, -5, 5);\n * // => -5\n *\n * _.clamp(10, -5, 5);\n * // => 5\n */\n function clamp(number, lower, upper) {\n if (upper === undefined) {\n upper = lower;\n lower = undefined;\n }\n if (upper !== undefined) {\n upper = toNumber(upper);\n upper = upper === upper ? upper : 0;\n }\n if (lower !== undefined) {\n lower = toNumber(lower);\n lower = lower === lower ? lower : 0;\n }\n return baseClamp(toNumber(number), lower, upper);\n }\n\n /**\n * Checks if `n` is between `start` and up to, but not including, `end`. If\n * `end` is not specified, it's set to `start` with `start` then set to `0`.\n * If `start` is greater than `end` the params are swapped to support\n * negative ranges.\n *\n * @static\n * @memberOf _\n * @since 3.3.0\n * @category Number\n * @param {number} number The number to check.\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n * @see _.range, _.rangeRight\n * @example\n *\n * _.inRange(3, 2, 4);\n * // => true\n *\n * _.inRange(4, 8);\n * // => true\n *\n * _.inRange(4, 2);\n * // => false\n *\n * _.inRange(2, 2);\n * // => false\n *\n * _.inRange(1.2, 2);\n * // => true\n *\n * _.inRange(5.2, 4);\n * // => false\n *\n * _.inRange(-3, -2, -6);\n * // => true\n */\n function inRange(number, start, end) {\n start = toFinite(start);\n if (end === undefined) {\n end = start;\n start = 0;\n } else {\n end = toFinite(end);\n }\n number = toNumber(number);\n return baseInRange(number, start, end);\n }\n\n /**\n * Produces a random number between the inclusive `lower` and `upper` bounds.\n * If only one argument is provided a number between `0` and the given number\n * is returned. If `floating` is `true`, or either `lower` or `upper` are\n * floats, a floating-point number is returned instead of an integer.\n *\n * **Note:** JavaScript follows the IEEE-754 standard for resolving\n * floating-point values which can produce unexpected results.\n *\n * @static\n * @memberOf _\n * @since 0.7.0\n * @category Number\n * @param {number} [lower=0] The lower bound.\n * @param {number} [upper=1] The upper bound.\n * @param {boolean} [floating] Specify returning a floating-point number.\n * @returns {number} Returns the random number.\n * @example\n *\n * _.random(0, 5);\n * // => an integer between 0 and 5\n *\n * _.random(5);\n * // => also an integer between 0 and 5\n *\n * _.random(5, true);\n * // => a floating-point number between 0 and 5\n *\n * _.random(1.2, 5.2);\n * // => a floating-point number between 1.2 and 5.2\n */\n function random(lower, upper, floating) {\n if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {\n upper = floating = undefined;\n }\n if (floating === undefined) {\n if (typeof upper == 'boolean') {\n floating = upper;\n upper = undefined;\n }\n else if (typeof lower == 'boolean') {\n floating = lower;\n lower = undefined;\n }\n }\n if (lower === undefined && upper === undefined) {\n lower = 0;\n upper = 1;\n }\n else {\n lower = toFinite(lower);\n if (upper === undefined) {\n upper = lower;\n lower = 0;\n } else {\n upper = toFinite(upper);\n }\n }\n if (lower > upper) {\n var temp = lower;\n lower = upper;\n upper = temp;\n }\n if (floating || lower % 1 || upper % 1) {\n var rand = nativeRandom();\n return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);\n }\n return baseRandom(lower, upper);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the camel cased string.\n * @example\n *\n * _.camelCase('Foo Bar');\n * // => 'fooBar'\n *\n * _.camelCase('--foo-bar--');\n * // => 'fooBar'\n *\n * _.camelCase('__FOO_BAR__');\n * // => 'fooBar'\n */\n var camelCase = createCompounder(function(result, word, index) {\n word = word.toLowerCase();\n return result + (index ? capitalize(word) : word);\n });\n\n /**\n * Converts the first character of `string` to upper case and the remaining\n * to lower case.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to capitalize.\n * @returns {string} Returns the capitalized string.\n * @example\n *\n * _.capitalize('FRED');\n * // => 'Fred'\n */\n function capitalize(string) {\n return upperFirst(toString(string).toLowerCase());\n }\n\n /**\n * Deburrs `string` by converting\n * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)\n * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)\n * letters to basic Latin letters and removing\n * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to deburr.\n * @returns {string} Returns the deburred string.\n * @example\n *\n * _.deburr('déjà vu');\n * // => 'deja vu'\n */\n function deburr(string) {\n string = toString(string);\n return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');\n }\n\n /**\n * Checks if `string` ends with the given target string.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {string} [target] The string to search for.\n * @param {number} [position=string.length] The position to search up to.\n * @returns {boolean} Returns `true` if `string` ends with `target`,\n * else `false`.\n * @example\n *\n * _.endsWith('abc', 'c');\n * // => true\n *\n * _.endsWith('abc', 'b');\n * // => false\n *\n * _.endsWith('abc', 'b', 2);\n * // => true\n */\n function endsWith(string, target, position) {\n string = toString(string);\n target = baseToString(target);\n\n var length = string.length;\n position = position === undefined\n ? length\n : baseClamp(toInteger(position), 0, length);\n\n var end = position;\n position -= target.length;\n return position >= 0 && string.slice(position, end) == target;\n }\n\n /**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `string` to their\n * corresponding HTML entities.\n *\n * **Note:** No other characters are escaped. To escape additional\n * characters use a third-party library like [_he_](https://mths.be/he).\n *\n * Though the \">\" character is escaped for symmetry, characters like\n * \">\" and \"/\" don't need escaping in HTML and have no special meaning\n * unless they're part of a tag or unquoted attribute value. See\n * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)\n * (under \"semi-related fun fact\") for more details.\n *\n * When working with HTML you should always\n * [quote attribute values](http://wonko.com/post/html-escaping) to reduce\n * XSS vectors.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escape('fred, barney, & pebbles');\n * // => 'fred, barney, & pebbles'\n */\n function escape(string) {\n string = toString(string);\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, escapeHtmlChar)\n : string;\n }\n\n /**\n * Escapes the `RegExp` special characters \"^\", \"$\", \"\\\", \".\", \"*\", \"+\",\n * \"?\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", and \"|\" in `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escapeRegExp('[lodash](https://lodash.com/)');\n * // => '\\[lodash\\]\\(https://lodash\\.com/\\)'\n */\n function escapeRegExp(string) {\n string = toString(string);\n return (string && reHasRegExpChar.test(string))\n ? string.replace(reRegExpChar, '\\\\$&')\n : string;\n }\n\n /**\n * Converts `string` to\n * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the kebab cased string.\n * @example\n *\n * _.kebabCase('Foo Bar');\n * // => 'foo-bar'\n *\n * _.kebabCase('fooBar');\n * // => 'foo-bar'\n *\n * _.kebabCase('__FOO_BAR__');\n * // => 'foo-bar'\n */\n var kebabCase = createCompounder(function(result, word, index) {\n return result + (index ? '-' : '') + word.toLowerCase();\n });\n\n /**\n * Converts `string`, as space separated words, to lower case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the lower cased string.\n * @example\n *\n * _.lowerCase('--Foo-Bar--');\n * // => 'foo bar'\n *\n * _.lowerCase('fooBar');\n * // => 'foo bar'\n *\n * _.lowerCase('__FOO_BAR__');\n * // => 'foo bar'\n */\n var lowerCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + word.toLowerCase();\n });\n\n /**\n * Converts the first character of `string` to lower case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.lowerFirst('Fred');\n * // => 'fred'\n *\n * _.lowerFirst('FRED');\n * // => 'fRED'\n */\n var lowerFirst = createCaseFirst('toLowerCase');\n\n /**\n * Pads `string` on the left and right sides if it's shorter than `length`.\n * Padding characters are truncated if they can't be evenly divided by `length`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.pad('abc', 8);\n * // => ' abc '\n *\n * _.pad('abc', 8, '_-');\n * // => '_-abc_-_'\n *\n * _.pad('abc', 3);\n * // => 'abc'\n */\n function pad(string, length, chars) {\n string = toString(string);\n length = toInteger(length);\n\n var strLength = length ? stringSize(string) : 0;\n if (!length || strLength >= length) {\n return string;\n }\n var mid = (length - strLength) / 2;\n return (\n createPadding(nativeFloor(mid), chars) +\n string +\n createPadding(nativeCeil(mid), chars)\n );\n }\n\n /**\n * Pads `string` on the right side if it's shorter than `length`. Padding\n * characters are truncated if they exceed `length`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.padEnd('abc', 6);\n * // => 'abc '\n *\n * _.padEnd('abc', 6, '_-');\n * // => 'abc_-_'\n *\n * _.padEnd('abc', 3);\n * // => 'abc'\n */\n function padEnd(string, length, chars) {\n string = toString(string);\n length = toInteger(length);\n\n var strLength = length ? stringSize(string) : 0;\n return (length && strLength < length)\n ? (string + createPadding(length - strLength, chars))\n : string;\n }\n\n /**\n * Pads `string` on the left side if it's shorter than `length`. Padding\n * characters are truncated if they exceed `length`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.padStart('abc', 6);\n * // => ' abc'\n *\n * _.padStart('abc', 6, '_-');\n * // => '_-_abc'\n *\n * _.padStart('abc', 3);\n * // => 'abc'\n */\n function padStart(string, length, chars) {\n string = toString(string);\n length = toInteger(length);\n\n var strLength = length ? stringSize(string) : 0;\n return (length && strLength < length)\n ? (createPadding(length - strLength, chars) + string)\n : string;\n }\n\n /**\n * Converts `string` to an integer of the specified radix. If `radix` is\n * `undefined` or `0`, a `radix` of `10` is used unless `value` is a\n * hexadecimal, in which case a `radix` of `16` is used.\n *\n * **Note:** This method aligns with the\n * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category String\n * @param {string} string The string to convert.\n * @param {number} [radix=10] The radix to interpret `value` by.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.parseInt('08');\n * // => 8\n *\n * _.map(['6', '08', '10'], _.parseInt);\n * // => [6, 8, 10]\n */\n function parseInt(string, radix, guard) {\n if (guard || radix == null) {\n radix = 0;\n } else if (radix) {\n radix = +radix;\n }\n return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);\n }\n\n /**\n * Repeats the given string `n` times.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to repeat.\n * @param {number} [n=1] The number of times to repeat the string.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the repeated string.\n * @example\n *\n * _.repeat('*', 3);\n * // => '***'\n *\n * _.repeat('abc', 2);\n * // => 'abcabc'\n *\n * _.repeat('abc', 0);\n * // => ''\n */\n function repeat(string, n, guard) {\n if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {\n n = 1;\n } else {\n n = toInteger(n);\n }\n return baseRepeat(toString(string), n);\n }\n\n /**\n * Replaces matches for `pattern` in `string` with `replacement`.\n *\n * **Note:** This method is based on\n * [`String#replace`](https://mdn.io/String/replace).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to modify.\n * @param {RegExp|string} pattern The pattern to replace.\n * @param {Function|string} replacement The match replacement.\n * @returns {string} Returns the modified string.\n * @example\n *\n * _.replace('Hi Fred', 'Fred', 'Barney');\n * // => 'Hi Barney'\n */\n function replace() {\n var args = arguments,\n string = toString(args[0]);\n\n return args.length < 3 ? string : string.replace(args[1], args[2]);\n }\n\n /**\n * Converts `string` to\n * [snake case](https://en.wikipedia.org/wiki/Snake_case).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the snake cased string.\n * @example\n *\n * _.snakeCase('Foo Bar');\n * // => 'foo_bar'\n *\n * _.snakeCase('fooBar');\n * // => 'foo_bar'\n *\n * _.snakeCase('--FOO-BAR--');\n * // => 'foo_bar'\n */\n var snakeCase = createCompounder(function(result, word, index) {\n return result + (index ? '_' : '') + word.toLowerCase();\n });\n\n /**\n * Splits `string` by `separator`.\n *\n * **Note:** This method is based on\n * [`String#split`](https://mdn.io/String/split).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to split.\n * @param {RegExp|string} separator The separator pattern to split by.\n * @param {number} [limit] The length to truncate results to.\n * @returns {Array} Returns the string segments.\n * @example\n *\n * _.split('a-b-c', '-', 2);\n * // => ['a', 'b']\n */\n function split(string, separator, limit) {\n if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {\n separator = limit = undefined;\n }\n limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;\n if (!limit) {\n return [];\n }\n string = toString(string);\n if (string && (\n typeof separator == 'string' ||\n (separator != null && !isRegExp(separator))\n )) {\n separator = baseToString(separator);\n if (!separator && hasUnicode(string)) {\n return castSlice(stringToArray(string), 0, limit);\n }\n }\n return string.split(separator, limit);\n }\n\n /**\n * Converts `string` to\n * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).\n *\n * @static\n * @memberOf _\n * @since 3.1.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the start cased string.\n * @example\n *\n * _.startCase('--foo-bar--');\n * // => 'Foo Bar'\n *\n * _.startCase('fooBar');\n * // => 'Foo Bar'\n *\n * _.startCase('__FOO_BAR__');\n * // => 'FOO BAR'\n */\n var startCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + upperFirst(word);\n });\n\n /**\n * Checks if `string` starts with the given target string.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {string} [target] The string to search for.\n * @param {number} [position=0] The position to search from.\n * @returns {boolean} Returns `true` if `string` starts with `target`,\n * else `false`.\n * @example\n *\n * _.startsWith('abc', 'a');\n * // => true\n *\n * _.startsWith('abc', 'b');\n * // => false\n *\n * _.startsWith('abc', 'b', 1);\n * // => true\n */\n function startsWith(string, target, position) {\n string = toString(string);\n position = position == null\n ? 0\n : baseClamp(toInteger(position), 0, string.length);\n\n target = baseToString(target);\n return string.slice(position, position + target.length) == target;\n }\n\n /**\n * Creates a compiled template function that can interpolate data properties\n * in \"interpolate\" delimiters, HTML-escape interpolated data properties in\n * \"escape\" delimiters, and execute JavaScript in \"evaluate\" delimiters. Data\n * properties may be accessed as free variables in the template. If a setting\n * object is given, it takes precedence over `_.templateSettings` values.\n *\n * **Note:** In the development build `_.template` utilizes\n * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)\n * for easier debugging.\n *\n * For more information on precompiling templates see\n * [lodash's custom builds documentation](https://lodash.com/custom-builds).\n *\n * For more information on Chrome extension sandboxes see\n * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The template string.\n * @param {Object} [options={}] The options object.\n * @param {RegExp} [options.escape=_.templateSettings.escape]\n * The HTML \"escape\" delimiter.\n * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]\n * The \"evaluate\" delimiter.\n * @param {Object} [options.imports=_.templateSettings.imports]\n * An object to import into the template as free variables.\n * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]\n * The \"interpolate\" delimiter.\n * @param {string} [options.sourceURL='lodash.templateSources[n]']\n * The sourceURL of the compiled template.\n * @param {string} [options.variable='obj']\n * The data object variable name.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the compiled template function.\n * @example\n *\n * // Use the \"interpolate\" delimiter to create a compiled template.\n * var compiled = _.template('hello <%= user %>!');\n * compiled({ 'user': 'fred' });\n * // => 'hello fred!'\n *\n * // Use the HTML \"escape\" delimiter to escape data property values.\n * var compiled = _.template('<b><%- value %></b>');\n * compiled({ 'value': '<script>' });\n * // => '<b><script></b>'\n *\n * // Use the \"evaluate\" delimiter to execute JavaScript and generate HTML.\n * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the internal `print` function in \"evaluate\" delimiters.\n * var compiled = _.template('<% print(\"hello \" + user); %>!');\n * compiled({ 'user': 'barney' });\n * // => 'hello barney!'\n *\n * // Use the ES template literal delimiter as an \"interpolate\" delimiter.\n * // Disable support by replacing the \"interpolate\" delimiter.\n * var compiled = _.template('hello ${ user }!');\n * compiled({ 'user': 'pebbles' });\n * // => 'hello pebbles!'\n *\n * // Use backslashes to treat delimiters as plain text.\n * var compiled = _.template('<%= \"\\\\<%- value %\\\\>\" %>');\n * compiled({ 'value': 'ignored' });\n * // => '<%- value %>'\n *\n * // Use the `imports` option to import `jQuery` as `jq`.\n * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';\n * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the `sourceURL` option to specify a custom sourceURL for the template.\n * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });\n * compiled(data);\n * // => Find the source of \"greeting.jst\" under the Sources tab or Resources panel of the web inspector.\n *\n * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.\n * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });\n * compiled.source;\n * // => function(data) {\n * // var __t, __p = '';\n * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';\n * // return __p;\n * // }\n *\n * // Use custom template delimiters.\n * _.templateSettings.interpolate = /{{([\\s\\S]+?)}}/g;\n * var compiled = _.template('hello {{ user }}!');\n * compiled({ 'user': 'mustache' });\n * // => 'hello mustache!'\n *\n * // Use the `source` property to inline compiled templates for meaningful\n * // line numbers in error messages and stack traces.\n * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\\\n * var JST = {\\\n * \"main\": ' + _.template(mainText).source + '\\\n * };\\\n * ');\n */\n function template(string, options, guard) {\n // Based on John Resig's `tmpl` implementation\n // (http://ejohn.org/blog/javascript-micro-templating/)\n // and Laura Doktorova's doT.js (https://github.com/olado/doT).\n var settings = lodash.templateSettings;\n\n if (guard && isIterateeCall(string, options, guard)) {\n options = undefined;\n }\n string = toString(string);\n options = assignInWith({}, options, settings, customDefaultsAssignIn);\n\n var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),\n importsKeys = keys(imports),\n importsValues = baseValues(imports, importsKeys);\n\n var isEscaping,\n isEvaluating,\n index = 0,\n interpolate = options.interpolate || reNoMatch,\n source = \"__p += '\";\n\n // Compile the regexp to match each delimiter.\n var reDelimiters = RegExp(\n (options.escape || reNoMatch).source + '|' +\n interpolate.source + '|' +\n (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +\n (options.evaluate || reNoMatch).source + '|$'\n , 'g');\n\n // Use a sourceURL for easier debugging.\n var sourceURL = '//# sourceURL=' +\n ('sourceURL' in options\n ? options.sourceURL\n : ('lodash.templateSources[' + (++templateCounter) + ']')\n ) + '\\n';\n\n string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {\n interpolateValue || (interpolateValue = esTemplateValue);\n\n // Escape characters that can't be included in string literals.\n source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);\n\n // Replace delimiters with snippets.\n if (escapeValue) {\n isEscaping = true;\n source += \"' +\\n__e(\" + escapeValue + \") +\\n'\";\n }\n if (evaluateValue) {\n isEvaluating = true;\n source += \"';\\n\" + evaluateValue + \";\\n__p += '\";\n }\n if (interpolateValue) {\n source += \"' +\\n((__t = (\" + interpolateValue + \")) == null ? '' : __t) +\\n'\";\n }\n index = offset + match.length;\n\n // The JS engine embedded in Adobe products needs `match` returned in\n // order to produce the correct `offset` value.\n return match;\n });\n\n source += \"';\\n\";\n\n // If `variable` is not specified wrap a with-statement around the generated\n // code to add the data object to the top of the scope chain.\n var variable = options.variable;\n if (!variable) {\n source = 'with (obj) {\\n' + source + '\\n}\\n';\n }\n // Cleanup code by stripping empty strings.\n source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)\n .replace(reEmptyStringMiddle, '$1')\n .replace(reEmptyStringTrailing, '$1;');\n\n // Frame code as the function body.\n source = 'function(' + (variable || 'obj') + ') {\\n' +\n (variable\n ? ''\n : 'obj || (obj = {});\\n'\n ) +\n \"var __t, __p = ''\" +\n (isEscaping\n ? ', __e = _.escape'\n : ''\n ) +\n (isEvaluating\n ? ', __j = Array.prototype.join;\\n' +\n \"function print() { __p += __j.call(arguments, '') }\\n\"\n : ';\\n'\n ) +\n source +\n 'return __p\\n}';\n\n var result = attempt(function() {\n return Function(importsKeys, sourceURL + 'return ' + source)\n .apply(undefined, importsValues);\n });\n\n // Provide the compiled function's source by its `toString` method or\n // the `source` property as a convenience for inlining compiled templates.\n result.source = source;\n if (isError(result)) {\n throw result;\n }\n return result;\n }\n\n /**\n * Converts `string`, as a whole, to lower case just like\n * [String#toLowerCase](https://mdn.io/toLowerCase).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the lower cased string.\n * @example\n *\n * _.toLower('--Foo-Bar--');\n * // => '--foo-bar--'\n *\n * _.toLower('fooBar');\n * // => 'foobar'\n *\n * _.toLower('__FOO_BAR__');\n * // => '__foo_bar__'\n */\n function toLower(value) {\n return toString(value).toLowerCase();\n }\n\n /**\n * Converts `string`, as a whole, to upper case just like\n * [String#toUpperCase](https://mdn.io/toUpperCase).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the upper cased string.\n * @example\n *\n * _.toUpper('--foo-bar--');\n * // => '--FOO-BAR--'\n *\n * _.toUpper('fooBar');\n * // => 'FOOBAR'\n *\n * _.toUpper('__foo_bar__');\n * // => '__FOO_BAR__'\n */\n function toUpper(value) {\n return toString(value).toUpperCase();\n }\n\n /**\n * Removes leading and trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trim(' abc ');\n * // => 'abc'\n *\n * _.trim('-_-abc-_-', '_-');\n * // => 'abc'\n *\n * _.map([' foo ', ' bar '], _.trim);\n * // => ['foo', 'bar']\n */\n function trim(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return string.replace(reTrim, '');\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n chrSymbols = stringToArray(chars),\n start = charsStartIndex(strSymbols, chrSymbols),\n end = charsEndIndex(strSymbols, chrSymbols) + 1;\n\n return castSlice(strSymbols, start, end).join('');\n }\n\n /**\n * Removes trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trimEnd(' abc ');\n * // => ' abc'\n *\n * _.trimEnd('-_-abc-_-', '_-');\n * // => '-_-abc'\n */\n function trimEnd(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return string.replace(reTrimEnd, '');\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;\n\n return castSlice(strSymbols, 0, end).join('');\n }\n\n /**\n * Removes leading whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trimStart(' abc ');\n * // => 'abc '\n *\n * _.trimStart('-_-abc-_-', '_-');\n * // => 'abc-_-'\n */\n function trimStart(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return string.replace(reTrimStart, '');\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n start = charsStartIndex(strSymbols, stringToArray(chars));\n\n return castSlice(strSymbols, start).join('');\n }\n\n /**\n * Truncates `string` if it's longer than the given maximum string length.\n * The last characters of the truncated string are replaced with the omission\n * string which defaults to \"...\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to truncate.\n * @param {Object} [options={}] The options object.\n * @param {number} [options.length=30] The maximum string length.\n * @param {string} [options.omission='...'] The string to indicate text is omitted.\n * @param {RegExp|string} [options.separator] The separator pattern to truncate to.\n * @returns {string} Returns the truncated string.\n * @example\n *\n * _.truncate('hi-diddly-ho there, neighborino');\n * // => 'hi-diddly-ho there, neighbo...'\n *\n * _.truncate('hi-diddly-ho there, neighborino', {\n * 'length': 24,\n * 'separator': ' '\n * });\n * // => 'hi-diddly-ho there,...'\n *\n * _.truncate('hi-diddly-ho there, neighborino', {\n * 'length': 24,\n * 'separator': /,? +/\n * });\n * // => 'hi-diddly-ho there...'\n *\n * _.truncate('hi-diddly-ho there, neighborino', {\n * 'omission': ' [...]'\n * });\n * // => 'hi-diddly-ho there, neig [...]'\n */\n function truncate(string, options) {\n var length = DEFAULT_TRUNC_LENGTH,\n omission = DEFAULT_TRUNC_OMISSION;\n\n if (isObject(options)) {\n var separator = 'separator' in options ? options.separator : separator;\n length = 'length' in options ? toInteger(options.length) : length;\n omission = 'omission' in options ? baseToString(options.omission) : omission;\n }\n string = toString(string);\n\n var strLength = string.length;\n if (hasUnicode(string)) {\n var strSymbols = stringToArray(string);\n strLength = strSymbols.length;\n }\n if (length >= strLength) {\n return string;\n }\n var end = length - stringSize(omission);\n if (end < 1) {\n return omission;\n }\n var result = strSymbols\n ? castSlice(strSymbols, 0, end).join('')\n : string.slice(0, end);\n\n if (separator === undefined) {\n return result + omission;\n }\n if (strSymbols) {\n end += (result.length - end);\n }\n if (isRegExp(separator)) {\n if (string.slice(end).search(separator)) {\n var match,\n substring = result;\n\n if (!separator.global) {\n separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');\n }\n separator.lastIndex = 0;\n while ((match = separator.exec(substring))) {\n var newEnd = match.index;\n }\n result = result.slice(0, newEnd === undefined ? end : newEnd);\n }\n } else if (string.indexOf(baseToString(separator), end) != end) {\n var index = result.lastIndexOf(separator);\n if (index > -1) {\n result = result.slice(0, index);\n }\n }\n return result + omission;\n }\n\n /**\n * The inverse of `_.escape`; this method converts the HTML entities\n * `&`, `<`, `>`, `"`, and `'` in `string` to\n * their corresponding characters.\n *\n * **Note:** No other HTML entities are unescaped. To unescape additional\n * HTML entities use a third-party library like [_he_](https://mths.be/he).\n *\n * @static\n * @memberOf _\n * @since 0.6.0\n * @category String\n * @param {string} [string=''] The string to unescape.\n * @returns {string} Returns the unescaped string.\n * @example\n *\n * _.unescape('fred, barney, & pebbles');\n * // => 'fred, barney, & pebbles'\n */\n function unescape(string) {\n string = toString(string);\n return (string && reHasEscapedHtml.test(string))\n ? string.replace(reEscapedHtml, unescapeHtmlChar)\n : string;\n }\n\n /**\n * Converts `string`, as space separated words, to upper case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the upper cased string.\n * @example\n *\n * _.upperCase('--foo-bar');\n * // => 'FOO BAR'\n *\n * _.upperCase('fooBar');\n * // => 'FOO BAR'\n *\n * _.upperCase('__foo_bar__');\n * // => 'FOO BAR'\n */\n var upperCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + word.toUpperCase();\n });\n\n /**\n * Converts the first character of `string` to upper case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.upperFirst('fred');\n * // => 'Fred'\n *\n * _.upperFirst('FRED');\n * // => 'FRED'\n */\n var upperFirst = createCaseFirst('toUpperCase');\n\n /**\n * Splits `string` into an array of its words.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {RegExp|string} [pattern] The pattern to match words.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the words of `string`.\n * @example\n *\n * _.words('fred, barney, & pebbles');\n * // => ['fred', 'barney', 'pebbles']\n *\n * _.words('fred, barney, & pebbles', /[^, ]+/g);\n * // => ['fred', 'barney', '&', 'pebbles']\n */\n function words(string, pattern, guard) {\n string = toString(string);\n pattern = guard ? undefined : pattern;\n\n if (pattern === undefined) {\n return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);\n }\n return string.match(pattern) || [];\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Attempts to invoke `func`, returning either the result or the caught error\n * object. Any additional arguments are provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Function} func The function to attempt.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {*} Returns the `func` result or error object.\n * @example\n *\n * // Avoid throwing errors for invalid selectors.\n * var elements = _.attempt(function(selector) {\n * return document.querySelectorAll(selector);\n * }, '>_>');\n *\n * if (_.isError(elements)) {\n * elements = [];\n * }\n */\n var attempt = baseRest(function(func, args) {\n try {\n return apply(func, undefined, args);\n } catch (e) {\n return isError(e) ? e : new Error(e);\n }\n });\n\n /**\n * Binds methods of an object to the object itself, overwriting the existing\n * method.\n *\n * **Note:** This method doesn't set the \"length\" property of bound functions.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {Object} object The object to bind and assign the bound methods to.\n * @param {...(string|string[])} methodNames The object method names to bind.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var view = {\n * 'label': 'docs',\n * 'click': function() {\n * console.log('clicked ' + this.label);\n * }\n * };\n *\n * _.bindAll(view, ['click']);\n * jQuery(element).on('click', view.click);\n * // => Logs 'clicked docs' when clicked.\n */\n var bindAll = flatRest(function(object, methodNames) {\n arrayEach(methodNames, function(key) {\n key = toKey(key);\n baseAssignValue(object, key, bind(object[key], object));\n });\n return object;\n });\n\n /**\n * Creates a function that iterates over `pairs` and invokes the corresponding\n * function of the first predicate to return truthy. The predicate-function\n * pairs are invoked with the `this` binding and arguments of the created\n * function.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {Array} pairs The predicate-function pairs.\n * @returns {Function} Returns the new composite function.\n * @example\n *\n * var func = _.cond([\n * [_.matches({ 'a': 1 }), _.constant('matches A')],\n * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],\n * [_.stubTrue, _.constant('no match')]\n * ]);\n *\n * func({ 'a': 1, 'b': 2 });\n * // => 'matches A'\n *\n * func({ 'a': 0, 'b': 1 });\n * // => 'matches B'\n *\n * func({ 'a': '1', 'b': '2' });\n * // => 'no match'\n */\n function cond(pairs) {\n var length = pairs == null ? 0 : pairs.length,\n toIteratee = getIteratee();\n\n pairs = !length ? [] : arrayMap(pairs, function(pair) {\n if (typeof pair[1] != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return [toIteratee(pair[0]), pair[1]];\n });\n\n return baseRest(function(args) {\n var index = -1;\n while (++index < length) {\n var pair = pairs[index];\n if (apply(pair[0], this, args)) {\n return apply(pair[1], this, args);\n }\n }\n });\n }\n\n /**\n * Creates a function that invokes the predicate properties of `source` with\n * the corresponding property values of a given object, returning `true` if\n * all predicates return truthy, else `false`.\n *\n * **Note:** The created function is equivalent to `_.conformsTo` with\n * `source` partially applied.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {Object} source The object of property predicates to conform to.\n * @returns {Function} Returns the new spec function.\n * @example\n *\n * var objects = [\n * { 'a': 2, 'b': 1 },\n * { 'a': 1, 'b': 2 }\n * ];\n *\n * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));\n * // => [{ 'a': 1, 'b': 2 }]\n */\n function conforms(source) {\n return baseConforms(baseClone(source, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new constant function.\n * @example\n *\n * var objects = _.times(2, _.constant({ 'a': 1 }));\n *\n * console.log(objects);\n * // => [{ 'a': 1 }, { 'a': 1 }]\n *\n * console.log(objects[0] === objects[1]);\n * // => true\n */\n function constant(value) {\n return function() {\n return value;\n };\n }\n\n /**\n * Checks `value` to determine whether a default value should be returned in\n * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,\n * or `undefined`.\n *\n * @static\n * @memberOf _\n * @since 4.14.0\n * @category Util\n * @param {*} value The value to check.\n * @param {*} defaultValue The default value.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * _.defaultTo(1, 10);\n * // => 1\n *\n * _.defaultTo(undefined, 10);\n * // => 10\n */\n function defaultTo(value, defaultValue) {\n return (value == null || value !== value) ? defaultValue : value;\n }\n\n /**\n * Creates a function that returns the result of invoking the given functions\n * with the `this` binding of the created function, where each successive\n * invocation is supplied the return value of the previous.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {...(Function|Function[])} [funcs] The functions to invoke.\n * @returns {Function} Returns the new composite function.\n * @see _.flowRight\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var addSquare = _.flow([_.add, square]);\n * addSquare(1, 2);\n * // => 9\n */\n var flow = createFlow();\n\n /**\n * This method is like `_.flow` except that it creates a function that\n * invokes the given functions from right to left.\n *\n * @static\n * @since 3.0.0\n * @memberOf _\n * @category Util\n * @param {...(Function|Function[])} [funcs] The functions to invoke.\n * @returns {Function} Returns the new composite function.\n * @see _.flow\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var addSquare = _.flowRight([square, _.add]);\n * addSquare(1, 2);\n * // => 9\n */\n var flowRight = createFlow(true);\n\n /**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\n function identity(value) {\n return value;\n }\n\n /**\n * Creates a function that invokes `func` with the arguments of the created\n * function. If `func` is a property name, the created function returns the\n * property value for a given element. If `func` is an array or object, the\n * created function returns `true` for elements that contain the equivalent\n * source properties, otherwise it returns `false`.\n *\n * @static\n * @since 4.0.0\n * @memberOf _\n * @category Util\n * @param {*} [func=_.identity] The value to convert to a callback.\n * @returns {Function} Returns the callback.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));\n * // => [{ 'user': 'barney', 'age': 36, 'active': true }]\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.filter(users, _.iteratee(['user', 'fred']));\n * // => [{ 'user': 'fred', 'age': 40 }]\n *\n * // The `_.property` iteratee shorthand.\n * _.map(users, _.iteratee('user'));\n * // => ['barney', 'fred']\n *\n * // Create custom iteratee shorthands.\n * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {\n * return !_.isRegExp(func) ? iteratee(func) : function(string) {\n * return func.test(string);\n * };\n * });\n *\n * _.filter(['abc', 'def'], /ef/);\n * // => ['def']\n */\n function iteratee(func) {\n return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that performs a partial deep comparison between a given\n * object and `source`, returning `true` if the given object has equivalent\n * property values, else `false`.\n *\n * **Note:** The created function is equivalent to `_.isMatch` with `source`\n * partially applied.\n *\n * Partial comparisons will match empty array and empty object `source`\n * values against any array or object value, respectively. See `_.isEqual`\n * for a list of supported value comparisons.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n * @example\n *\n * var objects = [\n * { 'a': 1, 'b': 2, 'c': 3 },\n * { 'a': 4, 'b': 5, 'c': 6 }\n * ];\n *\n * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));\n * // => [{ 'a': 4, 'b': 5, 'c': 6 }]\n */\n function matches(source) {\n return baseMatches(baseClone(source, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that performs a partial deep comparison between the\n * value at `path` of a given object to `srcValue`, returning `true` if the\n * object value is equivalent, else `false`.\n *\n * **Note:** Partial comparisons will match empty array and empty object\n * `srcValue` values against any array or object value, respectively. See\n * `_.isEqual` for a list of supported value comparisons.\n *\n * @static\n * @memberOf _\n * @since 3.2.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n * @example\n *\n * var objects = [\n * { 'a': 1, 'b': 2, 'c': 3 },\n * { 'a': 4, 'b': 5, 'c': 6 }\n * ];\n *\n * _.find(objects, _.matchesProperty('a', 4));\n * // => { 'a': 4, 'b': 5, 'c': 6 }\n */\n function matchesProperty(path, srcValue) {\n return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that invokes the method at `path` of a given object.\n * Any additional arguments are provided to the invoked method.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Util\n * @param {Array|string} path The path of the method to invoke.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Function} Returns the new invoker function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': _.constant(2) } },\n * { 'a': { 'b': _.constant(1) } }\n * ];\n *\n * _.map(objects, _.method('a.b'));\n * // => [2, 1]\n *\n * _.map(objects, _.method(['a', 'b']));\n * // => [2, 1]\n */\n var method = baseRest(function(path, args) {\n return function(object) {\n return baseInvoke(object, path, args);\n };\n });\n\n /**\n * The opposite of `_.method`; this method creates a function that invokes\n * the method at a given path of `object`. Any additional arguments are\n * provided to the invoked method.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Util\n * @param {Object} object The object to query.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Function} Returns the new invoker function.\n * @example\n *\n * var array = _.times(3, _.constant),\n * object = { 'a': array, 'b': array, 'c': array };\n *\n * _.map(['a[2]', 'c[0]'], _.methodOf(object));\n * // => [2, 0]\n *\n * _.map([['a', '2'], ['c', '0']], _.methodOf(object));\n * // => [2, 0]\n */\n var methodOf = baseRest(function(object, args) {\n return function(path) {\n return baseInvoke(object, path, args);\n };\n });\n\n /**\n * Adds all own enumerable string keyed function properties of a source\n * object to the destination object. If `object` is a function, then methods\n * are added to its prototype as well.\n *\n * **Note:** Use `_.runInContext` to create a pristine `lodash` function to\n * avoid conflicts caused by modifying the original.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {Function|Object} [object=lodash] The destination object.\n * @param {Object} source The object of functions to add.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.chain=true] Specify whether mixins are chainable.\n * @returns {Function|Object} Returns `object`.\n * @example\n *\n * function vowels(string) {\n * return _.filter(string, function(v) {\n * return /[aeiou]/i.test(v);\n * });\n * }\n *\n * _.mixin({ 'vowels': vowels });\n * _.vowels('fred');\n * // => ['e']\n *\n * _('fred').vowels().value();\n * // => ['e']\n *\n * _.mixin({ 'vowels': vowels }, { 'chain': false });\n * _('fred').vowels();\n * // => ['e']\n */\n function mixin(object, source, options) {\n var props = keys(source),\n methodNames = baseFunctions(source, props);\n\n if (options == null &&\n !(isObject(source) && (methodNames.length || !props.length))) {\n options = source;\n source = object;\n object = this;\n methodNames = baseFunctions(source, keys(source));\n }\n var chain = !(isObject(options) && 'chain' in options) || !!options.chain,\n isFunc = isFunction(object);\n\n arrayEach(methodNames, function(methodName) {\n var func = source[methodName];\n object[methodName] = func;\n if (isFunc) {\n object.prototype[methodName] = function() {\n var chainAll = this.__chain__;\n if (chain || chainAll) {\n var result = object(this.__wrapped__),\n actions = result.__actions__ = copyArray(this.__actions__);\n\n actions.push({ 'func': func, 'args': arguments, 'thisArg': object });\n result.__chain__ = chainAll;\n return result;\n }\n return func.apply(object, arrayPush([this.value()], arguments));\n };\n }\n });\n\n return object;\n }\n\n /**\n * Reverts the `_` variable to its previous value and returns a reference to\n * the `lodash` function.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @returns {Function} Returns the `lodash` function.\n * @example\n *\n * var lodash = _.noConflict();\n */\n function noConflict() {\n if (root._ === this) {\n root._ = oldDash;\n }\n return this;\n }\n\n /**\n * This method returns `undefined`.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Util\n * @example\n *\n * _.times(2, _.noop);\n * // => [undefined, undefined]\n */\n function noop() {\n // No operation performed.\n }\n\n /**\n * Creates a function that gets the argument at index `n`. If `n` is negative,\n * the nth argument from the end is returned.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {number} [n=0] The index of the argument to return.\n * @returns {Function} Returns the new pass-thru function.\n * @example\n *\n * var func = _.nthArg(1);\n * func('a', 'b', 'c', 'd');\n * // => 'b'\n *\n * var func = _.nthArg(-2);\n * func('a', 'b', 'c', 'd');\n * // => 'c'\n */\n function nthArg(n) {\n n = toInteger(n);\n return baseRest(function(args) {\n return baseNth(args, n);\n });\n }\n\n /**\n * Creates a function that invokes `iteratees` with the arguments it receives\n * and returns their results.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {...(Function|Function[])} [iteratees=[_.identity]]\n * The iteratees to invoke.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var func = _.over([Math.max, Math.min]);\n *\n * func(1, 2, 3, 4);\n * // => [4, 1]\n */\n var over = createOver(arrayMap);\n\n /**\n * Creates a function that checks if **all** of the `predicates` return\n * truthy when invoked with the arguments it receives.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {...(Function|Function[])} [predicates=[_.identity]]\n * The predicates to check.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var func = _.overEvery([Boolean, isFinite]);\n *\n * func('1');\n * // => true\n *\n * func(null);\n * // => false\n *\n * func(NaN);\n * // => false\n */\n var overEvery = createOver(arrayEvery);\n\n /**\n * Creates a function that checks if **any** of the `predicates` return\n * truthy when invoked with the arguments it receives.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {...(Function|Function[])} [predicates=[_.identity]]\n * The predicates to check.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var func = _.overSome([Boolean, isFinite]);\n *\n * func('1');\n * // => true\n *\n * func(null);\n * // => true\n *\n * func(NaN);\n * // => false\n */\n var overSome = createOver(arraySome);\n\n /**\n * Creates a function that returns the value at `path` of a given object.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': 2 } },\n * { 'a': { 'b': 1 } }\n * ];\n *\n * _.map(objects, _.property('a.b'));\n * // => [2, 1]\n *\n * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');\n * // => [1, 2]\n */\n function property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n }\n\n /**\n * The opposite of `_.property`; this method creates a function that returns\n * the value at a given path of `object`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var array = [0, 1, 2],\n * object = { 'a': array, 'b': array, 'c': array };\n *\n * _.map(['a[2]', 'c[0]'], _.propertyOf(object));\n * // => [2, 0]\n *\n * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));\n * // => [2, 0]\n */\n function propertyOf(object) {\n return function(path) {\n return object == null ? undefined : baseGet(object, path);\n };\n }\n\n /**\n * Creates an array of numbers (positive and/or negative) progressing from\n * `start` up to, but not including, `end`. A step of `-1` is used if a negative\n * `start` is specified without an `end` or `step`. If `end` is not specified,\n * it's set to `start` with `start` then set to `0`.\n *\n * **Note:** JavaScript follows the IEEE-754 standard for resolving\n * floating-point values which can produce unexpected results.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @param {number} [step=1] The value to increment or decrement by.\n * @returns {Array} Returns the range of numbers.\n * @see _.inRange, _.rangeRight\n * @example\n *\n * _.range(4);\n * // => [0, 1, 2, 3]\n *\n * _.range(-4);\n * // => [0, -1, -2, -3]\n *\n * _.range(1, 5);\n * // => [1, 2, 3, 4]\n *\n * _.range(0, 20, 5);\n * // => [0, 5, 10, 15]\n *\n * _.range(0, -4, -1);\n * // => [0, -1, -2, -3]\n *\n * _.range(1, 4, 0);\n * // => [1, 1, 1]\n *\n * _.range(0);\n * // => []\n */\n var range = createRange();\n\n /**\n * This method is like `_.range` except that it populates values in\n * descending order.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @param {number} [step=1] The value to increment or decrement by.\n * @returns {Array} Returns the range of numbers.\n * @see _.inRange, _.range\n * @example\n *\n * _.rangeRight(4);\n * // => [3, 2, 1, 0]\n *\n * _.rangeRight(-4);\n * // => [-3, -2, -1, 0]\n *\n * _.rangeRight(1, 5);\n * // => [4, 3, 2, 1]\n *\n * _.rangeRight(0, 20, 5);\n * // => [15, 10, 5, 0]\n *\n * _.rangeRight(0, -4, -1);\n * // => [-3, -2, -1, 0]\n *\n * _.rangeRight(1, 4, 0);\n * // => [1, 1, 1]\n *\n * _.rangeRight(0);\n * // => []\n */\n var rangeRight = createRange(true);\n\n /**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\n function stubArray() {\n return [];\n }\n\n /**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\n function stubFalse() {\n return false;\n }\n\n /**\n * This method returns a new empty object.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Object} Returns the new empty object.\n * @example\n *\n * var objects = _.times(2, _.stubObject);\n *\n * console.log(objects);\n * // => [{}, {}]\n *\n * console.log(objects[0] === objects[1]);\n * // => false\n */\n function stubObject() {\n return {};\n }\n\n /**\n * This method returns an empty string.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {string} Returns the empty string.\n * @example\n *\n * _.times(2, _.stubString);\n * // => ['', '']\n */\n function stubString() {\n return '';\n }\n\n /**\n * This method returns `true`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `true`.\n * @example\n *\n * _.times(2, _.stubTrue);\n * // => [true, true]\n */\n function stubTrue() {\n return true;\n }\n\n /**\n * Invokes the iteratee `n` times, returning an array of the results of\n * each invocation. The iteratee is invoked with one argument; (index).\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n * @example\n *\n * _.times(3, String);\n * // => ['0', '1', '2']\n *\n * _.times(4, _.constant(0));\n * // => [0, 0, 0, 0]\n */\n function times(n, iteratee) {\n n = toInteger(n);\n if (n < 1 || n > MAX_SAFE_INTEGER) {\n return [];\n }\n var index = MAX_ARRAY_LENGTH,\n length = nativeMin(n, MAX_ARRAY_LENGTH);\n\n iteratee = getIteratee(iteratee);\n n -= MAX_ARRAY_LENGTH;\n\n var result = baseTimes(length, iteratee);\n while (++index < n) {\n iteratee(index);\n }\n return result;\n }\n\n /**\n * Converts `value` to a property path array.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {*} value The value to convert.\n * @returns {Array} Returns the new property path array.\n * @example\n *\n * _.toPath('a.b.c');\n * // => ['a', 'b', 'c']\n *\n * _.toPath('a[0].b.c');\n * // => ['a', '0', 'b', 'c']\n */\n function toPath(value) {\n if (isArray(value)) {\n return arrayMap(value, toKey);\n }\n return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));\n }\n\n /**\n * Generates a unique ID. If `prefix` is given, the ID is appended to it.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {string} [prefix=''] The value to prefix the ID with.\n * @returns {string} Returns the unique ID.\n * @example\n *\n * _.uniqueId('contact_');\n * // => 'contact_104'\n *\n * _.uniqueId();\n * // => '105'\n */\n function uniqueId(prefix) {\n var id = ++idCounter;\n return toString(prefix) + id;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Adds two numbers.\n *\n * @static\n * @memberOf _\n * @since 3.4.0\n * @category Math\n * @param {number} augend The first number in an addition.\n * @param {number} addend The second number in an addition.\n * @returns {number} Returns the total.\n * @example\n *\n * _.add(6, 4);\n * // => 10\n */\n var add = createMathOperation(function(augend, addend) {\n return augend + addend;\n }, 0);\n\n /**\n * Computes `number` rounded up to `precision`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Math\n * @param {number} number The number to round up.\n * @param {number} [precision=0] The precision to round up to.\n * @returns {number} Returns the rounded up number.\n * @example\n *\n * _.ceil(4.006);\n * // => 5\n *\n * _.ceil(6.004, 2);\n * // => 6.01\n *\n * _.ceil(6040, -2);\n * // => 6100\n */\n var ceil = createRound('ceil');\n\n /**\n * Divide two numbers.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Math\n * @param {number} dividend The first number in a division.\n * @param {number} divisor The second number in a division.\n * @returns {number} Returns the quotient.\n * @example\n *\n * _.divide(6, 4);\n * // => 1.5\n */\n var divide = createMathOperation(function(dividend, divisor) {\n return dividend / divisor;\n }, 1);\n\n /**\n * Computes `number` rounded down to `precision`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Math\n * @param {number} number The number to round down.\n * @param {number} [precision=0] The precision to round down to.\n * @returns {number} Returns the rounded down number.\n * @example\n *\n * _.floor(4.006);\n * // => 4\n *\n * _.floor(0.046, 2);\n * // => 0.04\n *\n * _.floor(4060, -2);\n * // => 4000\n */\n var floor = createRound('floor');\n\n /**\n * Computes the maximum value of `array`. If `array` is empty or falsey,\n * `undefined` is returned.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {*} Returns the maximum value.\n * @example\n *\n * _.max([4, 2, 8, 6]);\n * // => 8\n *\n * _.max([]);\n * // => undefined\n */\n function max(array) {\n return (array && array.length)\n ? baseExtremum(array, identity, baseGt)\n : undefined;\n }\n\n /**\n * This method is like `_.max` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * the value is ranked. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {*} Returns the maximum value.\n * @example\n *\n * var objects = [{ 'n': 1 }, { 'n': 2 }];\n *\n * _.maxBy(objects, function(o) { return o.n; });\n * // => { 'n': 2 }\n *\n * // The `_.property` iteratee shorthand.\n * _.maxBy(objects, 'n');\n * // => { 'n': 2 }\n */\n function maxBy(array, iteratee) {\n return (array && array.length)\n ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)\n : undefined;\n }\n\n /**\n * Computes the mean of the values in `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {number} Returns the mean.\n * @example\n *\n * _.mean([4, 2, 8, 6]);\n * // => 5\n */\n function mean(array) {\n return baseMean(array, identity);\n }\n\n /**\n * This method is like `_.mean` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the value to be averaged.\n * The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the mean.\n * @example\n *\n * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];\n *\n * _.meanBy(objects, function(o) { return o.n; });\n * // => 5\n *\n * // The `_.property` iteratee shorthand.\n * _.meanBy(objects, 'n');\n * // => 5\n */\n function meanBy(array, iteratee) {\n return baseMean(array, getIteratee(iteratee, 2));\n }\n\n /**\n * Computes the minimum value of `array`. If `array` is empty or falsey,\n * `undefined` is returned.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {*} Returns the minimum value.\n * @example\n *\n * _.min([4, 2, 8, 6]);\n * // => 2\n *\n * _.min([]);\n * // => undefined\n */\n function min(array) {\n return (array && array.length)\n ? baseExtremum(array, identity, baseLt)\n : undefined;\n }\n\n /**\n * This method is like `_.min` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * the value is ranked. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {*} Returns the minimum value.\n * @example\n *\n * var objects = [{ 'n': 1 }, { 'n': 2 }];\n *\n * _.minBy(objects, function(o) { return o.n; });\n * // => { 'n': 1 }\n *\n * // The `_.property` iteratee shorthand.\n * _.minBy(objects, 'n');\n * // => { 'n': 1 }\n */\n function minBy(array, iteratee) {\n return (array && array.length)\n ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)\n : undefined;\n }\n\n /**\n * Multiply two numbers.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Math\n * @param {number} multiplier The first number in a multiplication.\n * @param {number} multiplicand The second number in a multiplication.\n * @returns {number} Returns the product.\n * @example\n *\n * _.multiply(6, 4);\n * // => 24\n */\n var multiply = createMathOperation(function(multiplier, multiplicand) {\n return multiplier * multiplicand;\n }, 1);\n\n /**\n * Computes `number` rounded to `precision`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Math\n * @param {number} number The number to round.\n * @param {number} [precision=0] The precision to round to.\n * @returns {number} Returns the rounded number.\n * @example\n *\n * _.round(4.006);\n * // => 4\n *\n * _.round(4.006, 2);\n * // => 4.01\n *\n * _.round(4060, -2);\n * // => 4100\n */\n var round = createRound('round');\n\n /**\n * Subtract two numbers.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {number} minuend The first number in a subtraction.\n * @param {number} subtrahend The second number in a subtraction.\n * @returns {number} Returns the difference.\n * @example\n *\n * _.subtract(6, 4);\n * // => 2\n */\n var subtract = createMathOperation(function(minuend, subtrahend) {\n return minuend - subtrahend;\n }, 0);\n\n /**\n * Computes the sum of the values in `array`.\n *\n * @static\n * @memberOf _\n * @since 3.4.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {number} Returns the sum.\n * @example\n *\n * _.sum([4, 2, 8, 6]);\n * // => 20\n */\n function sum(array) {\n return (array && array.length)\n ? baseSum(array, identity)\n : 0;\n }\n\n /**\n * This method is like `_.sum` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the value to be summed.\n * The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the sum.\n * @example\n *\n * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];\n *\n * _.sumBy(objects, function(o) { return o.n; });\n * // => 20\n *\n * // The `_.property` iteratee shorthand.\n * _.sumBy(objects, 'n');\n * // => 20\n */\n function sumBy(array, iteratee) {\n return (array && array.length)\n ? baseSum(array, getIteratee(iteratee, 2))\n : 0;\n }\n\n /*------------------------------------------------------------------------*/\n\n // Add methods that return wrapped values in chain sequences.\n lodash.after = after;\n lodash.ary = ary;\n lodash.assign = assign;\n lodash.assignIn = assignIn;\n lodash.assignInWith = assignInWith;\n lodash.assignWith = assignWith;\n lodash.at = at;\n lodash.before = before;\n lodash.bind = bind;\n lodash.bindAll = bindAll;\n lodash.bindKey = bindKey;\n lodash.castArray = castArray;\n lodash.chain = chain;\n lodash.chunk = chunk;\n lodash.compact = compact;\n lodash.concat = concat;\n lodash.cond = cond;\n lodash.conforms = conforms;\n lodash.constant = constant;\n lodash.countBy = countBy;\n lodash.create = create;\n lodash.curry = curry;\n lodash.curryRight = curryRight;\n lodash.debounce = debounce;\n lodash.defaults = defaults;\n lodash.defaultsDeep = defaultsDeep;\n lodash.defer = defer;\n lodash.delay = delay;\n lodash.difference = difference;\n lodash.differenceBy = differenceBy;\n lodash.differenceWith = differenceWith;\n lodash.drop = drop;\n lodash.dropRight = dropRight;\n lodash.dropRightWhile = dropRightWhile;\n lodash.dropWhile = dropWhile;\n lodash.fill = fill;\n lodash.filter = filter;\n lodash.flatMap = flatMap;\n lodash.flatMapDeep = flatMapDeep;\n lodash.flatMapDepth = flatMapDepth;\n lodash.flatten = flatten;\n lodash.flattenDeep = flattenDeep;\n lodash.flattenDepth = flattenDepth;\n lodash.flip = flip;\n lodash.flow = flow;\n lodash.flowRight = flowRight;\n lodash.fromPairs = fromPairs;\n lodash.functions = functions;\n lodash.functionsIn = functionsIn;\n lodash.groupBy = groupBy;\n lodash.initial = initial;\n lodash.intersection = intersection;\n lodash.intersectionBy = intersectionBy;\n lodash.intersectionWith = intersectionWith;\n lodash.invert = invert;\n lodash.invertBy = invertBy;\n lodash.invokeMap = invokeMap;\n lodash.iteratee = iteratee;\n lodash.keyBy = keyBy;\n lodash.keys = keys;\n lodash.keysIn = keysIn;\n lodash.map = map;\n lodash.mapKeys = mapKeys;\n lodash.mapValues = mapValues;\n lodash.matches = matches;\n lodash.matchesProperty = matchesProperty;\n lodash.memoize = memoize;\n lodash.merge = merge;\n lodash.mergeWith = mergeWith;\n lodash.method = method;\n lodash.methodOf = methodOf;\n lodash.mixin = mixin;\n lodash.negate = negate;\n lodash.nthArg = nthArg;\n lodash.omit = omit;\n lodash.omitBy = omitBy;\n lodash.once = once;\n lodash.orderBy = orderBy;\n lodash.over = over;\n lodash.overArgs = overArgs;\n lodash.overEvery = overEvery;\n lodash.overSome = overSome;\n lodash.partial = partial;\n lodash.partialRight = partialRight;\n lodash.partition = partition;\n lodash.pick = pick;\n lodash.pickBy = pickBy;\n lodash.property = property;\n lodash.propertyOf = propertyOf;\n lodash.pull = pull;\n lodash.pullAll = pullAll;\n lodash.pullAllBy = pullAllBy;\n lodash.pullAllWith = pullAllWith;\n lodash.pullAt = pullAt;\n lodash.range = range;\n lodash.rangeRight = rangeRight;\n lodash.rearg = rearg;\n lodash.reject = reject;\n lodash.remove = remove;\n lodash.rest = rest;\n lodash.reverse = reverse;\n lodash.sampleSize = sampleSize;\n lodash.set = set;\n lodash.setWith = setWith;\n lodash.shuffle = shuffle;\n lodash.slice = slice;\n lodash.sortBy = sortBy;\n lodash.sortedUniq = sortedUniq;\n lodash.sortedUniqBy = sortedUniqBy;\n lodash.split = split;\n lodash.spread = spread;\n lodash.tail = tail;\n lodash.take = take;\n lodash.takeRight = takeRight;\n lodash.takeRightWhile = takeRightWhile;\n lodash.takeWhile = takeWhile;\n lodash.tap = tap;\n lodash.throttle = throttle;\n lodash.thru = thru;\n lodash.toArray = toArray;\n lodash.toPairs = toPairs;\n lodash.toPairsIn = toPairsIn;\n lodash.toPath = toPath;\n lodash.toPlainObject = toPlainObject;\n lodash.transform = transform;\n lodash.unary = unary;\n lodash.union = union;\n lodash.unionBy = unionBy;\n lodash.unionWith = unionWith;\n lodash.uniq = uniq;\n lodash.uniqBy = uniqBy;\n lodash.uniqWith = uniqWith;\n lodash.unset = unset;\n lodash.unzip = unzip;\n lodash.unzipWith = unzipWith;\n lodash.update = update;\n lodash.updateWith = updateWith;\n lodash.values = values;\n lodash.valuesIn = valuesIn;\n lodash.without = without;\n lodash.words = words;\n lodash.wrap = wrap;\n lodash.xor = xor;\n lodash.xorBy = xorBy;\n lodash.xorWith = xorWith;\n lodash.zip = zip;\n lodash.zipObject = zipObject;\n lodash.zipObjectDeep = zipObjectDeep;\n lodash.zipWith = zipWith;\n\n // Add aliases.\n lodash.entries = toPairs;\n lodash.entriesIn = toPairsIn;\n lodash.extend = assignIn;\n lodash.extendWith = assignInWith;\n\n // Add methods to `lodash.prototype`.\n mixin(lodash, lodash);\n\n /*------------------------------------------------------------------------*/\n\n // Add methods that return unwrapped values in chain sequences.\n lodash.add = add;\n lodash.attempt = attempt;\n lodash.camelCase = camelCase;\n lodash.capitalize = capitalize;\n lodash.ceil = ceil;\n lodash.clamp = clamp;\n lodash.clone = clone;\n lodash.cloneDeep = cloneDeep;\n lodash.cloneDeepWith = cloneDeepWith;\n lodash.cloneWith = cloneWith;\n lodash.conformsTo = conformsTo;\n lodash.deburr = deburr;\n lodash.defaultTo = defaultTo;\n lodash.divide = divide;\n lodash.endsWith = endsWith;\n lodash.eq = eq;\n lodash.escape = escape;\n lodash.escapeRegExp = escapeRegExp;\n lodash.every = every;\n lodash.find = find;\n lodash.findIndex = findIndex;\n lodash.findKey = findKey;\n lodash.findLast = findLast;\n lodash.findLastIndex = findLastIndex;\n lodash.findLastKey = findLastKey;\n lodash.floor = floor;\n lodash.forEach = forEach;\n lodash.forEachRight = forEachRight;\n lodash.forIn = forIn;\n lodash.forInRight = forInRight;\n lodash.forOwn = forOwn;\n lodash.forOwnRight = forOwnRight;\n lodash.get = get;\n lodash.gt = gt;\n lodash.gte = gte;\n lodash.has = has;\n lodash.hasIn = hasIn;\n lodash.head = head;\n lodash.identity = identity;\n lodash.includes = includes;\n lodash.indexOf = indexOf;\n lodash.inRange = inRange;\n lodash.invoke = invoke;\n lodash.isArguments = isArguments;\n lodash.isArray = isArray;\n lodash.isArrayBuffer = isArrayBuffer;\n lodash.isArrayLike = isArrayLike;\n lodash.isArrayLikeObject = isArrayLikeObject;\n lodash.isBoolean = isBoolean;\n lodash.isBuffer = isBuffer;\n lodash.isDate = isDate;\n lodash.isElement = isElement;\n lodash.isEmpty = isEmpty;\n lodash.isEqual = isEqual;\n lodash.isEqualWith = isEqualWith;\n lodash.isError = isError;\n lodash.isFinite = isFinite;\n lodash.isFunction = isFunction;\n lodash.isInteger = isInteger;\n lodash.isLength = isLength;\n lodash.isMap = isMap;\n lodash.isMatch = isMatch;\n lodash.isMatchWith = isMatchWith;\n lodash.isNaN = isNaN;\n lodash.isNative = isNative;\n lodash.isNil = isNil;\n lodash.isNull = isNull;\n lodash.isNumber = isNumber;\n lodash.isObject = isObject;\n lodash.isObjectLike = isObjectLike;\n lodash.isPlainObject = isPlainObject;\n lodash.isRegExp = isRegExp;\n lodash.isSafeInteger = isSafeInteger;\n lodash.isSet = isSet;\n lodash.isString = isString;\n lodash.isSymbol = isSymbol;\n lodash.isTypedArray = isTypedArray;\n lodash.isUndefined = isUndefined;\n lodash.isWeakMap = isWeakMap;\n lodash.isWeakSet = isWeakSet;\n lodash.join = join;\n lodash.kebabCase = kebabCase;\n lodash.last = last;\n lodash.lastIndexOf = lastIndexOf;\n lodash.lowerCase = lowerCase;\n lodash.lowerFirst = lowerFirst;\n lodash.lt = lt;\n lodash.lte = lte;\n lodash.max = max;\n lodash.maxBy = maxBy;\n lodash.mean = mean;\n lodash.meanBy = meanBy;\n lodash.min = min;\n lodash.minBy = minBy;\n lodash.stubArray = stubArray;\n lodash.stubFalse = stubFalse;\n lodash.stubObject = stubObject;\n lodash.stubString = stubString;\n lodash.stubTrue = stubTrue;\n lodash.multiply = multiply;\n lodash.nth = nth;\n lodash.noConflict = noConflict;\n lodash.noop = noop;\n lodash.now = now;\n lodash.pad = pad;\n lodash.padEnd = padEnd;\n lodash.padStart = padStart;\n lodash.parseInt = parseInt;\n lodash.random = random;\n lodash.reduce = reduce;\n lodash.reduceRight = reduceRight;\n lodash.repeat = repeat;\n lodash.replace = replace;\n lodash.result = result;\n lodash.round = round;\n lodash.runInContext = runInContext;\n lodash.sample = sample;\n lodash.size = size;\n lodash.snakeCase = snakeCase;\n lodash.some = some;\n lodash.sortedIndex = sortedIndex;\n lodash.sortedIndexBy = sortedIndexBy;\n lodash.sortedIndexOf = sortedIndexOf;\n lodash.sortedLastIndex = sortedLastIndex;\n lodash.sortedLastIndexBy = sortedLastIndexBy;\n lodash.sortedLastIndexOf = sortedLastIndexOf;\n lodash.startCase = startCase;\n lodash.startsWith = startsWith;\n lodash.subtract = subtract;\n lodash.sum = sum;\n lodash.sumBy = sumBy;\n lodash.template = template;\n lodash.times = times;\n lodash.toFinite = toFinite;\n lodash.toInteger = toInteger;\n lodash.toLength = toLength;\n lodash.toLower = toLower;\n lodash.toNumber = toNumber;\n lodash.toSafeInteger = toSafeInteger;\n lodash.toString = toString;\n lodash.toUpper = toUpper;\n lodash.trim = trim;\n lodash.trimEnd = trimEnd;\n lodash.trimStart = trimStart;\n lodash.truncate = truncate;\n lodash.unescape = unescape;\n lodash.uniqueId = uniqueId;\n lodash.upperCase = upperCase;\n lodash.upperFirst = upperFirst;\n\n // Add aliases.\n lodash.each = forEach;\n lodash.eachRight = forEachRight;\n lodash.first = head;\n\n mixin(lodash, (function() {\n var source = {};\n baseForOwn(lodash, function(func, methodName) {\n if (!hasOwnProperty.call(lodash.prototype, methodName)) {\n source[methodName] = func;\n }\n });\n return source;\n }()), { 'chain': false });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The semantic version number.\n *\n * @static\n * @memberOf _\n * @type {string}\n */\n lodash.VERSION = VERSION;\n\n // Assign default placeholders.\n arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {\n lodash[methodName].placeholder = lodash;\n });\n\n // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.\n arrayEach(['drop', 'take'], function(methodName, index) {\n LazyWrapper.prototype[methodName] = function(n) {\n n = n === undefined ? 1 : nativeMax(toInteger(n), 0);\n\n var result = (this.__filtered__ && !index)\n ? new LazyWrapper(this)\n : this.clone();\n\n if (result.__filtered__) {\n result.__takeCount__ = nativeMin(n, result.__takeCount__);\n } else {\n result.__views__.push({\n 'size': nativeMin(n, MAX_ARRAY_LENGTH),\n 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')\n });\n }\n return result;\n };\n\n LazyWrapper.prototype[methodName + 'Right'] = function(n) {\n return this.reverse()[methodName](n).reverse();\n };\n });\n\n // Add `LazyWrapper` methods that accept an `iteratee` value.\n arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {\n var type = index + 1,\n isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;\n\n LazyWrapper.prototype[methodName] = function(iteratee) {\n var result = this.clone();\n result.__iteratees__.push({\n 'iteratee': getIteratee(iteratee, 3),\n 'type': type\n });\n result.__filtered__ = result.__filtered__ || isFilter;\n return result;\n };\n });\n\n // Add `LazyWrapper` methods for `_.head` and `_.last`.\n arrayEach(['head', 'last'], function(methodName, index) {\n var takeName = 'take' + (index ? 'Right' : '');\n\n LazyWrapper.prototype[methodName] = function() {\n return this[takeName](1).value()[0];\n };\n });\n\n // Add `LazyWrapper` methods for `_.initial` and `_.tail`.\n arrayEach(['initial', 'tail'], function(methodName, index) {\n var dropName = 'drop' + (index ? '' : 'Right');\n\n LazyWrapper.prototype[methodName] = function() {\n return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);\n };\n });\n\n LazyWrapper.prototype.compact = function() {\n return this.filter(identity);\n };\n\n LazyWrapper.prototype.find = function(predicate) {\n return this.filter(predicate).head();\n };\n\n LazyWrapper.prototype.findLast = function(predicate) {\n return this.reverse().find(predicate);\n };\n\n LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {\n if (typeof path == 'function') {\n return new LazyWrapper(this);\n }\n return this.map(function(value) {\n return baseInvoke(value, path, args);\n });\n });\n\n LazyWrapper.prototype.reject = function(predicate) {\n return this.filter(negate(getIteratee(predicate)));\n };\n\n LazyWrapper.prototype.slice = function(start, end) {\n start = toInteger(start);\n\n var result = this;\n if (result.__filtered__ && (start > 0 || end < 0)) {\n return new LazyWrapper(result);\n }\n if (start < 0) {\n result = result.takeRight(-start);\n } else if (start) {\n result = result.drop(start);\n }\n if (end !== undefined) {\n end = toInteger(end);\n result = end < 0 ? result.dropRight(-end) : result.take(end - start);\n }\n return result;\n };\n\n LazyWrapper.prototype.takeRightWhile = function(predicate) {\n return this.reverse().takeWhile(predicate).reverse();\n };\n\n LazyWrapper.prototype.toArray = function() {\n return this.take(MAX_ARRAY_LENGTH);\n };\n\n // Add `LazyWrapper` methods to `lodash.prototype`.\n baseForOwn(LazyWrapper.prototype, function(func, methodName) {\n var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),\n isTaker = /^(?:head|last)$/.test(methodName),\n lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],\n retUnwrapped = isTaker || /^find/.test(methodName);\n\n if (!lodashFunc) {\n return;\n }\n lodash.prototype[methodName] = function() {\n var value = this.__wrapped__,\n args = isTaker ? [1] : arguments,\n isLazy = value instanceof LazyWrapper,\n iteratee = args[0],\n useLazy = isLazy || isArray(value);\n\n var interceptor = function(value) {\n var result = lodashFunc.apply(lodash, arrayPush([value], args));\n return (isTaker && chainAll) ? result[0] : result;\n };\n\n if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {\n // Avoid lazy use if the iteratee has a \"length\" value other than `1`.\n isLazy = useLazy = false;\n }\n var chainAll = this.__chain__,\n isHybrid = !!this.__actions__.length,\n isUnwrapped = retUnwrapped && !chainAll,\n onlyLazy = isLazy && !isHybrid;\n\n if (!retUnwrapped && useLazy) {\n value = onlyLazy ? value : new LazyWrapper(this);\n var result = func.apply(value, args);\n result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });\n return new LodashWrapper(result, chainAll);\n }\n if (isUnwrapped && onlyLazy) {\n return func.apply(this, args);\n }\n result = this.thru(interceptor);\n return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;\n };\n });\n\n // Add `Array` methods to `lodash.prototype`.\n arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {\n var func = arrayProto[methodName],\n chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',\n retUnwrapped = /^(?:pop|shift)$/.test(methodName);\n\n lodash.prototype[methodName] = function() {\n var args = arguments;\n if (retUnwrapped && !this.__chain__) {\n var value = this.value();\n return func.apply(isArray(value) ? value : [], args);\n }\n return this[chainName](function(value) {\n return func.apply(isArray(value) ? value : [], args);\n });\n };\n });\n\n // Map minified method names to their real names.\n baseForOwn(LazyWrapper.prototype, function(func, methodName) {\n var lodashFunc = lodash[methodName];\n if (lodashFunc) {\n var key = (lodashFunc.name + ''),\n names = realNames[key] || (realNames[key] = []);\n\n names.push({ 'name': methodName, 'func': lodashFunc });\n }\n });\n\n realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{\n 'name': 'wrapper',\n 'func': undefined\n }];\n\n // Add methods to `LazyWrapper`.\n LazyWrapper.prototype.clone = lazyClone;\n LazyWrapper.prototype.reverse = lazyReverse;\n LazyWrapper.prototype.value = lazyValue;\n\n // Add chain sequence methods to the `lodash` wrapper.\n lodash.prototype.at = wrapperAt;\n lodash.prototype.chain = wrapperChain;\n lodash.prototype.commit = wrapperCommit;\n lodash.prototype.next = wrapperNext;\n lodash.prototype.plant = wrapperPlant;\n lodash.prototype.reverse = wrapperReverse;\n lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;\n\n // Add lazy aliases.\n lodash.prototype.first = lodash.prototype.head;\n\n if (symIterator) {\n lodash.prototype[symIterator] = wrapperToIterator;\n }\n return lodash;\n });\n\n /*--------------------------------------------------------------------------*/\n\n // Export lodash.\n var _ = runInContext();\n\n // Some AMD build optimizers, like r.js, check for condition patterns like:\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n // Expose Lodash on the global object to prevent errors when Lodash is\n // loaded by a script tag in the presence of an AMD loader.\n // See http://requirejs.org/docs/errors.html#mismatch for more details.\n // Use `_.noConflict` to remove Lodash from the global object.\n root._ = _;\n\n // Define as an anonymous module so, through path mapping, it can be\n // referenced as the \"underscore\" module.\n define(function() {\n return _;\n });\n }\n // Check for `exports` after `define` in case a build optimizer adds it.\n else if (freeModule) {\n // Export for Node.js.\n (freeModule.exports = _)._ = _;\n // Export for CommonJS support.\n freeExports._ = _;\n }\n else {\n // Export to the global object.\n root._ = _;\n }\n}.call(this));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash/lodash.js\n// module id = 15\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 16\n// module chunks = 0","module.exports = function(module) {\r\n\tif(!module.webpackPolyfill) {\r\n\t\tmodule.deprecate = function() {};\r\n\t\tmodule.paths = [];\r\n\t\t// module.parent = undefined by default\r\n\t\tif(!module.children) module.children = [];\r\n\t\tObject.defineProperty(module, \"loaded\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.l;\r\n\t\t\t}\r\n\t\t});\r\n\t\tObject.defineProperty(module, \"id\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.i;\r\n\t\t\t}\r\n\t\t});\r\n\t\tmodule.webpackPolyfill = 1;\r\n\t}\r\n\treturn module;\r\n};\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/module.js\n// module id = 17\n// module chunks = 0","function layout(rows, columns, padding, size, aspect) {\n var grid = [];\n\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n var x = -1 + aspect * (i * (padding + size) + padding);\n var y = 1 - (j * (padding + size) + padding);\n grid.push([ y, x ]);\n var x_next = x + size - padding;\n grid.push([ y, x_next ]);\n var y_next = y - size + padding;\n grid.push([ y_next, x ]);\n\n grid.push([ y_next, x ]);\n grid.push([ y, x_next ]);\n grid.push([ y_next, x_next ]);\n\n }\n }\n\n return grid.reverse();\n}\n\n\nmodule.exports = layout;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/layout.js\n// module id = 18\n// module chunks = 0","function texcoord(rows, columns, texture_indexes, num_textures) {\n var grid = [];\n var texture;\n var texture_start;\n var texture_next;\n\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n texture = texture_indexes[i*rows + j];\n texture_start = (1/num_textures)*texture;\n texture_next = texture_start + (1/num_textures);\n\n grid.push([ 0, texture_start ]);\n grid.push([ 1, texture_start ]);\n grid.push([ 0, texture_next ]);\n \n grid.push([ 0, texture_next ]);\n grid.push([ 1, texture_start ]);\n grid.push([ 1, texture_next ]);\n }\n }\n\n return grid;\n}\n\n\nmodule.exports = texcoord;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/texcoord.js\n// module id = 19\n// module chunks = 0","function range(j, k) { \n return Array\n .apply(null, Array((k - j) + 1))\n .map(function(discard, n){ return n + j; }); \n}\n\n\n\nmodule.exports = range;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/range.js\n// module id = 20\n// module chunks = 0","/**\n * Derived from Identicon.js 2.3.1\n * http://github.com/stewartlord/identicon.js\n *\n * Copyright 2017, Stewart Lord and Dallinger Contributors\n * Released under the BSD license\n * http://www.opensource.org/licenses/bsd-license.php\n */\n\n\nvar Identicon = function(hash, size, options){\n if (typeof(hash) !== 'string' || hash.length < 15) {\n throw 'A hash of at least 15 characters is required.';\n }\n\n this.defaults = {\n background: [240, 240, 240, 255],\n margin: 0.08,\n size: 64,\n saturation: 0.7,\n brightness: 0.5,\n format: 'pixels'\n };\n\n this.options = typeof(options) === 'object' ? options : this.defaults;\n\n this.hash = hash\n this.background = [128, 128, 128];\n this.foreground = [255, 255, 255];\n this.size = size;\n};\n\nIdenticon.prototype = {\n background: null,\n foreground: null,\n hash: null,\n margin: null,\n size: null,\n format: null,\n\n image: function(){\n return new Pixels(this.size, this.foreground, this.background)\n },\n\n render: function(){\n var image = this.image(),\n size = this.size,\n baseMargin = Math.floor(size * this.margin),\n cell = Math.floor((size - (baseMargin * 2)) / 5),\n margin = Math.floor((size - cell * 5) / 2),\n bg = this.background,\n fg = this.foreground;\n\n // the first 15 characters of the hash control the pixels (even/odd)\n // they are drawn down the middle first, then mirrored outwards\n var i, color;\n for (i = 0; i < 15; i++) {\n color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg;\n if (i < 5) {\n this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image);\n } else if (i < 10) {\n this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n } else if (i < 15) {\n this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n }\n }\n\n return image;\n },\n\n rectangle: function(x, y, w, h, color, image){\n var i, j;\n for (i = x; i < x + w; i++) {\n for (j = y; j < y + h; j++) {\n image.buffer[j][i] = color;\n }\n }\n }\n\n};\n\nvar Pixels = function(size){\n this.buffer = [];\n for (i = 0; i < size; i++) {\n var row = []\n for (j = 0; j < size; j++) {\n row.push([0,0,120]);\n }\n this.buffer.push(row);\n }\n};\n\nPixels.prototype = {\n pixels: null,\n\n};\n\n\nmodule.exports = Identicon;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/pixdenticon.js\n// module id = 21\n// module chunks = 0","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.createREGL = factory());\n}(this, (function () { 'use strict';\n\nvar arrayTypes = {\n\t\"[object Int8Array]\": 5120,\n\t\"[object Int16Array]\": 5122,\n\t\"[object Int32Array]\": 5124,\n\t\"[object Uint8Array]\": 5121,\n\t\"[object Uint8ClampedArray]\": 5121,\n\t\"[object Uint16Array]\": 5123,\n\t\"[object Uint32Array]\": 5125,\n\t\"[object Float32Array]\": 5126,\n\t\"[object Float64Array]\": 5121,\n\t\"[object ArrayBuffer]\": 5121\n};\n\nvar isTypedArray = function (x) {\n return Object.prototype.toString.call(x) in arrayTypes\n};\n\nvar extend = function (base, opts) {\n var keys = Object.keys(opts);\n for (var i = 0; i < keys.length; ++i) {\n base[keys[i]] = opts[keys[i]];\n }\n return base\n};\n\n// Error checking and parameter validation.\n//\n// Statements for the form `check.someProcedure(...)` get removed by\n// a browserify transform for optimized/minified bundles.\n//\n/* globals btoa */\n// only used for extracting shader names. if btoa not present, then errors\n// will be slightly crappier\nfunction decodeB64 (str) {\n if (typeof btoa !== 'undefined') {\n return btoa(str)\n }\n return 'base64:' + str\n}\n\nfunction raise (message) {\n var error = new Error('(regl) ' + message);\n console.error(error);\n throw error\n}\n\nfunction check (pred, message) {\n if (!pred) {\n raise(message);\n }\n}\n\nfunction encolon (message) {\n if (message) {\n return ': ' + message\n }\n return ''\n}\n\nfunction checkParameter (param, possibilities, message) {\n if (!(param in possibilities)) {\n raise('unknown parameter (' + param + ')' + encolon(message) +\n '. possible values: ' + Object.keys(possibilities).join());\n }\n}\n\nfunction checkIsTypedArray (data, message) {\n if (!isTypedArray(data)) {\n raise(\n 'invalid parameter type' + encolon(message) +\n '. must be a typed array');\n }\n}\n\nfunction checkTypeOf (value, type, message) {\n if (typeof value !== type) {\n raise(\n 'invalid parameter type' + encolon(message) +\n '. expected ' + type + ', got ' + (typeof value));\n }\n}\n\nfunction checkNonNegativeInt (value, message) {\n if (!((value >= 0) &&\n ((value | 0) === value))) {\n raise('invalid parameter type, (' + value + ')' + encolon(message) +\n '. must be a nonnegative integer');\n }\n}\n\nfunction checkOneOf (value, list, message) {\n if (list.indexOf(value) < 0) {\n raise('invalid value' + encolon(message) + '. must be one of: ' + list);\n }\n}\n\nvar constructorKeys = [\n 'gl',\n 'canvas',\n 'container',\n 'attributes',\n 'pixelRatio',\n 'extensions',\n 'optionalExtensions',\n 'profile',\n 'onDone'\n];\n\nfunction checkConstructor (obj) {\n Object.keys(obj).forEach(function (key) {\n if (constructorKeys.indexOf(key) < 0) {\n raise('invalid regl constructor argument \"' + key + '\". must be one of ' + constructorKeys);\n }\n });\n}\n\nfunction leftPad (str, n) {\n str = str + '';\n while (str.length < n) {\n str = ' ' + str;\n }\n return str\n}\n\nfunction ShaderFile () {\n this.name = 'unknown';\n this.lines = [];\n this.index = {};\n this.hasErrors = false;\n}\n\nfunction ShaderLine (number, line) {\n this.number = number;\n this.line = line;\n this.errors = [];\n}\n\nfunction ShaderError (fileNumber, lineNumber, message) {\n this.file = fileNumber;\n this.line = lineNumber;\n this.message = message;\n}\n\nfunction guessCommand () {\n var error = new Error();\n var stack = (error.stack || error).toString();\n var pat = /compileProcedure.*\\n\\s*at.*\\((.*)\\)/.exec(stack);\n if (pat) {\n return pat[1]\n }\n var pat2 = /compileProcedure.*\\n\\s*at\\s+(.*)(\\n|$)/.exec(stack);\n if (pat2) {\n return pat2[1]\n }\n return 'unknown'\n}\n\nfunction guessCallSite () {\n var error = new Error();\n var stack = (error.stack || error).toString();\n var pat = /at REGLCommand.*\\n\\s+at.*\\((.*)\\)/.exec(stack);\n if (pat) {\n return pat[1]\n }\n var pat2 = /at REGLCommand.*\\n\\s+at\\s+(.*)\\n/.exec(stack);\n if (pat2) {\n return pat2[1]\n }\n return 'unknown'\n}\n\nfunction parseSource (source, command) {\n var lines = source.split('\\n');\n var lineNumber = 1;\n var fileNumber = 0;\n var files = {\n unknown: new ShaderFile(),\n 0: new ShaderFile()\n };\n files.unknown.name = files[0].name = command || guessCommand();\n files.unknown.lines.push(new ShaderLine(0, ''));\n for (var i = 0; i < lines.length; ++i) {\n var line = lines[i];\n var parts = /^\\s*\\#\\s*(\\w+)\\s+(.+)\\s*$/.exec(line);\n if (parts) {\n switch (parts[1]) {\n case 'line':\n var lineNumberInfo = /(\\d+)(\\s+\\d+)?/.exec(parts[2]);\n if (lineNumberInfo) {\n lineNumber = lineNumberInfo[1] | 0;\n if (lineNumberInfo[2]) {\n fileNumber = lineNumberInfo[2] | 0;\n if (!(fileNumber in files)) {\n files[fileNumber] = new ShaderFile();\n }\n }\n }\n break\n case 'define':\n var nameInfo = /SHADER_NAME(_B64)?\\s+(.*)$/.exec(parts[2]);\n if (nameInfo) {\n files[fileNumber].name = (nameInfo[1]\n ? decodeB64(nameInfo[2])\n : nameInfo[2]);\n }\n break\n }\n }\n files[fileNumber].lines.push(new ShaderLine(lineNumber++, line));\n }\n Object.keys(files).forEach(function (fileNumber) {\n var file = files[fileNumber];\n file.lines.forEach(function (line) {\n file.index[line.number] = line;\n });\n });\n return files\n}\n\nfunction parseErrorLog (errLog) {\n var result = [];\n errLog.split('\\n').forEach(function (errMsg) {\n if (errMsg.length < 5) {\n return\n }\n var parts = /^ERROR\\:\\s+(\\d+)\\:(\\d+)\\:\\s*(.*)$/.exec(errMsg);\n if (parts) {\n result.push(new ShaderError(\n parts[1] | 0,\n parts[2] | 0,\n parts[3].trim()));\n } else if (errMsg.length > 0) {\n result.push(new ShaderError('unknown', 0, errMsg));\n }\n });\n return result\n}\n\nfunction annotateFiles (files, errors) {\n errors.forEach(function (error) {\n var file = files[error.file];\n if (file) {\n var line = file.index[error.line];\n if (line) {\n line.errors.push(error);\n file.hasErrors = true;\n return\n }\n }\n files.unknown.hasErrors = true;\n files.unknown.lines[0].errors.push(error);\n });\n}\n\nfunction checkShaderError (gl, shader, source, type, command) {\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n var errLog = gl.getShaderInfoLog(shader);\n var typeName = type === gl.FRAGMENT_SHADER ? 'fragment' : 'vertex';\n checkCommandType(source, 'string', typeName + ' shader source must be a string', command);\n var files = parseSource(source, command);\n var errors = parseErrorLog(errLog);\n annotateFiles(files, errors);\n\n Object.keys(files).forEach(function (fileNumber) {\n var file = files[fileNumber];\n if (!file.hasErrors) {\n return\n }\n\n var strings = [''];\n var styles = [''];\n\n function push (str, style) {\n strings.push(str);\n styles.push(style || '');\n }\n\n push('file number ' + fileNumber + ': ' + file.name + '\\n', 'color:red;text-decoration:underline;font-weight:bold');\n\n file.lines.forEach(function (line) {\n if (line.errors.length > 0) {\n push(leftPad(line.number, 4) + '| ', 'background-color:yellow; font-weight:bold');\n push(line.line + '\\n', 'color:red; background-color:yellow; font-weight:bold');\n\n // try to guess token\n var offset = 0;\n line.errors.forEach(function (error) {\n var message = error.message;\n var token = /^\\s*\\'(.*)\\'\\s*\\:\\s*(.*)$/.exec(message);\n if (token) {\n var tokenPat = token[1];\n message = token[2];\n switch (tokenPat) {\n case 'assign':\n tokenPat = '=';\n break\n }\n offset = Math.max(line.line.indexOf(tokenPat, offset), 0);\n } else {\n offset = 0;\n }\n\n push(leftPad('| ', 6));\n push(leftPad('^^^', offset + 3) + '\\n', 'font-weight:bold');\n push(leftPad('| ', 6));\n push(message + '\\n', 'font-weight:bold');\n });\n push(leftPad('| ', 6) + '\\n');\n } else {\n push(leftPad(line.number, 4) + '| ');\n push(line.line + '\\n', 'color:red');\n }\n });\n if (typeof document !== 'undefined') {\n styles[0] = strings.join('%c');\n console.log.apply(console, styles);\n } else {\n console.log(strings.join(''));\n }\n });\n\n check.raise('Error compiling ' + typeName + ' shader, ' + files[0].name);\n }\n}\n\nfunction checkLinkError (gl, program, fragShader, vertShader, command) {\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n var errLog = gl.getProgramInfoLog(program);\n var fragParse = parseSource(fragShader, command);\n var vertParse = parseSource(vertShader, command);\n\n var header = 'Error linking program with vertex shader, \"' +\n vertParse[0].name + '\", and fragment shader \"' + fragParse[0].name + '\"';\n\n if (typeof document !== 'undefined') {\n console.log('%c' + header + '\\n%c' + errLog,\n 'color:red;text-decoration:underline;font-weight:bold',\n 'color:red');\n } else {\n console.log(header + '\\n' + errLog);\n }\n check.raise(header);\n }\n}\n\nfunction saveCommandRef (object) {\n object._commandRef = guessCommand();\n}\n\nfunction saveDrawCommandInfo (opts, uniforms, attributes, stringStore) {\n saveCommandRef(opts);\n\n function id (str) {\n if (str) {\n return stringStore.id(str)\n }\n return 0\n }\n opts._fragId = id(opts.static.frag);\n opts._vertId = id(opts.static.vert);\n\n function addProps (dict, set) {\n Object.keys(set).forEach(function (u) {\n dict[stringStore.id(u)] = true;\n });\n }\n\n var uniformSet = opts._uniformSet = {};\n addProps(uniformSet, uniforms.static);\n addProps(uniformSet, uniforms.dynamic);\n\n var attributeSet = opts._attributeSet = {};\n addProps(attributeSet, attributes.static);\n addProps(attributeSet, attributes.dynamic);\n\n opts._hasCount = (\n 'count' in opts.static ||\n 'count' in opts.dynamic ||\n 'elements' in opts.static ||\n 'elements' in opts.dynamic);\n}\n\nfunction commandRaise (message, command) {\n var callSite = guessCallSite();\n raise(message +\n ' in command ' + (command || guessCommand()) +\n (callSite === 'unknown' ? '' : ' called from ' + callSite));\n}\n\nfunction checkCommand (pred, message, command) {\n if (!pred) {\n commandRaise(message, command || guessCommand());\n }\n}\n\nfunction checkParameterCommand (param, possibilities, message, command) {\n if (!(param in possibilities)) {\n commandRaise(\n 'unknown parameter (' + param + ')' + encolon(message) +\n '. possible values: ' + Object.keys(possibilities).join(),\n command || guessCommand());\n }\n}\n\nfunction checkCommandType (value, type, message, command) {\n if (typeof value !== type) {\n commandRaise(\n 'invalid parameter type' + encolon(message) +\n '. expected ' + type + ', got ' + (typeof value),\n command || guessCommand());\n }\n}\n\nfunction checkOptional (block) {\n block();\n}\n\nfunction checkFramebufferFormat (attachment, texFormats, rbFormats) {\n if (attachment.texture) {\n checkOneOf(\n attachment.texture._texture.internalformat,\n texFormats,\n 'unsupported texture format for attachment');\n } else {\n checkOneOf(\n attachment.renderbuffer._renderbuffer.format,\n rbFormats,\n 'unsupported renderbuffer format for attachment');\n }\n}\n\nvar GL_CLAMP_TO_EDGE = 0x812F;\n\nvar GL_NEAREST = 0x2600;\nvar GL_NEAREST_MIPMAP_NEAREST = 0x2700;\nvar GL_LINEAR_MIPMAP_NEAREST = 0x2701;\nvar GL_NEAREST_MIPMAP_LINEAR = 0x2702;\nvar GL_LINEAR_MIPMAP_LINEAR = 0x2703;\n\nvar GL_BYTE = 5120;\nvar GL_UNSIGNED_BYTE = 5121;\nvar GL_SHORT = 5122;\nvar GL_UNSIGNED_SHORT = 5123;\nvar GL_INT = 5124;\nvar GL_UNSIGNED_INT = 5125;\nvar GL_FLOAT = 5126;\n\nvar GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;\nvar GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;\nvar GL_UNSIGNED_SHORT_5_6_5 = 0x8363;\nvar GL_UNSIGNED_INT_24_8_WEBGL = 0x84FA;\n\nvar GL_HALF_FLOAT_OES = 0x8D61;\n\nvar TYPE_SIZE = {};\n\nTYPE_SIZE[GL_BYTE] =\nTYPE_SIZE[GL_UNSIGNED_BYTE] = 1;\n\nTYPE_SIZE[GL_SHORT] =\nTYPE_SIZE[GL_UNSIGNED_SHORT] =\nTYPE_SIZE[GL_HALF_FLOAT_OES] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_5_6_5] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_4_4_4_4] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_5_5_5_1] = 2;\n\nTYPE_SIZE[GL_INT] =\nTYPE_SIZE[GL_UNSIGNED_INT] =\nTYPE_SIZE[GL_FLOAT] =\nTYPE_SIZE[GL_UNSIGNED_INT_24_8_WEBGL] = 4;\n\nfunction pixelSize (type, channels) {\n if (type === GL_UNSIGNED_SHORT_5_5_5_1 ||\n type === GL_UNSIGNED_SHORT_4_4_4_4 ||\n type === GL_UNSIGNED_SHORT_5_6_5) {\n return 2\n } else if (type === GL_UNSIGNED_INT_24_8_WEBGL) {\n return 4\n } else {\n return TYPE_SIZE[type] * channels\n }\n}\n\nfunction isPow2 (v) {\n return !(v & (v - 1)) && (!!v)\n}\n\nfunction checkTexture2D (info, mipData, limits) {\n var i;\n var w = mipData.width;\n var h = mipData.height;\n var c = mipData.channels;\n\n // Check texture shape\n check(w > 0 && w <= limits.maxTextureSize &&\n h > 0 && h <= limits.maxTextureSize,\n 'invalid texture shape');\n\n // check wrap mode\n if (info.wrapS !== GL_CLAMP_TO_EDGE || info.wrapT !== GL_CLAMP_TO_EDGE) {\n check(isPow2(w) && isPow2(h),\n 'incompatible wrap mode for texture, both width and height must be power of 2');\n }\n\n if (mipData.mipmask === 1) {\n if (w !== 1 && h !== 1) {\n check(\n info.minFilter !== GL_NEAREST_MIPMAP_NEAREST &&\n info.minFilter !== GL_NEAREST_MIPMAP_LINEAR &&\n info.minFilter !== GL_LINEAR_MIPMAP_NEAREST &&\n info.minFilter !== GL_LINEAR_MIPMAP_LINEAR,\n 'min filter requires mipmap');\n }\n } else {\n // texture must be power of 2\n check(isPow2(w) && isPow2(h),\n 'texture must be a square power of 2 to support mipmapping');\n check(mipData.mipmask === (w << 1) - 1,\n 'missing or incomplete mipmap data');\n }\n\n if (mipData.type === GL_FLOAT) {\n if (limits.extensions.indexOf('oes_texture_float_linear') < 0) {\n check(info.minFilter === GL_NEAREST && info.magFilter === GL_NEAREST,\n 'filter not supported, must enable oes_texture_float_linear');\n }\n check(!info.genMipmaps,\n 'mipmap generation not supported with float textures');\n }\n\n // check image complete\n var mipimages = mipData.images;\n for (i = 0; i < 16; ++i) {\n if (mipimages[i]) {\n var mw = w >> i;\n var mh = h >> i;\n check(mipData.mipmask & (1 << i), 'missing mipmap data');\n\n var img = mipimages[i];\n\n check(\n img.width === mw &&\n img.height === mh,\n 'invalid shape for mip images');\n\n check(\n img.format === mipData.format &&\n img.internalformat === mipData.internalformat &&\n img.type === mipData.type,\n 'incompatible type for mip image');\n\n if (img.compressed) {\n // TODO: check size for compressed images\n } else if (img.data) {\n // check(img.data.byteLength === mw * mh *\n // Math.max(pixelSize(img.type, c), img.unpackAlignment),\n var rowSize = Math.ceil(pixelSize(img.type, c) * mw / img.unpackAlignment) * img.unpackAlignment;\n check(img.data.byteLength === rowSize * mh,\n 'invalid data for image, buffer size is inconsistent with image format');\n } else if (img.element) {\n // TODO: check element can be loaded\n } else if (img.copy) {\n // TODO: check compatible format and type\n }\n } else if (!info.genMipmaps) {\n check((mipData.mipmask & (1 << i)) === 0, 'extra mipmap data');\n }\n }\n\n if (mipData.compressed) {\n check(!info.genMipmaps,\n 'mipmap generation for compressed images not supported');\n }\n}\n\nfunction checkTextureCube (texture, info, faces, limits) {\n var w = texture.width;\n var h = texture.height;\n var c = texture.channels;\n\n // Check texture shape\n check(\n w > 0 && w <= limits.maxTextureSize && h > 0 && h <= limits.maxTextureSize,\n 'invalid texture shape');\n check(\n w === h,\n 'cube map must be square');\n check(\n info.wrapS === GL_CLAMP_TO_EDGE && info.wrapT === GL_CLAMP_TO_EDGE,\n 'wrap mode not supported by cube map');\n\n for (var i = 0; i < faces.length; ++i) {\n var face = faces[i];\n check(\n face.width === w && face.height === h,\n 'inconsistent cube map face shape');\n\n if (info.genMipmaps) {\n check(!face.compressed,\n 'can not generate mipmap for compressed textures');\n check(face.mipmask === 1,\n 'can not specify mipmaps and generate mipmaps');\n } else {\n // TODO: check mip and filter mode\n }\n\n var mipmaps = face.images;\n for (var j = 0; j < 16; ++j) {\n var img = mipmaps[j];\n if (img) {\n var mw = w >> j;\n var mh = h >> j;\n check(face.mipmask & (1 << j), 'missing mipmap data');\n check(\n img.width === mw &&\n img.height === mh,\n 'invalid shape for mip images');\n check(\n img.format === texture.format &&\n img.internalformat === texture.internalformat &&\n img.type === texture.type,\n 'incompatible type for mip image');\n\n if (img.compressed) {\n // TODO: check size for compressed images\n } else if (img.data) {\n check(img.data.byteLength === mw * mh *\n Math.max(pixelSize(img.type, c), img.unpackAlignment),\n 'invalid data for image, buffer size is inconsistent with image format');\n } else if (img.element) {\n // TODO: check element can be loaded\n } else if (img.copy) {\n // TODO: check compatible format and type\n }\n }\n }\n }\n}\n\nvar check$1 = extend(check, {\n optional: checkOptional,\n raise: raise,\n commandRaise: commandRaise,\n command: checkCommand,\n parameter: checkParameter,\n commandParameter: checkParameterCommand,\n constructor: checkConstructor,\n type: checkTypeOf,\n commandType: checkCommandType,\n isTypedArray: checkIsTypedArray,\n nni: checkNonNegativeInt,\n oneOf: checkOneOf,\n shaderError: checkShaderError,\n linkError: checkLinkError,\n callSite: guessCallSite,\n saveCommandRef: saveCommandRef,\n saveDrawInfo: saveDrawCommandInfo,\n framebufferFormat: checkFramebufferFormat,\n guessCommand: guessCommand,\n texture2D: checkTexture2D,\n textureCube: checkTextureCube\n});\n\nvar VARIABLE_COUNTER = 0;\n\nvar DYN_FUNC = 0;\n\nfunction DynamicVariable (type, data) {\n this.id = (VARIABLE_COUNTER++);\n this.type = type;\n this.data = data;\n}\n\nfunction escapeStr (str) {\n return str.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n}\n\nfunction splitParts (str) {\n if (str.length === 0) {\n return []\n }\n\n var firstChar = str.charAt(0);\n var lastChar = str.charAt(str.length - 1);\n\n if (str.length > 1 &&\n firstChar === lastChar &&\n (firstChar === '\"' || firstChar === \"'\")) {\n return ['\"' + escapeStr(str.substr(1, str.length - 2)) + '\"']\n }\n\n var parts = /\\[(false|true|null|\\d+|'[^']*'|\"[^\"]*\")\\]/.exec(str);\n if (parts) {\n return (\n splitParts(str.substr(0, parts.index))\n .concat(splitParts(parts[1]))\n .concat(splitParts(str.substr(parts.index + parts[0].length)))\n )\n }\n\n var subparts = str.split('.');\n if (subparts.length === 1) {\n return ['\"' + escapeStr(str) + '\"']\n }\n\n var result = [];\n for (var i = 0; i < subparts.length; ++i) {\n result = result.concat(splitParts(subparts[i]));\n }\n return result\n}\n\nfunction toAccessorString (str) {\n return '[' + splitParts(str).join('][') + ']'\n}\n\nfunction defineDynamic (type, data) {\n return new DynamicVariable(type, toAccessorString(data + ''))\n}\n\nfunction isDynamic (x) {\n return (typeof x === 'function' && !x._reglType) ||\n x instanceof DynamicVariable\n}\n\nfunction unbox (x, path) {\n if (typeof x === 'function') {\n return new DynamicVariable(DYN_FUNC, x)\n }\n return x\n}\n\nvar dynamic = {\n DynamicVariable: DynamicVariable,\n define: defineDynamic,\n isDynamic: isDynamic,\n unbox: unbox,\n accessor: toAccessorString\n};\n\n/* globals requestAnimationFrame, cancelAnimationFrame */\nvar raf = {\n next: typeof requestAnimationFrame === 'function'\n ? function (cb) { return requestAnimationFrame(cb) }\n : function (cb) { return setTimeout(cb, 16) },\n cancel: typeof cancelAnimationFrame === 'function'\n ? function (raf) { return cancelAnimationFrame(raf) }\n : clearTimeout\n};\n\n/* globals performance */\nvar clock = (typeof performance !== 'undefined' && performance.now)\n ? function () { return performance.now() }\n : function () { return +(new Date()) };\n\nfunction createStringStore () {\n var stringIds = {'': 0};\n var stringValues = [''];\n return {\n id: function (str) {\n var result = stringIds[str];\n if (result) {\n return result\n }\n result = stringIds[str] = stringValues.length;\n stringValues.push(str);\n return result\n },\n\n str: function (id) {\n return stringValues[id]\n }\n }\n}\n\n// Context and canvas creation helper functions\nfunction createCanvas (element, onDone, pixelRatio) {\n var canvas = document.createElement('canvas');\n extend(canvas.style, {\n border: 0,\n margin: 0,\n padding: 0,\n top: 0,\n left: 0\n });\n element.appendChild(canvas);\n\n if (element === document.body) {\n canvas.style.position = 'absolute';\n extend(element.style, {\n margin: 0,\n padding: 0\n });\n }\n\n function resize () {\n var w = window.innerWidth;\n var h = window.innerHeight;\n if (element !== document.body) {\n var bounds = element.getBoundingClientRect();\n w = bounds.right - bounds.left;\n h = bounds.bottom - bounds.top;\n }\n canvas.width = pixelRatio * w;\n canvas.height = pixelRatio * h;\n extend(canvas.style, {\n width: w + 'px',\n height: h + 'px'\n });\n }\n\n window.addEventListener('resize', resize, false);\n\n function onDestroy () {\n window.removeEventListener('resize', resize);\n element.removeChild(canvas);\n }\n\n resize();\n\n return {\n canvas: canvas,\n onDestroy: onDestroy\n }\n}\n\nfunction createContext (canvas, contexAttributes) {\n function get (name) {\n try {\n return canvas.getContext(name, contexAttributes)\n } catch (e) {\n return null\n }\n }\n return (\n get('webgl') ||\n get('experimental-webgl') ||\n get('webgl-experimental')\n )\n}\n\nfunction isHTMLElement (obj) {\n return (\n typeof obj.nodeName === 'string' &&\n typeof obj.appendChild === 'function' &&\n typeof obj.getBoundingClientRect === 'function'\n )\n}\n\nfunction isWebGLContext (obj) {\n return (\n typeof obj.drawArrays === 'function' ||\n typeof obj.drawElements === 'function'\n )\n}\n\nfunction parseExtensions (input) {\n if (typeof input === 'string') {\n return input.split()\n }\n check$1(Array.isArray(input), 'invalid extension array');\n return input\n}\n\nfunction getElement (desc) {\n if (typeof desc === 'string') {\n check$1(typeof document !== 'undefined', 'not supported outside of DOM');\n return document.querySelector(desc)\n }\n return desc\n}\n\nfunction parseArgs (args_) {\n var args = args_ || {};\n var element, container, canvas, gl;\n var contextAttributes = {};\n var extensions = [];\n var optionalExtensions = [];\n var pixelRatio = (typeof window === 'undefined' ? 1 : window.devicePixelRatio);\n var profile = false;\n var onDone = function (err) {\n if (err) {\n check$1.raise(err);\n }\n };\n var onDestroy = function () {};\n if (typeof args === 'string') {\n check$1(\n typeof document !== 'undefined',\n 'selector queries only supported in DOM enviroments');\n element = document.querySelector(args);\n check$1(element, 'invalid query string for element');\n } else if (typeof args === 'object') {\n if (isHTMLElement(args)) {\n element = args;\n } else if (isWebGLContext(args)) {\n gl = args;\n canvas = gl.canvas;\n } else {\n check$1.constructor(args);\n if ('gl' in args) {\n gl = args.gl;\n } else if ('canvas' in args) {\n canvas = getElement(args.canvas);\n } else if ('container' in args) {\n container = getElement(args.container);\n }\n if ('attributes' in args) {\n contextAttributes = args.attributes;\n check$1.type(contextAttributes, 'object', 'invalid context attributes');\n }\n if ('extensions' in args) {\n extensions = parseExtensions(args.extensions);\n }\n if ('optionalExtensions' in args) {\n optionalExtensions = parseExtensions(args.optionalExtensions);\n }\n if ('onDone' in args) {\n check$1.type(\n args.onDone, 'function',\n 'invalid or missing onDone callback');\n onDone = args.onDone;\n }\n if ('profile' in args) {\n profile = !!args.profile;\n }\n if ('pixelRatio' in args) {\n pixelRatio = +args.pixelRatio;\n check$1(pixelRatio > 0, 'invalid pixel ratio');\n }\n }\n } else {\n check$1.raise('invalid arguments to regl');\n }\n\n if (element) {\n if (element.nodeName.toLowerCase() === 'canvas') {\n canvas = element;\n } else {\n container = element;\n }\n }\n\n if (!gl) {\n if (!canvas) {\n check$1(\n typeof document !== 'undefined',\n 'must manually specify webgl context outside of DOM environments');\n var result = createCanvas(container || document.body, onDone, pixelRatio);\n if (!result) {\n return null\n }\n canvas = result.canvas;\n onDestroy = result.onDestroy;\n }\n gl = createContext(canvas, contextAttributes);\n }\n\n if (!gl) {\n onDestroy();\n onDone('webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org');\n return null\n }\n\n return {\n gl: gl,\n canvas: canvas,\n container: container,\n extensions: extensions,\n optionalExtensions: optionalExtensions,\n pixelRatio: pixelRatio,\n profile: profile,\n onDone: onDone,\n onDestroy: onDestroy\n }\n}\n\nfunction createExtensionCache (gl, config) {\n var extensions = {};\n\n function tryLoadExtension (name_) {\n check$1.type(name_, 'string', 'extension name must be string');\n var name = name_.toLowerCase();\n var ext;\n try {\n ext = extensions[name] = gl.getExtension(name);\n } catch (e) {}\n return !!ext\n }\n\n for (var i = 0; i < config.extensions.length; ++i) {\n var name = config.extensions[i];\n if (!tryLoadExtension(name)) {\n config.onDestroy();\n config.onDone('\"' + name + '\" extension is not supported by the current WebGL context, try upgrading your system or a different browser');\n return null\n }\n }\n\n config.optionalExtensions.forEach(tryLoadExtension);\n\n return {\n extensions: extensions,\n restore: function () {\n Object.keys(extensions).forEach(function (name) {\n if (!tryLoadExtension(name)) {\n throw new Error('(regl): error restoring extension ' + name)\n }\n });\n }\n }\n}\n\nvar GL_SUBPIXEL_BITS = 0x0D50;\nvar GL_RED_BITS = 0x0D52;\nvar GL_GREEN_BITS = 0x0D53;\nvar GL_BLUE_BITS = 0x0D54;\nvar GL_ALPHA_BITS = 0x0D55;\nvar GL_DEPTH_BITS = 0x0D56;\nvar GL_STENCIL_BITS = 0x0D57;\n\nvar GL_ALIASED_POINT_SIZE_RANGE = 0x846D;\nvar GL_ALIASED_LINE_WIDTH_RANGE = 0x846E;\n\nvar GL_MAX_TEXTURE_SIZE = 0x0D33;\nvar GL_MAX_VIEWPORT_DIMS = 0x0D3A;\nvar GL_MAX_VERTEX_ATTRIBS = 0x8869;\nvar GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;\nvar GL_MAX_VARYING_VECTORS = 0x8DFC;\nvar GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;\nvar GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;\nvar GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872;\nvar GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;\nvar GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;\nvar GL_MAX_RENDERBUFFER_SIZE = 0x84E8;\n\nvar GL_VENDOR = 0x1F00;\nvar GL_RENDERER = 0x1F01;\nvar GL_VERSION = 0x1F02;\nvar GL_SHADING_LANGUAGE_VERSION = 0x8B8C;\n\nvar GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;\n\nvar GL_MAX_COLOR_ATTACHMENTS_WEBGL = 0x8CDF;\nvar GL_MAX_DRAW_BUFFERS_WEBGL = 0x8824;\n\nvar wrapLimits = function (gl, extensions) {\n var maxAnisotropic = 1;\n if (extensions.ext_texture_filter_anisotropic) {\n maxAnisotropic = gl.getParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);\n }\n\n var maxDrawbuffers = 1;\n var maxColorAttachments = 1;\n if (extensions.webgl_draw_buffers) {\n maxDrawbuffers = gl.getParameter(GL_MAX_DRAW_BUFFERS_WEBGL);\n maxColorAttachments = gl.getParameter(GL_MAX_COLOR_ATTACHMENTS_WEBGL);\n }\n\n return {\n // drawing buffer bit depth\n colorBits: [\n gl.getParameter(GL_RED_BITS),\n gl.getParameter(GL_GREEN_BITS),\n gl.getParameter(GL_BLUE_BITS),\n gl.getParameter(GL_ALPHA_BITS)\n ],\n depthBits: gl.getParameter(GL_DEPTH_BITS),\n stencilBits: gl.getParameter(GL_STENCIL_BITS),\n subpixelBits: gl.getParameter(GL_SUBPIXEL_BITS),\n\n // supported extensions\n extensions: Object.keys(extensions).filter(function (ext) {\n return !!extensions[ext]\n }),\n\n // max aniso samples\n maxAnisotropic: maxAnisotropic,\n\n // max draw buffers\n maxDrawbuffers: maxDrawbuffers,\n maxColorAttachments: maxColorAttachments,\n\n // point and line size ranges\n pointSizeDims: gl.getParameter(GL_ALIASED_POINT_SIZE_RANGE),\n lineWidthDims: gl.getParameter(GL_ALIASED_LINE_WIDTH_RANGE),\n maxViewportDims: gl.getParameter(GL_MAX_VIEWPORT_DIMS),\n maxCombinedTextureUnits: gl.getParameter(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n maxCubeMapSize: gl.getParameter(GL_MAX_CUBE_MAP_TEXTURE_SIZE),\n maxRenderbufferSize: gl.getParameter(GL_MAX_RENDERBUFFER_SIZE),\n maxTextureUnits: gl.getParameter(GL_MAX_TEXTURE_IMAGE_UNITS),\n maxTextureSize: gl.getParameter(GL_MAX_TEXTURE_SIZE),\n maxAttributes: gl.getParameter(GL_MAX_VERTEX_ATTRIBS),\n maxVertexUniforms: gl.getParameter(GL_MAX_VERTEX_UNIFORM_VECTORS),\n maxVertexTextureUnits: gl.getParameter(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS),\n maxVaryingVectors: gl.getParameter(GL_MAX_VARYING_VECTORS),\n maxFragmentUniforms: gl.getParameter(GL_MAX_FRAGMENT_UNIFORM_VECTORS),\n\n // vendor info\n glsl: gl.getParameter(GL_SHADING_LANGUAGE_VERSION),\n renderer: gl.getParameter(GL_RENDERER),\n vendor: gl.getParameter(GL_VENDOR),\n version: gl.getParameter(GL_VERSION)\n }\n};\n\nfunction isNDArrayLike (obj) {\n return (\n !!obj &&\n typeof obj === 'object' &&\n Array.isArray(obj.shape) &&\n Array.isArray(obj.stride) &&\n typeof obj.offset === 'number' &&\n obj.shape.length === obj.stride.length &&\n (Array.isArray(obj.data) ||\n isTypedArray(obj.data)))\n}\n\nvar values = function (obj) {\n return Object.keys(obj).map(function (key) { return obj[key] })\n};\n\nfunction loop (n, f) {\n var result = Array(n);\n for (var i = 0; i < n; ++i) {\n result[i] = f(i);\n }\n return result\n}\n\nvar GL_BYTE$1 = 5120;\nvar GL_UNSIGNED_BYTE$2 = 5121;\nvar GL_SHORT$1 = 5122;\nvar GL_UNSIGNED_SHORT$1 = 5123;\nvar GL_INT$1 = 5124;\nvar GL_UNSIGNED_INT$1 = 5125;\nvar GL_FLOAT$2 = 5126;\n\nvar bufferPool = loop(8, function () {\n return []\n});\n\nfunction nextPow16 (v) {\n for (var i = 16; i <= (1 << 28); i *= 16) {\n if (v <= i) {\n return i\n }\n }\n return 0\n}\n\nfunction log2 (v) {\n var r, shift;\n r = (v > 0xFFFF) << 4;\n v >>>= r;\n shift = (v > 0xFF) << 3;\n v >>>= shift; r |= shift;\n shift = (v > 0xF) << 2;\n v >>>= shift; r |= shift;\n shift = (v > 0x3) << 1;\n v >>>= shift; r |= shift;\n return r | (v >> 1)\n}\n\nfunction alloc (n) {\n var sz = nextPow16(n);\n var bin = bufferPool[log2(sz) >> 2];\n if (bin.length > 0) {\n return bin.pop()\n }\n return new ArrayBuffer(sz)\n}\n\nfunction free (buf) {\n bufferPool[log2(buf.byteLength) >> 2].push(buf);\n}\n\nfunction allocType (type, n) {\n var result = null;\n switch (type) {\n case GL_BYTE$1:\n result = new Int8Array(alloc(n), 0, n);\n break\n case GL_UNSIGNED_BYTE$2:\n result = new Uint8Array(alloc(n), 0, n);\n break\n case GL_SHORT$1:\n result = new Int16Array(alloc(2 * n), 0, n);\n break\n case GL_UNSIGNED_SHORT$1:\n result = new Uint16Array(alloc(2 * n), 0, n);\n break\n case GL_INT$1:\n result = new Int32Array(alloc(4 * n), 0, n);\n break\n case GL_UNSIGNED_INT$1:\n result = new Uint32Array(alloc(4 * n), 0, n);\n break\n case GL_FLOAT$2:\n result = new Float32Array(alloc(4 * n), 0, n);\n break\n default:\n return null\n }\n if (result.length !== n) {\n return result.subarray(0, n)\n }\n return result\n}\n\nfunction freeType (array) {\n free(array.buffer);\n}\n\nvar pool = {\n alloc: alloc,\n free: free,\n allocType: allocType,\n freeType: freeType\n};\n\nvar flattenUtils = {\n shape: arrayShape$1,\n flatten: flattenArray\n};\n\nfunction flatten1D (array, nx, out) {\n for (var i = 0; i < nx; ++i) {\n out[i] = array[i];\n }\n}\n\nfunction flatten2D (array, nx, ny, out) {\n var ptr = 0;\n for (var i = 0; i < nx; ++i) {\n var row = array[i];\n for (var j = 0; j < ny; ++j) {\n out[ptr++] = row[j];\n }\n }\n}\n\nfunction flatten3D (array, nx, ny, nz, out, ptr_) {\n var ptr = ptr_;\n for (var i = 0; i < nx; ++i) {\n var row = array[i];\n for (var j = 0; j < ny; ++j) {\n var col = row[j];\n for (var k = 0; k < nz; ++k) {\n out[ptr++] = col[k];\n }\n }\n }\n}\n\nfunction flattenRec (array, shape, level, out, ptr) {\n var stride = 1;\n for (var i = level + 1; i < shape.length; ++i) {\n stride *= shape[i];\n }\n var n = shape[level];\n if (shape.length - level === 4) {\n var nx = shape[level + 1];\n var ny = shape[level + 2];\n var nz = shape[level + 3];\n for (i = 0; i < n; ++i) {\n flatten3D(array[i], nx, ny, nz, out, ptr);\n ptr += stride;\n }\n } else {\n for (i = 0; i < n; ++i) {\n flattenRec(array[i], shape, level + 1, out, ptr);\n ptr += stride;\n }\n }\n}\n\nfunction flattenArray (array, shape, type, out_) {\n var sz = 1;\n if (shape.length) {\n for (var i = 0; i < shape.length; ++i) {\n sz *= shape[i];\n }\n } else {\n sz = 0;\n }\n var out = out_ || pool.allocType(type, sz);\n switch (shape.length) {\n case 0:\n break\n case 1:\n flatten1D(array, shape[0], out);\n break\n case 2:\n flatten2D(array, shape[0], shape[1], out);\n break\n case 3:\n flatten3D(array, shape[0], shape[1], shape[2], out, 0);\n break\n default:\n flattenRec(array, shape, 0, out, 0);\n }\n return out\n}\n\nfunction arrayShape$1 (array_) {\n var shape = [];\n for (var array = array_; array.length; array = array[0]) {\n shape.push(array.length);\n }\n return shape\n}\n\nvar int8 = 5120;\nvar int16 = 5122;\nvar int32 = 5124;\nvar uint8 = 5121;\nvar uint16 = 5123;\nvar uint32 = 5125;\nvar float = 5126;\nvar float32 = 5126;\nvar glTypes = {\n\tint8: int8,\n\tint16: int16,\n\tint32: int32,\n\tuint8: uint8,\n\tuint16: uint16,\n\tuint32: uint32,\n\tfloat: float,\n\tfloat32: float32\n};\n\nvar dynamic$1 = 35048;\nvar stream = 35040;\nvar usageTypes = {\n\tdynamic: dynamic$1,\n\tstream: stream,\n\t\"static\": 35044\n};\n\nvar arrayFlatten = flattenUtils.flatten;\nvar arrayShape = flattenUtils.shape;\n\nvar GL_STATIC_DRAW = 0x88E4;\nvar GL_STREAM_DRAW = 0x88E0;\n\nvar GL_UNSIGNED_BYTE$1 = 5121;\nvar GL_FLOAT$1 = 5126;\n\nvar DTYPES_SIZES = [];\nDTYPES_SIZES[5120] = 1; // int8\nDTYPES_SIZES[5122] = 2; // int16\nDTYPES_SIZES[5124] = 4; // int32\nDTYPES_SIZES[5121] = 1; // uint8\nDTYPES_SIZES[5123] = 2; // uint16\nDTYPES_SIZES[5125] = 4; // uint32\nDTYPES_SIZES[5126] = 4; // float32\n\nfunction typedArrayCode (data) {\n return arrayTypes[Object.prototype.toString.call(data)] | 0\n}\n\nfunction copyArray (out, inp) {\n for (var i = 0; i < inp.length; ++i) {\n out[i] = inp[i];\n }\n}\n\nfunction transpose (\n result, data, shapeX, shapeY, strideX, strideY, offset) {\n var ptr = 0;\n for (var i = 0; i < shapeX; ++i) {\n for (var j = 0; j < shapeY; ++j) {\n result[ptr++] = data[strideX * i + strideY * j + offset];\n }\n }\n}\n\nfunction wrapBufferState (gl, stats, config) {\n var bufferCount = 0;\n var bufferSet = {};\n\n function REGLBuffer (type) {\n this.id = bufferCount++;\n this.buffer = gl.createBuffer();\n this.type = type;\n this.usage = GL_STATIC_DRAW;\n this.byteLength = 0;\n this.dimension = 1;\n this.dtype = GL_UNSIGNED_BYTE$1;\n\n this.persistentData = null;\n\n if (config.profile) {\n this.stats = {size: 0};\n }\n }\n\n REGLBuffer.prototype.bind = function () {\n gl.bindBuffer(this.type, this.buffer);\n };\n\n REGLBuffer.prototype.destroy = function () {\n destroy(this);\n };\n\n var streamPool = [];\n\n function createStream (type, data) {\n var buffer = streamPool.pop();\n if (!buffer) {\n buffer = new REGLBuffer(type);\n }\n buffer.bind();\n initBufferFromData(buffer, data, GL_STREAM_DRAW, 0, 1, false);\n return buffer\n }\n\n function destroyStream (stream$$1) {\n streamPool.push(stream$$1);\n }\n\n function initBufferFromTypedArray (buffer, data, usage) {\n buffer.byteLength = data.byteLength;\n gl.bufferData(buffer.type, data, usage);\n }\n\n function initBufferFromData (buffer, data, usage, dtype, dimension, persist) {\n var shape;\n buffer.usage = usage;\n if (Array.isArray(data)) {\n buffer.dtype = dtype || GL_FLOAT$1;\n if (data.length > 0) {\n var flatData;\n if (Array.isArray(data[0])) {\n shape = arrayShape(data);\n var dim = 1;\n for (var i = 1; i < shape.length; ++i) {\n dim *= shape[i];\n }\n buffer.dimension = dim;\n flatData = arrayFlatten(data, shape, buffer.dtype);\n initBufferFromTypedArray(buffer, flatData, usage);\n if (persist) {\n buffer.persistentData = flatData;\n } else {\n pool.freeType(flatData);\n }\n } else if (typeof data[0] === 'number') {\n buffer.dimension = dimension;\n var typedData = pool.allocType(buffer.dtype, data.length);\n copyArray(typedData, data);\n initBufferFromTypedArray(buffer, typedData, usage);\n if (persist) {\n buffer.persistentData = typedData;\n } else {\n pool.freeType(typedData);\n }\n } else if (isTypedArray(data[0])) {\n buffer.dimension = data[0].length;\n buffer.dtype = dtype || typedArrayCode(data[0]) || GL_FLOAT$1;\n flatData = arrayFlatten(\n data,\n [data.length, data[0].length],\n buffer.dtype);\n initBufferFromTypedArray(buffer, flatData, usage);\n if (persist) {\n buffer.persistentData = flatData;\n } else {\n pool.freeType(flatData);\n }\n } else {\n check$1.raise('invalid buffer data');\n }\n }\n } else if (isTypedArray(data)) {\n buffer.dtype = dtype || typedArrayCode(data);\n buffer.dimension = dimension;\n initBufferFromTypedArray(buffer, data, usage);\n if (persist) {\n buffer.persistentData = new Uint8Array(new Uint8Array(data.buffer));\n }\n } else if (isNDArrayLike(data)) {\n shape = data.shape;\n var stride = data.stride;\n var offset = data.offset;\n\n var shapeX = 0;\n var shapeY = 0;\n var strideX = 0;\n var strideY = 0;\n if (shape.length === 1) {\n shapeX = shape[0];\n shapeY = 1;\n strideX = stride[0];\n strideY = 0;\n } else if (shape.length === 2) {\n shapeX = shape[0];\n shapeY = shape[1];\n strideX = stride[0];\n strideY = stride[1];\n } else {\n check$1.raise('invalid shape');\n }\n\n buffer.dtype = dtype || typedArrayCode(data.data) || GL_FLOAT$1;\n buffer.dimension = shapeY;\n\n var transposeData = pool.allocType(buffer.dtype, shapeX * shapeY);\n transpose(transposeData,\n data.data,\n shapeX, shapeY,\n strideX, strideY,\n offset);\n initBufferFromTypedArray(buffer, transposeData, usage);\n if (persist) {\n buffer.persistentData = transposeData;\n } else {\n pool.freeType(transposeData);\n }\n } else {\n check$1.raise('invalid buffer data');\n }\n }\n\n function destroy (buffer) {\n stats.bufferCount--;\n\n var handle = buffer.buffer;\n check$1(handle, 'buffer must not be deleted already');\n gl.deleteBuffer(handle);\n buffer.buffer = null;\n delete bufferSet[buffer.id];\n }\n\n function createBuffer (options, type, deferInit, persistent) {\n stats.bufferCount++;\n\n var buffer = new REGLBuffer(type);\n bufferSet[buffer.id] = buffer;\n\n function reglBuffer (options) {\n var usage = GL_STATIC_DRAW;\n var data = null;\n var byteLength = 0;\n var dtype = 0;\n var dimension = 1;\n if (Array.isArray(options) ||\n isTypedArray(options) ||\n isNDArrayLike(options)) {\n data = options;\n } else if (typeof options === 'number') {\n byteLength = options | 0;\n } else if (options) {\n check$1.type(\n options, 'object',\n 'buffer arguments must be an object, a number or an array');\n\n if ('data' in options) {\n check$1(\n data === null ||\n Array.isArray(data) ||\n isTypedArray(data) ||\n isNDArrayLike(data),\n 'invalid data for buffer');\n data = options.data;\n }\n\n if ('usage' in options) {\n check$1.parameter(options.usage, usageTypes, 'invalid buffer usage');\n usage = usageTypes[options.usage];\n }\n\n if ('type' in options) {\n check$1.parameter(options.type, glTypes, 'invalid buffer type');\n dtype = glTypes[options.type];\n }\n\n if ('dimension' in options) {\n check$1.type(options.dimension, 'number', 'invalid dimension');\n dimension = options.dimension | 0;\n }\n\n if ('length' in options) {\n check$1.nni(byteLength, 'buffer length must be a nonnegative integer');\n byteLength = options.length | 0;\n }\n }\n\n buffer.bind();\n if (!data) {\n gl.bufferData(buffer.type, byteLength, usage);\n buffer.dtype = dtype || GL_UNSIGNED_BYTE$1;\n buffer.usage = usage;\n buffer.dimension = dimension;\n buffer.byteLength = byteLength;\n } else {\n initBufferFromData(buffer, data, usage, dtype, dimension, persistent);\n }\n\n if (config.profile) {\n buffer.stats.size = buffer.byteLength * DTYPES_SIZES[buffer.dtype];\n }\n\n return reglBuffer\n }\n\n function setSubData (data, offset) {\n check$1(offset + data.byteLength <= buffer.byteLength,\n 'invalid buffer subdata call, buffer is too small. ' + ' Can\\'t write data of size ' + data.byteLength + ' starting from offset ' + offset + ' to a buffer of size ' + buffer.byteLength);\n\n gl.bufferSubData(buffer.type, offset, data);\n }\n\n function subdata (data, offset_) {\n var offset = (offset_ || 0) | 0;\n var shape;\n buffer.bind();\n if (Array.isArray(data)) {\n if (data.length > 0) {\n if (typeof data[0] === 'number') {\n var converted = pool.allocType(buffer.dtype, data.length);\n copyArray(converted, data);\n setSubData(converted, offset);\n pool.freeType(converted);\n } else if (Array.isArray(data[0]) || isTypedArray(data[0])) {\n shape = arrayShape(data);\n var flatData = arrayFlatten(data, shape, buffer.dtype);\n setSubData(flatData, offset);\n pool.freeType(flatData);\n } else {\n check$1.raise('invalid buffer data');\n }\n }\n } else if (isTypedArray(data)) {\n setSubData(data, offset);\n } else if (isNDArrayLike(data)) {\n shape = data.shape;\n var stride = data.stride;\n\n var shapeX = 0;\n var shapeY = 0;\n var strideX = 0;\n var strideY = 0;\n if (shape.length === 1) {\n shapeX = shape[0];\n shapeY = 1;\n strideX = stride[0];\n strideY = 0;\n } else if (shape.length === 2) {\n shapeX = shape[0];\n shapeY = shape[1];\n strideX = stride[0];\n strideY = stride[1];\n } else {\n check$1.raise('invalid shape');\n }\n var dtype = Array.isArray(data.data)\n ? buffer.dtype\n : typedArrayCode(data.data);\n\n var transposeData = pool.allocType(dtype, shapeX * shapeY);\n transpose(transposeData,\n data.data,\n shapeX, shapeY,\n strideX, strideY,\n data.offset);\n setSubData(transposeData, offset);\n pool.freeType(transposeData);\n } else {\n check$1.raise('invalid data for buffer subdata');\n }\n return reglBuffer\n }\n\n if (!deferInit) {\n reglBuffer(options);\n }\n\n reglBuffer._reglType = 'buffer';\n reglBuffer._buffer = buffer;\n reglBuffer.subdata = subdata;\n if (config.profile) {\n reglBuffer.stats = buffer.stats;\n }\n reglBuffer.destroy = function () { destroy(buffer); };\n\n return reglBuffer\n }\n\n function restoreBuffers () {\n values(bufferSet).forEach(function (buffer) {\n buffer.buffer = gl.createBuffer();\n gl.bindBuffer(buffer.type, buffer.buffer);\n gl.bufferData(\n buffer.type, buffer.persistentData || buffer.byteLength, buffer.usage);\n });\n }\n\n if (config.profile) {\n stats.getTotalBufferSize = function () {\n var total = 0;\n // TODO: Right now, the streams are not part of the total count.\n Object.keys(bufferSet).forEach(function (key) {\n total += bufferSet[key].stats.size;\n });\n return total\n };\n }\n\n return {\n create: createBuffer,\n\n createStream: createStream,\n destroyStream: destroyStream,\n\n clear: function () {\n values(bufferSet).forEach(destroy);\n streamPool.forEach(destroy);\n },\n\n getBuffer: function (wrapper) {\n if (wrapper && wrapper._buffer instanceof REGLBuffer) {\n return wrapper._buffer\n }\n return null\n },\n\n restore: restoreBuffers,\n\n _initBuffer: initBufferFromData\n }\n}\n\nvar points = 0;\nvar point = 0;\nvar lines = 1;\nvar line = 1;\nvar triangles = 4;\nvar triangle = 4;\nvar primTypes = {\n\tpoints: points,\n\tpoint: point,\n\tlines: lines,\n\tline: line,\n\ttriangles: triangles,\n\ttriangle: triangle,\n\t\"line loop\": 2,\n\t\"line strip\": 3,\n\t\"triangle strip\": 5,\n\t\"triangle fan\": 6\n};\n\nvar GL_POINTS = 0;\nvar GL_LINES = 1;\nvar GL_TRIANGLES = 4;\n\nvar GL_BYTE$2 = 5120;\nvar GL_UNSIGNED_BYTE$3 = 5121;\nvar GL_SHORT$2 = 5122;\nvar GL_UNSIGNED_SHORT$2 = 5123;\nvar GL_INT$2 = 5124;\nvar GL_UNSIGNED_INT$2 = 5125;\n\nvar GL_ELEMENT_ARRAY_BUFFER = 34963;\n\nvar GL_STREAM_DRAW$1 = 0x88E0;\nvar GL_STATIC_DRAW$1 = 0x88E4;\n\nfunction wrapElementsState (gl, extensions, bufferState, stats) {\n var elementSet = {};\n var elementCount = 0;\n\n var elementTypes = {\n 'uint8': GL_UNSIGNED_BYTE$3,\n 'uint16': GL_UNSIGNED_SHORT$2\n };\n\n if (extensions.oes_element_index_uint) {\n elementTypes.uint32 = GL_UNSIGNED_INT$2;\n }\n\n function REGLElementBuffer (buffer) {\n this.id = elementCount++;\n elementSet[this.id] = this;\n this.buffer = buffer;\n this.primType = GL_TRIANGLES;\n this.vertCount = 0;\n this.type = 0;\n }\n\n REGLElementBuffer.prototype.bind = function () {\n this.buffer.bind();\n };\n\n var bufferPool = [];\n\n function createElementStream (data) {\n var result = bufferPool.pop();\n if (!result) {\n result = new REGLElementBuffer(bufferState.create(\n null,\n GL_ELEMENT_ARRAY_BUFFER,\n true,\n false)._buffer);\n }\n initElements(result, data, GL_STREAM_DRAW$1, -1, -1, 0, 0);\n return result\n }\n\n function destroyElementStream (elements) {\n bufferPool.push(elements);\n }\n\n function initElements (\n elements,\n data,\n usage,\n prim,\n count,\n byteLength,\n type) {\n elements.buffer.bind();\n if (data) {\n var predictedType = type;\n if (!type && (\n !isTypedArray(data) ||\n (isNDArrayLike(data) && !isTypedArray(data.data)))) {\n predictedType = extensions.oes_element_index_uint\n ? GL_UNSIGNED_INT$2\n : GL_UNSIGNED_SHORT$2;\n }\n bufferState._initBuffer(\n elements.buffer,\n data,\n usage,\n predictedType,\n 3);\n } else {\n gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, byteLength, usage);\n elements.buffer.dtype = dtype || GL_UNSIGNED_BYTE$3;\n elements.buffer.usage = usage;\n elements.buffer.dimension = 3;\n elements.buffer.byteLength = byteLength;\n }\n\n var dtype = type;\n if (!type) {\n switch (elements.buffer.dtype) {\n case GL_UNSIGNED_BYTE$3:\n case GL_BYTE$2:\n dtype = GL_UNSIGNED_BYTE$3;\n break\n\n case GL_UNSIGNED_SHORT$2:\n case GL_SHORT$2:\n dtype = GL_UNSIGNED_SHORT$2;\n break\n\n case GL_UNSIGNED_INT$2:\n case GL_INT$2:\n dtype = GL_UNSIGNED_INT$2;\n break\n\n default:\n check$1.raise('unsupported type for element array');\n }\n elements.buffer.dtype = dtype;\n }\n elements.type = dtype;\n\n // Check oes_element_index_uint extension\n check$1(\n dtype !== GL_UNSIGNED_INT$2 ||\n !!extensions.oes_element_index_uint,\n '32 bit element buffers not supported, enable oes_element_index_uint first');\n\n // try to guess default primitive type and arguments\n var vertCount = count;\n if (vertCount < 0) {\n vertCount = elements.buffer.byteLength;\n if (dtype === GL_UNSIGNED_SHORT$2) {\n vertCount >>= 1;\n } else if (dtype === GL_UNSIGNED_INT$2) {\n vertCount >>= 2;\n }\n }\n elements.vertCount = vertCount;\n\n // try to guess primitive type from cell dimension\n var primType = prim;\n if (prim < 0) {\n primType = GL_TRIANGLES;\n var dimension = elements.buffer.dimension;\n if (dimension === 1) primType = GL_POINTS;\n if (dimension === 2) primType = GL_LINES;\n if (dimension === 3) primType = GL_TRIANGLES;\n }\n elements.primType = primType;\n }\n\n function destroyElements (elements) {\n stats.elementsCount--;\n\n check$1(elements.buffer !== null, 'must not double destroy elements');\n delete elementSet[elements.id];\n elements.buffer.destroy();\n elements.buffer = null;\n }\n\n function createElements (options, persistent) {\n var buffer = bufferState.create(null, GL_ELEMENT_ARRAY_BUFFER, true);\n var elements = new REGLElementBuffer(buffer._buffer);\n stats.elementsCount++;\n\n function reglElements (options) {\n if (!options) {\n buffer();\n elements.primType = GL_TRIANGLES;\n elements.vertCount = 0;\n elements.type = GL_UNSIGNED_BYTE$3;\n } else if (typeof options === 'number') {\n buffer(options);\n elements.primType = GL_TRIANGLES;\n elements.vertCount = options | 0;\n elements.type = GL_UNSIGNED_BYTE$3;\n } else {\n var data = null;\n var usage = GL_STATIC_DRAW$1;\n var primType = -1;\n var vertCount = -1;\n var byteLength = 0;\n var dtype = 0;\n if (Array.isArray(options) ||\n isTypedArray(options) ||\n isNDArrayLike(options)) {\n data = options;\n } else {\n check$1.type(options, 'object', 'invalid arguments for elements');\n if ('data' in options) {\n data = options.data;\n check$1(\n Array.isArray(data) ||\n isTypedArray(data) ||\n isNDArrayLike(data),\n 'invalid data for element buffer');\n }\n if ('usage' in options) {\n check$1.parameter(\n options.usage,\n usageTypes,\n 'invalid element buffer usage');\n usage = usageTypes[options.usage];\n }\n if ('primitive' in options) {\n check$1.parameter(\n options.primitive,\n primTypes,\n 'invalid element buffer primitive');\n primType = primTypes[options.primitive];\n }\n if ('count' in options) {\n check$1(\n typeof options.count === 'number' && options.count >= 0,\n 'invalid vertex count for elements');\n vertCount = options.count | 0;\n }\n if ('type' in options) {\n check$1.parameter(\n options.type,\n elementTypes,\n 'invalid buffer type');\n dtype = elementTypes[options.type];\n }\n if ('length' in options) {\n byteLength = options.length | 0;\n } else {\n byteLength = vertCount;\n if (dtype === GL_UNSIGNED_SHORT$2 || dtype === GL_SHORT$2) {\n byteLength *= 2;\n } else if (dtype === GL_UNSIGNED_INT$2 || dtype === GL_INT$2) {\n byteLength *= 4;\n }\n }\n }\n initElements(\n elements,\n data,\n usage,\n primType,\n vertCount,\n byteLength,\n dtype);\n }\n\n return reglElements\n }\n\n reglElements(options);\n\n reglElements._reglType = 'elements';\n reglElements._elements = elements;\n reglElements.subdata = function (data, offset) {\n buffer.subdata(data, offset);\n return reglElements\n };\n reglElements.destroy = function () {\n destroyElements(elements);\n };\n\n return reglElements\n }\n\n return {\n create: createElements,\n createStream: createElementStream,\n destroyStream: destroyElementStream,\n getElements: function (elements) {\n if (typeof elements === 'function' &&\n elements._elements instanceof REGLElementBuffer) {\n return elements._elements\n }\n return null\n },\n clear: function () {\n values(elementSet).forEach(destroyElements);\n }\n }\n}\n\nvar FLOAT = new Float32Array(1);\nvar INT = new Uint32Array(FLOAT.buffer);\n\nvar GL_UNSIGNED_SHORT$4 = 5123;\n\nfunction convertToHalfFloat (array) {\n var ushorts = pool.allocType(GL_UNSIGNED_SHORT$4, array.length);\n\n for (var i = 0; i < array.length; ++i) {\n if (isNaN(array[i])) {\n ushorts[i] = 0xffff;\n } else if (array[i] === Infinity) {\n ushorts[i] = 0x7c00;\n } else if (array[i] === -Infinity) {\n ushorts[i] = 0xfc00;\n } else {\n FLOAT[0] = array[i];\n var x = INT[0];\n\n var sgn = (x >>> 31) << 15;\n var exp = ((x << 1) >>> 24) - 127;\n var frac = (x >> 13) & ((1 << 10) - 1);\n\n if (exp < -24) {\n // round non-representable denormals to 0\n ushorts[i] = sgn;\n } else if (exp < -14) {\n // handle denormals\n var s = -14 - exp;\n ushorts[i] = sgn + ((frac + (1 << 10)) >> s);\n } else if (exp > 15) {\n // round overflow to +/- Infinity\n ushorts[i] = sgn + 0x7c00;\n } else {\n // otherwise convert directly\n ushorts[i] = sgn + ((exp + 15) << 10) + frac;\n }\n }\n }\n\n return ushorts\n}\n\nfunction isArrayLike (s) {\n return Array.isArray(s) || isTypedArray(s)\n}\n\nvar GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;\n\nvar GL_TEXTURE_2D = 0x0DE1;\nvar GL_TEXTURE_CUBE_MAP = 0x8513;\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;\n\nvar GL_RGBA = 0x1908;\nvar GL_ALPHA = 0x1906;\nvar GL_RGB = 0x1907;\nvar GL_LUMINANCE = 0x1909;\nvar GL_LUMINANCE_ALPHA = 0x190A;\n\nvar GL_RGBA4 = 0x8056;\nvar GL_RGB5_A1 = 0x8057;\nvar GL_RGB565 = 0x8D62;\n\nvar GL_UNSIGNED_SHORT_4_4_4_4$1 = 0x8033;\nvar GL_UNSIGNED_SHORT_5_5_5_1$1 = 0x8034;\nvar GL_UNSIGNED_SHORT_5_6_5$1 = 0x8363;\nvar GL_UNSIGNED_INT_24_8_WEBGL$1 = 0x84FA;\n\nvar GL_DEPTH_COMPONENT = 0x1902;\nvar GL_DEPTH_STENCIL = 0x84F9;\n\nvar GL_SRGB_EXT = 0x8C40;\nvar GL_SRGB_ALPHA_EXT = 0x8C42;\n\nvar GL_HALF_FLOAT_OES$1 = 0x8D61;\n\nvar GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;\nvar GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;\nvar GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;\nvar GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;\n\nvar GL_COMPRESSED_RGB_ATC_WEBGL = 0x8C92;\nvar GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93;\nvar GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE;\n\nvar GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;\nvar GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;\nvar GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;\nvar GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;\n\nvar GL_COMPRESSED_RGB_ETC1_WEBGL = 0x8D64;\n\nvar GL_UNSIGNED_BYTE$4 = 0x1401;\nvar GL_UNSIGNED_SHORT$3 = 0x1403;\nvar GL_UNSIGNED_INT$3 = 0x1405;\nvar GL_FLOAT$3 = 0x1406;\n\nvar GL_TEXTURE_WRAP_S = 0x2802;\nvar GL_TEXTURE_WRAP_T = 0x2803;\n\nvar GL_REPEAT = 0x2901;\nvar GL_CLAMP_TO_EDGE$1 = 0x812F;\nvar GL_MIRRORED_REPEAT = 0x8370;\n\nvar GL_TEXTURE_MAG_FILTER = 0x2800;\nvar GL_TEXTURE_MIN_FILTER = 0x2801;\n\nvar GL_NEAREST$1 = 0x2600;\nvar GL_LINEAR = 0x2601;\nvar GL_NEAREST_MIPMAP_NEAREST$1 = 0x2700;\nvar GL_LINEAR_MIPMAP_NEAREST$1 = 0x2701;\nvar GL_NEAREST_MIPMAP_LINEAR$1 = 0x2702;\nvar GL_LINEAR_MIPMAP_LINEAR$1 = 0x2703;\n\nvar GL_GENERATE_MIPMAP_HINT = 0x8192;\nvar GL_DONT_CARE = 0x1100;\nvar GL_FASTEST = 0x1101;\nvar GL_NICEST = 0x1102;\n\nvar GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;\n\nvar GL_UNPACK_ALIGNMENT = 0x0CF5;\nvar GL_UNPACK_FLIP_Y_WEBGL = 0x9240;\nvar GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;\nvar GL_UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;\n\nvar GL_BROWSER_DEFAULT_WEBGL = 0x9244;\n\nvar GL_TEXTURE0 = 0x84C0;\n\nvar MIPMAP_FILTERS = [\n GL_NEAREST_MIPMAP_NEAREST$1,\n GL_NEAREST_MIPMAP_LINEAR$1,\n GL_LINEAR_MIPMAP_NEAREST$1,\n GL_LINEAR_MIPMAP_LINEAR$1\n];\n\nvar CHANNELS_FORMAT = [\n 0,\n GL_LUMINANCE,\n GL_LUMINANCE_ALPHA,\n GL_RGB,\n GL_RGBA\n];\n\nvar FORMAT_CHANNELS = {};\nFORMAT_CHANNELS[GL_LUMINANCE] =\nFORMAT_CHANNELS[GL_ALPHA] =\nFORMAT_CHANNELS[GL_DEPTH_COMPONENT] = 1;\nFORMAT_CHANNELS[GL_DEPTH_STENCIL] =\nFORMAT_CHANNELS[GL_LUMINANCE_ALPHA] = 2;\nFORMAT_CHANNELS[GL_RGB] =\nFORMAT_CHANNELS[GL_SRGB_EXT] = 3;\nFORMAT_CHANNELS[GL_RGBA] =\nFORMAT_CHANNELS[GL_SRGB_ALPHA_EXT] = 4;\n\nfunction objectName (str) {\n return '[object ' + str + ']'\n}\n\nvar CANVAS_CLASS = objectName('HTMLCanvasElement');\nvar CONTEXT2D_CLASS = objectName('CanvasRenderingContext2D');\nvar IMAGE_CLASS = objectName('HTMLImageElement');\nvar VIDEO_CLASS = objectName('HTMLVideoElement');\n\nvar PIXEL_CLASSES = Object.keys(arrayTypes).concat([\n CANVAS_CLASS,\n CONTEXT2D_CLASS,\n IMAGE_CLASS,\n VIDEO_CLASS\n]);\n\n// for every texture type, store\n// the size in bytes.\nvar TYPE_SIZES = [];\nTYPE_SIZES[GL_UNSIGNED_BYTE$4] = 1;\nTYPE_SIZES[GL_FLOAT$3] = 4;\nTYPE_SIZES[GL_HALF_FLOAT_OES$1] = 2;\n\nTYPE_SIZES[GL_UNSIGNED_SHORT$3] = 2;\nTYPE_SIZES[GL_UNSIGNED_INT$3] = 4;\n\nvar FORMAT_SIZES_SPECIAL = [];\nFORMAT_SIZES_SPECIAL[GL_RGBA4] = 2;\nFORMAT_SIZES_SPECIAL[GL_RGB5_A1] = 2;\nFORMAT_SIZES_SPECIAL[GL_RGB565] = 2;\nFORMAT_SIZES_SPECIAL[GL_DEPTH_STENCIL] = 4;\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_S3TC_DXT1_EXT] = 0.5;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT] = 0.5;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT] = 1;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT] = 1;\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ATC_WEBGL] = 0.5;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 1;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 1;\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 0.5;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 0.25;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 0.5;\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 0.25;\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ETC1_WEBGL] = 0.5;\n\nfunction isNumericArray (arr) {\n return (\n Array.isArray(arr) &&\n (arr.length === 0 ||\n typeof arr[0] === 'number'))\n}\n\nfunction isRectArray (arr) {\n if (!Array.isArray(arr)) {\n return false\n }\n var width = arr.length;\n if (width === 0 || !isArrayLike(arr[0])) {\n return false\n }\n return true\n}\n\nfunction classString (x) {\n return Object.prototype.toString.call(x)\n}\n\nfunction isCanvasElement (object) {\n return classString(object) === CANVAS_CLASS\n}\n\nfunction isContext2D (object) {\n return classString(object) === CONTEXT2D_CLASS\n}\n\nfunction isImageElement (object) {\n return classString(object) === IMAGE_CLASS\n}\n\nfunction isVideoElement (object) {\n return classString(object) === VIDEO_CLASS\n}\n\nfunction isPixelData (object) {\n if (!object) {\n return false\n }\n var className = classString(object);\n if (PIXEL_CLASSES.indexOf(className) >= 0) {\n return true\n }\n return (\n isNumericArray(object) ||\n isRectArray(object) ||\n isNDArrayLike(object))\n}\n\nfunction typedArrayCode$1 (data) {\n return arrayTypes[Object.prototype.toString.call(data)] | 0\n}\n\nfunction convertData (result, data) {\n var n = data.length;\n switch (result.type) {\n case GL_UNSIGNED_BYTE$4:\n case GL_UNSIGNED_SHORT$3:\n case GL_UNSIGNED_INT$3:\n case GL_FLOAT$3:\n var converted = pool.allocType(result.type, n);\n converted.set(data);\n result.data = converted;\n break\n\n case GL_HALF_FLOAT_OES$1:\n result.data = convertToHalfFloat(data);\n break\n\n default:\n check$1.raise('unsupported texture type, must specify a typed array');\n }\n}\n\nfunction preConvert (image, n) {\n return pool.allocType(\n image.type === GL_HALF_FLOAT_OES$1\n ? GL_FLOAT$3\n : image.type, n)\n}\n\nfunction postConvert (image, data) {\n if (image.type === GL_HALF_FLOAT_OES$1) {\n image.data = convertToHalfFloat(data);\n pool.freeType(data);\n } else {\n image.data = data;\n }\n}\n\nfunction transposeData (image, array, strideX, strideY, strideC, offset) {\n var w = image.width;\n var h = image.height;\n var c = image.channels;\n var n = w * h * c;\n var data = preConvert(image, n);\n\n var p = 0;\n for (var i = 0; i < h; ++i) {\n for (var j = 0; j < w; ++j) {\n for (var k = 0; k < c; ++k) {\n data[p++] = array[strideX * j + strideY * i + strideC * k + offset];\n }\n }\n }\n\n postConvert(image, data);\n}\n\nfunction getTextureSize (format, type, width, height, isMipmap, isCube) {\n var s;\n if (typeof FORMAT_SIZES_SPECIAL[format] !== 'undefined') {\n // we have a special array for dealing with weird color formats such as RGB5A1\n s = FORMAT_SIZES_SPECIAL[format];\n } else {\n s = FORMAT_CHANNELS[format] * TYPE_SIZES[type];\n }\n\n if (isCube) {\n s *= 6;\n }\n\n if (isMipmap) {\n // compute the total size of all the mipmaps.\n var total = 0;\n\n var w = width;\n while (w >= 1) {\n // we can only use mipmaps on a square image,\n // so we can simply use the width and ignore the height:\n total += s * w * w;\n w /= 2;\n }\n return total\n } else {\n return s * width * height\n }\n}\n\nfunction createTextureSet (\n gl, extensions, limits, reglPoll, contextState, stats, config) {\n // -------------------------------------------------------\n // Initialize constants and parameter tables here\n // -------------------------------------------------------\n var mipmapHint = {\n \"don't care\": GL_DONT_CARE,\n 'dont care': GL_DONT_CARE,\n 'nice': GL_NICEST,\n 'fast': GL_FASTEST\n };\n\n var wrapModes = {\n 'repeat': GL_REPEAT,\n 'clamp': GL_CLAMP_TO_EDGE$1,\n 'mirror': GL_MIRRORED_REPEAT\n };\n\n var magFilters = {\n 'nearest': GL_NEAREST$1,\n 'linear': GL_LINEAR\n };\n\n var minFilters = extend({\n 'mipmap': GL_LINEAR_MIPMAP_LINEAR$1,\n 'nearest mipmap nearest': GL_NEAREST_MIPMAP_NEAREST$1,\n 'linear mipmap nearest': GL_LINEAR_MIPMAP_NEAREST$1,\n 'nearest mipmap linear': GL_NEAREST_MIPMAP_LINEAR$1,\n 'linear mipmap linear': GL_LINEAR_MIPMAP_LINEAR$1\n }, magFilters);\n\n var colorSpace = {\n 'none': 0,\n 'browser': GL_BROWSER_DEFAULT_WEBGL\n };\n\n var textureTypes = {\n 'uint8': GL_UNSIGNED_BYTE$4,\n 'rgba4': GL_UNSIGNED_SHORT_4_4_4_4$1,\n 'rgb565': GL_UNSIGNED_SHORT_5_6_5$1,\n 'rgb5 a1': GL_UNSIGNED_SHORT_5_5_5_1$1\n };\n\n var textureFormats = {\n 'alpha': GL_ALPHA,\n 'luminance': GL_LUMINANCE,\n 'luminance alpha': GL_LUMINANCE_ALPHA,\n 'rgb': GL_RGB,\n 'rgba': GL_RGBA,\n 'rgba4': GL_RGBA4,\n 'rgb5 a1': GL_RGB5_A1,\n 'rgb565': GL_RGB565\n };\n\n var compressedTextureFormats = {};\n\n if (extensions.ext_srgb) {\n textureFormats.srgb = GL_SRGB_EXT;\n textureFormats.srgba = GL_SRGB_ALPHA_EXT;\n }\n\n if (extensions.oes_texture_float) {\n textureTypes.float32 = textureTypes.float = GL_FLOAT$3;\n }\n\n if (extensions.oes_texture_half_float) {\n textureTypes['float16'] = textureTypes['half float'] = GL_HALF_FLOAT_OES$1;\n }\n\n if (extensions.webgl_depth_texture) {\n extend(textureFormats, {\n 'depth': GL_DEPTH_COMPONENT,\n 'depth stencil': GL_DEPTH_STENCIL\n });\n\n extend(textureTypes, {\n 'uint16': GL_UNSIGNED_SHORT$3,\n 'uint32': GL_UNSIGNED_INT$3,\n 'depth stencil': GL_UNSIGNED_INT_24_8_WEBGL$1\n });\n }\n\n if (extensions.webgl_compressed_texture_s3tc) {\n extend(compressedTextureFormats, {\n 'rgb s3tc dxt1': GL_COMPRESSED_RGB_S3TC_DXT1_EXT,\n 'rgba s3tc dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,\n 'rgba s3tc dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,\n 'rgba s3tc dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\n });\n }\n\n if (extensions.webgl_compressed_texture_atc) {\n extend(compressedTextureFormats, {\n 'rgb atc': GL_COMPRESSED_RGB_ATC_WEBGL,\n 'rgba atc explicit alpha': GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,\n 'rgba atc interpolated alpha': GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL\n });\n }\n\n if (extensions.webgl_compressed_texture_pvrtc) {\n extend(compressedTextureFormats, {\n 'rgb pvrtc 4bppv1': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,\n 'rgb pvrtc 2bppv1': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,\n 'rgba pvrtc 4bppv1': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,\n 'rgba pvrtc 2bppv1': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG\n });\n }\n\n if (extensions.webgl_compressed_texture_etc1) {\n compressedTextureFormats['rgb etc1'] = GL_COMPRESSED_RGB_ETC1_WEBGL;\n }\n\n // Copy over all texture formats\n var supportedCompressedFormats = Array.prototype.slice.call(\n gl.getParameter(GL_COMPRESSED_TEXTURE_FORMATS));\n Object.keys(compressedTextureFormats).forEach(function (name) {\n var format = compressedTextureFormats[name];\n if (supportedCompressedFormats.indexOf(format) >= 0) {\n textureFormats[name] = format;\n }\n });\n\n var supportedFormats = Object.keys(textureFormats);\n limits.textureFormats = supportedFormats;\n\n // associate with every format string its\n // corresponding GL-value.\n var textureFormatsInvert = [];\n Object.keys(textureFormats).forEach(function (key) {\n var val = textureFormats[key];\n textureFormatsInvert[val] = key;\n });\n\n // associate with every type string its\n // corresponding GL-value.\n var textureTypesInvert = [];\n Object.keys(textureTypes).forEach(function (key) {\n var val = textureTypes[key];\n textureTypesInvert[val] = key;\n });\n\n var magFiltersInvert = [];\n Object.keys(magFilters).forEach(function (key) {\n var val = magFilters[key];\n magFiltersInvert[val] = key;\n });\n\n var minFiltersInvert = [];\n Object.keys(minFilters).forEach(function (key) {\n var val = minFilters[key];\n minFiltersInvert[val] = key;\n });\n\n var wrapModesInvert = [];\n Object.keys(wrapModes).forEach(function (key) {\n var val = wrapModes[key];\n wrapModesInvert[val] = key;\n });\n\n // colorFormats[] gives the format (channels) associated to an\n // internalformat\n var colorFormats = supportedFormats.reduce(function (color, key) {\n var glenum = textureFormats[key];\n if (glenum === GL_LUMINANCE ||\n glenum === GL_ALPHA ||\n glenum === GL_LUMINANCE ||\n glenum === GL_LUMINANCE_ALPHA ||\n glenum === GL_DEPTH_COMPONENT ||\n glenum === GL_DEPTH_STENCIL) {\n color[glenum] = glenum;\n } else if (glenum === GL_RGB5_A1 || key.indexOf('rgba') >= 0) {\n color[glenum] = GL_RGBA;\n } else {\n color[glenum] = GL_RGB;\n }\n return color\n }, {});\n\n function TexFlags () {\n // format info\n this.internalformat = GL_RGBA;\n this.format = GL_RGBA;\n this.type = GL_UNSIGNED_BYTE$4;\n this.compressed = false;\n\n // pixel storage\n this.premultiplyAlpha = false;\n this.flipY = false;\n this.unpackAlignment = 1;\n this.colorSpace = 0;\n\n // shape info\n this.width = 0;\n this.height = 0;\n this.channels = 0;\n }\n\n function copyFlags (result, other) {\n result.internalformat = other.internalformat;\n result.format = other.format;\n result.type = other.type;\n result.compressed = other.compressed;\n\n result.premultiplyAlpha = other.premultiplyAlpha;\n result.flipY = other.flipY;\n result.unpackAlignment = other.unpackAlignment;\n result.colorSpace = other.colorSpace;\n\n result.width = other.width;\n result.height = other.height;\n result.channels = other.channels;\n }\n\n function parseFlags (flags, options) {\n if (typeof options !== 'object' || !options) {\n return\n }\n\n if ('premultiplyAlpha' in options) {\n check$1.type(options.premultiplyAlpha, 'boolean',\n 'invalid premultiplyAlpha');\n flags.premultiplyAlpha = options.premultiplyAlpha;\n }\n\n if ('flipY' in options) {\n check$1.type(options.flipY, 'boolean',\n 'invalid texture flip');\n flags.flipY = options.flipY;\n }\n\n if ('alignment' in options) {\n check$1.oneOf(options.alignment, [1, 2, 4, 8],\n 'invalid texture unpack alignment');\n flags.unpackAlignment = options.alignment;\n }\n\n if ('colorSpace' in options) {\n check$1.parameter(options.colorSpace, colorSpace,\n 'invalid colorSpace');\n flags.colorSpace = colorSpace[options.colorSpace];\n }\n\n if ('type' in options) {\n var type = options.type;\n check$1(extensions.oes_texture_float ||\n !(type === 'float' || type === 'float32'),\n 'you must enable the OES_texture_float extension in order to use floating point textures.');\n check$1(extensions.oes_texture_half_float ||\n !(type === 'half float' || type === 'float16'),\n 'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.');\n check$1(extensions.webgl_depth_texture ||\n !(type === 'uint16' || type === 'uint32' || type === 'depth stencil'),\n 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.');\n check$1.parameter(type, textureTypes,\n 'invalid texture type');\n flags.type = textureTypes[type];\n }\n\n var w = flags.width;\n var h = flags.height;\n var c = flags.channels;\n var hasChannels = false;\n if ('shape' in options) {\n check$1(Array.isArray(options.shape) && options.shape.length >= 2,\n 'shape must be an array');\n w = options.shape[0];\n h = options.shape[1];\n if (options.shape.length === 3) {\n c = options.shape[2];\n check$1(c > 0 && c <= 4, 'invalid number of channels');\n hasChannels = true;\n }\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width');\n check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height');\n } else {\n if ('radius' in options) {\n w = h = options.radius;\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid radius');\n }\n if ('width' in options) {\n w = options.width;\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width');\n }\n if ('height' in options) {\n h = options.height;\n check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height');\n }\n if ('channels' in options) {\n c = options.channels;\n check$1(c > 0 && c <= 4, 'invalid number of channels');\n hasChannels = true;\n }\n }\n flags.width = w | 0;\n flags.height = h | 0;\n flags.channels = c | 0;\n\n var hasFormat = false;\n if ('format' in options) {\n var formatStr = options.format;\n check$1(extensions.webgl_depth_texture ||\n !(formatStr === 'depth' || formatStr === 'depth stencil'),\n 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.');\n check$1.parameter(formatStr, textureFormats,\n 'invalid texture format');\n var internalformat = flags.internalformat = textureFormats[formatStr];\n flags.format = colorFormats[internalformat];\n if (formatStr in textureTypes) {\n if (!('type' in options)) {\n flags.type = textureTypes[formatStr];\n }\n }\n if (formatStr in compressedTextureFormats) {\n flags.compressed = true;\n }\n hasFormat = true;\n }\n\n // Reconcile channels and format\n if (!hasChannels && hasFormat) {\n flags.channels = FORMAT_CHANNELS[flags.format];\n } else if (hasChannels && !hasFormat) {\n if (flags.channels !== CHANNELS_FORMAT[flags.format]) {\n flags.format = flags.internalformat = CHANNELS_FORMAT[flags.channels];\n }\n } else if (hasFormat && hasChannels) {\n check$1(\n flags.channels === FORMAT_CHANNELS[flags.format],\n 'number of channels inconsistent with specified format');\n }\n }\n\n function setFlags (flags) {\n gl.pixelStorei(GL_UNPACK_FLIP_Y_WEBGL, flags.flipY);\n gl.pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL, flags.premultiplyAlpha);\n gl.pixelStorei(GL_UNPACK_COLORSPACE_CONVERSION_WEBGL, flags.colorSpace);\n gl.pixelStorei(GL_UNPACK_ALIGNMENT, flags.unpackAlignment);\n }\n\n // -------------------------------------------------------\n // Tex image data\n // -------------------------------------------------------\n function TexImage () {\n TexFlags.call(this);\n\n this.xOffset = 0;\n this.yOffset = 0;\n\n // data\n this.data = null;\n this.needsFree = false;\n\n // html element\n this.element = null;\n\n // copyTexImage info\n this.needsCopy = false;\n }\n\n function parseImage (image, options) {\n var data = null;\n if (isPixelData(options)) {\n data = options;\n } else if (options) {\n check$1.type(options, 'object', 'invalid pixel data type');\n parseFlags(image, options);\n if ('x' in options) {\n image.xOffset = options.x | 0;\n }\n if ('y' in options) {\n image.yOffset = options.y | 0;\n }\n if (isPixelData(options.data)) {\n data = options.data;\n }\n }\n\n check$1(\n !image.compressed ||\n data instanceof Uint8Array,\n 'compressed texture data must be stored in a uint8array');\n\n if (options.copy) {\n check$1(!data, 'can not specify copy and data field for the same texture');\n var viewW = contextState.viewportWidth;\n var viewH = contextState.viewportHeight;\n image.width = image.width || (viewW - image.xOffset);\n image.height = image.height || (viewH - image.yOffset);\n image.needsCopy = true;\n check$1(image.xOffset >= 0 && image.xOffset < viewW &&\n image.yOffset >= 0 && image.yOffset < viewH &&\n image.width > 0 && image.width <= viewW &&\n image.height > 0 && image.height <= viewH,\n 'copy texture read out of bounds');\n } else if (!data) {\n image.width = image.width || 1;\n image.height = image.height || 1;\n image.channels = image.channels || 4;\n } else if (isTypedArray(data)) {\n image.channels = image.channels || 4;\n image.data = data;\n if (!('type' in options) && image.type === GL_UNSIGNED_BYTE$4) {\n image.type = typedArrayCode$1(data);\n }\n } else if (isNumericArray(data)) {\n image.channels = image.channels || 4;\n convertData(image, data);\n image.alignment = 1;\n image.needsFree = true;\n } else if (isNDArrayLike(data)) {\n var array = data.data;\n if (!Array.isArray(array) && image.type === GL_UNSIGNED_BYTE$4) {\n image.type = typedArrayCode$1(array);\n }\n var shape = data.shape;\n var stride = data.stride;\n var shapeX, shapeY, shapeC, strideX, strideY, strideC;\n if (shape.length === 3) {\n shapeC = shape[2];\n strideC = stride[2];\n } else {\n check$1(shape.length === 2, 'invalid ndarray pixel data, must be 2 or 3D');\n shapeC = 1;\n strideC = 1;\n }\n shapeX = shape[0];\n shapeY = shape[1];\n strideX = stride[0];\n strideY = stride[1];\n image.alignment = 1;\n image.width = shapeX;\n image.height = shapeY;\n image.channels = shapeC;\n image.format = image.internalformat = CHANNELS_FORMAT[shapeC];\n image.needsFree = true;\n transposeData(image, array, strideX, strideY, strideC, data.offset);\n } else if (isCanvasElement(data) || isContext2D(data)) {\n if (isCanvasElement(data)) {\n image.element = data;\n } else {\n image.element = data.canvas;\n }\n image.width = image.element.width;\n image.height = image.element.height;\n image.channels = 4;\n } else if (isImageElement(data)) {\n image.element = data;\n image.width = data.naturalWidth;\n image.height = data.naturalHeight;\n image.channels = 4;\n } else if (isVideoElement(data)) {\n image.element = data;\n image.width = data.videoWidth;\n image.height = data.videoHeight;\n image.channels = 4;\n } else if (isRectArray(data)) {\n var w = image.width || data[0].length;\n var h = image.height || data.length;\n var c = image.channels;\n if (isArrayLike(data[0][0])) {\n c = c || data[0][0].length;\n } else {\n c = c || 1;\n }\n var arrayShape = flattenUtils.shape(data);\n var n = 1;\n for (var dd = 0; dd < arrayShape.length; ++dd) {\n n *= arrayShape[dd];\n }\n var allocData = preConvert(image, n);\n flattenUtils.flatten(data, arrayShape, '', allocData);\n postConvert(image, allocData);\n image.alignment = 1;\n image.width = w;\n image.height = h;\n image.channels = c;\n image.format = image.internalformat = CHANNELS_FORMAT[c];\n image.needsFree = true;\n }\n\n if (image.type === GL_FLOAT$3) {\n check$1(limits.extensions.indexOf('oes_texture_float') >= 0,\n 'oes_texture_float extension not enabled');\n } else if (image.type === GL_HALF_FLOAT_OES$1) {\n check$1(limits.extensions.indexOf('oes_texture_half_float') >= 0,\n 'oes_texture_half_float extension not enabled');\n }\n\n // do compressed texture validation here.\n }\n\n function setImage (info, target, miplevel) {\n var element = info.element;\n var data = info.data;\n var internalformat = info.internalformat;\n var format = info.format;\n var type = info.type;\n var width = info.width;\n var height = info.height;\n\n setFlags(info);\n\n if (element) {\n gl.texImage2D(target, miplevel, format, format, type, element);\n } else if (info.compressed) {\n gl.compressedTexImage2D(target, miplevel, internalformat, width, height, 0, data);\n } else if (info.needsCopy) {\n reglPoll();\n gl.copyTexImage2D(\n target, miplevel, format, info.xOffset, info.yOffset, width, height, 0);\n } else {\n gl.texImage2D(\n target, miplevel, format, width, height, 0, format, type, data);\n }\n }\n\n function setSubImage (info, target, x, y, miplevel) {\n var element = info.element;\n var data = info.data;\n var internalformat = info.internalformat;\n var format = info.format;\n var type = info.type;\n var width = info.width;\n var height = info.height;\n\n setFlags(info);\n\n if (element) {\n gl.texSubImage2D(\n target, miplevel, x, y, format, type, element);\n } else if (info.compressed) {\n gl.compressedTexSubImage2D(\n target, miplevel, x, y, internalformat, width, height, data);\n } else if (info.needsCopy) {\n reglPoll();\n gl.copyTexSubImage2D(\n target, miplevel, x, y, info.xOffset, info.yOffset, width, height);\n } else {\n gl.texSubImage2D(\n target, miplevel, x, y, width, height, format, type, data);\n }\n }\n\n // texImage pool\n var imagePool = [];\n\n function allocImage () {\n return imagePool.pop() || new TexImage()\n }\n\n function freeImage (image) {\n if (image.needsFree) {\n pool.freeType(image.data);\n }\n TexImage.call(image);\n imagePool.push(image);\n }\n\n // -------------------------------------------------------\n // Mip map\n // -------------------------------------------------------\n function MipMap () {\n TexFlags.call(this);\n\n this.genMipmaps = false;\n this.mipmapHint = GL_DONT_CARE;\n this.mipmask = 0;\n this.images = Array(16);\n }\n\n function parseMipMapFromShape (mipmap, width, height) {\n var img = mipmap.images[0] = allocImage();\n mipmap.mipmask = 1;\n img.width = mipmap.width = width;\n img.height = mipmap.height = height;\n img.channels = mipmap.channels = 4;\n }\n\n function parseMipMapFromObject (mipmap, options) {\n var imgData = null;\n if (isPixelData(options)) {\n imgData = mipmap.images[0] = allocImage();\n copyFlags(imgData, mipmap);\n parseImage(imgData, options);\n mipmap.mipmask = 1;\n } else {\n parseFlags(mipmap, options);\n if (Array.isArray(options.mipmap)) {\n var mipData = options.mipmap;\n for (var i = 0; i < mipData.length; ++i) {\n imgData = mipmap.images[i] = allocImage();\n copyFlags(imgData, mipmap);\n imgData.width >>= i;\n imgData.height >>= i;\n parseImage(imgData, mipData[i]);\n mipmap.mipmask |= (1 << i);\n }\n } else {\n imgData = mipmap.images[0] = allocImage();\n copyFlags(imgData, mipmap);\n parseImage(imgData, options);\n mipmap.mipmask = 1;\n }\n }\n copyFlags(mipmap, mipmap.images[0]);\n\n // For textures of the compressed format WEBGL_compressed_texture_s3tc\n // we must have that\n //\n // \"When level equals zero width and height must be a multiple of 4.\n // When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. \"\n //\n // but we do not yet support having multiple mipmap levels for compressed textures,\n // so we only test for level zero.\n\n if (mipmap.compressed &&\n (mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT) ||\n (mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ||\n (mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) ||\n (mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) {\n check$1(mipmap.width % 4 === 0 &&\n mipmap.height % 4 === 0,\n 'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4');\n }\n }\n\n function setMipMap (mipmap, target) {\n var images = mipmap.images;\n for (var i = 0; i < images.length; ++i) {\n if (!images[i]) {\n return\n }\n setImage(images[i], target, i);\n }\n }\n\n var mipPool = [];\n\n function allocMipMap () {\n var result = mipPool.pop() || new MipMap();\n TexFlags.call(result);\n result.mipmask = 0;\n for (var i = 0; i < 16; ++i) {\n result.images[i] = null;\n }\n return result\n }\n\n function freeMipMap (mipmap) {\n var images = mipmap.images;\n for (var i = 0; i < images.length; ++i) {\n if (images[i]) {\n freeImage(images[i]);\n }\n images[i] = null;\n }\n mipPool.push(mipmap);\n }\n\n // -------------------------------------------------------\n // Tex info\n // -------------------------------------------------------\n function TexInfo () {\n this.minFilter = GL_NEAREST$1;\n this.magFilter = GL_NEAREST$1;\n\n this.wrapS = GL_CLAMP_TO_EDGE$1;\n this.wrapT = GL_CLAMP_TO_EDGE$1;\n\n this.anisotropic = 1;\n\n this.genMipmaps = false;\n this.mipmapHint = GL_DONT_CARE;\n }\n\n function parseTexInfo (info, options) {\n if ('min' in options) {\n var minFilter = options.min;\n check$1.parameter(minFilter, minFilters);\n info.minFilter = minFilters[minFilter];\n if (MIPMAP_FILTERS.indexOf(info.minFilter) >= 0) {\n info.genMipmaps = true;\n }\n }\n\n if ('mag' in options) {\n var magFilter = options.mag;\n check$1.parameter(magFilter, magFilters);\n info.magFilter = magFilters[magFilter];\n }\n\n var wrapS = info.wrapS;\n var wrapT = info.wrapT;\n if ('wrap' in options) {\n var wrap = options.wrap;\n if (typeof wrap === 'string') {\n check$1.parameter(wrap, wrapModes);\n wrapS = wrapT = wrapModes[wrap];\n } else if (Array.isArray(wrap)) {\n check$1.parameter(wrap[0], wrapModes);\n check$1.parameter(wrap[1], wrapModes);\n wrapS = wrapModes[wrap[0]];\n wrapT = wrapModes[wrap[1]];\n }\n } else {\n if ('wrapS' in options) {\n var optWrapS = options.wrapS;\n check$1.parameter(optWrapS, wrapModes);\n wrapS = wrapModes[optWrapS];\n }\n if ('wrapT' in options) {\n var optWrapT = options.wrapT;\n check$1.parameter(optWrapT, wrapModes);\n wrapT = wrapModes[optWrapT];\n }\n }\n info.wrapS = wrapS;\n info.wrapT = wrapT;\n\n if ('anisotropic' in options) {\n var anisotropic = options.anisotropic;\n check$1(typeof anisotropic === 'number' &&\n anisotropic >= 1 && anisotropic <= limits.maxAnisotropic,\n 'aniso samples must be between 1 and ');\n info.anisotropic = options.anisotropic;\n }\n\n if ('mipmap' in options) {\n var hasMipMap = false;\n switch (typeof options.mipmap) {\n case 'string':\n check$1.parameter(options.mipmap, mipmapHint,\n 'invalid mipmap hint');\n info.mipmapHint = mipmapHint[options.mipmap];\n info.genMipmaps = true;\n hasMipMap = true;\n break\n\n case 'boolean':\n hasMipMap = info.genMipmaps = options.mipmap;\n break\n\n case 'object':\n check$1(Array.isArray(options.mipmap), 'invalid mipmap type');\n info.genMipmaps = false;\n hasMipMap = true;\n break\n\n default:\n check$1.raise('invalid mipmap type');\n }\n if (hasMipMap && !('min' in options)) {\n info.minFilter = GL_NEAREST_MIPMAP_NEAREST$1;\n }\n }\n }\n\n function setTexInfo (info, target) {\n gl.texParameteri(target, GL_TEXTURE_MIN_FILTER, info.minFilter);\n gl.texParameteri(target, GL_TEXTURE_MAG_FILTER, info.magFilter);\n gl.texParameteri(target, GL_TEXTURE_WRAP_S, info.wrapS);\n gl.texParameteri(target, GL_TEXTURE_WRAP_T, info.wrapT);\n if (extensions.ext_texture_filter_anisotropic) {\n gl.texParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, info.anisotropic);\n }\n if (info.genMipmaps) {\n gl.hint(GL_GENERATE_MIPMAP_HINT, info.mipmapHint);\n gl.generateMipmap(target);\n }\n }\n\n // -------------------------------------------------------\n // Full texture object\n // -------------------------------------------------------\n var textureCount = 0;\n var textureSet = {};\n var numTexUnits = limits.maxTextureUnits;\n var textureUnits = Array(numTexUnits).map(function () {\n return null\n });\n\n function REGLTexture (target) {\n TexFlags.call(this);\n this.mipmask = 0;\n this.internalformat = GL_RGBA;\n\n this.id = textureCount++;\n\n this.refCount = 1;\n\n this.target = target;\n this.texture = gl.createTexture();\n\n this.unit = -1;\n this.bindCount = 0;\n\n this.texInfo = new TexInfo();\n\n if (config.profile) {\n this.stats = {size: 0};\n }\n }\n\n function tempBind (texture) {\n gl.activeTexture(GL_TEXTURE0);\n gl.bindTexture(texture.target, texture.texture);\n }\n\n function tempRestore () {\n var prev = textureUnits[0];\n if (prev) {\n gl.bindTexture(prev.target, prev.texture);\n } else {\n gl.bindTexture(GL_TEXTURE_2D, null);\n }\n }\n\n function destroy (texture) {\n var handle = texture.texture;\n check$1(handle, 'must not double destroy texture');\n var unit = texture.unit;\n var target = texture.target;\n if (unit >= 0) {\n gl.activeTexture(GL_TEXTURE0 + unit);\n gl.bindTexture(target, null);\n textureUnits[unit] = null;\n }\n gl.deleteTexture(handle);\n texture.texture = null;\n texture.params = null;\n texture.pixels = null;\n texture.refCount = 0;\n delete textureSet[texture.id];\n stats.textureCount--;\n }\n\n extend(REGLTexture.prototype, {\n bind: function () {\n var texture = this;\n texture.bindCount += 1;\n var unit = texture.unit;\n if (unit < 0) {\n for (var i = 0; i < numTexUnits; ++i) {\n var other = textureUnits[i];\n if (other) {\n if (other.bindCount > 0) {\n continue\n }\n other.unit = -1;\n }\n textureUnits[i] = texture;\n unit = i;\n break\n }\n if (unit >= numTexUnits) {\n check$1.raise('insufficient number of texture units');\n }\n if (config.profile && stats.maxTextureUnits < (unit + 1)) {\n stats.maxTextureUnits = unit + 1; // +1, since the units are zero-based\n }\n texture.unit = unit;\n gl.activeTexture(GL_TEXTURE0 + unit);\n gl.bindTexture(texture.target, texture.texture);\n }\n return unit\n },\n\n unbind: function () {\n this.bindCount -= 1;\n },\n\n decRef: function () {\n if (--this.refCount <= 0) {\n destroy(this);\n }\n }\n });\n\n function createTexture2D (a, b) {\n var texture = new REGLTexture(GL_TEXTURE_2D);\n textureSet[texture.id] = texture;\n stats.textureCount++;\n\n function reglTexture2D (a, b) {\n var texInfo = texture.texInfo;\n TexInfo.call(texInfo);\n var mipData = allocMipMap();\n\n if (typeof a === 'number') {\n if (typeof b === 'number') {\n parseMipMapFromShape(mipData, a | 0, b | 0);\n } else {\n parseMipMapFromShape(mipData, a | 0, a | 0);\n }\n } else if (a) {\n check$1.type(a, 'object', 'invalid arguments to regl.texture');\n parseTexInfo(texInfo, a);\n parseMipMapFromObject(mipData, a);\n } else {\n // empty textures get assigned a default shape of 1x1\n parseMipMapFromShape(mipData, 1, 1);\n }\n\n if (texInfo.genMipmaps) {\n mipData.mipmask = (mipData.width << 1) - 1;\n }\n texture.mipmask = mipData.mipmask;\n\n copyFlags(texture, mipData);\n\n check$1.texture2D(texInfo, mipData, limits);\n texture.internalformat = mipData.internalformat;\n\n reglTexture2D.width = mipData.width;\n reglTexture2D.height = mipData.height;\n\n tempBind(texture);\n setMipMap(mipData, GL_TEXTURE_2D);\n setTexInfo(texInfo, GL_TEXTURE_2D);\n tempRestore();\n\n freeMipMap(mipData);\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n mipData.width,\n mipData.height,\n texInfo.genMipmaps,\n false);\n }\n reglTexture2D.format = textureFormatsInvert[texture.internalformat];\n reglTexture2D.type = textureTypesInvert[texture.type];\n\n reglTexture2D.mag = magFiltersInvert[texInfo.magFilter];\n reglTexture2D.min = minFiltersInvert[texInfo.minFilter];\n\n reglTexture2D.wrapS = wrapModesInvert[texInfo.wrapS];\n reglTexture2D.wrapT = wrapModesInvert[texInfo.wrapT];\n\n return reglTexture2D\n }\n\n function subimage (image, x_, y_, level_) {\n check$1(!!image, 'must specify image data');\n\n var x = x_ | 0;\n var y = y_ | 0;\n var level = level_ | 0;\n\n var imageData = allocImage();\n copyFlags(imageData, texture);\n imageData.width = 0;\n imageData.height = 0;\n parseImage(imageData, image);\n imageData.width = imageData.width || ((texture.width >> level) - x);\n imageData.height = imageData.height || ((texture.height >> level) - y);\n\n check$1(\n texture.type === imageData.type &&\n texture.format === imageData.format &&\n texture.internalformat === imageData.internalformat,\n 'incompatible format for texture.subimage');\n check$1(\n x >= 0 && y >= 0 &&\n x + imageData.width <= texture.width &&\n y + imageData.height <= texture.height,\n 'texture.subimage write out of bounds');\n check$1(\n texture.mipmask & (1 << level),\n 'missing mipmap data');\n check$1(\n imageData.data || imageData.element || imageData.needsCopy,\n 'missing image data');\n\n tempBind(texture);\n setSubImage(imageData, GL_TEXTURE_2D, x, y, level);\n tempRestore();\n\n freeImage(imageData);\n\n return reglTexture2D\n }\n\n function resize (w_, h_) {\n var w = w_ | 0;\n var h = (h_ | 0) || w;\n if (w === texture.width && h === texture.height) {\n return reglTexture2D\n }\n\n reglTexture2D.width = texture.width = w;\n reglTexture2D.height = texture.height = h;\n\n tempBind(texture);\n for (var i = 0; texture.mipmask >> i; ++i) {\n gl.texImage2D(\n GL_TEXTURE_2D,\n i,\n texture.format,\n w >> i,\n h >> i,\n 0,\n texture.format,\n texture.type,\n null);\n }\n tempRestore();\n\n // also, recompute the texture size.\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n w,\n h,\n false,\n false);\n }\n\n return reglTexture2D\n }\n\n reglTexture2D(a, b);\n\n reglTexture2D.subimage = subimage;\n reglTexture2D.resize = resize;\n reglTexture2D._reglType = 'texture2d';\n reglTexture2D._texture = texture;\n if (config.profile) {\n reglTexture2D.stats = texture.stats;\n }\n reglTexture2D.destroy = function () {\n texture.decRef();\n };\n\n return reglTexture2D\n }\n\n function createTextureCube (a0, a1, a2, a3, a4, a5) {\n var texture = new REGLTexture(GL_TEXTURE_CUBE_MAP);\n textureSet[texture.id] = texture;\n stats.cubeCount++;\n\n var faces = new Array(6);\n\n function reglTextureCube (a0, a1, a2, a3, a4, a5) {\n var i;\n var texInfo = texture.texInfo;\n TexInfo.call(texInfo);\n for (i = 0; i < 6; ++i) {\n faces[i] = allocMipMap();\n }\n\n if (typeof a0 === 'number' || !a0) {\n var s = (a0 | 0) || 1;\n for (i = 0; i < 6; ++i) {\n parseMipMapFromShape(faces[i], s, s);\n }\n } else if (typeof a0 === 'object') {\n if (a1) {\n parseMipMapFromObject(faces[0], a0);\n parseMipMapFromObject(faces[1], a1);\n parseMipMapFromObject(faces[2], a2);\n parseMipMapFromObject(faces[3], a3);\n parseMipMapFromObject(faces[4], a4);\n parseMipMapFromObject(faces[5], a5);\n } else {\n parseTexInfo(texInfo, a0);\n parseFlags(texture, a0);\n if ('faces' in a0) {\n var face_input = a0.faces;\n check$1(Array.isArray(face_input) && face_input.length === 6,\n 'cube faces must be a length 6 array');\n for (i = 0; i < 6; ++i) {\n check$1(typeof face_input[i] === 'object' && !!face_input[i],\n 'invalid input for cube map face');\n copyFlags(faces[i], texture);\n parseMipMapFromObject(faces[i], face_input[i]);\n }\n } else {\n for (i = 0; i < 6; ++i) {\n parseMipMapFromObject(faces[i], a0);\n }\n }\n }\n } else {\n check$1.raise('invalid arguments to cube map');\n }\n\n copyFlags(texture, faces[0]);\n if (texInfo.genMipmaps) {\n texture.mipmask = (faces[0].width << 1) - 1;\n } else {\n texture.mipmask = faces[0].mipmask;\n }\n\n check$1.textureCube(texture, texInfo, faces, limits);\n texture.internalformat = faces[0].internalformat;\n\n reglTextureCube.width = faces[0].width;\n reglTextureCube.height = faces[0].height;\n\n tempBind(texture);\n for (i = 0; i < 6; ++i) {\n setMipMap(faces[i], GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);\n }\n setTexInfo(texInfo, GL_TEXTURE_CUBE_MAP);\n tempRestore();\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n reglTextureCube.width,\n reglTextureCube.height,\n texInfo.genMipmaps,\n true);\n }\n\n reglTextureCube.format = textureFormatsInvert[texture.internalformat];\n reglTextureCube.type = textureTypesInvert[texture.type];\n\n reglTextureCube.mag = magFiltersInvert[texInfo.magFilter];\n reglTextureCube.min = minFiltersInvert[texInfo.minFilter];\n\n reglTextureCube.wrapS = wrapModesInvert[texInfo.wrapS];\n reglTextureCube.wrapT = wrapModesInvert[texInfo.wrapT];\n\n for (i = 0; i < 6; ++i) {\n freeMipMap(faces[i]);\n }\n\n return reglTextureCube\n }\n\n function subimage (face, image, x_, y_, level_) {\n check$1(!!image, 'must specify image data');\n check$1(typeof face === 'number' && face === (face | 0) &&\n face >= 0 && face < 6, 'invalid face');\n\n var x = x_ | 0;\n var y = y_ | 0;\n var level = level_ | 0;\n\n var imageData = allocImage();\n copyFlags(imageData, texture);\n imageData.width = 0;\n imageData.height = 0;\n parseImage(imageData, image);\n imageData.width = imageData.width || ((texture.width >> level) - x);\n imageData.height = imageData.height || ((texture.height >> level) - y);\n\n check$1(\n texture.type === imageData.type &&\n texture.format === imageData.format &&\n texture.internalformat === imageData.internalformat,\n 'incompatible format for texture.subimage');\n check$1(\n x >= 0 && y >= 0 &&\n x + imageData.width <= texture.width &&\n y + imageData.height <= texture.height,\n 'texture.subimage write out of bounds');\n check$1(\n texture.mipmask & (1 << level),\n 'missing mipmap data');\n check$1(\n imageData.data || imageData.element || imageData.needsCopy,\n 'missing image data');\n\n tempBind(texture);\n setSubImage(imageData, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, x, y, level);\n tempRestore();\n\n freeImage(imageData);\n\n return reglTextureCube\n }\n\n function resize (radius_) {\n var radius = radius_ | 0;\n if (radius === texture.width) {\n return\n }\n\n reglTextureCube.width = texture.width = radius;\n reglTextureCube.height = texture.height = radius;\n\n tempBind(texture);\n for (var i = 0; i < 6; ++i) {\n for (var j = 0; texture.mipmask >> j; ++j) {\n gl.texImage2D(\n GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,\n j,\n texture.format,\n radius >> j,\n radius >> j,\n 0,\n texture.format,\n texture.type,\n null);\n }\n }\n tempRestore();\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n reglTextureCube.width,\n reglTextureCube.height,\n false,\n true);\n }\n\n return reglTextureCube\n }\n\n reglTextureCube(a0, a1, a2, a3, a4, a5);\n\n reglTextureCube.subimage = subimage;\n reglTextureCube.resize = resize;\n reglTextureCube._reglType = 'textureCube';\n reglTextureCube._texture = texture;\n if (config.profile) {\n reglTextureCube.stats = texture.stats;\n }\n reglTextureCube.destroy = function () {\n texture.decRef();\n };\n\n return reglTextureCube\n }\n\n // Called when regl is destroyed\n function destroyTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n gl.activeTexture(GL_TEXTURE0 + i);\n gl.bindTexture(GL_TEXTURE_2D, null);\n textureUnits[i] = null;\n }\n values(textureSet).forEach(destroy);\n\n stats.cubeCount = 0;\n stats.textureCount = 0;\n }\n\n if (config.profile) {\n stats.getTotalTextureSize = function () {\n var total = 0;\n Object.keys(textureSet).forEach(function (key) {\n total += textureSet[key].stats.size;\n });\n return total\n };\n }\n\n function restoreTextures () {\n values(textureSet).forEach(function (texture) {\n texture.texture = gl.createTexture();\n gl.bindTexture(texture.target, texture.texture);\n for (var i = 0; i < 32; ++i) {\n if ((texture.mipmask & (1 << i)) === 0) {\n continue\n }\n if (texture.target === GL_TEXTURE_2D) {\n gl.texImage2D(GL_TEXTURE_2D,\n i,\n texture.internalformat,\n texture.width >> i,\n texture.height >> i,\n 0,\n texture.internalformat,\n texture.type,\n null);\n } else {\n for (var j = 0; j < 6; ++j) {\n gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + j,\n i,\n texture.internalformat,\n texture.width >> i,\n texture.height >> i,\n 0,\n texture.internalformat,\n texture.type,\n null);\n }\n }\n }\n setTexInfo(texture.texInfo, texture.target);\n });\n }\n\n return {\n create2D: createTexture2D,\n createCube: createTextureCube,\n clear: destroyTextures,\n getTexture: function (wrapper) {\n return null\n },\n restore: restoreTextures\n }\n}\n\nvar GL_RENDERBUFFER = 0x8D41;\n\nvar GL_RGBA4$1 = 0x8056;\nvar GL_RGB5_A1$1 = 0x8057;\nvar GL_RGB565$1 = 0x8D62;\nvar GL_DEPTH_COMPONENT16 = 0x81A5;\nvar GL_STENCIL_INDEX8 = 0x8D48;\nvar GL_DEPTH_STENCIL$1 = 0x84F9;\n\nvar GL_SRGB8_ALPHA8_EXT = 0x8C43;\n\nvar GL_RGBA32F_EXT = 0x8814;\n\nvar GL_RGBA16F_EXT = 0x881A;\nvar GL_RGB16F_EXT = 0x881B;\n\nvar FORMAT_SIZES = [];\n\nFORMAT_SIZES[GL_RGBA4$1] = 2;\nFORMAT_SIZES[GL_RGB5_A1$1] = 2;\nFORMAT_SIZES[GL_RGB565$1] = 2;\n\nFORMAT_SIZES[GL_DEPTH_COMPONENT16] = 2;\nFORMAT_SIZES[GL_STENCIL_INDEX8] = 1;\nFORMAT_SIZES[GL_DEPTH_STENCIL$1] = 4;\n\nFORMAT_SIZES[GL_SRGB8_ALPHA8_EXT] = 4;\nFORMAT_SIZES[GL_RGBA32F_EXT] = 16;\nFORMAT_SIZES[GL_RGBA16F_EXT] = 8;\nFORMAT_SIZES[GL_RGB16F_EXT] = 6;\n\nfunction getRenderbufferSize (format, width, height) {\n return FORMAT_SIZES[format] * width * height\n}\n\nvar wrapRenderbuffers = function (gl, extensions, limits, stats, config) {\n var formatTypes = {\n 'rgba4': GL_RGBA4$1,\n 'rgb565': GL_RGB565$1,\n 'rgb5 a1': GL_RGB5_A1$1,\n 'depth': GL_DEPTH_COMPONENT16,\n 'stencil': GL_STENCIL_INDEX8,\n 'depth stencil': GL_DEPTH_STENCIL$1\n };\n\n if (extensions.ext_srgb) {\n formatTypes['srgba'] = GL_SRGB8_ALPHA8_EXT;\n }\n\n if (extensions.ext_color_buffer_half_float) {\n formatTypes['rgba16f'] = GL_RGBA16F_EXT;\n formatTypes['rgb16f'] = GL_RGB16F_EXT;\n }\n\n if (extensions.webgl_color_buffer_float) {\n formatTypes['rgba32f'] = GL_RGBA32F_EXT;\n }\n\n var formatTypesInvert = [];\n Object.keys(formatTypes).forEach(function (key) {\n var val = formatTypes[key];\n formatTypesInvert[val] = key;\n });\n\n var renderbufferCount = 0;\n var renderbufferSet = {};\n\n function REGLRenderbuffer (renderbuffer) {\n this.id = renderbufferCount++;\n this.refCount = 1;\n\n this.renderbuffer = renderbuffer;\n\n this.format = GL_RGBA4$1;\n this.width = 0;\n this.height = 0;\n\n if (config.profile) {\n this.stats = {size: 0};\n }\n }\n\n REGLRenderbuffer.prototype.decRef = function () {\n if (--this.refCount <= 0) {\n destroy(this);\n }\n };\n\n function destroy (rb) {\n var handle = rb.renderbuffer;\n check$1(handle, 'must not double destroy renderbuffer');\n gl.bindRenderbuffer(GL_RENDERBUFFER, null);\n gl.deleteRenderbuffer(handle);\n rb.renderbuffer = null;\n rb.refCount = 0;\n delete renderbufferSet[rb.id];\n stats.renderbufferCount--;\n }\n\n function createRenderbuffer (a, b) {\n var renderbuffer = new REGLRenderbuffer(gl.createRenderbuffer());\n renderbufferSet[renderbuffer.id] = renderbuffer;\n stats.renderbufferCount++;\n\n function reglRenderbuffer (a, b) {\n var w = 0;\n var h = 0;\n var format = GL_RGBA4$1;\n\n if (typeof a === 'object' && a) {\n var options = a;\n if ('shape' in options) {\n var shape = options.shape;\n check$1(Array.isArray(shape) && shape.length >= 2,\n 'invalid renderbuffer shape');\n w = shape[0] | 0;\n h = shape[1] | 0;\n } else {\n if ('radius' in options) {\n w = h = options.radius | 0;\n }\n if ('width' in options) {\n w = options.width | 0;\n }\n if ('height' in options) {\n h = options.height | 0;\n }\n }\n if ('format' in options) {\n check$1.parameter(options.format, formatTypes,\n 'invalid renderbuffer format');\n format = formatTypes[options.format];\n }\n } else if (typeof a === 'number') {\n w = a | 0;\n if (typeof b === 'number') {\n h = b | 0;\n } else {\n h = w;\n }\n } else if (!a) {\n w = h = 1;\n } else {\n check$1.raise('invalid arguments to renderbuffer constructor');\n }\n\n // check shape\n check$1(\n w > 0 && h > 0 &&\n w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize,\n 'invalid renderbuffer size');\n\n if (w === renderbuffer.width &&\n h === renderbuffer.height &&\n format === renderbuffer.format) {\n return\n }\n\n reglRenderbuffer.width = renderbuffer.width = w;\n reglRenderbuffer.height = renderbuffer.height = h;\n renderbuffer.format = format;\n\n gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer);\n gl.renderbufferStorage(GL_RENDERBUFFER, format, w, h);\n\n if (config.profile) {\n renderbuffer.stats.size = getRenderbufferSize(renderbuffer.format, renderbuffer.width, renderbuffer.height);\n }\n reglRenderbuffer.format = formatTypesInvert[renderbuffer.format];\n\n return reglRenderbuffer\n }\n\n function resize (w_, h_) {\n var w = w_ | 0;\n var h = (h_ | 0) || w;\n\n if (w === renderbuffer.width && h === renderbuffer.height) {\n return reglRenderbuffer\n }\n\n // check shape\n check$1(\n w > 0 && h > 0 &&\n w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize,\n 'invalid renderbuffer size');\n\n reglRenderbuffer.width = renderbuffer.width = w;\n reglRenderbuffer.height = renderbuffer.height = h;\n\n gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer);\n gl.renderbufferStorage(GL_RENDERBUFFER, renderbuffer.format, w, h);\n\n // also, recompute size.\n if (config.profile) {\n renderbuffer.stats.size = getRenderbufferSize(\n renderbuffer.format, renderbuffer.width, renderbuffer.height);\n }\n\n return reglRenderbuffer\n }\n\n reglRenderbuffer(a, b);\n\n reglRenderbuffer.resize = resize;\n reglRenderbuffer._reglType = 'renderbuffer';\n reglRenderbuffer._renderbuffer = renderbuffer;\n if (config.profile) {\n reglRenderbuffer.stats = renderbuffer.stats;\n }\n reglRenderbuffer.destroy = function () {\n renderbuffer.decRef();\n };\n\n return reglRenderbuffer\n }\n\n if (config.profile) {\n stats.getTotalRenderbufferSize = function () {\n var total = 0;\n Object.keys(renderbufferSet).forEach(function (key) {\n total += renderbufferSet[key].stats.size;\n });\n return total\n };\n }\n\n function restoreRenderbuffers () {\n values(renderbufferSet).forEach(function (rb) {\n rb.renderbuffer = gl.createRenderbuffer();\n gl.bindRenderbuffer(GL_RENDERBUFFER, rb.renderbuffer);\n gl.renderbufferStorage(GL_RENDERBUFFER, rb.format, rb.width, rb.height);\n });\n gl.bindRenderbuffer(GL_RENDERBUFFER, null);\n }\n\n return {\n create: createRenderbuffer,\n clear: function () {\n values(renderbufferSet).forEach(destroy);\n },\n restore: restoreRenderbuffers\n }\n};\n\n// We store these constants so that the minifier can inline them\nvar GL_FRAMEBUFFER = 0x8D40;\nvar GL_RENDERBUFFER$1 = 0x8D41;\n\nvar GL_TEXTURE_2D$1 = 0x0DE1;\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 = 0x8515;\n\nvar GL_COLOR_ATTACHMENT0 = 0x8CE0;\nvar GL_DEPTH_ATTACHMENT = 0x8D00;\nvar GL_STENCIL_ATTACHMENT = 0x8D20;\nvar GL_DEPTH_STENCIL_ATTACHMENT = 0x821A;\n\nvar GL_FRAMEBUFFER_COMPLETE = 0x8CD5;\nvar GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;\nvar GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;\nvar GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;\nvar GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD;\n\nvar GL_HALF_FLOAT_OES$2 = 0x8D61;\nvar GL_UNSIGNED_BYTE$5 = 0x1401;\nvar GL_FLOAT$4 = 0x1406;\n\nvar GL_RGBA$1 = 0x1908;\n\nvar GL_DEPTH_COMPONENT$1 = 0x1902;\n\nvar colorTextureFormatEnums = [\n GL_RGBA$1\n];\n\n// for every texture format, store\n// the number of channels\nvar textureFormatChannels = [];\ntextureFormatChannels[GL_RGBA$1] = 4;\n\n// for every texture type, store\n// the size in bytes.\nvar textureTypeSizes = [];\ntextureTypeSizes[GL_UNSIGNED_BYTE$5] = 1;\ntextureTypeSizes[GL_FLOAT$4] = 4;\ntextureTypeSizes[GL_HALF_FLOAT_OES$2] = 2;\n\nvar GL_RGBA4$2 = 0x8056;\nvar GL_RGB5_A1$2 = 0x8057;\nvar GL_RGB565$2 = 0x8D62;\nvar GL_DEPTH_COMPONENT16$1 = 0x81A5;\nvar GL_STENCIL_INDEX8$1 = 0x8D48;\nvar GL_DEPTH_STENCIL$2 = 0x84F9;\n\nvar GL_SRGB8_ALPHA8_EXT$1 = 0x8C43;\n\nvar GL_RGBA32F_EXT$1 = 0x8814;\n\nvar GL_RGBA16F_EXT$1 = 0x881A;\nvar GL_RGB16F_EXT$1 = 0x881B;\n\nvar colorRenderbufferFormatEnums = [\n GL_RGBA4$2,\n GL_RGB5_A1$2,\n GL_RGB565$2,\n GL_SRGB8_ALPHA8_EXT$1,\n GL_RGBA16F_EXT$1,\n GL_RGB16F_EXT$1,\n GL_RGBA32F_EXT$1\n];\n\nvar statusCode = {};\nstatusCode[GL_FRAMEBUFFER_COMPLETE] = 'complete';\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT] = 'incomplete attachment';\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS] = 'incomplete dimensions';\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT] = 'incomplete, missing attachment';\nstatusCode[GL_FRAMEBUFFER_UNSUPPORTED] = 'unsupported';\n\nfunction wrapFBOState (\n gl,\n extensions,\n limits,\n textureState,\n renderbufferState,\n stats) {\n var framebufferState = {\n cur: null,\n next: null,\n dirty: false,\n setFBO: null\n };\n\n var colorTextureFormats = ['rgba'];\n var colorRenderbufferFormats = ['rgba4', 'rgb565', 'rgb5 a1'];\n\n if (extensions.ext_srgb) {\n colorRenderbufferFormats.push('srgba');\n }\n\n if (extensions.ext_color_buffer_half_float) {\n colorRenderbufferFormats.push('rgba16f', 'rgb16f');\n }\n\n if (extensions.webgl_color_buffer_float) {\n colorRenderbufferFormats.push('rgba32f');\n }\n\n var colorTypes = ['uint8'];\n if (extensions.oes_texture_half_float) {\n colorTypes.push('half float', 'float16');\n }\n if (extensions.oes_texture_float) {\n colorTypes.push('float', 'float32');\n }\n\n function FramebufferAttachment (target, texture, renderbuffer) {\n this.target = target;\n this.texture = texture;\n this.renderbuffer = renderbuffer;\n\n var w = 0;\n var h = 0;\n if (texture) {\n w = texture.width;\n h = texture.height;\n } else if (renderbuffer) {\n w = renderbuffer.width;\n h = renderbuffer.height;\n }\n this.width = w;\n this.height = h;\n }\n\n function decRef (attachment) {\n if (attachment) {\n if (attachment.texture) {\n attachment.texture._texture.decRef();\n }\n if (attachment.renderbuffer) {\n attachment.renderbuffer._renderbuffer.decRef();\n }\n }\n }\n\n function incRefAndCheckShape (attachment, width, height) {\n if (!attachment) {\n return\n }\n if (attachment.texture) {\n var texture = attachment.texture._texture;\n var tw = Math.max(1, texture.width);\n var th = Math.max(1, texture.height);\n check$1(tw === width && th === height,\n 'inconsistent width/height for supplied texture');\n texture.refCount += 1;\n } else {\n var renderbuffer = attachment.renderbuffer._renderbuffer;\n check$1(\n renderbuffer.width === width && renderbuffer.height === height,\n 'inconsistent width/height for renderbuffer');\n renderbuffer.refCount += 1;\n }\n }\n\n function attach (location, attachment) {\n if (attachment) {\n if (attachment.texture) {\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER,\n location,\n attachment.target,\n attachment.texture._texture.texture,\n 0);\n } else {\n gl.framebufferRenderbuffer(\n GL_FRAMEBUFFER,\n location,\n GL_RENDERBUFFER$1,\n attachment.renderbuffer._renderbuffer.renderbuffer);\n }\n }\n }\n\n function parseAttachment (attachment) {\n var target = GL_TEXTURE_2D$1;\n var texture = null;\n var renderbuffer = null;\n\n var data = attachment;\n if (typeof attachment === 'object') {\n data = attachment.data;\n if ('target' in attachment) {\n target = attachment.target | 0;\n }\n }\n\n check$1.type(data, 'function', 'invalid attachment data');\n\n var type = data._reglType;\n if (type === 'texture2d') {\n texture = data;\n check$1(target === GL_TEXTURE_2D$1);\n } else if (type === 'textureCube') {\n texture = data;\n check$1(\n target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 &&\n target < GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + 6,\n 'invalid cube map target');\n } else if (type === 'renderbuffer') {\n renderbuffer = data;\n target = GL_RENDERBUFFER$1;\n } else {\n check$1.raise('invalid regl object for attachment');\n }\n\n return new FramebufferAttachment(target, texture, renderbuffer)\n }\n\n function allocAttachment (\n width,\n height,\n isTexture,\n format,\n type) {\n if (isTexture) {\n var texture = textureState.create2D({\n width: width,\n height: height,\n format: format,\n type: type\n });\n texture._texture.refCount = 0;\n return new FramebufferAttachment(GL_TEXTURE_2D$1, texture, null)\n } else {\n var rb = renderbufferState.create({\n width: width,\n height: height,\n format: format\n });\n rb._renderbuffer.refCount = 0;\n return new FramebufferAttachment(GL_RENDERBUFFER$1, null, rb)\n }\n }\n\n function unwrapAttachment (attachment) {\n return attachment && (attachment.texture || attachment.renderbuffer)\n }\n\n function resizeAttachment (attachment, w, h) {\n if (attachment) {\n if (attachment.texture) {\n attachment.texture.resize(w, h);\n } else if (attachment.renderbuffer) {\n attachment.renderbuffer.resize(w, h);\n }\n }\n }\n\n var framebufferCount = 0;\n var framebufferSet = {};\n\n function REGLFramebuffer () {\n this.id = framebufferCount++;\n framebufferSet[this.id] = this;\n\n this.framebuffer = gl.createFramebuffer();\n this.width = 0;\n this.height = 0;\n\n this.colorAttachments = [];\n this.depthAttachment = null;\n this.stencilAttachment = null;\n this.depthStencilAttachment = null;\n }\n\n function decFBORefs (framebuffer) {\n framebuffer.colorAttachments.forEach(decRef);\n decRef(framebuffer.depthAttachment);\n decRef(framebuffer.stencilAttachment);\n decRef(framebuffer.depthStencilAttachment);\n }\n\n function destroy (framebuffer) {\n var handle = framebuffer.framebuffer;\n check$1(handle, 'must not double destroy framebuffer');\n gl.deleteFramebuffer(handle);\n framebuffer.framebuffer = null;\n stats.framebufferCount--;\n delete framebufferSet[framebuffer.id];\n }\n\n function updateFramebuffer (framebuffer) {\n var i;\n\n gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer.framebuffer);\n var colorAttachments = framebuffer.colorAttachments;\n for (i = 0; i < colorAttachments.length; ++i) {\n attach(GL_COLOR_ATTACHMENT0 + i, colorAttachments[i]);\n }\n for (i = colorAttachments.length; i < limits.maxColorAttachments; ++i) {\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER,\n GL_COLOR_ATTACHMENT0 + i,\n GL_TEXTURE_2D$1,\n null,\n 0);\n }\n\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER,\n GL_DEPTH_STENCIL_ATTACHMENT,\n GL_TEXTURE_2D$1,\n null,\n 0);\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER,\n GL_DEPTH_ATTACHMENT,\n GL_TEXTURE_2D$1,\n null,\n 0);\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER,\n GL_STENCIL_ATTACHMENT,\n GL_TEXTURE_2D$1,\n null,\n 0);\n\n attach(GL_DEPTH_ATTACHMENT, framebuffer.depthAttachment);\n attach(GL_STENCIL_ATTACHMENT, framebuffer.stencilAttachment);\n attach(GL_DEPTH_STENCIL_ATTACHMENT, framebuffer.depthStencilAttachment);\n\n // Check status code\n var status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);\n if (status !== GL_FRAMEBUFFER_COMPLETE) {\n check$1.raise('framebuffer configuration not supported, status = ' +\n statusCode[status]);\n }\n\n gl.bindFramebuffer(GL_FRAMEBUFFER, framebufferState.next);\n framebufferState.cur = framebufferState.next;\n\n // FIXME: Clear error code here. This is a work around for a bug in\n // headless-gl\n gl.getError();\n }\n\n function createFBO (a0, a1) {\n var framebuffer = new REGLFramebuffer();\n stats.framebufferCount++;\n\n function reglFramebuffer (a, b) {\n var i;\n\n check$1(framebufferState.next !== framebuffer,\n 'can not update framebuffer which is currently in use');\n\n var extDrawBuffers = extensions.webgl_draw_buffers;\n\n var width = 0;\n var height = 0;\n\n var needsDepth = true;\n var needsStencil = true;\n\n var colorBuffer = null;\n var colorTexture = true;\n var colorFormat = 'rgba';\n var colorType = 'uint8';\n var colorCount = 1;\n\n var depthBuffer = null;\n var stencilBuffer = null;\n var depthStencilBuffer = null;\n var depthStencilTexture = false;\n\n if (typeof a === 'number') {\n width = a | 0;\n height = (b | 0) || width;\n } else if (!a) {\n width = height = 1;\n } else {\n check$1.type(a, 'object', 'invalid arguments for framebuffer');\n var options = a;\n\n if ('shape' in options) {\n var shape = options.shape;\n check$1(Array.isArray(shape) && shape.length >= 2,\n 'invalid shape for framebuffer');\n width = shape[0];\n height = shape[1];\n } else {\n if ('radius' in options) {\n width = height = options.radius;\n }\n if ('width' in options) {\n width = options.width;\n }\n if ('height' in options) {\n height = options.height;\n }\n }\n\n if ('color' in options ||\n 'colors' in options) {\n colorBuffer =\n options.color ||\n options.colors;\n if (Array.isArray(colorBuffer)) {\n check$1(\n colorBuffer.length === 1 || extDrawBuffers,\n 'multiple render targets not supported');\n }\n }\n\n if (!colorBuffer) {\n if ('colorCount' in options) {\n colorCount = options.colorCount | 0;\n check$1(colorCount > 0, 'invalid color buffer count');\n }\n\n if ('colorTexture' in options) {\n colorTexture = !!options.colorTexture;\n colorFormat = 'rgba4';\n }\n\n if ('colorType' in options) {\n colorType = options.colorType;\n if (!colorTexture) {\n if (colorType === 'half float' || colorType === 'float16') {\n check$1(extensions.ext_color_buffer_half_float,\n 'you must enable EXT_color_buffer_half_float to use 16-bit render buffers');\n colorFormat = 'rgba16f';\n } else if (colorType === 'float' || colorType === 'float32') {\n check$1(extensions.webgl_color_buffer_float,\n 'you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers');\n colorFormat = 'rgba32f';\n }\n } else {\n check$1(extensions.oes_texture_float ||\n !(colorType === 'float' || colorType === 'float32'),\n 'you must enable OES_texture_float in order to use floating point framebuffer objects');\n check$1(extensions.oes_texture_half_float ||\n !(colorType === 'half float' || colorType === 'float16'),\n 'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects');\n }\n check$1.oneOf(colorType, colorTypes, 'invalid color type');\n }\n\n if ('colorFormat' in options) {\n colorFormat = options.colorFormat;\n if (colorTextureFormats.indexOf(colorFormat) >= 0) {\n colorTexture = true;\n } else if (colorRenderbufferFormats.indexOf(colorFormat) >= 0) {\n colorTexture = false;\n } else {\n if (colorTexture) {\n check$1.oneOf(\n options.colorFormat, colorTextureFormats,\n 'invalid color format for texture');\n } else {\n check$1.oneOf(\n options.colorFormat, colorRenderbufferFormats,\n 'invalid color format for renderbuffer');\n }\n }\n }\n }\n\n if ('depthTexture' in options || 'depthStencilTexture' in options) {\n depthStencilTexture = !!(options.depthTexture ||\n options.depthStencilTexture);\n check$1(!depthStencilTexture || extensions.webgl_depth_texture,\n 'webgl_depth_texture extension not supported');\n }\n\n if ('depth' in options) {\n if (typeof options.depth === 'boolean') {\n needsDepth = options.depth;\n } else {\n depthBuffer = options.depth;\n needsStencil = false;\n }\n }\n\n if ('stencil' in options) {\n if (typeof options.stencil === 'boolean') {\n needsStencil = options.stencil;\n } else {\n stencilBuffer = options.stencil;\n needsDepth = false;\n }\n }\n\n if ('depthStencil' in options) {\n if (typeof options.depthStencil === 'boolean') {\n needsDepth = needsStencil = options.depthStencil;\n } else {\n depthStencilBuffer = options.depthStencil;\n needsDepth = false;\n needsStencil = false;\n }\n }\n }\n\n // parse attachments\n var colorAttachments = null;\n var depthAttachment = null;\n var stencilAttachment = null;\n var depthStencilAttachment = null;\n\n // Set up color attachments\n if (Array.isArray(colorBuffer)) {\n colorAttachments = colorBuffer.map(parseAttachment);\n } else if (colorBuffer) {\n colorAttachments = [parseAttachment(colorBuffer)];\n } else {\n colorAttachments = new Array(colorCount);\n for (i = 0; i < colorCount; ++i) {\n colorAttachments[i] = allocAttachment(\n width,\n height,\n colorTexture,\n colorFormat,\n colorType);\n }\n }\n\n check$1(extensions.webgl_draw_buffers || colorAttachments.length <= 1,\n 'you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers.');\n check$1(colorAttachments.length <= limits.maxColorAttachments,\n 'too many color attachments, not supported');\n\n width = width || colorAttachments[0].width;\n height = height || colorAttachments[0].height;\n\n if (depthBuffer) {\n depthAttachment = parseAttachment(depthBuffer);\n } else if (needsDepth && !needsStencil) {\n depthAttachment = allocAttachment(\n width,\n height,\n depthStencilTexture,\n 'depth',\n 'uint32');\n }\n\n if (stencilBuffer) {\n stencilAttachment = parseAttachment(stencilBuffer);\n } else if (needsStencil && !needsDepth) {\n stencilAttachment = allocAttachment(\n width,\n height,\n false,\n 'stencil',\n 'uint8');\n }\n\n if (depthStencilBuffer) {\n depthStencilAttachment = parseAttachment(depthStencilBuffer);\n } else if (!depthBuffer && !stencilBuffer && needsStencil && needsDepth) {\n depthStencilAttachment = allocAttachment(\n width,\n height,\n depthStencilTexture,\n 'depth stencil',\n 'depth stencil');\n }\n\n check$1(\n (!!depthBuffer) + (!!stencilBuffer) + (!!depthStencilBuffer) <= 1,\n 'invalid framebuffer configuration, can specify exactly one depth/stencil attachment');\n\n var commonColorAttachmentSize = null;\n\n for (i = 0; i < colorAttachments.length; ++i) {\n incRefAndCheckShape(colorAttachments[i], width, height);\n check$1(!colorAttachments[i] ||\n (colorAttachments[i].texture &&\n colorTextureFormatEnums.indexOf(colorAttachments[i].texture._texture.format) >= 0) ||\n (colorAttachments[i].renderbuffer &&\n colorRenderbufferFormatEnums.indexOf(colorAttachments[i].renderbuffer._renderbuffer.format) >= 0),\n 'framebuffer color attachment ' + i + ' is invalid');\n\n if (colorAttachments[i] && colorAttachments[i].texture) {\n var colorAttachmentSize =\n textureFormatChannels[colorAttachments[i].texture._texture.format] *\n textureTypeSizes[colorAttachments[i].texture._texture.type];\n\n if (commonColorAttachmentSize === null) {\n commonColorAttachmentSize = colorAttachmentSize;\n } else {\n // We need to make sure that all color attachments have the same number of bitplanes\n // (that is, the same numer of bits per pixel)\n // This is required by the GLES2.0 standard. See the beginning of Chapter 4 in that document.\n check$1(commonColorAttachmentSize === colorAttachmentSize,\n 'all color attachments much have the same number of bits per pixel.');\n }\n }\n }\n incRefAndCheckShape(depthAttachment, width, height);\n check$1(!depthAttachment ||\n (depthAttachment.texture &&\n depthAttachment.texture._texture.format === GL_DEPTH_COMPONENT$1) ||\n (depthAttachment.renderbuffer &&\n depthAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_COMPONENT16$1),\n 'invalid depth attachment for framebuffer object');\n incRefAndCheckShape(stencilAttachment, width, height);\n check$1(!stencilAttachment ||\n (stencilAttachment.renderbuffer &&\n stencilAttachment.renderbuffer._renderbuffer.format === GL_STENCIL_INDEX8$1),\n 'invalid stencil attachment for framebuffer object');\n incRefAndCheckShape(depthStencilAttachment, width, height);\n check$1(!depthStencilAttachment ||\n (depthStencilAttachment.texture &&\n depthStencilAttachment.texture._texture.format === GL_DEPTH_STENCIL$2) ||\n (depthStencilAttachment.renderbuffer &&\n depthStencilAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_STENCIL$2),\n 'invalid depth-stencil attachment for framebuffer object');\n\n // decrement references\n decFBORefs(framebuffer);\n\n framebuffer.width = width;\n framebuffer.height = height;\n\n framebuffer.colorAttachments = colorAttachments;\n framebuffer.depthAttachment = depthAttachment;\n framebuffer.stencilAttachment = stencilAttachment;\n framebuffer.depthStencilAttachment = depthStencilAttachment;\n\n reglFramebuffer.color = colorAttachments.map(unwrapAttachment);\n reglFramebuffer.depth = unwrapAttachment(depthAttachment);\n reglFramebuffer.stencil = unwrapAttachment(stencilAttachment);\n reglFramebuffer.depthStencil = unwrapAttachment(depthStencilAttachment);\n\n reglFramebuffer.width = framebuffer.width;\n reglFramebuffer.height = framebuffer.height;\n\n updateFramebuffer(framebuffer);\n\n return reglFramebuffer\n }\n\n function resize (w_, h_) {\n check$1(framebufferState.next !== framebuffer,\n 'can not resize a framebuffer which is currently in use');\n\n var w = w_ | 0;\n var h = (h_ | 0) || w;\n if (w === framebuffer.width && h === framebuffer.height) {\n return reglFramebuffer\n }\n\n // resize all buffers\n var colorAttachments = framebuffer.colorAttachments;\n for (var i = 0; i < colorAttachments.length; ++i) {\n resizeAttachment(colorAttachments[i], w, h);\n }\n resizeAttachment(framebuffer.depthAttachment, w, h);\n resizeAttachment(framebuffer.stencilAttachment, w, h);\n resizeAttachment(framebuffer.depthStencilAttachment, w, h);\n\n framebuffer.width = reglFramebuffer.width = w;\n framebuffer.height = reglFramebuffer.height = h;\n\n updateFramebuffer(framebuffer);\n\n return reglFramebuffer\n }\n\n reglFramebuffer(a0, a1);\n\n return extend(reglFramebuffer, {\n resize: resize,\n _reglType: 'framebuffer',\n _framebuffer: framebuffer,\n destroy: function () {\n destroy(framebuffer);\n decFBORefs(framebuffer);\n },\n use: function (block) {\n framebufferState.setFBO({\n framebuffer: reglFramebuffer\n }, block);\n }\n })\n }\n\n function createCubeFBO (options) {\n var faces = Array(6);\n\n function reglFramebufferCube (a) {\n var i;\n\n check$1(faces.indexOf(framebufferState.next) < 0,\n 'can not update framebuffer which is currently in use');\n\n var extDrawBuffers = extensions.webgl_draw_buffers;\n\n var params = {\n color: null\n };\n\n var radius = 0;\n\n var colorBuffer = null;\n var colorFormat = 'rgba';\n var colorType = 'uint8';\n var colorCount = 1;\n\n if (typeof a === 'number') {\n radius = a | 0;\n } else if (!a) {\n radius = 1;\n } else {\n check$1.type(a, 'object', 'invalid arguments for framebuffer');\n var options = a;\n\n if ('shape' in options) {\n var shape = options.shape;\n check$1(\n Array.isArray(shape) && shape.length >= 2,\n 'invalid shape for framebuffer');\n check$1(\n shape[0] === shape[1],\n 'cube framebuffer must be square');\n radius = shape[0];\n } else {\n if ('radius' in options) {\n radius = options.radius | 0;\n }\n if ('width' in options) {\n radius = options.width | 0;\n if ('height' in options) {\n check$1(options.height === radius, 'must be square');\n }\n } else if ('height' in options) {\n radius = options.height | 0;\n }\n }\n\n if ('color' in options ||\n 'colors' in options) {\n colorBuffer =\n options.color ||\n options.colors;\n if (Array.isArray(colorBuffer)) {\n check$1(\n colorBuffer.length === 1 || extDrawBuffers,\n 'multiple render targets not supported');\n }\n }\n\n if (!colorBuffer) {\n if ('colorCount' in options) {\n colorCount = options.colorCount | 0;\n check$1(colorCount > 0, 'invalid color buffer count');\n }\n\n if ('colorType' in options) {\n check$1.oneOf(\n options.colorType, colorTypes,\n 'invalid color type');\n colorType = options.colorType;\n }\n\n if ('colorFormat' in options) {\n colorFormat = options.colorFormat;\n check$1.oneOf(\n options.colorFormat, colorTextureFormats,\n 'invalid color format for texture');\n }\n }\n\n if ('depth' in options) {\n params.depth = options.depth;\n }\n\n if ('stencil' in options) {\n params.stencil = options.stencil;\n }\n\n if ('depthStencil' in options) {\n params.depthStencil = options.depthStencil;\n }\n }\n\n var colorCubes;\n if (colorBuffer) {\n if (Array.isArray(colorBuffer)) {\n colorCubes = [];\n for (i = 0; i < colorBuffer.length; ++i) {\n colorCubes[i] = colorBuffer[i];\n }\n } else {\n colorCubes = [ colorBuffer ];\n }\n } else {\n colorCubes = Array(colorCount);\n var cubeMapParams = {\n radius: radius,\n format: colorFormat,\n type: colorType\n };\n for (i = 0; i < colorCount; ++i) {\n colorCubes[i] = textureState.createCube(cubeMapParams);\n }\n }\n\n // Check color cubes\n params.color = Array(colorCubes.length);\n for (i = 0; i < colorCubes.length; ++i) {\n var cube = colorCubes[i];\n check$1(\n typeof cube === 'function' && cube._reglType === 'textureCube',\n 'invalid cube map');\n radius = radius || cube.width;\n check$1(\n cube.width === radius && cube.height === radius,\n 'invalid cube map shape');\n params.color[i] = {\n target: GL_TEXTURE_CUBE_MAP_POSITIVE_X$1,\n data: colorCubes[i]\n };\n }\n\n for (i = 0; i < 6; ++i) {\n for (var j = 0; j < colorCubes.length; ++j) {\n params.color[j].target = GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i;\n }\n // reuse depth-stencil attachments across all cube maps\n if (i > 0) {\n params.depth = faces[0].depth;\n params.stencil = faces[0].stencil;\n params.depthStencil = faces[0].depthStencil;\n }\n if (faces[i]) {\n (faces[i])(params);\n } else {\n faces[i] = createFBO(params);\n }\n }\n\n return extend(reglFramebufferCube, {\n width: radius,\n height: radius,\n color: colorCubes\n })\n }\n\n function resize (radius_) {\n var i;\n var radius = radius_ | 0;\n check$1(radius > 0 && radius <= limits.maxCubeMapSize,\n 'invalid radius for cube fbo');\n\n if (radius === reglFramebufferCube.width) {\n return reglFramebufferCube\n }\n\n var colors = reglFramebufferCube.color;\n for (i = 0; i < colors.length; ++i) {\n colors[i].resize(radius);\n }\n\n for (i = 0; i < 6; ++i) {\n faces[i].resize(radius);\n }\n\n reglFramebufferCube.width = reglFramebufferCube.height = radius;\n\n return reglFramebufferCube\n }\n\n reglFramebufferCube(options);\n\n return extend(reglFramebufferCube, {\n faces: faces,\n resize: resize,\n _reglType: 'framebufferCube',\n destroy: function () {\n faces.forEach(function (f) {\n f.destroy();\n });\n }\n })\n }\n\n function restoreFramebuffers () {\n values(framebufferSet).forEach(function (fb) {\n fb.framebuffer = gl.createFramebuffer();\n updateFramebuffer(fb);\n });\n }\n\n return extend(framebufferState, {\n getFramebuffer: function (object) {\n if (typeof object === 'function' && object._reglType === 'framebuffer') {\n var fbo = object._framebuffer;\n if (fbo instanceof REGLFramebuffer) {\n return fbo\n }\n }\n return null\n },\n create: createFBO,\n createCube: createCubeFBO,\n clear: function () {\n values(framebufferSet).forEach(destroy);\n },\n restore: restoreFramebuffers\n })\n}\n\nvar GL_FLOAT$5 = 5126;\n\nfunction AttributeRecord () {\n this.state = 0;\n\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n this.w = 0.0;\n\n this.buffer = null;\n this.size = 0;\n this.normalized = false;\n this.type = GL_FLOAT$5;\n this.offset = 0;\n this.stride = 0;\n this.divisor = 0;\n}\n\nfunction wrapAttributeState (\n gl,\n extensions,\n limits,\n bufferState,\n stringStore) {\n var NUM_ATTRIBUTES = limits.maxAttributes;\n var attributeBindings = new Array(NUM_ATTRIBUTES);\n for (var i = 0; i < NUM_ATTRIBUTES; ++i) {\n attributeBindings[i] = new AttributeRecord();\n }\n\n return {\n Record: AttributeRecord,\n scope: {},\n state: attributeBindings\n }\n}\n\nvar GL_FRAGMENT_SHADER = 35632;\nvar GL_VERTEX_SHADER = 35633;\n\nvar GL_ACTIVE_UNIFORMS = 0x8B86;\nvar GL_ACTIVE_ATTRIBUTES = 0x8B89;\n\nfunction wrapShaderState (gl, stringStore, stats, config) {\n // ===================================================\n // glsl compilation and linking\n // ===================================================\n var fragShaders = {};\n var vertShaders = {};\n\n function ActiveInfo (name, id, location, info) {\n this.name = name;\n this.id = id;\n this.location = location;\n this.info = info;\n }\n\n function insertActiveInfo (list, info) {\n for (var i = 0; i < list.length; ++i) {\n if (list[i].id === info.id) {\n list[i].location = info.location;\n return\n }\n }\n list.push(info);\n }\n\n function getShader (type, id, command) {\n var cache = type === GL_FRAGMENT_SHADER ? fragShaders : vertShaders;\n var shader = cache[id];\n\n if (!shader) {\n var source = stringStore.str(id);\n shader = gl.createShader(type);\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n check$1.shaderError(gl, shader, source, type, command);\n cache[id] = shader;\n }\n\n return shader\n }\n\n // ===================================================\n // program linking\n // ===================================================\n var programCache = {};\n var programList = [];\n\n var PROGRAM_COUNTER = 0;\n\n function REGLProgram (fragId, vertId) {\n this.id = PROGRAM_COUNTER++;\n this.fragId = fragId;\n this.vertId = vertId;\n this.program = null;\n this.uniforms = [];\n this.attributes = [];\n\n if (config.profile) {\n this.stats = {\n uniformsCount: 0,\n attributesCount: 0\n };\n }\n }\n\n function linkProgram (desc, command) {\n var i, info;\n\n // -------------------------------\n // compile & link\n // -------------------------------\n var fragShader = getShader(GL_FRAGMENT_SHADER, desc.fragId);\n var vertShader = getShader(GL_VERTEX_SHADER, desc.vertId);\n\n var program = desc.program = gl.createProgram();\n gl.attachShader(program, fragShader);\n gl.attachShader(program, vertShader);\n gl.linkProgram(program);\n check$1.linkError(\n gl,\n program,\n stringStore.str(desc.fragId),\n stringStore.str(desc.vertId),\n command);\n\n // -------------------------------\n // grab uniforms\n // -------------------------------\n var numUniforms = gl.getProgramParameter(program, GL_ACTIVE_UNIFORMS);\n if (config.profile) {\n desc.stats.uniformsCount = numUniforms;\n }\n var uniforms = desc.uniforms;\n for (i = 0; i < numUniforms; ++i) {\n info = gl.getActiveUniform(program, i);\n if (info) {\n if (info.size > 1) {\n for (var j = 0; j < info.size; ++j) {\n var name = info.name.replace('[0]', '[' + j + ']');\n insertActiveInfo(uniforms, new ActiveInfo(\n name,\n stringStore.id(name),\n gl.getUniformLocation(program, name),\n info));\n }\n } else {\n insertActiveInfo(uniforms, new ActiveInfo(\n info.name,\n stringStore.id(info.name),\n gl.getUniformLocation(program, info.name),\n info));\n }\n }\n }\n\n // -------------------------------\n // grab attributes\n // -------------------------------\n var numAttributes = gl.getProgramParameter(program, GL_ACTIVE_ATTRIBUTES);\n if (config.profile) {\n desc.stats.attributesCount = numAttributes;\n }\n\n var attributes = desc.attributes;\n for (i = 0; i < numAttributes; ++i) {\n info = gl.getActiveAttrib(program, i);\n if (info) {\n insertActiveInfo(attributes, new ActiveInfo(\n info.name,\n stringStore.id(info.name),\n gl.getAttribLocation(program, info.name),\n info));\n }\n }\n }\n\n if (config.profile) {\n stats.getMaxUniformsCount = function () {\n var m = 0;\n programList.forEach(function (desc) {\n if (desc.stats.uniformsCount > m) {\n m = desc.stats.uniformsCount;\n }\n });\n return m\n };\n\n stats.getMaxAttributesCount = function () {\n var m = 0;\n programList.forEach(function (desc) {\n if (desc.stats.attributesCount > m) {\n m = desc.stats.attributesCount;\n }\n });\n return m\n };\n }\n\n function restoreShaders () {\n fragShaders = {};\n vertShaders = {};\n for (var i = 0; i < programList.length; ++i) {\n linkProgram(programList[i]);\n }\n }\n\n return {\n clear: function () {\n var deleteShader = gl.deleteShader.bind(gl);\n values(fragShaders).forEach(deleteShader);\n fragShaders = {};\n values(vertShaders).forEach(deleteShader);\n vertShaders = {};\n\n programList.forEach(function (desc) {\n gl.deleteProgram(desc.program);\n });\n programList.length = 0;\n programCache = {};\n\n stats.shaderCount = 0;\n },\n\n program: function (vertId, fragId, command) {\n check$1.command(vertId >= 0, 'missing vertex shader', command);\n check$1.command(fragId >= 0, 'missing fragment shader', command);\n\n var cache = programCache[fragId];\n if (!cache) {\n cache = programCache[fragId] = {};\n }\n var program = cache[vertId];\n if (!program) {\n program = new REGLProgram(fragId, vertId);\n stats.shaderCount++;\n\n linkProgram(program, command);\n cache[vertId] = program;\n programList.push(program);\n }\n return program\n },\n\n restore: restoreShaders,\n\n shader: getShader,\n\n frag: -1,\n vert: -1\n }\n}\n\nvar GL_RGBA$2 = 6408;\nvar GL_UNSIGNED_BYTE$6 = 5121;\nvar GL_PACK_ALIGNMENT = 0x0D05;\nvar GL_FLOAT$6 = 0x1406; // 5126\n\nfunction wrapReadPixels (\n gl,\n framebufferState,\n reglPoll,\n context,\n glAttributes,\n extensions) {\n function readPixelsImpl (input) {\n var type;\n if (framebufferState.next === null) {\n check$1(\n glAttributes.preserveDrawingBuffer,\n 'you must create a webgl context with \"preserveDrawingBuffer\":true in order to read pixels from the drawing buffer');\n type = GL_UNSIGNED_BYTE$6;\n } else {\n check$1(\n framebufferState.next.colorAttachments[0].texture !== null,\n 'You cannot read from a renderbuffer');\n type = framebufferState.next.colorAttachments[0].texture._texture.type;\n\n if (extensions.oes_texture_float) {\n check$1(\n type === GL_UNSIGNED_BYTE$6 || type === GL_FLOAT$6,\n 'Reading from a framebuffer is only allowed for the types \\'uint8\\' and \\'float\\'');\n } else {\n check$1(\n type === GL_UNSIGNED_BYTE$6,\n 'Reading from a framebuffer is only allowed for the type \\'uint8\\'');\n }\n }\n\n var x = 0;\n var y = 0;\n var width = context.framebufferWidth;\n var height = context.framebufferHeight;\n var data = null;\n\n if (isTypedArray(input)) {\n data = input;\n } else if (input) {\n check$1.type(input, 'object', 'invalid arguments to regl.read()');\n x = input.x | 0;\n y = input.y | 0;\n check$1(\n x >= 0 && x < context.framebufferWidth,\n 'invalid x offset for regl.read');\n check$1(\n y >= 0 && y < context.framebufferHeight,\n 'invalid y offset for regl.read');\n width = (input.width || (context.framebufferWidth - x)) | 0;\n height = (input.height || (context.framebufferHeight - y)) | 0;\n data = input.data || null;\n }\n\n // sanity check input.data\n if (data) {\n if (type === GL_UNSIGNED_BYTE$6) {\n check$1(\n data instanceof Uint8Array,\n 'buffer must be \\'Uint8Array\\' when reading from a framebuffer of type \\'uint8\\'');\n } else if (type === GL_FLOAT$6) {\n check$1(\n data instanceof Float32Array,\n 'buffer must be \\'Float32Array\\' when reading from a framebuffer of type \\'float\\'');\n }\n }\n\n check$1(\n width > 0 && width + x <= context.framebufferWidth,\n 'invalid width for read pixels');\n check$1(\n height > 0 && height + y <= context.framebufferHeight,\n 'invalid height for read pixels');\n\n // Update WebGL state\n reglPoll();\n\n // Compute size\n var size = width * height * 4;\n\n // Allocate data\n if (!data) {\n if (type === GL_UNSIGNED_BYTE$6) {\n data = new Uint8Array(size);\n } else if (type === GL_FLOAT$6) {\n data = data || new Float32Array(size);\n }\n }\n\n // Type check\n check$1.isTypedArray(data, 'data buffer for regl.read() must be a typedarray');\n check$1(data.byteLength >= size, 'data buffer for regl.read() too small');\n\n // Run read pixels\n gl.pixelStorei(GL_PACK_ALIGNMENT, 4);\n gl.readPixels(x, y, width, height, GL_RGBA$2,\n type,\n data);\n\n return data\n }\n\n function readPixelsFBO (options) {\n var result;\n framebufferState.setFBO({\n framebuffer: options.framebuffer\n }, function () {\n result = readPixelsImpl(options);\n });\n return result\n }\n\n function readPixels (options) {\n if (!options || !('framebuffer' in options)) {\n return readPixelsImpl(options)\n } else {\n return readPixelsFBO(options)\n }\n }\n\n return readPixels\n}\n\nfunction slice (x) {\n return Array.prototype.slice.call(x)\n}\n\nfunction join (x) {\n return slice(x).join('')\n}\n\nfunction createEnvironment () {\n // Unique variable id counter\n var varCounter = 0;\n\n // Linked values are passed from this scope into the generated code block\n // Calling link() passes a value into the generated scope and returns\n // the variable name which it is bound to\n var linkedNames = [];\n var linkedValues = [];\n function link (value) {\n for (var i = 0; i < linkedValues.length; ++i) {\n if (linkedValues[i] === value) {\n return linkedNames[i]\n }\n }\n\n var name = 'g' + (varCounter++);\n linkedNames.push(name);\n linkedValues.push(value);\n return name\n }\n\n // create a code block\n function block () {\n var code = [];\n function push () {\n code.push.apply(code, slice(arguments));\n }\n\n var vars = [];\n function def () {\n var name = 'v' + (varCounter++);\n vars.push(name);\n\n if (arguments.length > 0) {\n code.push(name, '=');\n code.push.apply(code, slice(arguments));\n code.push(';');\n }\n\n return name\n }\n\n return extend(push, {\n def: def,\n toString: function () {\n return join([\n (vars.length > 0 ? 'var ' + vars + ';' : ''),\n join(code)\n ])\n }\n })\n }\n\n function scope () {\n var entry = block();\n var exit = block();\n\n var entryToString = entry.toString;\n var exitToString = exit.toString;\n\n function save (object, prop) {\n exit(object, prop, '=', entry.def(object, prop), ';');\n }\n\n return extend(function () {\n entry.apply(entry, slice(arguments));\n }, {\n def: entry.def,\n entry: entry,\n exit: exit,\n save: save,\n set: function (object, prop, value) {\n save(object, prop);\n entry(object, prop, '=', value, ';');\n },\n toString: function () {\n return entryToString() + exitToString()\n }\n })\n }\n\n function conditional () {\n var pred = join(arguments);\n var thenBlock = scope();\n var elseBlock = scope();\n\n var thenToString = thenBlock.toString;\n var elseToString = elseBlock.toString;\n\n return extend(thenBlock, {\n then: function () {\n thenBlock.apply(thenBlock, slice(arguments));\n return this\n },\n else: function () {\n elseBlock.apply(elseBlock, slice(arguments));\n return this\n },\n toString: function () {\n var elseClause = elseToString();\n if (elseClause) {\n elseClause = 'else{' + elseClause + '}';\n }\n return join([\n 'if(', pred, '){',\n thenToString(),\n '}', elseClause\n ])\n }\n })\n }\n\n // procedure list\n var globalBlock = block();\n var procedures = {};\n function proc (name, count) {\n var args = [];\n function arg () {\n var name = 'a' + args.length;\n args.push(name);\n return name\n }\n\n count = count || 0;\n for (var i = 0; i < count; ++i) {\n arg();\n }\n\n var body = scope();\n var bodyToString = body.toString;\n\n var result = procedures[name] = extend(body, {\n arg: arg,\n toString: function () {\n return join([\n 'function(', args.join(), '){',\n bodyToString(),\n '}'\n ])\n }\n });\n\n return result\n }\n\n function compile () {\n var code = ['\"use strict\";',\n globalBlock,\n 'return {'];\n Object.keys(procedures).forEach(function (name) {\n code.push('\"', name, '\":', procedures[name].toString(), ',');\n });\n code.push('}');\n var src = join(code)\n .replace(/;/g, ';\\n')\n .replace(/}/g, '}\\n')\n .replace(/{/g, '{\\n');\n var proc = Function.apply(null, linkedNames.concat(src));\n return proc.apply(null, linkedValues)\n }\n\n return {\n global: globalBlock,\n link: link,\n block: block,\n proc: proc,\n scope: scope,\n cond: conditional,\n compile: compile\n }\n}\n\n// \"cute\" names for vector components\nvar CUTE_COMPONENTS = 'xyzw'.split('');\n\nvar GL_UNSIGNED_BYTE$7 = 5121;\n\nvar ATTRIB_STATE_POINTER = 1;\nvar ATTRIB_STATE_CONSTANT = 2;\n\nvar DYN_FUNC$1 = 0;\nvar DYN_PROP$1 = 1;\nvar DYN_CONTEXT$1 = 2;\nvar DYN_STATE$1 = 3;\nvar DYN_THUNK = 4;\n\nvar S_DITHER = 'dither';\nvar S_BLEND_ENABLE = 'blend.enable';\nvar S_BLEND_COLOR = 'blend.color';\nvar S_BLEND_EQUATION = 'blend.equation';\nvar S_BLEND_FUNC = 'blend.func';\nvar S_DEPTH_ENABLE = 'depth.enable';\nvar S_DEPTH_FUNC = 'depth.func';\nvar S_DEPTH_RANGE = 'depth.range';\nvar S_DEPTH_MASK = 'depth.mask';\nvar S_COLOR_MASK = 'colorMask';\nvar S_CULL_ENABLE = 'cull.enable';\nvar S_CULL_FACE = 'cull.face';\nvar S_FRONT_FACE = 'frontFace';\nvar S_LINE_WIDTH = 'lineWidth';\nvar S_POLYGON_OFFSET_ENABLE = 'polygonOffset.enable';\nvar S_POLYGON_OFFSET_OFFSET = 'polygonOffset.offset';\nvar S_SAMPLE_ALPHA = 'sample.alpha';\nvar S_SAMPLE_ENABLE = 'sample.enable';\nvar S_SAMPLE_COVERAGE = 'sample.coverage';\nvar S_STENCIL_ENABLE = 'stencil.enable';\nvar S_STENCIL_MASK = 'stencil.mask';\nvar S_STENCIL_FUNC = 'stencil.func';\nvar S_STENCIL_OPFRONT = 'stencil.opFront';\nvar S_STENCIL_OPBACK = 'stencil.opBack';\nvar S_SCISSOR_ENABLE = 'scissor.enable';\nvar S_SCISSOR_BOX = 'scissor.box';\nvar S_VIEWPORT = 'viewport';\n\nvar S_PROFILE = 'profile';\n\nvar S_FRAMEBUFFER = 'framebuffer';\nvar S_VERT = 'vert';\nvar S_FRAG = 'frag';\nvar S_ELEMENTS = 'elements';\nvar S_PRIMITIVE = 'primitive';\nvar S_COUNT = 'count';\nvar S_OFFSET = 'offset';\nvar S_INSTANCES = 'instances';\n\nvar SUFFIX_WIDTH = 'Width';\nvar SUFFIX_HEIGHT = 'Height';\n\nvar S_FRAMEBUFFER_WIDTH = S_FRAMEBUFFER + SUFFIX_WIDTH;\nvar S_FRAMEBUFFER_HEIGHT = S_FRAMEBUFFER + SUFFIX_HEIGHT;\nvar S_VIEWPORT_WIDTH = S_VIEWPORT + SUFFIX_WIDTH;\nvar S_VIEWPORT_HEIGHT = S_VIEWPORT + SUFFIX_HEIGHT;\nvar S_DRAWINGBUFFER = 'drawingBuffer';\nvar S_DRAWINGBUFFER_WIDTH = S_DRAWINGBUFFER + SUFFIX_WIDTH;\nvar S_DRAWINGBUFFER_HEIGHT = S_DRAWINGBUFFER + SUFFIX_HEIGHT;\n\nvar NESTED_OPTIONS = [\n S_BLEND_FUNC,\n S_BLEND_EQUATION,\n S_STENCIL_FUNC,\n S_STENCIL_OPFRONT,\n S_STENCIL_OPBACK,\n S_SAMPLE_COVERAGE,\n S_VIEWPORT,\n S_SCISSOR_BOX,\n S_POLYGON_OFFSET_OFFSET\n];\n\nvar GL_ARRAY_BUFFER$1 = 34962;\nvar GL_ELEMENT_ARRAY_BUFFER$1 = 34963;\n\nvar GL_FRAGMENT_SHADER$1 = 35632;\nvar GL_VERTEX_SHADER$1 = 35633;\n\nvar GL_TEXTURE_2D$2 = 0x0DE1;\nvar GL_TEXTURE_CUBE_MAP$1 = 0x8513;\n\nvar GL_CULL_FACE = 0x0B44;\nvar GL_BLEND = 0x0BE2;\nvar GL_DITHER = 0x0BD0;\nvar GL_STENCIL_TEST = 0x0B90;\nvar GL_DEPTH_TEST = 0x0B71;\nvar GL_SCISSOR_TEST = 0x0C11;\nvar GL_POLYGON_OFFSET_FILL = 0x8037;\nvar GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;\nvar GL_SAMPLE_COVERAGE = 0x80A0;\n\nvar GL_FLOAT$7 = 5126;\nvar GL_FLOAT_VEC2 = 35664;\nvar GL_FLOAT_VEC3 = 35665;\nvar GL_FLOAT_VEC4 = 35666;\nvar GL_INT$3 = 5124;\nvar GL_INT_VEC2 = 35667;\nvar GL_INT_VEC3 = 35668;\nvar GL_INT_VEC4 = 35669;\nvar GL_BOOL = 35670;\nvar GL_BOOL_VEC2 = 35671;\nvar GL_BOOL_VEC3 = 35672;\nvar GL_BOOL_VEC4 = 35673;\nvar GL_FLOAT_MAT2 = 35674;\nvar GL_FLOAT_MAT3 = 35675;\nvar GL_FLOAT_MAT4 = 35676;\nvar GL_SAMPLER_2D = 35678;\nvar GL_SAMPLER_CUBE = 35680;\n\nvar GL_TRIANGLES$1 = 4;\n\nvar GL_FRONT = 1028;\nvar GL_BACK = 1029;\nvar GL_CW = 0x0900;\nvar GL_CCW = 0x0901;\nvar GL_MIN_EXT = 0x8007;\nvar GL_MAX_EXT = 0x8008;\nvar GL_ALWAYS = 519;\nvar GL_KEEP = 7680;\nvar GL_ZERO = 0;\nvar GL_ONE = 1;\nvar GL_FUNC_ADD = 0x8006;\nvar GL_LESS = 513;\n\nvar GL_FRAMEBUFFER$1 = 0x8D40;\nvar GL_COLOR_ATTACHMENT0$1 = 0x8CE0;\n\nvar blendFuncs = {\n '0': 0,\n '1': 1,\n 'zero': 0,\n 'one': 1,\n 'src color': 768,\n 'one minus src color': 769,\n 'src alpha': 770,\n 'one minus src alpha': 771,\n 'dst color': 774,\n 'one minus dst color': 775,\n 'dst alpha': 772,\n 'one minus dst alpha': 773,\n 'constant color': 32769,\n 'one minus constant color': 32770,\n 'constant alpha': 32771,\n 'one minus constant alpha': 32772,\n 'src alpha saturate': 776\n};\n\n// There are invalid values for srcRGB and dstRGB. See:\n// https://www.khronos.org/registry/webgl/specs/1.0/#6.13\n// https://github.com/KhronosGroup/WebGL/blob/0d3201f5f7ec3c0060bc1f04077461541f1987b9/conformance-suites/1.0.3/conformance/misc/webgl-specific.html#L56\nvar invalidBlendCombinations = [\n 'constant color, constant alpha',\n 'one minus constant color, constant alpha',\n 'constant color, one minus constant alpha',\n 'one minus constant color, one minus constant alpha',\n 'constant alpha, constant color',\n 'constant alpha, one minus constant color',\n 'one minus constant alpha, constant color',\n 'one minus constant alpha, one minus constant color'\n];\n\nvar compareFuncs = {\n 'never': 512,\n 'less': 513,\n '<': 513,\n 'equal': 514,\n '=': 514,\n '==': 514,\n '===': 514,\n 'lequal': 515,\n '<=': 515,\n 'greater': 516,\n '>': 516,\n 'notequal': 517,\n '!=': 517,\n '!==': 517,\n 'gequal': 518,\n '>=': 518,\n 'always': 519\n};\n\nvar stencilOps = {\n '0': 0,\n 'zero': 0,\n 'keep': 7680,\n 'replace': 7681,\n 'increment': 7682,\n 'decrement': 7683,\n 'increment wrap': 34055,\n 'decrement wrap': 34056,\n 'invert': 5386\n};\n\nvar shaderType = {\n 'frag': GL_FRAGMENT_SHADER$1,\n 'vert': GL_VERTEX_SHADER$1\n};\n\nvar orientationType = {\n 'cw': GL_CW,\n 'ccw': GL_CCW\n};\n\nfunction isBufferArgs (x) {\n return Array.isArray(x) ||\n isTypedArray(x) ||\n isNDArrayLike(x)\n}\n\n// Make sure viewport is processed first\nfunction sortState (state) {\n return state.sort(function (a, b) {\n if (a === S_VIEWPORT) {\n return -1\n } else if (b === S_VIEWPORT) {\n return 1\n }\n return (a < b) ? -1 : 1\n })\n}\n\nfunction Declaration (thisDep, contextDep, propDep, append) {\n this.thisDep = thisDep;\n this.contextDep = contextDep;\n this.propDep = propDep;\n this.append = append;\n}\n\nfunction isStatic (decl) {\n return decl && !(decl.thisDep || decl.contextDep || decl.propDep)\n}\n\nfunction createStaticDecl (append) {\n return new Declaration(false, false, false, append)\n}\n\nfunction createDynamicDecl (dyn, append) {\n var type = dyn.type;\n if (type === DYN_FUNC$1) {\n var numArgs = dyn.data.length;\n return new Declaration(\n true,\n numArgs >= 1,\n numArgs >= 2,\n append)\n } else if (type === DYN_THUNK) {\n var data = dyn.data;\n return new Declaration(\n data.thisDep,\n data.contextDep,\n data.propDep,\n append)\n } else {\n return new Declaration(\n type === DYN_STATE$1,\n type === DYN_CONTEXT$1,\n type === DYN_PROP$1,\n append)\n }\n}\n\nvar SCOPE_DECL = new Declaration(false, false, false, function () {});\n\nfunction reglCore (\n gl,\n stringStore,\n extensions,\n limits,\n bufferState,\n elementState,\n textureState,\n framebufferState,\n uniformState,\n attributeState,\n shaderState,\n drawState,\n contextState,\n timer,\n config) {\n var AttributeRecord = attributeState.Record;\n\n var blendEquations = {\n 'add': 32774,\n 'subtract': 32778,\n 'reverse subtract': 32779\n };\n if (extensions.ext_blend_minmax) {\n blendEquations.min = GL_MIN_EXT;\n blendEquations.max = GL_MAX_EXT;\n }\n\n var extInstancing = extensions.angle_instanced_arrays;\n var extDrawBuffers = extensions.webgl_draw_buffers;\n\n // ===================================================\n // ===================================================\n // WEBGL STATE\n // ===================================================\n // ===================================================\n var currentState = {\n dirty: true,\n profile: config.profile\n };\n var nextState = {};\n var GL_STATE_NAMES = [];\n var GL_FLAGS = {};\n var GL_VARIABLES = {};\n\n function propName (name) {\n return name.replace('.', '_')\n }\n\n function stateFlag (sname, cap, init) {\n var name = propName(sname);\n GL_STATE_NAMES.push(sname);\n nextState[name] = currentState[name] = !!init;\n GL_FLAGS[name] = cap;\n }\n\n function stateVariable (sname, func, init) {\n var name = propName(sname);\n GL_STATE_NAMES.push(sname);\n if (Array.isArray(init)) {\n currentState[name] = init.slice();\n nextState[name] = init.slice();\n } else {\n currentState[name] = nextState[name] = init;\n }\n GL_VARIABLES[name] = func;\n }\n\n // Dithering\n stateFlag(S_DITHER, GL_DITHER);\n\n // Blending\n stateFlag(S_BLEND_ENABLE, GL_BLEND);\n stateVariable(S_BLEND_COLOR, 'blendColor', [0, 0, 0, 0]);\n stateVariable(S_BLEND_EQUATION, 'blendEquationSeparate',\n [GL_FUNC_ADD, GL_FUNC_ADD]);\n stateVariable(S_BLEND_FUNC, 'blendFuncSeparate',\n [GL_ONE, GL_ZERO, GL_ONE, GL_ZERO]);\n\n // Depth\n stateFlag(S_DEPTH_ENABLE, GL_DEPTH_TEST, true);\n stateVariable(S_DEPTH_FUNC, 'depthFunc', GL_LESS);\n stateVariable(S_DEPTH_RANGE, 'depthRange', [0, 1]);\n stateVariable(S_DEPTH_MASK, 'depthMask', true);\n\n // Color mask\n stateVariable(S_COLOR_MASK, S_COLOR_MASK, [true, true, true, true]);\n\n // Face culling\n stateFlag(S_CULL_ENABLE, GL_CULL_FACE);\n stateVariable(S_CULL_FACE, 'cullFace', GL_BACK);\n\n // Front face orientation\n stateVariable(S_FRONT_FACE, S_FRONT_FACE, GL_CCW);\n\n // Line width\n stateVariable(S_LINE_WIDTH, S_LINE_WIDTH, 1);\n\n // Polygon offset\n stateFlag(S_POLYGON_OFFSET_ENABLE, GL_POLYGON_OFFSET_FILL);\n stateVariable(S_POLYGON_OFFSET_OFFSET, 'polygonOffset', [0, 0]);\n\n // Sample coverage\n stateFlag(S_SAMPLE_ALPHA, GL_SAMPLE_ALPHA_TO_COVERAGE);\n stateFlag(S_SAMPLE_ENABLE, GL_SAMPLE_COVERAGE);\n stateVariable(S_SAMPLE_COVERAGE, 'sampleCoverage', [1, false]);\n\n // Stencil\n stateFlag(S_STENCIL_ENABLE, GL_STENCIL_TEST);\n stateVariable(S_STENCIL_MASK, 'stencilMask', -1);\n stateVariable(S_STENCIL_FUNC, 'stencilFunc', [GL_ALWAYS, 0, -1]);\n stateVariable(S_STENCIL_OPFRONT, 'stencilOpSeparate',\n [GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP]);\n stateVariable(S_STENCIL_OPBACK, 'stencilOpSeparate',\n [GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP]);\n\n // Scissor\n stateFlag(S_SCISSOR_ENABLE, GL_SCISSOR_TEST);\n stateVariable(S_SCISSOR_BOX, 'scissor',\n [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]);\n\n // Viewport\n stateVariable(S_VIEWPORT, S_VIEWPORT,\n [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight]);\n\n // ===================================================\n // ===================================================\n // ENVIRONMENT\n // ===================================================\n // ===================================================\n var sharedState = {\n gl: gl,\n context: contextState,\n strings: stringStore,\n next: nextState,\n current: currentState,\n draw: drawState,\n elements: elementState,\n buffer: bufferState,\n shader: shaderState,\n attributes: attributeState.state,\n uniforms: uniformState,\n framebuffer: framebufferState,\n extensions: extensions,\n\n timer: timer,\n isBufferArgs: isBufferArgs\n };\n\n var sharedConstants = {\n primTypes: primTypes,\n compareFuncs: compareFuncs,\n blendFuncs: blendFuncs,\n blendEquations: blendEquations,\n stencilOps: stencilOps,\n glTypes: glTypes,\n orientationType: orientationType\n };\n\n check$1.optional(function () {\n sharedState.isArrayLike = isArrayLike;\n });\n\n if (extDrawBuffers) {\n sharedConstants.backBuffer = [GL_BACK];\n sharedConstants.drawBuffer = loop(limits.maxDrawbuffers, function (i) {\n if (i === 0) {\n return [0]\n }\n return loop(i, function (j) {\n return GL_COLOR_ATTACHMENT0$1 + j\n })\n });\n }\n\n var drawCallCounter = 0;\n function createREGLEnvironment () {\n var env = createEnvironment();\n var link = env.link;\n var global = env.global;\n env.id = drawCallCounter++;\n\n env.batchId = '0';\n\n // link shared state\n var SHARED = link(sharedState);\n var shared = env.shared = {\n props: 'a0'\n };\n Object.keys(sharedState).forEach(function (prop) {\n shared[prop] = global.def(SHARED, '.', prop);\n });\n\n // Inject runtime assertion stuff for debug builds\n check$1.optional(function () {\n env.CHECK = link(check$1);\n env.commandStr = check$1.guessCommand();\n env.command = link(env.commandStr);\n env.assert = function (block, pred, message) {\n block(\n 'if(!(', pred, '))',\n this.CHECK, '.commandRaise(', link(message), ',', this.command, ');');\n };\n\n sharedConstants.invalidBlendCombinations = invalidBlendCombinations;\n });\n\n // Copy GL state variables over\n var nextVars = env.next = {};\n var currentVars = env.current = {};\n Object.keys(GL_VARIABLES).forEach(function (variable) {\n if (Array.isArray(currentState[variable])) {\n nextVars[variable] = global.def(shared.next, '.', variable);\n currentVars[variable] = global.def(shared.current, '.', variable);\n }\n });\n\n // Initialize shared constants\n var constants = env.constants = {};\n Object.keys(sharedConstants).forEach(function (name) {\n constants[name] = global.def(JSON.stringify(sharedConstants[name]));\n });\n\n // Helper function for calling a block\n env.invoke = function (block, x) {\n switch (x.type) {\n case DYN_FUNC$1:\n var argList = [\n 'this',\n shared.context,\n shared.props,\n env.batchId\n ];\n return block.def(\n link(x.data), '.call(',\n argList.slice(0, Math.max(x.data.length + 1, 4)),\n ')')\n case DYN_PROP$1:\n return block.def(shared.props, x.data)\n case DYN_CONTEXT$1:\n return block.def(shared.context, x.data)\n case DYN_STATE$1:\n return block.def('this', x.data)\n case DYN_THUNK:\n x.data.append(env, block);\n return x.data.ref\n }\n };\n\n env.attribCache = {};\n\n var scopeAttribs = {};\n env.scopeAttrib = function (name) {\n var id = stringStore.id(name);\n if (id in scopeAttribs) {\n return scopeAttribs[id]\n }\n var binding = attributeState.scope[id];\n if (!binding) {\n binding = attributeState.scope[id] = new AttributeRecord();\n }\n var result = scopeAttribs[id] = link(binding);\n return result\n };\n\n return env\n }\n\n // ===================================================\n // ===================================================\n // PARSING\n // ===================================================\n // ===================================================\n function parseProfile (options) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n var profileEnable;\n if (S_PROFILE in staticOptions) {\n var value = !!staticOptions[S_PROFILE];\n profileEnable = createStaticDecl(function (env, scope) {\n return value\n });\n profileEnable.enable = value;\n } else if (S_PROFILE in dynamicOptions) {\n var dyn = dynamicOptions[S_PROFILE];\n profileEnable = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n });\n }\n\n return profileEnable\n }\n\n function parseFramebuffer (options, env) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n if (S_FRAMEBUFFER in staticOptions) {\n var framebuffer = staticOptions[S_FRAMEBUFFER];\n if (framebuffer) {\n framebuffer = framebufferState.getFramebuffer(framebuffer);\n check$1.command(framebuffer, 'invalid framebuffer object');\n return createStaticDecl(function (env, block) {\n var FRAMEBUFFER = env.link(framebuffer);\n var shared = env.shared;\n block.set(\n shared.framebuffer,\n '.next',\n FRAMEBUFFER);\n var CONTEXT = shared.context;\n block.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n FRAMEBUFFER + '.width');\n block.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n FRAMEBUFFER + '.height');\n return FRAMEBUFFER\n })\n } else {\n return createStaticDecl(function (env, scope) {\n var shared = env.shared;\n scope.set(\n shared.framebuffer,\n '.next',\n 'null');\n var CONTEXT = shared.context;\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH);\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT);\n return 'null'\n })\n }\n } else if (S_FRAMEBUFFER in dynamicOptions) {\n var dyn = dynamicOptions[S_FRAMEBUFFER];\n return createDynamicDecl(dyn, function (env, scope) {\n var FRAMEBUFFER_FUNC = env.invoke(scope, dyn);\n var shared = env.shared;\n var FRAMEBUFFER_STATE = shared.framebuffer;\n var FRAMEBUFFER = scope.def(\n FRAMEBUFFER_STATE, '.getFramebuffer(', FRAMEBUFFER_FUNC, ')');\n\n check$1.optional(function () {\n env.assert(scope,\n '!' + FRAMEBUFFER_FUNC + '||' + FRAMEBUFFER,\n 'invalid framebuffer object');\n });\n\n scope.set(\n FRAMEBUFFER_STATE,\n '.next',\n FRAMEBUFFER);\n var CONTEXT = shared.context;\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n FRAMEBUFFER + '?' + FRAMEBUFFER + '.width:' +\n CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH);\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n FRAMEBUFFER +\n '?' + FRAMEBUFFER + '.height:' +\n CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT);\n return FRAMEBUFFER\n })\n } else {\n return null\n }\n }\n\n function parseViewportScissor (options, framebuffer, env) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n function parseBox (param) {\n if (param in staticOptions) {\n var box = staticOptions[param];\n check$1.commandType(box, 'object', 'invalid ' + param, env.commandStr);\n\n var isStatic = true;\n var x = box.x | 0;\n var y = box.y | 0;\n var w, h;\n if ('width' in box) {\n w = box.width | 0;\n check$1.command(w >= 0, 'invalid ' + param, env.commandStr);\n } else {\n isStatic = false;\n }\n if ('height' in box) {\n h = box.height | 0;\n check$1.command(h >= 0, 'invalid ' + param, env.commandStr);\n } else {\n isStatic = false;\n }\n\n return new Declaration(\n !isStatic && framebuffer && framebuffer.thisDep,\n !isStatic && framebuffer && framebuffer.contextDep,\n !isStatic && framebuffer && framebuffer.propDep,\n function (env, scope) {\n var CONTEXT = env.shared.context;\n var BOX_W = w;\n if (!('width' in box)) {\n BOX_W = scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', x);\n }\n var BOX_H = h;\n if (!('height' in box)) {\n BOX_H = scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', y);\n }\n return [x, y, BOX_W, BOX_H]\n })\n } else if (param in dynamicOptions) {\n var dynBox = dynamicOptions[param];\n var result = createDynamicDecl(dynBox, function (env, scope) {\n var BOX = env.invoke(scope, dynBox);\n\n check$1.optional(function () {\n env.assert(scope,\n BOX + '&&typeof ' + BOX + '===\"object\"',\n 'invalid ' + param);\n });\n\n var CONTEXT = env.shared.context;\n var BOX_X = scope.def(BOX, '.x|0');\n var BOX_Y = scope.def(BOX, '.y|0');\n var BOX_W = scope.def(\n '\"width\" in ', BOX, '?', BOX, '.width|0:',\n '(', CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', BOX_X, ')');\n var BOX_H = scope.def(\n '\"height\" in ', BOX, '?', BOX, '.height|0:',\n '(', CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', BOX_Y, ')');\n\n check$1.optional(function () {\n env.assert(scope,\n BOX_W + '>=0&&' +\n BOX_H + '>=0',\n 'invalid ' + param);\n });\n\n return [BOX_X, BOX_Y, BOX_W, BOX_H]\n });\n if (framebuffer) {\n result.thisDep = result.thisDep || framebuffer.thisDep;\n result.contextDep = result.contextDep || framebuffer.contextDep;\n result.propDep = result.propDep || framebuffer.propDep;\n }\n return result\n } else if (framebuffer) {\n return new Declaration(\n framebuffer.thisDep,\n framebuffer.contextDep,\n framebuffer.propDep,\n function (env, scope) {\n var CONTEXT = env.shared.context;\n return [\n 0, 0,\n scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH),\n scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT)]\n })\n } else {\n return null\n }\n }\n\n var viewport = parseBox(S_VIEWPORT);\n\n if (viewport) {\n var prevViewport = viewport;\n viewport = new Declaration(\n viewport.thisDep,\n viewport.contextDep,\n viewport.propDep,\n function (env, scope) {\n var VIEWPORT = prevViewport.append(env, scope);\n var CONTEXT = env.shared.context;\n scope.set(\n CONTEXT,\n '.' + S_VIEWPORT_WIDTH,\n VIEWPORT[2]);\n scope.set(\n CONTEXT,\n '.' + S_VIEWPORT_HEIGHT,\n VIEWPORT[3]);\n return VIEWPORT\n });\n }\n\n return {\n viewport: viewport,\n scissor_box: parseBox(S_SCISSOR_BOX)\n }\n }\n\n function parseProgram (options) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n function parseShader (name) {\n if (name in staticOptions) {\n var id = stringStore.id(staticOptions[name]);\n check$1.optional(function () {\n shaderState.shader(shaderType[name], id, check$1.guessCommand());\n });\n var result = createStaticDecl(function () {\n return id\n });\n result.id = id;\n return result\n } else if (name in dynamicOptions) {\n var dyn = dynamicOptions[name];\n return createDynamicDecl(dyn, function (env, scope) {\n var str = env.invoke(scope, dyn);\n var id = scope.def(env.shared.strings, '.id(', str, ')');\n check$1.optional(function () {\n scope(\n env.shared.shader, '.shader(',\n shaderType[name], ',',\n id, ',',\n env.command, ');');\n });\n return id\n })\n }\n return null\n }\n\n var frag = parseShader(S_FRAG);\n var vert = parseShader(S_VERT);\n\n var program = null;\n var progVar;\n if (isStatic(frag) && isStatic(vert)) {\n program = shaderState.program(vert.id, frag.id);\n progVar = createStaticDecl(function (env, scope) {\n return env.link(program)\n });\n } else {\n progVar = new Declaration(\n (frag && frag.thisDep) || (vert && vert.thisDep),\n (frag && frag.contextDep) || (vert && vert.contextDep),\n (frag && frag.propDep) || (vert && vert.propDep),\n function (env, scope) {\n var SHADER_STATE = env.shared.shader;\n var fragId;\n if (frag) {\n fragId = frag.append(env, scope);\n } else {\n fragId = scope.def(SHADER_STATE, '.', S_FRAG);\n }\n var vertId;\n if (vert) {\n vertId = vert.append(env, scope);\n } else {\n vertId = scope.def(SHADER_STATE, '.', S_VERT);\n }\n var progDef = SHADER_STATE + '.program(' + vertId + ',' + fragId;\n check$1.optional(function () {\n progDef += ',' + env.command;\n });\n return scope.def(progDef + ')')\n });\n }\n\n return {\n frag: frag,\n vert: vert,\n progVar: progVar,\n program: program\n }\n }\n\n function parseDraw (options, env) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n function parseElements () {\n if (S_ELEMENTS in staticOptions) {\n var elements = staticOptions[S_ELEMENTS];\n if (isBufferArgs(elements)) {\n elements = elementState.getElements(elementState.create(elements, true));\n } else if (elements) {\n elements = elementState.getElements(elements);\n check$1.command(elements, 'invalid elements', env.commandStr);\n }\n var result = createStaticDecl(function (env, scope) {\n if (elements) {\n var result = env.link(elements);\n env.ELEMENTS = result;\n return result\n }\n env.ELEMENTS = null;\n return null\n });\n result.value = elements;\n return result\n } else if (S_ELEMENTS in dynamicOptions) {\n var dyn = dynamicOptions[S_ELEMENTS];\n return createDynamicDecl(dyn, function (env, scope) {\n var shared = env.shared;\n\n var IS_BUFFER_ARGS = shared.isBufferArgs;\n var ELEMENT_STATE = shared.elements;\n\n var elementDefn = env.invoke(scope, dyn);\n var elements = scope.def('null');\n var elementStream = scope.def(IS_BUFFER_ARGS, '(', elementDefn, ')');\n\n var ifte = env.cond(elementStream)\n .then(elements, '=', ELEMENT_STATE, '.createStream(', elementDefn, ');')\n .else(elements, '=', ELEMENT_STATE, '.getElements(', elementDefn, ');');\n\n check$1.optional(function () {\n env.assert(ifte.else,\n '!' + elementDefn + '||' + elements,\n 'invalid elements');\n });\n\n scope.entry(ifte);\n scope.exit(\n env.cond(elementStream)\n .then(ELEMENT_STATE, '.destroyStream(', elements, ');'));\n\n env.ELEMENTS = elements;\n\n return elements\n })\n }\n\n return null\n }\n\n var elements = parseElements();\n\n function parsePrimitive () {\n if (S_PRIMITIVE in staticOptions) {\n var primitive = staticOptions[S_PRIMITIVE];\n check$1.commandParameter(primitive, primTypes, 'invalid primitve', env.commandStr);\n return createStaticDecl(function (env, scope) {\n return primTypes[primitive]\n })\n } else if (S_PRIMITIVE in dynamicOptions) {\n var dynPrimitive = dynamicOptions[S_PRIMITIVE];\n return createDynamicDecl(dynPrimitive, function (env, scope) {\n var PRIM_TYPES = env.constants.primTypes;\n var prim = env.invoke(scope, dynPrimitive);\n check$1.optional(function () {\n env.assert(scope,\n prim + ' in ' + PRIM_TYPES,\n 'invalid primitive, must be one of ' + Object.keys(primTypes));\n });\n return scope.def(PRIM_TYPES, '[', prim, ']')\n })\n } else if (elements) {\n if (isStatic(elements)) {\n if (elements.value) {\n return createStaticDecl(function (env, scope) {\n return scope.def(env.ELEMENTS, '.primType')\n })\n } else {\n return createStaticDecl(function () {\n return GL_TRIANGLES$1\n })\n }\n } else {\n return new Declaration(\n elements.thisDep,\n elements.contextDep,\n elements.propDep,\n function (env, scope) {\n var elements = env.ELEMENTS;\n return scope.def(elements, '?', elements, '.primType:', GL_TRIANGLES$1)\n })\n }\n }\n return null\n }\n\n function parseParam (param, isOffset) {\n if (param in staticOptions) {\n var value = staticOptions[param] | 0;\n check$1.command(!isOffset || value >= 0, 'invalid ' + param, env.commandStr);\n return createStaticDecl(function (env, scope) {\n if (isOffset) {\n env.OFFSET = value;\n }\n return value\n })\n } else if (param in dynamicOptions) {\n var dynValue = dynamicOptions[param];\n return createDynamicDecl(dynValue, function (env, scope) {\n var result = env.invoke(scope, dynValue);\n if (isOffset) {\n env.OFFSET = result;\n check$1.optional(function () {\n env.assert(scope,\n result + '>=0',\n 'invalid ' + param);\n });\n }\n return result\n })\n } else if (isOffset && elements) {\n return createStaticDecl(function (env, scope) {\n env.OFFSET = '0';\n return 0\n })\n }\n return null\n }\n\n var OFFSET = parseParam(S_OFFSET, true);\n\n function parseVertCount () {\n if (S_COUNT in staticOptions) {\n var count = staticOptions[S_COUNT] | 0;\n check$1.command(\n typeof count === 'number' && count >= 0, 'invalid vertex count', env.commandStr);\n return createStaticDecl(function () {\n return count\n })\n } else if (S_COUNT in dynamicOptions) {\n var dynCount = dynamicOptions[S_COUNT];\n return createDynamicDecl(dynCount, function (env, scope) {\n var result = env.invoke(scope, dynCount);\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + result + '===\"number\"&&' +\n result + '>=0&&' +\n result + '===(' + result + '|0)',\n 'invalid vertex count');\n });\n return result\n })\n } else if (elements) {\n if (isStatic(elements)) {\n if (elements) {\n if (OFFSET) {\n return new Declaration(\n OFFSET.thisDep,\n OFFSET.contextDep,\n OFFSET.propDep,\n function (env, scope) {\n var result = scope.def(\n env.ELEMENTS, '.vertCount-', env.OFFSET);\n\n check$1.optional(function () {\n env.assert(scope,\n result + '>=0',\n 'invalid vertex offset/element buffer too small');\n });\n\n return result\n })\n } else {\n return createStaticDecl(function (env, scope) {\n return scope.def(env.ELEMENTS, '.vertCount')\n })\n }\n } else {\n var result = createStaticDecl(function () {\n return -1\n });\n check$1.optional(function () {\n result.MISSING = true;\n });\n return result\n }\n } else {\n var variable = new Declaration(\n elements.thisDep || OFFSET.thisDep,\n elements.contextDep || OFFSET.contextDep,\n elements.propDep || OFFSET.propDep,\n function (env, scope) {\n var elements = env.ELEMENTS;\n if (env.OFFSET) {\n return scope.def(elements, '?', elements, '.vertCount-',\n env.OFFSET, ':-1')\n }\n return scope.def(elements, '?', elements, '.vertCount:-1')\n });\n check$1.optional(function () {\n variable.DYNAMIC = true;\n });\n return variable\n }\n }\n return null\n }\n\n return {\n elements: elements,\n primitive: parsePrimitive(),\n count: parseVertCount(),\n instances: parseParam(S_INSTANCES, false),\n offset: OFFSET\n }\n }\n\n function parseGLState (options, env) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n var STATE = {};\n\n GL_STATE_NAMES.forEach(function (prop) {\n var param = propName(prop);\n\n function parseParam (parseStatic, parseDynamic) {\n if (prop in staticOptions) {\n var value = parseStatic(staticOptions[prop]);\n STATE[param] = createStaticDecl(function () {\n return value\n });\n } else if (prop in dynamicOptions) {\n var dyn = dynamicOptions[prop];\n STATE[param] = createDynamicDecl(dyn, function (env, scope) {\n return parseDynamic(env, scope, env.invoke(scope, dyn))\n });\n }\n }\n\n switch (prop) {\n case S_CULL_ENABLE:\n case S_BLEND_ENABLE:\n case S_DITHER:\n case S_STENCIL_ENABLE:\n case S_DEPTH_ENABLE:\n case S_SCISSOR_ENABLE:\n case S_POLYGON_OFFSET_ENABLE:\n case S_SAMPLE_ALPHA:\n case S_SAMPLE_ENABLE:\n case S_DEPTH_MASK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'boolean', prop, env.commandStr);\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"boolean\"',\n 'invalid flag ' + prop, env.commandStr);\n });\n return value\n })\n\n case S_DEPTH_FUNC:\n return parseParam(\n function (value) {\n check$1.commandParameter(value, compareFuncs, 'invalid ' + prop, env.commandStr);\n return compareFuncs[value]\n },\n function (env, scope, value) {\n var COMPARE_FUNCS = env.constants.compareFuncs;\n check$1.optional(function () {\n env.assert(scope,\n value + ' in ' + COMPARE_FUNCS,\n 'invalid ' + prop + ', must be one of ' + Object.keys(compareFuncs));\n });\n return scope.def(COMPARE_FUNCS, '[', value, ']')\n })\n\n case S_DEPTH_RANGE:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) &&\n value.length === 2 &&\n typeof value[0] === 'number' &&\n typeof value[1] === 'number' &&\n value[0] <= value[1],\n 'depth range is 2d array',\n env.commandStr);\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===2&&' +\n 'typeof ' + value + '[0]===\"number\"&&' +\n 'typeof ' + value + '[1]===\"number\"&&' +\n value + '[0]<=' + value + '[1]',\n 'depth range must be a 2d array');\n });\n\n var Z_NEAR = scope.def('+', value, '[0]');\n var Z_FAR = scope.def('+', value, '[1]');\n return [Z_NEAR, Z_FAR]\n })\n\n case S_BLEND_FUNC:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', 'blend.func', env.commandStr);\n var srcRGB = ('srcRGB' in value ? value.srcRGB : value.src);\n var srcAlpha = ('srcAlpha' in value ? value.srcAlpha : value.src);\n var dstRGB = ('dstRGB' in value ? value.dstRGB : value.dst);\n var dstAlpha = ('dstAlpha' in value ? value.dstAlpha : value.dst);\n check$1.commandParameter(srcRGB, blendFuncs, param + '.srcRGB', env.commandStr);\n check$1.commandParameter(srcAlpha, blendFuncs, param + '.srcAlpha', env.commandStr);\n check$1.commandParameter(dstRGB, blendFuncs, param + '.dstRGB', env.commandStr);\n check$1.commandParameter(dstAlpha, blendFuncs, param + '.dstAlpha', env.commandStr);\n\n check$1.command(\n (invalidBlendCombinations.indexOf(srcRGB + ', ' + dstRGB) === -1),\n 'unallowed blending combination (srcRGB, dstRGB) = (' + srcRGB + ', ' + dstRGB + ')', env.commandStr);\n\n return [\n blendFuncs[srcRGB],\n blendFuncs[dstRGB],\n blendFuncs[srcAlpha],\n blendFuncs[dstAlpha]\n ]\n },\n function (env, scope, value) {\n var BLEND_FUNCS = env.constants.blendFuncs;\n\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid blend func, must be an object');\n });\n\n function read (prefix, suffix) {\n var func = scope.def(\n '\"', prefix, suffix, '\" in ', value,\n '?', value, '.', prefix, suffix,\n ':', value, '.', prefix);\n\n check$1.optional(function () {\n env.assert(scope,\n func + ' in ' + BLEND_FUNCS,\n 'invalid ' + prop + '.' + prefix + suffix + ', must be one of ' + Object.keys(blendFuncs));\n });\n\n return func\n }\n\n var srcRGB = read('src', 'RGB');\n var dstRGB = read('dst', 'RGB');\n\n check$1.optional(function () {\n var INVALID_BLEND_COMBINATIONS = env.constants.invalidBlendCombinations;\n\n env.assert(scope,\n INVALID_BLEND_COMBINATIONS +\n '.indexOf(' + srcRGB + '+\", \"+' + dstRGB + ') === -1 ',\n 'unallowed blending combination for (srcRGB, dstRGB)'\n );\n });\n\n var SRC_RGB = scope.def(BLEND_FUNCS, '[', srcRGB, ']');\n var SRC_ALPHA = scope.def(BLEND_FUNCS, '[', read('src', 'Alpha'), ']');\n var DST_RGB = scope.def(BLEND_FUNCS, '[', dstRGB, ']');\n var DST_ALPHA = scope.def(BLEND_FUNCS, '[', read('dst', 'Alpha'), ']');\n\n return [SRC_RGB, DST_RGB, SRC_ALPHA, DST_ALPHA]\n })\n\n case S_BLEND_EQUATION:\n return parseParam(\n function (value) {\n if (typeof value === 'string') {\n check$1.commandParameter(value, blendEquations, 'invalid ' + prop, env.commandStr);\n return [\n blendEquations[value],\n blendEquations[value]\n ]\n } else if (typeof value === 'object') {\n check$1.commandParameter(\n value.rgb, blendEquations, prop + '.rgb', env.commandStr);\n check$1.commandParameter(\n value.alpha, blendEquations, prop + '.alpha', env.commandStr);\n return [\n blendEquations[value.rgb],\n blendEquations[value.alpha]\n ]\n } else {\n check$1.commandRaise('invalid blend.equation', env.commandStr);\n }\n },\n function (env, scope, value) {\n var BLEND_EQUATIONS = env.constants.blendEquations;\n\n var RGB = scope.def();\n var ALPHA = scope.def();\n\n var ifte = env.cond('typeof ', value, '===\"string\"');\n\n check$1.optional(function () {\n function checkProp (block, name, value) {\n env.assert(block,\n value + ' in ' + BLEND_EQUATIONS,\n 'invalid ' + name + ', must be one of ' + Object.keys(blendEquations));\n }\n checkProp(ifte.then, prop, value);\n\n env.assert(ifte.else,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop);\n checkProp(ifte.else, prop + '.rgb', value + '.rgb');\n checkProp(ifte.else, prop + '.alpha', value + '.alpha');\n });\n\n ifte.then(\n RGB, '=', ALPHA, '=', BLEND_EQUATIONS, '[', value, '];');\n ifte.else(\n RGB, '=', BLEND_EQUATIONS, '[', value, '.rgb];',\n ALPHA, '=', BLEND_EQUATIONS, '[', value, '.alpha];');\n\n scope(ifte);\n\n return [RGB, ALPHA]\n })\n\n case S_BLEND_COLOR:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) &&\n value.length === 4,\n 'blend.color must be a 4d array', env.commandStr);\n return loop(4, function (i) {\n return +value[i]\n })\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===4',\n 'blend.color must be a 4d array');\n });\n return loop(4, function (i) {\n return scope.def('+', value, '[', i, ']')\n })\n })\n\n case S_STENCIL_MASK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'number', param, env.commandStr);\n return value | 0\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"number\"',\n 'invalid stencil.mask');\n });\n return scope.def(value, '|0')\n })\n\n case S_STENCIL_FUNC:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr);\n var cmp = value.cmp || 'keep';\n var ref = value.ref || 0;\n var mask = 'mask' in value ? value.mask : -1;\n check$1.commandParameter(cmp, compareFuncs, prop + '.cmp', env.commandStr);\n check$1.commandType(ref, 'number', prop + '.ref', env.commandStr);\n check$1.commandType(mask, 'number', prop + '.mask', env.commandStr);\n return [\n compareFuncs[cmp],\n ref,\n mask\n ]\n },\n function (env, scope, value) {\n var COMPARE_FUNCS = env.constants.compareFuncs;\n check$1.optional(function () {\n function assert () {\n env.assert(scope,\n Array.prototype.join.call(arguments, ''),\n 'invalid stencil.func');\n }\n assert(value + '&&typeof ', value, '===\"object\"');\n assert('!(\"cmp\" in ', value, ')||(',\n value, '.cmp in ', COMPARE_FUNCS, ')');\n });\n var cmp = scope.def(\n '\"cmp\" in ', value,\n '?', COMPARE_FUNCS, '[', value, '.cmp]',\n ':', GL_KEEP);\n var ref = scope.def(value, '.ref|0');\n var mask = scope.def(\n '\"mask\" in ', value,\n '?', value, '.mask|0:-1');\n return [cmp, ref, mask]\n })\n\n case S_STENCIL_OPFRONT:\n case S_STENCIL_OPBACK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr);\n var fail = value.fail || 'keep';\n var zfail = value.zfail || 'keep';\n var zpass = value.zpass || 'keep';\n check$1.commandParameter(fail, stencilOps, prop + '.fail', env.commandStr);\n check$1.commandParameter(zfail, stencilOps, prop + '.zfail', env.commandStr);\n check$1.commandParameter(zpass, stencilOps, prop + '.zpass', env.commandStr);\n return [\n prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT,\n stencilOps[fail],\n stencilOps[zfail],\n stencilOps[zpass]\n ]\n },\n function (env, scope, value) {\n var STENCIL_OPS = env.constants.stencilOps;\n\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop);\n });\n\n function read (name) {\n check$1.optional(function () {\n env.assert(scope,\n '!(\"' + name + '\" in ' + value + ')||' +\n '(' + value + '.' + name + ' in ' + STENCIL_OPS + ')',\n 'invalid ' + prop + '.' + name + ', must be one of ' + Object.keys(stencilOps));\n });\n\n return scope.def(\n '\"', name, '\" in ', value,\n '?', STENCIL_OPS, '[', value, '.', name, ']:',\n GL_KEEP)\n }\n\n return [\n prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT,\n read('fail'),\n read('zfail'),\n read('zpass')\n ]\n })\n\n case S_POLYGON_OFFSET_OFFSET:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr);\n var factor = value.factor | 0;\n var units = value.units | 0;\n check$1.commandType(factor, 'number', param + '.factor', env.commandStr);\n check$1.commandType(units, 'number', param + '.units', env.commandStr);\n return [factor, units]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop);\n });\n\n var FACTOR = scope.def(value, '.factor|0');\n var UNITS = scope.def(value, '.units|0');\n\n return [FACTOR, UNITS]\n })\n\n case S_CULL_FACE:\n return parseParam(\n function (value) {\n var face = 0;\n if (value === 'front') {\n face = GL_FRONT;\n } else if (value === 'back') {\n face = GL_BACK;\n }\n check$1.command(!!face, param, env.commandStr);\n return face\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '===\"front\"||' +\n value + '===\"back\"',\n 'invalid cull.face');\n });\n return scope.def(value, '===\"front\"?', GL_FRONT, ':', GL_BACK)\n })\n\n case S_LINE_WIDTH:\n return parseParam(\n function (value) {\n check$1.command(\n typeof value === 'number' &&\n value >= limits.lineWidthDims[0] &&\n value <= limits.lineWidthDims[1],\n 'invalid line width, must positive number between ' +\n limits.lineWidthDims[0] + ' and ' + limits.lineWidthDims[1], env.commandStr);\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"number\"&&' +\n value + '>=' + limits.lineWidthDims[0] + '&&' +\n value + '<=' + limits.lineWidthDims[1],\n 'invalid line width');\n });\n\n return value\n })\n\n case S_FRONT_FACE:\n return parseParam(\n function (value) {\n check$1.commandParameter(value, orientationType, param, env.commandStr);\n return orientationType[value]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '===\"cw\"||' +\n value + '===\"ccw\"',\n 'invalid frontFace, must be one of cw,ccw');\n });\n return scope.def(value + '===\"cw\"?' + GL_CW + ':' + GL_CCW)\n })\n\n case S_COLOR_MASK:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'color.mask must be length 4 array', env.commandStr);\n return value.map(function (v) { return !!v })\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===4',\n 'invalid color.mask');\n });\n return loop(4, function (i) {\n return '!!' + value + '[' + i + ']'\n })\n })\n\n case S_SAMPLE_COVERAGE:\n return parseParam(\n function (value) {\n check$1.command(typeof value === 'object' && value, param, env.commandStr);\n var sampleValue = 'value' in value ? value.value : 1;\n var sampleInvert = !!value.invert;\n check$1.command(\n typeof sampleValue === 'number' &&\n sampleValue >= 0 && sampleValue <= 1,\n 'sample.coverage.value must be a number between 0 and 1', env.commandStr);\n return [sampleValue, sampleInvert]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid sample.coverage');\n });\n var VALUE = scope.def(\n '\"value\" in ', value, '?+', value, '.value:1');\n var INVERT = scope.def('!!', value, '.invert');\n return [VALUE, INVERT]\n })\n }\n });\n\n return STATE\n }\n\n function parseUniforms (uniforms, env) {\n var staticUniforms = uniforms.static;\n var dynamicUniforms = uniforms.dynamic;\n\n var UNIFORMS = {};\n\n Object.keys(staticUniforms).forEach(function (name) {\n var value = staticUniforms[name];\n var result;\n if (typeof value === 'number' ||\n typeof value === 'boolean') {\n result = createStaticDecl(function () {\n return value\n });\n } else if (typeof value === 'function') {\n var reglType = value._reglType;\n if (reglType === 'texture2d' ||\n reglType === 'textureCube') {\n result = createStaticDecl(function (env) {\n return env.link(value)\n });\n } else if (reglType === 'framebuffer' ||\n reglType === 'framebufferCube') {\n check$1.command(value.color.length > 0,\n 'missing color attachment for framebuffer sent to uniform \"' + name + '\"', env.commandStr);\n result = createStaticDecl(function (env) {\n return env.link(value.color[0])\n });\n } else {\n check$1.commandRaise('invalid data for uniform \"' + name + '\"', env.commandStr);\n }\n } else if (isArrayLike(value)) {\n result = createStaticDecl(function (env) {\n var ITEM = env.global.def('[',\n loop(value.length, function (i) {\n check$1.command(\n typeof value[i] === 'number' ||\n typeof value[i] === 'boolean',\n 'invalid uniform ' + name, env.commandStr);\n return value[i]\n }), ']');\n return ITEM\n });\n } else {\n check$1.commandRaise('invalid or missing data for uniform \"' + name + '\"', env.commandStr);\n }\n result.value = value;\n UNIFORMS[name] = result;\n });\n\n Object.keys(dynamicUniforms).forEach(function (key) {\n var dyn = dynamicUniforms[key];\n UNIFORMS[key] = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n });\n });\n\n return UNIFORMS\n }\n\n function parseAttributes (attributes, env) {\n var staticAttributes = attributes.static;\n var dynamicAttributes = attributes.dynamic;\n\n var attributeDefs = {};\n\n Object.keys(staticAttributes).forEach(function (attribute) {\n var value = staticAttributes[attribute];\n var id = stringStore.id(attribute);\n\n var record = new AttributeRecord();\n if (isBufferArgs(value)) {\n record.state = ATTRIB_STATE_POINTER;\n record.buffer = bufferState.getBuffer(\n bufferState.create(value, GL_ARRAY_BUFFER$1, false, true));\n record.type = 0;\n } else {\n var buffer = bufferState.getBuffer(value);\n if (buffer) {\n record.state = ATTRIB_STATE_POINTER;\n record.buffer = buffer;\n record.type = 0;\n } else {\n check$1.command(typeof value === 'object' && value,\n 'invalid data for attribute ' + attribute, env.commandStr);\n if (value.constant) {\n var constant = value.constant;\n record.buffer = 'null';\n record.state = ATTRIB_STATE_CONSTANT;\n if (typeof constant === 'number') {\n record.x = constant;\n } else {\n check$1.command(\n isArrayLike(constant) &&\n constant.length > 0 &&\n constant.length <= 4,\n 'invalid constant for attribute ' + attribute, env.commandStr);\n CUTE_COMPONENTS.forEach(function (c, i) {\n if (i < constant.length) {\n record[c] = constant[i];\n }\n });\n }\n } else {\n if (isBufferArgs(value.buffer)) {\n buffer = bufferState.getBuffer(\n bufferState.create(value.buffer, GL_ARRAY_BUFFER$1, false, true));\n } else {\n buffer = bufferState.getBuffer(value.buffer);\n }\n check$1.command(!!buffer, 'missing buffer for attribute \"' + attribute + '\"', env.commandStr);\n\n var offset = value.offset | 0;\n check$1.command(offset >= 0,\n 'invalid offset for attribute \"' + attribute + '\"', env.commandStr);\n\n var stride = value.stride | 0;\n check$1.command(stride >= 0 && stride < 256,\n 'invalid stride for attribute \"' + attribute + '\", must be integer betweeen [0, 255]', env.commandStr);\n\n var size = value.size | 0;\n check$1.command(!('size' in value) || (size > 0 && size <= 4),\n 'invalid size for attribute \"' + attribute + '\", must be 1,2,3,4', env.commandStr);\n\n var normalized = !!value.normalized;\n\n var type = 0;\n if ('type' in value) {\n check$1.commandParameter(\n value.type, glTypes,\n 'invalid type for attribute ' + attribute, env.commandStr);\n type = glTypes[value.type];\n }\n\n var divisor = value.divisor | 0;\n if ('divisor' in value) {\n check$1.command(divisor === 0 || extInstancing,\n 'cannot specify divisor for attribute \"' + attribute + '\", instancing not supported', env.commandStr);\n check$1.command(divisor >= 0,\n 'invalid divisor for attribute \"' + attribute + '\"', env.commandStr);\n }\n\n check$1.optional(function () {\n var command = env.commandStr;\n\n var VALID_KEYS = [\n 'buffer',\n 'offset',\n 'divisor',\n 'normalized',\n 'type',\n 'size',\n 'stride'\n ];\n\n Object.keys(value).forEach(function (prop) {\n check$1.command(\n VALID_KEYS.indexOf(prop) >= 0,\n 'unknown parameter \"' + prop + '\" for attribute pointer \"' + attribute + '\" (valid parameters are ' + VALID_KEYS + ')',\n command);\n });\n });\n\n record.buffer = buffer;\n record.state = ATTRIB_STATE_POINTER;\n record.size = size;\n record.normalized = normalized;\n record.type = type || buffer.dtype;\n record.offset = offset;\n record.stride = stride;\n record.divisor = divisor;\n }\n }\n }\n\n attributeDefs[attribute] = createStaticDecl(function (env, scope) {\n var cache = env.attribCache;\n if (id in cache) {\n return cache[id]\n }\n var result = {\n isStream: false\n };\n Object.keys(record).forEach(function (key) {\n result[key] = record[key];\n });\n if (record.buffer) {\n result.buffer = env.link(record.buffer);\n result.type = result.type || (result.buffer + '.dtype');\n }\n cache[id] = result;\n return result\n });\n });\n\n Object.keys(dynamicAttributes).forEach(function (attribute) {\n var dyn = dynamicAttributes[attribute];\n\n function appendAttributeCode (env, block) {\n var VALUE = env.invoke(block, dyn);\n\n var shared = env.shared;\n\n var IS_BUFFER_ARGS = shared.isBufferArgs;\n var BUFFER_STATE = shared.buffer;\n\n // Perform validation on attribute\n check$1.optional(function () {\n env.assert(block,\n VALUE + '&&(typeof ' + VALUE + '===\"object\"||typeof ' +\n VALUE + '===\"function\")&&(' +\n IS_BUFFER_ARGS + '(' + VALUE + ')||' +\n BUFFER_STATE + '.getBuffer(' + VALUE + ')||' +\n BUFFER_STATE + '.getBuffer(' + VALUE + '.buffer)||' +\n IS_BUFFER_ARGS + '(' + VALUE + '.buffer)||' +\n '(\"constant\" in ' + VALUE +\n '&&(typeof ' + VALUE + '.constant===\"number\"||' +\n shared.isArrayLike + '(' + VALUE + '.constant))))',\n 'invalid dynamic attribute \"' + attribute + '\"');\n });\n\n // allocate names for result\n var result = {\n isStream: block.def(false)\n };\n var defaultRecord = new AttributeRecord();\n defaultRecord.state = ATTRIB_STATE_POINTER;\n Object.keys(defaultRecord).forEach(function (key) {\n result[key] = block.def('' + defaultRecord[key]);\n });\n\n var BUFFER = result.buffer;\n var TYPE = result.type;\n block(\n 'if(', IS_BUFFER_ARGS, '(', VALUE, ')){',\n result.isStream, '=true;',\n BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$1, ',', VALUE, ');',\n TYPE, '=', BUFFER, '.dtype;',\n '}else{',\n BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, ');',\n 'if(', BUFFER, '){',\n TYPE, '=', BUFFER, '.dtype;',\n '}else if(\"constant\" in ', VALUE, '){',\n result.state, '=', ATTRIB_STATE_CONSTANT, ';',\n 'if(typeof ' + VALUE + '.constant === \"number\"){',\n result[CUTE_COMPONENTS[0]], '=', VALUE, '.constant;',\n CUTE_COMPONENTS.slice(1).map(function (n) {\n return result[n]\n }).join('='), '=0;',\n '}else{',\n CUTE_COMPONENTS.map(function (name, i) {\n return (\n result[name] + '=' + VALUE + '.constant.length>=' + i +\n '?' + VALUE + '.constant[' + i + ']:0;'\n )\n }).join(''),\n '}}else{',\n 'if(', IS_BUFFER_ARGS, '(', VALUE, '.buffer)){',\n BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$1, ',', VALUE, '.buffer);',\n '}else{',\n BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, '.buffer);',\n '}',\n TYPE, '=\"type\" in ', VALUE, '?',\n shared.glTypes, '[', VALUE, '.type]:', BUFFER, '.dtype;',\n result.normalized, '=!!', VALUE, '.normalized;');\n function emitReadRecord (name) {\n block(result[name], '=', VALUE, '.', name, '|0;');\n }\n emitReadRecord('size');\n emitReadRecord('offset');\n emitReadRecord('stride');\n emitReadRecord('divisor');\n\n block('}}');\n\n block.exit(\n 'if(', result.isStream, '){',\n BUFFER_STATE, '.destroyStream(', BUFFER, ');',\n '}');\n\n return result\n }\n\n attributeDefs[attribute] = createDynamicDecl(dyn, appendAttributeCode);\n });\n\n return attributeDefs\n }\n\n function parseContext (context) {\n var staticContext = context.static;\n var dynamicContext = context.dynamic;\n var result = {};\n\n Object.keys(staticContext).forEach(function (name) {\n var value = staticContext[name];\n result[name] = createStaticDecl(function (env, scope) {\n if (typeof value === 'number' || typeof value === 'boolean') {\n return '' + value\n } else {\n return env.link(value)\n }\n });\n });\n\n Object.keys(dynamicContext).forEach(function (name) {\n var dyn = dynamicContext[name];\n result[name] = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n });\n });\n\n return result\n }\n\n function parseArguments (options, attributes, uniforms, context, env) {\n var staticOptions = options.static;\n var dynamicOptions = options.dynamic;\n\n check$1.optional(function () {\n var KEY_NAMES = [\n S_FRAMEBUFFER,\n S_VERT,\n S_FRAG,\n S_ELEMENTS,\n S_PRIMITIVE,\n S_OFFSET,\n S_COUNT,\n S_INSTANCES,\n S_PROFILE\n ].concat(GL_STATE_NAMES);\n\n function checkKeys (dict) {\n Object.keys(dict).forEach(function (key) {\n check$1.command(\n KEY_NAMES.indexOf(key) >= 0,\n 'unknown parameter \"' + key + '\"',\n env.commandStr);\n });\n }\n\n checkKeys(staticOptions);\n checkKeys(dynamicOptions);\n });\n\n var framebuffer = parseFramebuffer(options, env);\n var viewportAndScissor = parseViewportScissor(options, framebuffer, env);\n var draw = parseDraw(options, env);\n var state = parseGLState(options, env);\n var shader = parseProgram(options, env);\n\n function copyBox (name) {\n var defn = viewportAndScissor[name];\n if (defn) {\n state[name] = defn;\n }\n }\n copyBox(S_VIEWPORT);\n copyBox(propName(S_SCISSOR_BOX));\n\n var dirty = Object.keys(state).length > 0;\n\n var result = {\n framebuffer: framebuffer,\n draw: draw,\n shader: shader,\n state: state,\n dirty: dirty\n };\n\n result.profile = parseProfile(options, env);\n result.uniforms = parseUniforms(uniforms, env);\n result.attributes = parseAttributes(attributes, env);\n result.context = parseContext(context, env);\n return result\n }\n\n // ===================================================\n // ===================================================\n // COMMON UPDATE FUNCTIONS\n // ===================================================\n // ===================================================\n function emitContext (env, scope, context) {\n var shared = env.shared;\n var CONTEXT = shared.context;\n\n var contextEnter = env.scope();\n\n Object.keys(context).forEach(function (name) {\n scope.save(CONTEXT, '.' + name);\n var defn = context[name];\n contextEnter(CONTEXT, '.', name, '=', defn.append(env, scope), ';');\n });\n\n scope(contextEnter);\n }\n\n // ===================================================\n // ===================================================\n // COMMON DRAWING FUNCTIONS\n // ===================================================\n // ===================================================\n function emitPollFramebuffer (env, scope, framebuffer, skipCheck) {\n var shared = env.shared;\n\n var GL = shared.gl;\n var FRAMEBUFFER_STATE = shared.framebuffer;\n var EXT_DRAW_BUFFERS;\n if (extDrawBuffers) {\n EXT_DRAW_BUFFERS = scope.def(shared.extensions, '.webgl_draw_buffers');\n }\n\n var constants = env.constants;\n\n var DRAW_BUFFERS = constants.drawBuffer;\n var BACK_BUFFER = constants.backBuffer;\n\n var NEXT;\n if (framebuffer) {\n NEXT = framebuffer.append(env, scope);\n } else {\n NEXT = scope.def(FRAMEBUFFER_STATE, '.next');\n }\n\n if (!skipCheck) {\n scope('if(', NEXT, '!==', FRAMEBUFFER_STATE, '.cur){');\n }\n scope(\n 'if(', NEXT, '){',\n GL, '.bindFramebuffer(', GL_FRAMEBUFFER$1, ',', NEXT, '.framebuffer);');\n if (extDrawBuffers) {\n scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(',\n DRAW_BUFFERS, '[', NEXT, '.colorAttachments.length]);');\n }\n scope('}else{',\n GL, '.bindFramebuffer(', GL_FRAMEBUFFER$1, ',null);');\n if (extDrawBuffers) {\n scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', BACK_BUFFER, ');');\n }\n scope(\n '}',\n FRAMEBUFFER_STATE, '.cur=', NEXT, ';');\n if (!skipCheck) {\n scope('}');\n }\n }\n\n function emitPollState (env, scope, args) {\n var shared = env.shared;\n\n var GL = shared.gl;\n\n var CURRENT_VARS = env.current;\n var NEXT_VARS = env.next;\n var CURRENT_STATE = shared.current;\n var NEXT_STATE = shared.next;\n\n var block = env.cond(CURRENT_STATE, '.dirty');\n\n GL_STATE_NAMES.forEach(function (prop) {\n var param = propName(prop);\n if (param in args.state) {\n return\n }\n\n var NEXT, CURRENT;\n if (param in NEXT_VARS) {\n NEXT = NEXT_VARS[param];\n CURRENT = CURRENT_VARS[param];\n var parts = loop(currentState[param].length, function (i) {\n return block.def(NEXT, '[', i, ']')\n });\n block(env.cond(parts.map(function (p, i) {\n return p + '!==' + CURRENT + '[' + i + ']'\n }).join('||'))\n .then(\n GL, '.', GL_VARIABLES[param], '(', parts, ');',\n parts.map(function (p, i) {\n return CURRENT + '[' + i + ']=' + p\n }).join(';'), ';'));\n } else {\n NEXT = block.def(NEXT_STATE, '.', param);\n var ifte = env.cond(NEXT, '!==', CURRENT_STATE, '.', param);\n block(ifte);\n if (param in GL_FLAGS) {\n ifte(\n env.cond(NEXT)\n .then(GL, '.enable(', GL_FLAGS[param], ');')\n .else(GL, '.disable(', GL_FLAGS[param], ');'),\n CURRENT_STATE, '.', param, '=', NEXT, ';');\n } else {\n ifte(\n GL, '.', GL_VARIABLES[param], '(', NEXT, ');',\n CURRENT_STATE, '.', param, '=', NEXT, ';');\n }\n }\n });\n if (Object.keys(args.state).length === 0) {\n block(CURRENT_STATE, '.dirty=false;');\n }\n scope(block);\n }\n\n function emitSetOptions (env, scope, options, filter) {\n var shared = env.shared;\n var CURRENT_VARS = env.current;\n var CURRENT_STATE = shared.current;\n var GL = shared.gl;\n sortState(Object.keys(options)).forEach(function (param) {\n var defn = options[param];\n if (filter && !filter(defn)) {\n return\n }\n var variable = defn.append(env, scope);\n if (GL_FLAGS[param]) {\n var flag = GL_FLAGS[param];\n if (isStatic(defn)) {\n if (variable) {\n scope(GL, '.enable(', flag, ');');\n } else {\n scope(GL, '.disable(', flag, ');');\n }\n } else {\n scope(env.cond(variable)\n .then(GL, '.enable(', flag, ');')\n .else(GL, '.disable(', flag, ');'));\n }\n scope(CURRENT_STATE, '.', param, '=', variable, ';');\n } else if (isArrayLike(variable)) {\n var CURRENT = CURRENT_VARS[param];\n scope(\n GL, '.', GL_VARIABLES[param], '(', variable, ');',\n variable.map(function (v, i) {\n return CURRENT + '[' + i + ']=' + v\n }).join(';'), ';');\n } else {\n scope(\n GL, '.', GL_VARIABLES[param], '(', variable, ');',\n CURRENT_STATE, '.', param, '=', variable, ';');\n }\n });\n }\n\n function injectExtensions (env, scope) {\n if (extInstancing) {\n env.instancing = scope.def(\n env.shared.extensions, '.angle_instanced_arrays');\n }\n }\n\n function emitProfile (env, scope, args, useScope, incrementCounter) {\n var shared = env.shared;\n var STATS = env.stats;\n var CURRENT_STATE = shared.current;\n var TIMER = shared.timer;\n var profileArg = args.profile;\n\n function perfCounter () {\n if (typeof performance === 'undefined') {\n return 'Date.now()'\n } else {\n return 'performance.now()'\n }\n }\n\n var CPU_START, QUERY_COUNTER;\n function emitProfileStart (block) {\n CPU_START = scope.def();\n block(CPU_START, '=', perfCounter(), ';');\n if (typeof incrementCounter === 'string') {\n block(STATS, '.count+=', incrementCounter, ';');\n } else {\n block(STATS, '.count++;');\n }\n if (timer) {\n if (useScope) {\n QUERY_COUNTER = scope.def();\n block(QUERY_COUNTER, '=', TIMER, '.getNumPendingQueries();');\n } else {\n block(TIMER, '.beginQuery(', STATS, ');');\n }\n }\n }\n\n function emitProfileEnd (block) {\n block(STATS, '.cpuTime+=', perfCounter(), '-', CPU_START, ';');\n if (timer) {\n if (useScope) {\n block(TIMER, '.pushScopeStats(',\n QUERY_COUNTER, ',',\n TIMER, '.getNumPendingQueries(),',\n STATS, ');');\n } else {\n block(TIMER, '.endQuery();');\n }\n }\n }\n\n function scopeProfile (value) {\n var prev = scope.def(CURRENT_STATE, '.profile');\n scope(CURRENT_STATE, '.profile=', value, ';');\n scope.exit(CURRENT_STATE, '.profile=', prev, ';');\n }\n\n var USE_PROFILE;\n if (profileArg) {\n if (isStatic(profileArg)) {\n if (profileArg.enable) {\n emitProfileStart(scope);\n emitProfileEnd(scope.exit);\n scopeProfile('true');\n } else {\n scopeProfile('false');\n }\n return\n }\n USE_PROFILE = profileArg.append(env, scope);\n scopeProfile(USE_PROFILE);\n } else {\n USE_PROFILE = scope.def(CURRENT_STATE, '.profile');\n }\n\n var start = env.block();\n emitProfileStart(start);\n scope('if(', USE_PROFILE, '){', start, '}');\n var end = env.block();\n emitProfileEnd(end);\n scope.exit('if(', USE_PROFILE, '){', end, '}');\n }\n\n function emitAttributes (env, scope, args, attributes, filter) {\n var shared = env.shared;\n\n function typeLength (x) {\n switch (x) {\n case GL_FLOAT_VEC2:\n case GL_INT_VEC2:\n case GL_BOOL_VEC2:\n return 2\n case GL_FLOAT_VEC3:\n case GL_INT_VEC3:\n case GL_BOOL_VEC3:\n return 3\n case GL_FLOAT_VEC4:\n case GL_INT_VEC4:\n case GL_BOOL_VEC4:\n return 4\n default:\n return 1\n }\n }\n\n function emitBindAttribute (ATTRIBUTE, size, record) {\n var GL = shared.gl;\n\n var LOCATION = scope.def(ATTRIBUTE, '.location');\n var BINDING = scope.def(shared.attributes, '[', LOCATION, ']');\n\n var STATE = record.state;\n var BUFFER = record.buffer;\n var CONST_COMPONENTS = [\n record.x,\n record.y,\n record.z,\n record.w\n ];\n\n var COMMON_KEYS = [\n 'buffer',\n 'normalized',\n 'offset',\n 'stride'\n ];\n\n function emitBuffer () {\n scope(\n 'if(!', BINDING, '.buffer){',\n GL, '.enableVertexAttribArray(', LOCATION, ');}');\n\n var TYPE = record.type;\n var SIZE;\n if (!record.size) {\n SIZE = size;\n } else {\n SIZE = scope.def(record.size, '||', size);\n }\n\n scope('if(',\n BINDING, '.type!==', TYPE, '||',\n BINDING, '.size!==', SIZE, '||',\n COMMON_KEYS.map(function (key) {\n return BINDING + '.' + key + '!==' + record[key]\n }).join('||'),\n '){',\n GL, '.bindBuffer(', GL_ARRAY_BUFFER$1, ',', BUFFER, '.buffer);',\n GL, '.vertexAttribPointer(', [\n LOCATION,\n SIZE,\n TYPE,\n record.normalized,\n record.stride,\n record.offset\n ], ');',\n BINDING, '.type=', TYPE, ';',\n BINDING, '.size=', SIZE, ';',\n COMMON_KEYS.map(function (key) {\n return BINDING + '.' + key + '=' + record[key] + ';'\n }).join(''),\n '}');\n\n if (extInstancing) {\n var DIVISOR = record.divisor;\n scope(\n 'if(', BINDING, '.divisor!==', DIVISOR, '){',\n env.instancing, '.vertexAttribDivisorANGLE(', [LOCATION, DIVISOR], ');',\n BINDING, '.divisor=', DIVISOR, ';}');\n }\n }\n\n function emitConstant () {\n scope(\n 'if(', BINDING, '.buffer){',\n GL, '.disableVertexAttribArray(', LOCATION, ');',\n '}if(', CUTE_COMPONENTS.map(function (c, i) {\n return BINDING + '.' + c + '!==' + CONST_COMPONENTS[i]\n }).join('||'), '){',\n GL, '.vertexAttrib4f(', LOCATION, ',', CONST_COMPONENTS, ');',\n CUTE_COMPONENTS.map(function (c, i) {\n return BINDING + '.' + c + '=' + CONST_COMPONENTS[i] + ';'\n }).join(''),\n '}');\n }\n\n if (STATE === ATTRIB_STATE_POINTER) {\n emitBuffer();\n } else if (STATE === ATTRIB_STATE_CONSTANT) {\n emitConstant();\n } else {\n scope('if(', STATE, '===', ATTRIB_STATE_POINTER, '){');\n emitBuffer();\n scope('}else{');\n emitConstant();\n scope('}');\n }\n }\n\n attributes.forEach(function (attribute) {\n var name = attribute.name;\n var arg = args.attributes[name];\n var record;\n if (arg) {\n if (!filter(arg)) {\n return\n }\n record = arg.append(env, scope);\n } else {\n if (!filter(SCOPE_DECL)) {\n return\n }\n var scopeAttrib = env.scopeAttrib(name);\n check$1.optional(function () {\n env.assert(scope,\n scopeAttrib + '.state',\n 'missing attribute ' + name);\n });\n record = {};\n Object.keys(new AttributeRecord()).forEach(function (key) {\n record[key] = scope.def(scopeAttrib, '.', key);\n });\n }\n emitBindAttribute(\n env.link(attribute), typeLength(attribute.info.type), record);\n });\n }\n\n function emitUniforms (env, scope, args, uniforms, filter) {\n var shared = env.shared;\n var GL = shared.gl;\n\n var infix;\n for (var i = 0; i < uniforms.length; ++i) {\n var uniform = uniforms[i];\n var name = uniform.name;\n var type = uniform.info.type;\n var arg = args.uniforms[name];\n var UNIFORM = env.link(uniform);\n var LOCATION = UNIFORM + '.location';\n\n var VALUE;\n if (arg) {\n if (!filter(arg)) {\n continue\n }\n if (isStatic(arg)) {\n var value = arg.value;\n check$1.command(\n value !== null && typeof value !== 'undefined',\n 'missing uniform \"' + name + '\"', env.commandStr);\n if (type === GL_SAMPLER_2D || type === GL_SAMPLER_CUBE) {\n check$1.command(\n typeof value === 'function' &&\n ((type === GL_SAMPLER_2D &&\n (value._reglType === 'texture2d' ||\n value._reglType === 'framebuffer')) ||\n (type === GL_SAMPLER_CUBE &&\n (value._reglType === 'textureCube' ||\n value._reglType === 'framebufferCube'))),\n 'invalid texture for uniform ' + name, env.commandStr);\n var TEX_VALUE = env.link(value._texture || value.color[0]._texture);\n scope(GL, '.uniform1i(', LOCATION, ',', TEX_VALUE + '.bind());');\n scope.exit(TEX_VALUE, '.unbind();');\n } else if (\n type === GL_FLOAT_MAT2 ||\n type === GL_FLOAT_MAT3 ||\n type === GL_FLOAT_MAT4) {\n check$1.optional(function () {\n check$1.command(isArrayLike(value),\n 'invalid matrix for uniform ' + name, env.commandStr);\n check$1.command(\n (type === GL_FLOAT_MAT2 && value.length === 4) ||\n (type === GL_FLOAT_MAT3 && value.length === 9) ||\n (type === GL_FLOAT_MAT4 && value.length === 16),\n 'invalid length for matrix uniform ' + name, env.commandStr);\n });\n var MAT_VALUE = env.global.def('new Float32Array([' +\n Array.prototype.slice.call(value) + '])');\n var dim = 2;\n if (type === GL_FLOAT_MAT3) {\n dim = 3;\n } else if (type === GL_FLOAT_MAT4) {\n dim = 4;\n }\n scope(\n GL, '.uniformMatrix', dim, 'fv(',\n LOCATION, ',false,', MAT_VALUE, ');');\n } else {\n switch (type) {\n case GL_FLOAT$7:\n check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr);\n infix = '1f';\n break\n case GL_FLOAT_VEC2:\n check$1.command(\n isArrayLike(value) && value.length === 2,\n 'uniform ' + name, env.commandStr);\n infix = '2f';\n break\n case GL_FLOAT_VEC3:\n check$1.command(\n isArrayLike(value) && value.length === 3,\n 'uniform ' + name, env.commandStr);\n infix = '3f';\n break\n case GL_FLOAT_VEC4:\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'uniform ' + name, env.commandStr);\n infix = '4f';\n break\n case GL_BOOL:\n check$1.commandType(value, 'boolean', 'uniform ' + name, env.commandStr);\n infix = '1i';\n break\n case GL_INT$3:\n check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr);\n infix = '1i';\n break\n case GL_BOOL_VEC2:\n check$1.command(\n isArrayLike(value) && value.length === 2,\n 'uniform ' + name, env.commandStr);\n infix = '2i';\n break\n case GL_INT_VEC2:\n check$1.command(\n isArrayLike(value) && value.length === 2,\n 'uniform ' + name, env.commandStr);\n infix = '2i';\n break\n case GL_BOOL_VEC3:\n check$1.command(\n isArrayLike(value) && value.length === 3,\n 'uniform ' + name, env.commandStr);\n infix = '3i';\n break\n case GL_INT_VEC3:\n check$1.command(\n isArrayLike(value) && value.length === 3,\n 'uniform ' + name, env.commandStr);\n infix = '3i';\n break\n case GL_BOOL_VEC4:\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'uniform ' + name, env.commandStr);\n infix = '4i';\n break\n case GL_INT_VEC4:\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'uniform ' + name, env.commandStr);\n infix = '4i';\n break\n }\n scope(GL, '.uniform', infix, '(', LOCATION, ',',\n isArrayLike(value) ? Array.prototype.slice.call(value) : value,\n ');');\n }\n continue\n } else {\n VALUE = arg.append(env, scope);\n }\n } else {\n if (!filter(SCOPE_DECL)) {\n continue\n }\n VALUE = scope.def(shared.uniforms, '[', stringStore.id(name), ']');\n }\n\n if (type === GL_SAMPLER_2D) {\n scope(\n 'if(', VALUE, '&&', VALUE, '._reglType===\"framebuffer\"){',\n VALUE, '=', VALUE, '.color[0];',\n '}');\n } else if (type === GL_SAMPLER_CUBE) {\n scope(\n 'if(', VALUE, '&&', VALUE, '._reglType===\"framebufferCube\"){',\n VALUE, '=', VALUE, '.color[0];',\n '}');\n }\n\n // perform type validation\n check$1.optional(function () {\n function check (pred, message) {\n env.assert(scope, pred,\n 'bad data or missing for uniform \"' + name + '\". ' + message);\n }\n\n function checkType (type) {\n check(\n 'typeof ' + VALUE + '===\"' + type + '\"',\n 'invalid type, expected ' + type);\n }\n\n function checkVector (n, type) {\n check(\n shared.isArrayLike + '(' + VALUE + ')&&' + VALUE + '.length===' + n,\n 'invalid vector, should have length ' + n, env.commandStr);\n }\n\n function checkTexture (target) {\n check(\n 'typeof ' + VALUE + '===\"function\"&&' +\n VALUE + '._reglType===\"texture' +\n (target === GL_TEXTURE_2D$2 ? '2d' : 'Cube') + '\"',\n 'invalid texture type', env.commandStr);\n }\n\n switch (type) {\n case GL_INT$3:\n checkType('number');\n break\n case GL_INT_VEC2:\n checkVector(2, 'number');\n break\n case GL_INT_VEC3:\n checkVector(3, 'number');\n break\n case GL_INT_VEC4:\n checkVector(4, 'number');\n break\n case GL_FLOAT$7:\n checkType('number');\n break\n case GL_FLOAT_VEC2:\n checkVector(2, 'number');\n break\n case GL_FLOAT_VEC3:\n checkVector(3, 'number');\n break\n case GL_FLOAT_VEC4:\n checkVector(4, 'number');\n break\n case GL_BOOL:\n checkType('boolean');\n break\n case GL_BOOL_VEC2:\n checkVector(2, 'boolean');\n break\n case GL_BOOL_VEC3:\n checkVector(3, 'boolean');\n break\n case GL_BOOL_VEC4:\n checkVector(4, 'boolean');\n break\n case GL_FLOAT_MAT2:\n checkVector(4, 'number');\n break\n case GL_FLOAT_MAT3:\n checkVector(9, 'number');\n break\n case GL_FLOAT_MAT4:\n checkVector(16, 'number');\n break\n case GL_SAMPLER_2D:\n checkTexture(GL_TEXTURE_2D$2);\n break\n case GL_SAMPLER_CUBE:\n checkTexture(GL_TEXTURE_CUBE_MAP$1);\n break\n }\n });\n\n var unroll = 1;\n switch (type) {\n case GL_SAMPLER_2D:\n case GL_SAMPLER_CUBE:\n var TEX = scope.def(VALUE, '._texture');\n scope(GL, '.uniform1i(', LOCATION, ',', TEX, '.bind());');\n scope.exit(TEX, '.unbind();');\n continue\n\n case GL_INT$3:\n case GL_BOOL:\n infix = '1i';\n break\n\n case GL_INT_VEC2:\n case GL_BOOL_VEC2:\n infix = '2i';\n unroll = 2;\n break\n\n case GL_INT_VEC3:\n case GL_BOOL_VEC3:\n infix = '3i';\n unroll = 3;\n break\n\n case GL_INT_VEC4:\n case GL_BOOL_VEC4:\n infix = '4i';\n unroll = 4;\n break\n\n case GL_FLOAT$7:\n infix = '1f';\n break\n\n case GL_FLOAT_VEC2:\n infix = '2f';\n unroll = 2;\n break\n\n case GL_FLOAT_VEC3:\n infix = '3f';\n unroll = 3;\n break\n\n case GL_FLOAT_VEC4:\n infix = '4f';\n unroll = 4;\n break\n\n case GL_FLOAT_MAT2:\n infix = 'Matrix2fv';\n break\n\n case GL_FLOAT_MAT3:\n infix = 'Matrix3fv';\n break\n\n case GL_FLOAT_MAT4:\n infix = 'Matrix4fv';\n break\n }\n\n scope(GL, '.uniform', infix, '(', LOCATION, ',');\n if (infix.charAt(0) === 'M') {\n var matSize = Math.pow(type - GL_FLOAT_MAT2 + 2, 2);\n var STORAGE = env.global.def('new Float32Array(', matSize, ')');\n scope(\n 'false,(Array.isArray(', VALUE, ')||', VALUE, ' instanceof Float32Array)?', VALUE, ':(',\n loop(matSize, function (i) {\n return STORAGE + '[' + i + ']=' + VALUE + '[' + i + ']'\n }), ',', STORAGE, ')');\n } else if (unroll > 1) {\n scope(loop(unroll, function (i) {\n return VALUE + '[' + i + ']'\n }));\n } else {\n scope(VALUE);\n }\n scope(');');\n }\n }\n\n function emitDraw (env, outer, inner, args) {\n var shared = env.shared;\n var GL = shared.gl;\n var DRAW_STATE = shared.draw;\n\n var drawOptions = args.draw;\n\n function emitElements () {\n var defn = drawOptions.elements;\n var ELEMENTS;\n var scope = outer;\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n scope = inner;\n }\n ELEMENTS = defn.append(env, scope);\n } else {\n ELEMENTS = scope.def(DRAW_STATE, '.', S_ELEMENTS);\n }\n if (ELEMENTS) {\n scope(\n 'if(' + ELEMENTS + ')' +\n GL + '.bindBuffer(' + GL_ELEMENT_ARRAY_BUFFER$1 + ',' + ELEMENTS + '.buffer.buffer);');\n }\n return ELEMENTS\n }\n\n function emitCount () {\n var defn = drawOptions.count;\n var COUNT;\n var scope = outer;\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n scope = inner;\n }\n COUNT = defn.append(env, scope);\n check$1.optional(function () {\n if (defn.MISSING) {\n env.assert(outer, 'false', 'missing vertex count');\n }\n if (defn.DYNAMIC) {\n env.assert(scope, COUNT + '>=0', 'missing vertex count');\n }\n });\n } else {\n COUNT = scope.def(DRAW_STATE, '.', S_COUNT);\n check$1.optional(function () {\n env.assert(scope, COUNT + '>=0', 'missing vertex count');\n });\n }\n return COUNT\n }\n\n var ELEMENTS = emitElements();\n function emitValue (name) {\n var defn = drawOptions[name];\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n return defn.append(env, inner)\n } else {\n return defn.append(env, outer)\n }\n } else {\n return outer.def(DRAW_STATE, '.', name)\n }\n }\n\n var PRIMITIVE = emitValue(S_PRIMITIVE);\n var OFFSET = emitValue(S_OFFSET);\n\n var COUNT = emitCount();\n if (typeof COUNT === 'number') {\n if (COUNT === 0) {\n return\n }\n } else {\n inner('if(', COUNT, '){');\n inner.exit('}');\n }\n\n var INSTANCES, EXT_INSTANCING;\n if (extInstancing) {\n INSTANCES = emitValue(S_INSTANCES);\n EXT_INSTANCING = env.instancing;\n }\n\n var ELEMENT_TYPE = ELEMENTS + '.type';\n\n var elementsStatic = drawOptions.elements && isStatic(drawOptions.elements);\n\n function emitInstancing () {\n function drawElements () {\n inner(EXT_INSTANCING, '.drawElementsInstancedANGLE(', [\n PRIMITIVE,\n COUNT,\n ELEMENT_TYPE,\n OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$7 + ')>>1)',\n INSTANCES\n ], ');');\n }\n\n function drawArrays () {\n inner(EXT_INSTANCING, '.drawArraysInstancedANGLE(',\n [PRIMITIVE, OFFSET, COUNT, INSTANCES], ');');\n }\n\n if (ELEMENTS) {\n if (!elementsStatic) {\n inner('if(', ELEMENTS, '){');\n drawElements();\n inner('}else{');\n drawArrays();\n inner('}');\n } else {\n drawElements();\n }\n } else {\n drawArrays();\n }\n }\n\n function emitRegular () {\n function drawElements () {\n inner(GL + '.drawElements(' + [\n PRIMITIVE,\n COUNT,\n ELEMENT_TYPE,\n OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$7 + ')>>1)'\n ] + ');');\n }\n\n function drawArrays () {\n inner(GL + '.drawArrays(' + [PRIMITIVE, OFFSET, COUNT] + ');');\n }\n\n if (ELEMENTS) {\n if (!elementsStatic) {\n inner('if(', ELEMENTS, '){');\n drawElements();\n inner('}else{');\n drawArrays();\n inner('}');\n } else {\n drawElements();\n }\n } else {\n drawArrays();\n }\n }\n\n if (extInstancing && (typeof INSTANCES !== 'number' || INSTANCES >= 0)) {\n if (typeof INSTANCES === 'string') {\n inner('if(', INSTANCES, '>0){');\n emitInstancing();\n inner('}else if(', INSTANCES, '<0){');\n emitRegular();\n inner('}');\n } else {\n emitInstancing();\n }\n } else {\n emitRegular();\n }\n }\n\n function createBody (emitBody, parentEnv, args, program, count) {\n var env = createREGLEnvironment();\n var scope = env.proc('body', count);\n check$1.optional(function () {\n env.commandStr = parentEnv.commandStr;\n env.command = env.link(parentEnv.commandStr);\n });\n if (extInstancing) {\n env.instancing = scope.def(\n env.shared.extensions, '.angle_instanced_arrays');\n }\n emitBody(env, scope, args, program);\n return env.compile().body\n }\n\n // ===================================================\n // ===================================================\n // DRAW PROC\n // ===================================================\n // ===================================================\n function emitDrawBody (env, draw, args, program) {\n injectExtensions(env, draw);\n emitAttributes(env, draw, args, program.attributes, function () {\n return true\n });\n emitUniforms(env, draw, args, program.uniforms, function () {\n return true\n });\n emitDraw(env, draw, draw, args);\n }\n\n function emitDrawProc (env, args) {\n var draw = env.proc('draw', 1);\n\n injectExtensions(env, draw);\n\n emitContext(env, draw, args.context);\n emitPollFramebuffer(env, draw, args.framebuffer);\n\n emitPollState(env, draw, args);\n emitSetOptions(env, draw, args.state);\n\n emitProfile(env, draw, args, false, true);\n\n var program = args.shader.progVar.append(env, draw);\n draw(env.shared.gl, '.useProgram(', program, '.program);');\n\n if (args.shader.program) {\n emitDrawBody(env, draw, args, args.shader.program);\n } else {\n var drawCache = env.global.def('{}');\n var PROG_ID = draw.def(program, '.id');\n var CACHED_PROC = draw.def(drawCache, '[', PROG_ID, ']');\n draw(\n env.cond(CACHED_PROC)\n .then(CACHED_PROC, '.call(this,a0);')\n .else(\n CACHED_PROC, '=', drawCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(emitDrawBody, env, args, program, 1)\n }), '(', program, ');',\n CACHED_PROC, '.call(this,a0);'));\n }\n\n if (Object.keys(args.state).length > 0) {\n draw(env.shared.current, '.dirty=true;');\n }\n }\n\n // ===================================================\n // ===================================================\n // BATCH PROC\n // ===================================================\n // ===================================================\n\n function emitBatchDynamicShaderBody (env, scope, args, program) {\n env.batchId = 'a1';\n\n injectExtensions(env, scope);\n\n function all () {\n return true\n }\n\n emitAttributes(env, scope, args, program.attributes, all);\n emitUniforms(env, scope, args, program.uniforms, all);\n emitDraw(env, scope, scope, args);\n }\n\n function emitBatchBody (env, scope, args, program) {\n injectExtensions(env, scope);\n\n var contextDynamic = args.contextDep;\n\n var BATCH_ID = scope.def();\n var PROP_LIST = 'a0';\n var NUM_PROPS = 'a1';\n var PROPS = scope.def();\n env.shared.props = PROPS;\n env.batchId = BATCH_ID;\n\n var outer = env.scope();\n var inner = env.scope();\n\n scope(\n outer.entry,\n 'for(', BATCH_ID, '=0;', BATCH_ID, '<', NUM_PROPS, ';++', BATCH_ID, '){',\n PROPS, '=', PROP_LIST, '[', BATCH_ID, '];',\n inner,\n '}',\n outer.exit);\n\n function isInnerDefn (defn) {\n return ((defn.contextDep && contextDynamic) || defn.propDep)\n }\n\n function isOuterDefn (defn) {\n return !isInnerDefn(defn)\n }\n\n if (args.needsContext) {\n emitContext(env, inner, args.context);\n }\n if (args.needsFramebuffer) {\n emitPollFramebuffer(env, inner, args.framebuffer);\n }\n emitSetOptions(env, inner, args.state, isInnerDefn);\n\n if (args.profile && isInnerDefn(args.profile)) {\n emitProfile(env, inner, args, false, true);\n }\n\n if (!program) {\n var progCache = env.global.def('{}');\n var PROGRAM = args.shader.progVar.append(env, inner);\n var PROG_ID = inner.def(PROGRAM, '.id');\n var CACHED_PROC = inner.def(progCache, '[', PROG_ID, ']');\n inner(\n env.shared.gl, '.useProgram(', PROGRAM, '.program);',\n 'if(!', CACHED_PROC, '){',\n CACHED_PROC, '=', progCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(\n emitBatchDynamicShaderBody, env, args, program, 2)\n }), '(', PROGRAM, ');}',\n CACHED_PROC, '.call(this,a0[', BATCH_ID, '],', BATCH_ID, ');');\n } else {\n emitAttributes(env, outer, args, program.attributes, isOuterDefn);\n emitAttributes(env, inner, args, program.attributes, isInnerDefn);\n emitUniforms(env, outer, args, program.uniforms, isOuterDefn);\n emitUniforms(env, inner, args, program.uniforms, isInnerDefn);\n emitDraw(env, outer, inner, args);\n }\n }\n\n function emitBatchProc (env, args) {\n var batch = env.proc('batch', 2);\n env.batchId = '0';\n\n injectExtensions(env, batch);\n\n // Check if any context variables depend on props\n var contextDynamic = false;\n var needsContext = true;\n Object.keys(args.context).forEach(function (name) {\n contextDynamic = contextDynamic || args.context[name].propDep;\n });\n if (!contextDynamic) {\n emitContext(env, batch, args.context);\n needsContext = false;\n }\n\n // framebuffer state affects framebufferWidth/height context vars\n var framebuffer = args.framebuffer;\n var needsFramebuffer = false;\n if (framebuffer) {\n if (framebuffer.propDep) {\n contextDynamic = needsFramebuffer = true;\n } else if (framebuffer.contextDep && contextDynamic) {\n needsFramebuffer = true;\n }\n if (!needsFramebuffer) {\n emitPollFramebuffer(env, batch, framebuffer);\n }\n } else {\n emitPollFramebuffer(env, batch, null);\n }\n\n // viewport is weird because it can affect context vars\n if (args.state.viewport && args.state.viewport.propDep) {\n contextDynamic = true;\n }\n\n function isInnerDefn (defn) {\n return (defn.contextDep && contextDynamic) || defn.propDep\n }\n\n // set webgl options\n emitPollState(env, batch, args);\n emitSetOptions(env, batch, args.state, function (defn) {\n return !isInnerDefn(defn)\n });\n\n if (!args.profile || !isInnerDefn(args.profile)) {\n emitProfile(env, batch, args, false, 'a1');\n }\n\n // Save these values to args so that the batch body routine can use them\n args.contextDep = contextDynamic;\n args.needsContext = needsContext;\n args.needsFramebuffer = needsFramebuffer;\n\n // determine if shader is dynamic\n var progDefn = args.shader.progVar;\n if ((progDefn.contextDep && contextDynamic) || progDefn.propDep) {\n emitBatchBody(\n env,\n batch,\n args,\n null);\n } else {\n var PROGRAM = progDefn.append(env, batch);\n batch(env.shared.gl, '.useProgram(', PROGRAM, '.program);');\n if (args.shader.program) {\n emitBatchBody(\n env,\n batch,\n args,\n args.shader.program);\n } else {\n var batchCache = env.global.def('{}');\n var PROG_ID = batch.def(PROGRAM, '.id');\n var CACHED_PROC = batch.def(batchCache, '[', PROG_ID, ']');\n batch(\n env.cond(CACHED_PROC)\n .then(CACHED_PROC, '.call(this,a0,a1);')\n .else(\n CACHED_PROC, '=', batchCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(emitBatchBody, env, args, program, 2)\n }), '(', PROGRAM, ');',\n CACHED_PROC, '.call(this,a0,a1);'));\n }\n }\n\n if (Object.keys(args.state).length > 0) {\n batch(env.shared.current, '.dirty=true;');\n }\n }\n\n // ===================================================\n // ===================================================\n // SCOPE COMMAND\n // ===================================================\n // ===================================================\n function emitScopeProc (env, args) {\n var scope = env.proc('scope', 3);\n env.batchId = 'a2';\n\n var shared = env.shared;\n var CURRENT_STATE = shared.current;\n\n emitContext(env, scope, args.context);\n\n if (args.framebuffer) {\n args.framebuffer.append(env, scope);\n }\n\n sortState(Object.keys(args.state)).forEach(function (name) {\n var defn = args.state[name];\n var value = defn.append(env, scope);\n if (isArrayLike(value)) {\n value.forEach(function (v, i) {\n scope.set(env.next[name], '[' + i + ']', v);\n });\n } else {\n scope.set(shared.next, '.' + name, value);\n }\n });\n\n emitProfile(env, scope, args, true, true)\n\n ;[S_ELEMENTS, S_OFFSET, S_COUNT, S_INSTANCES, S_PRIMITIVE].forEach(\n function (opt) {\n var variable = args.draw[opt];\n if (!variable) {\n return\n }\n scope.set(shared.draw, '.' + opt, '' + variable.append(env, scope));\n });\n\n Object.keys(args.uniforms).forEach(function (opt) {\n scope.set(\n shared.uniforms,\n '[' + stringStore.id(opt) + ']',\n args.uniforms[opt].append(env, scope));\n });\n\n Object.keys(args.attributes).forEach(function (name) {\n var record = args.attributes[name].append(env, scope);\n var scopeAttrib = env.scopeAttrib(name);\n Object.keys(new AttributeRecord()).forEach(function (prop) {\n scope.set(scopeAttrib, '.' + prop, record[prop]);\n });\n });\n\n function saveShader (name) {\n var shader = args.shader[name];\n if (shader) {\n scope.set(shared.shader, '.' + name, shader.append(env, scope));\n }\n }\n saveShader(S_VERT);\n saveShader(S_FRAG);\n\n if (Object.keys(args.state).length > 0) {\n scope(CURRENT_STATE, '.dirty=true;');\n scope.exit(CURRENT_STATE, '.dirty=true;');\n }\n\n scope('a1(', env.shared.context, ',a0,', env.batchId, ');');\n }\n\n function isDynamicObject (object) {\n if (typeof object !== 'object' || isArrayLike(object)) {\n return\n }\n var props = Object.keys(object);\n for (var i = 0; i < props.length; ++i) {\n if (dynamic.isDynamic(object[props[i]])) {\n return true\n }\n }\n return false\n }\n\n function splatObject (env, options, name) {\n var object = options.static[name];\n if (!object || !isDynamicObject(object)) {\n return\n }\n\n var globals = env.global;\n var keys = Object.keys(object);\n var thisDep = false;\n var contextDep = false;\n var propDep = false;\n var objectRef = env.global.def('{}');\n keys.forEach(function (key) {\n var value = object[key];\n if (dynamic.isDynamic(value)) {\n if (typeof value === 'function') {\n value = object[key] = dynamic.unbox(value);\n }\n var deps = createDynamicDecl(value, null);\n thisDep = thisDep || deps.thisDep;\n propDep = propDep || deps.propDep;\n contextDep = contextDep || deps.contextDep;\n } else {\n globals(objectRef, '.', key, '=');\n switch (typeof value) {\n case 'number':\n globals(value);\n break\n case 'string':\n globals('\"', value, '\"');\n break\n case 'object':\n if (Array.isArray(value)) {\n globals('[', value.join(), ']');\n }\n break\n default:\n globals(env.link(value));\n break\n }\n globals(';');\n }\n });\n\n function appendBlock (env, block) {\n keys.forEach(function (key) {\n var value = object[key];\n if (!dynamic.isDynamic(value)) {\n return\n }\n var ref = env.invoke(block, value);\n block(objectRef, '.', key, '=', ref, ';');\n });\n }\n\n options.dynamic[name] = new dynamic.DynamicVariable(DYN_THUNK, {\n thisDep: thisDep,\n contextDep: contextDep,\n propDep: propDep,\n ref: objectRef,\n append: appendBlock\n });\n delete options.static[name];\n }\n\n // ===========================================================================\n // ===========================================================================\n // MAIN DRAW COMMAND\n // ===========================================================================\n // ===========================================================================\n function compileCommand (options, attributes, uniforms, context, stats) {\n var env = createREGLEnvironment();\n\n // link stats, so that we can easily access it in the program.\n env.stats = env.link(stats);\n\n // splat options and attributes to allow for dynamic nested properties\n Object.keys(attributes.static).forEach(function (key) {\n splatObject(env, attributes, key);\n });\n NESTED_OPTIONS.forEach(function (name) {\n splatObject(env, options, name);\n });\n\n var args = parseArguments(options, attributes, uniforms, context, env);\n\n emitDrawProc(env, args);\n emitScopeProc(env, args);\n emitBatchProc(env, args);\n\n return env.compile()\n }\n\n // ===========================================================================\n // ===========================================================================\n // POLL / REFRESH\n // ===========================================================================\n // ===========================================================================\n return {\n next: nextState,\n current: currentState,\n procs: (function () {\n var env = createREGLEnvironment();\n var poll = env.proc('poll');\n var refresh = env.proc('refresh');\n var common = env.block();\n poll(common);\n refresh(common);\n\n var shared = env.shared;\n var GL = shared.gl;\n var NEXT_STATE = shared.next;\n var CURRENT_STATE = shared.current;\n\n common(CURRENT_STATE, '.dirty=false;');\n\n emitPollFramebuffer(env, poll);\n emitPollFramebuffer(env, refresh, null, true);\n\n // Refresh updates all attribute state changes\n var extInstancing = gl.getExtension('angle_instanced_arrays');\n var INSTANCING;\n if (extInstancing) {\n INSTANCING = env.link(extInstancing);\n }\n for (var i = 0; i < limits.maxAttributes; ++i) {\n var BINDING = refresh.def(shared.attributes, '[', i, ']');\n var ifte = env.cond(BINDING, '.buffer');\n ifte.then(\n GL, '.enableVertexAttribArray(', i, ');',\n GL, '.bindBuffer(',\n GL_ARRAY_BUFFER$1, ',',\n BINDING, '.buffer.buffer);',\n GL, '.vertexAttribPointer(',\n i, ',',\n BINDING, '.size,',\n BINDING, '.type,',\n BINDING, '.normalized,',\n BINDING, '.stride,',\n BINDING, '.offset);'\n ).else(\n GL, '.disableVertexAttribArray(', i, ');',\n GL, '.vertexAttrib4f(',\n i, ',',\n BINDING, '.x,',\n BINDING, '.y,',\n BINDING, '.z,',\n BINDING, '.w);',\n BINDING, '.buffer=null;');\n refresh(ifte);\n if (extInstancing) {\n refresh(\n INSTANCING, '.vertexAttribDivisorANGLE(',\n i, ',',\n BINDING, '.divisor);');\n }\n }\n\n Object.keys(GL_FLAGS).forEach(function (flag) {\n var cap = GL_FLAGS[flag];\n var NEXT = common.def(NEXT_STATE, '.', flag);\n var block = env.block();\n block('if(', NEXT, '){',\n GL, '.enable(', cap, ')}else{',\n GL, '.disable(', cap, ')}',\n CURRENT_STATE, '.', flag, '=', NEXT, ';');\n refresh(block);\n poll(\n 'if(', NEXT, '!==', CURRENT_STATE, '.', flag, '){',\n block,\n '}');\n });\n\n Object.keys(GL_VARIABLES).forEach(function (name) {\n var func = GL_VARIABLES[name];\n var init = currentState[name];\n var NEXT, CURRENT;\n var block = env.block();\n block(GL, '.', func, '(');\n if (isArrayLike(init)) {\n var n = init.length;\n NEXT = env.global.def(NEXT_STATE, '.', name);\n CURRENT = env.global.def(CURRENT_STATE, '.', name);\n block(\n loop(n, function (i) {\n return NEXT + '[' + i + ']'\n }), ');',\n loop(n, function (i) {\n return CURRENT + '[' + i + ']=' + NEXT + '[' + i + '];'\n }).join(''));\n poll(\n 'if(', loop(n, function (i) {\n return NEXT + '[' + i + ']!==' + CURRENT + '[' + i + ']'\n }).join('||'), '){',\n block,\n '}');\n } else {\n NEXT = common.def(NEXT_STATE, '.', name);\n CURRENT = common.def(CURRENT_STATE, '.', name);\n block(\n NEXT, ');',\n CURRENT_STATE, '.', name, '=', NEXT, ';');\n poll(\n 'if(', NEXT, '!==', CURRENT, '){',\n block,\n '}');\n }\n refresh(block);\n });\n\n return env.compile()\n })(),\n compile: compileCommand\n }\n}\n\nfunction stats () {\n return {\n bufferCount: 0,\n elementsCount: 0,\n framebufferCount: 0,\n shaderCount: 0,\n textureCount: 0,\n cubeCount: 0,\n renderbufferCount: 0,\n\n maxTextureUnits: 0\n }\n}\n\nvar GL_QUERY_RESULT_EXT = 0x8866;\nvar GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867;\nvar GL_TIME_ELAPSED_EXT = 0x88BF;\n\nvar createTimer = function (gl, extensions) {\n var extTimer = extensions.ext_disjoint_timer_query;\n\n if (!extTimer) {\n return null\n }\n\n // QUERY POOL BEGIN\n var queryPool = [];\n function allocQuery () {\n return queryPool.pop() || extTimer.createQueryEXT()\n }\n function freeQuery (query) {\n queryPool.push(query);\n }\n // QUERY POOL END\n\n var pendingQueries = [];\n function beginQuery (stats) {\n var query = allocQuery();\n extTimer.beginQueryEXT(GL_TIME_ELAPSED_EXT, query);\n pendingQueries.push(query);\n pushScopeStats(pendingQueries.length - 1, pendingQueries.length, stats);\n }\n\n function endQuery () {\n extTimer.endQueryEXT(GL_TIME_ELAPSED_EXT);\n }\n\n //\n // Pending stats pool.\n //\n function PendingStats () {\n this.startQueryIndex = -1;\n this.endQueryIndex = -1;\n this.sum = 0;\n this.stats = null;\n }\n var pendingStatsPool = [];\n function allocPendingStats () {\n return pendingStatsPool.pop() || new PendingStats()\n }\n function freePendingStats (pendingStats) {\n pendingStatsPool.push(pendingStats);\n }\n // Pending stats pool end\n\n var pendingStats = [];\n function pushScopeStats (start, end, stats) {\n var ps = allocPendingStats();\n ps.startQueryIndex = start;\n ps.endQueryIndex = end;\n ps.sum = 0;\n ps.stats = stats;\n pendingStats.push(ps);\n }\n\n // we should call this at the beginning of the frame,\n // in order to update gpuTime\n var timeSum = [];\n var queryPtr = [];\n function update () {\n var ptr, i;\n\n var n = pendingQueries.length;\n if (n === 0) {\n return\n }\n\n // Reserve space\n queryPtr.length = Math.max(queryPtr.length, n + 1);\n timeSum.length = Math.max(timeSum.length, n + 1);\n timeSum[0] = 0;\n queryPtr[0] = 0;\n\n // Update all pending timer queries\n var queryTime = 0;\n ptr = 0;\n for (i = 0; i < pendingQueries.length; ++i) {\n var query = pendingQueries[i];\n if (extTimer.getQueryObjectEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT)) {\n queryTime += extTimer.getQueryObjectEXT(query, GL_QUERY_RESULT_EXT);\n freeQuery(query);\n } else {\n pendingQueries[ptr++] = query;\n }\n timeSum[i + 1] = queryTime;\n queryPtr[i + 1] = ptr;\n }\n pendingQueries.length = ptr;\n\n // Update all pending stat queries\n ptr = 0;\n for (i = 0; i < pendingStats.length; ++i) {\n var stats = pendingStats[i];\n var start = stats.startQueryIndex;\n var end = stats.endQueryIndex;\n stats.sum += timeSum[end] - timeSum[start];\n var startPtr = queryPtr[start];\n var endPtr = queryPtr[end];\n if (endPtr === startPtr) {\n stats.stats.gpuTime += stats.sum / 1e6;\n freePendingStats(stats);\n } else {\n stats.startQueryIndex = startPtr;\n stats.endQueryIndex = endPtr;\n pendingStats[ptr++] = stats;\n }\n }\n pendingStats.length = ptr;\n }\n\n return {\n beginQuery: beginQuery,\n endQuery: endQuery,\n pushScopeStats: pushScopeStats,\n update: update,\n getNumPendingQueries: function () {\n return pendingQueries.length\n },\n clear: function () {\n queryPool.push.apply(queryPool, pendingQueries);\n for (var i = 0; i < queryPool.length; i++) {\n extTimer.deleteQueryEXT(queryPool[i]);\n }\n pendingQueries.length = 0;\n queryPool.length = 0;\n },\n restore: function () {\n pendingQueries.length = 0;\n queryPool.length = 0;\n }\n }\n};\n\nvar GL_COLOR_BUFFER_BIT = 16384;\nvar GL_DEPTH_BUFFER_BIT = 256;\nvar GL_STENCIL_BUFFER_BIT = 1024;\n\nvar GL_ARRAY_BUFFER = 34962;\n\nvar CONTEXT_LOST_EVENT = 'webglcontextlost';\nvar CONTEXT_RESTORED_EVENT = 'webglcontextrestored';\n\nvar DYN_PROP = 1;\nvar DYN_CONTEXT = 2;\nvar DYN_STATE = 3;\n\nfunction find (haystack, needle) {\n for (var i = 0; i < haystack.length; ++i) {\n if (haystack[i] === needle) {\n return i\n }\n }\n return -1\n}\n\nfunction wrapREGL (args) {\n var config = parseArgs(args);\n if (!config) {\n return null\n }\n\n var gl = config.gl;\n var glAttributes = gl.getContextAttributes();\n var contextLost = gl.isContextLost();\n\n var extensionState = createExtensionCache(gl, config);\n if (!extensionState) {\n return null\n }\n\n var stringStore = createStringStore();\n var stats$$1 = stats();\n var extensions = extensionState.extensions;\n var timer = createTimer(gl, extensions);\n\n var START_TIME = clock();\n var WIDTH = gl.drawingBufferWidth;\n var HEIGHT = gl.drawingBufferHeight;\n\n var contextState = {\n tick: 0,\n time: 0,\n viewportWidth: WIDTH,\n viewportHeight: HEIGHT,\n framebufferWidth: WIDTH,\n framebufferHeight: HEIGHT,\n drawingBufferWidth: WIDTH,\n drawingBufferHeight: HEIGHT,\n pixelRatio: config.pixelRatio\n };\n var uniformState = {};\n var drawState = {\n elements: null,\n primitive: 4, // GL_TRIANGLES\n count: -1,\n offset: 0,\n instances: -1\n };\n\n var limits = wrapLimits(gl, extensions);\n var bufferState = wrapBufferState(gl, stats$$1, config);\n var elementState = wrapElementsState(gl, extensions, bufferState, stats$$1);\n var attributeState = wrapAttributeState(\n gl,\n extensions,\n limits,\n bufferState,\n stringStore);\n var shaderState = wrapShaderState(gl, stringStore, stats$$1, config);\n var textureState = createTextureSet(\n gl,\n extensions,\n limits,\n function () { core.procs.poll(); },\n contextState,\n stats$$1,\n config);\n var renderbufferState = wrapRenderbuffers(gl, extensions, limits, stats$$1, config);\n var framebufferState = wrapFBOState(\n gl,\n extensions,\n limits,\n textureState,\n renderbufferState,\n stats$$1);\n var core = reglCore(\n gl,\n stringStore,\n extensions,\n limits,\n bufferState,\n elementState,\n textureState,\n framebufferState,\n uniformState,\n attributeState,\n shaderState,\n drawState,\n contextState,\n timer,\n config);\n var readPixels = wrapReadPixels(\n gl,\n framebufferState,\n core.procs.poll,\n contextState,\n glAttributes, extensions);\n\n var nextState = core.next;\n var canvas = gl.canvas;\n\n var rafCallbacks = [];\n var lossCallbacks = [];\n var restoreCallbacks = [];\n var destroyCallbacks = [config.onDestroy];\n\n var activeRAF = null;\n function handleRAF () {\n if (rafCallbacks.length === 0) {\n if (timer) {\n timer.update();\n }\n activeRAF = null;\n return\n }\n\n // schedule next animation frame\n activeRAF = raf.next(handleRAF);\n\n // poll for changes\n poll();\n\n // fire a callback for all pending rafs\n for (var i = rafCallbacks.length - 1; i >= 0; --i) {\n var cb = rafCallbacks[i];\n if (cb) {\n cb(contextState, null, 0);\n }\n }\n\n // flush all pending webgl calls\n gl.flush();\n\n // poll GPU timers *after* gl.flush so we don't delay command dispatch\n if (timer) {\n timer.update();\n }\n }\n\n function startRAF () {\n if (!activeRAF && rafCallbacks.length > 0) {\n activeRAF = raf.next(handleRAF);\n }\n }\n\n function stopRAF () {\n if (activeRAF) {\n raf.cancel(handleRAF);\n activeRAF = null;\n }\n }\n\n function handleContextLoss (event) {\n event.preventDefault();\n\n // set context lost flag\n contextLost = true;\n\n // pause request animation frame\n stopRAF();\n\n // lose context\n lossCallbacks.forEach(function (cb) {\n cb();\n });\n }\n\n function handleContextRestored (event) {\n // clear error code\n gl.getError();\n\n // clear context lost flag\n contextLost = false;\n\n // refresh state\n extensionState.restore();\n shaderState.restore();\n bufferState.restore();\n textureState.restore();\n renderbufferState.restore();\n framebufferState.restore();\n if (timer) {\n timer.restore();\n }\n\n // refresh state\n core.procs.refresh();\n\n // restart RAF\n startRAF();\n\n // restore context\n restoreCallbacks.forEach(function (cb) {\n cb();\n });\n }\n\n if (canvas) {\n canvas.addEventListener(CONTEXT_LOST_EVENT, handleContextLoss, false);\n canvas.addEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored, false);\n }\n\n function destroy () {\n rafCallbacks.length = 0;\n stopRAF();\n\n if (canvas) {\n canvas.removeEventListener(CONTEXT_LOST_EVENT, handleContextLoss);\n canvas.removeEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored);\n }\n\n shaderState.clear();\n framebufferState.clear();\n renderbufferState.clear();\n textureState.clear();\n elementState.clear();\n bufferState.clear();\n\n if (timer) {\n timer.clear();\n }\n\n destroyCallbacks.forEach(function (cb) {\n cb();\n });\n }\n\n function compileProcedure (options) {\n check$1(!!options, 'invalid args to regl({...})');\n check$1.type(options, 'object', 'invalid args to regl({...})');\n\n function flattenNestedOptions (options) {\n var result = extend({}, options);\n delete result.uniforms;\n delete result.attributes;\n delete result.context;\n\n if ('stencil' in result && result.stencil.op) {\n result.stencil.opBack = result.stencil.opFront = result.stencil.op;\n delete result.stencil.op;\n }\n\n function merge (name) {\n if (name in result) {\n var child = result[name];\n delete result[name];\n Object.keys(child).forEach(function (prop) {\n result[name + '.' + prop] = child[prop];\n });\n }\n }\n merge('blend');\n merge('depth');\n merge('cull');\n merge('stencil');\n merge('polygonOffset');\n merge('scissor');\n merge('sample');\n\n return result\n }\n\n function separateDynamic (object) {\n var staticItems = {};\n var dynamicItems = {};\n Object.keys(object).forEach(function (option) {\n var value = object[option];\n if (dynamic.isDynamic(value)) {\n dynamicItems[option] = dynamic.unbox(value, option);\n } else {\n staticItems[option] = value;\n }\n });\n return {\n dynamic: dynamicItems,\n static: staticItems\n }\n }\n\n // Treat context variables separate from other dynamic variables\n var context = separateDynamic(options.context || {});\n var uniforms = separateDynamic(options.uniforms || {});\n var attributes = separateDynamic(options.attributes || {});\n var opts = separateDynamic(flattenNestedOptions(options));\n\n var stats$$1 = {\n gpuTime: 0.0,\n cpuTime: 0.0,\n count: 0\n };\n\n var compiled = core.compile(opts, attributes, uniforms, context, stats$$1);\n\n var draw = compiled.draw;\n var batch = compiled.batch;\n var scope = compiled.scope;\n\n // FIXME: we should modify code generation for batch commands so this\n // isn't necessary\n var EMPTY_ARRAY = [];\n function reserve (count) {\n while (EMPTY_ARRAY.length < count) {\n EMPTY_ARRAY.push(null);\n }\n return EMPTY_ARRAY\n }\n\n function REGLCommand (args, body) {\n var i;\n if (contextLost) {\n check$1.raise('context lost');\n }\n if (typeof args === 'function') {\n return scope.call(this, null, args, 0)\n } else if (typeof body === 'function') {\n if (typeof args === 'number') {\n for (i = 0; i < args; ++i) {\n scope.call(this, null, body, i);\n }\n return\n } else if (Array.isArray(args)) {\n for (i = 0; i < args.length; ++i) {\n scope.call(this, args[i], body, i);\n }\n return\n } else {\n return scope.call(this, args, body, 0)\n }\n } else if (typeof args === 'number') {\n if (args > 0) {\n return batch.call(this, reserve(args | 0), args | 0)\n }\n } else if (Array.isArray(args)) {\n if (args.length) {\n return batch.call(this, args, args.length)\n }\n } else {\n return draw.call(this, args)\n }\n }\n\n return extend(REGLCommand, {\n stats: stats$$1\n })\n }\n\n var setFBO = framebufferState.setFBO = compileProcedure({\n framebuffer: dynamic.define.call(null, DYN_PROP, 'framebuffer')\n });\n\n function clearImpl (_, options) {\n var clearFlags = 0;\n core.procs.poll();\n\n var c = options.color;\n if (c) {\n gl.clearColor(+c[0] || 0, +c[1] || 0, +c[2] || 0, +c[3] || 0);\n clearFlags |= GL_COLOR_BUFFER_BIT;\n }\n if ('depth' in options) {\n gl.clearDepth(+options.depth);\n clearFlags |= GL_DEPTH_BUFFER_BIT;\n }\n if ('stencil' in options) {\n gl.clearStencil(options.stencil | 0);\n clearFlags |= GL_STENCIL_BUFFER_BIT;\n }\n\n check$1(!!clearFlags, 'called regl.clear with no buffer specified');\n gl.clear(clearFlags);\n }\n\n function clear (options) {\n check$1(\n typeof options === 'object' && options,\n 'regl.clear() takes an object as input');\n if ('framebuffer' in options) {\n if (options.framebuffer &&\n options.framebuffer_reglType === 'framebufferCube') {\n for (var i = 0; i < 6; ++i) {\n setFBO(extend({\n framebuffer: options.framebuffer.faces[i]\n }, options), clearImpl);\n }\n } else {\n setFBO(options, clearImpl);\n }\n } else {\n clearImpl(null, options);\n }\n }\n\n function frame (cb) {\n check$1.type(cb, 'function', 'regl.frame() callback must be a function');\n rafCallbacks.push(cb);\n\n function cancel () {\n // FIXME: should we check something other than equals cb here?\n // what if a user calls frame twice with the same callback...\n //\n var i = find(rafCallbacks, cb);\n check$1(i >= 0, 'cannot cancel a frame twice');\n function pendingCancel () {\n var index = find(rafCallbacks, pendingCancel);\n rafCallbacks[index] = rafCallbacks[rafCallbacks.length - 1];\n rafCallbacks.length -= 1;\n if (rafCallbacks.length <= 0) {\n stopRAF();\n }\n }\n rafCallbacks[i] = pendingCancel;\n }\n\n startRAF();\n\n return {\n cancel: cancel\n }\n }\n\n // poll viewport\n function pollViewport () {\n var viewport = nextState.viewport;\n var scissorBox = nextState.scissor_box;\n viewport[0] = viewport[1] = scissorBox[0] = scissorBox[1] = 0;\n contextState.viewportWidth =\n contextState.framebufferWidth =\n contextState.drawingBufferWidth =\n viewport[2] =\n scissorBox[2] = gl.drawingBufferWidth;\n contextState.viewportHeight =\n contextState.framebufferHeight =\n contextState.drawingBufferHeight =\n viewport[3] =\n scissorBox[3] = gl.drawingBufferHeight;\n }\n\n function poll () {\n contextState.tick += 1;\n contextState.time = now();\n pollViewport();\n core.procs.poll();\n }\n\n function refresh () {\n pollViewport();\n core.procs.refresh();\n if (timer) {\n timer.update();\n }\n }\n\n function now () {\n return (clock() - START_TIME) / 1000.0\n }\n\n refresh();\n\n function addListener (event, callback) {\n check$1.type(callback, 'function', 'listener callback must be a function');\n\n var callbacks;\n switch (event) {\n case 'frame':\n return frame(callback)\n case 'lost':\n callbacks = lossCallbacks;\n break\n case 'restore':\n callbacks = restoreCallbacks;\n break\n case 'destroy':\n callbacks = destroyCallbacks;\n break\n default:\n check$1.raise('invalid event, must be one of frame,lost,restore,destroy');\n }\n\n callbacks.push(callback);\n return {\n cancel: function () {\n for (var i = 0; i < callbacks.length; ++i) {\n if (callbacks[i] === callback) {\n callbacks[i] = callbacks[callbacks.length - 1];\n callbacks.pop();\n return\n }\n }\n }\n }\n }\n\n var regl = extend(compileProcedure, {\n // Clear current FBO\n clear: clear,\n\n // Short cuts for dynamic variables\n prop: dynamic.define.bind(null, DYN_PROP),\n context: dynamic.define.bind(null, DYN_CONTEXT),\n this: dynamic.define.bind(null, DYN_STATE),\n\n // executes an empty draw command\n draw: compileProcedure({}),\n\n // Resources\n buffer: function (options) {\n return bufferState.create(options, GL_ARRAY_BUFFER, false, false)\n },\n elements: function (options) {\n return elementState.create(options, false)\n },\n texture: textureState.create2D,\n cube: textureState.createCube,\n renderbuffer: renderbufferState.create,\n framebuffer: framebufferState.create,\n framebufferCube: framebufferState.createCube,\n\n // Expose context attributes\n attributes: glAttributes,\n\n // Frame rendering\n frame: frame,\n on: addListener,\n\n // System limits\n limits: limits,\n hasExtension: function (name) {\n return limits.extensions.indexOf(name.toLowerCase()) >= 0\n },\n\n // Read pixels\n read: readPixels,\n\n // Destroy regl and all associated resources\n destroy: destroy,\n\n // Direct GL state manipulation\n _gl: gl,\n _refresh: refresh,\n\n poll: function () {\n poll();\n if (timer) {\n timer.update();\n }\n },\n\n // Current time\n now: now,\n\n // regl Statistics Information\n stats: stats$$1\n });\n\n config.onDone(null, regl);\n\n return regl\n}\n\nreturn wrapREGL;\n\n})));\n//# sourceMappingURL=regl.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/regl/dist/regl.js\n// module id = 22\n// module chunks = 0","var Emitter = require('events/')\n\nmodule.exports = attach\n\nfunction attach(element, listener) {\n var position = new Emitter\n\n position[0] = 0\n position[1] = 0\n position.prev = [0, 0]\n position.flush = flush\n\n if (typeof window === 'undefined') {\n return position\n }\n\n listener = listener || element || window\n element = element || document.body\n listener.addEventListener('mousemove', (\n element === document.body\n || element === window\n ) ? function(e) {\n position.prev[0] = position[0]\n position.prev[1] = position[1]\n position[0] = e.clientX\n position[1] = e.clientY\n position.emit('move', e)\n }\n : function(e) {\n position.prev[0] = position[0]\n position.prev[1] = position[1]\n var bounds = element.getBoundingClientRect()\n position[0] = e.clientX - bounds.left\n position[1] = e.clientY - bounds.top\n position.emit('move', e)\n }\n , false)\n\n return position\n\n function flush() {\n position.prev[0] = position[0]\n position.prev[1] = position[1]\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/mouse-position/index.js\n// module id = 23\n// module chunks = 0","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfunction EventEmitter() {\n this._events = this._events || {};\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nEventEmitter.defaultMaxListeners = 10;\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!isNumber(n) || n < 0 || isNaN(n))\n throw TypeError('n must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nEventEmitter.prototype.emit = function(type) {\n var er, handler, len, args, i, listeners;\n\n if (!this._events)\n this._events = {};\n\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events.error ||\n (isObject(this._events.error) && !this._events.error.length)) {\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n }\n }\n\n handler = this._events[type];\n\n if (isUndefined(handler))\n return false;\n\n if (isFunction(handler)) {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n } else if (isObject(handler)) {\n args = Array.prototype.slice.call(arguments, 1);\n listeners = handler.slice();\n len = listeners.length;\n for (i = 0; i < len; i++)\n listeners[i].apply(this, args);\n }\n\n return true;\n};\n\nEventEmitter.prototype.addListener = function(type, listener) {\n var m;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events)\n this._events = {};\n\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (this._events.newListener)\n this.emit('newListener', type,\n isFunction(listener.listener) ?\n listener.listener : listener);\n\n if (!this._events[type])\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n else if (isObject(this._events[type]))\n // If we've already got an array, just append.\n this._events[type].push(listener);\n else\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n\n // Check for listener leak\n if (isObject(this._events[type]) && !this._events[type].warned) {\n if (!isUndefined(this._maxListeners)) {\n m = this._maxListeners;\n } else {\n m = EventEmitter.defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n if (typeof console.trace === 'function') {\n // not supported in IE 10\n console.trace();\n }\n }\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n var fired = false;\n\n function g() {\n this.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n g.listener = listener;\n this.on(type, g);\n\n return this;\n};\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener = function(type, listener) {\n var list, position, length, i;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events || !this._events[type])\n return this;\n\n list = this._events[type];\n length = list.length;\n position = -1;\n\n if (list === listener ||\n (isFunction(list.listener) && list.listener === listener)) {\n delete this._events[type];\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n\n } else if (isObject(list)) {\n for (i = length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list.length = 0;\n delete this._events[type];\n } else {\n list.splice(position, 1);\n }\n\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n var key, listeners;\n\n if (!this._events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!this._events.removeListener) {\n if (arguments.length === 0)\n this._events = {};\n else if (this._events[type])\n delete this._events[type];\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (key in this._events) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = {};\n return this;\n }\n\n listeners = this._events[type];\n\n if (isFunction(listeners)) {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n while (listeners.length)\n this.removeListener(type, listeners[listeners.length - 1]);\n }\n delete this._events[type];\n\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n var ret;\n if (!this._events || !this._events[type])\n ret = [];\n else if (isFunction(this._events[type]))\n ret = [this._events[type]];\n else\n ret = this._events[type].slice();\n return ret;\n};\n\nEventEmitter.prototype.listenerCount = function(type) {\n if (this._events) {\n var evlistener = this._events[type];\n\n if (isFunction(evlistener))\n return 1;\n else if (evlistener)\n return evlistener.length;\n }\n return 0;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n return emitter.listenerCount(type);\n};\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/events/events.js\n// module id = 24\n// module chunks = 0","/*global define:false */\n/**\n * Copyright 2012-2017 Craig Campbell\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * Mousetrap is a simple keyboard shortcut library for Javascript with\n * no external dependencies\n *\n * @version 1.6.1\n * @url craig.is/killing/mice\n */\n(function(window, document, undefined) {\n\n // Check if mousetrap is used inside browser, if not, return\n if (!window) {\n return;\n }\n\n /**\n * mapping of special keycodes to their corresponding keys\n *\n * everything in this dictionary cannot use keypress events\n * so it has to be here to map to the correct keycodes for\n * keyup/keydown events\n *\n * @type {Object}\n */\n var _MAP = {\n 8: 'backspace',\n 9: 'tab',\n 13: 'enter',\n 16: 'shift',\n 17: 'ctrl',\n 18: 'alt',\n 20: 'capslock',\n 27: 'esc',\n 32: 'space',\n 33: 'pageup',\n 34: 'pagedown',\n 35: 'end',\n 36: 'home',\n 37: 'left',\n 38: 'up',\n 39: 'right',\n 40: 'down',\n 45: 'ins',\n 46: 'del',\n 91: 'meta',\n 93: 'meta',\n 224: 'meta'\n };\n\n /**\n * mapping for special characters so they can support\n *\n * this dictionary is only used incase you want to bind a\n * keyup or keydown event to one of these keys\n *\n * @type {Object}\n */\n var _KEYCODE_MAP = {\n 106: '*',\n 107: '+',\n 109: '-',\n 110: '.',\n 111 : '/',\n 186: ';',\n 187: '=',\n 188: ',',\n 189: '-',\n 190: '.',\n 191: '/',\n 192: '`',\n 219: '[',\n 220: '\\\\',\n 221: ']',\n 222: '\\''\n };\n\n /**\n * this is a mapping of keys that require shift on a US keypad\n * back to the non shift equivelents\n *\n * this is so you can use keyup events with these keys\n *\n * note that this will only work reliably on US keyboards\n *\n * @type {Object}\n */\n var _SHIFT_MAP = {\n '~': '`',\n '!': '1',\n '@': '2',\n '#': '3',\n '$': '4',\n '%': '5',\n '^': '6',\n '&': '7',\n '*': '8',\n '(': '9',\n ')': '0',\n '_': '-',\n '+': '=',\n ':': ';',\n '\\\"': '\\'',\n '<': ',',\n '>': '.',\n '?': '/',\n '|': '\\\\'\n };\n\n /**\n * this is a list of special strings you can use to map\n * to modifier keys when you specify your keyboard shortcuts\n *\n * @type {Object}\n */\n var _SPECIAL_ALIASES = {\n 'option': 'alt',\n 'command': 'meta',\n 'return': 'enter',\n 'escape': 'esc',\n 'plus': '+',\n 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'\n };\n\n /**\n * variable to store the flipped version of _MAP from above\n * needed to check if we should use keypress or not when no action\n * is specified\n *\n * @type {Object|undefined}\n */\n var _REVERSE_MAP;\n\n /**\n * loop through the f keys, f1 to f19 and add them to the map\n * programatically\n */\n for (var i = 1; i < 20; ++i) {\n _MAP[111 + i] = 'f' + i;\n }\n\n /**\n * loop through to map numbers on the numeric keypad\n */\n for (i = 0; i <= 9; ++i) {\n\n // This needs to use a string cause otherwise since 0 is falsey\n // mousetrap will never fire for numpad 0 pressed as part of a keydown\n // event.\n //\n // @see https://github.com/ccampbell/mousetrap/pull/258\n _MAP[i + 96] = i.toString();\n }\n\n /**\n * cross browser add event method\n *\n * @param {Element|HTMLDocument} object\n * @param {string} type\n * @param {Function} callback\n * @returns void\n */\n function _addEvent(object, type, callback) {\n if (object.addEventListener) {\n object.addEventListener(type, callback, false);\n return;\n }\n\n object.attachEvent('on' + type, callback);\n }\n\n /**\n * takes the event and returns the key character\n *\n * @param {Event} e\n * @return {string}\n */\n function _characterFromEvent(e) {\n\n // for keypress events we should return the character as is\n if (e.type == 'keypress') {\n var character = String.fromCharCode(e.which);\n\n // if the shift key is not pressed then it is safe to assume\n // that we want the character to be lowercase. this means if\n // you accidentally have caps lock on then your key bindings\n // will continue to work\n //\n // the only side effect that might not be desired is if you\n // bind something like 'A' cause you want to trigger an\n // event when capital A is pressed caps lock will no longer\n // trigger the event. shift+a will though.\n if (!e.shiftKey) {\n character = character.toLowerCase();\n }\n\n return character;\n }\n\n // for non keypress events the special maps are needed\n if (_MAP[e.which]) {\n return _MAP[e.which];\n }\n\n if (_KEYCODE_MAP[e.which]) {\n return _KEYCODE_MAP[e.which];\n }\n\n // if it is not in the special map\n\n // with keydown and keyup events the character seems to always\n // come in as an uppercase character whether you are pressing shift\n // or not. we should make sure it is always lowercase for comparisons\n return String.fromCharCode(e.which).toLowerCase();\n }\n\n /**\n * checks if two arrays are equal\n *\n * @param {Array} modifiers1\n * @param {Array} modifiers2\n * @returns {boolean}\n */\n function _modifiersMatch(modifiers1, modifiers2) {\n return modifiers1.sort().join(',') === modifiers2.sort().join(',');\n }\n\n /**\n * takes a key event and figures out what the modifiers are\n *\n * @param {Event} e\n * @returns {Array}\n */\n function _eventModifiers(e) {\n var modifiers = [];\n\n if (e.shiftKey) {\n modifiers.push('shift');\n }\n\n if (e.altKey) {\n modifiers.push('alt');\n }\n\n if (e.ctrlKey) {\n modifiers.push('ctrl');\n }\n\n if (e.metaKey) {\n modifiers.push('meta');\n }\n\n return modifiers;\n }\n\n /**\n * prevents default for this event\n *\n * @param {Event} e\n * @returns void\n */\n function _preventDefault(e) {\n if (e.preventDefault) {\n e.preventDefault();\n return;\n }\n\n e.returnValue = false;\n }\n\n /**\n * stops propogation for this event\n *\n * @param {Event} e\n * @returns void\n */\n function _stopPropagation(e) {\n if (e.stopPropagation) {\n e.stopPropagation();\n return;\n }\n\n e.cancelBubble = true;\n }\n\n /**\n * determines if the keycode specified is a modifier key or not\n *\n * @param {string} key\n * @returns {boolean}\n */\n function _isModifier(key) {\n return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';\n }\n\n /**\n * reverses the map lookup so that we can look for specific keys\n * to see what can and can't use keypress\n *\n * @return {Object}\n */\n function _getReverseMap() {\n if (!_REVERSE_MAP) {\n _REVERSE_MAP = {};\n for (var key in _MAP) {\n\n // pull out the numeric keypad from here cause keypress should\n // be able to detect the keys from the character\n if (key > 95 && key < 112) {\n continue;\n }\n\n if (_MAP.hasOwnProperty(key)) {\n _REVERSE_MAP[_MAP[key]] = key;\n }\n }\n }\n return _REVERSE_MAP;\n }\n\n /**\n * picks the best action based on the key combination\n *\n * @param {string} key - character for key\n * @param {Array} modifiers\n * @param {string=} action passed in\n */\n function _pickBestAction(key, modifiers, action) {\n\n // if no action was picked in we should try to pick the one\n // that we think would work best for this key\n if (!action) {\n action = _getReverseMap()[key] ? 'keydown' : 'keypress';\n }\n\n // modifier keys don't work as expected with keypress,\n // switch to keydown\n if (action == 'keypress' && modifiers.length) {\n action = 'keydown';\n }\n\n return action;\n }\n\n /**\n * Converts from a string key combination to an array\n *\n * @param {string} combination like \"command+shift+l\"\n * @return {Array}\n */\n function _keysFromString(combination) {\n if (combination === '+') {\n return ['+'];\n }\n\n combination = combination.replace(/\\+{2}/g, '+plus');\n return combination.split('+');\n }\n\n /**\n * Gets info for a specific key combination\n *\n * @param {string} combination key combination (\"command+s\" or \"a\" or \"*\")\n * @param {string=} action\n * @returns {Object}\n */\n function _getKeyInfo(combination, action) {\n var keys;\n var key;\n var i;\n var modifiers = [];\n\n // take the keys from this pattern and figure out what the actual\n // pattern is all about\n keys = _keysFromString(combination);\n\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n\n // normalize key names\n if (_SPECIAL_ALIASES[key]) {\n key = _SPECIAL_ALIASES[key];\n }\n\n // if this is not a keypress event then we should\n // be smart about using shift keys\n // this will only work for US keyboards however\n if (action && action != 'keypress' && _SHIFT_MAP[key]) {\n key = _SHIFT_MAP[key];\n modifiers.push('shift');\n }\n\n // if this key is a modifier then add it to the list of modifiers\n if (_isModifier(key)) {\n modifiers.push(key);\n }\n }\n\n // depending on what the key combination is\n // we will try to pick the best event for it\n action = _pickBestAction(key, modifiers, action);\n\n return {\n key: key,\n modifiers: modifiers,\n action: action\n };\n }\n\n function _belongsTo(element, ancestor) {\n if (element === null || element === document) {\n return false;\n }\n\n if (element === ancestor) {\n return true;\n }\n\n return _belongsTo(element.parentNode, ancestor);\n }\n\n function Mousetrap(targetElement) {\n var self = this;\n\n targetElement = targetElement || document;\n\n if (!(self instanceof Mousetrap)) {\n return new Mousetrap(targetElement);\n }\n\n /**\n * element to attach key events to\n *\n * @type {Element}\n */\n self.target = targetElement;\n\n /**\n * a list of all the callbacks setup via Mousetrap.bind()\n *\n * @type {Object}\n */\n self._callbacks = {};\n\n /**\n * direct map of string combinations to callbacks used for trigger()\n *\n * @type {Object}\n */\n self._directMap = {};\n\n /**\n * keeps track of what level each sequence is at since multiple\n * sequences can start out with the same sequence\n *\n * @type {Object}\n */\n var _sequenceLevels = {};\n\n /**\n * variable to store the setTimeout call\n *\n * @type {null|number}\n */\n var _resetTimer;\n\n /**\n * temporary state where we will ignore the next keyup\n *\n * @type {boolean|string}\n */\n var _ignoreNextKeyup = false;\n\n /**\n * temporary state where we will ignore the next keypress\n *\n * @type {boolean}\n */\n var _ignoreNextKeypress = false;\n\n /**\n * are we currently inside of a sequence?\n * type of action (\"keyup\" or \"keydown\" or \"keypress\") or false\n *\n * @type {boolean|string}\n */\n var _nextExpectedAction = false;\n\n /**\n * resets all sequence counters except for the ones passed in\n *\n * @param {Object} doNotReset\n * @returns void\n */\n function _resetSequences(doNotReset) {\n doNotReset = doNotReset || {};\n\n var activeSequences = false,\n key;\n\n for (key in _sequenceLevels) {\n if (doNotReset[key]) {\n activeSequences = true;\n continue;\n }\n _sequenceLevels[key] = 0;\n }\n\n if (!activeSequences) {\n _nextExpectedAction = false;\n }\n }\n\n /**\n * finds all callbacks that match based on the keycode, modifiers,\n * and action\n *\n * @param {string} character\n * @param {Array} modifiers\n * @param {Event|Object} e\n * @param {string=} sequenceName - name of the sequence we are looking for\n * @param {string=} combination\n * @param {number=} level\n * @returns {Array}\n */\n function _getMatches(character, modifiers, e, sequenceName, combination, level) {\n var i;\n var callback;\n var matches = [];\n var action = e.type;\n\n // if there are no events related to this keycode\n if (!self._callbacks[character]) {\n return [];\n }\n\n // if a modifier key is coming up on its own we should allow it\n if (action == 'keyup' && _isModifier(character)) {\n modifiers = [character];\n }\n\n // loop through all callbacks for the key that was pressed\n // and see if any of them match\n for (i = 0; i < self._callbacks[character].length; ++i) {\n callback = self._callbacks[character][i];\n\n // if a sequence name is not specified, but this is a sequence at\n // the wrong level then move onto the next match\n if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {\n continue;\n }\n\n // if the action we are looking for doesn't match the action we got\n // then we should keep going\n if (action != callback.action) {\n continue;\n }\n\n // if this is a keypress event and the meta key and control key\n // are not pressed that means that we need to only look at the\n // character, otherwise check the modifiers as well\n //\n // chrome will not fire a keypress if meta or control is down\n // safari will fire a keypress if meta or meta+shift is down\n // firefox will fire a keypress if meta or control is down\n if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {\n\n // when you bind a combination or sequence a second time it\n // should overwrite the first one. if a sequenceName or\n // combination is specified in this call it does just that\n //\n // @todo make deleting its own method?\n var deleteCombo = !sequenceName && callback.combo == combination;\n var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;\n if (deleteCombo || deleteSequence) {\n self._callbacks[character].splice(i, 1);\n }\n\n matches.push(callback);\n }\n }\n\n return matches;\n }\n\n /**\n * actually calls the callback function\n *\n * if your callback function returns false this will use the jquery\n * convention - prevent default and stop propogation on the event\n *\n * @param {Function} callback\n * @param {Event} e\n * @returns void\n */\n function _fireCallback(callback, e, combo, sequence) {\n\n // if this event should not happen stop here\n if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {\n return;\n }\n\n if (callback(e, combo) === false) {\n _preventDefault(e);\n _stopPropagation(e);\n }\n }\n\n /**\n * handles a character key event\n *\n * @param {string} character\n * @param {Array} modifiers\n * @param {Event} e\n * @returns void\n */\n self._handleKey = function(character, modifiers, e) {\n var callbacks = _getMatches(character, modifiers, e);\n var i;\n var doNotReset = {};\n var maxLevel = 0;\n var processedSequenceCallback = false;\n\n // Calculate the maxLevel for sequences so we can only execute the longest callback sequence\n for (i = 0; i < callbacks.length; ++i) {\n if (callbacks[i].seq) {\n maxLevel = Math.max(maxLevel, callbacks[i].level);\n }\n }\n\n // loop through matching callbacks for this key event\n for (i = 0; i < callbacks.length; ++i) {\n\n // fire for all sequence callbacks\n // this is because if for example you have multiple sequences\n // bound such as \"g i\" and \"g t\" they both need to fire the\n // callback for matching g cause otherwise you can only ever\n // match the first one\n if (callbacks[i].seq) {\n\n // only fire callbacks for the maxLevel to prevent\n // subsequences from also firing\n //\n // for example 'a option b' should not cause 'option b' to fire\n // even though 'option b' is part of the other sequence\n //\n // any sequences that do not match here will be discarded\n // below by the _resetSequences call\n if (callbacks[i].level != maxLevel) {\n continue;\n }\n\n processedSequenceCallback = true;\n\n // keep a list of which sequences were matches for later\n doNotReset[callbacks[i].seq] = 1;\n _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);\n continue;\n }\n\n // if there were no sequence matches but we are still here\n // that means this is a regular match so we should fire that\n if (!processedSequenceCallback) {\n _fireCallback(callbacks[i].callback, e, callbacks[i].combo);\n }\n }\n\n // if the key you pressed matches the type of sequence without\n // being a modifier (ie \"keyup\" or \"keypress\") then we should\n // reset all sequences that were not matched by this event\n //\n // this is so, for example, if you have the sequence \"h a t\" and you\n // type \"h e a r t\" it does not match. in this case the \"e\" will\n // cause the sequence to reset\n //\n // modifier keys are ignored because you can have a sequence\n // that contains modifiers such as \"enter ctrl+space\" and in most\n // cases the modifier key will be pressed before the next key\n //\n // also if you have a sequence such as \"ctrl+b a\" then pressing the\n // \"b\" key will trigger a \"keypress\" and a \"keydown\"\n //\n // the \"keydown\" is expected when there is a modifier, but the\n // \"keypress\" ends up matching the _nextExpectedAction since it occurs\n // after and that causes the sequence to reset\n //\n // we ignore keypresses in a sequence that directly follow a keydown\n // for the same character\n var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;\n if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {\n _resetSequences(doNotReset);\n }\n\n _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';\n };\n\n /**\n * handles a keydown event\n *\n * @param {Event} e\n * @returns void\n */\n function _handleKeyEvent(e) {\n\n // normalize e.which for key events\n // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion\n if (typeof e.which !== 'number') {\n e.which = e.keyCode;\n }\n\n var character = _characterFromEvent(e);\n\n // no character found then stop\n if (!character) {\n return;\n }\n\n // need to use === for the character check because the character can be 0\n if (e.type == 'keyup' && _ignoreNextKeyup === character) {\n _ignoreNextKeyup = false;\n return;\n }\n\n self.handleKey(character, _eventModifiers(e), e);\n }\n\n /**\n * called to set a 1 second timeout on the specified sequence\n *\n * this is so after each key press in the sequence you have 1 second\n * to press the next key before you have to start over\n *\n * @returns void\n */\n function _resetSequenceTimer() {\n clearTimeout(_resetTimer);\n _resetTimer = setTimeout(_resetSequences, 1000);\n }\n\n /**\n * binds a key sequence to an event\n *\n * @param {string} combo - combo specified in bind call\n * @param {Array} keys\n * @param {Function} callback\n * @param {string=} action\n * @returns void\n */\n function _bindSequence(combo, keys, callback, action) {\n\n // start off by adding a sequence level record for this combination\n // and setting the level to 0\n _sequenceLevels[combo] = 0;\n\n /**\n * callback to increase the sequence level for this sequence and reset\n * all other sequences that were active\n *\n * @param {string} nextAction\n * @returns {Function}\n */\n function _increaseSequence(nextAction) {\n return function() {\n _nextExpectedAction = nextAction;\n ++_sequenceLevels[combo];\n _resetSequenceTimer();\n };\n }\n\n /**\n * wraps the specified callback inside of another function in order\n * to reset all sequence counters as soon as this sequence is done\n *\n * @param {Event} e\n * @returns void\n */\n function _callbackAndReset(e) {\n _fireCallback(callback, e, combo);\n\n // we should ignore the next key up if the action is key down\n // or keypress. this is so if you finish a sequence and\n // release the key the final key will not trigger a keyup\n if (action !== 'keyup') {\n _ignoreNextKeyup = _characterFromEvent(e);\n }\n\n // weird race condition if a sequence ends with the key\n // another sequence begins with\n setTimeout(_resetSequences, 10);\n }\n\n // loop through keys one at a time and bind the appropriate callback\n // function. for any key leading up to the final one it should\n // increase the sequence. after the final, it should reset all sequences\n //\n // if an action is specified in the original bind call then that will\n // be used throughout. otherwise we will pass the action that the\n // next key in the sequence should match. this allows a sequence\n // to mix and match keypress and keydown events depending on which\n // ones are better suited to the key provided\n for (var i = 0; i < keys.length; ++i) {\n var isFinal = i + 1 === keys.length;\n var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);\n _bindSingle(keys[i], wrappedCallback, action, combo, i);\n }\n }\n\n /**\n * binds a single keyboard combination\n *\n * @param {string} combination\n * @param {Function} callback\n * @param {string=} action\n * @param {string=} sequenceName - name of sequence if part of sequence\n * @param {number=} level - what part of the sequence the command is\n * @returns void\n */\n function _bindSingle(combination, callback, action, sequenceName, level) {\n\n // store a direct mapped reference for use with Mousetrap.trigger\n self._directMap[combination + ':' + action] = callback;\n\n // make sure multiple spaces in a row become a single space\n combination = combination.replace(/\\s+/g, ' ');\n\n var sequence = combination.split(' ');\n var info;\n\n // if this pattern is a sequence of keys then run through this method\n // to reprocess each pattern one key at a time\n if (sequence.length > 1) {\n _bindSequence(combination, sequence, callback, action);\n return;\n }\n\n info = _getKeyInfo(combination, action);\n\n // make sure to initialize array if this is the first time\n // a callback is added for this key\n self._callbacks[info.key] = self._callbacks[info.key] || [];\n\n // remove an existing match if there is one\n _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);\n\n // add this call back to the array\n // if it is a sequence put it at the beginning\n // if not put it at the end\n //\n // this is important because the way these are processed expects\n // the sequence ones to come first\n self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({\n callback: callback,\n modifiers: info.modifiers,\n action: info.action,\n seq: sequenceName,\n level: level,\n combo: combination\n });\n }\n\n /**\n * binds multiple combinations to the same callback\n *\n * @param {Array} combinations\n * @param {Function} callback\n * @param {string|undefined} action\n * @returns void\n */\n self._bindMultiple = function(combinations, callback, action) {\n for (var i = 0; i < combinations.length; ++i) {\n _bindSingle(combinations[i], callback, action);\n }\n };\n\n // start!\n _addEvent(targetElement, 'keypress', _handleKeyEvent);\n _addEvent(targetElement, 'keydown', _handleKeyEvent);\n _addEvent(targetElement, 'keyup', _handleKeyEvent);\n }\n\n /**\n * binds an event to mousetrap\n *\n * can be a single key, a combination of keys separated with +,\n * an array of keys, or a sequence of keys separated by spaces\n *\n * be sure to list the modifier keys first to make sure that the\n * correct key ends up getting bound (the last key in the pattern)\n *\n * @param {string|Array} keys\n * @param {Function} callback\n * @param {string=} action - 'keypress', 'keydown', or 'keyup'\n * @returns void\n */\n Mousetrap.prototype.bind = function(keys, callback, action) {\n var self = this;\n keys = keys instanceof Array ? keys : [keys];\n self._bindMultiple.call(self, keys, callback, action);\n return self;\n };\n\n /**\n * unbinds an event to mousetrap\n *\n * the unbinding sets the callback function of the specified key combo\n * to an empty function and deletes the corresponding key in the\n * _directMap dict.\n *\n * TODO: actually remove this from the _callbacks dictionary instead\n * of binding an empty function\n *\n * the keycombo+action has to be exactly the same as\n * it was defined in the bind method\n *\n * @param {string|Array} keys\n * @param {string} action\n * @returns void\n */\n Mousetrap.prototype.unbind = function(keys, action) {\n var self = this;\n return self.bind.call(self, keys, function() {}, action);\n };\n\n /**\n * triggers an event that has already been bound\n *\n * @param {string} keys\n * @param {string=} action\n * @returns void\n */\n Mousetrap.prototype.trigger = function(keys, action) {\n var self = this;\n if (self._directMap[keys + ':' + action]) {\n self._directMap[keys + ':' + action]({}, keys);\n }\n return self;\n };\n\n /**\n * resets the library back to its initial state. this is useful\n * if you want to clear out the current keyboard shortcuts and bind\n * new ones - for example if you switch to another page\n *\n * @returns void\n */\n Mousetrap.prototype.reset = function() {\n var self = this;\n self._callbacks = {};\n self._directMap = {};\n return self;\n };\n\n /**\n * should we stop this event before firing off callbacks\n *\n * @param {Event} e\n * @param {Element} element\n * @return {boolean}\n */\n Mousetrap.prototype.stopCallback = function(e, element) {\n var self = this;\n\n // if the element has the class \"mousetrap\" then no need to stop\n if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {\n return false;\n }\n\n if (_belongsTo(element, self.target)) {\n return false;\n }\n\n // stop for input, select, and textarea\n return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;\n };\n\n /**\n * exposes _handleKey publicly so it can be overwritten by extensions\n */\n Mousetrap.prototype.handleKey = function() {\n var self = this;\n return self._handleKey.apply(self, arguments);\n };\n\n /**\n * allow custom key mappings\n */\n Mousetrap.addKeycodes = function(object) {\n for (var key in object) {\n if (object.hasOwnProperty(key)) {\n _MAP[key] = object[key];\n }\n }\n _REVERSE_MAP = null;\n };\n\n /**\n * Init the global mousetrap functions\n *\n * This method is needed to allow the global mousetrap functions to work\n * now that mousetrap is a constructor function.\n */\n Mousetrap.init = function() {\n var documentMousetrap = Mousetrap(document);\n for (var method in documentMousetrap) {\n if (method.charAt(0) !== '_') {\n Mousetrap[method] = (function(method) {\n return function() {\n return documentMousetrap[method].apply(documentMousetrap, arguments);\n };\n } (method));\n }\n }\n };\n\n Mousetrap.init();\n\n // expose mousetrap to the global object\n window.Mousetrap = Mousetrap;\n\n // expose as a common js module\n if (typeof module !== 'undefined' && module.exports) {\n module.exports = Mousetrap;\n }\n\n // expose mousetrap as an AMD module\n if (typeof define === 'function' && define.amd) {\n define(function() {\n return Mousetrap;\n });\n }\n}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/mousetrap/mousetrap.js\n// module id = 25\n// module chunks = 0","\"use strict\";\nvar isWebSocket = function (constructor) {\n return constructor && constructor.CLOSING === 2;\n};\nvar isGlobalWebSocket = function () {\n return typeof WebSocket !== 'undefined' && isWebSocket(WebSocket);\n};\nvar getDefaultOptions = function () { return ({\n constructor: isGlobalWebSocket() ? WebSocket : null,\n maxReconnectionDelay: 10000,\n minReconnectionDelay: 1500,\n reconnectionDelayGrowFactor: 1.3,\n connectionTimeout: 4000,\n maxRetries: Infinity,\n debug: false,\n}); };\nvar bypassProperty = function (src, dst, name) {\n Object.defineProperty(dst, name, {\n get: function () { return src[name]; },\n set: function (value) { src[name] = value; },\n enumerable: true,\n configurable: true,\n });\n};\nvar initReconnectionDelay = function (config) {\n return (config.minReconnectionDelay + Math.random() * config.minReconnectionDelay);\n};\nvar updateReconnectionDelay = function (config, previousDelay) {\n var newDelay = previousDelay * config.reconnectionDelayGrowFactor;\n return (newDelay > config.maxReconnectionDelay)\n ? config.maxReconnectionDelay\n : newDelay;\n};\nvar LEVEL_0_EVENTS = ['onopen', 'onclose', 'onmessage', 'onerror'];\nvar reassignEventListeners = function (ws, oldWs, listeners) {\n Object.keys(listeners).forEach(function (type) {\n listeners[type].forEach(function (_a) {\n var listener = _a[0], options = _a[1];\n ws.addEventListener(type, listener, options);\n });\n });\n if (oldWs) {\n LEVEL_0_EVENTS.forEach(function (name) { ws[name] = oldWs[name]; });\n }\n};\nvar ReconnectingWebsocket = function (url, protocols, options) {\n var _this = this;\n if (options === void 0) { options = {}; }\n var ws;\n var connectingTimeout;\n var reconnectDelay = 0;\n var retriesCount = 0;\n var shouldRetry = true;\n var savedOnClose = null;\n var listeners = {};\n // require new to construct\n if (!(this instanceof ReconnectingWebsocket)) {\n throw new TypeError(\"Failed to construct 'ReconnectingWebSocket': Please use the 'new' operator\");\n }\n // Set config. Not using `Object.assign` because of IE11\n var config = getDefaultOptions();\n Object.keys(config)\n .filter(function (key) { return options.hasOwnProperty(key); })\n .forEach(function (key) { return config[key] = options[key]; });\n if (!isWebSocket(config.constructor)) {\n throw new TypeError('Invalid WebSocket constructor. Set `options.constructor`');\n }\n var log = config.debug ? function () {\n var params = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n params[_i - 0] = arguments[_i];\n }\n return console.log.apply(console, ['RWS:'].concat(params));\n } : function () { };\n /**\n * Not using dispatchEvent, otherwise we must use a DOM Event object\n * Deferred because we want to handle the close event before this\n */\n var emitError = function (code, msg) { return setTimeout(function () {\n var err = new Error(msg);\n err.code = code;\n if (Array.isArray(listeners.error)) {\n listeners.error.forEach(function (_a) {\n var fn = _a[0];\n return fn(err);\n });\n }\n if (ws.onerror) {\n ws.onerror(err);\n }\n }, 0); };\n var handleClose = function () {\n log('close');\n retriesCount++;\n log('retries count:', retriesCount);\n if (retriesCount > config.maxRetries) {\n emitError('EHOSTDOWN', 'Too many failed connection attempts');\n return;\n }\n if (!reconnectDelay) {\n reconnectDelay = initReconnectionDelay(config);\n }\n else {\n reconnectDelay = updateReconnectionDelay(config, reconnectDelay);\n }\n log('reconnectDelay:', reconnectDelay);\n if (shouldRetry) {\n setTimeout(connect, reconnectDelay);\n }\n };\n var connect = function () {\n log('connect');\n var oldWs = ws;\n ws = new config.constructor(url, protocols);\n connectingTimeout = setTimeout(function () {\n log('timeout');\n ws.close();\n emitError('ETIMEDOUT', 'Connection timeout');\n }, config.connectionTimeout);\n log('bypass properties');\n for (var key in ws) {\n // @todo move to constant\n if (['addEventListener', 'removeEventListener', 'close', 'send'].indexOf(key) < 0) {\n bypassProperty(ws, _this, key);\n }\n }\n ws.addEventListener('open', function () {\n clearTimeout(connectingTimeout);\n log('open');\n reconnectDelay = initReconnectionDelay(config);\n log('reconnectDelay:', reconnectDelay);\n retriesCount = 0;\n });\n ws.addEventListener('close', handleClose);\n reassignEventListeners(ws, oldWs, listeners);\n // because when closing with fastClose=true, it is saved and set to null to avoid double calls\n ws.onclose = ws.onclose || savedOnClose;\n savedOnClose = null;\n };\n log('init');\n connect();\n this.close = function (code, reason, _a) {\n if (code === void 0) { code = 1000; }\n if (reason === void 0) { reason = ''; }\n var _b = _a === void 0 ? {} : _a, _c = _b.keepClosed, keepClosed = _c === void 0 ? false : _c, _d = _b.fastClose, fastClose = _d === void 0 ? true : _d, _e = _b.delay, delay = _e === void 0 ? 0 : _e;\n if (delay) {\n reconnectDelay = delay;\n }\n shouldRetry = !keepClosed;\n ws.close(code, reason);\n if (fastClose) {\n var fakeCloseEvent_1 = {\n code: code,\n reason: reason,\n wasClean: true,\n };\n // execute close listeners soon with a fake closeEvent\n // and remove them from the WS instance so they\n // don't get fired on the real close.\n handleClose();\n ws.removeEventListener('close', handleClose);\n // run and remove level2\n if (Array.isArray(listeners.close)) {\n listeners.close.forEach(function (_a) {\n var listener = _a[0], options = _a[1];\n listener(fakeCloseEvent_1);\n ws.removeEventListener('close', listener, options);\n });\n }\n // run and remove level0\n if (ws.onclose) {\n savedOnClose = ws.onclose;\n ws.onclose(fakeCloseEvent_1);\n ws.onclose = null;\n }\n }\n };\n this.send = function (data) {\n ws.send(data);\n };\n this.addEventListener = function (type, listener, options) {\n if (Array.isArray(listeners[type])) {\n if (!listeners[type].some(function (_a) {\n var l = _a[0];\n return l === listener;\n })) {\n listeners[type].push([listener, options]);\n }\n }\n else {\n listeners[type] = [[listener, options]];\n }\n ws.addEventListener(type, listener, options);\n };\n this.removeEventListener = function (type, listener, options) {\n if (Array.isArray(listeners[type])) {\n listeners[type] = listeners[type].filter(function (_a) {\n var l = _a[0];\n return l !== listener;\n });\n }\n ws.removeEventListener(type, listener, options);\n };\n};\nmodule.exports = ReconnectingWebsocket;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/reconnecting-websocket/dist/index.js\n// module id = 26\n// module chunks = 0","module.exports = jQuery;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"jQuery\"\n// module id = 27\n// module chunks = 0","(function(exports) {\n\n // Complementary error function\n // From Numerical Recipes in C 2e p221\n var erfc = function(x) {\n var z = Math.abs(x);\n var t = 1 / (1 + z / 2);\n var r = t * Math.exp(-z * z - 1.26551223 + t * (1.00002368 +\n t * (0.37409196 + t * (0.09678418 + t * (-0.18628806 +\n t * (0.27886807 + t * (-1.13520398 + t * (1.48851587 +\n t * (-0.82215223 + t * 0.17087277)))))))))\n return x >= 0 ? r : 2 - r;\n };\n\n // Inverse complementary error function\n // From Numerical Recipes 3e p265\n var ierfc = function(x) {\n if (x >= 2) { return -100; }\n if (x <= 0) { return 100; }\n\n var xx = (x < 1) ? x : 2 - x;\n var t = Math.sqrt(-2 * Math.log(xx / 2));\n\n var r = -0.70711 * ((2.30753 + t * 0.27061) /\n (1 + t * (0.99229 + t * 0.04481)) - t);\n\n for (var j = 0; j < 2; j++) {\n var err = erfc(r) - xx;\n r += err / (1.12837916709551257 * Math.exp(-(r * r)) - r * err);\n }\n\n return (x < 1) ? r : -r;\n };\n\n // Models the normal distribution\n var Gaussian = function(mean, variance) {\n if (variance <= 0) {\n throw new Error('Variance must be > 0 (but was ' + variance + ')');\n }\n this.mean = mean;\n this.variance = variance;\n this.standardDeviation = Math.sqrt(variance);\n }\n\n // Probability density function\n Gaussian.prototype.pdf = function(x) {\n var m = this.standardDeviation * Math.sqrt(2 * Math.PI);\n var e = Math.exp(-Math.pow(x - this.mean, 2) / (2 * this.variance));\n return e / m;\n };\n\n // Cumulative density function\n Gaussian.prototype.cdf = function(x) {\n return 0.5 * erfc(-(x - this.mean) / (this.standardDeviation * Math.sqrt(2)));\n };\n\n // Percent point function\n Gaussian.prototype.ppf = function(x) {\n return this.mean - this.standardDeviation * Math.sqrt(2) * ierfc(2 * x);\n };\n\n // Product distribution of this and d (scale for constant)\n Gaussian.prototype.mul = function(d) {\n if (typeof(d) === \"number\") {\n return this.scale(d);\n }\n var precision = 1 / this.variance;\n var dprecision = 1 / d.variance;\n return fromPrecisionMean(\n precision + dprecision, \n precision * this.mean + dprecision * d.mean);\n };\n\n // Quotient distribution of this and d (scale for constant)\n Gaussian.prototype.div = function(d) {\n if (typeof(d) === \"number\") {\n return this.scale(1 / d);\n }\n var precision = 1 / this.variance;\n var dprecision = 1 / d.variance;\n return fromPrecisionMean(\n precision - dprecision, \n precision * this.mean - dprecision * d.mean);\n };\n\n // Addition of this and d\n Gaussian.prototype.add = function(d) {\n return gaussian(this.mean + d.mean, this.variance + d.variance);\n };\n\n // Subtraction of this and d\n Gaussian.prototype.sub = function(d) {\n return gaussian(this.mean - d.mean, this.variance + d.variance);\n };\n\n // Scale this by constant c\n Gaussian.prototype.scale = function(c) {\n return gaussian(this.mean * c, this.variance * c * c);\n };\n\n var gaussian = function(mean, variance) {\n return new Gaussian(mean, variance);\n };\n\n var fromPrecisionMean = function(precision, precisionmean) {\n return gaussian(precisionmean / precision, 1 / precision);\n };\n\n exports(gaussian);\n})\n(typeof(exports) !== \"undefined\"\n ? function(e) { module.exports = e; }\n : function(e) { this[\"gaussian\"] = e; });\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/gaussian/lib/gaussian.js\n// module id = 28\n// module chunks = 0","'use strict';\n\nvar colorString = require('color-string');\nvar convert = require('color-convert');\n\nvar _slice = [].slice;\n\nvar skippedModels = [\n\t// to be honest, I don't really feel like keyword belongs in color convert, but eh.\n\t'keyword',\n\n\t// gray conflicts with some method names, and has its own method defined.\n\t'gray',\n\n\t// shouldn't really be in color-convert either...\n\t'hex'\n];\n\nvar hashedModelKeys = {};\nObject.keys(convert).forEach(function (model) {\n\thashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model;\n});\n\nvar limiters = {};\n\nfunction Color(obj, model) {\n\tif (!(this instanceof Color)) {\n\t\treturn new Color(obj, model);\n\t}\n\n\tif (model && model in skippedModels) {\n\t\tmodel = null;\n\t}\n\n\tif (model && !(model in convert)) {\n\t\tthrow new Error('Unknown model: ' + model);\n\t}\n\n\tvar i;\n\tvar channels;\n\n\tif (!obj) {\n\t\tthis.model = 'rgb';\n\t\tthis.color = [0, 0, 0];\n\t\tthis.valpha = 1;\n\t} else if (obj instanceof Color) {\n\t\tthis.model = obj.model;\n\t\tthis.color = obj.color.slice();\n\t\tthis.valpha = obj.valpha;\n\t} else if (typeof obj === 'string') {\n\t\tvar result = colorString.get(obj);\n\t\tif (result === null) {\n\t\t\tthrow new Error('Unable to parse color from string: ' + obj);\n\t\t}\n\n\t\tthis.model = result.model;\n\t\tchannels = convert[this.model].channels;\n\t\tthis.color = result.value.slice(0, channels);\n\t\tthis.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;\n\t} else if (obj.length) {\n\t\tthis.model = model || 'rgb';\n\t\tchannels = convert[this.model].channels;\n\t\tvar newArr = _slice.call(obj, 0, channels);\n\t\tthis.color = zeroArray(newArr, channels);\n\t\tthis.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;\n\t} else if (typeof obj === 'number') {\n\t\t// this is always RGB - can be converted later on.\n\t\tobj &= 0xFFFFFF;\n\t\tthis.model = 'rgb';\n\t\tthis.color = [\n\t\t\t(obj >> 16) & 0xFF,\n\t\t\t(obj >> 8) & 0xFF,\n\t\t\tobj & 0xFF\n\t\t];\n\t\tthis.valpha = 1;\n\t} else {\n\t\tthis.valpha = 1;\n\n\t\tvar keys = Object.keys(obj);\n\t\tif ('alpha' in obj) {\n\t\t\tkeys.splice(keys.indexOf('alpha'), 1);\n\t\t\tthis.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;\n\t\t}\n\n\t\tvar hashedKeys = keys.sort().join('');\n\t\tif (!(hashedKeys in hashedModelKeys)) {\n\t\t\tthrow new Error('Unable to parse color from object: ' + JSON.stringify(obj));\n\t\t}\n\n\t\tthis.model = hashedModelKeys[hashedKeys];\n\n\t\tvar labels = convert[this.model].labels;\n\t\tvar color = [];\n\t\tfor (i = 0; i < labels.length; i++) {\n\t\t\tcolor.push(obj[labels[i]]);\n\t\t}\n\n\t\tthis.color = zeroArray(color);\n\t}\n\n\t// perform limitations (clamping, etc.)\n\tif (limiters[this.model]) {\n\t\tchannels = convert[this.model].channels;\n\t\tfor (i = 0; i < channels; i++) {\n\t\t\tvar limit = limiters[this.model][i];\n\t\t\tif (limit) {\n\t\t\t\tthis.color[i] = limit(this.color[i]);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.valpha = Math.max(0, Math.min(1, this.valpha));\n\n\tif (Object.freeze) {\n\t\tObject.freeze(this);\n\t}\n}\n\nColor.prototype = {\n\ttoString: function () {\n\t\treturn this.string();\n\t},\n\n\ttoJSON: function () {\n\t\treturn this[this.model]();\n\t},\n\n\tstring: function (places) {\n\t\tvar self = this.model in colorString.to ? this : this.rgb();\n\t\tself = self.round(typeof places === 'number' ? places : 1);\n\t\tvar args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);\n\t\treturn colorString.to[self.model](args);\n\t},\n\n\tpercentString: function (places) {\n\t\tvar self = this.rgb().round(typeof places === 'number' ? places : 1);\n\t\tvar args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);\n\t\treturn colorString.to.rgb.percent(args);\n\t},\n\n\tarray: function () {\n\t\treturn this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);\n\t},\n\n\tobject: function () {\n\t\tvar result = {};\n\t\tvar channels = convert[this.model].channels;\n\t\tvar labels = convert[this.model].labels;\n\n\t\tfor (var i = 0; i < channels; i++) {\n\t\t\tresult[labels[i]] = this.color[i];\n\t\t}\n\n\t\tif (this.valpha !== 1) {\n\t\t\tresult.alpha = this.valpha;\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tunitArray: function () {\n\t\tvar rgb = this.rgb().color;\n\t\trgb[0] /= 255;\n\t\trgb[1] /= 255;\n\t\trgb[2] /= 255;\n\n\t\tif (this.valpha !== 1) {\n\t\t\trgb.push(this.valpha);\n\t\t}\n\n\t\treturn rgb;\n\t},\n\n\tunitObject: function () {\n\t\tvar rgb = this.rgb().object();\n\t\trgb.r /= 255;\n\t\trgb.g /= 255;\n\t\trgb.b /= 255;\n\n\t\tif (this.valpha !== 1) {\n\t\t\trgb.alpha = this.valpha;\n\t\t}\n\n\t\treturn rgb;\n\t},\n\n\tround: function (places) {\n\t\tplaces = Math.max(places || 0, 0);\n\t\treturn new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);\n\t},\n\n\talpha: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);\n\t\t}\n\n\t\treturn this.valpha;\n\t},\n\n\t// rgb\n\tred: getset('rgb', 0, maxfn(255)),\n\tgreen: getset('rgb', 1, maxfn(255)),\n\tblue: getset('rgb', 2, maxfn(255)),\n\n\thue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style\n\n\tsaturationl: getset('hsl', 1, maxfn(100)),\n\tlightness: getset('hsl', 2, maxfn(100)),\n\n\tsaturationv: getset('hsv', 1, maxfn(100)),\n\tvalue: getset('hsv', 2, maxfn(100)),\n\n\tchroma: getset('hcg', 1, maxfn(100)),\n\tgray: getset('hcg', 2, maxfn(100)),\n\n\twhite: getset('hwb', 1, maxfn(100)),\n\twblack: getset('hwb', 2, maxfn(100)),\n\n\tcyan: getset('cmyk', 0, maxfn(100)),\n\tmagenta: getset('cmyk', 1, maxfn(100)),\n\tyellow: getset('cmyk', 2, maxfn(100)),\n\tblack: getset('cmyk', 3, maxfn(100)),\n\n\tx: getset('xyz', 0, maxfn(100)),\n\ty: getset('xyz', 1, maxfn(100)),\n\tz: getset('xyz', 2, maxfn(100)),\n\n\tl: getset('lab', 0, maxfn(100)),\n\ta: getset('lab', 1),\n\tb: getset('lab', 2),\n\n\tkeyword: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(val);\n\t\t}\n\n\t\treturn convert[this.model].keyword(this.color);\n\t},\n\n\thex: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(val);\n\t\t}\n\n\t\treturn colorString.to.hex(this.rgb().round().color);\n\t},\n\n\trgbNumber: function () {\n\t\tvar rgb = this.rgb().color;\n\t\treturn ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);\n\t},\n\n\tluminosity: function () {\n\t\t// http://www.w3.org/TR/WCAG20/#relativeluminancedef\n\t\tvar rgb = this.rgb().color;\n\n\t\tvar lum = [];\n\t\tfor (var i = 0; i < rgb.length; i++) {\n\t\t\tvar chan = rgb[i] / 255;\n\t\t\tlum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);\n\t\t}\n\n\t\treturn 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];\n\t},\n\n\tcontrast: function (color2) {\n\t\t// http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n\t\tvar lum1 = this.luminosity();\n\t\tvar lum2 = color2.luminosity();\n\n\t\tif (lum1 > lum2) {\n\t\t\treturn (lum1 + 0.05) / (lum2 + 0.05);\n\t\t}\n\n\t\treturn (lum2 + 0.05) / (lum1 + 0.05);\n\t},\n\n\tlevel: function (color2) {\n\t\tvar contrastRatio = this.contrast(color2);\n\t\tif (contrastRatio >= 7.1) {\n\t\t\treturn 'AAA';\n\t\t}\n\n\t\treturn (contrastRatio >= 4.5) ? 'AA' : '';\n\t},\n\n\tdark: function () {\n\t\t// YIQ equation from http://24ways.org/2010/calculating-color-contrast\n\t\tvar rgb = this.rgb().color;\n\t\tvar yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;\n\t\treturn yiq < 128;\n\t},\n\n\tlight: function () {\n\t\treturn !this.dark();\n\t},\n\n\tnegate: function () {\n\t\tvar rgb = this.rgb();\n\t\tfor (var i = 0; i < 3; i++) {\n\t\t\trgb.color[i] = 255 - rgb.color[i];\n\t\t}\n\t\treturn rgb;\n\t},\n\n\tlighten: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[2] += hsl.color[2] * ratio;\n\t\treturn hsl;\n\t},\n\n\tdarken: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[2] -= hsl.color[2] * ratio;\n\t\treturn hsl;\n\t},\n\n\tsaturate: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[1] += hsl.color[1] * ratio;\n\t\treturn hsl;\n\t},\n\n\tdesaturate: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[1] -= hsl.color[1] * ratio;\n\t\treturn hsl;\n\t},\n\n\twhiten: function (ratio) {\n\t\tvar hwb = this.hwb();\n\t\thwb.color[1] += hwb.color[1] * ratio;\n\t\treturn hwb;\n\t},\n\n\tblacken: function (ratio) {\n\t\tvar hwb = this.hwb();\n\t\thwb.color[2] += hwb.color[2] * ratio;\n\t\treturn hwb;\n\t},\n\n\tgrayscale: function () {\n\t\t// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale\n\t\tvar rgb = this.rgb().color;\n\t\tvar val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;\n\t\treturn Color.rgb(val, val, val);\n\t},\n\n\tfade: function (ratio) {\n\t\treturn this.alpha(this.valpha - (this.valpha * ratio));\n\t},\n\n\topaquer: function (ratio) {\n\t\treturn this.alpha(this.valpha + (this.valpha * ratio));\n\t},\n\n\trotate: function (degrees) {\n\t\tvar hsl = this.hsl();\n\t\tvar hue = hsl.color[0];\n\t\thue = (hue + degrees) % 360;\n\t\thue = hue < 0 ? 360 + hue : hue;\n\t\thsl.color[0] = hue;\n\t\treturn hsl;\n\t},\n\n\tmix: function (mixinColor, weight) {\n\t\t// ported from sass implementation in C\n\t\t// https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209\n\t\tvar color1 = mixinColor.rgb();\n\t\tvar color2 = this.rgb();\n\t\tvar p = weight === undefined ? 0.5 : weight;\n\n\t\tvar w = 2 * p - 1;\n\t\tvar a = color1.alpha() - color2.alpha();\n\n\t\tvar w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n\t\tvar w2 = 1 - w1;\n\n\t\treturn Color.rgb(\n\t\t\t\tw1 * color1.red() + w2 * color2.red(),\n\t\t\t\tw1 * color1.green() + w2 * color2.green(),\n\t\t\t\tw1 * color1.blue() + w2 * color2.blue(),\n\t\t\t\tcolor1.alpha() * p + color2.alpha() * (1 - p));\n\t}\n};\n\n// model conversion methods and static constructors\nObject.keys(convert).forEach(function (model) {\n\tif (skippedModels.indexOf(model) !== -1) {\n\t\treturn;\n\t}\n\n\tvar channels = convert[model].channels;\n\n\t// conversion methods\n\tColor.prototype[model] = function () {\n\t\tif (this.model === model) {\n\t\t\treturn new Color(this);\n\t\t}\n\n\t\tif (arguments.length) {\n\t\t\treturn new Color(arguments, model);\n\t\t}\n\n\t\tvar newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;\n\t\treturn new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);\n\t};\n\n\t// 'static' construction methods\n\tColor[model] = function (color) {\n\t\tif (typeof color === 'number') {\n\t\t\tcolor = zeroArray(_slice.call(arguments), channels);\n\t\t}\n\t\treturn new Color(color, model);\n\t};\n});\n\nfunction roundTo(num, places) {\n\treturn Number(num.toFixed(places));\n}\n\nfunction roundToPlace(places) {\n\treturn function (num) {\n\t\treturn roundTo(num, places);\n\t};\n}\n\nfunction getset(model, channel, modifier) {\n\tmodel = Array.isArray(model) ? model : [model];\n\n\tmodel.forEach(function (m) {\n\t\t(limiters[m] || (limiters[m] = []))[channel] = modifier;\n\t});\n\n\tmodel = model[0];\n\n\treturn function (val) {\n\t\tvar result;\n\n\t\tif (arguments.length) {\n\t\t\tif (modifier) {\n\t\t\t\tval = modifier(val);\n\t\t\t}\n\n\t\t\tresult = this[model]();\n\t\t\tresult.color[channel] = val;\n\t\t\treturn result;\n\t\t}\n\n\t\tresult = this[model]().color[channel];\n\t\tif (modifier) {\n\t\t\tresult = modifier(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction maxfn(max) {\n\treturn function (v) {\n\t\treturn Math.max(0, Math.min(max, v));\n\t};\n}\n\nfunction assertArray(val) {\n\treturn Array.isArray(val) ? val : [val];\n}\n\nfunction zeroArray(arr, length) {\n\tfor (var i = 0; i < length; i++) {\n\t\tif (typeof arr[i] !== 'number') {\n\t\t\tarr[i] = 0;\n\t\t}\n\t}\n\n\treturn arr;\n}\n\nmodule.exports = Color;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/color/index.js\n// module id = 29\n// module chunks = 0","/* MIT license */\nvar colorNames = require('color-name');\nvar swizzle = require('simple-swizzle');\n\nvar reverseNames = {};\n\n// create a list of reverse color names\nfor (var name in colorNames) {\n\tif (colorNames.hasOwnProperty(name)) {\n\t\treverseNames[colorNames[name]] = name;\n\t}\n}\n\nvar cs = module.exports = {\n\tto: {}\n};\n\ncs.get = function (string) {\n\tvar prefix = string.substring(0, 3).toLowerCase();\n\tvar val;\n\tvar model;\n\tswitch (prefix) {\n\t\tcase 'hsl':\n\t\t\tval = cs.get.hsl(string);\n\t\t\tmodel = 'hsl';\n\t\t\tbreak;\n\t\tcase 'hwb':\n\t\t\tval = cs.get.hwb(string);\n\t\t\tmodel = 'hwb';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tval = cs.get.rgb(string);\n\t\t\tmodel = 'rgb';\n\t\t\tbreak;\n\t}\n\n\tif (!val) {\n\t\treturn null;\n\t}\n\n\treturn {model: model, value: val};\n};\n\ncs.get.rgb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar abbr = /^#([a-f0-9]{3,4})$/i;\n\tvar hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;\n\tvar rgba = /^rgba?\\(\\s*([+-]?\\d+)\\s*,\\s*([+-]?\\d+)\\s*,\\s*([+-]?\\d+)\\s*(?:,\\s*([+-]?[\\d\\.]+)\\s*)?\\)$/;\n\tvar per = /^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,\\s*([+-]?[\\d\\.]+)\\%\\s*,\\s*([+-]?[\\d\\.]+)\\%\\s*(?:,\\s*([+-]?[\\d\\.]+)\\s*)?\\)$/;\n\tvar keyword = /(\\D+)/;\n\n\tvar rgb = [0, 0, 0, 1];\n\tvar match;\n\tvar i;\n\tvar hexAlpha;\n\n\tif (match = string.match(hex)) {\n\t\thexAlpha = match[2];\n\t\tmatch = match[1];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\t// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19\n\t\t\tvar i2 = i * 2;\n\t\t\trgb[i] = parseInt(match.slice(i2, i2 + 2), 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100;\n\t\t}\n\t} else if (match = string.match(abbr)) {\n\t\tmatch = match[1];\n\t\thexAlpha = match[3];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i] + match[i], 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100;\n\t\t}\n\t} else if (match = string.match(rgba)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i + 1], 0);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\trgb[3] = parseFloat(match[4]);\n\t\t}\n\t} else if (match = string.match(per)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\trgb[3] = parseFloat(match[4]);\n\t\t}\n\t} else if (match = string.match(keyword)) {\n\t\tif (match[1] === 'transparent') {\n\t\t\treturn [0, 0, 0, 0];\n\t\t}\n\n\t\trgb = colorNames[match[1]];\n\n\t\tif (!rgb) {\n\t\t\treturn null;\n\t\t}\n\n\t\trgb[3] = 1;\n\n\t\treturn rgb;\n\t} else {\n\t\treturn null;\n\t}\n\n\tfor (i = 0; i < 3; i++) {\n\t\trgb[i] = clamp(rgb[i], 0, 255);\n\t}\n\trgb[3] = clamp(rgb[3], 0, 1);\n\n\treturn rgb;\n};\n\ncs.get.hsl = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hsl = /^hsla?\\(\\s*([+-]?\\d*[\\.]?\\d+)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?[\\d\\.]+)\\s*)?\\)$/;\n\tvar match = string.match(hsl);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar s = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar l = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\n\t\treturn [h, s, l, a];\n\t}\n\n\treturn null;\n};\n\ncs.get.hwb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hwb = /^hwb\\(\\s*([+-]?\\d*[\\.]?\\d+)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?[\\d\\.]+)\\s*)?\\)$/;\n\tvar match = string.match(hwb);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar w = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar b = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\t\treturn [h, w, b, a];\n\t}\n\n\treturn null;\n};\n\ncs.to.hex = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn (\n\t\t'#' +\n\t\thexDouble(rgba[0]) +\n\t\thexDouble(rgba[1]) +\n\t\thexDouble(rgba[2]) +\n\t\t(rgba[3] < 1\n\t\t\t? (hexDouble(Math.round(rgba[3] * 255)))\n\t\t\t: '')\n\t);\n};\n\ncs.to.rgb = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'\n\t\t: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';\n};\n\ncs.to.rgb.percent = function () {\n\tvar rgba = swizzle(arguments);\n\n\tvar r = Math.round(rgba[0] / 255 * 100);\n\tvar g = Math.round(rgba[1] / 255 * 100);\n\tvar b = Math.round(rgba[2] / 255 * 100);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'\n\t\t: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';\n};\n\ncs.to.hsl = function () {\n\tvar hsla = swizzle(arguments);\n\treturn hsla.length < 4 || hsla[3] === 1\n\t\t? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'\n\t\t: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';\n};\n\n// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax\n// (hwb have alpha optional & 1 is default value)\ncs.to.hwb = function () {\n\tvar hwba = swizzle(arguments);\n\n\tvar a = '';\n\tif (hwba.length >= 4 && hwba[3] !== 1) {\n\t\ta = ', ' + hwba[3];\n\t}\n\n\treturn 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';\n};\n\ncs.to.keyword = function (rgb) {\n\treturn reverseNames[rgb.slice(0, 3)];\n};\n\n// helpers\nfunction clamp(num, min, max) {\n\treturn Math.min(Math.max(min, num), max);\n}\n\nfunction hexDouble(num) {\n\tvar str = num.toString(16).toUpperCase();\n\treturn (str.length < 2) ? '0' + str : str;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/color-string/index.js\n// module id = 30\n// module chunks = 0","'use strict';\n\nvar isArrayish = require('is-arrayish');\n\nvar concat = Array.prototype.concat;\nvar slice = Array.prototype.slice;\n\nvar swizzle = module.exports = function swizzle(args) {\n\tvar results = [];\n\n\tfor (var i = 0, len = args.length; i < len; i++) {\n\t\tvar arg = args[i];\n\n\t\tif (isArrayish(arg)) {\n\t\t\t// http://jsperf.com/javascript-array-concat-vs-push/98\n\t\t\tresults = concat.call(results, slice.call(arg));\n\t\t} else {\n\t\t\tresults.push(arg);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nswizzle.wrap = function (fn) {\n\treturn function () {\n\t\treturn fn(swizzle(arguments));\n\t};\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/simple-swizzle/index.js\n// module id = 31\n// module chunks = 0","'use strict';\n\nmodule.exports = function isArrayish(obj) {\n\tif (!obj || typeof obj === 'string') {\n\t\treturn false;\n\t}\n\n\treturn obj instanceof Array || Array.isArray(obj) ||\n\t\t(obj.length >= 0 && (obj.splice instanceof Function ||\n\t\t\t(Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/is-arrayish/index.js\n// module id = 32\n// module chunks = 0","var conversions = require('./conversions');\nvar route = require('./route');\n\nvar convert = {};\n\nvar models = Object.keys(conversions);\n\nfunction wrapRaw(fn) {\n\tvar wrappedFn = function (args) {\n\t\tif (args === undefined || args === null) {\n\t\t\treturn args;\n\t\t}\n\n\t\tif (arguments.length > 1) {\n\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t}\n\n\t\treturn fn(args);\n\t};\n\n\t// preserve .conversion property if there is one\n\tif ('conversion' in fn) {\n\t\twrappedFn.conversion = fn.conversion;\n\t}\n\n\treturn wrappedFn;\n}\n\nfunction wrapRounded(fn) {\n\tvar wrappedFn = function (args) {\n\t\tif (args === undefined || args === null) {\n\t\t\treturn args;\n\t\t}\n\n\t\tif (arguments.length > 1) {\n\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t}\n\n\t\tvar result = fn(args);\n\n\t\t// we're assuming the result is an array here.\n\t\t// see notice in conversions.js; don't use box types\n\t\t// in conversion functions.\n\t\tif (typeof result === 'object') {\n\t\t\tfor (var len = result.length, i = 0; i < len; i++) {\n\t\t\t\tresult[i] = Math.round(result[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// preserve .conversion property if there is one\n\tif ('conversion' in fn) {\n\t\twrappedFn.conversion = fn.conversion;\n\t}\n\n\treturn wrappedFn;\n}\n\nmodels.forEach(function (fromModel) {\n\tconvert[fromModel] = {};\n\n\tObject.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});\n\tObject.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});\n\n\tvar routes = route(fromModel);\n\tvar routeModels = Object.keys(routes);\n\n\trouteModels.forEach(function (toModel) {\n\t\tvar fn = routes[toModel];\n\n\t\tconvert[fromModel][toModel] = wrapRounded(fn);\n\t\tconvert[fromModel][toModel].raw = wrapRaw(fn);\n\t});\n});\n\nmodule.exports = convert;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/color-convert/index.js\n// module id = 33\n// module chunks = 0","var conversions = require('./conversions');\n\n/*\n\tthis function routes a model to all other models.\n\n\tall functions that are routed have a property `.conversion` attached\n\tto the returned synthetic function. This property is an array\n\tof strings, each with the steps in between the 'from' and 'to'\n\tcolor models (inclusive).\n\n\tconversions that are not possible simply are not included.\n*/\n\n// https://jsperf.com/object-keys-vs-for-in-with-closure/3\nvar models = Object.keys(conversions);\n\nfunction buildGraph() {\n\tvar graph = {};\n\n\tfor (var len = models.length, i = 0; i < len; i++) {\n\t\tgraph[models[i]] = {\n\t\t\t// http://jsperf.com/1-vs-infinity\n\t\t\t// micro-opt, but this is simple.\n\t\t\tdistance: -1,\n\t\t\tparent: null\n\t\t};\n\t}\n\n\treturn graph;\n}\n\n// https://en.wikipedia.org/wiki/Breadth-first_search\nfunction deriveBFS(fromModel) {\n\tvar graph = buildGraph();\n\tvar queue = [fromModel]; // unshift -> queue -> pop\n\n\tgraph[fromModel].distance = 0;\n\n\twhile (queue.length) {\n\t\tvar current = queue.pop();\n\t\tvar adjacents = Object.keys(conversions[current]);\n\n\t\tfor (var len = adjacents.length, i = 0; i < len; i++) {\n\t\t\tvar adjacent = adjacents[i];\n\t\t\tvar node = graph[adjacent];\n\n\t\t\tif (node.distance === -1) {\n\t\t\t\tnode.distance = graph[current].distance + 1;\n\t\t\t\tnode.parent = current;\n\t\t\t\tqueue.unshift(adjacent);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn graph;\n}\n\nfunction link(from, to) {\n\treturn function (args) {\n\t\treturn to(from(args));\n\t};\n}\n\nfunction wrapConversion(toModel, graph) {\n\tvar path = [graph[toModel].parent, toModel];\n\tvar fn = conversions[graph[toModel].parent][toModel];\n\n\tvar cur = graph[toModel].parent;\n\twhile (graph[cur].parent) {\n\t\tpath.unshift(graph[cur].parent);\n\t\tfn = link(conversions[graph[cur].parent][cur], fn);\n\t\tcur = graph[cur].parent;\n\t}\n\n\tfn.conversion = path;\n\treturn fn;\n}\n\nmodule.exports = function (fromModel) {\n\tvar graph = deriveBFS(fromModel);\n\tvar conversion = {};\n\n\tvar models = Object.keys(graph);\n\tfor (var len = models.length, i = 0; i < len; i++) {\n\t\tvar toModel = models[i];\n\t\tvar node = graph[toModel];\n\n\t\tif (node.parent === null) {\n\t\t\t// no possible conversion, or this node is the source model.\n\t\t\tcontinue;\n\t\t}\n\n\t\tconversion[toModel] = wrapConversion(toModel, graph);\n\t}\n\n\treturn conversion;\n};\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/color-convert/route.js\n// module id = 34\n// module chunks = 0","/**\n * Identicon.js 2.3.1\n * http://github.com/stewartlord/identicon.js\n *\n * PNGLib required for PNG output\n * http://www.xarg.org/download/pnglib.js\n *\n * Copyright 2017, Stewart Lord\n * Released under the BSD license\n * http://www.opensource.org/licenses/bsd-license.php\n */\n\n(function() {\n var PNGlib;\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n PNGlib = require('./pnglib');\n } else {\n PNGlib = window.PNGlib;\n }\n\n var Identicon = function(hash, options){\n if (typeof(hash) !== 'string' || hash.length < 15) {\n throw 'A hash of at least 15 characters is required.';\n }\n\n this.defaults = {\n background: [240, 240, 240, 255],\n margin: 0.08,\n size: 64,\n saturation: 0.7,\n brightness: 0.5,\n format: 'png'\n };\n\n this.options = typeof(options) === 'object' ? options : this.defaults;\n\n // backward compatibility with old constructor (hash, size, margin)\n if (typeof(arguments[1]) === 'number') { this.options.size = arguments[1]; }\n if (arguments[2]) { this.options.margin = arguments[2]; }\n\n this.hash = hash\n this.background = this.options.background || this.defaults.background;\n this.size = this.options.size || this.defaults.size;\n this.format = this.options.format || this.defaults.format;\n this.margin = this.options.margin !== undefined ? this.options.margin : this.defaults.margin;\n\n // foreground defaults to last 7 chars as hue at 70% saturation, 50% brightness\n var hue = parseInt(this.hash.substr(-7), 16) / 0xfffffff;\n var saturation = this.options.saturation || this.defaults.saturation;\n var brightness = this.options.brightness || this.defaults.brightness;\n this.foreground = this.options.foreground || this.hsl2rgb(hue, saturation, brightness);\n };\n\n Identicon.prototype = {\n background: null,\n foreground: null,\n hash: null,\n margin: null,\n size: null,\n format: null,\n\n image: function(){\n return this.isSvg()\n ? new Svg(this.size, this.foreground, this.background)\n : new PNGlib(this.size, this.size, 256);\n },\n\n render: function(){\n var image = this.image(),\n size = this.size,\n baseMargin = Math.floor(size * this.margin),\n cell = Math.floor((size - (baseMargin * 2)) / 5),\n margin = Math.floor((size - cell * 5) / 2),\n bg = image.color.apply(image, this.background),\n fg = image.color.apply(image, this.foreground);\n\n // the first 15 characters of the hash control the pixels (even/odd)\n // they are drawn down the middle first, then mirrored outwards\n var i, color;\n for (i = 0; i < 15; i++) {\n color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg;\n if (i < 5) {\n this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image);\n } else if (i < 10) {\n this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n } else if (i < 15) {\n this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n }\n }\n\n return image;\n },\n\n rectangle: function(x, y, w, h, color, image){\n if (this.isSvg()) {\n image.rectangles.push({x: x, y: y, w: w, h: h, color: color});\n } else {\n var i, j;\n for (i = x; i < x + w; i++) {\n for (j = y; j < y + h; j++) {\n image.buffer[image.index(i, j)] = color;\n }\n }\n }\n },\n\n // adapted from: https://gist.github.com/aemkei/1325937\n hsl2rgb: function(h, s, b){\n h *= 6;\n s = [\n b += s *= b < .5 ? b : 1 - b,\n b - h % 1 * s * 2,\n b -= s *= 2,\n b,\n b + h % 1 * s,\n b + s\n ];\n\n return[\n s[ ~~h % 6 ] * 255, // red\n s[ (h|16) % 6 ] * 255, // green\n s[ (h|8) % 6 ] * 255 // blue\n ];\n },\n\n toString: function(raw){\n // backward compatibility with old toString, default to base64\n if (raw) {\n return this.render().getDump();\n } else {\n return this.render().getBase64();\n }\n },\n\n isSvg: function(){\n return this.format.match(/svg/i)\n }\n };\n\n var Svg = function(size, foreground, background){\n this.size = size;\n this.foreground = this.color.apply(this, foreground);\n this.background = this.color.apply(this, background);\n this.rectangles = [];\n };\n\n Svg.prototype = {\n size: null,\n foreground: null,\n background: null,\n rectangles: null,\n\n color: function(r, g, b, a){\n var values = [r, g, b].map(Math.round);\n values.push((a >= 0) && (a <= 255) ? a/255 : 1);\n return 'rgba(' + values.join(',') + ')';\n },\n\n getDump: function(){\n var i,\n xml,\n rect,\n fg = this.foreground,\n bg = this.background,\n stroke = this.size * 0.005;\n\n xml = \"<svg xmlns='http://www.w3.org/2000/svg'\"\n + \" width='\" + this.size + \"' height='\" + this.size + \"'\"\n + \" style='background-color:\" + bg + \";'>\"\n + \"<g style='fill:\" + fg + \"; stroke:\" + fg + \"; stroke-width:\" + stroke + \";'>\";\n\n for (i = 0; i < this.rectangles.length; i++) {\n rect = this.rectangles[i];\n if (rect.color == bg) continue;\n xml += \"<rect \"\n + \" x='\" + rect.x + \"'\"\n + \" y='\" + rect.y + \"'\"\n + \" width='\" + rect.w + \"'\"\n + \" height='\" + rect.h + \"'\"\n + \"/>\";\n }\n xml += \"</g></svg>\"\n\n return xml;\n },\n\n getBase64: function(){\n return btoa(this.getDump());\n }\n };\n\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n module.exports = Identicon;\n } else {\n window.Identicon = Identicon;\n }\n})();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/identicon.js\n// module id = 35\n// module chunks = 0","/**\n* A handy class to calculate color values.\n*\n* @version 1.0\n* @author Robert Eisele <robert@xarg.org>\n* @copyright Copyright (c) 2010, Robert Eisele\n* @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/\n* @license http://www.opensource.org/licenses/bsd-license.php BSD License\n*\n*/\n\n(function() {\n \n // helper functions for that ctx\n function write(buffer, offs) {\n for (var i = 2; i < arguments.length; i++) {\n for (var j = 0; j < arguments[i].length; j++) {\n buffer[offs++] = arguments[i].charAt(j);\n }\n }\n }\n \n function byte2(w) {\n return String.fromCharCode((w >> 8) & 255, w & 255);\n }\n \n function byte4(w) {\n return String.fromCharCode((w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w & 255);\n }\n \n function byte2lsb(w) {\n return String.fromCharCode(w & 255, (w >> 8) & 255);\n }\n \n // modified from original source to support NPM\n var PNGlib = function(width,height,depth) {\n \n this.width = width;\n this.height = height;\n this.depth = depth;\n \n // pixel data and row filter identifier size\n this.pix_size = height * (width + 1);\n \n // deflate header, pix_size, block headers, adler32 checksum\n this.data_size = 2 + this.pix_size + 5 * Math.floor((0xfffe + this.pix_size) / 0xffff) + 4;\n \n // offsets and sizes of Png chunks\n this.ihdr_offs = 0;\t\t\t\t\t\t\t\t\t// IHDR offset and size\n this.ihdr_size = 4 + 4 + 13 + 4;\n this.plte_offs = this.ihdr_offs + this.ihdr_size;\t// PLTE offset and size\n this.plte_size = 4 + 4 + 3 * depth + 4;\n this.trns_offs = this.plte_offs + this.plte_size;\t// tRNS offset and size\n this.trns_size = 4 + 4 + depth + 4;\n this.idat_offs = this.trns_offs + this.trns_size;\t// IDAT offset and size\n this.idat_size = 4 + 4 + this.data_size + 4;\n this.iend_offs = this.idat_offs + this.idat_size;\t// IEND offset and size\n this.iend_size = 4 + 4 + 4;\n this.buffer_size = this.iend_offs + this.iend_size;\t// total PNG size\n \n this.buffer = new Array();\n this.palette = new Object();\n this.pindex = 0;\n \n var _crc32 = new Array();\n \n // initialize buffer with zero bytes\n for (var i = 0; i < this.buffer_size; i++) {\n this.buffer[i] = \"\\x00\";\n }\n \n // initialize non-zero elements\n write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), 'IHDR', byte4(width), byte4(height), \"\\x08\\x03\");\n write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), 'PLTE');\n write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), 'tRNS');\n write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), 'IDAT');\n write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), 'IEND');\n \n // initialize deflate header\n var header = ((8 + (7 << 4)) << 8) | (3 << 6);\n header+= 31 - (header % 31);\n \n write(this.buffer, this.idat_offs + 8, byte2(header));\n \n // initialize deflate block headers\n for (var i = 0; (i << 16) - 1 < this.pix_size; i++) {\n var size, bits;\n if (i + 0xffff < this.pix_size) {\n size = 0xffff;\n bits = \"\\x00\";\n } else {\n size = this.pix_size - (i << 16) - i;\n bits = \"\\x01\";\n }\n write(this.buffer, this.idat_offs + 8 + 2 + (i << 16) + (i << 2), bits, byte2lsb(size), byte2lsb(~size));\n }\n \n /* Create crc32 lookup table */\n for (var i = 0; i < 256; i++) {\n var c = i;\n for (var j = 0; j < 8; j++) {\n if (c & 1) {\n c = -306674912 ^ ((c >> 1) & 0x7fffffff);\n } else {\n c = (c >> 1) & 0x7fffffff;\n }\n }\n _crc32[i] = c;\n }\n \n // compute the index into a png for a given pixel\n this.index = function(x,y) {\n var i = y * (this.width + 1) + x + 1;\n var j = this.idat_offs + 8 + 2 + 5 * Math.floor((i / 0xffff) + 1) + i;\n return j;\n }\n \n // convert a color and build up the palette\n this.color = function(red, green, blue, alpha) {\n \n alpha = alpha >= 0 ? alpha : 255;\n var color = (((((alpha << 8) | red) << 8) | green) << 8) | blue;\n \n if (typeof this.palette[color] == \"undefined\") {\n if (this.pindex == this.depth) return \"\\x00\";\n \n var ndx = this.plte_offs + 8 + 3 * this.pindex;\n \n this.buffer[ndx + 0] = String.fromCharCode(red);\n this.buffer[ndx + 1] = String.fromCharCode(green);\n this.buffer[ndx + 2] = String.fromCharCode(blue);\n this.buffer[this.trns_offs+8+this.pindex] = String.fromCharCode(alpha);\n \n this.palette[color] = String.fromCharCode(this.pindex++);\n }\n return this.palette[color];\n }\n \n // output a PNG string, Base64 encoded\n this.getBase64 = function() {\n \n var s = this.getDump();\n \n var ch = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n var c1, c2, c3, e1, e2, e3, e4;\n var l = s.length;\n var i = 0;\n var r = \"\";\n \n do {\n c1 = s.charCodeAt(i);\n e1 = c1 >> 2;\n c2 = s.charCodeAt(i+1);\n e2 = ((c1 & 3) << 4) | (c2 >> 4);\n c3 = s.charCodeAt(i+2);\n if (l < i+2) { e3 = 64; } else { e3 = ((c2 & 0xf) << 2) | (c3 >> 6); }\n if (l < i+3) { e4 = 64; } else { e4 = c3 & 0x3f; }\n r+= ch.charAt(e1) + ch.charAt(e2) + ch.charAt(e3) + ch.charAt(e4);\n } while ((i+= 3) < l);\n return r;\n }\n \n // output a PNG string\n this.getDump = function() {\n \n // compute adler32 of output pixels + row filter bytes\n var BASE = 65521; /* largest prime smaller than 65536 */\n var NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n var s1 = 1;\n var s2 = 0;\n var n = NMAX;\n \n for (var y = 0; y < this.height; y++) {\n for (var x = -1; x < this.width; x++) {\n s1+= this.buffer[this.index(x, y)].charCodeAt(0);\n s2+= s1;\n if ((n-= 1) == 0) {\n s1%= BASE;\n s2%= BASE;\n n = NMAX;\n }\n }\n }\n s1%= BASE;\n s2%= BASE;\n write(this.buffer, this.idat_offs + this.idat_size - 8, byte4((s2 << 16) | s1));\n \n // compute crc32 of the PNG chunks\n function crc32(png, offs, size) {\n var crc = -1;\n for (var i = 4; i < size-4; i += 1) {\n crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff);\n }\n write(png, offs+size-4, byte4(crc ^ -1));\n }\n \n crc32(this.buffer, this.ihdr_offs, this.ihdr_size);\n crc32(this.buffer, this.plte_offs, this.plte_size);\n crc32(this.buffer, this.trns_offs, this.trns_size);\n crc32(this.buffer, this.idat_offs, this.idat_size);\n crc32(this.buffer, this.iend_offs, this.iend_size);\n \n // convert PNG to string\n return \"\\x89PNG\\r\\n\\x1a\\n\"+this.buffer.join('');\n }\n }\n \n // modified from original source to support NPM\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n module.exports = PNGlib;\n } else {\n window.PNGlib = PNGlib;\n }\n })();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/pnglib.js\n// module id = 36\n// module chunks = 0","/**\n * Representation of a game item, which for the moment is limited to a\n * simple Food type.\n */\n\nexport class Item {\n constructor(id, itemId, maturity, remainingUses) {\n this.id = id;\n this.itemId = itemId;\n this.maturity = maturity;\n this.remainingUses = remainingUses;\n\n // XXX Maybe we can avoid this copy of every shared value\n // to every instance, but going with it for now.\n Object.assign(this, settings.item_config[this.itemId]);\n }\n\n /**\n * Calculate a color based on sprite definition and maturity\n */\n get color() {\n let immature, mature;\n\n if (this.sprite.includes(\",\")) {\n [immature, mature] = this.sprite.split(\",\");\n // For now, assume these are hex colors\n } else {\n immature = mature = this.sprite;\n }\n\n return rgbOnScale(\n hexToRgbPercentages(immature),\n hexToRgbPercentages(mature),\n this.maturity\n );\n }\n}\n\n/**\n * Manages Items that sit on the grid.\n *\n * Items currently being carried by a Player are not included.\n * These are instead held by reference in the Play instances,\n * (named `current_item`).\n */\nexport class GridItems {\n constructor() {\n this._itemsByPosition = new Map();\n this._positionsById = new Map();\n }\n\n add(item, position) {\n this._itemsByPosition.set(JSON.stringify(position), item);\n this._positionsById.set(item.id, JSON.stringify(position));\n }\n\n atPosition(position) {\n const key = JSON.stringify(position);\n return this._itemsByPosition.get(key) || null;\n }\n\n positionOf(item) {\n if (this._positionsById.has(item.id)) {\n return JSON.parse(this._positionsById.get(item.id));\n }\n\n return undefined;\n }\n\n remove(position) {\n const item = this.atPosition(position);\n\n if (item) {\n this._itemsByPosition.delete(JSON.stringify(position));\n this._positionsById.delete(item.id);\n }\n }\n\n /**\n * Retrieve pairs of positions and Item objects (like Python's dict.items())\n * @returns Map.prototype[@@iterator] of[position, Item] pairs\n */\n *entries() {\n for (const [itemPosition, currentItem] of this._itemsByPosition.entries()) {\n yield [JSON.parse(itemPosition), currentItem];\n }\n }\n}\n\nfunction hexToRgbPercentages(hexColor) {\n if (hexColor.startsWith(\"#\")) {\n hexColor = hexColor.substring(1);\n }\n\n // Check if the hex color has a valid length (either 3 or 6 characters)\n if (hexColor.length !== 3 && hexColor.length !== 6) {\n throw new Error(\n \"Invalid hex color format. It should be either 3 or 6 characters long.\"\n );\n }\n\n // If the hex color is 3 characters long, expand it to 6 characters by\n // duplicating each character\n if (hexColor.length === 3) {\n hexColor = hexColor\n .split(\"\")\n .map((char) => char + char)\n .join(\"\");\n }\n\n // Convert the hex color to RGB percentage values\n const red = parseInt(hexColor.substring(0, 2), 16) / 255;\n const green = parseInt(hexColor.substring(2, 4), 16) / 255;\n const blue = parseInt(hexColor.substring(4, 6), 16) / 255;\n\n return [red, green, blue];\n}\n\nfunction rgbOnScale(startColor, endColor, percentage) {\n const result = [];\n for (let i = 0; i < 3; i++) {\n result[i] = endColor[i] + percentage * (startColor[i] - endColor[i]);\n }\n\n return result;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/items.js\n// module id = 37\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 387feb8eadb9c5b23992","webpack:///./dlgr/griduniverse/static/scripts/util/md5.js","webpack:///./~/color-convert/conversions.js","webpack:///./~/is-array/index.js","webpack:///./~/is-number/index.js","webpack:///./~/is-string/index.js","webpack:///./~/parse-color/index.js","webpack:///./dlgr/griduniverse/static/scripts/index.js","webpack:///./dlgr/griduniverse/static/scripts/items.js","webpack:///./dlgr/griduniverse/static/scripts/util/identicon.js","webpack:///./~/color/index.js","webpack:///./~/gaussian/lib/gaussian.js","webpack:///./~/mouse-position/index.js","webpack:///./~/mousetrap/mousetrap.js","webpack:///./~/reconnecting-websocket/dist/index.js","webpack:///external \"jQuery\"","webpack:///./dlgr/griduniverse/static/scripts/demo.js","webpack:///./dlgr/griduniverse/static/scripts/util/convert.js","webpack:///./dlgr/griduniverse/static/scripts/util/layout.js","webpack:///./dlgr/griduniverse/static/scripts/util/pixdenticon.js","webpack:///./dlgr/griduniverse/static/scripts/util/pnglib.js","webpack:///./dlgr/griduniverse/static/scripts/util/range.js","webpack:///./dlgr/griduniverse/static/scripts/util/texcoord.js","webpack:///./~/color-convert/index.js","webpack:///./~/color-convert/route.js","webpack:///./~/color-name/index.js","webpack:///./~/color-string/index.js","webpack:///./~/color-string/~/color-name/index.js","webpack:///./~/gaussian/lib/box-muller.js","webpack:///./~/has-symbols/shams.js","webpack:///./~/has-tostringtag/shams.js","webpack:///./~/is-arrayish/index.js","webpack:///./~/is-buffer/index.js","webpack:///./~/kind-of/index.js","webpack:///./~/lodash/lodash.js","webpack:///./~/node-libs-browser/~/events/events.js","webpack:///./~/parse-color/~/color-convert/conversions.js","webpack:///./~/parse-color/~/color-convert/index.js","webpack:///./~/regl/dist/regl.js","webpack:///./~/simple-swizzle/index.js","webpack:///(webpack)/buildin/global.js","webpack:///(webpack)/buildin/module.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA,2CAA2C,cAAc;;QAEzD;QACA;QACA;QACA;QACA;QACA;QACA;QACA,KAAK;QACL;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA;;;;;;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,CAAC;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA,eAAe,aAAa;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAM,IAA0C;AAChD,IAAI,kCAAO;AACX;AACA,KAAK;AAAA,oGAAC;AACN,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA,CAAC,O;;;;;;ACxRD;AACA,kBAAkB,mBAAO,CAAC,EAAY;;AAEtC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,QAAQ,4BAA4B;AACpC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,6BAA6B;AACpC,WAAW,iCAAiC;AAC5C,UAAU,gCAAgC;AAC1C,WAAW,iCAAiC;AAC5C,OAAO,qCAAqC;AAC5C,SAAS,2CAA2C;AACpD,QAAQ;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qDAAqD,gBAAgB;AACrE,mDAAmD,cAAc;AACjE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,uBAAuB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO,QAAQ;AAC/B,gBAAgB,OAAO,QAAQ;AAC/B,iBAAiB,OAAO,OAAO;AAC/B,iBAAiB,OAAO,OAAO;AAC/B,gBAAgB,QAAQ,OAAO;AAC/B,gBAAgB,QAAQ,OAAO;AAC/B;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,sEAAsE;;AAEtE;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,+CAA+C,EAAE,UAAU,EAAE;AAC7D;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA,EAAE;AACF;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa;AAC5B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;ACl2BA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,YAAY;AACZ;;AAEA;AACA;AACA;;;;;;;;AChCA;AACA;AACA;AACA;AACA;AACA;;AAEa;;AAEb,aAAa,mBAAO,CAAC,EAAS;;AAE9B;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;;;;;;;ACrBa;;AAEb;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,qBAAqB,mBAAO,CAAC,EAAuB;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACvBA,cAAc,mBAAO,CAAC,EAAe;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,oCAAoC;;AAE7C;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;;;;;;;AClFA,YAAY,mBAAO,CAAC,CAAa;AACjC,eAAe,mBAAO,CAAC,CAAW;AAClC,eAAe,mBAAO,CAAC,CAAW;AAClC,cAAc,mBAAO,CAAC,CAAU;AAChC,cAAc,mBAAO,CAAC,EAAgB;AACtC,aAAa,mBAAO,CAAC,EAAe;AACpC,eAAe,mBAAO,CAAC,EAAiB;AACxC,YAAY,mBAAO,CAAC,EAAc;AAClC,kBAAkB,mBAAO,CAAC,EAAoB;AAC9C,UAAU,mBAAO,CAAC,CAAY;;AAE9B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,aAAa,mBAAO,CAAC,EAAM;;AAE3B;AACA,eAAe,iBAAiB;AAChC;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,UAAU;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,+FAA+F;AAChH;AACA;AACA,eAAe;AACf,GAAG;;AAEH;AACA,gBAAgB,mBAAmB;AACnC,kBAAkB,OAAO;AACzB;AACA;AACA;;AAEA,gBAAgB;;AAEhB;AACA,gBAAgB,uCAAuC;AACvD,aAAa,2DAA2D;AACxE;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,gBAAgB,mBAAmB;AACnC,kBAAkB,OAAO;AACzB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AC/JA;AAAA;AACA;AACA;AACA;;AAEO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAAA;AAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAAA;AAAA;;AAED;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;;;;;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,mBAAO,CAAC,EAAU;AACnC,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,gDAAgD,oCAAoC;AACpF,gDAAgD,oCAAoC;;AAEpF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uBAAuB,QAAQ;AAC/B;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA,SAAS;;AAET;AACA;AACA,uCAAuC,qCAAqC;AAC5E,aAAa;AACb;AACA,2BAA2B,WAAW;AACtC,+BAA+B,WAAW;AAC1C;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD;AACvD,6CAA6C,mBAAmB,6BAA6B;;AAE7F,uBAAuB,4BAA4B;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,CAAC,I;;;;;;;ACtMY;;AAEb,kBAAkB,mBAAO,CAAC,EAAc;AACxC,cAAc,mBAAO,CAAC,EAAe;;AAErC;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,aAAa,mBAAmB;AAChC;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,cAAc;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA,qEAAqE,kCAAkC,EAAE;;AAEzG;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;;AAEF;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,gBAAgB,YAAY;AAC5B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;ACjeA;;AAEA,2BAA2B,mBAAO,CAAC,EAAc;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,aAAa;AAC9B,iBAAiB,YAAY;;AAE7B;AACA;;AAEA;AACA;;AAEA,mBAAmB,OAAO;AAC1B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,CAAC;AACD,CAAC,KAA+B;AAChC,mBAAmB,oBAAoB;AACvC;AACA,mBAAmB,sBAAsB,EAAE;;;;;;;;ACpI3C,cAAc,mBAAO,CAAC,EAAS;;AAE/B;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;;;;;;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;;AAEA;AACA;AACA;AACA,eAAe,QAAQ;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,qBAAqB;AACpC,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB;AACjB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA,8CAA8C,EAAE;AAChD;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB,gBAAgB,QAAQ;AACxB,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB,iBAAiB;AACpC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,MAAM;AACzB,mBAAmB,aAAa;AAChC,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,uCAAuC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B,mBAAmB,MAAM;AACzB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,MAAM;AACzB,mBAAmB,MAAM;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;;AAEA;AACA,uBAAuB,sBAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,MAAM;AACzB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,MAAM;AACzB,mBAAmB,SAAS;AAC5B,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,MAAM;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B,mBAAmB,SAAS;AAC5B,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,mDAAmD,kBAAkB;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;AACA;AACA,mBAAmB,MAAM;AACzB,mBAAmB,SAAS;AAC5B,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA,2BAA2B,yBAAyB;AACpD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,uDAAuD;AACvD;;AAEA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB,gBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,QAAQ,IAA0C;AAClD,QAAQ,kCAAO;AACf;AACA,SAAS;AAAA,oGAAC;AACV;AACA,CAAC;;;;;;;;ACjiCY;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,EAAE;AACH;AACA;AACA,0BAA0B,kBAAkB,EAAE;AAC9C,+BAA+B,mBAAmB,EAAE;AACpD;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,6BAA6B,cAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,oCAAoC,EAAE;AACtE,iCAAiC,mCAAmC,EAAE;AACtE;AACA;AACA;AACA;AACA;AACA,wBAAwB,uBAAuB;AAC/C;AACA;AACA;AACA,KAAK,gBAAgB;AACrB;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK,KAAK;AACV;AACA,4BAA4B,2BAA2B;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,aAAa;AAC3C,gCAAgC,aAAa;AAC7C,mCAAmC;AACnC,gCAAgC,wIAAwI;AACxK;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;;;;;;;ACtNA,wB;;;;;;ACAA;AACA;;AAEA;;AAEA,WAAW,mBAAO,CAAC,CAAS;AAC5B,eAAe,mBAAO,CAAC,EAAgB;AACvC,gBAAgB,mBAAO,CAAC,EAAW;AACnC,4BAA4B,mBAAO,CAAC,EAAwB;AAC5D,QAAQ,mBAAO,CAAC,EAAQ;AACxB,eAAe,mBAAO,CAAC,EAAU;AACjC,YAAY,mBAAO,CAAC,EAAO;AAC3B,gBAAgB,mBAAO,CAAC,CAAkB;AAC1C,UAAU,mBAAO,CAAC,CAAY;AAC9B,cAAc,mBAAO,EAAE,CAAS;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC,qBAAqB,kBAAkB;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,eAAe;AAClC,qBAAqB,kBAAkB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,mBAAmB;AAClC,iBAAiB,sBAAsB;AACvC;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,4BAA4B,uCAAuC;AACnE;AACA;AACA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,iBAAiB,2BAA2B;AAC5C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA,OAAO;;AAEP;AACA,gBAAgB;AAChB,OAAO;AACP;;AAEA;AACA;;AAEA;AACA,2BAA2B,qDAAqD;AAChF,OAAO;;AAEP;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;AACA,yBAAyB,oBAAoB;;AAE7C;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2BAA2B,KAAK;AAChC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,6BAA6B;AAC7B;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;;AAEA,2BAA2B,gBAAgB,EAAE;AAC7C,2BAA2B,mBAAmB,EAAE;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,+BAA+B,mCAAmC;AAClE;AACA;AACA,cAAc,iBAAiB,KAAK,iBAAiB;AACrD;;AAEA;AACA;AACA;AACA,GAAG;AACH,yBAAyB,8BAA8B;AACvD;AACA;AACA,YAAY,iBAAiB,KAAK,iBAAiB,KAAK,eAAe,KAAK,eAAe;;AAE3F;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,2BAA2B;AACtD,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAe,wBAAwB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wBAAwB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,wBAAwB;AAClD;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uGAAuG;AACvG,GAAG;AACH,sFAAsF;AACtF;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,4BAA4B;AAC5D,eAAe,yBAAyB;AACxC;AACA;AACA,4JAA4J;AAC5J;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,0BAA0B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,wBAAwB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA,CAAC;;AAED,CAAC;;;;;;;;;ACr7CD,aAAa,mBAAO,CAAC,EAAQ;AAC7B,cAAc,mBAAO,CAAC,CAAU;AAChC,eAAe,mBAAO,CAAC,CAAW;AAClC,eAAe,mBAAO,CAAC,CAAW;AAClC,YAAY,mBAAO,CAAC,CAAa;;AAEjC;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;;AAEA;AACA;;AAEA;;;;;;;AC1BA;AACA;;AAEA,iBAAiB,UAAU;AAC3B,mBAAmB,aAAa;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;;;;;;;ACxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA,mBAAmB,WAAW;AAC9B,uBAAuB,WAAW;AAClC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,eAAe,UAAU;AACzB;AACA,mBAAmB,UAAU;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;AAGA;;;;;;;ACpGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,2BAA2B,sBAAsB;AACjD,+BAA+B,yBAAyB;AACxD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,+BAA+B;AAC/B;AACA,6DAA6D;AAC7D;AACA,6DAA6D;AAC7D;AACA,6DAA6D;AAC7D;AACA,6DAA6D;AAC7D;AACA,gEAAgE;;AAEhE;AACA;AACA;;AAEA;;AAEA;AACA,2BAA2B,sBAAsB;AACjD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,2BAA2B,+BAA+B;AAC1D;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B,SAAS;AACpC;AACA,+BAA+B,OAAO;AACtC;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,SAAS,EAAE,OAAO,oCAAoC;AACxF,kCAAkC,SAAS,EAAE,OAAO,gBAAgB;AACpE;AACA,iBAAiB;AACjB;AACA;;AAEA;AACA;;AAEA;AACA,iCAAiC;AACjC,gCAAgC;AAChC;AACA;AACA;;AAEA,+BAA+B,iBAAiB;AAChD,oCAAoC,gBAAgB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mCAAmC,YAAY;AAC/C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK,I;;;;;;ACrNL,sB;AACA;AACA;AACA,kCAAkC,cAAc,EAAE,E;AAClD;;;;AAIA;;;;;;;ACRA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,UAAU;AAC3B,mBAAmB,aAAa;AAChC;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;;;;;;;AC1BA,kBAAkB,mBAAO,CAAC,CAAe;AACzC,YAAY,mBAAO,CAAC,EAAS;;AAE7B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,wDAAwD,uCAAuC;AAC/F,sDAAsD,qCAAqC;;AAE3F;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;AACF,CAAC;;AAED;;;;;;;AC7EA,kBAAkB,mBAAO,CAAC,CAAe;;AAEzC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB;;AAEzB;;AAEA;AACA;AACA;;AAEA,yCAAyC,SAAS;AAClD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,qCAAqC,SAAS;AAC9C;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;AC/FY;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACvJA;AACA,iBAAiB,mBAAO,CAAC,EAAY;AACrC,cAAc,mBAAO,CAAC,EAAgB;AACtC;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA,yBAAyB,IAAI;AAC7B,wBAAwB,EAAE,WAAW,EAAE;AACvC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,EAAE;AACF,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,EAAE;AACF;AACA;;AAEA,YAAY,OAAO;AACnB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,mCAAmC,IAAI;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,8BAA8B,IAAI;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;ACjPY;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACvJA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,CAAC;AACD,CAAC,KAA+B;AAChC,mBAAmB,oBAAoB;AACvC;AACA,mBAAmB,uBAAuB,EAAE;;;;;;;;;ACzC/B;;AAEb;AACA;AACA,0FAA0F,cAAc;AACxG,2CAA2C,aAAa;;AAExD;AACA;AACA;AACA,+BAA+B,cAAc;;AAE7C,iEAAiE,cAAc;AAC/E,oEAAoE,cAAc;;AAElF;AACA,gCAAgC,cAAc;AAC9C;AACA,sCAAsC,cAAc;;AAEpD,0DAA0D,cAAc;AACxE,8DAA8D,cAAc;;AAE5E;AACA;AACA,mBAAmB,cAAc,EAAE;AACnC,0EAA0E,cAAc;;AAExF,wGAAwG,cAAc;;AAEtH;AACA,4CAA4C,cAAc;;AAE1D,6DAA6D,cAAc;;AAE3E;AACA;AACA,sEAAsE,cAAc;AACpF;;AAEA;AACA;;;;;;;;ACzCa;;AAEb,iBAAiB,mBAAO,CAAC,EAAmB;;AAE5C;AACA;AACA;;;;;;;ACNA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACpBA,eAAe,mBAAO,CAAC,EAAW;AAClC;;AAEA;AACA;AACA;AACA,YAAY,EAAE;AACd,YAAY,EAAE;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2CAA2C;AAC3C;AACA,2DAA2D;;AAE3D;AACA,+CAA+C;AAC/C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,yBAAyB;AACzB,yBAAyB;AACzB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,2CAA2C;;AAE3C;AACA;;AAEA;AACA;AACA;AACA;AACA,0BAA0B,MAAM,aAAa,OAAO;;AAEpD;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAiD,EAAE;AACnD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C,EAAE;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf,cAAc;AACd,cAAc;AACd,gBAAgB;AAChB,eAAe;AACf;;AAEA;AACA;AACA,UAAU;AACV,SAAS;AACT,SAAS;AACT,WAAW;AACX,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,MAAM;AACnB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,SAAS;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,QAAQ;AACrB;AACA,eAAe,EAAE;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,QAAQ;AACrB;AACA,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,aAAa,SAAS;AACtB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,EAAE;AACf,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,SAAS;AACtB,aAAa,EAAE;AACf,aAAa,QAAQ;AACrB;AACA,aAAa,SAAS;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,SAAS;AACtB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,SAAS;AACtB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,aAAa,OAAO;AACpB,eAAe,EAAE;AACjB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,EAAE;AACf,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe,SAAS;AACxB;AACA;AACA,cAAc,2BAA2B;AACzC;AACA;AACA,mBAAmB,gCAAgC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,6BAA6B;AAC9D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW;AACX;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,cAAc;AAC/B;AACA;AACA;AACA;AACA;AACA,oCAAoC,6BAA6B,EAAE;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,EAAE;AACnB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,6BAA6B;AAC5C,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT,gBAAgB;AAChB,OAAO;;AAEP;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qEAAqE;AACrE;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,aAAa;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,YAAY;AAC3B,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,mBAAmB;AAClC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,gBAAgB,QAAQ;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,gBAAgB,QAAQ;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,OAAO,WAAW;AACjC,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,4BAA4B;;AAE5B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,WAAW;AACjC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,WAAW;AACjC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,+CAA+C;AACpF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,oEAAoE;AACpE;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,0CAA0C;AAC1C,wCAAwC;AACxC,+DAA+D;AAC/D,iEAAiE;AACjE;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C;AAC7C;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,cAAc;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,cAAc;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,MAAM;AACvB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,SAAS,GAAG,SAAS,KAAK,SAAS;AAC3D,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D;AACA,mCAAmC,iBAAiB;AACpD,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,oCAAoC;AAC9C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,4CAA4C,kBAAkB,EAAE;AAChE;AACA;AACA;AACA,gCAAgC,qCAAqC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,uCAAuC,kBAAkB,EAAE;AAC3D;AACA;AACA;AACA,2BAA2B,oCAAoC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,uCAAuC,2BAA2B,EAAE;AACpE;AACA;AACA;AACA,2BAA2B,kCAAkC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,oCAAoC;AAC9C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,2CAA2C,4BAA4B,EAAE;AACzE;AACA;AACA;AACA,+BAA+B,mCAAmC;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,SAAS,KAAK,SAAS,GAAG,SAAS;AAC7D,eAAe,SAAS;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D,sBAAsB,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,qBAAqB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;AAClE;AACA,4BAA4B,SAAS,GAAG,SAAS;AACjD;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,qBAAqB,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB;AAC9E;AACA,8BAA8B,iBAAiB;AAC/C;AACA,eAAe,iBAAiB,GAAG,iBAAiB;AACpD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,qBAAqB;AACpC,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,iCAAiC,SAAS,eAAe,YAAY,EAAE;AACvE;AACA;AACA;AACA,iCAAiC,SAAS;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,qCAAqC,SAAS,eAAe,YAAY,EAAE;AAC3E;AACA;AACA;AACA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,oCAAoC;AAC9C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,4CAA4C,kBAAkB,EAAE;AAChE;AACA;AACA;AACA,gCAAgC,qCAAqC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,qCAAqC;AAC/C,UAAU;AACV;AACA;AACA,uCAAuC,kBAAkB,EAAE;AAC3D;AACA;AACA;AACA,2BAA2B,oCAAoC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS,KAAK,SAAS,GAAG,SAAS;AACtD,eAAe,SAAS,GAAG,SAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D,sBAAsB,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA,eAAe,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB;AACxE;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS,GAAG,SAAS,GAAG,SAAS;AACnD,eAAe,SAAS,GAAG,SAAS;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB;AAChF;AACA;AACA,eAAe,iBAAiB,GAAG,iBAAiB;AACpD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,KAAK,SAAS,GAAG,SAAS;AACpD,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA,uBAAuB,iBAAiB,GAAG,iBAAiB;AAC5D,sBAAsB,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA,eAAe,iBAAiB,GAAG,iBAAiB;AACpD;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc,OAAO,QAAQ,SAAS,GAAG,SAAS,GAAG;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,+BAA+B;AACzC,UAAU,+BAA+B;AACzC,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,8BAA8B;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,8BAA8B;AACxC,UAAU;AACV;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA,cAAc;AACd;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,gBAAgB,OAAO;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,+CAA+C;AACzD,UAAU;AACV;AACA;AACA;AACA,uBAAuB,oCAAoC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,UAAU,8CAA8C;AACxD,UAAU;AACV;AACA;AACA,oCAAoC,kBAAkB,EAAE;AACxD;AACA;AACA;AACA,wBAAwB,4BAA4B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,YAAY;AAChD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA,UAAU,+CAA+C;AACzD,UAAU,gDAAgD;AAC1D,UAAU;AACV;AACA;AACA,kCAAkC,mBAAmB,EAAE;AACvD;AACA;AACA;AACA,sBAAsB,2BAA2B;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,aAAa;AAC9B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,eAAe,EAAE;AACjB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,sBAAsB;AACrC;AACA,eAAe,KAAK;AACpB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,UAAU,4BAA4B;AACtC,UAAU;AACV;AACA;AACA;AACA;AACA,QAAQ;AACR,cAAc,OAAO,4BAA4B,QAAQ,8BAA8B;AACvF;AACA;AACA,cAAc,UAAU,4BAA4B,YAAY,8BAA8B;AAC9F;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA;AACA,UAAU,mBAAmB;AAC7B,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,qCAAqC;AACpD;AACA,eAAe,SAAS;AACxB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,gDAAgD;AAC1D,UAAU,+CAA+C;AACzD,UAAU;AACV;AACA;AACA,uCAAuC,iBAAiB,EAAE;AAC1D;AACA;AACA;AACA,2BAA2B,4BAA4B;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,cAAc,iBAAiB,EAAE;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,iBAAiB,yBAAyB;AAC1C;AACA;AACA,QAAQ,IAAI;AACZ,cAAc,8BAA8B;AAC5C;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA,UAAU,+CAA+C;AACzD,UAAU;AACV;AACA;AACA,oCAAoC,kBAAkB,EAAE;AACxD;AACA;AACA;AACA,wBAAwB,4BAA4B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,gBAAgB,OAAO;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,mCAAmC;AAC7C,UAAU;AACV;AACA;AACA;AACA,sBAAsB,oCAAoC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,yBAAyB;AACxC;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU,8BAA8B;AACxC,UAAU;AACV;AACA;AACA,qCAAqC,eAAe,EAAE;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,oBAAoB,iCAAiC;AACrD,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,QAAQ;AACvB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,QAAQ;AACvB;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,kDAAkD,kBAAkB;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,KAAK;AACpB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,qBAAqB;AACpC,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD,oBAAoB;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA,oBAAoB,SAAS;AAC7B,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB;AACA,6BAA6B,mBAAmB,cAAc,EAAE,EAAE;AAClE;AACA;AACA,6BAA6B,mBAAmB,cAAc,EAAE,EAAE;AAClE;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA,iCAAiC,kBAAkB,EAAE;AACrD;AACA;AACA;AACA;AACA;AACA,kDAAkD,kBAAkB,EAAE;AACtE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB;AACrB;AACA,0BAA0B,SAAS;AACnC;AACA;AACA,0BAA0B,SAAS;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,MAAM;AACvB;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B,cAAc;AACd;AACA,iBAAiB,SAAS;AAC1B,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,GAAG,SAAS,GAAG,SAAS;AAClD,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,GAAG,SAAS,GAAG,SAAS;AAClD,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,MAAM;AACvB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,mBAAmB,SAAS,GAAG,SAAS,GAAG,SAAS;AACpD,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,uBAAuB,OAAO,SAAS,EAAE,GAAG,OAAO,iBAAiB,EAAE;AACtE,cAAc,OAAO,iBAAiB;AACtC;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA,qBAAqB,4BAA4B;AACjD,qBAAqB,6BAA6B;AAClD,qBAAqB;AACrB;AACA;AACA,qCAAqC,mBAAmB,EAAE;AAC1D;AACA;AACA;AACA,yBAAyB,2BAA2B;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA,qBAAqB,4BAA4B;AACjD,qBAAqB,6BAA6B;AAClD,qBAAqB;AACrB;AACA;AACA,yCAAyC,mBAAmB,EAAE;AAC9D;AACA;AACA;AACA,6BAA6B,4BAA4B;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB,OAAO,SAAS;AACrC,6BAA6B,gBAAgB,SAAS,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA,8BAA8B,gBAAgB,SAAS,GAAG;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,QAAQ;AACR,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,KAAK;AACpB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB,QAAQ,OAAO,oBAAoB,EAAE;AAC1D;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA,QAAQ;AACR,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA,qBAAqB,+BAA+B;AACpD,qBAAqB;AACrB;AACA;AACA,uCAAuC,cAAc,EAAE;AACvD,cAAc,2BAA2B;AACzC;AACA;AACA;AACA,cAAc,2BAA2B;AACzC;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,gBAAgB,SAAS,GAAG,SAAS;AACrC;AACA;AACA;AACA,gBAAgB,SAAS,GAAG,SAAS;AACrC;AACA;AACA;AACA,cAAc,QAAQ,iBAAiB,GAAG,iBAAiB;AAC3D;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,oBAAoB;AACpB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,KAAK;;AAEL;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA,gCAAgC;AAChC,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB;AACrB;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB,QAAQ,OAAO,+BAA+B,EAAE;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc,OAAO,WAAW;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,oBAAoB,yBAAyB;AAC7C;AACA,QAAQ,IAAI;AACZ,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,iBAAiB,QAAQ;AACzB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA,cAAc,QAAQ,QAAQ,EAAE;AAChC;AACA;AACA;AACA;AACA;AACA,cAAc,QAAQ,QAAQ,EAAE;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,qBAAqB,QAAQ,OAAO,SAAS,EAAE;AAC/C;AACA,iDAAiD,cAAc,EAAE;AACjE;AACA;AACA;AACA,iDAAiD,sBAAsB,EAAE;AACzE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,aAAa;AAC5B,eAAe,SAAS;AACxB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc,OAAO,WAAW;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kCAAkC,KAAK;AACvC;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,eAAe,gBAAgB;AAC/B,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,OAAO;AACvB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA,iBAAiB,sBAAsB;AACvC,qBAAqB,UAAU;AAC/B;AACA;AACA,sEAAsE,2BAA2B,EAAE;AACnG,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA,4DAA4D;AAC5D,iBAAiB,mBAAmB;AACpC;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA,qDAAqD,2BAA2B,EAAE;AAClF,wCAAwC,aAAa,eAAe,EAAE;AACtE,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA,wDAAwD,qCAAqC;AAC7F;AACA;AACA;AACA;AACA,0DAA0D,qBAAqB;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,YAAY;AACvD,0CAA0C,QAAQ;AAClD,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,+BAA+B;;AAE/B,mCAAmC;AACnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,wBAAwB;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;;AAEP,mBAAmB;;AAEnB;AACA;AACA;AACA;AACA,8BAA8B,mBAAmB;AACjD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,4CAA4C;;AAE5C;AACA,uDAAuD;AACvD;AACA;AACA,6BAA6B,EAAE;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C,+BAA+B,iCAAiC;AAChE,cAAc;AACd;AACA;AACA,sBAAsB;;AAEtB;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAiC;AACjC,aAAa,QAAQ,QAAQ,UAAU,aAAa;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,cAAc;AAC7B,gBAAgB,OAAO;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB,eAAe,KAAK;AACpB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,qBAAqB;AACpC,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,qBAAqB,SAAS;AAC9B,sBAAsB,kBAAkB;AACxC;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA,aAAa,qBAAqB;AAClC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,iBAAiB;AAC3B,UAAU;AACV;AACA;AACA,qCAAqC,mBAAmB,cAAc,EAAE,EAAE;AAC1E,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA,4CAA4C,SAAS;AACrD;AACA;AACA,eAAe,SAAS,GAAG,SAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,EAAE;AACnB;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,8CAA8C;AACxD,UAAU;AACV;AACA;AACA;AACA,mCAAmC,mCAAmC;AACtE,eAAe,8CAA8C;AAC7D;AACA;AACA;AACA,eAAe,4BAA4B;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,yBAAyB;AACnC,UAAU;AACV;AACA;AACA,oCAAoC,iBAAiB;AACrD,eAAe,yBAAyB;AACxC;AACA;AACA,gDAAgD,SAAS,cAAc,SAAS;AAChF,eAAe,yBAAyB,GAAG,yBAAyB;AACpE;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,EAAE;AACjB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,yBAAyB;AACnC,UAAU;AACV;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,eAAe,yBAAyB,GAAG,yBAAyB;AACpE;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,OAAO,qBAAqB,EAAE;AACxC,UAAU,OAAO,qBAAqB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,KAAK;AACpB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,OAAO;AACtB,eAAe,OAAO,YAAY;AAClC,eAAe,QAAQ;AACvB,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,mBAAmB,GAAG,iBAAiB;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,4BAA4B,qDAAqD;AACjF;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS,GAAG,SAAS;AAC3D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa;AAC5B,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,UAAU,OAAO,SAAS,EAAE;AAC5B,UAAU,OAAO,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA,gBAAgB,IAAI;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,EAAE;AACjB,iBAAiB,MAAM;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,qCAAqC,YAAY,EAAE;AACnD,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;AACpE;AACA,sCAAsC,YAAY,EAAE;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,EAAE;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,EAAE;AACnB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS;AAC5C;AACA,qCAAqC,YAAY,EAAE;AACnD,cAAc;AACd;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,iBAAiB,OAAO;AACxB;AACA;AACA,uBAAuB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;AACpE;AACA,qCAAqC,YAAY,EAAE;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK,MAAM,iBAAiB;;AAE5B;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mCAAmC,4DAA4D;AAC/F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,yCAAyC;AACtE;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;;AAEA;AACA;;AAEA;AACA,MAAM,IAA0E;AAChF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI,kCAAO;AACX;AACA,KAAK;AAAA,oGAAC;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;ACxzhBD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEa;;AAEb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,sBAAsB;AACvC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,cAAc;AACd;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA,iCAAiC,QAAQ;AACzC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,OAAO;AACP;AACA,sCAAsC,QAAQ;AAC9C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;;AAEA;AACA,QAAQ,yBAAyB;AACjC;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,6DAA6D,aAAa;AAC1E;AACA,6DAA6D,aAAa;AAC1E;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,oCAAoC,aAAa;AACjD;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;AACA;;;;;;;AChfA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;;AAExB;AACA;AACA;AACA,kBAAkB,OAAO,QAAQ;AACjC,kBAAkB,OAAO,QAAQ;AACjC,mBAAmB,OAAO,OAAO;AACjC,mBAAmB,OAAO,OAAO;AACjC,kBAAkB,QAAQ,OAAO;AACjC,kBAAkB,QAAQ,OAAO;AACjC;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;ACzrBA,kBAAkB,mBAAO,CAAC,EAAe;;AAEzC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA,uD;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB;;AAEnB,qBAAqB,gBAAgB;AACrC;AACA;AACA;AACA,GAAG;AACH;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gD;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,CAAC;;AAED,yB;;;;;;AC3FA;AACA,IAAI,KAA4D;AAChE;AACA;AACA,CAAC,qBAAqB;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,6EAA6E,0BAA0B;;AAEvG;AACA;AACA,yEAAyE;AACzE,4CAA4C,yBAAyB;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,0BAA0B;AAC7C;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB;AACrB,qBAAqB,4BAA4B;AACjD;AACA,sBAAsB;AACtB;AACA;;AAEA;AACA;AACA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,eAAe;AACf;AACA,eAAe;AACf;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,8CAA8C,kBAAkB;AAChE;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,mBAAmB,QAAQ;AAC3B;AACA,qBAAqB,QAAQ;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,yBAAyB,kBAAkB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;AACA,GAAG;AACH,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,cAAc;AACxC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B,mBAAmB,YAAY;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,kBAAkB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;;AAEtC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA,iBAAiB,kBAAkB;AACnC;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,OAAO;AACxB,mBAAmB,OAAO;AAC1B,qBAAqB,OAAO;AAC5B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG,IAAI;;AAEP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,uBAAuB,oBAAoB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,uBAAuB,OAAO;AAC9B;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,qBAAqB,OAAO;AAC5B,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,QAAQ;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,yBAAyB,OAAO;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,eAAe,6BAA6B;AAC5C;AACA;AACA,qCAAqC,gCAAgC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,iBAAiB,6BAA6B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qBAAqB,6BAA6B;AAClD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qBAAqB,wBAAwB;AAC7C;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,uBAAuB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,OAAO;AACxB,uBAAuB,uBAAuB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,mBAAmB;AACpC;AACA;;AAEA,iBAAiB,OAAO;AACxB;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;AACH;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,8BAA8B;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,qBAAqB,8BAA8B;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,uBAAuB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,mCAAmC,oBAAoB;AACvD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,uBAAuB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA,qBAAqB,wBAAwB;AAC7C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,qBAAqB,wBAAwB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,+BAA+B;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA,yBAAyB,eAAe;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,mBAAmB,wBAAwB;AAC3C;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB;AACpB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,yDAAyD;AACzD;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,yDAAyD;AACzD;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,6BAA6B,mBAAmB;AAChD;AACA;AACA,0BAA0B;AAC1B;AACA,YAAY;AACZ;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,WAAW;AAC9B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA,YAAY;AACZ;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,8BAA8B;AAC9B;AACA,eAAe;AACf;AACA;AACA,KAAK;AACL,gBAAgB;AAChB;AACA,iBAAiB,MAAM;AACvB,iBAAiB,MAAM;AACvB,iBAAiB,MAAM;AACvB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,mBAAmB,qBAAqB;AACxC;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oEAAoE;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6EAA6E;AAC7E;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,OAAO;AACP;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,wBAAwB;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,kFAAkF;AAClF,iFAAiF;;AAEjF;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA;AACA;AACA,mEAAmE;;AAEnE;;AAEA;AACA,SAAS;AACT;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,aAAa;AACb,WAAW;AACX;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB;;AAEnB;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA,eAAe;AACf;AACA,WAAW;AACX;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA;AACA,WAAW;AACX;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB;;AAEjB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;;AAEA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA,sEAAsE;AACtE;AACA,8DAA8D;AAC9D,kEAAkE;;AAElE;;AAEA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe;AACf,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;AAEjB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA;;AAEA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;;AAEf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,aAAa;AAC1D,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe;AACf,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,WAAW;AACX;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA,iDAAiD;AACjD,kCAAkC;AAClC,yFAAyF;AACzF,qCAAqC;AACrC,YAAY,KAAK;AACjB,8DAA8D;AAC9D,4BAA4B;AAC5B,qCAAqC;AACrC,YAAY,mCAAmC;AAC/C,sDAAsD;AACtD,0DAA0D;AAC1D,6DAA6D;AAC7D;AACA;AACA,WAAW,iBAAiB;AAC5B,YAAY,KAAK;AACjB;AACA;AACA;AACA,oDAAoD;AACpD;AACA,WAAW;AACX,aAAa,KAAK;AAClB,wDAAwD;AACxD,gGAAgG;AAChG,YAAY,KAAK;AACjB,qEAAqE;AACrE,YAAY;AACZ;AACA,oEAAoE;AACpE,wDAAwD;AACxD;AACA,yDAAyD;AACzD;AACA;AACA;AACA;AACA;;AAEA,iBAAiB;;AAEjB;AACA,qCAAqC;AACrC,sDAAsD;AACtD,YAAY;;AAEZ;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,gEAAgE;AAChE,OAAO;AACP,uDAAuD;AACvD;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA,0DAA0D;AAC1D;AACA;AACA,sBAAsB;AACtB,2EAA2E;AAC3E;AACA;AACA,6DAA6D;AAC7D;AACA,YAAY,KAAK;AACjB,yDAAyD;AACzD;AACA,oEAAoE;AACpE;AACA;AACA,QAAQ;AACR,0CAA0C;AAC1C;AACA,cAAc;AACd;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA,yDAAyD;AACzD;AACA;AACA,aAAa,SAAS,MAAM;AAC5B,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,wDAAwD;AACxD,yDAAyD;AACzD,oDAAoD;AACpD,SAAS;AACT;AACA,wDAAwD;AACxD,oDAAoD;AACpD;AACA;AACA,KAAK;AACL;AACA,yCAAyC;AACzC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C,WAAW;AACX,4CAA4C;AAC5C;AACA,SAAS;AACT;AACA,2CAA2C;AAC3C,4CAA4C;AAC5C;AACA,0DAA0D;AAC1D,OAAO;AACP;AACA;AACA,0DAA0D;AAC1D;AACA;AACA,WAAW,SAAS,MAAM;AAC1B,OAAO;AACP;AACA,0DAA0D;AAC1D,sDAAsD;AACtD;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,6CAA6C;AAC7C;AACA,qDAAqD;AACrD,OAAO;AACP,+BAA+B;AAC/B;AACA;AACA;AACA;AACA,oEAAoE;AACpE,SAAS;AACT,iDAAiD;AACjD;AACA;AACA;;AAEA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB,SAAS;AACT,oCAAoC;AACpC;AACA;AACA;;AAEA;AACA;AACA,iDAAiD;AACjD,qDAAqD;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,iCAAiC,YAAY;AAC7C;AACA;AACA,sCAAsC,UAAU;AAChD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qCAAqC;AACrC,yDAAyD;;AAEzD;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,aAAa;AACb,wEAAwE;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,qCAAqC;AACrC,qCAAqC;AACrC;AACA,+DAA+D;AAC/D,WAAW;AACX,YAAY;;AAEZ;AACA;AACA;AACA,uDAAuD;AACvD,kFAAkF;AAClF,8CAA8C;AAC9C;AACA;;AAEA;AACA;AACA,oCAAoC;AACpC,yDAAyD;AACzD,iCAAiC;AACjC,YAAY;AACZ;AACA,WAAW,iBAAiB;AAC5B,sEAAsE;AACtE;AACA,qEAAqE;AACrE,WAAW;AACX,YAAY;AACZ;;AAEA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP,4DAA4D;AAC5D;AACA,gBAAgB,KAAK;AACrB;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA,mBAAmB,qBAAqB;AACxC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E;AAC1E,6CAA6C;AAC7C,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,iDAAiD;AACjD,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kEAAkE;AAClE,wCAAwC;AACxC,YAAY;AACZ,OAAO;AACP;AACA;AACA,sEAAsE;AACtE,wCAAwC;AACxC,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA,iEAAiE;AACjE,qCAAqC;AACrC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,OAAO;AACP;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA,eAAe;AACf;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,8FAA8F;AAC9F;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,6BAA6B;AAC7B,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;;AAEA;AACA;AACA,oDAAoD;AACpD;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA,kBAAkB,KAAK;AACvB;AACA,kBAAkB;AAClB,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;;AAEA;AACA,oEAAoE;AACpE;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA,kBAAkB,KAAK;AACvB;AACA,kBAAkB;AAClB,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA,qCAAqC;AACrC;AACA,gBAAgB,2BAA2B;AAC3C;AACA,gBAAgB;AAChB,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4EAA4E;AAC5E,OAAO;AACP,sEAAsE;AACtE;AACA,KAAK;AACL,0CAA0C;AAC1C;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,4DAA4D;;AAE5D;AACA;AACA,KAAK;AACL,0CAA0C;AAC1C,wCAAwC;AACxC;AACA;AACA;AACA;AACA,6CAA6C;AAC7C;AACA;AACA;AACA;AACA,aAAa,oBAAoB;AACjC,yCAAyC;AACzC;;AAEA;AACA,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,4BAA4B,+BAA+B,kBAAkB;AAC7E,+CAA+C;AAC/C;AACA,QAAQ;AACR;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wCAAwC;AACxC;AACA;AACA;AACA;AACA,2DAA2D;AAC3D,gCAAgC;AAChC;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,oEAAoE;AACpE,KAAK;AACL;AACA;AACA;AACA;AACA,kFAAkF;AAClF,WAAW;AACX;AACA,kFAAkF;AAClF;AACA,SAAS;AACT;AACA,yEAAyE;AACzE;AACA,OAAO;AACP,6CAA6C;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,+DAA+D;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,6CAA6C;AAC7C,2CAA2C;AAC3C;AACA;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,8CAA8C;AAC9C;AACA;;AAEA;AACA,6CAA6C;AAC7C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA,KAAK;;AAEL;;AAEA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wCAAwC;AACxC,6CAA6C;AAC7C;;AAEA,6DAA6D;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,0CAA0C;;AAE1C;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,yFAAyF;AACzF;AACA,qBAAqB,0BAA0B;AAC/C;AACA;AACA;AACA,iDAAiD;AACjD;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA,kDAAkD;AAClD;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA,0CAA0C;AAC1C,iEAAiE;;AAEjE;AACA;AACA;AACA;AACA,8BAA8B;AAC9B,kCAAkC,KAAK;AACvC,mCAAmC;AACnC,iDAAiD;AACjD;AACA;AACA,2DAA2D;AAC3D;AACA,YAAY;AACZ,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA,oEAAoE;AACpE,aAAa;AACb;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA,cAAc;AACd,SAAS;AACT;AACA;AACA;AACA,qBAAqB;AACrB,mDAAmD;AACnD;AACA,4CAA4C;AAC5C;AACA,cAAc;AACd;AACA;AACA,OAAO;;AAEP;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,2BAA2B;AAC1C;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,yCAAyC,QAAQ;AACjD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C,IAAI;AAClD,2DAA2D,IAAI;;AAE/D;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,yBAAyB,kBAAkB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA,uDAAuD;AACvD,yDAAyD;AACzD,6DAA6D;AAC7D;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,qBAAqB,UAAU;AAC/B;AACA;AACA,SAAS;AACT,qBAAqB,iBAAiB;AACtC;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B;AACA;AACA,WAAW;AACX;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B;;AAE7B;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;;AAEA;AACA;;AAEA;;AAEA,CAAC;AACD;;;;;;;;AC5+Ta;;AAEb,iBAAiB,mBAAO,CAAC,EAAa;;AAEtC;AACA;;AAEA;AACA;;AAEA,mCAAmC,SAAS;AAC5C;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;AC5BA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA","file":"scripts/dist/bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 16);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 387feb8eadb9c5b23992","/*\n * JavaScript MD5\n * https://github.com/blueimp/JavaScript-MD5\n *\n * Copyright 2011, Sebastian Tschan\n * https://blueimp.net\n *\n * Licensed under the MIT license:\n * https://opensource.org/licenses/MIT\n *\n * Based on\n * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message\n * Digest Algorithm, as defined in RFC 1321.\n * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for more info.\n */\n\n/* global define */\n\n;(function ($) {\n 'use strict'\n\n /*\n * Add integers, wrapping at 2^32. This uses 16-bit operations internally\n * to work around bugs in some JS interpreters.\n */\n function safeAdd (x, y) {\n var lsw = (x & 0xFFFF) + (y & 0xFFFF)\n var msw = (x >> 16) + (y >> 16) + (lsw >> 16)\n return (msw << 16) | (lsw & 0xFFFF)\n }\n\n /*\n * Bitwise rotate a 32-bit number to the left.\n */\n function bitRotateLeft (num, cnt) {\n return (num << cnt) | (num >>> (32 - cnt))\n }\n\n /*\n * These functions implement the four basic operations the algorithm uses.\n */\n function md5cmn (q, a, b, x, s, t) {\n return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)\n }\n function md5ff (a, b, c, d, x, s, t) {\n return md5cmn((b & c) | ((~b) & d), a, b, x, s, t)\n }\n function md5gg (a, b, c, d, x, s, t) {\n return md5cmn((b & d) | (c & (~d)), a, b, x, s, t)\n }\n function md5hh (a, b, c, d, x, s, t) {\n return md5cmn(b ^ c ^ d, a, b, x, s, t)\n }\n function md5ii (a, b, c, d, x, s, t) {\n return md5cmn(c ^ (b | (~d)), a, b, x, s, t)\n }\n\n /*\n * Calculate the MD5 of an array of little-endian words, and a bit length.\n */\n function binlMD5 (x, len) {\n /* append padding */\n x[len >> 5] |= 0x80 << (len % 32)\n x[(((len + 64) >>> 9) << 4) + 14] = len\n\n var i\n var olda\n var oldb\n var oldc\n var oldd\n var a = 1732584193\n var b = -271733879\n var c = -1732584194\n var d = 271733878\n\n for (i = 0; i < x.length; i += 16) {\n olda = a\n oldb = b\n oldc = c\n oldd = d\n\n a = md5ff(a, b, c, d, x[i], 7, -680876936)\n d = md5ff(d, a, b, c, x[i + 1], 12, -389564586)\n c = md5ff(c, d, a, b, x[i + 2], 17, 606105819)\n b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330)\n a = md5ff(a, b, c, d, x[i + 4], 7, -176418897)\n d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426)\n c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341)\n b = md5ff(b, c, d, a, x[i + 7], 22, -45705983)\n a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416)\n d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417)\n c = md5ff(c, d, a, b, x[i + 10], 17, -42063)\n b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162)\n a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682)\n d = md5ff(d, a, b, c, x[i + 13], 12, -40341101)\n c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290)\n b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329)\n\n a = md5gg(a, b, c, d, x[i + 1], 5, -165796510)\n d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632)\n c = md5gg(c, d, a, b, x[i + 11], 14, 643717713)\n b = md5gg(b, c, d, a, x[i], 20, -373897302)\n a = md5gg(a, b, c, d, x[i + 5], 5, -701558691)\n d = md5gg(d, a, b, c, x[i + 10], 9, 38016083)\n c = md5gg(c, d, a, b, x[i + 15], 14, -660478335)\n b = md5gg(b, c, d, a, x[i + 4], 20, -405537848)\n a = md5gg(a, b, c, d, x[i + 9], 5, 568446438)\n d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690)\n c = md5gg(c, d, a, b, x[i + 3], 14, -187363961)\n b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501)\n a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467)\n d = md5gg(d, a, b, c, x[i + 2], 9, -51403784)\n c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473)\n b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734)\n\n a = md5hh(a, b, c, d, x[i + 5], 4, -378558)\n d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463)\n c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562)\n b = md5hh(b, c, d, a, x[i + 14], 23, -35309556)\n a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060)\n d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353)\n c = md5hh(c, d, a, b, x[i + 7], 16, -155497632)\n b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640)\n a = md5hh(a, b, c, d, x[i + 13], 4, 681279174)\n d = md5hh(d, a, b, c, x[i], 11, -358537222)\n c = md5hh(c, d, a, b, x[i + 3], 16, -722521979)\n b = md5hh(b, c, d, a, x[i + 6], 23, 76029189)\n a = md5hh(a, b, c, d, x[i + 9], 4, -640364487)\n d = md5hh(d, a, b, c, x[i + 12], 11, -421815835)\n c = md5hh(c, d, a, b, x[i + 15], 16, 530742520)\n b = md5hh(b, c, d, a, x[i + 2], 23, -995338651)\n\n a = md5ii(a, b, c, d, x[i], 6, -198630844)\n d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415)\n c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905)\n b = md5ii(b, c, d, a, x[i + 5], 21, -57434055)\n a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571)\n d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606)\n c = md5ii(c, d, a, b, x[i + 10], 15, -1051523)\n b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799)\n a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359)\n d = md5ii(d, a, b, c, x[i + 15], 10, -30611744)\n c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380)\n b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649)\n a = md5ii(a, b, c, d, x[i + 4], 6, -145523070)\n d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379)\n c = md5ii(c, d, a, b, x[i + 2], 15, 718787259)\n b = md5ii(b, c, d, a, x[i + 9], 21, -343485551)\n\n a = safeAdd(a, olda)\n b = safeAdd(b, oldb)\n c = safeAdd(c, oldc)\n d = safeAdd(d, oldd)\n }\n return [a, b, c, d]\n }\n\n /*\n * Convert an array of little-endian words to a string\n */\n function binl2rstr (input) {\n var i\n var output = ''\n var length32 = input.length * 32\n for (i = 0; i < length32; i += 8) {\n output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF)\n }\n return output\n }\n\n /*\n * Convert a raw string to an array of little-endian words\n * Characters >255 have their high-byte silently ignored.\n */\n function rstr2binl (input) {\n var i\n var output = []\n output[(input.length >> 2) - 1] = undefined\n for (i = 0; i < output.length; i += 1) {\n output[i] = 0\n }\n var length8 = input.length * 8\n for (i = 0; i < length8; i += 8) {\n output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32)\n }\n return output\n }\n\n /*\n * Calculate the MD5 of a raw string\n */\n function rstrMD5 (s) {\n return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))\n }\n\n /*\n * Calculate the HMAC-MD5, of a key and some data (raw strings)\n */\n function rstrHMACMD5 (key, data) {\n var i\n var bkey = rstr2binl(key)\n var ipad = []\n var opad = []\n var hash\n ipad[15] = opad[15] = undefined\n if (bkey.length > 16) {\n bkey = binlMD5(bkey, key.length * 8)\n }\n for (i = 0; i < 16; i += 1) {\n ipad[i] = bkey[i] ^ 0x36363636\n opad[i] = bkey[i] ^ 0x5C5C5C5C\n }\n hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8)\n return binl2rstr(binlMD5(opad.concat(hash), 512 + 128))\n }\n\n /*\n * Convert a raw string to a hex string\n */\n function rstr2hex (input) {\n var hexTab = '0123456789abcdef'\n var output = ''\n var x\n var i\n for (i = 0; i < input.length; i += 1) {\n x = input.charCodeAt(i)\n output += hexTab.charAt((x >>> 4) & 0x0F) +\n hexTab.charAt(x & 0x0F)\n }\n return output\n }\n\n /*\n * Encode a string as utf-8\n */\n function str2rstrUTF8 (input) {\n return unescape(encodeURIComponent(input))\n }\n\n /*\n * Take string arguments and return either raw or hex encoded strings\n */\n function rawMD5 (s) {\n return rstrMD5(str2rstrUTF8(s))\n }\n function hexMD5 (s) {\n return rstr2hex(rawMD5(s))\n }\n function rawHMACMD5 (k, d) {\n return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d))\n }\n function hexHMACMD5 (k, d) {\n return rstr2hex(rawHMACMD5(k, d))\n }\n\n function md5 (string, key, raw) {\n if (!key) {\n if (!raw) {\n return hexMD5(string)\n }\n return rawMD5(string)\n }\n if (!raw) {\n return hexHMACMD5(key, string)\n }\n return rawHMACMD5(key, string)\n }\n\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return md5\n })\n } else if (typeof module === 'object' && module.exports) {\n module.exports = md5\n } else {\n $.md5 = md5\n }\n}(this))\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/md5.js\n// module id = 1\n// module chunks = 0","/* MIT license */\nvar cssKeywords = require('color-name');\n\n// NOTE: conversions should only return primitive values (i.e. arrays, or\n// values that give correct `typeof` results).\n// do not use box values types (i.e. Number(), String(), etc.)\n\nvar reverseKeywords = {};\nfor (var key in cssKeywords) {\n\tif (cssKeywords.hasOwnProperty(key)) {\n\t\treverseKeywords[cssKeywords[key]] = key;\n\t}\n}\n\nvar convert = module.exports = {\n\trgb: {channels: 3, labels: 'rgb'},\n\thsl: {channels: 3, labels: 'hsl'},\n\thsv: {channels: 3, labels: 'hsv'},\n\thwb: {channels: 3, labels: 'hwb'},\n\tcmyk: {channels: 4, labels: 'cmyk'},\n\txyz: {channels: 3, labels: 'xyz'},\n\tlab: {channels: 3, labels: 'lab'},\n\tlch: {channels: 3, labels: 'lch'},\n\thex: {channels: 1, labels: ['hex']},\n\tkeyword: {channels: 1, labels: ['keyword']},\n\tansi16: {channels: 1, labels: ['ansi16']},\n\tansi256: {channels: 1, labels: ['ansi256']},\n\thcg: {channels: 3, labels: ['h', 'c', 'g']},\n\tapple: {channels: 3, labels: ['r16', 'g16', 'b16']},\n\tgray: {channels: 1, labels: ['gray']}\n};\n\n// hide .channels and .labels properties\nfor (var model in convert) {\n\tif (convert.hasOwnProperty(model)) {\n\t\tif (!('channels' in convert[model])) {\n\t\t\tthrow new Error('missing channels property: ' + model);\n\t\t}\n\n\t\tif (!('labels' in convert[model])) {\n\t\t\tthrow new Error('missing channel labels property: ' + model);\n\t\t}\n\n\t\tif (convert[model].labels.length !== convert[model].channels) {\n\t\t\tthrow new Error('channel and label counts mismatch: ' + model);\n\t\t}\n\n\t\tvar channels = convert[model].channels;\n\t\tvar labels = convert[model].labels;\n\t\tdelete convert[model].channels;\n\t\tdelete convert[model].labels;\n\t\tObject.defineProperty(convert[model], 'channels', {value: channels});\n\t\tObject.defineProperty(convert[model], 'labels', {value: labels});\n\t}\n}\n\nconvert.rgb.hsl = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar min = Math.min(r, g, b);\n\tvar max = Math.max(r, g, b);\n\tvar delta = max - min;\n\tvar h;\n\tvar s;\n\tvar l;\n\n\tif (max === min) {\n\t\th = 0;\n\t} else if (r === max) {\n\t\th = (g - b) / delta;\n\t} else if (g === max) {\n\t\th = 2 + (b - r) / delta;\n\t} else if (b === max) {\n\t\th = 4 + (r - g) / delta;\n\t}\n\n\th = Math.min(h * 60, 360);\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tl = (min + max) / 2;\n\n\tif (max === min) {\n\t\ts = 0;\n\t} else if (l <= 0.5) {\n\t\ts = delta / (max + min);\n\t} else {\n\t\ts = delta / (2 - max - min);\n\t}\n\n\treturn [h, s * 100, l * 100];\n};\n\nconvert.rgb.hsv = function (rgb) {\n\tvar rdif;\n\tvar gdif;\n\tvar bdif;\n\tvar h;\n\tvar s;\n\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar v = Math.max(r, g, b);\n\tvar diff = v - Math.min(r, g, b);\n\tvar diffc = function (c) {\n\t\treturn (v - c) / 6 / diff + 1 / 2;\n\t};\n\n\tif (diff === 0) {\n\t\th = s = 0;\n\t} else {\n\t\ts = diff / v;\n\t\trdif = diffc(r);\n\t\tgdif = diffc(g);\n\t\tbdif = diffc(b);\n\n\t\tif (r === v) {\n\t\t\th = bdif - gdif;\n\t\t} else if (g === v) {\n\t\t\th = (1 / 3) + rdif - bdif;\n\t\t} else if (b === v) {\n\t\t\th = (2 / 3) + gdif - rdif;\n\t\t}\n\t\tif (h < 0) {\n\t\t\th += 1;\n\t\t} else if (h > 1) {\n\t\t\th -= 1;\n\t\t}\n\t}\n\n\treturn [\n\t\th * 360,\n\t\ts * 100,\n\t\tv * 100\n\t];\n};\n\nconvert.rgb.hwb = function (rgb) {\n\tvar r = rgb[0];\n\tvar g = rgb[1];\n\tvar b = rgb[2];\n\tvar h = convert.rgb.hsl(rgb)[0];\n\tvar w = 1 / 255 * Math.min(r, Math.min(g, b));\n\n\tb = 1 - 1 / 255 * Math.max(r, Math.max(g, b));\n\n\treturn [h, w * 100, b * 100];\n};\n\nconvert.rgb.cmyk = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar c;\n\tvar m;\n\tvar y;\n\tvar k;\n\n\tk = Math.min(1 - r, 1 - g, 1 - b);\n\tc = (1 - r - k) / (1 - k) || 0;\n\tm = (1 - g - k) / (1 - k) || 0;\n\ty = (1 - b - k) / (1 - k) || 0;\n\n\treturn [c * 100, m * 100, y * 100, k * 100];\n};\n\n/**\n * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance\n * */\nfunction comparativeDistance(x, y) {\n\treturn (\n\t\tMath.pow(x[0] - y[0], 2) +\n\t\tMath.pow(x[1] - y[1], 2) +\n\t\tMath.pow(x[2] - y[2], 2)\n\t);\n}\n\nconvert.rgb.keyword = function (rgb) {\n\tvar reversed = reverseKeywords[rgb];\n\tif (reversed) {\n\t\treturn reversed;\n\t}\n\n\tvar currentClosestDistance = Infinity;\n\tvar currentClosestKeyword;\n\n\tfor (var keyword in cssKeywords) {\n\t\tif (cssKeywords.hasOwnProperty(keyword)) {\n\t\t\tvar value = cssKeywords[keyword];\n\n\t\t\t// Compute comparative distance\n\t\t\tvar distance = comparativeDistance(rgb, value);\n\n\t\t\t// Check if its less, if so set as closest\n\t\t\tif (distance < currentClosestDistance) {\n\t\t\t\tcurrentClosestDistance = distance;\n\t\t\t\tcurrentClosestKeyword = keyword;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn currentClosestKeyword;\n};\n\nconvert.keyword.rgb = function (keyword) {\n\treturn cssKeywords[keyword];\n};\n\nconvert.rgb.xyz = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\n\t// assume sRGB\n\tr = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n\tvar x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n\tvar y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n\tvar z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n\n\treturn [x * 100, y * 100, z * 100];\n};\n\nconvert.rgb.lab = function (rgb) {\n\tvar xyz = convert.rgb.xyz(rgb);\n\tvar x = xyz[0];\n\tvar y = xyz[1];\n\tvar z = xyz[2];\n\tvar l;\n\tvar a;\n\tvar b;\n\n\tx /= 95.047;\n\ty /= 100;\n\tz /= 108.883;\n\n\tx = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);\n\ty = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);\n\tz = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);\n\n\tl = (116 * y) - 16;\n\ta = 500 * (x - y);\n\tb = 200 * (y - z);\n\n\treturn [l, a, b];\n};\n\nconvert.hsl.rgb = function (hsl) {\n\tvar h = hsl[0] / 360;\n\tvar s = hsl[1] / 100;\n\tvar l = hsl[2] / 100;\n\tvar t1;\n\tvar t2;\n\tvar t3;\n\tvar rgb;\n\tvar val;\n\n\tif (s === 0) {\n\t\tval = l * 255;\n\t\treturn [val, val, val];\n\t}\n\n\tif (l < 0.5) {\n\t\tt2 = l * (1 + s);\n\t} else {\n\t\tt2 = l + s - l * s;\n\t}\n\n\tt1 = 2 * l - t2;\n\n\trgb = [0, 0, 0];\n\tfor (var i = 0; i < 3; i++) {\n\t\tt3 = h + 1 / 3 * -(i - 1);\n\t\tif (t3 < 0) {\n\t\t\tt3++;\n\t\t}\n\t\tif (t3 > 1) {\n\t\t\tt3--;\n\t\t}\n\n\t\tif (6 * t3 < 1) {\n\t\t\tval = t1 + (t2 - t1) * 6 * t3;\n\t\t} else if (2 * t3 < 1) {\n\t\t\tval = t2;\n\t\t} else if (3 * t3 < 2) {\n\t\t\tval = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n\t\t} else {\n\t\t\tval = t1;\n\t\t}\n\n\t\trgb[i] = val * 255;\n\t}\n\n\treturn rgb;\n};\n\nconvert.hsl.hsv = function (hsl) {\n\tvar h = hsl[0];\n\tvar s = hsl[1] / 100;\n\tvar l = hsl[2] / 100;\n\tvar smin = s;\n\tvar lmin = Math.max(l, 0.01);\n\tvar sv;\n\tvar v;\n\n\tl *= 2;\n\ts *= (l <= 1) ? l : 2 - l;\n\tsmin *= lmin <= 1 ? lmin : 2 - lmin;\n\tv = (l + s) / 2;\n\tsv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);\n\n\treturn [h, sv * 100, v * 100];\n};\n\nconvert.hsv.rgb = function (hsv) {\n\tvar h = hsv[0] / 60;\n\tvar s = hsv[1] / 100;\n\tvar v = hsv[2] / 100;\n\tvar hi = Math.floor(h) % 6;\n\n\tvar f = h - Math.floor(h);\n\tvar p = 255 * v * (1 - s);\n\tvar q = 255 * v * (1 - (s * f));\n\tvar t = 255 * v * (1 - (s * (1 - f)));\n\tv *= 255;\n\n\tswitch (hi) {\n\t\tcase 0:\n\t\t\treturn [v, t, p];\n\t\tcase 1:\n\t\t\treturn [q, v, p];\n\t\tcase 2:\n\t\t\treturn [p, v, t];\n\t\tcase 3:\n\t\t\treturn [p, q, v];\n\t\tcase 4:\n\t\t\treturn [t, p, v];\n\t\tcase 5:\n\t\t\treturn [v, p, q];\n\t}\n};\n\nconvert.hsv.hsl = function (hsv) {\n\tvar h = hsv[0];\n\tvar s = hsv[1] / 100;\n\tvar v = hsv[2] / 100;\n\tvar vmin = Math.max(v, 0.01);\n\tvar lmin;\n\tvar sl;\n\tvar l;\n\n\tl = (2 - s) * v;\n\tlmin = (2 - s) * vmin;\n\tsl = s * vmin;\n\tsl /= (lmin <= 1) ? lmin : 2 - lmin;\n\tsl = sl || 0;\n\tl /= 2;\n\n\treturn [h, sl * 100, l * 100];\n};\n\n// http://dev.w3.org/csswg/css-color/#hwb-to-rgb\nconvert.hwb.rgb = function (hwb) {\n\tvar h = hwb[0] / 360;\n\tvar wh = hwb[1] / 100;\n\tvar bl = hwb[2] / 100;\n\tvar ratio = wh + bl;\n\tvar i;\n\tvar v;\n\tvar f;\n\tvar n;\n\n\t// wh + bl cant be > 1\n\tif (ratio > 1) {\n\t\twh /= ratio;\n\t\tbl /= ratio;\n\t}\n\n\ti = Math.floor(6 * h);\n\tv = 1 - bl;\n\tf = 6 * h - i;\n\n\tif ((i & 0x01) !== 0) {\n\t\tf = 1 - f;\n\t}\n\n\tn = wh + f * (v - wh); // linear interpolation\n\n\tvar r;\n\tvar g;\n\tvar b;\n\tswitch (i) {\n\t\tdefault:\n\t\tcase 6:\n\t\tcase 0: r = v; g = n; b = wh; break;\n\t\tcase 1: r = n; g = v; b = wh; break;\n\t\tcase 2: r = wh; g = v; b = n; break;\n\t\tcase 3: r = wh; g = n; b = v; break;\n\t\tcase 4: r = n; g = wh; b = v; break;\n\t\tcase 5: r = v; g = wh; b = n; break;\n\t}\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.cmyk.rgb = function (cmyk) {\n\tvar c = cmyk[0] / 100;\n\tvar m = cmyk[1] / 100;\n\tvar y = cmyk[2] / 100;\n\tvar k = cmyk[3] / 100;\n\tvar r;\n\tvar g;\n\tvar b;\n\n\tr = 1 - Math.min(1, c * (1 - k) + k);\n\tg = 1 - Math.min(1, m * (1 - k) + k);\n\tb = 1 - Math.min(1, y * (1 - k) + k);\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.xyz.rgb = function (xyz) {\n\tvar x = xyz[0] / 100;\n\tvar y = xyz[1] / 100;\n\tvar z = xyz[2] / 100;\n\tvar r;\n\tvar g;\n\tvar b;\n\n\tr = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n\tg = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n\tb = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n\t// assume sRGB\n\tr = r > 0.0031308\n\t\t? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)\n\t\t: r * 12.92;\n\n\tg = g > 0.0031308\n\t\t? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)\n\t\t: g * 12.92;\n\n\tb = b > 0.0031308\n\t\t? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)\n\t\t: b * 12.92;\n\n\tr = Math.min(Math.max(0, r), 1);\n\tg = Math.min(Math.max(0, g), 1);\n\tb = Math.min(Math.max(0, b), 1);\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.xyz.lab = function (xyz) {\n\tvar x = xyz[0];\n\tvar y = xyz[1];\n\tvar z = xyz[2];\n\tvar l;\n\tvar a;\n\tvar b;\n\n\tx /= 95.047;\n\ty /= 100;\n\tz /= 108.883;\n\n\tx = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);\n\ty = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);\n\tz = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);\n\n\tl = (116 * y) - 16;\n\ta = 500 * (x - y);\n\tb = 200 * (y - z);\n\n\treturn [l, a, b];\n};\n\nconvert.lab.xyz = function (lab) {\n\tvar l = lab[0];\n\tvar a = lab[1];\n\tvar b = lab[2];\n\tvar x;\n\tvar y;\n\tvar z;\n\n\ty = (l + 16) / 116;\n\tx = a / 500 + y;\n\tz = y - b / 200;\n\n\tvar y2 = Math.pow(y, 3);\n\tvar x2 = Math.pow(x, 3);\n\tvar z2 = Math.pow(z, 3);\n\ty = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;\n\tx = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;\n\tz = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;\n\n\tx *= 95.047;\n\ty *= 100;\n\tz *= 108.883;\n\n\treturn [x, y, z];\n};\n\nconvert.lab.lch = function (lab) {\n\tvar l = lab[0];\n\tvar a = lab[1];\n\tvar b = lab[2];\n\tvar hr;\n\tvar h;\n\tvar c;\n\n\thr = Math.atan2(b, a);\n\th = hr * 360 / 2 / Math.PI;\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tc = Math.sqrt(a * a + b * b);\n\n\treturn [l, c, h];\n};\n\nconvert.lch.lab = function (lch) {\n\tvar l = lch[0];\n\tvar c = lch[1];\n\tvar h = lch[2];\n\tvar a;\n\tvar b;\n\tvar hr;\n\n\thr = h / 360 * 2 * Math.PI;\n\ta = c * Math.cos(hr);\n\tb = c * Math.sin(hr);\n\n\treturn [l, a, b];\n};\n\nconvert.rgb.ansi16 = function (args) {\n\tvar r = args[0];\n\tvar g = args[1];\n\tvar b = args[2];\n\tvar value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization\n\n\tvalue = Math.round(value / 50);\n\n\tif (value === 0) {\n\t\treturn 30;\n\t}\n\n\tvar ansi = 30\n\t\t+ ((Math.round(b / 255) << 2)\n\t\t| (Math.round(g / 255) << 1)\n\t\t| Math.round(r / 255));\n\n\tif (value === 2) {\n\t\tansi += 60;\n\t}\n\n\treturn ansi;\n};\n\nconvert.hsv.ansi16 = function (args) {\n\t// optimization here; we already know the value and don't need to get\n\t// it converted for us.\n\treturn convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);\n};\n\nconvert.rgb.ansi256 = function (args) {\n\tvar r = args[0];\n\tvar g = args[1];\n\tvar b = args[2];\n\n\t// we use the extended greyscale palette here, with the exception of\n\t// black and white. normal palette only has 4 greyscale shades.\n\tif (r === g && g === b) {\n\t\tif (r < 8) {\n\t\t\treturn 16;\n\t\t}\n\n\t\tif (r > 248) {\n\t\t\treturn 231;\n\t\t}\n\n\t\treturn Math.round(((r - 8) / 247) * 24) + 232;\n\t}\n\n\tvar ansi = 16\n\t\t+ (36 * Math.round(r / 255 * 5))\n\t\t+ (6 * Math.round(g / 255 * 5))\n\t\t+ Math.round(b / 255 * 5);\n\n\treturn ansi;\n};\n\nconvert.ansi16.rgb = function (args) {\n\tvar color = args % 10;\n\n\t// handle greyscale\n\tif (color === 0 || color === 7) {\n\t\tif (args > 50) {\n\t\t\tcolor += 3.5;\n\t\t}\n\n\t\tcolor = color / 10.5 * 255;\n\n\t\treturn [color, color, color];\n\t}\n\n\tvar mult = (~~(args > 50) + 1) * 0.5;\n\tvar r = ((color & 1) * mult) * 255;\n\tvar g = (((color >> 1) & 1) * mult) * 255;\n\tvar b = (((color >> 2) & 1) * mult) * 255;\n\n\treturn [r, g, b];\n};\n\nconvert.ansi256.rgb = function (args) {\n\t// handle greyscale\n\tif (args >= 232) {\n\t\tvar c = (args - 232) * 10 + 8;\n\t\treturn [c, c, c];\n\t}\n\n\targs -= 16;\n\n\tvar rem;\n\tvar r = Math.floor(args / 36) / 5 * 255;\n\tvar g = Math.floor((rem = args % 36) / 6) / 5 * 255;\n\tvar b = (rem % 6) / 5 * 255;\n\n\treturn [r, g, b];\n};\n\nconvert.rgb.hex = function (args) {\n\tvar integer = ((Math.round(args[0]) & 0xFF) << 16)\n\t\t+ ((Math.round(args[1]) & 0xFF) << 8)\n\t\t+ (Math.round(args[2]) & 0xFF);\n\n\tvar string = integer.toString(16).toUpperCase();\n\treturn '000000'.substring(string.length) + string;\n};\n\nconvert.hex.rgb = function (args) {\n\tvar match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);\n\tif (!match) {\n\t\treturn [0, 0, 0];\n\t}\n\n\tvar colorString = match[0];\n\n\tif (match[0].length === 3) {\n\t\tcolorString = colorString.split('').map(function (char) {\n\t\t\treturn char + char;\n\t\t}).join('');\n\t}\n\n\tvar integer = parseInt(colorString, 16);\n\tvar r = (integer >> 16) & 0xFF;\n\tvar g = (integer >> 8) & 0xFF;\n\tvar b = integer & 0xFF;\n\n\treturn [r, g, b];\n};\n\nconvert.rgb.hcg = function (rgb) {\n\tvar r = rgb[0] / 255;\n\tvar g = rgb[1] / 255;\n\tvar b = rgb[2] / 255;\n\tvar max = Math.max(Math.max(r, g), b);\n\tvar min = Math.min(Math.min(r, g), b);\n\tvar chroma = (max - min);\n\tvar grayscale;\n\tvar hue;\n\n\tif (chroma < 1) {\n\t\tgrayscale = min / (1 - chroma);\n\t} else {\n\t\tgrayscale = 0;\n\t}\n\n\tif (chroma <= 0) {\n\t\thue = 0;\n\t} else\n\tif (max === r) {\n\t\thue = ((g - b) / chroma) % 6;\n\t} else\n\tif (max === g) {\n\t\thue = 2 + (b - r) / chroma;\n\t} else {\n\t\thue = 4 + (r - g) / chroma + 4;\n\t}\n\n\thue /= 6;\n\thue %= 1;\n\n\treturn [hue * 360, chroma * 100, grayscale * 100];\n};\n\nconvert.hsl.hcg = function (hsl) {\n\tvar s = hsl[1] / 100;\n\tvar l = hsl[2] / 100;\n\tvar c = 1;\n\tvar f = 0;\n\n\tif (l < 0.5) {\n\t\tc = 2.0 * s * l;\n\t} else {\n\t\tc = 2.0 * s * (1.0 - l);\n\t}\n\n\tif (c < 1.0) {\n\t\tf = (l - 0.5 * c) / (1.0 - c);\n\t}\n\n\treturn [hsl[0], c * 100, f * 100];\n};\n\nconvert.hsv.hcg = function (hsv) {\n\tvar s = hsv[1] / 100;\n\tvar v = hsv[2] / 100;\n\n\tvar c = s * v;\n\tvar f = 0;\n\n\tif (c < 1.0) {\n\t\tf = (v - c) / (1 - c);\n\t}\n\n\treturn [hsv[0], c * 100, f * 100];\n};\n\nconvert.hcg.rgb = function (hcg) {\n\tvar h = hcg[0] / 360;\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\n\tif (c === 0.0) {\n\t\treturn [g * 255, g * 255, g * 255];\n\t}\n\n\tvar pure = [0, 0, 0];\n\tvar hi = (h % 1) * 6;\n\tvar v = hi % 1;\n\tvar w = 1 - v;\n\tvar mg = 0;\n\n\tswitch (Math.floor(hi)) {\n\t\tcase 0:\n\t\t\tpure[0] = 1; pure[1] = v; pure[2] = 0; break;\n\t\tcase 1:\n\t\t\tpure[0] = w; pure[1] = 1; pure[2] = 0; break;\n\t\tcase 2:\n\t\t\tpure[0] = 0; pure[1] = 1; pure[2] = v; break;\n\t\tcase 3:\n\t\t\tpure[0] = 0; pure[1] = w; pure[2] = 1; break;\n\t\tcase 4:\n\t\t\tpure[0] = v; pure[1] = 0; pure[2] = 1; break;\n\t\tdefault:\n\t\t\tpure[0] = 1; pure[1] = 0; pure[2] = w;\n\t}\n\n\tmg = (1.0 - c) * g;\n\n\treturn [\n\t\t(c * pure[0] + mg) * 255,\n\t\t(c * pure[1] + mg) * 255,\n\t\t(c * pure[2] + mg) * 255\n\t];\n};\n\nconvert.hcg.hsv = function (hcg) {\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\n\tvar v = c + g * (1.0 - c);\n\tvar f = 0;\n\n\tif (v > 0.0) {\n\t\tf = c / v;\n\t}\n\n\treturn [hcg[0], f * 100, v * 100];\n};\n\nconvert.hcg.hsl = function (hcg) {\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\n\tvar l = g * (1.0 - c) + 0.5 * c;\n\tvar s = 0;\n\n\tif (l > 0.0 && l < 0.5) {\n\t\ts = c / (2 * l);\n\t} else\n\tif (l >= 0.5 && l < 1.0) {\n\t\ts = c / (2 * (1 - l));\n\t}\n\n\treturn [hcg[0], s * 100, l * 100];\n};\n\nconvert.hcg.hwb = function (hcg) {\n\tvar c = hcg[1] / 100;\n\tvar g = hcg[2] / 100;\n\tvar v = c + g * (1.0 - c);\n\treturn [hcg[0], (v - c) * 100, (1 - v) * 100];\n};\n\nconvert.hwb.hcg = function (hwb) {\n\tvar w = hwb[1] / 100;\n\tvar b = hwb[2] / 100;\n\tvar v = 1 - b;\n\tvar c = v - w;\n\tvar g = 0;\n\n\tif (c < 1) {\n\t\tg = (v - c) / (1 - c);\n\t}\n\n\treturn [hwb[0], c * 100, g * 100];\n};\n\nconvert.apple.rgb = function (apple) {\n\treturn [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];\n};\n\nconvert.rgb.apple = function (rgb) {\n\treturn [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];\n};\n\nconvert.gray.rgb = function (args) {\n\treturn [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];\n};\n\nconvert.gray.hsl = convert.gray.hsv = function (args) {\n\treturn [0, 0, args[0]];\n};\n\nconvert.gray.hwb = function (gray) {\n\treturn [0, 100, gray[0]];\n};\n\nconvert.gray.cmyk = function (gray) {\n\treturn [0, 0, 0, gray[0]];\n};\n\nconvert.gray.lab = function (gray) {\n\treturn [gray[0], 0, 0];\n};\n\nconvert.gray.hex = function (gray) {\n\tvar val = Math.round(gray[0] / 100 * 255) & 0xFF;\n\tvar integer = (val << 16) + (val << 8) + val;\n\n\tvar string = integer.toString(16).toUpperCase();\n\treturn '000000'.substring(string.length) + string;\n};\n\nconvert.rgb.gray = function (rgb) {\n\tvar val = (rgb[0] + rgb[1] + rgb[2]) / 3;\n\treturn [val / 255 * 100];\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color-convert/conversions.js\n// module id = 2\n// module chunks = 0","\n/**\n * isArray\n */\n\nvar isArray = Array.isArray;\n\n/**\n * toString\n */\n\nvar str = Object.prototype.toString;\n\n/**\n * Whether or not the given `val`\n * is an array.\n *\n * example:\n *\n * isArray([]);\n * // > true\n * isArray(arguments);\n * // > false\n * isArray('');\n * // > false\n *\n * @param {mixed} val\n * @return {bool}\n */\n\nmodule.exports = isArray || function (val) {\n return !! val && '[object Array]' == str.call(val);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-array/index.js\n// module id = 3\n// module chunks = 0","/*!\n * is-number <https://github.com/jonschlinkert/is-number>\n *\n * Copyright (c) 2014-2015, Jon Schlinkert.\n * Licensed under the MIT License.\n */\n\n'use strict';\n\nvar typeOf = require('kind-of');\n\nmodule.exports = function isNumber(num) {\n var type = typeOf(num);\n\n if (type === 'string') {\n if (!num.trim()) return false;\n } else if (type !== 'number') {\n return false;\n }\n\n return (num - num + 1) >= 0;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-number/index.js\n// module id = 4\n// module chunks = 0","'use strict';\n\nvar strValue = String.prototype.valueOf;\nvar tryStringObject = function tryStringObject(value) {\n\ttry {\n\t\tstrValue.call(value);\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n};\nvar toStr = Object.prototype.toString;\nvar strClass = '[object String]';\nvar hasToStringTag = require('has-tostringtag/shams')();\n\nmodule.exports = function isString(value) {\n\tif (typeof value === 'string') {\n\t\treturn true;\n\t}\n\tif (typeof value !== 'object') {\n\t\treturn false;\n\t}\n\treturn hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-string/index.js\n// module id = 5\n// module chunks = 0","var convert = require('color-convert');\n\nmodule.exports = function (cstr) {\n var m, conv, parts, alpha;\n if (m = /^((?:rgb|hs[lv]|cmyk|xyz|lab)a?)\\s*\\(([^\\)]*)\\)/.exec(cstr)) {\n var name = m[1];\n var base = name.replace(/a$/, '');\n var size = base === 'cmyk' ? 4 : 3;\n conv = convert[base];\n \n parts = m[2].replace(/^\\s+|\\s+$/g, '')\n .split(/\\s*,\\s*/)\n .map(function (x, i) {\n if (/%$/.test(x) && i === size) {\n return parseFloat(x) / 100;\n }\n else if (/%$/.test(x)) {\n return parseFloat(x);\n }\n return parseFloat(x);\n })\n ;\n if (name === base) parts.push(1);\n alpha = parts[size] === undefined ? 1 : parts[size];\n parts = parts.slice(0, size);\n \n conv[base] = function () { return parts };\n }\n else if (/^#[A-Fa-f0-9]+$/.test(cstr)) {\n var base = cstr.replace(/^#/,'');\n var size = base.length;\n conv = convert.rgb;\n parts = base.split(size === 3 ? /(.)/ : /(..)/);\n parts = parts.filter(Boolean)\n .map(function (x) {\n if (size === 3) {\n return parseInt(x + x, 16);\n }\n else {\n return parseInt(x, 16)\n }\n })\n ;\n alpha = 1;\n conv.rgb = function () { return parts };\n if (!parts[0]) parts[0] = 0;\n if (!parts[1]) parts[1] = 0;\n if (!parts[2]) parts[2] = 0;\n }\n else {\n conv = convert.keyword;\n conv.keyword = function () { return cstr };\n parts = cstr;\n alpha = 1;\n }\n \n var res = {\n rgb: undefined,\n hsl: undefined,\n hsv: undefined,\n cmyk: undefined,\n keyword: undefined,\n hex: undefined\n };\n try { res.rgb = conv.rgb(parts) } catch (e) {}\n try { res.hsl = conv.hsl(parts) } catch (e) {}\n try { res.hsv = conv.hsv(parts) } catch (e) {}\n try { res.cmyk = conv.cmyk(parts) } catch (e) {}\n try { res.keyword = conv.keyword(parts) } catch (e) {}\n \n if (res.rgb) res.hex = '#' + res.rgb.map(function (x) {\n var s = x.toString(16);\n if (s.length === 1) return '0' + s;\n return s;\n }).join('');\n \n if (res.rgb) res.rgba = res.rgb.concat(alpha);\n if (res.hsl) res.hsla = res.hsl.concat(alpha);\n if (res.hsv) res.hsva = res.hsv.concat(alpha);\n if (res.cmyk) res.cmyka = res.cmyk.concat(alpha);\n \n return res;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/parse-color/index.js\n// module id = 6\n// module chunks = 0","var parse = require(\"parse-color\");\nvar isnumber = require(\"is-number\");\nvar isstring = require(\"is-string\");\nvar isarray = require(\"is-array\");\nvar convert = require(\"./util/convert\");\nvar layout = require(\"./util/layout\");\nvar texcoord = require(\"./util/texcoord\");\nvar range = require(\"./util/range\");\nvar pixdenticon = require(\"./util/pixdenticon\");\nvar md5 = require(\"./util/md5\");\n\nfunction Pixels(data, textures, opts) {\n if (!(this instanceof Pixels)) return new Pixels(data, textures, opts);\n var self = this;\n opts = opts || {};\n this.opts = opts;\n var num_identicons = 100;\n\n opts.background = opts.background || [ 0.5, 0.5, 0.5 ];\n opts.size = isnumber(opts.size) ? opts.size : 10;\n opts.padding = isnumber(opts.padding) ? opts.padding : 2;\n\n if (isstring(opts.background))\n opts.background = parse(opts.background).rgb.map(function(c) {\n return c / 255;\n });\n\n if (isarray(data[0]) && data[0].length !== 3) {\n opts.rows = data.length;\n opts.columns = data[0].length;\n }\n\n if (!opts.rows || !opts.columns) {\n opts.rows = opts.columns = Math.round(Math.sqrt(data.length));\n }\n\n var width = opts.columns * opts.size + (opts.columns + 1) * opts.padding;\n var height = opts.rows * opts.size + (opts.rows + 1) * opts.padding;\n\n var canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n if (opts.root) opts.root.appendChild(canvas);\n\n var colors = opts.formatted ? data : convert(data);\n var texcoords = texcoord(\n opts.rows,\n opts.columns,\n textures,\n num_identicons\n );\n\n var positions = layout(\n opts.rows,\n opts.columns,\n 2 * opts.padding / width,\n 2 * opts.size / width,\n width / height\n );\n\n var regl = require(\"regl\")(canvas);\n\n var initial_texture = [];\n for (row = 0; row < opts.size; row++) {\n rowdata = []\n for (col = 0; col < opts.size; col++) {\n rowdata.push([255, 255, 255]);\n }\n initial_texture.push(rowdata);\n }\n var salt = $(\"#grid\").data(\"identicon-salt\");\n for (var i = 0; i < num_identicons; i++) {\n texture = new pixdenticon(md5(salt + i), opts.size).render().buffer;\n for (row = 0; row < opts.size; row++) {\n initial_texture.push(texture[row]);\n }\n }\n\n var texture = regl.texture(initial_texture);\n\n var squares = regl({\n vert: `\n precision mediump float;\n attribute vec2 position;\n attribute vec2 texcoords;\n attribute vec3 color;\n varying vec3 vcolor;\n varying vec2 v_texcoords;\n void main() {\n gl_PointSize = float(${opts.size});\n gl_Position = vec4(position.x, position.y, 0.0, 1.0);\n v_texcoords = texcoords;\n vcolor = color;\n }\n `,\n frag: `\n precision mediump float;\n varying vec3 vcolor;\n varying vec2 v_texcoords;\n uniform sampler2D vtexture;\n void main() {\n vec4 texture;\n texture = texture2D(vtexture, v_texcoords);\n gl_FragColor = texture * vec4(vcolor.r, vcolor.g, vcolor.b, 1.0);\n }\n `,\n attributes: { position: regl.prop(\"position\"), texcoords: regl.prop(\"texcoords\"), color: regl.prop(\"color\")},\n primitive: \"triangles\",\n count: colors.length * 6,\n uniforms: { vtexture: texture }\n });\n\n var expanded_colors = [];\n for(var i = 0; i < colors.length; ++i){\n for(var n = 0; n < 6; ++n) {\n expanded_colors.push(colors[i]);\n }\n }\n\n var buffer = { position: regl.buffer(positions), texcoords: regl.buffer(texcoords), color: regl.buffer(expanded_colors)};\n\n var draw = function(positions, texcoords, colors) {\n regl.clear({ color: opts.background.concat([ 1 ]) });\n squares({ position: positions, texcoords: texcoords, color: colors });\n };\n\n draw(buffer.position, buffer.texcoords, buffer.color);\n\n self._buffer = buffer;\n self._draw = draw;\n self._formatted = opts.formatted;\n self.canvas = canvas;\n self.frame = regl.frame;\n}\n\nPixels.prototype.update = function(data, textures) {\n var self = this;\n var colors = self._formatted ? data : convert(data);\n var expanded_colors = [];\n\n for(var i = 0; i < colors.length; ++i){\n for(var n = 0; n < 6; ++n) {\n expanded_colors.push(colors[i]);\n }\n }\n\n var opts = this.opts;\n var num_identicons = 100;\n\n var texcoords = texcoord(\n opts.rows,\n opts.columns,\n textures,\n num_identicons\n );\n\n self._draw(self._buffer.position, self._buffer.texcoords(texcoords), self._buffer.color(expanded_colors));\n};\n\nmodule.exports = Pixels;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/index.js\n// module id = 7\n// module chunks = 0","/**\n * Representation of a game item, which for the moment is limited to a\n * simple Food type.\n */\n\nexport class Item {\n constructor(id, itemId, maturity, remainingUses) {\n this.id = id;\n this.itemId = itemId;\n this.maturity = maturity;\n this.remainingUses = remainingUses;\n\n // XXX Maybe we can avoid this copy of every shared value\n // to every instance, but going with it for now.\n Object.assign(this, settings.item_config[this.itemId]);\n }\n\n /**\n * Calculate a color based on sprite definition and maturity\n */\n get color() {\n let immature, mature;\n\n if (this.sprite.includes(\",\")) {\n [immature, mature] = this.sprite.split(\",\");\n // For now, assume these are hex colors\n } else {\n immature = mature = this.sprite;\n }\n\n return rgbOnScale(\n hexToRgbPercentages(immature),\n hexToRgbPercentages(mature),\n this.maturity\n );\n }\n}\n\n/**\n * Manages Items that sit on the grid.\n *\n * Items currently being carried by a Player are not included.\n * These are instead held by reference in the Play instances,\n * (named `current_item`).\n */\nexport class GridItems {\n constructor() {\n this._itemsByPosition = new Map();\n this._positionsById = new Map();\n }\n\n add(item, position) {\n this._itemsByPosition.set(JSON.stringify(position), item);\n this._positionsById.set(item.id, JSON.stringify(position));\n }\n\n atPosition(position) {\n const key = JSON.stringify(position);\n return this._itemsByPosition.get(key) || null;\n }\n\n positionOf(item) {\n if (this._positionsById.has(item.id)) {\n return JSON.parse(this._positionsById.get(item.id));\n }\n\n return undefined;\n }\n\n remove(position) {\n const item = this.atPosition(position);\n\n if (item) {\n this._itemsByPosition.delete(JSON.stringify(position));\n this._positionsById.delete(item.id);\n }\n }\n\n /**\n * Retrieve pairs of positions and Item objects (like Python's dict.items())\n * @returns Map.prototype[@@iterator] of[position, Item] pairs\n */\n *entries() {\n for (const [itemPosition, currentItem] of this._itemsByPosition.entries()) {\n yield [JSON.parse(itemPosition), currentItem];\n }\n }\n}\n\nfunction hexToRgbPercentages(hexColor) {\n if (hexColor.startsWith(\"#\")) {\n hexColor = hexColor.substring(1);\n }\n\n // Check if the hex color has a valid length (either 3 or 6 characters)\n if (hexColor.length !== 3 && hexColor.length !== 6) {\n throw new Error(\n \"Invalid hex color format. It should be either 3 or 6 characters long.\"\n );\n }\n\n // If the hex color is 3 characters long, expand it to 6 characters by\n // duplicating each character\n if (hexColor.length === 3) {\n hexColor = hexColor\n .split(\"\")\n .map((char) => char + char)\n .join(\"\");\n }\n\n // Convert the hex color to RGB percentage values\n const red = parseInt(hexColor.substring(0, 2), 16) / 255;\n const green = parseInt(hexColor.substring(2, 4), 16) / 255;\n const blue = parseInt(hexColor.substring(4, 6), 16) / 255;\n\n return [red, green, blue];\n}\n\nfunction rgbOnScale(startColor, endColor, percentage) {\n const result = [];\n for (let i = 0; i < 3; i++) {\n result[i] = endColor[i] + percentage * (startColor[i] - endColor[i]);\n }\n\n return result;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/items.js\n// module id = 8\n// module chunks = 0","/**\n * Identicon.js 2.3.1\n * http://github.com/stewartlord/identicon.js\n *\n * PNGLib required for PNG output\n * http://www.xarg.org/download/pnglib.js\n *\n * Copyright 2017, Stewart Lord\n * Released under the BSD license\n * http://www.opensource.org/licenses/bsd-license.php\n */\n\n(function() {\n var PNGlib;\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n PNGlib = require('./pnglib');\n } else {\n PNGlib = window.PNGlib;\n }\n\n var Identicon = function(hash, options){\n if (typeof(hash) !== 'string' || hash.length < 15) {\n throw 'A hash of at least 15 characters is required.';\n }\n\n this.defaults = {\n background: [240, 240, 240, 255],\n margin: 0.08,\n size: 64,\n saturation: 0.7,\n brightness: 0.5,\n format: 'png'\n };\n\n this.options = typeof(options) === 'object' ? options : this.defaults;\n\n // backward compatibility with old constructor (hash, size, margin)\n if (typeof(arguments[1]) === 'number') { this.options.size = arguments[1]; }\n if (arguments[2]) { this.options.margin = arguments[2]; }\n\n this.hash = hash\n this.background = this.options.background || this.defaults.background;\n this.size = this.options.size || this.defaults.size;\n this.format = this.options.format || this.defaults.format;\n this.margin = this.options.margin !== undefined ? this.options.margin : this.defaults.margin;\n\n // foreground defaults to last 7 chars as hue at 70% saturation, 50% brightness\n var hue = parseInt(this.hash.substr(-7), 16) / 0xfffffff;\n var saturation = this.options.saturation || this.defaults.saturation;\n var brightness = this.options.brightness || this.defaults.brightness;\n this.foreground = this.options.foreground || this.hsl2rgb(hue, saturation, brightness);\n };\n\n Identicon.prototype = {\n background: null,\n foreground: null,\n hash: null,\n margin: null,\n size: null,\n format: null,\n\n image: function(){\n return this.isSvg()\n ? new Svg(this.size, this.foreground, this.background)\n : new PNGlib(this.size, this.size, 256);\n },\n\n render: function(){\n var image = this.image(),\n size = this.size,\n baseMargin = Math.floor(size * this.margin),\n cell = Math.floor((size - (baseMargin * 2)) / 5),\n margin = Math.floor((size - cell * 5) / 2),\n bg = image.color.apply(image, this.background),\n fg = image.color.apply(image, this.foreground);\n\n // the first 15 characters of the hash control the pixels (even/odd)\n // they are drawn down the middle first, then mirrored outwards\n var i, color;\n for (i = 0; i < 15; i++) {\n color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg;\n if (i < 5) {\n this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image);\n } else if (i < 10) {\n this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n } else if (i < 15) {\n this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n }\n }\n\n return image;\n },\n\n rectangle: function(x, y, w, h, color, image){\n if (this.isSvg()) {\n image.rectangles.push({x: x, y: y, w: w, h: h, color: color});\n } else {\n var i, j;\n for (i = x; i < x + w; i++) {\n for (j = y; j < y + h; j++) {\n image.buffer[image.index(i, j)] = color;\n }\n }\n }\n },\n\n // adapted from: https://gist.github.com/aemkei/1325937\n hsl2rgb: function(h, s, b){\n h *= 6;\n s = [\n b += s *= b < .5 ? b : 1 - b,\n b - h % 1 * s * 2,\n b -= s *= 2,\n b,\n b + h % 1 * s,\n b + s\n ];\n\n return[\n s[ ~~h % 6 ] * 255, // red\n s[ (h|16) % 6 ] * 255, // green\n s[ (h|8) % 6 ] * 255 // blue\n ];\n },\n\n toString: function(raw){\n // backward compatibility with old toString, default to base64\n if (raw) {\n return this.render().getDump();\n } else {\n return this.render().getBase64();\n }\n },\n\n isSvg: function(){\n return this.format.match(/svg/i)\n }\n };\n\n var Svg = function(size, foreground, background){\n this.size = size;\n this.foreground = this.color.apply(this, foreground);\n this.background = this.color.apply(this, background);\n this.rectangles = [];\n };\n\n Svg.prototype = {\n size: null,\n foreground: null,\n background: null,\n rectangles: null,\n\n color: function(r, g, b, a){\n var values = [r, g, b].map(Math.round);\n values.push((a >= 0) && (a <= 255) ? a/255 : 1);\n return 'rgba(' + values.join(',') + ')';\n },\n\n getDump: function(){\n var i,\n xml,\n rect,\n fg = this.foreground,\n bg = this.background,\n stroke = this.size * 0.005;\n\n xml = \"<svg xmlns='http://www.w3.org/2000/svg'\"\n + \" width='\" + this.size + \"' height='\" + this.size + \"'\"\n + \" style='background-color:\" + bg + \";'>\"\n + \"<g style='fill:\" + fg + \"; stroke:\" + fg + \"; stroke-width:\" + stroke + \";'>\";\n\n for (i = 0; i < this.rectangles.length; i++) {\n rect = this.rectangles[i];\n if (rect.color == bg) continue;\n xml += \"<rect \"\n + \" x='\" + rect.x + \"'\"\n + \" y='\" + rect.y + \"'\"\n + \" width='\" + rect.w + \"'\"\n + \" height='\" + rect.h + \"'\"\n + \"/>\";\n }\n xml += \"</g></svg>\"\n\n return xml;\n },\n\n getBase64: function(){\n return btoa(this.getDump());\n }\n };\n\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n module.exports = Identicon;\n } else {\n window.Identicon = Identicon;\n }\n})();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/identicon.js\n// module id = 9\n// module chunks = 0","'use strict';\n\nvar colorString = require('color-string');\nvar convert = require('color-convert');\n\nvar _slice = [].slice;\n\nvar skippedModels = [\n\t// to be honest, I don't really feel like keyword belongs in color convert, but eh.\n\t'keyword',\n\n\t// gray conflicts with some method names, and has its own method defined.\n\t'gray',\n\n\t// shouldn't really be in color-convert either...\n\t'hex'\n];\n\nvar hashedModelKeys = {};\nObject.keys(convert).forEach(function (model) {\n\thashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model;\n});\n\nvar limiters = {};\n\nfunction Color(obj, model) {\n\tif (!(this instanceof Color)) {\n\t\treturn new Color(obj, model);\n\t}\n\n\tif (model && model in skippedModels) {\n\t\tmodel = null;\n\t}\n\n\tif (model && !(model in convert)) {\n\t\tthrow new Error('Unknown model: ' + model);\n\t}\n\n\tvar i;\n\tvar channels;\n\n\tif (obj == null) { // eslint-disable-line no-eq-null,eqeqeq\n\t\tthis.model = 'rgb';\n\t\tthis.color = [0, 0, 0];\n\t\tthis.valpha = 1;\n\t} else if (obj instanceof Color) {\n\t\tthis.model = obj.model;\n\t\tthis.color = obj.color.slice();\n\t\tthis.valpha = obj.valpha;\n\t} else if (typeof obj === 'string') {\n\t\tvar result = colorString.get(obj);\n\t\tif (result === null) {\n\t\t\tthrow new Error('Unable to parse color from string: ' + obj);\n\t\t}\n\n\t\tthis.model = result.model;\n\t\tchannels = convert[this.model].channels;\n\t\tthis.color = result.value.slice(0, channels);\n\t\tthis.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;\n\t} else if (obj.length) {\n\t\tthis.model = model || 'rgb';\n\t\tchannels = convert[this.model].channels;\n\t\tvar newArr = _slice.call(obj, 0, channels);\n\t\tthis.color = zeroArray(newArr, channels);\n\t\tthis.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;\n\t} else if (typeof obj === 'number') {\n\t\t// this is always RGB - can be converted later on.\n\t\tobj &= 0xFFFFFF;\n\t\tthis.model = 'rgb';\n\t\tthis.color = [\n\t\t\t(obj >> 16) & 0xFF,\n\t\t\t(obj >> 8) & 0xFF,\n\t\t\tobj & 0xFF\n\t\t];\n\t\tthis.valpha = 1;\n\t} else {\n\t\tthis.valpha = 1;\n\n\t\tvar keys = Object.keys(obj);\n\t\tif ('alpha' in obj) {\n\t\t\tkeys.splice(keys.indexOf('alpha'), 1);\n\t\t\tthis.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;\n\t\t}\n\n\t\tvar hashedKeys = keys.sort().join('');\n\t\tif (!(hashedKeys in hashedModelKeys)) {\n\t\t\tthrow new Error('Unable to parse color from object: ' + JSON.stringify(obj));\n\t\t}\n\n\t\tthis.model = hashedModelKeys[hashedKeys];\n\n\t\tvar labels = convert[this.model].labels;\n\t\tvar color = [];\n\t\tfor (i = 0; i < labels.length; i++) {\n\t\t\tcolor.push(obj[labels[i]]);\n\t\t}\n\n\t\tthis.color = zeroArray(color);\n\t}\n\n\t// perform limitations (clamping, etc.)\n\tif (limiters[this.model]) {\n\t\tchannels = convert[this.model].channels;\n\t\tfor (i = 0; i < channels; i++) {\n\t\t\tvar limit = limiters[this.model][i];\n\t\t\tif (limit) {\n\t\t\t\tthis.color[i] = limit(this.color[i]);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.valpha = Math.max(0, Math.min(1, this.valpha));\n\n\tif (Object.freeze) {\n\t\tObject.freeze(this);\n\t}\n}\n\nColor.prototype = {\n\ttoString: function () {\n\t\treturn this.string();\n\t},\n\n\ttoJSON: function () {\n\t\treturn this[this.model]();\n\t},\n\n\tstring: function (places) {\n\t\tvar self = this.model in colorString.to ? this : this.rgb();\n\t\tself = self.round(typeof places === 'number' ? places : 1);\n\t\tvar args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);\n\t\treturn colorString.to[self.model](args);\n\t},\n\n\tpercentString: function (places) {\n\t\tvar self = this.rgb().round(typeof places === 'number' ? places : 1);\n\t\tvar args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);\n\t\treturn colorString.to.rgb.percent(args);\n\t},\n\n\tarray: function () {\n\t\treturn this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);\n\t},\n\n\tobject: function () {\n\t\tvar result = {};\n\t\tvar channels = convert[this.model].channels;\n\t\tvar labels = convert[this.model].labels;\n\n\t\tfor (var i = 0; i < channels; i++) {\n\t\t\tresult[labels[i]] = this.color[i];\n\t\t}\n\n\t\tif (this.valpha !== 1) {\n\t\t\tresult.alpha = this.valpha;\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tunitArray: function () {\n\t\tvar rgb = this.rgb().color;\n\t\trgb[0] /= 255;\n\t\trgb[1] /= 255;\n\t\trgb[2] /= 255;\n\n\t\tif (this.valpha !== 1) {\n\t\t\trgb.push(this.valpha);\n\t\t}\n\n\t\treturn rgb;\n\t},\n\n\tunitObject: function () {\n\t\tvar rgb = this.rgb().object();\n\t\trgb.r /= 255;\n\t\trgb.g /= 255;\n\t\trgb.b /= 255;\n\n\t\tif (this.valpha !== 1) {\n\t\t\trgb.alpha = this.valpha;\n\t\t}\n\n\t\treturn rgb;\n\t},\n\n\tround: function (places) {\n\t\tplaces = Math.max(places || 0, 0);\n\t\treturn new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);\n\t},\n\n\talpha: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);\n\t\t}\n\n\t\treturn this.valpha;\n\t},\n\n\t// rgb\n\tred: getset('rgb', 0, maxfn(255)),\n\tgreen: getset('rgb', 1, maxfn(255)),\n\tblue: getset('rgb', 2, maxfn(255)),\n\n\thue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style\n\n\tsaturationl: getset('hsl', 1, maxfn(100)),\n\tlightness: getset('hsl', 2, maxfn(100)),\n\n\tsaturationv: getset('hsv', 1, maxfn(100)),\n\tvalue: getset('hsv', 2, maxfn(100)),\n\n\tchroma: getset('hcg', 1, maxfn(100)),\n\tgray: getset('hcg', 2, maxfn(100)),\n\n\twhite: getset('hwb', 1, maxfn(100)),\n\twblack: getset('hwb', 2, maxfn(100)),\n\n\tcyan: getset('cmyk', 0, maxfn(100)),\n\tmagenta: getset('cmyk', 1, maxfn(100)),\n\tyellow: getset('cmyk', 2, maxfn(100)),\n\tblack: getset('cmyk', 3, maxfn(100)),\n\n\tx: getset('xyz', 0, maxfn(100)),\n\ty: getset('xyz', 1, maxfn(100)),\n\tz: getset('xyz', 2, maxfn(100)),\n\n\tl: getset('lab', 0, maxfn(100)),\n\ta: getset('lab', 1),\n\tb: getset('lab', 2),\n\n\tkeyword: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(val);\n\t\t}\n\n\t\treturn convert[this.model].keyword(this.color);\n\t},\n\n\thex: function (val) {\n\t\tif (arguments.length) {\n\t\t\treturn new Color(val);\n\t\t}\n\n\t\treturn colorString.to.hex(this.rgb().round().color);\n\t},\n\n\trgbNumber: function () {\n\t\tvar rgb = this.rgb().color;\n\t\treturn ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);\n\t},\n\n\tluminosity: function () {\n\t\t// http://www.w3.org/TR/WCAG20/#relativeluminancedef\n\t\tvar rgb = this.rgb().color;\n\n\t\tvar lum = [];\n\t\tfor (var i = 0; i < rgb.length; i++) {\n\t\t\tvar chan = rgb[i] / 255;\n\t\t\tlum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);\n\t\t}\n\n\t\treturn 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];\n\t},\n\n\tcontrast: function (color2) {\n\t\t// http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n\t\tvar lum1 = this.luminosity();\n\t\tvar lum2 = color2.luminosity();\n\n\t\tif (lum1 > lum2) {\n\t\t\treturn (lum1 + 0.05) / (lum2 + 0.05);\n\t\t}\n\n\t\treturn (lum2 + 0.05) / (lum1 + 0.05);\n\t},\n\n\tlevel: function (color2) {\n\t\tvar contrastRatio = this.contrast(color2);\n\t\tif (contrastRatio >= 7.1) {\n\t\t\treturn 'AAA';\n\t\t}\n\n\t\treturn (contrastRatio >= 4.5) ? 'AA' : '';\n\t},\n\n\tisDark: function () {\n\t\t// YIQ equation from http://24ways.org/2010/calculating-color-contrast\n\t\tvar rgb = this.rgb().color;\n\t\tvar yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;\n\t\treturn yiq < 128;\n\t},\n\n\tisLight: function () {\n\t\treturn !this.isDark();\n\t},\n\n\tnegate: function () {\n\t\tvar rgb = this.rgb();\n\t\tfor (var i = 0; i < 3; i++) {\n\t\t\trgb.color[i] = 255 - rgb.color[i];\n\t\t}\n\t\treturn rgb;\n\t},\n\n\tlighten: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[2] += hsl.color[2] * ratio;\n\t\treturn hsl;\n\t},\n\n\tdarken: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[2] -= hsl.color[2] * ratio;\n\t\treturn hsl;\n\t},\n\n\tsaturate: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[1] += hsl.color[1] * ratio;\n\t\treturn hsl;\n\t},\n\n\tdesaturate: function (ratio) {\n\t\tvar hsl = this.hsl();\n\t\thsl.color[1] -= hsl.color[1] * ratio;\n\t\treturn hsl;\n\t},\n\n\twhiten: function (ratio) {\n\t\tvar hwb = this.hwb();\n\t\thwb.color[1] += hwb.color[1] * ratio;\n\t\treturn hwb;\n\t},\n\n\tblacken: function (ratio) {\n\t\tvar hwb = this.hwb();\n\t\thwb.color[2] += hwb.color[2] * ratio;\n\t\treturn hwb;\n\t},\n\n\tgrayscale: function () {\n\t\t// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale\n\t\tvar rgb = this.rgb().color;\n\t\tvar val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;\n\t\treturn Color.rgb(val, val, val);\n\t},\n\n\tfade: function (ratio) {\n\t\treturn this.alpha(this.valpha - (this.valpha * ratio));\n\t},\n\n\topaquer: function (ratio) {\n\t\treturn this.alpha(this.valpha + (this.valpha * ratio));\n\t},\n\n\trotate: function (degrees) {\n\t\tvar hsl = this.hsl();\n\t\tvar hue = hsl.color[0];\n\t\thue = (hue + degrees) % 360;\n\t\thue = hue < 0 ? 360 + hue : hue;\n\t\thsl.color[0] = hue;\n\t\treturn hsl;\n\t},\n\n\tmix: function (mixinColor, weight) {\n\t\t// ported from sass implementation in C\n\t\t// https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209\n\t\tif (!mixinColor || !mixinColor.rgb) {\n\t\t\tthrow new Error('Argument to \"mix\" was not a Color instance, but rather an instance of ' + typeof mixinColor);\n\t\t}\n\t\tvar color1 = mixinColor.rgb();\n\t\tvar color2 = this.rgb();\n\t\tvar p = weight === undefined ? 0.5 : weight;\n\n\t\tvar w = 2 * p - 1;\n\t\tvar a = color1.alpha() - color2.alpha();\n\n\t\tvar w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n\t\tvar w2 = 1 - w1;\n\n\t\treturn Color.rgb(\n\t\t\t\tw1 * color1.red() + w2 * color2.red(),\n\t\t\t\tw1 * color1.green() + w2 * color2.green(),\n\t\t\t\tw1 * color1.blue() + w2 * color2.blue(),\n\t\t\t\tcolor1.alpha() * p + color2.alpha() * (1 - p));\n\t}\n};\n\n// model conversion methods and static constructors\nObject.keys(convert).forEach(function (model) {\n\tif (skippedModels.indexOf(model) !== -1) {\n\t\treturn;\n\t}\n\n\tvar channels = convert[model].channels;\n\n\t// conversion methods\n\tColor.prototype[model] = function () {\n\t\tif (this.model === model) {\n\t\t\treturn new Color(this);\n\t\t}\n\n\t\tif (arguments.length) {\n\t\t\treturn new Color(arguments, model);\n\t\t}\n\n\t\tvar newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;\n\t\treturn new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);\n\t};\n\n\t// 'static' construction methods\n\tColor[model] = function (color) {\n\t\tif (typeof color === 'number') {\n\t\t\tcolor = zeroArray(_slice.call(arguments), channels);\n\t\t}\n\t\treturn new Color(color, model);\n\t};\n});\n\nfunction roundTo(num, places) {\n\treturn Number(num.toFixed(places));\n}\n\nfunction roundToPlace(places) {\n\treturn function (num) {\n\t\treturn roundTo(num, places);\n\t};\n}\n\nfunction getset(model, channel, modifier) {\n\tmodel = Array.isArray(model) ? model : [model];\n\n\tmodel.forEach(function (m) {\n\t\t(limiters[m] || (limiters[m] = []))[channel] = modifier;\n\t});\n\n\tmodel = model[0];\n\n\treturn function (val) {\n\t\tvar result;\n\n\t\tif (arguments.length) {\n\t\t\tif (modifier) {\n\t\t\t\tval = modifier(val);\n\t\t\t}\n\n\t\t\tresult = this[model]();\n\t\t\tresult.color[channel] = val;\n\t\t\treturn result;\n\t\t}\n\n\t\tresult = this[model]().color[channel];\n\t\tif (modifier) {\n\t\t\tresult = modifier(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction maxfn(max) {\n\treturn function (v) {\n\t\treturn Math.max(0, Math.min(max, v));\n\t};\n}\n\nfunction assertArray(val) {\n\treturn Array.isArray(val) ? val : [val];\n}\n\nfunction zeroArray(arr, length) {\n\tfor (var i = 0; i < length; i++) {\n\t\tif (typeof arr[i] !== 'number') {\n\t\t\tarr[i] = 0;\n\t\t}\n\t}\n\n\treturn arr;\n}\n\nmodule.exports = Color;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color/index.js\n// module id = 10\n// module chunks = 0","(function(exports) {\n\n const generateGaussian = require('./box-muller');\n\n // Complementary error function\n // From Numerical Recipes in C 2e p221\n var erfc = function(x) {\n var z = Math.abs(x);\n var t = 1 / (1 + z / 2);\n var r = t * Math.exp(-z * z - 1.26551223 + t * (1.00002368 +\n t * (0.37409196 + t * (0.09678418 + t * (-0.18628806 +\n t * (0.27886807 + t * (-1.13520398 + t * (1.48851587 +\n t * (-0.82215223 + t * 0.17087277)))))))))\n return x >= 0 ? r : 2 - r;\n };\n\n // Inverse complementary error function\n // From Numerical Recipes 3e p265\n var ierfc = function(x) {\n if (x >= 2) { return -100; }\n if (x <= 0) { return 100; }\n\n var xx = (x < 1) ? x : 2 - x;\n var t = Math.sqrt(-2 * Math.log(xx / 2));\n\n var r = -0.70711 * ((2.30753 + t * 0.27061) /\n (1 + t * (0.99229 + t * 0.04481)) - t);\n\n for (var j = 0; j < 2; j++) {\n var err = erfc(r) - xx;\n r += err / (1.12837916709551257 * Math.exp(-(r * r)) - r * err);\n }\n\n return (x < 1) ? r : -r;\n };\n\n // Models the normal distribution\n var Gaussian = function(mean, variance) {\n if (variance <= 0) {\n throw new Error('Variance must be > 0 (but was ' + variance + ')');\n }\n this.mean = mean;\n this.variance = variance;\n this.standardDeviation = Math.sqrt(variance);\n }\n\n // Probability density function\n Gaussian.prototype.pdf = function(x) {\n var m = this.standardDeviation * Math.sqrt(2 * Math.PI);\n var e = Math.exp(-Math.pow(x - this.mean, 2) / (2 * this.variance));\n return e / m;\n };\n\n // Cumulative density function\n Gaussian.prototype.cdf = function(x) {\n return 0.5 * erfc(-(x - this.mean) / (this.standardDeviation * Math.sqrt(2)));\n };\n\n // Percent point function\n Gaussian.prototype.ppf = function(x) {\n return this.mean - this.standardDeviation * Math.sqrt(2) * ierfc(2 * x);\n };\n\n // Product distribution of this and d (scale for constant)\n Gaussian.prototype.mul = function(d) {\n if (typeof(d) === \"number\") {\n return this.scale(d);\n }\n var precision = 1 / this.variance;\n var dprecision = 1 / d.variance;\n return fromPrecisionMean(\n precision + dprecision, \n precision * this.mean + dprecision * d.mean);\n };\n\n // Quotient distribution of this and d (scale for constant)\n Gaussian.prototype.div = function(d) {\n if (typeof(d) === \"number\") {\n return this.scale(1 / d);\n }\n var precision = 1 / this.variance;\n var dprecision = 1 / d.variance;\n return fromPrecisionMean(\n precision - dprecision, \n precision * this.mean - dprecision * d.mean);\n };\n\n // Addition of this and d\n Gaussian.prototype.add = function(d) {\n return gaussian(this.mean + d.mean, this.variance + d.variance);\n };\n\n // Subtraction of this and d\n Gaussian.prototype.sub = function(d) {\n return gaussian(this.mean - d.mean, this.variance + d.variance);\n };\n\n // Scale this by constant c\n Gaussian.prototype.scale = function(c) {\n return gaussian(this.mean * c, this.variance * c * c);\n };\n\n\n /**\n * Generate [num] random samples\n * @param {number} num\n * @param randFn - an optional function that returns a float between 0 (inclusive) and 1\n * (exclusive). Use this if you want to pass in a random number generator other than\n * Math.random().\n * @returns {number[]}\n */\n Gaussian.prototype.random = function(num, randFn = null){\n let mean = this.mean;\n let std = this.standardDeviation;\n return Array(num).fill(0).map(() => {\n return generateGaussian(mean,std, randFn)\n })\n };\n\n var gaussian = function(mean, variance) {\n return new Gaussian(mean, variance);\n };\n\n var fromPrecisionMean = function(precision, precisionmean) {\n return gaussian(precisionmean / precision, 1 / precision);\n };\n\n exports(gaussian);\n})\n(typeof(exports) !== \"undefined\"\n ? function(e) { module.exports = e; }\n // istanbul ignore next\n : function(e) { this[\"gaussian\"] = e; });\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/gaussian/lib/gaussian.js\n// module id = 11\n// module chunks = 0","var Emitter = require('events/')\n\nmodule.exports = attach\n\nfunction attach(element, listener) {\n var position = new Emitter\n\n position[0] = 0\n position[1] = 0\n position.prev = [0, 0]\n position.flush = flush\n position.dispose = dispose\n\n if (typeof window === 'undefined') {\n return position\n }\n\n listener = listener || element || window\n element = element || document.body\n var handler = (element === document.body || element === window\n ) ? function(e) {\n position.prev[0] = position[0]\n position.prev[1] = position[1]\n position[0] = e.clientX\n position[1] = e.clientY\n position.emit('move', e)\n }\n : function(e) {\n position.prev[0] = position[0]\n position.prev[1] = position[1]\n var bounds = element.getBoundingClientRect()\n position[0] = e.clientX - bounds.left\n position[1] = e.clientY - bounds.top\n position.emit('move', e)\n }\n listener.addEventListener('mousemove', handler, false)\n\n return position\n\n function flush() {\n position.prev[0] = position[0]\n position.prev[1] = position[1]\n }\n\n function dispose() {\n position.removeAllListeners('move')\n listener.removeEventListener('mousemove', handler)\n }\n\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/mouse-position/index.js\n// module id = 12\n// module chunks = 0","/*global define:false */\n/**\n * Copyright 2012-2017 Craig Campbell\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * Mousetrap is a simple keyboard shortcut library for Javascript with\n * no external dependencies\n *\n * @version 1.6.5\n * @url craig.is/killing/mice\n */\n(function(window, document, undefined) {\n\n // Check if mousetrap is used inside browser, if not, return\n if (!window) {\n return;\n }\n\n /**\n * mapping of special keycodes to their corresponding keys\n *\n * everything in this dictionary cannot use keypress events\n * so it has to be here to map to the correct keycodes for\n * keyup/keydown events\n *\n * @type {Object}\n */\n var _MAP = {\n 8: 'backspace',\n 9: 'tab',\n 13: 'enter',\n 16: 'shift',\n 17: 'ctrl',\n 18: 'alt',\n 20: 'capslock',\n 27: 'esc',\n 32: 'space',\n 33: 'pageup',\n 34: 'pagedown',\n 35: 'end',\n 36: 'home',\n 37: 'left',\n 38: 'up',\n 39: 'right',\n 40: 'down',\n 45: 'ins',\n 46: 'del',\n 91: 'meta',\n 93: 'meta',\n 224: 'meta'\n };\n\n /**\n * mapping for special characters so they can support\n *\n * this dictionary is only used incase you want to bind a\n * keyup or keydown event to one of these keys\n *\n * @type {Object}\n */\n var _KEYCODE_MAP = {\n 106: '*',\n 107: '+',\n 109: '-',\n 110: '.',\n 111 : '/',\n 186: ';',\n 187: '=',\n 188: ',',\n 189: '-',\n 190: '.',\n 191: '/',\n 192: '`',\n 219: '[',\n 220: '\\\\',\n 221: ']',\n 222: '\\''\n };\n\n /**\n * this is a mapping of keys that require shift on a US keypad\n * back to the non shift equivelents\n *\n * this is so you can use keyup events with these keys\n *\n * note that this will only work reliably on US keyboards\n *\n * @type {Object}\n */\n var _SHIFT_MAP = {\n '~': '`',\n '!': '1',\n '@': '2',\n '#': '3',\n '$': '4',\n '%': '5',\n '^': '6',\n '&': '7',\n '*': '8',\n '(': '9',\n ')': '0',\n '_': '-',\n '+': '=',\n ':': ';',\n '\\\"': '\\'',\n '<': ',',\n '>': '.',\n '?': '/',\n '|': '\\\\'\n };\n\n /**\n * this is a list of special strings you can use to map\n * to modifier keys when you specify your keyboard shortcuts\n *\n * @type {Object}\n */\n var _SPECIAL_ALIASES = {\n 'option': 'alt',\n 'command': 'meta',\n 'return': 'enter',\n 'escape': 'esc',\n 'plus': '+',\n 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'\n };\n\n /**\n * variable to store the flipped version of _MAP from above\n * needed to check if we should use keypress or not when no action\n * is specified\n *\n * @type {Object|undefined}\n */\n var _REVERSE_MAP;\n\n /**\n * loop through the f keys, f1 to f19 and add them to the map\n * programatically\n */\n for (var i = 1; i < 20; ++i) {\n _MAP[111 + i] = 'f' + i;\n }\n\n /**\n * loop through to map numbers on the numeric keypad\n */\n for (i = 0; i <= 9; ++i) {\n\n // This needs to use a string cause otherwise since 0 is falsey\n // mousetrap will never fire for numpad 0 pressed as part of a keydown\n // event.\n //\n // @see https://github.com/ccampbell/mousetrap/pull/258\n _MAP[i + 96] = i.toString();\n }\n\n /**\n * cross browser add event method\n *\n * @param {Element|HTMLDocument} object\n * @param {string} type\n * @param {Function} callback\n * @returns void\n */\n function _addEvent(object, type, callback) {\n if (object.addEventListener) {\n object.addEventListener(type, callback, false);\n return;\n }\n\n object.attachEvent('on' + type, callback);\n }\n\n /**\n * takes the event and returns the key character\n *\n * @param {Event} e\n * @return {string}\n */\n function _characterFromEvent(e) {\n\n // for keypress events we should return the character as is\n if (e.type == 'keypress') {\n var character = String.fromCharCode(e.which);\n\n // if the shift key is not pressed then it is safe to assume\n // that we want the character to be lowercase. this means if\n // you accidentally have caps lock on then your key bindings\n // will continue to work\n //\n // the only side effect that might not be desired is if you\n // bind something like 'A' cause you want to trigger an\n // event when capital A is pressed caps lock will no longer\n // trigger the event. shift+a will though.\n if (!e.shiftKey) {\n character = character.toLowerCase();\n }\n\n return character;\n }\n\n // for non keypress events the special maps are needed\n if (_MAP[e.which]) {\n return _MAP[e.which];\n }\n\n if (_KEYCODE_MAP[e.which]) {\n return _KEYCODE_MAP[e.which];\n }\n\n // if it is not in the special map\n\n // with keydown and keyup events the character seems to always\n // come in as an uppercase character whether you are pressing shift\n // or not. we should make sure it is always lowercase for comparisons\n return String.fromCharCode(e.which).toLowerCase();\n }\n\n /**\n * checks if two arrays are equal\n *\n * @param {Array} modifiers1\n * @param {Array} modifiers2\n * @returns {boolean}\n */\n function _modifiersMatch(modifiers1, modifiers2) {\n return modifiers1.sort().join(',') === modifiers2.sort().join(',');\n }\n\n /**\n * takes a key event and figures out what the modifiers are\n *\n * @param {Event} e\n * @returns {Array}\n */\n function _eventModifiers(e) {\n var modifiers = [];\n\n if (e.shiftKey) {\n modifiers.push('shift');\n }\n\n if (e.altKey) {\n modifiers.push('alt');\n }\n\n if (e.ctrlKey) {\n modifiers.push('ctrl');\n }\n\n if (e.metaKey) {\n modifiers.push('meta');\n }\n\n return modifiers;\n }\n\n /**\n * prevents default for this event\n *\n * @param {Event} e\n * @returns void\n */\n function _preventDefault(e) {\n if (e.preventDefault) {\n e.preventDefault();\n return;\n }\n\n e.returnValue = false;\n }\n\n /**\n * stops propogation for this event\n *\n * @param {Event} e\n * @returns void\n */\n function _stopPropagation(e) {\n if (e.stopPropagation) {\n e.stopPropagation();\n return;\n }\n\n e.cancelBubble = true;\n }\n\n /**\n * determines if the keycode specified is a modifier key or not\n *\n * @param {string} key\n * @returns {boolean}\n */\n function _isModifier(key) {\n return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';\n }\n\n /**\n * reverses the map lookup so that we can look for specific keys\n * to see what can and can't use keypress\n *\n * @return {Object}\n */\n function _getReverseMap() {\n if (!_REVERSE_MAP) {\n _REVERSE_MAP = {};\n for (var key in _MAP) {\n\n // pull out the numeric keypad from here cause keypress should\n // be able to detect the keys from the character\n if (key > 95 && key < 112) {\n continue;\n }\n\n if (_MAP.hasOwnProperty(key)) {\n _REVERSE_MAP[_MAP[key]] = key;\n }\n }\n }\n return _REVERSE_MAP;\n }\n\n /**\n * picks the best action based on the key combination\n *\n * @param {string} key - character for key\n * @param {Array} modifiers\n * @param {string=} action passed in\n */\n function _pickBestAction(key, modifiers, action) {\n\n // if no action was picked in we should try to pick the one\n // that we think would work best for this key\n if (!action) {\n action = _getReverseMap()[key] ? 'keydown' : 'keypress';\n }\n\n // modifier keys don't work as expected with keypress,\n // switch to keydown\n if (action == 'keypress' && modifiers.length) {\n action = 'keydown';\n }\n\n return action;\n }\n\n /**\n * Converts from a string key combination to an array\n *\n * @param {string} combination like \"command+shift+l\"\n * @return {Array}\n */\n function _keysFromString(combination) {\n if (combination === '+') {\n return ['+'];\n }\n\n combination = combination.replace(/\\+{2}/g, '+plus');\n return combination.split('+');\n }\n\n /**\n * Gets info for a specific key combination\n *\n * @param {string} combination key combination (\"command+s\" or \"a\" or \"*\")\n * @param {string=} action\n * @returns {Object}\n */\n function _getKeyInfo(combination, action) {\n var keys;\n var key;\n var i;\n var modifiers = [];\n\n // take the keys from this pattern and figure out what the actual\n // pattern is all about\n keys = _keysFromString(combination);\n\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n\n // normalize key names\n if (_SPECIAL_ALIASES[key]) {\n key = _SPECIAL_ALIASES[key];\n }\n\n // if this is not a keypress event then we should\n // be smart about using shift keys\n // this will only work for US keyboards however\n if (action && action != 'keypress' && _SHIFT_MAP[key]) {\n key = _SHIFT_MAP[key];\n modifiers.push('shift');\n }\n\n // if this key is a modifier then add it to the list of modifiers\n if (_isModifier(key)) {\n modifiers.push(key);\n }\n }\n\n // depending on what the key combination is\n // we will try to pick the best event for it\n action = _pickBestAction(key, modifiers, action);\n\n return {\n key: key,\n modifiers: modifiers,\n action: action\n };\n }\n\n function _belongsTo(element, ancestor) {\n if (element === null || element === document) {\n return false;\n }\n\n if (element === ancestor) {\n return true;\n }\n\n return _belongsTo(element.parentNode, ancestor);\n }\n\n function Mousetrap(targetElement) {\n var self = this;\n\n targetElement = targetElement || document;\n\n if (!(self instanceof Mousetrap)) {\n return new Mousetrap(targetElement);\n }\n\n /**\n * element to attach key events to\n *\n * @type {Element}\n */\n self.target = targetElement;\n\n /**\n * a list of all the callbacks setup via Mousetrap.bind()\n *\n * @type {Object}\n */\n self._callbacks = {};\n\n /**\n * direct map of string combinations to callbacks used for trigger()\n *\n * @type {Object}\n */\n self._directMap = {};\n\n /**\n * keeps track of what level each sequence is at since multiple\n * sequences can start out with the same sequence\n *\n * @type {Object}\n */\n var _sequenceLevels = {};\n\n /**\n * variable to store the setTimeout call\n *\n * @type {null|number}\n */\n var _resetTimer;\n\n /**\n * temporary state where we will ignore the next keyup\n *\n * @type {boolean|string}\n */\n var _ignoreNextKeyup = false;\n\n /**\n * temporary state where we will ignore the next keypress\n *\n * @type {boolean}\n */\n var _ignoreNextKeypress = false;\n\n /**\n * are we currently inside of a sequence?\n * type of action (\"keyup\" or \"keydown\" or \"keypress\") or false\n *\n * @type {boolean|string}\n */\n var _nextExpectedAction = false;\n\n /**\n * resets all sequence counters except for the ones passed in\n *\n * @param {Object} doNotReset\n * @returns void\n */\n function _resetSequences(doNotReset) {\n doNotReset = doNotReset || {};\n\n var activeSequences = false,\n key;\n\n for (key in _sequenceLevels) {\n if (doNotReset[key]) {\n activeSequences = true;\n continue;\n }\n _sequenceLevels[key] = 0;\n }\n\n if (!activeSequences) {\n _nextExpectedAction = false;\n }\n }\n\n /**\n * finds all callbacks that match based on the keycode, modifiers,\n * and action\n *\n * @param {string} character\n * @param {Array} modifiers\n * @param {Event|Object} e\n * @param {string=} sequenceName - name of the sequence we are looking for\n * @param {string=} combination\n * @param {number=} level\n * @returns {Array}\n */\n function _getMatches(character, modifiers, e, sequenceName, combination, level) {\n var i;\n var callback;\n var matches = [];\n var action = e.type;\n\n // if there are no events related to this keycode\n if (!self._callbacks[character]) {\n return [];\n }\n\n // if a modifier key is coming up on its own we should allow it\n if (action == 'keyup' && _isModifier(character)) {\n modifiers = [character];\n }\n\n // loop through all callbacks for the key that was pressed\n // and see if any of them match\n for (i = 0; i < self._callbacks[character].length; ++i) {\n callback = self._callbacks[character][i];\n\n // if a sequence name is not specified, but this is a sequence at\n // the wrong level then move onto the next match\n if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {\n continue;\n }\n\n // if the action we are looking for doesn't match the action we got\n // then we should keep going\n if (action != callback.action) {\n continue;\n }\n\n // if this is a keypress event and the meta key and control key\n // are not pressed that means that we need to only look at the\n // character, otherwise check the modifiers as well\n //\n // chrome will not fire a keypress if meta or control is down\n // safari will fire a keypress if meta or meta+shift is down\n // firefox will fire a keypress if meta or control is down\n if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {\n\n // when you bind a combination or sequence a second time it\n // should overwrite the first one. if a sequenceName or\n // combination is specified in this call it does just that\n //\n // @todo make deleting its own method?\n var deleteCombo = !sequenceName && callback.combo == combination;\n var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;\n if (deleteCombo || deleteSequence) {\n self._callbacks[character].splice(i, 1);\n }\n\n matches.push(callback);\n }\n }\n\n return matches;\n }\n\n /**\n * actually calls the callback function\n *\n * if your callback function returns false this will use the jquery\n * convention - prevent default and stop propogation on the event\n *\n * @param {Function} callback\n * @param {Event} e\n * @returns void\n */\n function _fireCallback(callback, e, combo, sequence) {\n\n // if this event should not happen stop here\n if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {\n return;\n }\n\n if (callback(e, combo) === false) {\n _preventDefault(e);\n _stopPropagation(e);\n }\n }\n\n /**\n * handles a character key event\n *\n * @param {string} character\n * @param {Array} modifiers\n * @param {Event} e\n * @returns void\n */\n self._handleKey = function(character, modifiers, e) {\n var callbacks = _getMatches(character, modifiers, e);\n var i;\n var doNotReset = {};\n var maxLevel = 0;\n var processedSequenceCallback = false;\n\n // Calculate the maxLevel for sequences so we can only execute the longest callback sequence\n for (i = 0; i < callbacks.length; ++i) {\n if (callbacks[i].seq) {\n maxLevel = Math.max(maxLevel, callbacks[i].level);\n }\n }\n\n // loop through matching callbacks for this key event\n for (i = 0; i < callbacks.length; ++i) {\n\n // fire for all sequence callbacks\n // this is because if for example you have multiple sequences\n // bound such as \"g i\" and \"g t\" they both need to fire the\n // callback for matching g cause otherwise you can only ever\n // match the first one\n if (callbacks[i].seq) {\n\n // only fire callbacks for the maxLevel to prevent\n // subsequences from also firing\n //\n // for example 'a option b' should not cause 'option b' to fire\n // even though 'option b' is part of the other sequence\n //\n // any sequences that do not match here will be discarded\n // below by the _resetSequences call\n if (callbacks[i].level != maxLevel) {\n continue;\n }\n\n processedSequenceCallback = true;\n\n // keep a list of which sequences were matches for later\n doNotReset[callbacks[i].seq] = 1;\n _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);\n continue;\n }\n\n // if there were no sequence matches but we are still here\n // that means this is a regular match so we should fire that\n if (!processedSequenceCallback) {\n _fireCallback(callbacks[i].callback, e, callbacks[i].combo);\n }\n }\n\n // if the key you pressed matches the type of sequence without\n // being a modifier (ie \"keyup\" or \"keypress\") then we should\n // reset all sequences that were not matched by this event\n //\n // this is so, for example, if you have the sequence \"h a t\" and you\n // type \"h e a r t\" it does not match. in this case the \"e\" will\n // cause the sequence to reset\n //\n // modifier keys are ignored because you can have a sequence\n // that contains modifiers such as \"enter ctrl+space\" and in most\n // cases the modifier key will be pressed before the next key\n //\n // also if you have a sequence such as \"ctrl+b a\" then pressing the\n // \"b\" key will trigger a \"keypress\" and a \"keydown\"\n //\n // the \"keydown\" is expected when there is a modifier, but the\n // \"keypress\" ends up matching the _nextExpectedAction since it occurs\n // after and that causes the sequence to reset\n //\n // we ignore keypresses in a sequence that directly follow a keydown\n // for the same character\n var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;\n if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {\n _resetSequences(doNotReset);\n }\n\n _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';\n };\n\n /**\n * handles a keydown event\n *\n * @param {Event} e\n * @returns void\n */\n function _handleKeyEvent(e) {\n\n // normalize e.which for key events\n // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion\n if (typeof e.which !== 'number') {\n e.which = e.keyCode;\n }\n\n var character = _characterFromEvent(e);\n\n // no character found then stop\n if (!character) {\n return;\n }\n\n // need to use === for the character check because the character can be 0\n if (e.type == 'keyup' && _ignoreNextKeyup === character) {\n _ignoreNextKeyup = false;\n return;\n }\n\n self.handleKey(character, _eventModifiers(e), e);\n }\n\n /**\n * called to set a 1 second timeout on the specified sequence\n *\n * this is so after each key press in the sequence you have 1 second\n * to press the next key before you have to start over\n *\n * @returns void\n */\n function _resetSequenceTimer() {\n clearTimeout(_resetTimer);\n _resetTimer = setTimeout(_resetSequences, 1000);\n }\n\n /**\n * binds a key sequence to an event\n *\n * @param {string} combo - combo specified in bind call\n * @param {Array} keys\n * @param {Function} callback\n * @param {string=} action\n * @returns void\n */\n function _bindSequence(combo, keys, callback, action) {\n\n // start off by adding a sequence level record for this combination\n // and setting the level to 0\n _sequenceLevels[combo] = 0;\n\n /**\n * callback to increase the sequence level for this sequence and reset\n * all other sequences that were active\n *\n * @param {string} nextAction\n * @returns {Function}\n */\n function _increaseSequence(nextAction) {\n return function() {\n _nextExpectedAction = nextAction;\n ++_sequenceLevels[combo];\n _resetSequenceTimer();\n };\n }\n\n /**\n * wraps the specified callback inside of another function in order\n * to reset all sequence counters as soon as this sequence is done\n *\n * @param {Event} e\n * @returns void\n */\n function _callbackAndReset(e) {\n _fireCallback(callback, e, combo);\n\n // we should ignore the next key up if the action is key down\n // or keypress. this is so if you finish a sequence and\n // release the key the final key will not trigger a keyup\n if (action !== 'keyup') {\n _ignoreNextKeyup = _characterFromEvent(e);\n }\n\n // weird race condition if a sequence ends with the key\n // another sequence begins with\n setTimeout(_resetSequences, 10);\n }\n\n // loop through keys one at a time and bind the appropriate callback\n // function. for any key leading up to the final one it should\n // increase the sequence. after the final, it should reset all sequences\n //\n // if an action is specified in the original bind call then that will\n // be used throughout. otherwise we will pass the action that the\n // next key in the sequence should match. this allows a sequence\n // to mix and match keypress and keydown events depending on which\n // ones are better suited to the key provided\n for (var i = 0; i < keys.length; ++i) {\n var isFinal = i + 1 === keys.length;\n var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);\n _bindSingle(keys[i], wrappedCallback, action, combo, i);\n }\n }\n\n /**\n * binds a single keyboard combination\n *\n * @param {string} combination\n * @param {Function} callback\n * @param {string=} action\n * @param {string=} sequenceName - name of sequence if part of sequence\n * @param {number=} level - what part of the sequence the command is\n * @returns void\n */\n function _bindSingle(combination, callback, action, sequenceName, level) {\n\n // store a direct mapped reference for use with Mousetrap.trigger\n self._directMap[combination + ':' + action] = callback;\n\n // make sure multiple spaces in a row become a single space\n combination = combination.replace(/\\s+/g, ' ');\n\n var sequence = combination.split(' ');\n var info;\n\n // if this pattern is a sequence of keys then run through this method\n // to reprocess each pattern one key at a time\n if (sequence.length > 1) {\n _bindSequence(combination, sequence, callback, action);\n return;\n }\n\n info = _getKeyInfo(combination, action);\n\n // make sure to initialize array if this is the first time\n // a callback is added for this key\n self._callbacks[info.key] = self._callbacks[info.key] || [];\n\n // remove an existing match if there is one\n _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);\n\n // add this call back to the array\n // if it is a sequence put it at the beginning\n // if not put it at the end\n //\n // this is important because the way these are processed expects\n // the sequence ones to come first\n self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({\n callback: callback,\n modifiers: info.modifiers,\n action: info.action,\n seq: sequenceName,\n level: level,\n combo: combination\n });\n }\n\n /**\n * binds multiple combinations to the same callback\n *\n * @param {Array} combinations\n * @param {Function} callback\n * @param {string|undefined} action\n * @returns void\n */\n self._bindMultiple = function(combinations, callback, action) {\n for (var i = 0; i < combinations.length; ++i) {\n _bindSingle(combinations[i], callback, action);\n }\n };\n\n // start!\n _addEvent(targetElement, 'keypress', _handleKeyEvent);\n _addEvent(targetElement, 'keydown', _handleKeyEvent);\n _addEvent(targetElement, 'keyup', _handleKeyEvent);\n }\n\n /**\n * binds an event to mousetrap\n *\n * can be a single key, a combination of keys separated with +,\n * an array of keys, or a sequence of keys separated by spaces\n *\n * be sure to list the modifier keys first to make sure that the\n * correct key ends up getting bound (the last key in the pattern)\n *\n * @param {string|Array} keys\n * @param {Function} callback\n * @param {string=} action - 'keypress', 'keydown', or 'keyup'\n * @returns void\n */\n Mousetrap.prototype.bind = function(keys, callback, action) {\n var self = this;\n keys = keys instanceof Array ? keys : [keys];\n self._bindMultiple.call(self, keys, callback, action);\n return self;\n };\n\n /**\n * unbinds an event to mousetrap\n *\n * the unbinding sets the callback function of the specified key combo\n * to an empty function and deletes the corresponding key in the\n * _directMap dict.\n *\n * TODO: actually remove this from the _callbacks dictionary instead\n * of binding an empty function\n *\n * the keycombo+action has to be exactly the same as\n * it was defined in the bind method\n *\n * @param {string|Array} keys\n * @param {string} action\n * @returns void\n */\n Mousetrap.prototype.unbind = function(keys, action) {\n var self = this;\n return self.bind.call(self, keys, function() {}, action);\n };\n\n /**\n * triggers an event that has already been bound\n *\n * @param {string} keys\n * @param {string=} action\n * @returns void\n */\n Mousetrap.prototype.trigger = function(keys, action) {\n var self = this;\n if (self._directMap[keys + ':' + action]) {\n self._directMap[keys + ':' + action]({}, keys);\n }\n return self;\n };\n\n /**\n * resets the library back to its initial state. this is useful\n * if you want to clear out the current keyboard shortcuts and bind\n * new ones - for example if you switch to another page\n *\n * @returns void\n */\n Mousetrap.prototype.reset = function() {\n var self = this;\n self._callbacks = {};\n self._directMap = {};\n return self;\n };\n\n /**\n * should we stop this event before firing off callbacks\n *\n * @param {Event} e\n * @param {Element} element\n * @return {boolean}\n */\n Mousetrap.prototype.stopCallback = function(e, element) {\n var self = this;\n\n // if the element has the class \"mousetrap\" then no need to stop\n if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {\n return false;\n }\n\n if (_belongsTo(element, self.target)) {\n return false;\n }\n\n // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,\n // not the initial event target in the shadow tree. Note that not all events cross the\n // shadow boundary.\n // For shadow trees with `mode: 'open'`, the initial event target is the first element in\n // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event\n // target cannot be obtained.\n if ('composedPath' in e && typeof e.composedPath === 'function') {\n // For open shadow trees, update `element` so that the following check works.\n var initialEventTarget = e.composedPath()[0];\n if (initialEventTarget !== e.target) {\n element = initialEventTarget;\n }\n }\n\n // stop for input, select, and textarea\n return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;\n };\n\n /**\n * exposes _handleKey publicly so it can be overwritten by extensions\n */\n Mousetrap.prototype.handleKey = function() {\n var self = this;\n return self._handleKey.apply(self, arguments);\n };\n\n /**\n * allow custom key mappings\n */\n Mousetrap.addKeycodes = function(object) {\n for (var key in object) {\n if (object.hasOwnProperty(key)) {\n _MAP[key] = object[key];\n }\n }\n _REVERSE_MAP = null;\n };\n\n /**\n * Init the global mousetrap functions\n *\n * This method is needed to allow the global mousetrap functions to work\n * now that mousetrap is a constructor function.\n */\n Mousetrap.init = function() {\n var documentMousetrap = Mousetrap(document);\n for (var method in documentMousetrap) {\n if (method.charAt(0) !== '_') {\n Mousetrap[method] = (function(method) {\n return function() {\n return documentMousetrap[method].apply(documentMousetrap, arguments);\n };\n } (method));\n }\n }\n };\n\n Mousetrap.init();\n\n // expose mousetrap to the global object\n window.Mousetrap = Mousetrap;\n\n // expose as a common js module\n if (typeof module !== 'undefined' && module.exports) {\n module.exports = Mousetrap;\n }\n\n // expose mousetrap as an AMD module\n if (typeof define === 'function' && define.amd) {\n define(function() {\n return Mousetrap;\n });\n }\n}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/mousetrap/mousetrap.js\n// module id = 13\n// module chunks = 0","\"use strict\";\n;\n;\n;\nvar isWebSocket = function (constructor) {\n return constructor && constructor.CLOSING === 2;\n};\nvar isGlobalWebSocket = function () {\n return typeof WebSocket !== 'undefined' && isWebSocket(WebSocket);\n};\nvar getDefaultOptions = function () { return ({\n constructor: isGlobalWebSocket() ? WebSocket : null,\n maxReconnectionDelay: 10000,\n minReconnectionDelay: 1500,\n reconnectionDelayGrowFactor: 1.3,\n connectionTimeout: 4000,\n maxRetries: Infinity,\n debug: false,\n}); };\nvar bypassProperty = function (src, dst, name) {\n Object.defineProperty(dst, name, {\n get: function () { return src[name]; },\n set: function (value) { src[name] = value; },\n enumerable: true,\n configurable: true,\n });\n};\nvar initReconnectionDelay = function (config) {\n return (config.minReconnectionDelay + Math.random() * config.minReconnectionDelay);\n};\nvar updateReconnectionDelay = function (config, previousDelay) {\n var newDelay = previousDelay * config.reconnectionDelayGrowFactor;\n return (newDelay > config.maxReconnectionDelay)\n ? config.maxReconnectionDelay\n : newDelay;\n};\nvar LEVEL_0_EVENTS = ['onopen', 'onclose', 'onmessage', 'onerror'];\nvar reassignEventListeners = function (ws, oldWs, listeners) {\n Object.keys(listeners).forEach(function (type) {\n listeners[type].forEach(function (_a) {\n var listener = _a[0], options = _a[1];\n ws.addEventListener(type, listener, options);\n });\n });\n if (oldWs) {\n LEVEL_0_EVENTS.forEach(function (name) {\n ws[name] = oldWs[name];\n });\n }\n};\nvar ReconnectingWebsocket = function (url, protocols, options) {\n var _this = this;\n if (options === void 0) { options = {}; }\n var ws;\n var connectingTimeout;\n var reconnectDelay = 0;\n var retriesCount = 0;\n var shouldRetry = true;\n var savedOnClose = null;\n var listeners = {};\n // require new to construct\n if (!(this instanceof ReconnectingWebsocket)) {\n throw new TypeError(\"Failed to construct 'ReconnectingWebSocket': Please use the 'new' operator\");\n }\n // Set config. Not using `Object.assign` because of IE11\n var config = getDefaultOptions();\n Object.keys(config)\n .filter(function (key) { return options.hasOwnProperty(key); })\n .forEach(function (key) { return config[key] = options[key]; });\n if (!isWebSocket(config.constructor)) {\n throw new TypeError('Invalid WebSocket constructor. Set `options.constructor`');\n }\n var log = config.debug ? function () {\n var params = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n params[_i] = arguments[_i];\n }\n return console.log.apply(console, ['RWS:'].concat(params));\n } : function () { };\n /**\n * Not using dispatchEvent, otherwise we must use a DOM Event object\n * Deferred because we want to handle the close event before this\n */\n var emitError = function (code, msg) { return setTimeout(function () {\n var err = new Error(msg);\n err.code = code;\n if (Array.isArray(listeners.error)) {\n listeners.error.forEach(function (_a) {\n var fn = _a[0];\n return fn(err);\n });\n }\n if (ws.onerror) {\n ws.onerror(err);\n }\n }, 0); };\n var handleClose = function () {\n log('handleClose', { shouldRetry: shouldRetry });\n retriesCount++;\n log('retries count:', retriesCount);\n if (retriesCount > config.maxRetries) {\n emitError('EHOSTDOWN', 'Too many failed connection attempts');\n return;\n }\n if (!reconnectDelay) {\n reconnectDelay = initReconnectionDelay(config);\n }\n else {\n reconnectDelay = updateReconnectionDelay(config, reconnectDelay);\n }\n log('handleClose - reconnectDelay:', reconnectDelay);\n if (shouldRetry) {\n setTimeout(connect, reconnectDelay);\n }\n };\n var connect = function () {\n if (!shouldRetry) {\n return;\n }\n log('connect');\n var oldWs = ws;\n var wsUrl = (typeof url === 'function') ? url() : url;\n ws = new config.constructor(wsUrl, protocols);\n connectingTimeout = setTimeout(function () {\n log('timeout');\n ws.close();\n emitError('ETIMEDOUT', 'Connection timeout');\n }, config.connectionTimeout);\n log('bypass properties');\n for (var key in ws) {\n // @todo move to constant\n if (['addEventListener', 'removeEventListener', 'close', 'send'].indexOf(key) < 0) {\n bypassProperty(ws, _this, key);\n }\n }\n ws.addEventListener('open', function () {\n clearTimeout(connectingTimeout);\n log('open');\n reconnectDelay = initReconnectionDelay(config);\n log('reconnectDelay:', reconnectDelay);\n retriesCount = 0;\n });\n ws.addEventListener('close', handleClose);\n reassignEventListeners(ws, oldWs, listeners);\n // because when closing with fastClose=true, it is saved and set to null to avoid double calls\n ws.onclose = ws.onclose || savedOnClose;\n savedOnClose = null;\n };\n log('init');\n connect();\n this.close = function (code, reason, _a) {\n if (code === void 0) { code = 1000; }\n if (reason === void 0) { reason = ''; }\n var _b = _a === void 0 ? {} : _a, _c = _b.keepClosed, keepClosed = _c === void 0 ? false : _c, _d = _b.fastClose, fastClose = _d === void 0 ? true : _d, _e = _b.delay, delay = _e === void 0 ? 0 : _e;\n log('close - params:', { reason: reason, keepClosed: keepClosed, fastClose: fastClose, delay: delay, retriesCount: retriesCount, maxRetries: config.maxRetries });\n shouldRetry = !keepClosed && retriesCount <= config.maxRetries;\n if (delay) {\n reconnectDelay = delay;\n }\n ws.close(code, reason);\n if (fastClose) {\n var fakeCloseEvent_1 = {\n code: code,\n reason: reason,\n wasClean: true,\n };\n // execute close listeners soon with a fake closeEvent\n // and remove them from the WS instance so they\n // don't get fired on the real close.\n handleClose();\n ws.removeEventListener('close', handleClose);\n // run and remove level2\n if (Array.isArray(listeners.close)) {\n listeners.close.forEach(function (_a) {\n var listener = _a[0], options = _a[1];\n listener(fakeCloseEvent_1);\n ws.removeEventListener('close', listener, options);\n });\n }\n // run and remove level0\n if (ws.onclose) {\n savedOnClose = ws.onclose;\n ws.onclose(fakeCloseEvent_1);\n ws.onclose = null;\n }\n }\n };\n this.send = function (data) {\n ws.send(data);\n };\n this.addEventListener = function (type, listener, options) {\n if (Array.isArray(listeners[type])) {\n if (!listeners[type].some(function (_a) {\n var l = _a[0];\n return l === listener;\n })) {\n listeners[type].push([listener, options]);\n }\n }\n else {\n listeners[type] = [[listener, options]];\n }\n ws.addEventListener(type, listener, options);\n };\n this.removeEventListener = function (type, listener, options) {\n if (Array.isArray(listeners[type])) {\n listeners[type] = listeners[type].filter(function (_a) {\n var l = _a[0];\n return l !== listener;\n });\n }\n ws.removeEventListener(type, listener, options);\n };\n};\nmodule.exports = ReconnectingWebsocket;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/reconnecting-websocket/dist/index.js\n// module id = 14\n// module chunks = 0","module.exports = jQuery;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"jQuery\"\n// module id = 15\n// module chunks = 0","/*global dallinger, require, settings */\n/*jshint esversion: 6 */\n\n(function (dallinger, require, settings) {\n\nvar grid = require(\"./index\");\nvar position = require(\"mouse-position\");\nvar Mousetrap = require(\"mousetrap\");\nvar ReconnectingWebSocket = require(\"reconnecting-websocket\");\nvar $ = require(\"jquery\");\nvar gaussian = require(\"gaussian\");\nvar Color = require('color');\nvar Identicon = require('./util/identicon');\nvar md5 = require('./util/md5');\nvar itemlib = require (\"./items\");\n\nfunction coordsToIdx(x, y, columns) {\n return y * columns + x;\n}\n\nfunction animateColor(color) {\n if (settings.background_animation) {\n rand = Math.random() * 0.02;\n } else {\n rand = 0.01;\n }\n return [\n color[0] * 0.95 + rand,\n color[1] * 0.95 + rand,\n color[2] * 0.95 + rand\n ];\n}\n\nfunction positionsAreEqual(a, b) {\n // Items with null positions are never co-located\n if (a === null || b === null) {\n return false;\n }\n return a[0] === b[0] && a[1] === b[1];\n}\n\nclass Section {\n // Represents the currently visible section (window) of the grid\n\n constructor(data, left, top) {\n this.left = left;\n this.top = top;\n this.columns = settings.window_columns;\n this.rows = settings.window_rows;\n this.data = [];\n this.textures = [];\n // build data array for just this section\n for (var j = 0; j < this.rows; j++) {\n for (var i = 0; i < this.columns; i++) {\n this.data.push(data[this.sectionCoordsToGridIdx(i, j)]);\n this.textures.push(0);\n }\n }\n }\n\n gridCoordsToSectionIdx(x, y) {\n // Convert grid coordinates to section data array index\n return (y - this.top) * this.columns + (x - this.left);\n }\n\n sectionCoordsToGridIdx(x, y) {\n // Convert section coordinates to grid data array index\n return coordsToIdx(this.left + x, this.top + y, settings.columns);\n }\n\n plot(x, y, color, texture) {\n // Set color at position (x, y) in full-grid coordinates.\n if (x >= this.left && x < this.left + this.columns) {\n if (y >= this.top && y < this.top + this.rows) {\n this.data[this.gridCoordsToSectionIdx(x, y)] = color;\n if (texture !== undefined ){\n this.textures[this.gridCoordsToSectionIdx(x, y)] = texture;\n }\n background[coordsToIdx(x, y, settings.columns)] = color;\n }\n }\n }\n\n map(func) {\n // For each cell, call func with (x, y, color) to get the new color\n for (var j = 0; j < this.rows; j++) {\n for (var i = 0; i < this.columns; i++) {\n var idx = coordsToIdx(i, j, this.columns);\n this.data[idx] = Reflect.apply(\n func, this, [this.left + i, this.top + j, this.data[idx]]);\n }\n }\n }\n}\n\nvar background = [], color;\nfor (var j = 0; j < settings.rows; j++) {\n for (var i = 0; i < settings.columns; i++) {\n color = [0, 0, 0];\n for (var k = 0; k < 15; k++) {\n color = animateColor(color);\n }\n background.push(color);\n }\n}\n\nvar initialSection = new Section(background, 0, 0);\n\nvar INVISIBLE_COLOR = [0.66, 0.66, 0.66];\nvar CHANNEL = \"griduniverse\";\nvar CONTROL_CHANNEL = \"griduniverse_ctrl\";\n\nvar pixels = grid(initialSection.data, initialSection.textures, {\n rows: settings.window_rows,\n columns: settings.window_columns,\n size: settings.block_size,\n padding: settings.padding,\n background: [0.1, 0.1, 0.1],\n formatted: true\n});\n\nvar mouse = position(pixels.canvas);\n\nvar isSpectator = false;\nvar start = performance.now();\nvar gridItems = new itemlib.GridItems();\nvar walls = [];\nvar wall_map = {};\nvar transitionsSeen = new Set();\nvar rand;\n\nvar name2idx = function (name) {\n var names = settings.player_color_names;\n for (var idx=0; idx < names.length; idx++) {\n if (names[idx] === name) {\n return idx;\n }\n }\n};\n\nvar color2idx = function (color) {\n var colors = settings.player_colors;\n var value = color.join(',');\n for (var idx=0; idx < colors.length; idx++) {\n if (colors[idx].join(',') === value) {\n return idx;\n }\n }\n};\n\nvar color2name = function (color) {\n var idx = color2idx(color);\n return settings.player_color_names[idx];\n}\n\n\nvar Wall = function (settings) {\n if (!(this instanceof Wall)) {\n return new Wall();\n }\n this.position = settings.position;\n this.color = settings.color;\n return this;\n};\n\nvar Player = function (settings, dimness) {\n if (!(this instanceof Player)) {\n return new Player();\n }\n this.id = settings.id;\n this.position = settings.position;\n this.positionInSync = true;\n this.color = settings.color;\n this.motion_auto = settings.motion_auto;\n this.motion_direction = settings.motion_direction;\n this.motion_speed_limit = settings.motion_speed_limit;\n this.motion_timestamp = settings.motion_timestamp;\n this.score = settings.score;\n this.payoff = settings.payoff;\n this.name = settings.name;\n this.identity_visible = settings.identity_visible;\n this.dimness = dimness;\n this.replaceItem(settings.current_item);\n return this;\n};\n\nPlayer.prototype.move = function(direction) {\n\n function _isCrossable(position) {\n const hasWall = ! _.isUndefined(wall_map[[position[1], position[0]]]);\n if (hasWall) {\n return false;\n }\n const itemHere = gridItems.atPosition(position);\n return _.isNull(itemHere) || itemHere.crossable;\n }\n\n this.motion_direction = direction;\n\n var ts = performance.now() - start,\n waitTime = 1000 / this.motion_speed_limit;\n\n if (ts > this.motion_timestamp + waitTime) {\n var newPosition = this.position.slice();\n\n switch (direction) {\n case \"up\":\n if (this.position[0] > 0) {\n newPosition[0] -= 1;\n }\n break;\n\n case \"down\":\n if (this.position[0] < settings.rows - 1) {\n newPosition[0] += 1;\n }\n break;\n\n case \"left\":\n if (this.position[1] > 0) {\n newPosition[1] -= 1;\n }\n break;\n\n case \"right\":\n if (this.position[1] < settings.columns - 1) {\n newPosition[1] += 1;\n }\n break;\n\n default:\n console.log(\"Direction not recognized.\");\n }\n\n if (_isCrossable(newPosition) && (!players.isPlayerAt(newPosition) || settings.player_overlap)) {\n this.position = newPosition;\n this.motion_timestamp = ts;\n return true;\n }\n }\n return false;\n};\n\n\nPlayer.prototype.replaceItem = function(item) {\n if (item && !(item instanceof itemlib.Item)) {\n item = new itemlib.Item(item.id, item.item_id, item.maturity, item.remaining_uses)\n }\n this.currentItem = item;\n displayWhatEgoPlayerIsCarrying(item);\n};\n\nPlayer.prototype.getTransition = function () {\n var transition;\n var player_item = this.currentItem;\n var position = this.position;\n var item_at_pos = gridItems.atPosition(position);\n var transition_id = (player_item && player_item.itemId || '') + '|' + (item_at_pos && item_at_pos.itemId || '');\n var last_transition_id = 'last_' + transition_id;\n if (item_at_pos && item_at_pos.remaining_uses == 1) {\n transition = settings.transition_config[last_transition_id];\n if (transition) {\n transition_id = last_transition_id;\n }\n }\n if (!transition) {\n transition = settings.transition_config[transition_id];\n }\n if (!transition) {\n return null;\n }\n return {id: transition_id, transition: transition};\n}\n\nvar playerSet = (function () {\n\n var PlayerSet = function (settings) {\n if (!(this instanceof PlayerSet)) {\n return new PlayerSet(settings);\n }\n\n this._players = {};\n this.ego_id = settings.ego_id;\n };\n\n PlayerSet.prototype.isPlayerAt = function (position) {\n var id, player;\n\n for (id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n player = this._players[id];\n if (positionsAreEqual(position, player.position)) {\n return true;\n }\n }\n }\n return false;\n };\n\n PlayerSet.prototype.drawToGrid = function (grid) {\n var player,\n id,\n minScore,\n maxScore,\n d,\n color,\n player_color;\n if (settings.score_visible) {\n minScore = this.minScore();\n maxScore = this.maxScore();\n }\n\n for (id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n player = this._players[id];\n /* It's unlikely that auto motion will keep identical pace to server-side auto-motion */\n /* this should be implemented either all on server or all on client */\n if (player.motion_auto) {\n player.move(player.motion_direction);\n }\n if (id === this.ego_id || settings.others_visible) {\n player_color = settings.player_colors[name2idx(player.color)];\n if (player.identity_visible) {\n color = player_color;\n } else {\n color = (id === this.ego_id) ? Color.rgb(player_color).desaturate(0.6).rgb().array() : INVISIBLE_COLOR;\n }\n if (settings.score_visible) {\n if (maxScore-minScore > 0) {\n d = 0.75 * (1 - (player.score-minScore)/(maxScore-minScore));\n } else {\n d = 0.375;\n }\n color = Color.rgb(player_color).desaturate(d).rgb().array();\n } else {\n color = player_color;\n }\n var texture = 0;\n if (settings.use_identicons) {\n texture = parseInt(id, 10);\n }\n grid.plot(player.position[1], player.position[0], color, texture);\n if (id === this.ego_id) {\n store.set(\"color\", color2name(color));\n }\n }\n }\n }\n };\n\n PlayerSet.prototype.nearest = function (row, column) {\n var distances = [],\n distance,\n player,\n id;\n\n for (id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n player = this._players[id];\n if (player.hasOwnProperty('position')) {\n distance = Math.abs(row - player.position[0]) + Math.abs(column - player.position[1]);\n distances.push({\"player\": player, \"distance\": distance});\n }\n }\n }\n\n distances.sort(function (a, b) {\n return a.distance - b.distance;\n });\n\n return distances[0].player;\n };\n\n PlayerSet.prototype.ego = function () {\n return this.get(this.ego_id);\n };\n\n PlayerSet.prototype.get = function (id) {\n return this._players[id];\n };\n\n PlayerSet.prototype.count = function () {\n return Object.keys(this._players).length;\n };\n\n PlayerSet.prototype.update = function (allPlayersData) {\n var freshPlayerData,\n existingPlayer,\n i;\n\n for (i = 0; i < allPlayersData.length; i++) {\n freshPlayerData = allPlayersData[i];\n existingPlayer = this._players[freshPlayerData.id];\n if (existingPlayer && existingPlayer.id === this.ego_id) {\n\n /* Don't override current player motion timestamp */\n freshPlayerData.motion_timestamp = existingPlayer.motion_timestamp;\n\n // Only override position from server if tremble is enabled,\n // or if we know the Player's position is out of sync with the server.\n // Otherwise, the ego player's motion is constantly jittery.\n if (settings.motion_tremble_rate === 0 && existingPlayer.positionInSync) {\n freshPlayerData.position = existingPlayer.position;\n } else {\n console.log(\"Overriding position from server!\");\n }\n }\n var last_dimness = 1;\n if (this._players[freshPlayerData.id] !== undefined) {\n last_dimness = this._players[freshPlayerData.id].dimness;\n }\n this._players[freshPlayerData.id] = new Player(freshPlayerData, last_dimness);\n }\n };\n\n PlayerSet.prototype.startScheduledAutosyncOfEgoPosition = function () {\n var self = this;\n setInterval(function () {\n var ego = self.ego();\n if (ego) {\n ego.positionInSync = false;\n console.log(\"Scheduled marking of (\" + ego.id + \") as out of sync with server.\");\n }\n }, 5000);\n };\n\n PlayerSet.prototype.maxScore = function () {\n var id,\n maxScore = 0;\n for (id in this._players) {\n if (this._players[id].score > maxScore) {\n maxScore = this._players[id].score;\n }\n }\n return maxScore;\n };\n\n PlayerSet.prototype.minScore = function () {\n var id,\n minScore = Infinity;\n for (id in this._players) {\n if (this._players[id].score < minScore) {\n minScore = this._players[id].score;\n }\n }\n return minScore;\n };\n\n PlayerSet.prototype.each = function (callback) {\n var i = 0;\n for (var id in this._players) {\n if (this._players.hasOwnProperty(id)) {\n callback(i, this._players[id]);\n i++;\n }\n }\n };\n\n PlayerSet.prototype.group_scores = function () {\n var group_scores = {};\n\n this.each(function (i, player) {\n var color_name = player.color;\n var cur_score = group_scores[color_name] || 0;\n group_scores[color_name] = cur_score + Math.round(player.score);\n });\n\n var group_order = Object.keys(group_scores).sort(function (a, b) {\n return group_scores[a] > group_scores[b] ? -1 : (group_scores[a] < group_scores[b] ? 1 : 0);\n });\n\n return group_order.map(function(color_name) {\n return {name: color_name, score: group_scores[color_name]};\n });\n };\n\n PlayerSet.prototype.player_scores = function () {\n var player_order = [];\n\n this.each(function(i, player) {\n player_order.push({id: player.id, name: player.name, score:player.score});\n });\n\n player_order = player_order.sort(function (a, b) {\n return a.score > b.score ? -1 : (a.score < b.score ? 1 : 0);\n });\n\n return player_order;\n };\n\n return PlayerSet;\n}());\n\nvar GUSocket = (function () {\n var makeSocket = function (endpoint, channel, tolerance) {\n var ws_scheme = (window.location.protocol === \"https:\") ? 'wss://' : 'ws://',\n app_root = ws_scheme + location.host + '/',\n socket;\n\n socket = new ReconnectingWebSocket(\n app_root + endpoint + \"?channel=\" + channel + \"&tolerance=\" + tolerance\n );\n socket.debug = true;\n\n return socket;\n };\n\n var dispatch = function (self, event) {\n var marker = self.broadcastChannel + ':';\n if (event.data.indexOf(marker) !== 0) {\n console.log(\n \"Message was not on channel \" + self.broadcastChannel + \". Ignoring.\");\n return;\n }\n var msg = JSON.parse(event.data.substring(marker.length));\n\n var callback = self.callbackMap[msg.type];\n if (typeof callback !== 'undefined') {\n callback(msg);\n } else {\n console.log(\"Unrecognized message type \" + msg.type + ' from backend.');\n }\n };\n\n /*\n * Public API\n */\n var Socket = function (settings) {\n if (!(this instanceof Socket)) {\n return new Socket(settings);\n }\n\n var self = this,\n isOpen = $.Deferred(),\n tolerance = typeof(settings.lagTolerance) !== 'undefined' ? settings.lagTolerance : 0.1;\n\n this.broadcastChannel = settings.broadcast;\n this.controlChannel = settings.control;\n this.callbackMap = settings.callbackMap;\n\n\n this.socket = makeSocket(\n settings.endpoint, this.broadcastChannel, tolerance);\n\n this.socket.onmessage = function (event) {\n dispatch(self, event);\n };\n };\n\n Socket.prototype.open = function () {\n var isOpen = $.Deferred();\n\n this.socket.onopen = function (event) {\n isOpen.resolve();\n };\n\n return isOpen;\n };\n\n Socket.prototype.send = function (data) {\n var msg = JSON.stringify(data),\n channel = this.controlChannel;\n\n console.log(\"Sending message to the \" + channel + \" channel: \" + msg);\n this.socket.send(channel + ':' + msg);\n };\n\n Socket.prototype.broadcast = function (data) {\n var msg = JSON.stringify(data),\n channel = this.broadcastChannel;\n\n console.log(\"Broadcasting message to the \" + channel + \" channel: \" + msg);\n this.socket.send(channel + ':' + msg);\n };\n\n return Socket;\n}());\n\n// ego will be updated on page load\nvar players = playerSet({'ego_id': undefined});\n\npixels.canvas.style.marginLeft = window.innerWidth * 0.03 / 2 + \"px\";\npixels.canvas.style.marginTop = window.innerHeight * 0.04 / 2 + \"px\";\ndocument.body.style.transition = \"0.3s all\";\ndocument.body.style.background = \"#ffffff\";\n\nvar startTime = performance.now();\n\npixels.frame(function() {\n // Update the background.\n var ego = players.ego(),\n w = getWindowPosition(),\n section = new Section(background, w.left, w.top),\n dimness,\n rescaling,\n x, y;\n\n // Animate background for each visible cell\n section.map(function(x, y, color) {\n var newColor = animateColor(color);\n background[coordsToIdx(x, y, settings.columns)] = newColor;\n return newColor;\n });\n\n for (const [position, item] of gridItems.entries()) {\n if (players.isPlayerAt(position)) {\n if (!item.interactive) {\n // Non-interactive items get consumed immediately\n gridItems.remove(position);\n }\n } else {\n section.plot(position[1], position[0], item.color);\n }\n }\n\n // Draw the players:\n players.drawToGrid(section);\n\n // Show info about the item the current player\n // is sharing a square with:\n if (! _.isUndefined(ego)) {\n updateItemInfoWindow(ego, gridItems);\n }\n\n // Add the Gaussian mask.\n var elapsedTime = performance.now() - startTime;\n var visibilityNow = clamp(\n (settings.visibility * elapsedTime) / (1000 * settings.visibility_ramp_time),\n 3,\n settings.visibility\n );\n if (settings.highlightEgo) {\n visibilityNow = Math.min(visibilityNow, 4);\n }\n var g = gaussian(0, Math.pow(visibilityNow, 2));\n rescaling = 1 / g.pdf(0);\n\n if (typeof ego !== \"undefined\") {\n x = ego.position[1];\n y = ego.position[0];\n } else {\n x = 1e100;\n y = 1e100;\n }\n section.map(function(i, j, color) {\n var newColor;\n // Draw walls\n if (settings.walls_visible) {\n color = wall_map[[i,j]] || color;\n }\n // Add Blur\n players.each(function (i, player) {\n dimness = g.pdf(distance(y, x, player.position[0], player.position[1])) * rescaling;\n player[\"dimness\"] = dimness;\n });\n newColor = color;\n if (!isSpectator) {\n dimness = g.pdf(distance(x, y, i, j)) * rescaling;\n newColor = [\n color[0] * dimness,\n color[1] * dimness,\n color[2] * dimness\n ];\n }\n return newColor;\n });\n pixels.update(section.data, section.textures);\n});\n\nfunction clamp(val, min, max) {\n return Math.max(min, Math.min(max, val));\n}\n\nfunction distance(x, y, xx, yy) {\n return Math.sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y));\n}\n\nfunction arraysEqual(arr1, arr2) {\n for (var i = arr1.length; i--; ) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction arraySearch(arr, val) {\n for (var i = 0; i < arr.length; i++) {\n if (arraysEqual(arr[i], val)) {\n return i;\n }\n }\n return false;\n}\n\nfunction getWindowPosition() {\n var ego = players.ego(),\n w = {\n left: 0,\n top: 0,\n columns: settings.window_columns,\n rows: settings.window_rows\n };\n\n if (typeof ego !== 'undefined') {\n w.left = clamp(\n ego.position[1] - Math.floor(settings.window_columns / 2),\n 0, settings.columns - settings.window_columns);\n w.top = clamp(\n ego.position[0] - Math.floor(settings.window_rows / 2),\n 0, settings.rows - settings.window_rows);\n }\n return w;\n}\n\nfunction bindGameKeys(socket) {\n var directions = [\"up\", \"down\", \"left\", \"right\"],\n repeatDelayMS = 1000 / settings.motion_speed_limit,\n lastDirection = null,\n repeatIntervalId = null,\n highlightEgo = false;\n\n function moveInDir(direction) {\n var ego = players.ego();\n if (ego.move(direction) ) {\n var msg = {\n type: \"move\",\n player_id: ego.id,\n move: direction,\n timestamp: ego.motion_timestamp\n };\n socket.send(msg);\n }\n }\n\n directions.forEach(function(direction) {\n Mousetrap.bind(\n direction,\n function(e) {\n e.preventDefault();\n if (direction === lastDirection) {\n return;\n }\n\n // New direction may be pressed before previous dir key is released\n if (repeatIntervalId) {\n clearInterval(repeatIntervalId);\n }\n\n moveInDir(direction); // Move once immediately so there's no lag\n lastDirection = direction;\n repeatIntervalId = setInterval(moveInDir, repeatDelayMS, direction);\n },\n 'keydown'\n );\n\n Mousetrap.bind(\n direction,\n function(e) {\n e.preventDefault();\n if (direction) {\n clearInterval(repeatIntervalId);\n lastDirection = null;\n }\n },\n \"keyup\"\n );\n\n });\n\n Mousetrap.bind(\"space\", function () {\n var msg_type;\n var ego = players.ego();\n var position = ego.position;\n var item_at_pos = gridItems.atPosition(position);\n var player_item = ego.currentItem;\n var transition = ego.getTransition();\n if (!item_at_pos && !player_item) {\n // If there's nothing here, we try to plant food GU 1.0 style\n msg_type = \"plant_food\";\n } else if (transition) {\n // Check for a transition between objects. For now we don't do anything\n // client-side other checking that it exists. We could optimize display\n // updates later\n msg_type = \"item_transition\";\n transitionsSeen.add(transition.id);\n } else if (player_item && player_item.calories) {\n // If there's nothing here to transition with and we're holding something\n // edible, consume it.\n msg_type = \"item_consume\";\n player_item.remainingUses = player_item.remainingUses - 1;\n if (player_item.remainingUses < 1) {\n ego.replaceItem(null);\n }\n } else if (!player_item && item_at_pos && item_at_pos.portable) {\n // If there's a portable item here and we don't something in hand, pick it up.\n msg_type = \"item_pick_up\";\n gridItems.remove(position);\n ego.replaceItem(item_at_pos);\n }\n if (!msg_type) {\n return;\n }\n var msg = {\n type: msg_type,\n player_id: ego.id,\n position: position\n };\n socket.send(msg);\n });\n\n Mousetrap.bind(\"d\", function () {\n var ego = players.ego();\n var position = ego.position;\n var currentItem = ego.currentItem;\n if (!currentItem || gridItems.atPosition(position)) {\n return;\n }\n var msg = {\n type: \"item_drop\",\n player_id: ego.id,\n position: position\n };\n socket.send(msg);\n ego.replaceItem(null);\n gridItems.add(currentItem, position);\n });\n\n if (settings.mutable_colors) {\n Mousetrap.bind('c', function () {\n var keys = settings.player_color_names,\n index = arraySearch(keys, players.ego().color),\n nextItem = keys[(index + 1) % keys.length],\n msg;\n\n players.ego().color = nextItem;\n msg = {\n type: \"change_color\",\n player_id: players.ego().id,\n color: players.ego().color\n };\n socket.send(msg);\n });\n }\n\n if (settings.identity_signaling) {\n Mousetrap.bind(\"v\", function () {\n var ego = players.ego(),\n msg;\n\n ego.identity_visible = !ego.identity_visible;\n msg = {\n type: \"toggle_visible\",\n player_id: ego.id,\n identity_visible: ego.identity_visible\n };\n socket.send(msg);\n });\n }\n\n if (settings.build_walls) {\n Mousetrap.bind(\"w\", function () {\n var msg = {\n type: \"build_wall\",\n player_id: players.ego().id,\n position: players.ego().position\n };\n socket.send(msg);\n });\n }\n\n Mousetrap.bind(\"h\", function () {\n settings.highlightEgo = !settings.highlightEgo;\n });\n}\n\nfunction chatName(player_id) {\n var ego = players.ego(),\n entry = \"<span class='name'>\",\n id = parseInt(player_id) - 1,\n salt = $(\"#grid\").data(\"identicon-salt\"),\n fg = settings.player_colors[name2idx(players.get(player_id).color)].concat(1),\n bg,\n identicon,\n name,\n options;\n\n if (id === ego) {\n name = \"You\";\n } else if (settings.pseudonyms) {\n name = players.get(player_id).name;\n } else if (player_id % 1 === 0) {\n name = \"Player \" + player_id;\n } else {\n // Non-integer player_id\n return '<span class=\"name\">' + player_id + '</span>';\n }\n\n fg = fg.map(function(x) { return x * 255; });\n bg = fg.map(function(x) { return (x * 0.66); });\n bg[3] = 255;\n options = {\n size: 10,\n foreground: fg,\n background: bg,\n format: 'svg'\n };\n\n identicon = new Identicon(md5(salt + id), options).toString();\n if (settings.use_identicons) {\n entry = entry + \" <img src='data:image/svg+xml;base64,\" + identicon + \"' />\";\n }\n entry = entry + \" \" + name + \"</span> \";\n return entry;\n}\n\nfunction onChatMessage(msg) {\n var entry = chatName(msg.player_id);\n if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) {\n return;\n }\n $(\"#messages\").append(($(\"<li>\").text(\": \" + msg.contents)).prepend(entry));\n $(\"#chatlog\").scrollTop($(\"#chatlog\")[0].scrollHeight);\n}\n\nfunction onColorChanged(msg) {\n store.set(\"color\", msg.new_color);\n if (settings.spatial_chat && players.get(msg.player_id).dimness < settings.chat_visibility_threshold) {\n return;\n }\n pushMessage(\"<span class='name'>Moderator:</span> \" + chatName(msg.player_id) + ' changed from team ' + msg.old_color + ' to team ' + msg.new_color + '.');\n}\n\nfunction onMoveRejected(msg) {\n var offendingPlayerId = msg.player_id,\n ego = players.ego();\n\n if (ego && offendingPlayerId === ego.id) {\n ego.positionInSync = false;\n console.log(\"Marking your player (\" + ego.id + \") as out of sync with server. Should sync on next state update\");\n }\n}\n\nfunction onDonationProcessed(msg) {\n var donor = players.get(msg.donor_id),\n recipient_id = msg.recipient_id,\n team_idx,\n donor_name,\n recipient_name,\n donated_points,\n received_points,\n entry;\n\n donor_name = chatName(msg.donor_id);\n\n if (recipient_id === 'all') {\n recipient_name = '<span class=\"name\">All players</span>';\n } else if (recipient_id.indexOf('group:') === 0) {\n team_idx = +recipient_id.substring(6);\n recipient_name = 'Everyone in <span class=\"name\">' + settings.player_color_names[team_idx] + '</span>';\n } else {\n recipient_name = chatName(recipient_id);\n }\n\n if (msg.amount === 1) {\n donated_points = msg.amount + ' point.';\n } else {\n donated_points = msg.amount + ' points.';\n }\n\n if (msg.received === 1) {\n received_points = msg.received + ' point.';\n } else {\n received_points = msg.received + ' points.';\n }\n\n entry = donor_name + \" contributed \" + donated_points + \" \" + recipient_name + \" received \" + received_points;\n\n $(\"#messages\").append($(\"<li>\").html(entry));\n $(\"#chatlog\").scrollTop($(\"#chatlog\")[0].scrollHeight);\n $('#individual-donate, #group-donate').addClass('button-outline');\n $('#donate label').text($('#donate label').data('orig-text'));\n settings.donation_type = null;\n}\n\nfunction updateDonationStatus(donation_is_active) {\n // If alternating donation/consumption rounds, announce round type\n if (settings.alternate_consumption_donation && (settings.donation_active !== donation_is_active)) {\n if (donation_is_active) {\n pushMessage(\"<span class='name'>Moderator:</span> Starting a donation round. Players cannot move, only donate.\");\n } else {\n pushMessage(\"<span class='name'>Moderator:</span> Starting a consumption round. Players have to consume as much food as possible.\");\n }\n }\n // Update donation status\n settings.donation_active = donation_is_active;\n}\n\n\nfunction renderTransition(transition) {\n if (! transition) {\n return \"\";\n }\n const transition_visibility = transition.transition.visible;\n const states = [\n transition.transition.actor_start,\n transition.transition.actor_end,\n transition.transition.target_start,\n transition.transition.target_end\n ];\n\n const [aStartItem, aEndItem, tStartItem, tEndItem] = states.map(\n (state) => settings.item_config[state]\n );\n\n const aStartItemString = `✋${aStartItem ? aStartItem.name : '⬜'}`;\n const tStartItemString = tStartItem ? tStartItem.name : '⬜';\n if (transition_visibility == \"never\") {\n return `${aStartItemString} + ${tStartItemString}`\n }\n \n if (transition_visibility == \"seen\" && !transitionsSeen.has(transition.id)) {\n var aEndItemString = \"✋❓\";\n var tEndItemString = \"✋❓\";\n } else {\n aEndItemString = `✋${aEndItem ? aEndItem.name: '⬜'}`;\n tEndItemString = tEndItem ? tEndItem.name: '⬜';\n }\n return `${aStartItemString} + ${tStartItemString} → ${aEndItemString} + ${tEndItemString}`;\n\n}\n/**\n * If the current player is sharing a grid position with an interactive\n * item, we show information about it on the page.\n *\n * @param {Player} egoPlayer the current Player\n * @param {itemlib.GridItems} gridItems the collection of all Items on the grid\n */\nfunction updateItemInfoWindow(egoPlayer, gridItems) {\n const inspectedItem = gridItems.atPosition(egoPlayer.position),\n transition = egoPlayer.getTransition(),\n $square = $(\"#location-contents-item\"),\n $transition = $(\"#transition-details\");\n\n if (! inspectedItem) {\n $square.empty();\n } else {\n $square.html(inspectedItem.name);\n }\n\n if (! transition) {\n // If we're holding an item with calories, indicate that we might want to eat it.\n if (egoPlayer.currentItem && egoPlayer.currentItem.calories) {\n $transition.html(`✋${egoPlayer.currentItem.name} + 🤤`);\n } else {\n $transition.empty();\n }\n } else {\n $transition.html(renderTransition(transition));\n }\n}\n\nfunction displayWhatEgoPlayerIsCarrying(item) {\n $('#inventory-item').text(item ? item.name : '');\n}\n\nfunction onGameStateChange(msg) {\n var $donationButtons = $('#individual-donate, #group-donate, #public-donate, #ingroup-donate'),\n $timeElement = $(\"#time\"),\n $loading = $('.grid-loading'),\n cur_wall,\n ego,\n state,\n j,\n k;\n\n performance.mark('state_start');\n if ($loading.is(':visible')) $loading.fadeOut();\n\n if (settings.paused_game) {\n $timeElement.html(0);\n return;\n }\n\n // Update remaining time.\n $timeElement.html(Math.max(Math.round(msg.remaining_time), 0));\n\n // Update round.\n if (settings.num_rounds > 1) {\n $(\"#round\").html(msg.round + 1);\n }\n\n // Update players.\n state = JSON.parse(msg.grid);\n players.update(state.players);\n ego = players.ego();\n\n updateDonationStatus(state.donation_active);\n\n // Update gridItems\n if (state.items !== undefined && state.items !== null) {\n gridItems = new itemlib.GridItems();\n for (j = 0; j < state.items.length; j++) {\n\n gridItems.add(\n new itemlib.Item(\n state.items[j].id,\n state.items[j].item_id,\n state.items[j].maturity,\n state.items[j].remaining_uses,\n ),\n state.items[j].position\n );\n }\n }\n // Update walls if they haven't been created yet.\n if (state.walls !== undefined && walls.length === 0) {\n for (k = 0; k < state.walls.length; k++) {\n cur_wall = state.walls[k];\n if (cur_wall instanceof Array) {\n cur_wall = {\n position: cur_wall,\n color: [0.5, 0.5, 0.5]\n };\n }\n walls.push(\n new Wall({\n position: cur_wall.position,\n color: cur_wall.color\n })\n );\n wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color;\n }\n }\n\n // If new walls have been added, draw them\n if (state.walls !== undefined && walls.length < state.walls.length) {\n for (k = walls.length; k < state.walls.length; k++) {\n cur_wall = state.walls[k];\n walls.push(\n new Wall({\n position: cur_wall.position,\n color: cur_wall.color\n })\n );\n wall_map[[cur_wall.position[1], cur_wall.position[0]]] = cur_wall.color;\n }\n }\n\n // Update displayed score, set donation info.\n if (ego !== undefined) {\n $(\"#score\").html(Math.round(ego.score));\n $(\"#dollars\").html(ego.payoff.toFixed(2));\n window.state = msg.grid;\n window.ego = ego.id;\n if (settings.donation_active &&\n ego.score >= settings.donation_amount &&\n players.count() > 1\n ) {\n $donationButtons.prop('disabled', false);\n } else {\n $('#donation-instructions').text('');\n $donationButtons.prop('disabled', true);\n }\n }\n}\n\nfunction addWall(msg) {\n var wall = msg.wall;\n if (wall) {\n walls.push(\n new Wall({\n position: wall.position,\n color: wall.color\n })\n );\n wall_map[[wall.position[1], wall.position[0]]] = wall.color;\n }\n}\n\nfunction pushMessage(html) {\n $(\"#messages\").append(($(\"<li>\").html(html)));\n $(\"#chatlog\").scrollTop($(\"#chatlog\")[0].scrollHeight);\n}\n\nfunction displayLeaderboards(msg, callback) {\n if (!settings.leaderboard_group && !settings.leaderboard_individual) {\n if (callback) {\n callback();\n }\n return;\n }\n var i;\n if (msg.type === 'new_round') {\n pushMessage(\"<span class='name'>Moderator:</span> the round \" + msg.round + ' standings are…');\n } else {\n pushMessage(\"<span class='name'>Moderator:</span> the final standings are …\");\n }\n if (settings.leaderboard_group) {\n if (settings.leaderboard_individual) {\n pushMessage('<em>Group</em>');\n }\n var group_scores = players.group_scores();\n var rgb_map = function (e) { return Math.round(e * 255); };\n for (i = 0; i < group_scores.length; i++) {\n var group = group_scores[i];\n var color = settings.player_colors[name2idx(group.name)].map(rgb_map);\n pushMessage('<span class=\"GroupScore\">' + group.score + '</span><span class=\"GroupIndicator\" style=\"background-color:' + Color.rgb(color).string() +';\"></span>');\n }\n }\n if (settings.leaderboard_individual) {\n if (settings.leaderboard_group) {\n pushMessage('<em>Individual</em>');\n }\n var player_scores = players.player_scores();\n var ego_id = players.ego_id;\n for (i = 0; i < player_scores.length; i++) {\n var player = player_scores[i];\n var player_name = chatName(player.id);\n pushMessage('<span class=\"PlayerScore\">' + Math.round(player.score) + '</span><span class=\"PlayerName\">' + player_name + '</span>');\n }\n }\n if (settings.leaderboard_time) {\n settings.paused_game = true;\n setTimeout(function () {\n settings.paused_game = false;\n if (callback) {\n callback();\n }\n }, 1000 * settings.leaderboard_time);\n } else if (callback) {\n callback();\n }\n}\n\nfunction gameOverHandler(player_id) {\n var callback;\n if (!isSpectator) {\n callback = function () {\n $(\"#dashboard\").hide();\n $(\"#instructions\").hide();\n $(\"#chat\").hide();\n if (player_id) {\n window.location.href = \"/questionnaire?participant_id=\" + player_id;\n }\n };\n pixels.canvas.style.display = \"none\";\n }\n return function (msg) {\n $(\"#game-over\").show();\n return displayLeaderboards(msg, callback);\n };\n}\n\n$(document).ready(function() {\n var player_id = dallinger.getUrlParameter('participant_id');\n isSpectator = typeof player_id === 'undefined';\n var socketSettings = {\n 'endpoint': 'chat',\n 'broadcast': CHANNEL,\n 'control': CONTROL_CHANNEL,\n 'lagTolerance': 0.001,\n 'callbackMap': {\n 'chat': onChatMessage,\n 'donation_processed': onDonationProcessed,\n 'color_changed': onColorChanged,\n 'state': onGameStateChange,\n 'new_round': displayLeaderboards,\n 'stop': gameOverHandler(player_id),\n 'wall_built': addWall,\n 'move_rejection': onMoveRejected\n }\n };\n var socket = new GUSocket(socketSettings);\n\n socket.open().done(function () {\n var data = {\n type: 'connect',\n player_id: isSpectator ? 'spectator' : player_id\n };\n socket.send(data);\n });\n\n players.ego_id = player_id;\n players.startScheduledAutosyncOfEgoPosition();\n $('#donate label').data('orig-text', $('#donate label').text());\n\n setInterval(function () {\n var delays = [],\n start_marks = performance.getEntriesByName('state_start', 'mark');\n for (var i = 0; i < start_marks.length; i++) {\n if (start_marks.length > i + 2) {\n delays.push(start_marks[i+1].startTime - start_marks[i].startTime);\n }\n }\n if (delays.length) {\n var average_delay = delays.reduce(function(sum, value){\n return sum + value;\n }, 0) / delays.length;\n console.log('Average delay between state updates: ' + average_delay + 'ms.');\n }\n }, 5000);\n\n // Append the canvas.\n $(\"#grid\").append(pixels.canvas);\n\n // Opt out of the experiment.\n $(\"#opt-out\").click(function() {\n window.location.href = \"/questionnaire?participant_id=\" + player_id;\n });\n\n if (isSpectator) {\n $(\".for-players\").hide();\n }\n\n // Consent to the experiment.\n $(\"#go-to-experiment\").click(function() {\n window.location.href = \"/exp\";\n });\n\n // Submit the questionnaire.\n $(\"#submit-questionnaire\").click(function() {\n dallinger.submitResponses();\n });\n\n if (settings.show_grid) {\n pixels.canvas.style.display = \"inline\";\n }\n\n if (settings.show_chatroom) {\n $(\"#chat form\").show();\n }\n\n var donateToClicked = function() {\n var w = getWindowPosition(),\n row = w.top + pixels2cells(mouse[1]),\n column = w.left + pixels2cells(mouse[0]),\n recipient = players.nearest(row, column),\n donor = players.ego(),\n amt = settings.donation_amount,\n recipient_id,\n msg;\n\n if (!settings.donation_active) {\n return;\n }\n\n if (amt > donor.score) {\n return;\n }\n\n if (settings.donation_type === 'individual') {\n recipient_id = recipient.id;\n } else if (settings.donation_type === 'group') {\n recipient_id = 'group:' + name2idx(recipient.color).toString();\n } else {\n return;\n }\n\n if (recipient_id !== donor.id) {\n msg = {\n type: \"donation_submitted\",\n recipient_id: recipient_id,\n donor_id: donor.id,\n amount: amt\n };\n socket.send(msg);\n }\n };\n\n var donateToAll = function() {\n var donor = players.ego(),\n amt = settings.donation_amount,\n msg;\n\n msg = {\n type: \"donation_submitted\",\n recipient_id: 'all',\n donor_id: donor.id,\n amount: amt\n };\n socket.send(msg);\n };\n\n var donateToInGroup = function () {\n var donor = players.ego(),\n amt = settings.donation_amount,\n recipientId = 'group:' + name2idx(donor.color).toString(),\n msg;\n\n msg = {\n type: \"donation_submitted\",\n recipient_id: recipientId,\n donor_id: donor.id,\n amount: amt\n };\n socket.send(msg);\n };\n\n var pixels2cells = function(pix) {\n return Math.floor(pix / (settings.block_size + settings.padding));\n };\n\n $(\"form\").submit(function() {\n var chatmessage = $(\"#message\").val().trim(),\n msg;\n\n if (! chatmessage) {\n return false;\n }\n\n try {\n msg = {\n type: 'chat',\n contents: chatmessage,\n player_id: players.ego().id,\n timestamp: performance.now() - start,\n broadcast: true\n };\n // send directly to all clients\n socket.broadcast(msg);\n // Also send to the server for logging\n socket.send(msg);\n } catch(err) {\n console.error(err);\n } finally {\n $(\"#message\").val(\"\");\n return false;\n }\n });\n\n if (!isSpectator) {\n // Main game keys:\n bindGameKeys(socket);\n // Donation click events:\n $(pixels.canvas).click(function (e) {\n donateToClicked();\n });\n $('#public-donate').click(donateToAll);\n $('#ingroup-donate').click(donateToInGroup);\n $('#group-donate').click(function () {\n if (settings.donation_group) {\n $('#donate label').text('Click on a color');\n settings.donation_type = 'group';\n $(this).prop('disabled', false);\n $(this).removeClass('button-outline');\n $('#individual-donate').addClass('button-outline');\n }\n });\n $('#individual-donate').click(function () {\n if (settings.donation_individual) {\n $('#donate label').text('Click on a player');\n settings.donation_type = 'individual';\n $(this).removeClass('button-outline');\n $('#group-donate').addClass('button-outline');\n }\n });\n }\n\n});\n\n}(dallinger, require, window.settings));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/demo.js\n// module id = 16\n// module chunks = 0","var lodash = require(\"lodash\");\nvar isarray = require(\"is-array\");\nvar isnumber = require(\"is-number\");\nvar isstring = require(\"is-string\");\nvar parse = require(\"parse-color\");\n\nfunction convert(data) {\n data = isarray(data[0]) && data[0].length !== 3 ? lodash.flatten(data, 1) : data;\n\n if (isnumber(data[0])) {\n data = data.map(function(d) {\n return [ d, d, d ];\n });\n }\n\n if (isstring(data[0])) {\n data = data.map(function(d) {\n return parse(d).rgb.map(function(c) {\n return c / 255;\n });\n });\n }\n\n return data;\n}\n\nmodule.exports = convert;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/convert.js\n// module id = 19\n// module chunks = 0","function layout(rows, columns, padding, size, aspect) {\n var grid = [];\n\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n var x = -1 + aspect * (i * (padding + size) + padding);\n var y = 1 - (j * (padding + size) + padding);\n grid.push([ y, x ]);\n var x_next = x + size - padding;\n grid.push([ y, x_next ]);\n var y_next = y - size + padding;\n grid.push([ y_next, x ]);\n\n grid.push([ y_next, x ]);\n grid.push([ y, x_next ]);\n grid.push([ y_next, x_next ]);\n\n }\n }\n\n return grid.reverse();\n}\n\n\nmodule.exports = layout;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/layout.js\n// module id = 20\n// module chunks = 0","/**\n * Derived from Identicon.js 2.3.1\n * http://github.com/stewartlord/identicon.js\n *\n * Copyright 2017, Stewart Lord and Dallinger Contributors\n * Released under the BSD license\n * http://www.opensource.org/licenses/bsd-license.php\n */\n\n\nvar Identicon = function(hash, size, options){\n if (typeof(hash) !== 'string' || hash.length < 15) {\n throw 'A hash of at least 15 characters is required.';\n }\n\n this.defaults = {\n background: [240, 240, 240, 255],\n margin: 0.08,\n size: 64,\n saturation: 0.7,\n brightness: 0.5,\n format: 'pixels'\n };\n\n this.options = typeof(options) === 'object' ? options : this.defaults;\n\n this.hash = hash\n this.background = [128, 128, 128];\n this.foreground = [255, 255, 255];\n this.size = size;\n};\n\nIdenticon.prototype = {\n background: null,\n foreground: null,\n hash: null,\n margin: null,\n size: null,\n format: null,\n\n image: function(){\n return new Pixels(this.size, this.foreground, this.background)\n },\n\n render: function(){\n var image = this.image(),\n size = this.size,\n baseMargin = Math.floor(size * this.margin),\n cell = Math.floor((size - (baseMargin * 2)) / 5),\n margin = Math.floor((size - cell * 5) / 2),\n bg = this.background,\n fg = this.foreground;\n\n // the first 15 characters of the hash control the pixels (even/odd)\n // they are drawn down the middle first, then mirrored outwards\n var i, color;\n for (i = 0; i < 15; i++) {\n color = parseInt(this.hash.charAt(i), 16) % 2 ? bg : fg;\n if (i < 5) {\n this.rectangle(2 * cell + margin, i * cell + margin, cell, cell, color, image);\n } else if (i < 10) {\n this.rectangle(1 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n this.rectangle(3 * cell + margin, (i - 5) * cell + margin, cell, cell, color, image);\n } else if (i < 15) {\n this.rectangle(0 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n this.rectangle(4 * cell + margin, (i - 10) * cell + margin, cell, cell, color, image);\n }\n }\n\n return image;\n },\n\n rectangle: function(x, y, w, h, color, image){\n var i, j;\n for (i = x; i < x + w; i++) {\n for (j = y; j < y + h; j++) {\n image.buffer[j][i] = color;\n }\n }\n }\n\n};\n\nvar Pixels = function(size){\n this.buffer = [];\n for (i = 0; i < size; i++) {\n var row = []\n for (j = 0; j < size; j++) {\n row.push([0,0,120]);\n }\n this.buffer.push(row);\n }\n};\n\nPixels.prototype = {\n pixels: null,\n\n};\n\n\nmodule.exports = Identicon;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/pixdenticon.js\n// module id = 21\n// module chunks = 0","/**\n* A handy class to calculate color values.\n*\n* @version 1.0\n* @author Robert Eisele <robert@xarg.org>\n* @copyright Copyright (c) 2010, Robert Eisele\n* @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/\n* @license http://www.opensource.org/licenses/bsd-license.php BSD License\n*\n*/\n\n(function() {\n \n // helper functions for that ctx\n function write(buffer, offs) {\n for (var i = 2; i < arguments.length; i++) {\n for (var j = 0; j < arguments[i].length; j++) {\n buffer[offs++] = arguments[i].charAt(j);\n }\n }\n }\n \n function byte2(w) {\n return String.fromCharCode((w >> 8) & 255, w & 255);\n }\n \n function byte4(w) {\n return String.fromCharCode((w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w & 255);\n }\n \n function byte2lsb(w) {\n return String.fromCharCode(w & 255, (w >> 8) & 255);\n }\n \n // modified from original source to support NPM\n var PNGlib = function(width,height,depth) {\n \n this.width = width;\n this.height = height;\n this.depth = depth;\n \n // pixel data and row filter identifier size\n this.pix_size = height * (width + 1);\n \n // deflate header, pix_size, block headers, adler32 checksum\n this.data_size = 2 + this.pix_size + 5 * Math.floor((0xfffe + this.pix_size) / 0xffff) + 4;\n \n // offsets and sizes of Png chunks\n this.ihdr_offs = 0;\t\t\t\t\t\t\t\t\t// IHDR offset and size\n this.ihdr_size = 4 + 4 + 13 + 4;\n this.plte_offs = this.ihdr_offs + this.ihdr_size;\t// PLTE offset and size\n this.plte_size = 4 + 4 + 3 * depth + 4;\n this.trns_offs = this.plte_offs + this.plte_size;\t// tRNS offset and size\n this.trns_size = 4 + 4 + depth + 4;\n this.idat_offs = this.trns_offs + this.trns_size;\t// IDAT offset and size\n this.idat_size = 4 + 4 + this.data_size + 4;\n this.iend_offs = this.idat_offs + this.idat_size;\t// IEND offset and size\n this.iend_size = 4 + 4 + 4;\n this.buffer_size = this.iend_offs + this.iend_size;\t// total PNG size\n \n this.buffer = new Array();\n this.palette = new Object();\n this.pindex = 0;\n \n var _crc32 = new Array();\n \n // initialize buffer with zero bytes\n for (var i = 0; i < this.buffer_size; i++) {\n this.buffer[i] = \"\\x00\";\n }\n \n // initialize non-zero elements\n write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), 'IHDR', byte4(width), byte4(height), \"\\x08\\x03\");\n write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), 'PLTE');\n write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), 'tRNS');\n write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), 'IDAT');\n write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), 'IEND');\n \n // initialize deflate header\n var header = ((8 + (7 << 4)) << 8) | (3 << 6);\n header+= 31 - (header % 31);\n \n write(this.buffer, this.idat_offs + 8, byte2(header));\n \n // initialize deflate block headers\n for (var i = 0; (i << 16) - 1 < this.pix_size; i++) {\n var size, bits;\n if (i + 0xffff < this.pix_size) {\n size = 0xffff;\n bits = \"\\x00\";\n } else {\n size = this.pix_size - (i << 16) - i;\n bits = \"\\x01\";\n }\n write(this.buffer, this.idat_offs + 8 + 2 + (i << 16) + (i << 2), bits, byte2lsb(size), byte2lsb(~size));\n }\n \n /* Create crc32 lookup table */\n for (var i = 0; i < 256; i++) {\n var c = i;\n for (var j = 0; j < 8; j++) {\n if (c & 1) {\n c = -306674912 ^ ((c >> 1) & 0x7fffffff);\n } else {\n c = (c >> 1) & 0x7fffffff;\n }\n }\n _crc32[i] = c;\n }\n \n // compute the index into a png for a given pixel\n this.index = function(x,y) {\n var i = y * (this.width + 1) + x + 1;\n var j = this.idat_offs + 8 + 2 + 5 * Math.floor((i / 0xffff) + 1) + i;\n return j;\n }\n \n // convert a color and build up the palette\n this.color = function(red, green, blue, alpha) {\n \n alpha = alpha >= 0 ? alpha : 255;\n var color = (((((alpha << 8) | red) << 8) | green) << 8) | blue;\n \n if (typeof this.palette[color] == \"undefined\") {\n if (this.pindex == this.depth) return \"\\x00\";\n \n var ndx = this.plte_offs + 8 + 3 * this.pindex;\n \n this.buffer[ndx + 0] = String.fromCharCode(red);\n this.buffer[ndx + 1] = String.fromCharCode(green);\n this.buffer[ndx + 2] = String.fromCharCode(blue);\n this.buffer[this.trns_offs+8+this.pindex] = String.fromCharCode(alpha);\n \n this.palette[color] = String.fromCharCode(this.pindex++);\n }\n return this.palette[color];\n }\n \n // output a PNG string, Base64 encoded\n this.getBase64 = function() {\n \n var s = this.getDump();\n \n var ch = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n var c1, c2, c3, e1, e2, e3, e4;\n var l = s.length;\n var i = 0;\n var r = \"\";\n \n do {\n c1 = s.charCodeAt(i);\n e1 = c1 >> 2;\n c2 = s.charCodeAt(i+1);\n e2 = ((c1 & 3) << 4) | (c2 >> 4);\n c3 = s.charCodeAt(i+2);\n if (l < i+2) { e3 = 64; } else { e3 = ((c2 & 0xf) << 2) | (c3 >> 6); }\n if (l < i+3) { e4 = 64; } else { e4 = c3 & 0x3f; }\n r+= ch.charAt(e1) + ch.charAt(e2) + ch.charAt(e3) + ch.charAt(e4);\n } while ((i+= 3) < l);\n return r;\n }\n \n // output a PNG string\n this.getDump = function() {\n \n // compute adler32 of output pixels + row filter bytes\n var BASE = 65521; /* largest prime smaller than 65536 */\n var NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n var s1 = 1;\n var s2 = 0;\n var n = NMAX;\n \n for (var y = 0; y < this.height; y++) {\n for (var x = -1; x < this.width; x++) {\n s1+= this.buffer[this.index(x, y)].charCodeAt(0);\n s2+= s1;\n if ((n-= 1) == 0) {\n s1%= BASE;\n s2%= BASE;\n n = NMAX;\n }\n }\n }\n s1%= BASE;\n s2%= BASE;\n write(this.buffer, this.idat_offs + this.idat_size - 8, byte4((s2 << 16) | s1));\n \n // compute crc32 of the PNG chunks\n function crc32(png, offs, size) {\n var crc = -1;\n for (var i = 4; i < size-4; i += 1) {\n crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff);\n }\n write(png, offs+size-4, byte4(crc ^ -1));\n }\n \n crc32(this.buffer, this.ihdr_offs, this.ihdr_size);\n crc32(this.buffer, this.plte_offs, this.plte_size);\n crc32(this.buffer, this.trns_offs, this.trns_size);\n crc32(this.buffer, this.idat_offs, this.idat_size);\n crc32(this.buffer, this.iend_offs, this.iend_size);\n \n // convert PNG to string\n return \"\\x89PNG\\r\\n\\x1a\\n\"+this.buffer.join('');\n }\n }\n \n // modified from original source to support NPM\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n module.exports = PNGlib;\n } else {\n window.PNGlib = PNGlib;\n }\n })();\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/pnglib.js\n// module id = 22\n// module chunks = 0","function range(j, k) { \n return Array\n .apply(null, Array((k - j) + 1))\n .map(function(discard, n){ return n + j; }); \n}\n\n\n\nmodule.exports = range;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/range.js\n// module id = 23\n// module chunks = 0","function texcoord(rows, columns, texture_indexes, num_textures) {\n var grid = [];\n var texture;\n var texture_start;\n var texture_next;\n\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n texture = texture_indexes[i*rows + j];\n texture_start = (1/num_textures)*texture;\n texture_next = texture_start + (1/num_textures);\n\n grid.push([ 0, texture_start ]);\n grid.push([ 1, texture_start ]);\n grid.push([ 0, texture_next ]);\n \n grid.push([ 0, texture_next ]);\n grid.push([ 1, texture_start ]);\n grid.push([ 1, texture_next ]);\n }\n }\n\n return grid;\n}\n\n\nmodule.exports = texcoord;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/util/texcoord.js\n// module id = 24\n// module chunks = 0","var conversions = require('./conversions');\nvar route = require('./route');\n\nvar convert = {};\n\nvar models = Object.keys(conversions);\n\nfunction wrapRaw(fn) {\n\tvar wrappedFn = function (args) {\n\t\tif (args === undefined || args === null) {\n\t\t\treturn args;\n\t\t}\n\n\t\tif (arguments.length > 1) {\n\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t}\n\n\t\treturn fn(args);\n\t};\n\n\t// preserve .conversion property if there is one\n\tif ('conversion' in fn) {\n\t\twrappedFn.conversion = fn.conversion;\n\t}\n\n\treturn wrappedFn;\n}\n\nfunction wrapRounded(fn) {\n\tvar wrappedFn = function (args) {\n\t\tif (args === undefined || args === null) {\n\t\t\treturn args;\n\t\t}\n\n\t\tif (arguments.length > 1) {\n\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t}\n\n\t\tvar result = fn(args);\n\n\t\t// we're assuming the result is an array here.\n\t\t// see notice in conversions.js; don't use box types\n\t\t// in conversion functions.\n\t\tif (typeof result === 'object') {\n\t\t\tfor (var len = result.length, i = 0; i < len; i++) {\n\t\t\t\tresult[i] = Math.round(result[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// preserve .conversion property if there is one\n\tif ('conversion' in fn) {\n\t\twrappedFn.conversion = fn.conversion;\n\t}\n\n\treturn wrappedFn;\n}\n\nmodels.forEach(function (fromModel) {\n\tconvert[fromModel] = {};\n\n\tObject.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});\n\tObject.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});\n\n\tvar routes = route(fromModel);\n\tvar routeModels = Object.keys(routes);\n\n\trouteModels.forEach(function (toModel) {\n\t\tvar fn = routes[toModel];\n\n\t\tconvert[fromModel][toModel] = wrapRounded(fn);\n\t\tconvert[fromModel][toModel].raw = wrapRaw(fn);\n\t});\n});\n\nmodule.exports = convert;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color-convert/index.js\n// module id = 25\n// module chunks = 0","var conversions = require('./conversions');\n\n/*\n\tthis function routes a model to all other models.\n\n\tall functions that are routed have a property `.conversion` attached\n\tto the returned synthetic function. This property is an array\n\tof strings, each with the steps in between the 'from' and 'to'\n\tcolor models (inclusive).\n\n\tconversions that are not possible simply are not included.\n*/\n\nfunction buildGraph() {\n\tvar graph = {};\n\t// https://jsperf.com/object-keys-vs-for-in-with-closure/3\n\tvar models = Object.keys(conversions);\n\n\tfor (var len = models.length, i = 0; i < len; i++) {\n\t\tgraph[models[i]] = {\n\t\t\t// http://jsperf.com/1-vs-infinity\n\t\t\t// micro-opt, but this is simple.\n\t\t\tdistance: -1,\n\t\t\tparent: null\n\t\t};\n\t}\n\n\treturn graph;\n}\n\n// https://en.wikipedia.org/wiki/Breadth-first_search\nfunction deriveBFS(fromModel) {\n\tvar graph = buildGraph();\n\tvar queue = [fromModel]; // unshift -> queue -> pop\n\n\tgraph[fromModel].distance = 0;\n\n\twhile (queue.length) {\n\t\tvar current = queue.pop();\n\t\tvar adjacents = Object.keys(conversions[current]);\n\n\t\tfor (var len = adjacents.length, i = 0; i < len; i++) {\n\t\t\tvar adjacent = adjacents[i];\n\t\t\tvar node = graph[adjacent];\n\n\t\t\tif (node.distance === -1) {\n\t\t\t\tnode.distance = graph[current].distance + 1;\n\t\t\t\tnode.parent = current;\n\t\t\t\tqueue.unshift(adjacent);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn graph;\n}\n\nfunction link(from, to) {\n\treturn function (args) {\n\t\treturn to(from(args));\n\t};\n}\n\nfunction wrapConversion(toModel, graph) {\n\tvar path = [graph[toModel].parent, toModel];\n\tvar fn = conversions[graph[toModel].parent][toModel];\n\n\tvar cur = graph[toModel].parent;\n\twhile (graph[cur].parent) {\n\t\tpath.unshift(graph[cur].parent);\n\t\tfn = link(conversions[graph[cur].parent][cur], fn);\n\t\tcur = graph[cur].parent;\n\t}\n\n\tfn.conversion = path;\n\treturn fn;\n}\n\nmodule.exports = function (fromModel) {\n\tvar graph = deriveBFS(fromModel);\n\tvar conversion = {};\n\n\tvar models = Object.keys(graph);\n\tfor (var len = models.length, i = 0; i < len; i++) {\n\t\tvar toModel = models[i];\n\t\tvar node = graph[toModel];\n\n\t\tif (node.parent === null) {\n\t\t\t// no possible conversion, or this node is the source model.\n\t\t\tcontinue;\n\t\t}\n\n\t\tconversion[toModel] = wrapConversion(toModel, graph);\n\t}\n\n\treturn conversion;\n};\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color-convert/route.js\n// module id = 26\n// module chunks = 0","'use strict'\r\n\r\nmodule.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color-name/index.js\n// module id = 27\n// module chunks = 0","/* MIT license */\nvar colorNames = require('color-name');\nvar swizzle = require('simple-swizzle');\nvar hasOwnProperty = Object.hasOwnProperty;\n\nvar reverseNames = Object.create(null);\n\n// create a list of reverse color names\nfor (var name in colorNames) {\n\tif (hasOwnProperty.call(colorNames, name)) {\n\t\treverseNames[colorNames[name]] = name;\n\t}\n}\n\nvar cs = module.exports = {\n\tto: {},\n\tget: {}\n};\n\ncs.get = function (string) {\n\tvar prefix = string.substring(0, 3).toLowerCase();\n\tvar val;\n\tvar model;\n\tswitch (prefix) {\n\t\tcase 'hsl':\n\t\t\tval = cs.get.hsl(string);\n\t\t\tmodel = 'hsl';\n\t\t\tbreak;\n\t\tcase 'hwb':\n\t\t\tval = cs.get.hwb(string);\n\t\t\tmodel = 'hwb';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tval = cs.get.rgb(string);\n\t\t\tmodel = 'rgb';\n\t\t\tbreak;\n\t}\n\n\tif (!val) {\n\t\treturn null;\n\t}\n\n\treturn {model: model, value: val};\n};\n\ncs.get.rgb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar abbr = /^#([a-f0-9]{3,4})$/i;\n\tvar hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;\n\tvar rgba = /^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/;\n\tvar per = /^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/;\n\tvar keyword = /^(\\w+)$/;\n\n\tvar rgb = [0, 0, 0, 1];\n\tvar match;\n\tvar i;\n\tvar hexAlpha;\n\n\tif (match = string.match(hex)) {\n\t\thexAlpha = match[2];\n\t\tmatch = match[1];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\t// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19\n\t\t\tvar i2 = i * 2;\n\t\t\trgb[i] = parseInt(match.slice(i2, i2 + 2), 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = parseInt(hexAlpha, 16) / 255;\n\t\t}\n\t} else if (match = string.match(abbr)) {\n\t\tmatch = match[1];\n\t\thexAlpha = match[3];\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i] + match[i], 16);\n\t\t}\n\n\t\tif (hexAlpha) {\n\t\t\trgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;\n\t\t}\n\t} else if (match = string.match(rgba)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = parseInt(match[i + 1], 0);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\tif (match[5]) {\n\t\t\t\trgb[3] = parseFloat(match[4]) * 0.01;\n\t\t\t} else {\n\t\t\t\trgb[3] = parseFloat(match[4]);\n\t\t\t}\n\t\t}\n\t} else if (match = string.match(per)) {\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\trgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);\n\t\t}\n\n\t\tif (match[4]) {\n\t\t\tif (match[5]) {\n\t\t\t\trgb[3] = parseFloat(match[4]) * 0.01;\n\t\t\t} else {\n\t\t\t\trgb[3] = parseFloat(match[4]);\n\t\t\t}\n\t\t}\n\t} else if (match = string.match(keyword)) {\n\t\tif (match[1] === 'transparent') {\n\t\t\treturn [0, 0, 0, 0];\n\t\t}\n\n\t\tif (!hasOwnProperty.call(colorNames, match[1])) {\n\t\t\treturn null;\n\t\t}\n\n\t\trgb = colorNames[match[1]];\n\t\trgb[3] = 1;\n\n\t\treturn rgb;\n\t} else {\n\t\treturn null;\n\t}\n\n\tfor (i = 0; i < 3; i++) {\n\t\trgb[i] = clamp(rgb[i], 0, 255);\n\t}\n\trgb[3] = clamp(rgb[3], 0, 1);\n\n\treturn rgb;\n};\n\ncs.get.hsl = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hsl = /^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n\tvar match = string.match(hsl);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar s = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar l = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\n\t\treturn [h, s, l, a];\n\t}\n\n\treturn null;\n};\n\ncs.get.hwb = function (string) {\n\tif (!string) {\n\t\treturn null;\n\t}\n\n\tvar hwb = /^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n\tvar match = string.match(hwb);\n\n\tif (match) {\n\t\tvar alpha = parseFloat(match[4]);\n\t\tvar h = ((parseFloat(match[1]) % 360) + 360) % 360;\n\t\tvar w = clamp(parseFloat(match[2]), 0, 100);\n\t\tvar b = clamp(parseFloat(match[3]), 0, 100);\n\t\tvar a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);\n\t\treturn [h, w, b, a];\n\t}\n\n\treturn null;\n};\n\ncs.to.hex = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn (\n\t\t'#' +\n\t\thexDouble(rgba[0]) +\n\t\thexDouble(rgba[1]) +\n\t\thexDouble(rgba[2]) +\n\t\t(rgba[3] < 1\n\t\t\t? (hexDouble(Math.round(rgba[3] * 255)))\n\t\t\t: '')\n\t);\n};\n\ncs.to.rgb = function () {\n\tvar rgba = swizzle(arguments);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'\n\t\t: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';\n};\n\ncs.to.rgb.percent = function () {\n\tvar rgba = swizzle(arguments);\n\n\tvar r = Math.round(rgba[0] / 255 * 100);\n\tvar g = Math.round(rgba[1] / 255 * 100);\n\tvar b = Math.round(rgba[2] / 255 * 100);\n\n\treturn rgba.length < 4 || rgba[3] === 1\n\t\t? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'\n\t\t: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';\n};\n\ncs.to.hsl = function () {\n\tvar hsla = swizzle(arguments);\n\treturn hsla.length < 4 || hsla[3] === 1\n\t\t? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'\n\t\t: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';\n};\n\n// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax\n// (hwb have alpha optional & 1 is default value)\ncs.to.hwb = function () {\n\tvar hwba = swizzle(arguments);\n\n\tvar a = '';\n\tif (hwba.length >= 4 && hwba[3] !== 1) {\n\t\ta = ', ' + hwba[3];\n\t}\n\n\treturn 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';\n};\n\ncs.to.keyword = function (rgb) {\n\treturn reverseNames[rgb.slice(0, 3)];\n};\n\n// helpers\nfunction clamp(num, min, max) {\n\treturn Math.min(Math.max(min, num), max);\n}\n\nfunction hexDouble(num) {\n\tvar str = Math.round(num).toString(16).toUpperCase();\n\treturn (str.length < 2) ? '0' + str : str;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color-string/index.js\n// module id = 28\n// module chunks = 0","'use strict'\r\n\r\nmodule.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/color-string/~/color-name/index.js\n// module id = 29\n// module chunks = 0","/** \n * Box-Muller implementation\n * https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform\n */\n\n(function(exports){\n const PRECISION = 1e9;\n const _2PI = Math.PI * 2;\n\n /**\n *\n * @param {number} mean\n * @param {number} std\n * @param randFn - an optional function that returns a float between 0 (inclusive) and 1\n * (exclusive). Use this if you want to pass in a random number generator other than\n * Math.random().\n * @returns {number}\n */\n function generateGaussian(mean,std, randFn = null){\n var u1;\n var u2;\n if (randFn) {\n u1 = randFn();\n u2 = randFn();\n }\n else {\n u1 = Math.random();\n u2 = Math.random();\n }\n \n var z0 = Math.sqrt(-2.0 * Math.log(u1)) * Math.cos(_2PI * u2);\n var z1 = Math.sqrt(-2.0 * Math.log(u1)) * Math.sin(_2PI * u2);\n\n return z0 * std + mean;\n }\n\n exports(generateGaussian)\n})\n(typeof(exports) !== \"undefined\"\n ? function(e) { module.exports = e; }\n // istanbul ignore next\n : function(e) { this[\"boxmuller\"] = e; });\n \n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/gaussian/lib/box-muller.js\n// module id = 30\n// module chunks = 0","'use strict';\n\n/* eslint complexity: [2, 18], max-statements: [2, 33] */\nmodule.exports = function hasSymbols() {\n\tif (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }\n\tif (typeof Symbol.iterator === 'symbol') { return true; }\n\n\tvar obj = {};\n\tvar sym = Symbol('test');\n\tvar symObj = Object(sym);\n\tif (typeof sym === 'string') { return false; }\n\n\tif (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }\n\tif (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }\n\n\t// temp disabled per https://github.com/ljharb/object.assign/issues/17\n\t// if (sym instanceof Symbol) { return false; }\n\t// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4\n\t// if (!(symObj instanceof Symbol)) { return false; }\n\n\t// if (typeof Symbol.prototype.toString !== 'function') { return false; }\n\t// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }\n\n\tvar symVal = 42;\n\tobj[sym] = symVal;\n\tfor (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop\n\tif (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }\n\n\tif (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }\n\n\tvar syms = Object.getOwnPropertySymbols(obj);\n\tif (syms.length !== 1 || syms[0] !== sym) { return false; }\n\n\tif (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }\n\n\tif (typeof Object.getOwnPropertyDescriptor === 'function') {\n\t\tvar descriptor = Object.getOwnPropertyDescriptor(obj, sym);\n\t\tif (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }\n\t}\n\n\treturn true;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/has-symbols/shams.js\n// module id = 31\n// module chunks = 0","'use strict';\n\nvar hasSymbols = require('has-symbols/shams');\n\nmodule.exports = function hasToStringTagShams() {\n\treturn hasSymbols() && !!Symbol.toStringTag;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/has-tostringtag/shams.js\n// module id = 32\n// module chunks = 0","module.exports = function isArrayish(obj) {\n\tif (!obj || typeof obj === 'string') {\n\t\treturn false;\n\t}\n\n\treturn obj instanceof Array || Array.isArray(obj) ||\n\t\t(obj.length >= 0 && (obj.splice instanceof Function ||\n\t\t\t(Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-arrayish/index.js\n// module id = 33\n// module chunks = 0","/*!\n * Determine if an object is a Buffer\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n */\n\n// The _isBuffer check is for Safari 5-7 support, because it's missing\n// Object.prototype.constructor. Remove this eventually\nmodule.exports = function (obj) {\n return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n}\n\nfunction isBuffer (obj) {\n return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n}\n\n// For Node v0.10 support. Remove this eventually.\nfunction isSlowBuffer (obj) {\n return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/is-buffer/index.js\n// module id = 34\n// module chunks = 0","var isBuffer = require('is-buffer');\nvar toString = Object.prototype.toString;\n\n/**\n * Get the native `typeof` a value.\n *\n * @param {*} `val`\n * @return {*} Native javascript type\n */\n\nmodule.exports = function kindOf(val) {\n // primitivies\n if (typeof val === 'undefined') {\n return 'undefined';\n }\n if (val === null) {\n return 'null';\n }\n if (val === true || val === false || val instanceof Boolean) {\n return 'boolean';\n }\n if (typeof val === 'string' || val instanceof String) {\n return 'string';\n }\n if (typeof val === 'number' || val instanceof Number) {\n return 'number';\n }\n\n // functions\n if (typeof val === 'function' || val instanceof Function) {\n return 'function';\n }\n\n // array\n if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {\n return 'array';\n }\n\n // check for instances of RegExp and Date before calling `toString`\n if (val instanceof RegExp) {\n return 'regexp';\n }\n if (val instanceof Date) {\n return 'date';\n }\n\n // other objects\n var type = toString.call(val);\n\n if (type === '[object RegExp]') {\n return 'regexp';\n }\n if (type === '[object Date]') {\n return 'date';\n }\n if (type === '[object Arguments]') {\n return 'arguments';\n }\n if (type === '[object Error]') {\n return 'error';\n }\n\n // buffer\n if (isBuffer(val)) {\n return 'buffer';\n }\n\n // es6: Map, WeakMap, Set, WeakSet\n if (type === '[object Set]') {\n return 'set';\n }\n if (type === '[object WeakSet]') {\n return 'weakset';\n }\n if (type === '[object Map]') {\n return 'map';\n }\n if (type === '[object WeakMap]') {\n return 'weakmap';\n }\n if (type === '[object Symbol]') {\n return 'symbol';\n }\n\n // typed arrays\n if (type === '[object Int8Array]') {\n return 'int8array';\n }\n if (type === '[object Uint8Array]') {\n return 'uint8array';\n }\n if (type === '[object Uint8ClampedArray]') {\n return 'uint8clampedarray';\n }\n if (type === '[object Int16Array]') {\n return 'int16array';\n }\n if (type === '[object Uint16Array]') {\n return 'uint16array';\n }\n if (type === '[object Int32Array]') {\n return 'int32array';\n }\n if (type === '[object Uint32Array]') {\n return 'uint32array';\n }\n if (type === '[object Float32Array]') {\n return 'float32array';\n }\n if (type === '[object Float64Array]') {\n return 'float64array';\n }\n\n // must be a plain object\n return 'object';\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/kind-of/index.js\n// module id = 35\n// module chunks = 0","/**\n * @license\n * Lodash <https://lodash.com/>\n * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n;(function() {\n\n /** Used as a safe reference for `undefined` in pre-ES5 environments. */\n var undefined;\n\n /** Used as the semantic version number. */\n var VERSION = '4.17.21';\n\n /** Used as the size to enable large array optimizations. */\n var LARGE_ARRAY_SIZE = 200;\n\n /** Error message constants. */\n var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',\n FUNC_ERROR_TEXT = 'Expected a function',\n INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';\n\n /** Used to stand-in for `undefined` hash values. */\n var HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n /** Used as the maximum memoize cache size. */\n var MAX_MEMOIZE_SIZE = 500;\n\n /** Used as the internal argument placeholder. */\n var PLACEHOLDER = '__lodash_placeholder__';\n\n /** Used to compose bitmasks for cloning. */\n var CLONE_DEEP_FLAG = 1,\n CLONE_FLAT_FLAG = 2,\n CLONE_SYMBOLS_FLAG = 4;\n\n /** Used to compose bitmasks for value comparisons. */\n var COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n /** Used to compose bitmasks for function metadata. */\n var WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_BOUND_FLAG = 4,\n WRAP_CURRY_FLAG = 8,\n WRAP_CURRY_RIGHT_FLAG = 16,\n WRAP_PARTIAL_FLAG = 32,\n WRAP_PARTIAL_RIGHT_FLAG = 64,\n WRAP_ARY_FLAG = 128,\n WRAP_REARG_FLAG = 256,\n WRAP_FLIP_FLAG = 512;\n\n /** Used as default options for `_.truncate`. */\n var DEFAULT_TRUNC_LENGTH = 30,\n DEFAULT_TRUNC_OMISSION = '...';\n\n /** Used to detect hot functions by number of calls within a span of milliseconds. */\n var HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n /** Used to indicate the type of lazy iteratees. */\n var LAZY_FILTER_FLAG = 1,\n LAZY_MAP_FLAG = 2,\n LAZY_WHILE_FLAG = 3;\n\n /** Used as references for various `Number` constants. */\n var INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n /** Used as references for the maximum length and index of an array. */\n var MAX_ARRAY_LENGTH = 4294967295,\n MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,\n HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;\n\n /** Used to associate wrap methods with their bit flags. */\n var wrapFlags = [\n ['ary', WRAP_ARY_FLAG],\n ['bind', WRAP_BIND_FLAG],\n ['bindKey', WRAP_BIND_KEY_FLAG],\n ['curry', WRAP_CURRY_FLAG],\n ['curryRight', WRAP_CURRY_RIGHT_FLAG],\n ['flip', WRAP_FLIP_FLAG],\n ['partial', WRAP_PARTIAL_FLAG],\n ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],\n ['rearg', WRAP_REARG_FLAG]\n ];\n\n /** `Object#toString` result references. */\n var argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n asyncTag = '[object AsyncFunction]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n domExcTag = '[object DOMException]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n nullTag = '[object Null]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n proxyTag = '[object Proxy]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n undefinedTag = '[object Undefined]',\n weakMapTag = '[object WeakMap]',\n weakSetTag = '[object WeakSet]';\n\n var arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n /** Used to match empty string literals in compiled template source. */\n var reEmptyStringLeading = /\\b__p \\+= '';/g,\n reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n\n /** Used to match HTML entities and HTML characters. */\n var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,\n reUnescapedHtml = /[&<>\"']/g,\n reHasEscapedHtml = RegExp(reEscapedHtml.source),\n reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n /** Used to match template delimiters. */\n var reEscape = /<%-([\\s\\S]+?)%>/g,\n reEvaluate = /<%([\\s\\S]+?)%>/g,\n reInterpolate = /<%=([\\s\\S]+?)%>/g;\n\n /** Used to match property names within property paths. */\n var reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/,\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n /**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\n var reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g,\n reHasRegExpChar = RegExp(reRegExpChar.source);\n\n /** Used to match leading whitespace. */\n var reTrimStart = /^\\s+/;\n\n /** Used to match a single whitespace character. */\n var reWhitespace = /\\s/;\n\n /** Used to match wrap detail comments. */\n var reWrapComment = /\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/,\n reWrapDetails = /\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,\n reSplitDetails = /,? & /;\n\n /** Used to match words composed of alphanumeric characters. */\n var reAsciiWord = /[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+/g;\n\n /**\n * Used to validate the `validate` option in `_.template` variable.\n *\n * Forbids characters which could potentially change the meaning of the function argument definition:\n * - \"(),\" (modification of function parameters)\n * - \"=\" (default value)\n * - \"[]{}\" (destructuring of function parameters)\n * - \"/\" (beginning of a comment)\n * - whitespace\n */\n var reForbiddenIdentifierChars = /[()=,{}\\[\\]\\/\\s]/;\n\n /** Used to match backslashes in property paths. */\n var reEscapeChar = /\\\\(\\\\)?/g;\n\n /**\n * Used to match\n * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).\n */\n var reEsTemplate = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n\n /** Used to match `RegExp` flags from their coerced string values. */\n var reFlags = /\\w*$/;\n\n /** Used to detect bad signed hexadecimal string values. */\n var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n /** Used to detect binary string values. */\n var reIsBinary = /^0b[01]+$/i;\n\n /** Used to detect host constructors (Safari). */\n var reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n /** Used to detect octal string values. */\n var reIsOctal = /^0o[0-7]+$/i;\n\n /** Used to detect unsigned integer values. */\n var reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n /** Used to match Latin Unicode letters (excluding mathematical operators). */\n var reLatin = /[\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\xff\\u0100-\\u017f]/g;\n\n /** Used to ensure capturing order of template delimiters. */\n var reNoMatch = /($^)/;\n\n /** Used to match unescaped characters in compiled string literals. */\n var reUnescapedString = /['\\n\\r\\u2028\\u2029\\\\]/g;\n\n /** Used to compose unicode character classes. */\n var rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsDingbatRange = '\\\\u2700-\\\\u27bf',\n rsLowerRange = 'a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff',\n rsMathOpRange = '\\\\xac\\\\xb1\\\\xd7\\\\xf7',\n rsNonCharRange = '\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf',\n rsPunctuationRange = '\\\\u2000-\\\\u206f',\n rsSpaceRange = ' \\\\t\\\\x0b\\\\f\\\\xa0\\\\ufeff\\\\n\\\\r\\\\u2028\\\\u2029\\\\u1680\\\\u180e\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200a\\\\u202f\\\\u205f\\\\u3000',\n rsUpperRange = 'A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde',\n rsVarRange = '\\\\ufe0e\\\\ufe0f',\n rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;\n\n /** Used to compose unicode capture groups. */\n var rsApos = \"['\\u2019]\",\n rsAstral = '[' + rsAstralRange + ']',\n rsBreak = '[' + rsBreakRange + ']',\n rsCombo = '[' + rsComboRange + ']',\n rsDigits = '\\\\d+',\n rsDingbat = '[' + rsDingbatRange + ']',\n rsLower = '[' + rsLowerRange + ']',\n rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',\n rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n rsNonAstral = '[^' + rsAstralRange + ']',\n rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n rsUpper = '[' + rsUpperRange + ']',\n rsZWJ = '\\\\u200d';\n\n /** Used to compose unicode regexes. */\n var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',\n rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',\n rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',\n rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',\n reOptMod = rsModifier + '?',\n rsOptVar = '[' + rsVarRange + ']?',\n rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n rsOrdLower = '\\\\d*(?:1st|2nd|3rd|(?![123])\\\\dth)(?=\\\\b|[A-Z_])',\n rsOrdUpper = '\\\\d*(?:1ST|2ND|3RD|(?![123])\\\\dTH)(?=\\\\b|[a-z_])',\n rsSeq = rsOptVar + reOptMod + rsOptJoin,\n rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,\n rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n\n /** Used to match apostrophes. */\n var reApos = RegExp(rsApos, 'g');\n\n /**\n * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and\n * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).\n */\n var reComboMark = RegExp(rsCombo, 'g');\n\n /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */\n var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');\n\n /** Used to match complex or compound words. */\n var reUnicodeWord = RegExp([\n rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',\n rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',\n rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,\n rsUpper + '+' + rsOptContrUpper,\n rsOrdUpper,\n rsOrdLower,\n rsDigits,\n rsEmoji\n ].join('|'), 'g');\n\n /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */\n var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');\n\n /** Used to detect strings that need a more robust regexp to match words. */\n var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;\n\n /** Used to assign default `context` object properties. */\n var contextProps = [\n 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',\n 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',\n 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',\n 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',\n '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'\n ];\n\n /** Used to make template sourceURLs easier to identify. */\n var templateCounter = -1;\n\n /** Used to identify `toStringTag` values of typed arrays. */\n var typedArrayTags = {};\n typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\n typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\n typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\n typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\n typedArrayTags[uint32Tag] = true;\n typedArrayTags[argsTag] = typedArrayTags[arrayTag] =\n typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\n typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\n typedArrayTags[errorTag] = typedArrayTags[funcTag] =\n typedArrayTags[mapTag] = typedArrayTags[numberTag] =\n typedArrayTags[objectTag] = typedArrayTags[regexpTag] =\n typedArrayTags[setTag] = typedArrayTags[stringTag] =\n typedArrayTags[weakMapTag] = false;\n\n /** Used to identify `toStringTag` values supported by `_.clone`. */\n var cloneableTags = {};\n cloneableTags[argsTag] = cloneableTags[arrayTag] =\n cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =\n cloneableTags[boolTag] = cloneableTags[dateTag] =\n cloneableTags[float32Tag] = cloneableTags[float64Tag] =\n cloneableTags[int8Tag] = cloneableTags[int16Tag] =\n cloneableTags[int32Tag] = cloneableTags[mapTag] =\n cloneableTags[numberTag] = cloneableTags[objectTag] =\n cloneableTags[regexpTag] = cloneableTags[setTag] =\n cloneableTags[stringTag] = cloneableTags[symbolTag] =\n cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =\n cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;\n cloneableTags[errorTag] = cloneableTags[funcTag] =\n cloneableTags[weakMapTag] = false;\n\n /** Used to map Latin Unicode letters to basic Latin letters. */\n var deburredLetters = {\n // Latin-1 Supplement block.\n '\\xc0': 'A', '\\xc1': 'A', '\\xc2': 'A', '\\xc3': 'A', '\\xc4': 'A', '\\xc5': 'A',\n '\\xe0': 'a', '\\xe1': 'a', '\\xe2': 'a', '\\xe3': 'a', '\\xe4': 'a', '\\xe5': 'a',\n '\\xc7': 'C', '\\xe7': 'c',\n '\\xd0': 'D', '\\xf0': 'd',\n '\\xc8': 'E', '\\xc9': 'E', '\\xca': 'E', '\\xcb': 'E',\n '\\xe8': 'e', '\\xe9': 'e', '\\xea': 'e', '\\xeb': 'e',\n '\\xcc': 'I', '\\xcd': 'I', '\\xce': 'I', '\\xcf': 'I',\n '\\xec': 'i', '\\xed': 'i', '\\xee': 'i', '\\xef': 'i',\n '\\xd1': 'N', '\\xf1': 'n',\n '\\xd2': 'O', '\\xd3': 'O', '\\xd4': 'O', '\\xd5': 'O', '\\xd6': 'O', '\\xd8': 'O',\n '\\xf2': 'o', '\\xf3': 'o', '\\xf4': 'o', '\\xf5': 'o', '\\xf6': 'o', '\\xf8': 'o',\n '\\xd9': 'U', '\\xda': 'U', '\\xdb': 'U', '\\xdc': 'U',\n '\\xf9': 'u', '\\xfa': 'u', '\\xfb': 'u', '\\xfc': 'u',\n '\\xdd': 'Y', '\\xfd': 'y', '\\xff': 'y',\n '\\xc6': 'Ae', '\\xe6': 'ae',\n '\\xde': 'Th', '\\xfe': 'th',\n '\\xdf': 'ss',\n // Latin Extended-A block.\n '\\u0100': 'A', '\\u0102': 'A', '\\u0104': 'A',\n '\\u0101': 'a', '\\u0103': 'a', '\\u0105': 'a',\n '\\u0106': 'C', '\\u0108': 'C', '\\u010a': 'C', '\\u010c': 'C',\n '\\u0107': 'c', '\\u0109': 'c', '\\u010b': 'c', '\\u010d': 'c',\n '\\u010e': 'D', '\\u0110': 'D', '\\u010f': 'd', '\\u0111': 'd',\n '\\u0112': 'E', '\\u0114': 'E', '\\u0116': 'E', '\\u0118': 'E', '\\u011a': 'E',\n '\\u0113': 'e', '\\u0115': 'e', '\\u0117': 'e', '\\u0119': 'e', '\\u011b': 'e',\n '\\u011c': 'G', '\\u011e': 'G', '\\u0120': 'G', '\\u0122': 'G',\n '\\u011d': 'g', '\\u011f': 'g', '\\u0121': 'g', '\\u0123': 'g',\n '\\u0124': 'H', '\\u0126': 'H', '\\u0125': 'h', '\\u0127': 'h',\n '\\u0128': 'I', '\\u012a': 'I', '\\u012c': 'I', '\\u012e': 'I', '\\u0130': 'I',\n '\\u0129': 'i', '\\u012b': 'i', '\\u012d': 'i', '\\u012f': 'i', '\\u0131': 'i',\n '\\u0134': 'J', '\\u0135': 'j',\n '\\u0136': 'K', '\\u0137': 'k', '\\u0138': 'k',\n '\\u0139': 'L', '\\u013b': 'L', '\\u013d': 'L', '\\u013f': 'L', '\\u0141': 'L',\n '\\u013a': 'l', '\\u013c': 'l', '\\u013e': 'l', '\\u0140': 'l', '\\u0142': 'l',\n '\\u0143': 'N', '\\u0145': 'N', '\\u0147': 'N', '\\u014a': 'N',\n '\\u0144': 'n', '\\u0146': 'n', '\\u0148': 'n', '\\u014b': 'n',\n '\\u014c': 'O', '\\u014e': 'O', '\\u0150': 'O',\n '\\u014d': 'o', '\\u014f': 'o', '\\u0151': 'o',\n '\\u0154': 'R', '\\u0156': 'R', '\\u0158': 'R',\n '\\u0155': 'r', '\\u0157': 'r', '\\u0159': 'r',\n '\\u015a': 'S', '\\u015c': 'S', '\\u015e': 'S', '\\u0160': 'S',\n '\\u015b': 's', '\\u015d': 's', '\\u015f': 's', '\\u0161': 's',\n '\\u0162': 'T', '\\u0164': 'T', '\\u0166': 'T',\n '\\u0163': 't', '\\u0165': 't', '\\u0167': 't',\n '\\u0168': 'U', '\\u016a': 'U', '\\u016c': 'U', '\\u016e': 'U', '\\u0170': 'U', '\\u0172': 'U',\n '\\u0169': 'u', '\\u016b': 'u', '\\u016d': 'u', '\\u016f': 'u', '\\u0171': 'u', '\\u0173': 'u',\n '\\u0174': 'W', '\\u0175': 'w',\n '\\u0176': 'Y', '\\u0177': 'y', '\\u0178': 'Y',\n '\\u0179': 'Z', '\\u017b': 'Z', '\\u017d': 'Z',\n '\\u017a': 'z', '\\u017c': 'z', '\\u017e': 'z',\n '\\u0132': 'IJ', '\\u0133': 'ij',\n '\\u0152': 'Oe', '\\u0153': 'oe',\n '\\u0149': \"'n\", '\\u017f': 's'\n };\n\n /** Used to map characters to HTML entities. */\n var htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n\n /** Used to map HTML entities to characters. */\n var htmlUnescapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\"\n };\n\n /** Used to escape characters for inclusion in compiled string literals. */\n var stringEscapes = {\n '\\\\': '\\\\',\n \"'\": \"'\",\n '\\n': 'n',\n '\\r': 'r',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n };\n\n /** Built-in method references without a dependency on `root`. */\n var freeParseFloat = parseFloat,\n freeParseInt = parseInt;\n\n /** Detect free variable `global` from Node.js. */\n var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n /** Detect free variable `self`. */\n var freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n /** Used as a reference to the global object. */\n var root = freeGlobal || freeSelf || Function('return this')();\n\n /** Detect free variable `exports`. */\n var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n /** Detect free variable `module`. */\n var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n /** Detect the popular CommonJS extension `module.exports`. */\n var moduleExports = freeModule && freeModule.exports === freeExports;\n\n /** Detect free variable `process` from Node.js. */\n var freeProcess = moduleExports && freeGlobal.process;\n\n /** Used to access faster Node.js helpers. */\n var nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n }());\n\n /* Node.js helper references. */\n var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,\n nodeIsDate = nodeUtil && nodeUtil.isDate,\n nodeIsMap = nodeUtil && nodeUtil.isMap,\n nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,\n nodeIsSet = nodeUtil && nodeUtil.isSet,\n nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\n function apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n }\n\n /**\n * A specialized version of `baseAggregator` for arrays.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform keys.\n * @param {Object} accumulator The initial aggregated object.\n * @returns {Function} Returns `accumulator`.\n */\n function arrayAggregator(array, setter, iteratee, accumulator) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n var value = array[index];\n setter(accumulator, value, iteratee(value), array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.forEach` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\n function arrayEach(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (iteratee(array[index], index, array) === false) {\n break;\n }\n }\n return array;\n }\n\n /**\n * A specialized version of `_.forEachRight` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\n function arrayEachRight(array, iteratee) {\n var length = array == null ? 0 : array.length;\n\n while (length--) {\n if (iteratee(array[length], length, array) === false) {\n break;\n }\n }\n return array;\n }\n\n /**\n * A specialized version of `_.every` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`.\n */\n function arrayEvery(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (!predicate(array[index], index, array)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\n function arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.includes` for arrays without support for\n * specifying an index to search from.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\n function arrayIncludes(array, value) {\n var length = array == null ? 0 : array.length;\n return !!length && baseIndexOf(array, value, 0) > -1;\n }\n\n /**\n * This function is like `arrayIncludes` except that it accepts a comparator.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\n function arrayIncludesWith(array, value, comparator) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (comparator(value, array[index])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\n function arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n }\n\n /**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\n function arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n }\n\n /**\n * A specialized version of `_.reduce` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initAccum] Specify using the first element of `array` as\n * the initial value.\n * @returns {*} Returns the accumulated value.\n */\n function arrayReduce(array, iteratee, accumulator, initAccum) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n if (initAccum && length) {\n accumulator = array[++index];\n }\n while (++index < length) {\n accumulator = iteratee(accumulator, array[index], index, array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.reduceRight` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initAccum] Specify using the last element of `array` as\n * the initial value.\n * @returns {*} Returns the accumulated value.\n */\n function arrayReduceRight(array, iteratee, accumulator, initAccum) {\n var length = array == null ? 0 : array.length;\n if (initAccum && length) {\n accumulator = array[--length];\n }\n while (length--) {\n accumulator = iteratee(accumulator, array[length], length, array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\n function arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Gets the size of an ASCII `string`.\n *\n * @private\n * @param {string} string The string inspect.\n * @returns {number} Returns the string size.\n */\n var asciiSize = baseProperty('length');\n\n /**\n * Converts an ASCII `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\n function asciiToArray(string) {\n return string.split('');\n }\n\n /**\n * Splits an ASCII `string` into an array of its words.\n *\n * @private\n * @param {string} The string to inspect.\n * @returns {Array} Returns the words of `string`.\n */\n function asciiWords(string) {\n return string.match(reAsciiWord) || [];\n }\n\n /**\n * The base implementation of methods like `_.findKey` and `_.findLastKey`,\n * without support for iteratee shorthands, which iterates over `collection`\n * using `eachFunc`.\n *\n * @private\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @returns {*} Returns the found element or its key, else `undefined`.\n */\n function baseFindKey(collection, predicate, eachFunc) {\n var result;\n eachFunc(collection, function(value, key, collection) {\n if (predicate(value, key, collection)) {\n result = key;\n return false;\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseIndexOf(array, value, fromIndex) {\n return value === value\n ? strictIndexOf(array, value, fromIndex)\n : baseFindIndex(array, baseIsNaN, fromIndex);\n }\n\n /**\n * This function is like `baseIndexOf` except that it accepts a comparator.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseIndexOfWith(array, value, fromIndex, comparator) {\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (comparator(array[index], value)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * The base implementation of `_.isNaN` without support for number objects.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n */\n function baseIsNaN(value) {\n return value !== value;\n }\n\n /**\n * The base implementation of `_.mean` and `_.meanBy` without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the mean.\n */\n function baseMean(array, iteratee) {\n var length = array == null ? 0 : array.length;\n return length ? (baseSum(array, iteratee) / length) : NAN;\n }\n\n /**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\n function baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n }\n\n /**\n * The base implementation of `_.propertyOf` without support for deep paths.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n */\n function basePropertyOf(object) {\n return function(key) {\n return object == null ? undefined : object[key];\n };\n }\n\n /**\n * The base implementation of `_.reduce` and `_.reduceRight`, without support\n * for iteratee shorthands, which iterates over `collection` using `eachFunc`.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} accumulator The initial value.\n * @param {boolean} initAccum Specify using the first or last element of\n * `collection` as the initial value.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @returns {*} Returns the accumulated value.\n */\n function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {\n eachFunc(collection, function(value, index, collection) {\n accumulator = initAccum\n ? (initAccum = false, value)\n : iteratee(accumulator, value, index, collection);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `_.sortBy` which uses `comparer` to define the\n * sort order of `array` and replaces criteria objects with their corresponding\n * values.\n *\n * @private\n * @param {Array} array The array to sort.\n * @param {Function} comparer The function to define sort order.\n * @returns {Array} Returns `array`.\n */\n function baseSortBy(array, comparer) {\n var length = array.length;\n\n array.sort(comparer);\n while (length--) {\n array[length] = array[length].value;\n }\n return array;\n }\n\n /**\n * The base implementation of `_.sum` and `_.sumBy` without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the sum.\n */\n function baseSum(array, iteratee) {\n var result,\n index = -1,\n length = array.length;\n\n while (++index < length) {\n var current = iteratee(array[index]);\n if (current !== undefined) {\n result = result === undefined ? current : (result + current);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\n function baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n }\n\n /**\n * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array\n * of key-value pairs for `object` corresponding to the property names of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the key-value pairs.\n */\n function baseToPairs(object, props) {\n return arrayMap(props, function(key) {\n return [key, object[key]];\n });\n }\n\n /**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\n function baseTrim(string) {\n return string\n ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n : string;\n }\n\n /**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\n function baseUnary(func) {\n return function(value) {\n return func(value);\n };\n }\n\n /**\n * The base implementation of `_.values` and `_.valuesIn` which creates an\n * array of `object` property values corresponding to the property names\n * of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the array of property values.\n */\n function baseValues(object, props) {\n return arrayMap(props, function(key) {\n return object[key];\n });\n }\n\n /**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function cacheHas(cache, key) {\n return cache.has(key);\n }\n\n /**\n * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the first unmatched string symbol.\n */\n function charsStartIndex(strSymbols, chrSymbols) {\n var index = -1,\n length = strSymbols.length;\n\n while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n }\n\n /**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the last unmatched string symbol.\n */\n function charsEndIndex(strSymbols, chrSymbols) {\n var index = strSymbols.length;\n\n while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n }\n\n /**\n * Gets the number of `placeholder` occurrences in `array`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} placeholder The placeholder to search for.\n * @returns {number} Returns the placeholder count.\n */\n function countHolders(array, placeholder) {\n var length = array.length,\n result = 0;\n\n while (length--) {\n if (array[length] === placeholder) {\n ++result;\n }\n }\n return result;\n }\n\n /**\n * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A\n * letters to basic Latin letters.\n *\n * @private\n * @param {string} letter The matched letter to deburr.\n * @returns {string} Returns the deburred letter.\n */\n var deburrLetter = basePropertyOf(deburredLetters);\n\n /**\n * Used by `_.escape` to convert characters to HTML entities.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\n var escapeHtmlChar = basePropertyOf(htmlEscapes);\n\n /**\n * Used by `_.template` to escape characters for inclusion in compiled string literals.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\n function escapeStringChar(chr) {\n return '\\\\' + stringEscapes[chr];\n }\n\n /**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\n function getValue(object, key) {\n return object == null ? undefined : object[key];\n }\n\n /**\n * Checks if `string` contains Unicode symbols.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {boolean} Returns `true` if a symbol is found, else `false`.\n */\n function hasUnicode(string) {\n return reHasUnicode.test(string);\n }\n\n /**\n * Checks if `string` contains a word composed of Unicode symbols.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {boolean} Returns `true` if a word is found, else `false`.\n */\n function hasUnicodeWord(string) {\n return reHasUnicodeWord.test(string);\n }\n\n /**\n * Converts `iterator` to an array.\n *\n * @private\n * @param {Object} iterator The iterator to convert.\n * @returns {Array} Returns the converted array.\n */\n function iteratorToArray(iterator) {\n var data,\n result = [];\n\n while (!(data = iterator.next()).done) {\n result.push(data.value);\n }\n return result;\n }\n\n /**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\n function mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n }\n\n /**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\n function overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n }\n\n /**\n * Replaces all `placeholder` elements in `array` with an internal placeholder\n * and returns an array of their indexes.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {*} placeholder The placeholder to replace.\n * @returns {Array} Returns the new array of placeholder indexes.\n */\n function replaceHolders(array, placeholder) {\n var index = -1,\n length = array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value === placeholder || value === PLACEHOLDER) {\n array[index] = PLACEHOLDER;\n result[resIndex++] = index;\n }\n }\n return result;\n }\n\n /**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\n function setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n }\n\n /**\n * Converts `set` to its value-value pairs.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the value-value pairs.\n */\n function setToPairs(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = [value, value];\n });\n return result;\n }\n\n /**\n * A specialized version of `_.indexOf` which performs strict equality\n * comparisons of values, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function strictIndexOf(array, value, fromIndex) {\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * A specialized version of `_.lastIndexOf` which performs strict equality\n * comparisons of values, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function strictLastIndexOf(array, value, fromIndex) {\n var index = fromIndex + 1;\n while (index--) {\n if (array[index] === value) {\n return index;\n }\n }\n return index;\n }\n\n /**\n * Gets the number of symbols in `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the string size.\n */\n function stringSize(string) {\n return hasUnicode(string)\n ? unicodeSize(string)\n : asciiSize(string);\n }\n\n /**\n * Converts `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\n function stringToArray(string) {\n return hasUnicode(string)\n ? unicodeToArray(string)\n : asciiToArray(string);\n }\n\n /**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\n function trimmedEndIndex(string) {\n var index = string.length;\n\n while (index-- && reWhitespace.test(string.charAt(index))) {}\n return index;\n }\n\n /**\n * Used by `_.unescape` to convert HTML entities to characters.\n *\n * @private\n * @param {string} chr The matched character to unescape.\n * @returns {string} Returns the unescaped character.\n */\n var unescapeHtmlChar = basePropertyOf(htmlUnescapes);\n\n /**\n * Gets the size of a Unicode `string`.\n *\n * @private\n * @param {string} string The string inspect.\n * @returns {number} Returns the string size.\n */\n function unicodeSize(string) {\n var result = reUnicode.lastIndex = 0;\n while (reUnicode.test(string)) {\n ++result;\n }\n return result;\n }\n\n /**\n * Converts a Unicode `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\n function unicodeToArray(string) {\n return string.match(reUnicode) || [];\n }\n\n /**\n * Splits a Unicode `string` into an array of its words.\n *\n * @private\n * @param {string} The string to inspect.\n * @returns {Array} Returns the words of `string`.\n */\n function unicodeWords(string) {\n return string.match(reUnicodeWord) || [];\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Create a new pristine `lodash` function using the `context` object.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Util\n * @param {Object} [context=root] The context object.\n * @returns {Function} Returns a new `lodash` function.\n * @example\n *\n * _.mixin({ 'foo': _.constant('foo') });\n *\n * var lodash = _.runInContext();\n * lodash.mixin({ 'bar': lodash.constant('bar') });\n *\n * _.isFunction(_.foo);\n * // => true\n * _.isFunction(_.bar);\n * // => false\n *\n * lodash.isFunction(lodash.foo);\n * // => false\n * lodash.isFunction(lodash.bar);\n * // => true\n *\n * // Create a suped-up `defer` in Node.js.\n * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;\n */\n var runInContext = (function runInContext(context) {\n context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));\n\n /** Built-in constructor references. */\n var Array = context.Array,\n Date = context.Date,\n Error = context.Error,\n Function = context.Function,\n Math = context.Math,\n Object = context.Object,\n RegExp = context.RegExp,\n String = context.String,\n TypeError = context.TypeError;\n\n /** Used for built-in method references. */\n var arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n /** Used to detect overreaching core-js shims. */\n var coreJsData = context['__core-js_shared__'];\n\n /** Used to resolve the decompiled source of functions. */\n var funcToString = funcProto.toString;\n\n /** Used to check objects for own properties. */\n var hasOwnProperty = objectProto.hasOwnProperty;\n\n /** Used to generate unique IDs. */\n var idCounter = 0;\n\n /** Used to detect methods masquerading as native. */\n var maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n }());\n\n /**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\n var nativeObjectToString = objectProto.toString;\n\n /** Used to infer the `Object` constructor. */\n var objectCtorString = funcToString.call(Object);\n\n /** Used to restore the original `_` reference in `_.noConflict`. */\n var oldDash = root._;\n\n /** Used to detect if a method is native. */\n var reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n );\n\n /** Built-in value references. */\n var Buffer = moduleExports ? context.Buffer : undefined,\n Symbol = context.Symbol,\n Uint8Array = context.Uint8Array,\n allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,\n getPrototype = overArg(Object.getPrototypeOf, Object),\n objectCreate = Object.create,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice,\n spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,\n symIterator = Symbol ? Symbol.iterator : undefined,\n symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n var defineProperty = (function() {\n try {\n var func = getNative(Object, 'defineProperty');\n func({}, '', {});\n return func;\n } catch (e) {}\n }());\n\n /** Mocked built-ins. */\n var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,\n ctxNow = Date && Date.now !== root.Date.now && Date.now,\n ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;\n\n /* Built-in method references for those with the same name as other `lodash` methods. */\n var nativeCeil = Math.ceil,\n nativeFloor = Math.floor,\n nativeGetSymbols = Object.getOwnPropertySymbols,\n nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,\n nativeIsFinite = context.isFinite,\n nativeJoin = arrayProto.join,\n nativeKeys = overArg(Object.keys, Object),\n nativeMax = Math.max,\n nativeMin = Math.min,\n nativeNow = Date.now,\n nativeParseInt = context.parseInt,\n nativeRandom = Math.random,\n nativeReverse = arrayProto.reverse;\n\n /* Built-in method references that are verified to be native. */\n var DataView = getNative(context, 'DataView'),\n Map = getNative(context, 'Map'),\n Promise = getNative(context, 'Promise'),\n Set = getNative(context, 'Set'),\n WeakMap = getNative(context, 'WeakMap'),\n nativeCreate = getNative(Object, 'create');\n\n /** Used to store function metadata. */\n var metaMap = WeakMap && new WeakMap;\n\n /** Used to lookup unminified function names. */\n var realNames = {};\n\n /** Used to detect maps, sets, and weakmaps. */\n var dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n /** Used to convert symbols to primitives and strings. */\n var symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a `lodash` object which wraps `value` to enable implicit method\n * chain sequences. Methods that operate on and return arrays, collections,\n * and functions can be chained together. Methods that retrieve a single value\n * or may return a primitive value will automatically end the chain sequence\n * and return the unwrapped value. Otherwise, the value must be unwrapped\n * with `_#value`.\n *\n * Explicit chain sequences, which must be unwrapped with `_#value`, may be\n * enabled using `_.chain`.\n *\n * The execution of chained methods is lazy, that is, it's deferred until\n * `_#value` is implicitly or explicitly called.\n *\n * Lazy evaluation allows several methods to support shortcut fusion.\n * Shortcut fusion is an optimization to merge iteratee calls; this avoids\n * the creation of intermediate arrays and can greatly reduce the number of\n * iteratee executions. Sections of a chain sequence qualify for shortcut\n * fusion if the section is applied to an array and iteratees accept only\n * one argument. The heuristic for whether a section qualifies for shortcut\n * fusion is subject to change.\n *\n * Chaining is supported in custom builds as long as the `_#value` method is\n * directly or indirectly included in the build.\n *\n * In addition to lodash methods, wrappers have `Array` and `String` methods.\n *\n * The wrapper `Array` methods are:\n * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`\n *\n * The wrapper `String` methods are:\n * `replace` and `split`\n *\n * The wrapper methods that support shortcut fusion are:\n * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,\n * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,\n * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`\n *\n * The chainable wrapper methods are:\n * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,\n * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,\n * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,\n * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,\n * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,\n * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,\n * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,\n * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,\n * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,\n * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,\n * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,\n * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,\n * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,\n * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,\n * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,\n * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,\n * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,\n * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,\n * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,\n * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,\n * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,\n * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,\n * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,\n * `zipObject`, `zipObjectDeep`, and `zipWith`\n *\n * The wrapper methods that are **not** chainable by default are:\n * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,\n * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,\n * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,\n * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,\n * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,\n * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,\n * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,\n * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,\n * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,\n * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,\n * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,\n * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,\n * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,\n * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,\n * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,\n * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,\n * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,\n * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,\n * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,\n * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,\n * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,\n * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,\n * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,\n * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,\n * `upperFirst`, `value`, and `words`\n *\n * @name _\n * @constructor\n * @category Seq\n * @param {*} value The value to wrap in a `lodash` instance.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var wrapped = _([1, 2, 3]);\n *\n * // Returns an unwrapped value.\n * wrapped.reduce(_.add);\n * // => 6\n *\n * // Returns a wrapped value.\n * var squares = wrapped.map(square);\n *\n * _.isArray(squares);\n * // => false\n *\n * _.isArray(squares.value());\n * // => true\n */\n function lodash(value) {\n if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {\n if (value instanceof LodashWrapper) {\n return value;\n }\n if (hasOwnProperty.call(value, '__wrapped__')) {\n return wrapperClone(value);\n }\n }\n return new LodashWrapper(value);\n }\n\n /**\n * The base implementation of `_.create` without support for assigning\n * properties to the created object.\n *\n * @private\n * @param {Object} proto The object to inherit from.\n * @returns {Object} Returns the new object.\n */\n var baseCreate = (function() {\n function object() {}\n return function(proto) {\n if (!isObject(proto)) {\n return {};\n }\n if (objectCreate) {\n return objectCreate(proto);\n }\n object.prototype = proto;\n var result = new object;\n object.prototype = undefined;\n return result;\n };\n }());\n\n /**\n * The function whose prototype chain sequence wrappers inherit from.\n *\n * @private\n */\n function baseLodash() {\n // No operation performed.\n }\n\n /**\n * The base constructor for creating `lodash` wrapper objects.\n *\n * @private\n * @param {*} value The value to wrap.\n * @param {boolean} [chainAll] Enable explicit method chain sequences.\n */\n function LodashWrapper(value, chainAll) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__chain__ = !!chainAll;\n this.__index__ = 0;\n this.__values__ = undefined;\n }\n\n /**\n * By default, the template delimiters used by lodash are like those in\n * embedded Ruby (ERB) as well as ES2015 template strings. Change the\n * following template settings to use alternative delimiters.\n *\n * @static\n * @memberOf _\n * @type {Object}\n */\n lodash.templateSettings = {\n\n /**\n * Used to detect `data` property values to be HTML-escaped.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'escape': reEscape,\n\n /**\n * Used to detect code to be evaluated.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'evaluate': reEvaluate,\n\n /**\n * Used to detect `data` property values to inject.\n *\n * @memberOf _.templateSettings\n * @type {RegExp}\n */\n 'interpolate': reInterpolate,\n\n /**\n * Used to reference the data object in the template text.\n *\n * @memberOf _.templateSettings\n * @type {string}\n */\n 'variable': '',\n\n /**\n * Used to import variables into the compiled template.\n *\n * @memberOf _.templateSettings\n * @type {Object}\n */\n 'imports': {\n\n /**\n * A reference to the `lodash` function.\n *\n * @memberOf _.templateSettings.imports\n * @type {Function}\n */\n '_': lodash\n }\n };\n\n // Ensure wrappers are instances of `baseLodash`.\n lodash.prototype = baseLodash.prototype;\n lodash.prototype.constructor = lodash;\n\n LodashWrapper.prototype = baseCreate(baseLodash.prototype);\n LodashWrapper.prototype.constructor = LodashWrapper;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.\n *\n * @private\n * @constructor\n * @param {*} value The value to wrap.\n */\n function LazyWrapper(value) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__dir__ = 1;\n this.__filtered__ = false;\n this.__iteratees__ = [];\n this.__takeCount__ = MAX_ARRAY_LENGTH;\n this.__views__ = [];\n }\n\n /**\n * Creates a clone of the lazy wrapper object.\n *\n * @private\n * @name clone\n * @memberOf LazyWrapper\n * @returns {Object} Returns the cloned `LazyWrapper` object.\n */\n function lazyClone() {\n var result = new LazyWrapper(this.__wrapped__);\n result.__actions__ = copyArray(this.__actions__);\n result.__dir__ = this.__dir__;\n result.__filtered__ = this.__filtered__;\n result.__iteratees__ = copyArray(this.__iteratees__);\n result.__takeCount__ = this.__takeCount__;\n result.__views__ = copyArray(this.__views__);\n return result;\n }\n\n /**\n * Reverses the direction of lazy iteration.\n *\n * @private\n * @name reverse\n * @memberOf LazyWrapper\n * @returns {Object} Returns the new reversed `LazyWrapper` object.\n */\n function lazyReverse() {\n if (this.__filtered__) {\n var result = new LazyWrapper(this);\n result.__dir__ = -1;\n result.__filtered__ = true;\n } else {\n result = this.clone();\n result.__dir__ *= -1;\n }\n return result;\n }\n\n /**\n * Extracts the unwrapped value from its lazy wrapper.\n *\n * @private\n * @name value\n * @memberOf LazyWrapper\n * @returns {*} Returns the unwrapped value.\n */\n function lazyValue() {\n var array = this.__wrapped__.value(),\n dir = this.__dir__,\n isArr = isArray(array),\n isRight = dir < 0,\n arrLength = isArr ? array.length : 0,\n view = getView(0, arrLength, this.__views__),\n start = view.start,\n end = view.end,\n length = end - start,\n index = isRight ? end : (start - 1),\n iteratees = this.__iteratees__,\n iterLength = iteratees.length,\n resIndex = 0,\n takeCount = nativeMin(length, this.__takeCount__);\n\n if (!isArr || (!isRight && arrLength == length && takeCount == length)) {\n return baseWrapperValue(array, this.__actions__);\n }\n var result = [];\n\n outer:\n while (length-- && resIndex < takeCount) {\n index += dir;\n\n var iterIndex = -1,\n value = array[index];\n\n while (++iterIndex < iterLength) {\n var data = iteratees[iterIndex],\n iteratee = data.iteratee,\n type = data.type,\n computed = iteratee(value);\n\n if (type == LAZY_MAP_FLAG) {\n value = computed;\n } else if (!computed) {\n if (type == LAZY_FILTER_FLAG) {\n continue outer;\n } else {\n break outer;\n }\n }\n }\n result[resIndex++] = value;\n }\n return result;\n }\n\n // Ensure `LazyWrapper` is an instance of `baseLodash`.\n LazyWrapper.prototype = baseCreate(baseLodash.prototype);\n LazyWrapper.prototype.constructor = LazyWrapper;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n /**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\n function hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n }\n\n /**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n }\n\n /**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n }\n\n /**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n }\n\n /**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\n function hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n }\n\n // Add methods to `Hash`.\n Hash.prototype.clear = hashClear;\n Hash.prototype['delete'] = hashDelete;\n Hash.prototype.get = hashGet;\n Hash.prototype.has = hashHas;\n Hash.prototype.set = hashSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n /**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\n function listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n }\n\n /**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n }\n\n /**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n }\n\n /**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n }\n\n /**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\n function listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n }\n\n // Add methods to `ListCache`.\n ListCache.prototype.clear = listCacheClear;\n ListCache.prototype['delete'] = listCacheDelete;\n ListCache.prototype.get = listCacheGet;\n ListCache.prototype.has = listCacheHas;\n ListCache.prototype.set = listCacheSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n /**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\n function mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n }\n\n /**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n }\n\n /**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function mapCacheGet(key) {\n return getMapData(this, key).get(key);\n }\n\n /**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function mapCacheHas(key) {\n return getMapData(this, key).has(key);\n }\n\n /**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\n function mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n }\n\n // Add methods to `MapCache`.\n MapCache.prototype.clear = mapCacheClear;\n MapCache.prototype['delete'] = mapCacheDelete;\n MapCache.prototype.get = mapCacheGet;\n MapCache.prototype.has = mapCacheHas;\n MapCache.prototype.set = mapCacheSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\n function SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n }\n\n /**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\n function setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n }\n\n /**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\n function setCacheHas(value) {\n return this.__data__.has(value);\n }\n\n // Add methods to `SetCache`.\n SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\n SetCache.prototype.has = setCacheHas;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\n function Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n }\n\n /**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\n function stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n }\n\n /**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\n function stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n }\n\n /**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\n function stackGet(key) {\n return this.__data__.get(key);\n }\n\n /**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function stackHas(key) {\n return this.__data__.has(key);\n }\n\n /**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\n function stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n }\n\n // Add methods to `Stack`.\n Stack.prototype.clear = stackClear;\n Stack.prototype['delete'] = stackDelete;\n Stack.prototype.get = stackGet;\n Stack.prototype.has = stackHas;\n Stack.prototype.set = stackSet;\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\n function arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.sample` for arrays.\n *\n * @private\n * @param {Array} array The array to sample.\n * @returns {*} Returns the random element.\n */\n function arraySample(array) {\n var length = array.length;\n return length ? array[baseRandom(0, length - 1)] : undefined;\n }\n\n /**\n * A specialized version of `_.sampleSize` for arrays.\n *\n * @private\n * @param {Array} array The array to sample.\n * @param {number} n The number of elements to sample.\n * @returns {Array} Returns the random elements.\n */\n function arraySampleSize(array, n) {\n return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));\n }\n\n /**\n * A specialized version of `_.shuffle` for arrays.\n *\n * @private\n * @param {Array} array The array to shuffle.\n * @returns {Array} Returns the new shuffled array.\n */\n function arrayShuffle(array) {\n return shuffleSelf(copyArray(array));\n }\n\n /**\n * This function is like `assignValue` except that it doesn't assign\n * `undefined` values.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\n function assignMergeValue(object, key, value) {\n if ((value !== undefined && !eq(object[key], value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n }\n\n /**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\n function assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n }\n\n /**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n }\n\n /**\n * Aggregates elements of `collection` on `accumulator` with keys transformed\n * by `iteratee` and values set by `setter`.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform keys.\n * @param {Object} accumulator The initial aggregated object.\n * @returns {Function} Returns `accumulator`.\n */\n function baseAggregator(collection, setter, iteratee, accumulator) {\n baseEach(collection, function(value, key, collection) {\n setter(accumulator, value, iteratee(value), collection);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `_.assign` without support for multiple sources\n * or `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\n function baseAssign(object, source) {\n return object && copyObject(source, keys(source), object);\n }\n\n /**\n * The base implementation of `_.assignIn` without support for multiple sources\n * or `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\n function baseAssignIn(object, source) {\n return object && copyObject(source, keysIn(source), object);\n }\n\n /**\n * The base implementation of `assignValue` and `assignMergeValue` without\n * value checks.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\n function baseAssignValue(object, key, value) {\n if (key == '__proto__' && defineProperty) {\n defineProperty(object, key, {\n 'configurable': true,\n 'enumerable': true,\n 'value': value,\n 'writable': true\n });\n } else {\n object[key] = value;\n }\n }\n\n /**\n * The base implementation of `_.at` without support for individual paths.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {string[]} paths The property paths to pick.\n * @returns {Array} Returns the picked elements.\n */\n function baseAt(object, paths) {\n var index = -1,\n length = paths.length,\n result = Array(length),\n skip = object == null;\n\n while (++index < length) {\n result[index] = skip ? undefined : get(object, paths[index]);\n }\n return result;\n }\n\n /**\n * The base implementation of `_.clamp` which doesn't coerce arguments.\n *\n * @private\n * @param {number} number The number to clamp.\n * @param {number} [lower] The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the clamped number.\n */\n function baseClamp(number, lower, upper) {\n if (number === number) {\n if (upper !== undefined) {\n number = number <= upper ? number : upper;\n }\n if (lower !== undefined) {\n number = number >= lower ? number : lower;\n }\n }\n return number;\n }\n\n /**\n * The base implementation of `_.clone` and `_.cloneDeep` which tracks\n * traversed objects.\n *\n * @private\n * @param {*} value The value to clone.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Deep clone\n * 2 - Flatten inherited properties\n * 4 - Clone symbols\n * @param {Function} [customizer] The function to customize cloning.\n * @param {string} [key] The key of `value`.\n * @param {Object} [object] The parent object of `value`.\n * @param {Object} [stack] Tracks traversed objects and their clone counterparts.\n * @returns {*} Returns the cloned value.\n */\n function baseClone(value, bitmask, customizer, key, object, stack) {\n var result,\n isDeep = bitmask & CLONE_DEEP_FLAG,\n isFlat = bitmask & CLONE_FLAT_FLAG,\n isFull = bitmask & CLONE_SYMBOLS_FLAG;\n\n if (customizer) {\n result = object ? customizer(value, key, object, stack) : customizer(value);\n }\n if (result !== undefined) {\n return result;\n }\n if (!isObject(value)) {\n return value;\n }\n var isArr = isArray(value);\n if (isArr) {\n result = initCloneArray(value);\n if (!isDeep) {\n return copyArray(value, result);\n }\n } else {\n var tag = getTag(value),\n isFunc = tag == funcTag || tag == genTag;\n\n if (isBuffer(value)) {\n return cloneBuffer(value, isDeep);\n }\n if (tag == objectTag || tag == argsTag || (isFunc && !object)) {\n result = (isFlat || isFunc) ? {} : initCloneObject(value);\n if (!isDeep) {\n return isFlat\n ? copySymbolsIn(value, baseAssignIn(result, value))\n : copySymbols(value, baseAssign(result, value));\n }\n } else {\n if (!cloneableTags[tag]) {\n return object ? value : {};\n }\n result = initCloneByTag(value, tag, isDeep);\n }\n }\n // Check for circular references and return its corresponding clone.\n stack || (stack = new Stack);\n var stacked = stack.get(value);\n if (stacked) {\n return stacked;\n }\n stack.set(value, result);\n\n if (isSet(value)) {\n value.forEach(function(subValue) {\n result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));\n });\n } else if (isMap(value)) {\n value.forEach(function(subValue, key) {\n result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));\n });\n }\n\n var keysFunc = isFull\n ? (isFlat ? getAllKeysIn : getAllKeys)\n : (isFlat ? keysIn : keys);\n\n var props = isArr ? undefined : keysFunc(value);\n arrayEach(props || value, function(subValue, key) {\n if (props) {\n key = subValue;\n subValue = value[key];\n }\n // Recursively populate clone (susceptible to call stack limits).\n assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));\n });\n return result;\n }\n\n /**\n * The base implementation of `_.conforms` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property predicates to conform to.\n * @returns {Function} Returns the new spec function.\n */\n function baseConforms(source) {\n var props = keys(source);\n return function(object) {\n return baseConformsTo(object, source, props);\n };\n }\n\n /**\n * The base implementation of `_.conformsTo` which accepts `props` to check.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property predicates to conform to.\n * @returns {boolean} Returns `true` if `object` conforms, else `false`.\n */\n function baseConformsTo(object, source, props) {\n var length = props.length;\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (length--) {\n var key = props[length],\n predicate = source[key],\n value = object[key];\n\n if ((value === undefined && !(key in object)) || !predicate(value)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * The base implementation of `_.delay` and `_.defer` which accepts `args`\n * to provide to `func`.\n *\n * @private\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @param {Array} args The arguments to provide to `func`.\n * @returns {number|Object} Returns the timer id or timeout object.\n */\n function baseDelay(func, wait, args) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return setTimeout(function() { func.apply(undefined, args); }, wait);\n }\n\n /**\n * The base implementation of methods like `_.difference` without support\n * for excluding multiple arrays or iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Array} values The values to exclude.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n */\n function baseDifference(array, values, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n isCommon = true,\n length = array.length,\n result = [],\n valuesLength = values.length;\n\n if (!length) {\n return result;\n }\n if (iteratee) {\n values = arrayMap(values, baseUnary(iteratee));\n }\n if (comparator) {\n includes = arrayIncludesWith;\n isCommon = false;\n }\n else if (values.length >= LARGE_ARRAY_SIZE) {\n includes = cacheHas;\n isCommon = false;\n values = new SetCache(values);\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee == null ? value : iteratee(value);\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var valuesIndex = valuesLength;\n while (valuesIndex--) {\n if (values[valuesIndex] === computed) {\n continue outer;\n }\n }\n result.push(value);\n }\n else if (!includes(values, computed, comparator)) {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.forEach` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n */\n var baseEach = createBaseEach(baseForOwn);\n\n /**\n * The base implementation of `_.forEachRight` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n */\n var baseEachRight = createBaseEach(baseForOwnRight, true);\n\n /**\n * The base implementation of `_.every` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`\n */\n function baseEvery(collection, predicate) {\n var result = true;\n baseEach(collection, function(value, index, collection) {\n result = !!predicate(value, index, collection);\n return result;\n });\n return result;\n }\n\n /**\n * The base implementation of methods like `_.max` and `_.min` which accepts a\n * `comparator` to determine the extremum value.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The iteratee invoked per iteration.\n * @param {Function} comparator The comparator used to compare values.\n * @returns {*} Returns the extremum value.\n */\n function baseExtremum(array, iteratee, comparator) {\n var index = -1,\n length = array.length;\n\n while (++index < length) {\n var value = array[index],\n current = iteratee(value);\n\n if (current != null && (computed === undefined\n ? (current === current && !isSymbol(current))\n : comparator(current, computed)\n )) {\n var computed = current,\n result = value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.fill` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to fill.\n * @param {*} value The value to fill `array` with.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns `array`.\n */\n function baseFill(array, value, start, end) {\n var length = array.length;\n\n start = toInteger(start);\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = (end === undefined || end > length) ? length : toInteger(end);\n if (end < 0) {\n end += length;\n }\n end = start > end ? 0 : toLength(end);\n while (start < end) {\n array[start++] = value;\n }\n return array;\n }\n\n /**\n * The base implementation of `_.filter` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\n function baseFilter(collection, predicate) {\n var result = [];\n baseEach(collection, function(value, index, collection) {\n if (predicate(value, index, collection)) {\n result.push(value);\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.flatten` with support for restricting flattening.\n *\n * @private\n * @param {Array} array The array to flatten.\n * @param {number} depth The maximum recursion depth.\n * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.\n * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.\n * @param {Array} [result=[]] The initial result value.\n * @returns {Array} Returns the new flattened array.\n */\n function baseFlatten(array, depth, predicate, isStrict, result) {\n var index = -1,\n length = array.length;\n\n predicate || (predicate = isFlattenable);\n result || (result = []);\n\n while (++index < length) {\n var value = array[index];\n if (depth > 0 && predicate(value)) {\n if (depth > 1) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, depth - 1, predicate, isStrict, result);\n } else {\n arrayPush(result, value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `baseForOwn` which iterates over `object`\n * properties returned by `keysFunc` and invokes `iteratee` for each property.\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\n var baseFor = createBaseFor();\n\n /**\n * This function is like `baseFor` except that it iterates over properties\n * in the opposite order.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\n var baseForRight = createBaseFor(true);\n\n /**\n * The base implementation of `_.forOwn` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForOwn(object, iteratee) {\n return object && baseFor(object, iteratee, keys);\n }\n\n /**\n * The base implementation of `_.forOwnRight` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForOwnRight(object, iteratee) {\n return object && baseForRight(object, iteratee, keys);\n }\n\n /**\n * The base implementation of `_.functions` which creates an array of\n * `object` function property names filtered from `props`.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Array} props The property names to filter.\n * @returns {Array} Returns the function names.\n */\n function baseFunctions(object, props) {\n return arrayFilter(props, function(key) {\n return isFunction(object[key]);\n });\n }\n\n /**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\n function baseGet(object, path) {\n path = castPath(path, object);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n }\n\n /**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\n function baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n }\n\n /**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\n function baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n }\n\n /**\n * The base implementation of `_.gt` which doesn't coerce arguments.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than `other`,\n * else `false`.\n */\n function baseGt(value, other) {\n return value > other;\n }\n\n /**\n * The base implementation of `_.has` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\n function baseHas(object, key) {\n return object != null && hasOwnProperty.call(object, key);\n }\n\n /**\n * The base implementation of `_.hasIn` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\n function baseHasIn(object, key) {\n return object != null && key in Object(object);\n }\n\n /**\n * The base implementation of `_.inRange` which doesn't coerce arguments.\n *\n * @private\n * @param {number} number The number to check.\n * @param {number} start The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n */\n function baseInRange(number, start, end) {\n return number >= nativeMin(start, end) && number < nativeMax(start, end);\n }\n\n /**\n * The base implementation of methods like `_.intersection`, without support\n * for iteratee shorthands, that accepts an array of arrays to inspect.\n *\n * @private\n * @param {Array} arrays The arrays to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of shared values.\n */\n function baseIntersection(arrays, iteratee, comparator) {\n var includes = comparator ? arrayIncludesWith : arrayIncludes,\n length = arrays[0].length,\n othLength = arrays.length,\n othIndex = othLength,\n caches = Array(othLength),\n maxLength = Infinity,\n result = [];\n\n while (othIndex--) {\n var array = arrays[othIndex];\n if (othIndex && iteratee) {\n array = arrayMap(array, baseUnary(iteratee));\n }\n maxLength = nativeMin(array.length, maxLength);\n caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))\n ? new SetCache(othIndex && array)\n : undefined;\n }\n array = arrays[0];\n\n var index = -1,\n seen = caches[0];\n\n outer:\n while (++index < length && result.length < maxLength) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (!(seen\n ? cacheHas(seen, computed)\n : includes(result, computed, comparator)\n )) {\n othIndex = othLength;\n while (--othIndex) {\n var cache = caches[othIndex];\n if (!(cache\n ? cacheHas(cache, computed)\n : includes(arrays[othIndex], computed, comparator))\n ) {\n continue outer;\n }\n }\n if (seen) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.invert` and `_.invertBy` which inverts\n * `object` with values transformed by `iteratee` and set by `setter`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform values.\n * @param {Object} accumulator The initial inverted object.\n * @returns {Function} Returns `accumulator`.\n */\n function baseInverter(object, setter, iteratee, accumulator) {\n baseForOwn(object, function(value, key, object) {\n setter(accumulator, iteratee(value), key, object);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `_.invoke` without support for individual\n * method arguments.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the method to invoke.\n * @param {Array} args The arguments to invoke the method with.\n * @returns {*} Returns the result of the invoked method.\n */\n function baseInvoke(object, path, args) {\n path = castPath(path, object);\n object = parent(object, path);\n var func = object == null ? object : object[toKey(last(path))];\n return func == null ? undefined : apply(func, object, args);\n }\n\n /**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\n function baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n }\n\n /**\n * The base implementation of `_.isArrayBuffer` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.\n */\n function baseIsArrayBuffer(value) {\n return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;\n }\n\n /**\n * The base implementation of `_.isDate` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n */\n function baseIsDate(value) {\n return isObjectLike(value) && baseGetTag(value) == dateTag;\n }\n\n /**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\n function baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n }\n\n /**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n }\n\n /**\n * The base implementation of `_.isMap` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n */\n function baseIsMap(value) {\n return isObjectLike(value) && getTag(value) == mapTag;\n }\n\n /**\n * The base implementation of `_.isMatch` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Array} matchData The property names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\n function baseIsMatch(object, source, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var stack = new Stack;\n if (customizer) {\n var result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\n function baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n }\n\n /**\n * The base implementation of `_.isRegExp` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.\n */\n function baseIsRegExp(value) {\n return isObjectLike(value) && baseGetTag(value) == regexpTag;\n }\n\n /**\n * The base implementation of `_.isSet` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n */\n function baseIsSet(value) {\n return isObjectLike(value) && getTag(value) == setTag;\n }\n\n /**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\n function baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n }\n\n /**\n * The base implementation of `_.iteratee`.\n *\n * @private\n * @param {*} [value=_.identity] The value to convert to an iteratee.\n * @returns {Function} Returns the iteratee.\n */\n function baseIteratee(value) {\n // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return identity;\n }\n if (typeof value == 'object') {\n return isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n }\n\n /**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.lt` which doesn't coerce arguments.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than `other`,\n * else `false`.\n */\n function baseLt(value, other) {\n return value < other;\n }\n\n /**\n * The base implementation of `_.map` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\n function baseMap(collection, iteratee) {\n var index = -1,\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value, key, collection) {\n result[++index] = iteratee(value, key, collection);\n });\n return result;\n }\n\n /**\n * The base implementation of `_.matches` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n */\n function baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return function(object) {\n return object === source || baseIsMatch(object, source, matchData);\n };\n }\n\n /**\n * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\n function baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return function(object) {\n var objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);\n };\n }\n\n /**\n * The base implementation of `_.merge` without support for multiple sources.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\n function baseMerge(object, source, srcIndex, customizer, stack) {\n if (object === source) {\n return;\n }\n baseFor(source, function(srcValue, key) {\n stack || (stack = new Stack);\n if (isObject(srcValue)) {\n baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n }\n else {\n var newValue = customizer\n ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)\n : undefined;\n\n if (newValue === undefined) {\n newValue = srcValue;\n }\n assignMergeValue(object, key, newValue);\n }\n }, keysIn);\n }\n\n /**\n * A specialized version of `baseMerge` for arrays and objects which performs\n * deep merges and tracks traversed objects enabling objects with circular\n * references to be merged.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {string} key The key of the value to merge.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} mergeFunc The function to merge values.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\n function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {\n var objValue = safeGet(object, key),\n srcValue = safeGet(source, key),\n stacked = stack.get(srcValue);\n\n if (stacked) {\n assignMergeValue(object, key, stacked);\n return;\n }\n var newValue = customizer\n ? customizer(objValue, srcValue, (key + ''), object, source, stack)\n : undefined;\n\n var isCommon = newValue === undefined;\n\n if (isCommon) {\n var isArr = isArray(srcValue),\n isBuff = !isArr && isBuffer(srcValue),\n isTyped = !isArr && !isBuff && isTypedArray(srcValue);\n\n newValue = srcValue;\n if (isArr || isBuff || isTyped) {\n if (isArray(objValue)) {\n newValue = objValue;\n }\n else if (isArrayLikeObject(objValue)) {\n newValue = copyArray(objValue);\n }\n else if (isBuff) {\n isCommon = false;\n newValue = cloneBuffer(srcValue, true);\n }\n else if (isTyped) {\n isCommon = false;\n newValue = cloneTypedArray(srcValue, true);\n }\n else {\n newValue = [];\n }\n }\n else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n newValue = objValue;\n if (isArguments(objValue)) {\n newValue = toPlainObject(objValue);\n }\n else if (!isObject(objValue) || isFunction(objValue)) {\n newValue = initCloneObject(srcValue);\n }\n }\n else {\n isCommon = false;\n }\n }\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, newValue);\n mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n stack['delete'](srcValue);\n }\n assignMergeValue(object, key, newValue);\n }\n\n /**\n * The base implementation of `_.nth` which doesn't coerce arguments.\n *\n * @private\n * @param {Array} array The array to query.\n * @param {number} n The index of the element to return.\n * @returns {*} Returns the nth element of `array`.\n */\n function baseNth(array, n) {\n var length = array.length;\n if (!length) {\n return;\n }\n n += n < 0 ? length : 0;\n return isIndex(n, length) ? array[n] : undefined;\n }\n\n /**\n * The base implementation of `_.orderBy` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {string[]} orders The sort orders of `iteratees`.\n * @returns {Array} Returns the new sorted array.\n */\n function baseOrderBy(collection, iteratees, orders) {\n if (iteratees.length) {\n iteratees = arrayMap(iteratees, function(iteratee) {\n if (isArray(iteratee)) {\n return function(value) {\n return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);\n }\n }\n return iteratee;\n });\n } else {\n iteratees = [identity];\n }\n\n var index = -1;\n iteratees = arrayMap(iteratees, baseUnary(getIteratee()));\n\n var result = baseMap(collection, function(value, key, collection) {\n var criteria = arrayMap(iteratees, function(iteratee) {\n return iteratee(value);\n });\n return { 'criteria': criteria, 'index': ++index, 'value': value };\n });\n\n return baseSortBy(result, function(object, other) {\n return compareMultiple(object, other, orders);\n });\n }\n\n /**\n * The base implementation of `_.pick` without support for individual\n * property identifiers.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} paths The property paths to pick.\n * @returns {Object} Returns the new object.\n */\n function basePick(object, paths) {\n return basePickBy(object, paths, function(value, path) {\n return hasIn(object, path);\n });\n }\n\n /**\n * The base implementation of `_.pickBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} paths The property paths to pick.\n * @param {Function} predicate The function invoked per property.\n * @returns {Object} Returns the new object.\n */\n function basePickBy(object, paths, predicate) {\n var index = -1,\n length = paths.length,\n result = {};\n\n while (++index < length) {\n var path = paths[index],\n value = baseGet(object, path);\n\n if (predicate(value, path)) {\n baseSet(result, castPath(path, object), value);\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\n function basePropertyDeep(path) {\n return function(object) {\n return baseGet(object, path);\n };\n }\n\n /**\n * The base implementation of `_.pullAllBy` without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns `array`.\n */\n function basePullAll(array, values, iteratee, comparator) {\n var indexOf = comparator ? baseIndexOfWith : baseIndexOf,\n index = -1,\n length = values.length,\n seen = array;\n\n if (array === values) {\n values = copyArray(values);\n }\n if (iteratee) {\n seen = arrayMap(array, baseUnary(iteratee));\n }\n while (++index < length) {\n var fromIndex = 0,\n value = values[index],\n computed = iteratee ? iteratee(value) : value;\n\n while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {\n if (seen !== array) {\n splice.call(seen, fromIndex, 1);\n }\n splice.call(array, fromIndex, 1);\n }\n }\n return array;\n }\n\n /**\n * The base implementation of `_.pullAt` without support for individual\n * indexes or capturing the removed elements.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {number[]} indexes The indexes of elements to remove.\n * @returns {Array} Returns `array`.\n */\n function basePullAt(array, indexes) {\n var length = array ? indexes.length : 0,\n lastIndex = length - 1;\n\n while (length--) {\n var index = indexes[length];\n if (length == lastIndex || index !== previous) {\n var previous = index;\n if (isIndex(index)) {\n splice.call(array, index, 1);\n } else {\n baseUnset(array, index);\n }\n }\n }\n return array;\n }\n\n /**\n * The base implementation of `_.random` without support for returning\n * floating-point numbers.\n *\n * @private\n * @param {number} lower The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the random number.\n */\n function baseRandom(lower, upper) {\n return lower + nativeFloor(nativeRandom() * (upper - lower + 1));\n }\n\n /**\n * The base implementation of `_.range` and `_.rangeRight` which doesn't\n * coerce arguments.\n *\n * @private\n * @param {number} start The start of the range.\n * @param {number} end The end of the range.\n * @param {number} step The value to increment or decrement by.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Array} Returns the range of numbers.\n */\n function baseRange(start, end, step, fromRight) {\n var index = -1,\n length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),\n result = Array(length);\n\n while (length--) {\n result[fromRight ? length : ++index] = start;\n start += step;\n }\n return result;\n }\n\n /**\n * The base implementation of `_.repeat` which doesn't coerce arguments.\n *\n * @private\n * @param {string} string The string to repeat.\n * @param {number} n The number of times to repeat the string.\n * @returns {string} Returns the repeated string.\n */\n function baseRepeat(string, n) {\n var result = '';\n if (!string || n < 1 || n > MAX_SAFE_INTEGER) {\n return result;\n }\n // Leverage the exponentiation by squaring algorithm for a faster repeat.\n // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.\n do {\n if (n % 2) {\n result += string;\n }\n n = nativeFloor(n / 2);\n if (n) {\n string += string;\n }\n } while (n);\n\n return result;\n }\n\n /**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\n function baseRest(func, start) {\n return setToString(overRest(func, start, identity), func + '');\n }\n\n /**\n * The base implementation of `_.sample`.\n *\n * @private\n * @param {Array|Object} collection The collection to sample.\n * @returns {*} Returns the random element.\n */\n function baseSample(collection) {\n return arraySample(values(collection));\n }\n\n /**\n * The base implementation of `_.sampleSize` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to sample.\n * @param {number} n The number of elements to sample.\n * @returns {Array} Returns the random elements.\n */\n function baseSampleSize(collection, n) {\n var array = values(collection);\n return shuffleSelf(array, baseClamp(n, 0, array.length));\n }\n\n /**\n * The base implementation of `_.set`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @param {Function} [customizer] The function to customize path creation.\n * @returns {Object} Returns `object`.\n */\n function baseSet(object, path, value, customizer) {\n if (!isObject(object)) {\n return object;\n }\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n lastIndex = length - 1,\n nested = object;\n\n while (nested != null && ++index < length) {\n var key = toKey(path[index]),\n newValue = value;\n\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n return object;\n }\n\n if (index != lastIndex) {\n var objValue = nested[key];\n newValue = customizer ? customizer(objValue, key, nested) : undefined;\n if (newValue === undefined) {\n newValue = isObject(objValue)\n ? objValue\n : (isIndex(path[index + 1]) ? [] : {});\n }\n }\n assignValue(nested, key, newValue);\n nested = nested[key];\n }\n return object;\n }\n\n /**\n * The base implementation of `setData` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\n var baseSetData = !metaMap ? identity : function(func, data) {\n metaMap.set(func, data);\n return func;\n };\n\n /**\n * The base implementation of `setToString` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\n var baseSetToString = !defineProperty ? identity : function(func, string) {\n return defineProperty(func, 'toString', {\n 'configurable': true,\n 'enumerable': false,\n 'value': constant(string),\n 'writable': true\n });\n };\n\n /**\n * The base implementation of `_.shuffle`.\n *\n * @private\n * @param {Array|Object} collection The collection to shuffle.\n * @returns {Array} Returns the new shuffled array.\n */\n function baseShuffle(collection) {\n return shuffleSelf(values(collection));\n }\n\n /**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\n function baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n }\n\n /**\n * The base implementation of `_.some` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\n function baseSome(collection, predicate) {\n var result;\n\n baseEach(collection, function(value, index, collection) {\n result = predicate(value, index, collection);\n return !result;\n });\n return !!result;\n }\n\n /**\n * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which\n * performs a binary search of `array` to determine the index at which `value`\n * should be inserted into `array` in order to maintain its sort order.\n *\n * @private\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n */\n function baseSortedIndex(array, value, retHighest) {\n var low = 0,\n high = array == null ? low : array.length;\n\n if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {\n while (low < high) {\n var mid = (low + high) >>> 1,\n computed = array[mid];\n\n if (computed !== null && !isSymbol(computed) &&\n (retHighest ? (computed <= value) : (computed < value))) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return high;\n }\n return baseSortedIndexBy(array, value, identity, retHighest);\n }\n\n /**\n * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`\n * which invokes `iteratee` for `value` and each element of `array` to compute\n * their sort ranking. The iteratee is invoked with one argument; (value).\n *\n * @private\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} iteratee The iteratee invoked per element.\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n */\n function baseSortedIndexBy(array, value, iteratee, retHighest) {\n var low = 0,\n high = array == null ? 0 : array.length;\n if (high === 0) {\n return 0;\n }\n\n value = iteratee(value);\n var valIsNaN = value !== value,\n valIsNull = value === null,\n valIsSymbol = isSymbol(value),\n valIsUndefined = value === undefined;\n\n while (low < high) {\n var mid = nativeFloor((low + high) / 2),\n computed = iteratee(array[mid]),\n othIsDefined = computed !== undefined,\n othIsNull = computed === null,\n othIsReflexive = computed === computed,\n othIsSymbol = isSymbol(computed);\n\n if (valIsNaN) {\n var setLow = retHighest || othIsReflexive;\n } else if (valIsUndefined) {\n setLow = othIsReflexive && (retHighest || othIsDefined);\n } else if (valIsNull) {\n setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);\n } else if (valIsSymbol) {\n setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);\n } else if (othIsNull || othIsSymbol) {\n setLow = false;\n } else {\n setLow = retHighest ? (computed <= value) : (computed < value);\n }\n if (setLow) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return nativeMin(high, MAX_ARRAY_INDEX);\n }\n\n /**\n * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n */\n function baseSortedUniq(array, iteratee) {\n var index = -1,\n length = array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n if (!index || !eq(computed, seen)) {\n var seen = computed;\n result[resIndex++] = value === 0 ? 0 : value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.toNumber` which doesn't ensure correct\n * conversions of binary, hexadecimal, or octal string values.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n */\n function baseToNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n return +value;\n }\n\n /**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\n function baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n }\n\n /**\n * The base implementation of `_.uniqBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n */\n function baseUniq(array, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n length = array.length,\n isCommon = true,\n result = [],\n seen = result;\n\n if (comparator) {\n isCommon = false;\n includes = arrayIncludesWith;\n }\n else if (length >= LARGE_ARRAY_SIZE) {\n var set = iteratee ? null : createSet(array);\n if (set) {\n return setToArray(set);\n }\n isCommon = false;\n includes = cacheHas;\n seen = new SetCache;\n }\n else {\n seen = iteratee ? [] : result;\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var seenIndex = seen.length;\n while (seenIndex--) {\n if (seen[seenIndex] === computed) {\n continue outer;\n }\n }\n if (iteratee) {\n seen.push(computed);\n }\n result.push(value);\n }\n else if (!includes(seen, computed, comparator)) {\n if (seen !== result) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.unset`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The property path to unset.\n * @returns {boolean} Returns `true` if the property is deleted, else `false`.\n */\n function baseUnset(object, path) {\n path = castPath(path, object);\n object = parent(object, path);\n return object == null || delete object[toKey(last(path))];\n }\n\n /**\n * The base implementation of `_.update`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to update.\n * @param {Function} updater The function to produce the updated value.\n * @param {Function} [customizer] The function to customize path creation.\n * @returns {Object} Returns `object`.\n */\n function baseUpdate(object, path, updater, customizer) {\n return baseSet(object, path, updater(baseGet(object, path)), customizer);\n }\n\n /**\n * The base implementation of methods like `_.dropWhile` and `_.takeWhile`\n * without support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to query.\n * @param {Function} predicate The function invoked per iteration.\n * @param {boolean} [isDrop] Specify dropping elements instead of taking them.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Array} Returns the slice of `array`.\n */\n function baseWhile(array, predicate, isDrop, fromRight) {\n var length = array.length,\n index = fromRight ? length : -1;\n\n while ((fromRight ? index-- : ++index < length) &&\n predicate(array[index], index, array)) {}\n\n return isDrop\n ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))\n : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));\n }\n\n /**\n * The base implementation of `wrapperValue` which returns the result of\n * performing a sequence of actions on the unwrapped `value`, where each\n * successive action is supplied the return value of the previous.\n *\n * @private\n * @param {*} value The unwrapped value.\n * @param {Array} actions Actions to perform to resolve the unwrapped value.\n * @returns {*} Returns the resolved value.\n */\n function baseWrapperValue(value, actions) {\n var result = value;\n if (result instanceof LazyWrapper) {\n result = result.value();\n }\n return arrayReduce(actions, function(result, action) {\n return action.func.apply(action.thisArg, arrayPush([result], action.args));\n }, result);\n }\n\n /**\n * The base implementation of methods like `_.xor`, without support for\n * iteratee shorthands, that accepts an array of arrays to inspect.\n *\n * @private\n * @param {Array} arrays The arrays to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of values.\n */\n function baseXor(arrays, iteratee, comparator) {\n var length = arrays.length;\n if (length < 2) {\n return length ? baseUniq(arrays[0]) : [];\n }\n var index = -1,\n result = Array(length);\n\n while (++index < length) {\n var array = arrays[index],\n othIndex = -1;\n\n while (++othIndex < length) {\n if (othIndex != index) {\n result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);\n }\n }\n }\n return baseUniq(baseFlatten(result, 1), iteratee, comparator);\n }\n\n /**\n * This base implementation of `_.zipObject` which assigns values using `assignFunc`.\n *\n * @private\n * @param {Array} props The property identifiers.\n * @param {Array} values The property values.\n * @param {Function} assignFunc The function to assign values.\n * @returns {Object} Returns the new object.\n */\n function baseZipObject(props, values, assignFunc) {\n var index = -1,\n length = props.length,\n valsLength = values.length,\n result = {};\n\n while (++index < length) {\n var value = index < valsLength ? values[index] : undefined;\n assignFunc(result, props[index], value);\n }\n return result;\n }\n\n /**\n * Casts `value` to an empty array if it's not an array like object.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Array|Object} Returns the cast array-like object.\n */\n function castArrayLikeObject(value) {\n return isArrayLikeObject(value) ? value : [];\n }\n\n /**\n * Casts `value` to `identity` if it's not a function.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Function} Returns cast function.\n */\n function castFunction(value) {\n return typeof value == 'function' ? value : identity;\n }\n\n /**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\n function castPath(value, object) {\n if (isArray(value)) {\n return value;\n }\n return isKey(value, object) ? [value] : stringToPath(toString(value));\n }\n\n /**\n * A `baseRest` alias which can be replaced with `identity` by module\n * replacement plugins.\n *\n * @private\n * @type {Function}\n * @param {Function} func The function to apply a rest parameter to.\n * @returns {Function} Returns the new function.\n */\n var castRest = baseRest;\n\n /**\n * Casts `array` to a slice if it's needed.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {number} start The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the cast slice.\n */\n function castSlice(array, start, end) {\n var length = array.length;\n end = end === undefined ? length : end;\n return (!start && end >= length) ? array : baseSlice(array, start, end);\n }\n\n /**\n * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).\n *\n * @private\n * @param {number|Object} id The timer id or timeout object of the timer to clear.\n */\n var clearTimeout = ctxClearTimeout || function(id) {\n return root.clearTimeout(id);\n };\n\n /**\n * Creates a clone of `buffer`.\n *\n * @private\n * @param {Buffer} buffer The buffer to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Buffer} Returns the cloned buffer.\n */\n function cloneBuffer(buffer, isDeep) {\n if (isDeep) {\n return buffer.slice();\n }\n var length = buffer.length,\n result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);\n\n buffer.copy(result);\n return result;\n }\n\n /**\n * Creates a clone of `arrayBuffer`.\n *\n * @private\n * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\n * @returns {ArrayBuffer} Returns the cloned array buffer.\n */\n function cloneArrayBuffer(arrayBuffer) {\n var result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n return result;\n }\n\n /**\n * Creates a clone of `dataView`.\n *\n * @private\n * @param {Object} dataView The data view to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned data view.\n */\n function cloneDataView(dataView, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;\n return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);\n }\n\n /**\n * Creates a clone of `regexp`.\n *\n * @private\n * @param {Object} regexp The regexp to clone.\n * @returns {Object} Returns the cloned regexp.\n */\n function cloneRegExp(regexp) {\n var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));\n result.lastIndex = regexp.lastIndex;\n return result;\n }\n\n /**\n * Creates a clone of the `symbol` object.\n *\n * @private\n * @param {Object} symbol The symbol object to clone.\n * @returns {Object} Returns the cloned symbol object.\n */\n function cloneSymbol(symbol) {\n return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};\n }\n\n /**\n * Creates a clone of `typedArray`.\n *\n * @private\n * @param {Object} typedArray The typed array to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned typed array.\n */\n function cloneTypedArray(typedArray, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n }\n\n /**\n * Compares values to sort them in ascending order.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {number} Returns the sort order indicator for `value`.\n */\n function compareAscending(value, other) {\n if (value !== other) {\n var valIsDefined = value !== undefined,\n valIsNull = value === null,\n valIsReflexive = value === value,\n valIsSymbol = isSymbol(value);\n\n var othIsDefined = other !== undefined,\n othIsNull = other === null,\n othIsReflexive = other === other,\n othIsSymbol = isSymbol(other);\n\n if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||\n (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||\n (valIsNull && othIsDefined && othIsReflexive) ||\n (!valIsDefined && othIsReflexive) ||\n !valIsReflexive) {\n return 1;\n }\n if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||\n (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||\n (othIsNull && valIsDefined && valIsReflexive) ||\n (!othIsDefined && valIsReflexive) ||\n !othIsReflexive) {\n return -1;\n }\n }\n return 0;\n }\n\n /**\n * Used by `_.orderBy` to compare multiple properties of a value to another\n * and stable sort them.\n *\n * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,\n * specify an order of \"desc\" for descending or \"asc\" for ascending sort order\n * of corresponding values.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {boolean[]|string[]} orders The order to sort by for each property.\n * @returns {number} Returns the sort order indicator for `object`.\n */\n function compareMultiple(object, other, orders) {\n var index = -1,\n objCriteria = object.criteria,\n othCriteria = other.criteria,\n length = objCriteria.length,\n ordersLength = orders.length;\n\n while (++index < length) {\n var result = compareAscending(objCriteria[index], othCriteria[index]);\n if (result) {\n if (index >= ordersLength) {\n return result;\n }\n var order = orders[index];\n return result * (order == 'desc' ? -1 : 1);\n }\n }\n // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications\n // that causes it, under certain circumstances, to provide the same value for\n // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247\n // for more details.\n //\n // This also ensures a stable sort in V8 and other engines.\n // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.\n return object.index - other.index;\n }\n\n /**\n * Creates an array that is the composition of partially applied arguments,\n * placeholders, and provided arguments into a single array of arguments.\n *\n * @private\n * @param {Array} args The provided arguments.\n * @param {Array} partials The arguments to prepend to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @params {boolean} [isCurried] Specify composing for a curried function.\n * @returns {Array} Returns the new array of composed arguments.\n */\n function composeArgs(args, partials, holders, isCurried) {\n var argsIndex = -1,\n argsLength = args.length,\n holdersLength = holders.length,\n leftIndex = -1,\n leftLength = partials.length,\n rangeLength = nativeMax(argsLength - holdersLength, 0),\n result = Array(leftLength + rangeLength),\n isUncurried = !isCurried;\n\n while (++leftIndex < leftLength) {\n result[leftIndex] = partials[leftIndex];\n }\n while (++argsIndex < holdersLength) {\n if (isUncurried || argsIndex < argsLength) {\n result[holders[argsIndex]] = args[argsIndex];\n }\n }\n while (rangeLength--) {\n result[leftIndex++] = args[argsIndex++];\n }\n return result;\n }\n\n /**\n * This function is like `composeArgs` except that the arguments composition\n * is tailored for `_.partialRight`.\n *\n * @private\n * @param {Array} args The provided arguments.\n * @param {Array} partials The arguments to append to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @params {boolean} [isCurried] Specify composing for a curried function.\n * @returns {Array} Returns the new array of composed arguments.\n */\n function composeArgsRight(args, partials, holders, isCurried) {\n var argsIndex = -1,\n argsLength = args.length,\n holdersIndex = -1,\n holdersLength = holders.length,\n rightIndex = -1,\n rightLength = partials.length,\n rangeLength = nativeMax(argsLength - holdersLength, 0),\n result = Array(rangeLength + rightLength),\n isUncurried = !isCurried;\n\n while (++argsIndex < rangeLength) {\n result[argsIndex] = args[argsIndex];\n }\n var offset = argsIndex;\n while (++rightIndex < rightLength) {\n result[offset + rightIndex] = partials[rightIndex];\n }\n while (++holdersIndex < holdersLength) {\n if (isUncurried || argsIndex < argsLength) {\n result[offset + holders[holdersIndex]] = args[argsIndex++];\n }\n }\n return result;\n }\n\n /**\n * Copies the values of `source` to `array`.\n *\n * @private\n * @param {Array} source The array to copy values from.\n * @param {Array} [array=[]] The array to copy values to.\n * @returns {Array} Returns `array`.\n */\n function copyArray(source, array) {\n var index = -1,\n length = source.length;\n\n array || (array = Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n }\n\n /**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\n function copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n }\n\n /**\n * Copies own symbols of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy symbols from.\n * @param {Object} [object={}] The object to copy symbols to.\n * @returns {Object} Returns `object`.\n */\n function copySymbols(source, object) {\n return copyObject(source, getSymbols(source), object);\n }\n\n /**\n * Copies own and inherited symbols of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy symbols from.\n * @param {Object} [object={}] The object to copy symbols to.\n * @returns {Object} Returns `object`.\n */\n function copySymbolsIn(source, object) {\n return copyObject(source, getSymbolsIn(source), object);\n }\n\n /**\n * Creates a function like `_.groupBy`.\n *\n * @private\n * @param {Function} setter The function to set accumulator values.\n * @param {Function} [initializer] The accumulator object initializer.\n * @returns {Function} Returns the new aggregator function.\n */\n function createAggregator(setter, initializer) {\n return function(collection, iteratee) {\n var func = isArray(collection) ? arrayAggregator : baseAggregator,\n accumulator = initializer ? initializer() : {};\n\n return func(collection, setter, getIteratee(iteratee, 2), accumulator);\n };\n }\n\n /**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\n function createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n }\n\n /**\n * Creates a `baseEach` or `baseEachRight` function.\n *\n * @private\n * @param {Function} eachFunc The function to iterate over a collection.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\n function createBaseEach(eachFunc, fromRight) {\n return function(collection, iteratee) {\n if (collection == null) {\n return collection;\n }\n if (!isArrayLike(collection)) {\n return eachFunc(collection, iteratee);\n }\n var length = collection.length,\n index = fromRight ? length : -1,\n iterable = Object(collection);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (iteratee(iterable[index], index, iterable) === false) {\n break;\n }\n }\n return collection;\n };\n }\n\n /**\n * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\n function createBaseFor(fromRight) {\n return function(object, iteratee, keysFunc) {\n var index = -1,\n iterable = Object(object),\n props = keysFunc(object),\n length = props.length;\n\n while (length--) {\n var key = props[fromRight ? length : ++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n }\n\n /**\n * Creates a function that wraps `func` to invoke it with the optional `this`\n * binding of `thisArg`.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createBind(func, bitmask, thisArg) {\n var isBind = bitmask & WRAP_BIND_FLAG,\n Ctor = createCtor(func);\n\n function wrapper() {\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return fn.apply(isBind ? thisArg : this, arguments);\n }\n return wrapper;\n }\n\n /**\n * Creates a function like `_.lowerFirst`.\n *\n * @private\n * @param {string} methodName The name of the `String` case method to use.\n * @returns {Function} Returns the new case function.\n */\n function createCaseFirst(methodName) {\n return function(string) {\n string = toString(string);\n\n var strSymbols = hasUnicode(string)\n ? stringToArray(string)\n : undefined;\n\n var chr = strSymbols\n ? strSymbols[0]\n : string.charAt(0);\n\n var trailing = strSymbols\n ? castSlice(strSymbols, 1).join('')\n : string.slice(1);\n\n return chr[methodName]() + trailing;\n };\n }\n\n /**\n * Creates a function like `_.camelCase`.\n *\n * @private\n * @param {Function} callback The function to combine each word.\n * @returns {Function} Returns the new compounder function.\n */\n function createCompounder(callback) {\n return function(string) {\n return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');\n };\n }\n\n /**\n * Creates a function that produces an instance of `Ctor` regardless of\n * whether it was invoked as part of a `new` expression or by `call` or `apply`.\n *\n * @private\n * @param {Function} Ctor The constructor to wrap.\n * @returns {Function} Returns the new wrapped function.\n */\n function createCtor(Ctor) {\n return function() {\n // Use a `switch` statement to work with class constructors. See\n // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist\n // for more details.\n var args = arguments;\n switch (args.length) {\n case 0: return new Ctor;\n case 1: return new Ctor(args[0]);\n case 2: return new Ctor(args[0], args[1]);\n case 3: return new Ctor(args[0], args[1], args[2]);\n case 4: return new Ctor(args[0], args[1], args[2], args[3]);\n case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);\n case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);\n case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);\n }\n var thisBinding = baseCreate(Ctor.prototype),\n result = Ctor.apply(thisBinding, args);\n\n // Mimic the constructor's `return` behavior.\n // See https://es5.github.io/#x13.2.2 for more details.\n return isObject(result) ? result : thisBinding;\n };\n }\n\n /**\n * Creates a function that wraps `func` to enable currying.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {number} arity The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createCurry(func, bitmask, arity) {\n var Ctor = createCtor(func);\n\n function wrapper() {\n var length = arguments.length,\n args = Array(length),\n index = length,\n placeholder = getHolder(wrapper);\n\n while (index--) {\n args[index] = arguments[index];\n }\n var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)\n ? []\n : replaceHolders(args, placeholder);\n\n length -= holders.length;\n if (length < arity) {\n return createRecurry(\n func, bitmask, createHybrid, wrapper.placeholder, undefined,\n args, holders, undefined, undefined, arity - length);\n }\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return apply(fn, this, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a `_.find` or `_.findLast` function.\n *\n * @private\n * @param {Function} findIndexFunc The function to find the collection index.\n * @returns {Function} Returns the new find function.\n */\n function createFind(findIndexFunc) {\n return function(collection, predicate, fromIndex) {\n var iterable = Object(collection);\n if (!isArrayLike(collection)) {\n var iteratee = getIteratee(predicate, 3);\n collection = keys(collection);\n predicate = function(key) { return iteratee(iterable[key], key, iterable); };\n }\n var index = findIndexFunc(collection, predicate, fromIndex);\n return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;\n };\n }\n\n /**\n * Creates a `_.flow` or `_.flowRight` function.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new flow function.\n */\n function createFlow(fromRight) {\n return flatRest(function(funcs) {\n var length = funcs.length,\n index = length,\n prereq = LodashWrapper.prototype.thru;\n\n if (fromRight) {\n funcs.reverse();\n }\n while (index--) {\n var func = funcs[index];\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (prereq && !wrapper && getFuncName(func) == 'wrapper') {\n var wrapper = new LodashWrapper([], true);\n }\n }\n index = wrapper ? index : length;\n while (++index < length) {\n func = funcs[index];\n\n var funcName = getFuncName(func),\n data = funcName == 'wrapper' ? getData(func) : undefined;\n\n if (data && isLaziable(data[0]) &&\n data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&\n !data[4].length && data[9] == 1\n ) {\n wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);\n } else {\n wrapper = (func.length == 1 && isLaziable(func))\n ? wrapper[funcName]()\n : wrapper.thru(func);\n }\n }\n return function() {\n var args = arguments,\n value = args[0];\n\n if (wrapper && args.length == 1 && isArray(value)) {\n return wrapper.plant(value).value();\n }\n var index = 0,\n result = length ? funcs[index].apply(this, args) : value;\n\n while (++index < length) {\n result = funcs[index].call(this, result);\n }\n return result;\n };\n });\n }\n\n /**\n * Creates a function that wraps `func` to invoke it with optional `this`\n * binding of `thisArg`, partial application, and currying.\n *\n * @private\n * @param {Function|string} func The function or method name to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to\n * the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [partialsRight] The arguments to append to those provided\n * to the new function.\n * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {\n var isAry = bitmask & WRAP_ARY_FLAG,\n isBind = bitmask & WRAP_BIND_FLAG,\n isBindKey = bitmask & WRAP_BIND_KEY_FLAG,\n isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),\n isFlip = bitmask & WRAP_FLIP_FLAG,\n Ctor = isBindKey ? undefined : createCtor(func);\n\n function wrapper() {\n var length = arguments.length,\n args = Array(length),\n index = length;\n\n while (index--) {\n args[index] = arguments[index];\n }\n if (isCurried) {\n var placeholder = getHolder(wrapper),\n holdersCount = countHolders(args, placeholder);\n }\n if (partials) {\n args = composeArgs(args, partials, holders, isCurried);\n }\n if (partialsRight) {\n args = composeArgsRight(args, partialsRight, holdersRight, isCurried);\n }\n length -= holdersCount;\n if (isCurried && length < arity) {\n var newHolders = replaceHolders(args, placeholder);\n return createRecurry(\n func, bitmask, createHybrid, wrapper.placeholder, thisArg,\n args, newHolders, argPos, ary, arity - length\n );\n }\n var thisBinding = isBind ? thisArg : this,\n fn = isBindKey ? thisBinding[func] : func;\n\n length = args.length;\n if (argPos) {\n args = reorder(args, argPos);\n } else if (isFlip && length > 1) {\n args.reverse();\n }\n if (isAry && ary < length) {\n args.length = ary;\n }\n if (this && this !== root && this instanceof wrapper) {\n fn = Ctor || createCtor(fn);\n }\n return fn.apply(thisBinding, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a function like `_.invertBy`.\n *\n * @private\n * @param {Function} setter The function to set accumulator values.\n * @param {Function} toIteratee The function to resolve iteratees.\n * @returns {Function} Returns the new inverter function.\n */\n function createInverter(setter, toIteratee) {\n return function(object, iteratee) {\n return baseInverter(object, setter, toIteratee(iteratee), {});\n };\n }\n\n /**\n * Creates a function that performs a mathematical operation on two values.\n *\n * @private\n * @param {Function} operator The function to perform the operation.\n * @param {number} [defaultValue] The value used for `undefined` arguments.\n * @returns {Function} Returns the new mathematical operation function.\n */\n function createMathOperation(operator, defaultValue) {\n return function(value, other) {\n var result;\n if (value === undefined && other === undefined) {\n return defaultValue;\n }\n if (value !== undefined) {\n result = value;\n }\n if (other !== undefined) {\n if (result === undefined) {\n return other;\n }\n if (typeof value == 'string' || typeof other == 'string') {\n value = baseToString(value);\n other = baseToString(other);\n } else {\n value = baseToNumber(value);\n other = baseToNumber(other);\n }\n result = operator(value, other);\n }\n return result;\n };\n }\n\n /**\n * Creates a function like `_.over`.\n *\n * @private\n * @param {Function} arrayFunc The function to iterate over iteratees.\n * @returns {Function} Returns the new over function.\n */\n function createOver(arrayFunc) {\n return flatRest(function(iteratees) {\n iteratees = arrayMap(iteratees, baseUnary(getIteratee()));\n return baseRest(function(args) {\n var thisArg = this;\n return arrayFunc(iteratees, function(iteratee) {\n return apply(iteratee, thisArg, args);\n });\n });\n });\n }\n\n /**\n * Creates the padding for `string` based on `length`. The `chars` string\n * is truncated if the number of characters exceeds `length`.\n *\n * @private\n * @param {number} length The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padding for `string`.\n */\n function createPadding(length, chars) {\n chars = chars === undefined ? ' ' : baseToString(chars);\n\n var charsLength = chars.length;\n if (charsLength < 2) {\n return charsLength ? baseRepeat(chars, length) : chars;\n }\n var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));\n return hasUnicode(chars)\n ? castSlice(stringToArray(result), 0, length).join('')\n : result.slice(0, length);\n }\n\n /**\n * Creates a function that wraps `func` to invoke it with the `this` binding\n * of `thisArg` and `partials` prepended to the arguments it receives.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} partials The arguments to prepend to those provided to\n * the new function.\n * @returns {Function} Returns the new wrapped function.\n */\n function createPartial(func, bitmask, thisArg, partials) {\n var isBind = bitmask & WRAP_BIND_FLAG,\n Ctor = createCtor(func);\n\n function wrapper() {\n var argsIndex = -1,\n argsLength = arguments.length,\n leftIndex = -1,\n leftLength = partials.length,\n args = Array(leftLength + argsLength),\n fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n\n while (++leftIndex < leftLength) {\n args[leftIndex] = partials[leftIndex];\n }\n while (argsLength--) {\n args[leftIndex++] = arguments[++argsIndex];\n }\n return apply(fn, isBind ? thisArg : this, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a `_.range` or `_.rangeRight` function.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new range function.\n */\n function createRange(fromRight) {\n return function(start, end, step) {\n if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {\n end = step = undefined;\n }\n // Ensure the sign of `-0` is preserved.\n start = toFinite(start);\n if (end === undefined) {\n end = start;\n start = 0;\n } else {\n end = toFinite(end);\n }\n step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);\n return baseRange(start, end, step, fromRight);\n };\n }\n\n /**\n * Creates a function that performs a relational operation on two values.\n *\n * @private\n * @param {Function} operator The function to perform the operation.\n * @returns {Function} Returns the new relational operation function.\n */\n function createRelationalOperation(operator) {\n return function(value, other) {\n if (!(typeof value == 'string' && typeof other == 'string')) {\n value = toNumber(value);\n other = toNumber(other);\n }\n return operator(value, other);\n };\n }\n\n /**\n * Creates a function that wraps `func` to continue currying.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {Function} wrapFunc The function to create the `func` wrapper.\n * @param {*} placeholder The placeholder value.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to\n * the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {\n var isCurry = bitmask & WRAP_CURRY_FLAG,\n newHolders = isCurry ? holders : undefined,\n newHoldersRight = isCurry ? undefined : holders,\n newPartials = isCurry ? partials : undefined,\n newPartialsRight = isCurry ? undefined : partials;\n\n bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);\n bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);\n\n if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {\n bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);\n }\n var newData = [\n func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,\n newHoldersRight, argPos, ary, arity\n ];\n\n var result = wrapFunc.apply(undefined, newData);\n if (isLaziable(func)) {\n setData(result, newData);\n }\n result.placeholder = placeholder;\n return setWrapToString(result, func, bitmask);\n }\n\n /**\n * Creates a function like `_.round`.\n *\n * @private\n * @param {string} methodName The name of the `Math` method to use when rounding.\n * @returns {Function} Returns the new round function.\n */\n function createRound(methodName) {\n var func = Math[methodName];\n return function(number, precision) {\n number = toNumber(number);\n precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);\n if (precision && nativeIsFinite(number)) {\n // Shift with exponential notation to avoid floating-point issues.\n // See [MDN](https://mdn.io/round#Examples) for more details.\n var pair = (toString(number) + 'e').split('e'),\n value = func(pair[0] + 'e' + (+pair[1] + precision));\n\n pair = (toString(value) + 'e').split('e');\n return +(pair[0] + 'e' + (+pair[1] - precision));\n }\n return func(number);\n };\n }\n\n /**\n * Creates a set object of `values`.\n *\n * @private\n * @param {Array} values The values to add to the set.\n * @returns {Object} Returns the new set.\n */\n var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {\n return new Set(values);\n };\n\n /**\n * Creates a `_.toPairs` or `_.toPairsIn` function.\n *\n * @private\n * @param {Function} keysFunc The function to get the keys of a given object.\n * @returns {Function} Returns the new pairs function.\n */\n function createToPairs(keysFunc) {\n return function(object) {\n var tag = getTag(object);\n if (tag == mapTag) {\n return mapToArray(object);\n }\n if (tag == setTag) {\n return setToPairs(object);\n }\n return baseToPairs(object, keysFunc(object));\n };\n }\n\n /**\n * Creates a function that either curries or invokes `func` with optional\n * `this` binding and partially applied arguments.\n *\n * @private\n * @param {Function|string} func The function or method name to wrap.\n * @param {number} bitmask The bitmask flags.\n * 1 - `_.bind`\n * 2 - `_.bindKey`\n * 4 - `_.curry` or `_.curryRight` of a bound function\n * 8 - `_.curry`\n * 16 - `_.curryRight`\n * 32 - `_.partial`\n * 64 - `_.partialRight`\n * 128 - `_.rearg`\n * 256 - `_.ary`\n * 512 - `_.flip`\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to be partially applied.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {\n var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;\n if (!isBindKey && typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var length = partials ? partials.length : 0;\n if (!length) {\n bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);\n partials = holders = undefined;\n }\n ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);\n arity = arity === undefined ? arity : toInteger(arity);\n length -= holders ? holders.length : 0;\n\n if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {\n var partialsRight = partials,\n holdersRight = holders;\n\n partials = holders = undefined;\n }\n var data = isBindKey ? undefined : getData(func);\n\n var newData = [\n func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,\n argPos, ary, arity\n ];\n\n if (data) {\n mergeData(newData, data);\n }\n func = newData[0];\n bitmask = newData[1];\n thisArg = newData[2];\n partials = newData[3];\n holders = newData[4];\n arity = newData[9] = newData[9] === undefined\n ? (isBindKey ? 0 : func.length)\n : nativeMax(newData[9] - length, 0);\n\n if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {\n bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);\n }\n if (!bitmask || bitmask == WRAP_BIND_FLAG) {\n var result = createBind(func, bitmask, thisArg);\n } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {\n result = createCurry(func, bitmask, arity);\n } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {\n result = createPartial(func, bitmask, thisArg, partials);\n } else {\n result = createHybrid.apply(undefined, newData);\n }\n var setter = data ? baseSetData : setData;\n return setWrapToString(setter(result, newData), func, bitmask);\n }\n\n /**\n * Used by `_.defaults` to customize its `_.assignIn` use to assign properties\n * of source objects to the destination object for all destination properties\n * that resolve to `undefined`.\n *\n * @private\n * @param {*} objValue The destination value.\n * @param {*} srcValue The source value.\n * @param {string} key The key of the property to assign.\n * @param {Object} object The parent object of `objValue`.\n * @returns {*} Returns the value to assign.\n */\n function customDefaultsAssignIn(objValue, srcValue, key, object) {\n if (objValue === undefined ||\n (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n return srcValue;\n }\n return objValue;\n }\n\n /**\n * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source\n * objects into destination objects that are passed thru.\n *\n * @private\n * @param {*} objValue The destination value.\n * @param {*} srcValue The source value.\n * @param {string} key The key of the property to merge.\n * @param {Object} object The parent object of `objValue`.\n * @param {Object} source The parent object of `srcValue`.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n * @returns {*} Returns the value to assign.\n */\n function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {\n if (isObject(objValue) && isObject(srcValue)) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, objValue);\n baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);\n stack['delete'](srcValue);\n }\n return objValue;\n }\n\n /**\n * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain\n * objects.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {string} key The key of the property to inspect.\n * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.\n */\n function customOmitClone(value) {\n return isPlainObject(value) ? undefined : value;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\n function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Check that cyclic values are equal.\n var arrStacked = stack.get(array);\n var othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Check that cyclic values are equal.\n var objStacked = stack.get(object);\n var othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n }\n\n /**\n * A specialized version of `baseRest` which flattens the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @returns {Function} Returns the new function.\n */\n function flatRest(func) {\n return setToString(overRest(func, undefined, flatten), func + '');\n }\n\n /**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\n function getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n }\n\n /**\n * Creates an array of own and inherited enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\n function getAllKeysIn(object) {\n return baseGetAllKeys(object, keysIn, getSymbolsIn);\n }\n\n /**\n * Gets metadata for `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {*} Returns the metadata for `func`.\n */\n var getData = !metaMap ? noop : function(func) {\n return metaMap.get(func);\n };\n\n /**\n * Gets the name of `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {string} Returns the function name.\n */\n function getFuncName(func) {\n var result = (func.name + ''),\n array = realNames[result],\n length = hasOwnProperty.call(realNames, result) ? array.length : 0;\n\n while (length--) {\n var data = array[length],\n otherFunc = data.func;\n if (otherFunc == null || otherFunc == func) {\n return data.name;\n }\n }\n return result;\n }\n\n /**\n * Gets the argument placeholder value for `func`.\n *\n * @private\n * @param {Function} func The function to inspect.\n * @returns {*} Returns the placeholder value.\n */\n function getHolder(func) {\n var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;\n return object.placeholder;\n }\n\n /**\n * Gets the appropriate \"iteratee\" function. If `_.iteratee` is customized,\n * this function returns the custom method, otherwise it returns `baseIteratee`.\n * If arguments are provided, the chosen function is invoked with them and\n * its result is returned.\n *\n * @private\n * @param {*} [value] The value to convert to an iteratee.\n * @param {number} [arity] The arity of the created iteratee.\n * @returns {Function} Returns the chosen function or its result.\n */\n function getIteratee() {\n var result = lodash.iteratee || iteratee;\n result = result === iteratee ? baseIteratee : result;\n return arguments.length ? result(arguments[0], arguments[1]) : result;\n }\n\n /**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\n function getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n }\n\n /**\n * Gets the property names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\n function getMatchData(object) {\n var result = keys(object),\n length = result.length;\n\n while (length--) {\n var key = result[length],\n value = object[key];\n\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n }\n\n /**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\n function getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n }\n\n /**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\n function getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n }\n\n /**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\n var getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n };\n\n /**\n * Creates an array of the own and inherited enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\n var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {\n var result = [];\n while (object) {\n arrayPush(result, getSymbols(object));\n object = getPrototype(object);\n }\n return result;\n };\n\n /**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\n var getTag = baseGetTag;\n\n // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\n if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n }\n\n /**\n * Gets the view, applying any `transforms` to the `start` and `end` positions.\n *\n * @private\n * @param {number} start The start of the view.\n * @param {number} end The end of the view.\n * @param {Array} transforms The transformations to apply to the view.\n * @returns {Object} Returns an object containing the `start` and `end`\n * positions of the view.\n */\n function getView(start, end, transforms) {\n var index = -1,\n length = transforms.length;\n\n while (++index < length) {\n var data = transforms[index],\n size = data.size;\n\n switch (data.type) {\n case 'drop': start += size; break;\n case 'dropRight': end -= size; break;\n case 'take': end = nativeMin(end, start + size); break;\n case 'takeRight': start = nativeMax(start, end - size); break;\n }\n }\n return { 'start': start, 'end': end };\n }\n\n /**\n * Extracts wrapper details from the `source` body comment.\n *\n * @private\n * @param {string} source The source to inspect.\n * @returns {Array} Returns the wrapper details.\n */\n function getWrapDetails(source) {\n var match = source.match(reWrapDetails);\n return match ? match[1].split(reSplitDetails) : [];\n }\n\n /**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\n function hasPath(object, path, hasFunc) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n result = false;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result || ++index != length) {\n return result;\n }\n length = object == null ? 0 : object.length;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n }\n\n /**\n * Initializes an array clone.\n *\n * @private\n * @param {Array} array The array to clone.\n * @returns {Array} Returns the initialized clone.\n */\n function initCloneArray(array) {\n var length = array.length,\n result = new array.constructor(length);\n\n // Add properties assigned by `RegExp#exec`.\n if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {\n result.index = array.index;\n result.input = array.input;\n }\n return result;\n }\n\n /**\n * Initializes an object clone.\n *\n * @private\n * @param {Object} object The object to clone.\n * @returns {Object} Returns the initialized clone.\n */\n function initCloneObject(object) {\n return (typeof object.constructor == 'function' && !isPrototype(object))\n ? baseCreate(getPrototype(object))\n : {};\n }\n\n /**\n * Initializes an object clone based on its `toStringTag`.\n *\n * **Note:** This function only supports cloning values with tags of\n * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.\n *\n * @private\n * @param {Object} object The object to clone.\n * @param {string} tag The `toStringTag` of the object to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the initialized clone.\n */\n function initCloneByTag(object, tag, isDeep) {\n var Ctor = object.constructor;\n switch (tag) {\n case arrayBufferTag:\n return cloneArrayBuffer(object);\n\n case boolTag:\n case dateTag:\n return new Ctor(+object);\n\n case dataViewTag:\n return cloneDataView(object, isDeep);\n\n case float32Tag: case float64Tag:\n case int8Tag: case int16Tag: case int32Tag:\n case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:\n return cloneTypedArray(object, isDeep);\n\n case mapTag:\n return new Ctor;\n\n case numberTag:\n case stringTag:\n return new Ctor(object);\n\n case regexpTag:\n return cloneRegExp(object);\n\n case setTag:\n return new Ctor;\n\n case symbolTag:\n return cloneSymbol(object);\n }\n }\n\n /**\n * Inserts wrapper `details` in a comment at the top of the `source` body.\n *\n * @private\n * @param {string} source The source to modify.\n * @returns {Array} details The details to insert.\n * @returns {string} Returns the modified source.\n */\n function insertWrapDetails(source, details) {\n var length = details.length;\n if (!length) {\n return source;\n }\n var lastIndex = length - 1;\n details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];\n details = details.join(length > 2 ? ', ' : ' ');\n return source.replace(reWrapComment, '{\\n/* [wrapped with ' + details + '] */\\n');\n }\n\n /**\n * Checks if `value` is a flattenable `arguments` object or array.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.\n */\n function isFlattenable(value) {\n return isArray(value) || isArguments(value) ||\n !!(spreadableSymbol && value && value[spreadableSymbol]);\n }\n\n /**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\n function isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n }\n\n /**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\n function isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n }\n\n /**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\n function isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n }\n\n /**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\n function isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n }\n\n /**\n * Checks if `func` has a lazy counterpart.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` has a lazy counterpart,\n * else `false`.\n */\n function isLaziable(func) {\n var funcName = getFuncName(func),\n other = lodash[funcName];\n\n if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {\n return false;\n }\n if (func === other) {\n return true;\n }\n var data = getData(other);\n return !!data && func === data[0];\n }\n\n /**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\n function isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n }\n\n /**\n * Checks if `func` is capable of being masked.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `func` is maskable, else `false`.\n */\n var isMaskable = coreJsData ? isFunction : stubFalse;\n\n /**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\n function isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n }\n\n /**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\n function isStrictComparable(value) {\n return value === value && !isObject(value);\n }\n\n /**\n * A specialized version of `matchesProperty` for source values suitable\n * for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\n function matchesStrictComparable(key, srcValue) {\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n }\n\n /**\n * A specialized version of `_.memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\n function memoizeCapped(func) {\n var result = memoize(func, function(key) {\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n var cache = result.cache;\n return result;\n }\n\n /**\n * Merges the function metadata of `source` into `data`.\n *\n * Merging metadata reduces the number of wrappers used to invoke a function.\n * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`\n * may be applied regardless of execution order. Methods like `_.ary` and\n * `_.rearg` modify function arguments, making the order in which they are\n * executed important, preventing the merging of metadata. However, we make\n * an exception for a safe combined case where curried functions have `_.ary`\n * and or `_.rearg` applied.\n *\n * @private\n * @param {Array} data The destination metadata.\n * @param {Array} source The source metadata.\n * @returns {Array} Returns `data`.\n */\n function mergeData(data, source) {\n var bitmask = data[1],\n srcBitmask = source[1],\n newBitmask = bitmask | srcBitmask,\n isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);\n\n var isCombo =\n ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||\n ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||\n ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));\n\n // Exit early if metadata can't be merged.\n if (!(isCommon || isCombo)) {\n return data;\n }\n // Use source `thisArg` if available.\n if (srcBitmask & WRAP_BIND_FLAG) {\n data[2] = source[2];\n // Set when currying a bound function.\n newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;\n }\n // Compose partial arguments.\n var value = source[3];\n if (value) {\n var partials = data[3];\n data[3] = partials ? composeArgs(partials, value, source[4]) : value;\n data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];\n }\n // Compose partial right arguments.\n value = source[5];\n if (value) {\n partials = data[5];\n data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;\n data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];\n }\n // Use source `argPos` if available.\n value = source[7];\n if (value) {\n data[7] = value;\n }\n // Use source `ary` if it's smaller.\n if (srcBitmask & WRAP_ARY_FLAG) {\n data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);\n }\n // Use source `arity` if one is not provided.\n if (data[9] == null) {\n data[9] = source[9];\n }\n // Use source `func` and merge bitmasks.\n data[0] = source[0];\n data[1] = newBitmask;\n\n return data;\n }\n\n /**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\n function objectToString(value) {\n return nativeObjectToString.call(value);\n }\n\n /**\n * A specialized version of `baseRest` which transforms the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @param {Function} transform The rest array transform.\n * @returns {Function} Returns the new function.\n */\n function overRest(func, start, transform) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = transform(array);\n return apply(func, this, otherArgs);\n };\n }\n\n /**\n * Gets the parent value at `path` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path to get the parent value of.\n * @returns {*} Returns the parent value.\n */\n function parent(object, path) {\n return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));\n }\n\n /**\n * Reorder `array` according to the specified indexes where the element at\n * the first index is assigned as the first element, the element at\n * the second index is assigned as the second element, and so on.\n *\n * @private\n * @param {Array} array The array to reorder.\n * @param {Array} indexes The arranged array indexes.\n * @returns {Array} Returns `array`.\n */\n function reorder(array, indexes) {\n var arrLength = array.length,\n length = nativeMin(indexes.length, arrLength),\n oldArray = copyArray(array);\n\n while (length--) {\n var index = indexes[length];\n array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;\n }\n return array;\n }\n\n /**\n * Gets the value at `key`, unless `key` is \"__proto__\" or \"constructor\".\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\n function safeGet(object, key) {\n if (key === 'constructor' && typeof object[key] === 'function') {\n return;\n }\n\n if (key == '__proto__') {\n return;\n }\n\n return object[key];\n }\n\n /**\n * Sets metadata for `func`.\n *\n * **Note:** If this function becomes hot, i.e. is invoked a lot in a short\n * period of time, it will trip its breaker and transition to an identity\n * function to avoid garbage collection pauses in V8. See\n * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)\n * for more details.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\n var setData = shortOut(baseSetData);\n\n /**\n * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).\n *\n * @private\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @returns {number|Object} Returns the timer id or timeout object.\n */\n var setTimeout = ctxSetTimeout || function(func, wait) {\n return root.setTimeout(func, wait);\n };\n\n /**\n * Sets the `toString` method of `func` to return `string`.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\n var setToString = shortOut(baseSetToString);\n\n /**\n * Sets the `toString` method of `wrapper` to mimic the source of `reference`\n * with wrapper details in a comment at the top of the source body.\n *\n * @private\n * @param {Function} wrapper The function to modify.\n * @param {Function} reference The reference function.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @returns {Function} Returns `wrapper`.\n */\n function setWrapToString(wrapper, reference, bitmask) {\n var source = (reference + '');\n return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));\n }\n\n /**\n * Creates a function that'll short out and invoke `identity` instead\n * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n * milliseconds.\n *\n * @private\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new shortable function.\n */\n function shortOut(func) {\n var count = 0,\n lastCalled = 0;\n\n return function() {\n var stamp = nativeNow(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return arguments[0];\n }\n } else {\n count = 0;\n }\n return func.apply(undefined, arguments);\n };\n }\n\n /**\n * A specialized version of `_.shuffle` which mutates and sets the size of `array`.\n *\n * @private\n * @param {Array} array The array to shuffle.\n * @param {number} [size=array.length] The size of `array`.\n * @returns {Array} Returns `array`.\n */\n function shuffleSelf(array, size) {\n var index = -1,\n length = array.length,\n lastIndex = length - 1;\n\n size = size === undefined ? length : size;\n while (++index < size) {\n var rand = baseRandom(index, lastIndex),\n value = array[rand];\n\n array[rand] = array[index];\n array[index] = value;\n }\n array.length = size;\n return array;\n }\n\n /**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\n var stringToPath = memoizeCapped(function(string) {\n var result = [];\n if (string.charCodeAt(0) === 46 /* . */) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, subString) {\n result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n });\n\n /**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\n function toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n }\n\n /**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\n function toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n }\n\n /**\n * Updates wrapper `details` based on `bitmask` flags.\n *\n * @private\n * @returns {Array} details The details to modify.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @returns {Array} Returns `details`.\n */\n function updateWrapDetails(details, bitmask) {\n arrayEach(wrapFlags, function(pair) {\n var value = '_.' + pair[0];\n if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {\n details.push(value);\n }\n });\n return details.sort();\n }\n\n /**\n * Creates a clone of `wrapper`.\n *\n * @private\n * @param {Object} wrapper The wrapper to clone.\n * @returns {Object} Returns the cloned wrapper.\n */\n function wrapperClone(wrapper) {\n if (wrapper instanceof LazyWrapper) {\n return wrapper.clone();\n }\n var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);\n result.__actions__ = copyArray(wrapper.__actions__);\n result.__index__ = wrapper.__index__;\n result.__values__ = wrapper.__values__;\n return result;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\n function chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array == null ? 0 : array.length;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n }\n\n /**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\n function compact(array) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n }\n\n /**\n * Creates a new array concatenating `array` with any additional arrays\n * and/or values.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to concatenate.\n * @param {...*} [values] The values to concatenate.\n * @returns {Array} Returns the new concatenated array.\n * @example\n *\n * var array = [1];\n * var other = _.concat(array, 2, [3], [[4]]);\n *\n * console.log(other);\n * // => [1, 2, 3, [4]]\n *\n * console.log(array);\n * // => [1]\n */\n function concat() {\n var length = arguments.length;\n if (!length) {\n return [];\n }\n var args = Array(length - 1),\n array = arguments[0],\n index = length;\n\n while (index--) {\n args[index - 1] = arguments[index];\n }\n return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));\n }\n\n /**\n * Creates an array of `array` values not included in the other given arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. The order and references of result values are\n * determined by the first array.\n *\n * **Note:** Unlike `_.pullAll`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.without, _.xor\n * @example\n *\n * _.difference([2, 1], [2, 3]);\n * // => [1]\n */\n var difference = baseRest(function(array, values) {\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))\n : [];\n });\n\n /**\n * This method is like `_.difference` except that it accepts `iteratee` which\n * is invoked for each element of `array` and `values` to generate the criterion\n * by which they're compared. The order and references of result values are\n * determined by the first array. The iteratee is invoked with one argument:\n * (value).\n *\n * **Note:** Unlike `_.pullAllBy`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // => [1.2]\n *\n * // The `_.property` iteratee shorthand.\n * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');\n * // => [{ 'x': 2 }]\n */\n var differenceBy = baseRest(function(array, values) {\n var iteratee = last(values);\n if (isArrayLikeObject(iteratee)) {\n iteratee = undefined;\n }\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))\n : [];\n });\n\n /**\n * This method is like `_.difference` except that it accepts `comparator`\n * which is invoked to compare elements of `array` to `values`. The order and\n * references of result values are determined by the first array. The comparator\n * is invoked with two arguments: (arrVal, othVal).\n *\n * **Note:** Unlike `_.pullAllWith`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n *\n * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);\n * // => [{ 'x': 2, 'y': 1 }]\n */\n var differenceWith = baseRest(function(array, values) {\n var comparator = last(values);\n if (isArrayLikeObject(comparator)) {\n comparator = undefined;\n }\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)\n : [];\n });\n\n /**\n * Creates a slice of `array` with `n` elements dropped from the beginning.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to drop.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.drop([1, 2, 3]);\n * // => [2, 3]\n *\n * _.drop([1, 2, 3], 2);\n * // => [3]\n *\n * _.drop([1, 2, 3], 5);\n * // => []\n *\n * _.drop([1, 2, 3], 0);\n * // => [1, 2, 3]\n */\n function drop(array, n, guard) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n return baseSlice(array, n < 0 ? 0 : n, length);\n }\n\n /**\n * Creates a slice of `array` with `n` elements dropped from the end.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to drop.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.dropRight([1, 2, 3]);\n * // => [1, 2]\n *\n * _.dropRight([1, 2, 3], 2);\n * // => [1]\n *\n * _.dropRight([1, 2, 3], 5);\n * // => []\n *\n * _.dropRight([1, 2, 3], 0);\n * // => [1, 2, 3]\n */\n function dropRight(array, n, guard) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n n = length - n;\n return baseSlice(array, 0, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` excluding elements dropped from the end.\n * Elements are dropped until `predicate` returns falsey. The predicate is\n * invoked with three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.dropRightWhile(users, function(o) { return !o.active; });\n * // => objects for ['barney']\n *\n * // The `_.matches` iteratee shorthand.\n * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });\n * // => objects for ['barney', 'fred']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.dropRightWhile(users, ['active', false]);\n * // => objects for ['barney']\n *\n * // The `_.property` iteratee shorthand.\n * _.dropRightWhile(users, 'active');\n * // => objects for ['barney', 'fred', 'pebbles']\n */\n function dropRightWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3), true, true)\n : [];\n }\n\n /**\n * Creates a slice of `array` excluding elements dropped from the beginning.\n * Elements are dropped until `predicate` returns falsey. The predicate is\n * invoked with three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.dropWhile(users, function(o) { return !o.active; });\n * // => objects for ['pebbles']\n *\n * // The `_.matches` iteratee shorthand.\n * _.dropWhile(users, { 'user': 'barney', 'active': false });\n * // => objects for ['fred', 'pebbles']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.dropWhile(users, ['active', false]);\n * // => objects for ['pebbles']\n *\n * // The `_.property` iteratee shorthand.\n * _.dropWhile(users, 'active');\n * // => objects for ['barney', 'fred', 'pebbles']\n */\n function dropWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3), true)\n : [];\n }\n\n /**\n * Fills elements of `array` with `value` from `start` up to, but not\n * including, `end`.\n *\n * **Note:** This method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 3.2.0\n * @category Array\n * @param {Array} array The array to fill.\n * @param {*} value The value to fill `array` with.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _.fill(array, 'a');\n * console.log(array);\n * // => ['a', 'a', 'a']\n *\n * _.fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * _.fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n */\n function fill(array, value, start, end) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {\n start = 0;\n end = length;\n }\n return baseFill(array, value, start, end);\n }\n\n /**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(o) { return o.user == 'barney'; });\n * // => 0\n *\n * // The `_.matches` iteratee shorthand.\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findIndex(users, ['active', false]);\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.findIndex(users, 'active');\n * // => 2\n */\n function findIndex(array, predicate, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseFindIndex(array, getIteratee(predicate, 3), index);\n }\n\n /**\n * This method is like `_.findIndex` except that it iterates over elements\n * of `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=array.length-1] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });\n * // => 2\n *\n * // The `_.matches` iteratee shorthand.\n * _.findLastIndex(users, { 'user': 'barney', 'active': true });\n * // => 0\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findLastIndex(users, ['active', false]);\n * // => 2\n *\n * // The `_.property` iteratee shorthand.\n * _.findLastIndex(users, 'active');\n * // => 0\n */\n function findLastIndex(array, predicate, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = length - 1;\n if (fromIndex !== undefined) {\n index = toInteger(fromIndex);\n index = fromIndex < 0\n ? nativeMax(length + index, 0)\n : nativeMin(index, length - 1);\n }\n return baseFindIndex(array, getIteratee(predicate, 3), index, true);\n }\n\n /**\n * Flattens `array` a single level deep.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flatten([1, [2, [3, [4]], 5]]);\n * // => [1, 2, [3, [4]], 5]\n */\n function flatten(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, 1) : [];\n }\n\n /**\n * Recursively flattens `array`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flattenDeep([1, [2, [3, [4]], 5]]);\n * // => [1, 2, 3, 4, 5]\n */\n function flattenDeep(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, INFINITY) : [];\n }\n\n /**\n * Recursively flatten `array` up to `depth` times.\n *\n * @static\n * @memberOf _\n * @since 4.4.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @param {number} [depth=1] The maximum recursion depth.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * var array = [1, [2, [3, [4]], 5]];\n *\n * _.flattenDepth(array, 1);\n * // => [1, 2, [3, [4]], 5]\n *\n * _.flattenDepth(array, 2);\n * // => [1, 2, 3, [4], 5]\n */\n function flattenDepth(array, depth) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n depth = depth === undefined ? 1 : toInteger(depth);\n return baseFlatten(array, depth);\n }\n\n /**\n * The inverse of `_.toPairs`; this method returns an object composed\n * from key-value `pairs`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} pairs The key-value pairs.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.fromPairs([['a', 1], ['b', 2]]);\n * // => { 'a': 1, 'b': 2 }\n */\n function fromPairs(pairs) {\n var index = -1,\n length = pairs == null ? 0 : pairs.length,\n result = {};\n\n while (++index < length) {\n var pair = pairs[index];\n result[pair[0]] = pair[1];\n }\n return result;\n }\n\n /**\n * Gets the first element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @alias first\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the first element of `array`.\n * @example\n *\n * _.head([1, 2, 3]);\n * // => 1\n *\n * _.head([]);\n * // => undefined\n */\n function head(array) {\n return (array && array.length) ? array[0] : undefined;\n }\n\n /**\n * Gets the index at which the first occurrence of `value` is found in `array`\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. If `fromIndex` is negative, it's used as the\n * offset from the end of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.indexOf([1, 2, 1, 2], 2);\n * // => 1\n *\n * // Search from the `fromIndex`.\n * _.indexOf([1, 2, 1, 2], 2, 2);\n * // => 3\n */\n function indexOf(array, value, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseIndexOf(array, value, index);\n }\n\n /**\n * Gets all but the last element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.initial([1, 2, 3]);\n * // => [1, 2]\n */\n function initial(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseSlice(array, 0, -1) : [];\n }\n\n /**\n * Creates an array of unique values that are included in all given arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. The order and references of result values are\n * determined by the first array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * _.intersection([2, 1], [2, 3]);\n * // => [2]\n */\n var intersection = baseRest(function(arrays) {\n var mapped = arrayMap(arrays, castArrayLikeObject);\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped)\n : [];\n });\n\n /**\n * This method is like `_.intersection` except that it accepts `iteratee`\n * which is invoked for each element of each `arrays` to generate the criterion\n * by which they're compared. The order and references of result values are\n * determined by the first array. The iteratee is invoked with one argument:\n * (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // => [2.1]\n *\n * // The `_.property` iteratee shorthand.\n * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }]\n */\n var intersectionBy = baseRest(function(arrays) {\n var iteratee = last(arrays),\n mapped = arrayMap(arrays, castArrayLikeObject);\n\n if (iteratee === last(mapped)) {\n iteratee = undefined;\n } else {\n mapped.pop();\n }\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped, getIteratee(iteratee, 2))\n : [];\n });\n\n /**\n * This method is like `_.intersection` except that it accepts `comparator`\n * which is invoked to compare elements of `arrays`. The order and references\n * of result values are determined by the first array. The comparator is\n * invoked with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.intersectionWith(objects, others, _.isEqual);\n * // => [{ 'x': 1, 'y': 2 }]\n */\n var intersectionWith = baseRest(function(arrays) {\n var comparator = last(arrays),\n mapped = arrayMap(arrays, castArrayLikeObject);\n\n comparator = typeof comparator == 'function' ? comparator : undefined;\n if (comparator) {\n mapped.pop();\n }\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped, undefined, comparator)\n : [];\n });\n\n /**\n * Converts all elements in `array` into a string separated by `separator`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to convert.\n * @param {string} [separator=','] The element separator.\n * @returns {string} Returns the joined string.\n * @example\n *\n * _.join(['a', 'b', 'c'], '~');\n * // => 'a~b~c'\n */\n function join(array, separator) {\n return array == null ? '' : nativeJoin.call(array, separator);\n }\n\n /**\n * Gets the last element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the last element of `array`.\n * @example\n *\n * _.last([1, 2, 3]);\n * // => 3\n */\n function last(array) {\n var length = array == null ? 0 : array.length;\n return length ? array[length - 1] : undefined;\n }\n\n /**\n * This method is like `_.indexOf` except that it iterates over elements of\n * `array` from right to left.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=array.length-1] The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.lastIndexOf([1, 2, 1, 2], 2);\n * // => 3\n *\n * // Search from the `fromIndex`.\n * _.lastIndexOf([1, 2, 1, 2], 2, 2);\n * // => 1\n */\n function lastIndexOf(array, value, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = length;\n if (fromIndex !== undefined) {\n index = toInteger(fromIndex);\n index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);\n }\n return value === value\n ? strictLastIndexOf(array, value, index)\n : baseFindIndex(array, baseIsNaN, index, true);\n }\n\n /**\n * Gets the element at index `n` of `array`. If `n` is negative, the nth\n * element from the end is returned.\n *\n * @static\n * @memberOf _\n * @since 4.11.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=0] The index of the element to return.\n * @returns {*} Returns the nth element of `array`.\n * @example\n *\n * var array = ['a', 'b', 'c', 'd'];\n *\n * _.nth(array, 1);\n * // => 'b'\n *\n * _.nth(array, -2);\n * // => 'c';\n */\n function nth(array, n) {\n return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;\n }\n\n /**\n * Removes all given values from `array` using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`\n * to remove elements from an array by predicate.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {...*} [values] The values to remove.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = ['a', 'b', 'c', 'a', 'b', 'c'];\n *\n * _.pull(array, 'a', 'c');\n * console.log(array);\n * // => ['b', 'b']\n */\n var pull = baseRest(pullAll);\n\n /**\n * This method is like `_.pull` except that it accepts an array of values to remove.\n *\n * **Note:** Unlike `_.difference`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = ['a', 'b', 'c', 'a', 'b', 'c'];\n *\n * _.pullAll(array, ['a', 'c']);\n * console.log(array);\n * // => ['b', 'b']\n */\n function pullAll(array, values) {\n return (array && array.length && values && values.length)\n ? basePullAll(array, values)\n : array;\n }\n\n /**\n * This method is like `_.pullAll` except that it accepts `iteratee` which is\n * invoked for each element of `array` and `values` to generate the criterion\n * by which they're compared. The iteratee is invoked with one argument: (value).\n *\n * **Note:** Unlike `_.differenceBy`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];\n *\n * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');\n * console.log(array);\n * // => [{ 'x': 2 }]\n */\n function pullAllBy(array, values, iteratee) {\n return (array && array.length && values && values.length)\n ? basePullAll(array, values, getIteratee(iteratee, 2))\n : array;\n }\n\n /**\n * This method is like `_.pullAll` except that it accepts `comparator` which\n * is invoked to compare elements of `array` to `values`. The comparator is\n * invoked with two arguments: (arrVal, othVal).\n *\n * **Note:** Unlike `_.differenceWith`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 4.6.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Array} values The values to remove.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];\n *\n * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);\n * console.log(array);\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]\n */\n function pullAllWith(array, values, comparator) {\n return (array && array.length && values && values.length)\n ? basePullAll(array, values, undefined, comparator)\n : array;\n }\n\n /**\n * Removes elements from `array` corresponding to `indexes` and returns an\n * array of removed elements.\n *\n * **Note:** Unlike `_.at`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {...(number|number[])} [indexes] The indexes of elements to remove.\n * @returns {Array} Returns the new array of removed elements.\n * @example\n *\n * var array = ['a', 'b', 'c', 'd'];\n * var pulled = _.pullAt(array, [1, 3]);\n *\n * console.log(array);\n * // => ['a', 'c']\n *\n * console.log(pulled);\n * // => ['b', 'd']\n */\n var pullAt = flatRest(function(array, indexes) {\n var length = array == null ? 0 : array.length,\n result = baseAt(array, indexes);\n\n basePullAt(array, arrayMap(indexes, function(index) {\n return isIndex(index, length) ? +index : index;\n }).sort(compareAscending));\n\n return result;\n });\n\n /**\n * Removes all elements from `array` that `predicate` returns truthy for\n * and returns an array of the removed elements. The predicate is invoked\n * with three arguments: (value, index, array).\n *\n * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`\n * to pull elements from an array by value.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new array of removed elements.\n * @example\n *\n * var array = [1, 2, 3, 4];\n * var evens = _.remove(array, function(n) {\n * return n % 2 == 0;\n * });\n *\n * console.log(array);\n * // => [1, 3]\n *\n * console.log(evens);\n * // => [2, 4]\n */\n function remove(array, predicate) {\n var result = [];\n if (!(array && array.length)) {\n return result;\n }\n var index = -1,\n indexes = [],\n length = array.length;\n\n predicate = getIteratee(predicate, 3);\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result.push(value);\n indexes.push(index);\n }\n }\n basePullAt(array, indexes);\n return result;\n }\n\n /**\n * Reverses `array` so that the first element becomes the last, the second\n * element becomes the second to last, and so on.\n *\n * **Note:** This method mutates `array` and is based on\n * [`Array#reverse`](https://mdn.io/Array/reverse).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to modify.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _.reverse(array);\n * // => [3, 2, 1]\n *\n * console.log(array);\n * // => [3, 2, 1]\n */\n function reverse(array) {\n return array == null ? array : nativeReverse.call(array);\n }\n\n /**\n * Creates a slice of `array` from `start` up to, but not including, `end`.\n *\n * **Note:** This method is used instead of\n * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are\n * returned.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\n function slice(array, start, end) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {\n start = 0;\n end = length;\n }\n else {\n start = start == null ? 0 : toInteger(start);\n end = end === undefined ? length : toInteger(end);\n }\n return baseSlice(array, start, end);\n }\n\n /**\n * Uses a binary search to determine the lowest index at which `value`\n * should be inserted into `array` in order to maintain its sort order.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * _.sortedIndex([30, 50], 40);\n * // => 1\n */\n function sortedIndex(array, value) {\n return baseSortedIndex(array, value);\n }\n\n /**\n * This method is like `_.sortedIndex` except that it accepts `iteratee`\n * which is invoked for `value` and each element of `array` to compute their\n * sort ranking. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * var objects = [{ 'x': 4 }, { 'x': 5 }];\n *\n * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.sortedIndexBy(objects, { 'x': 4 }, 'x');\n * // => 0\n */\n function sortedIndexBy(array, value, iteratee) {\n return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));\n }\n\n /**\n * This method is like `_.indexOf` except that it performs a binary\n * search on a sorted `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.sortedIndexOf([4, 5, 5, 5, 6], 5);\n * // => 1\n */\n function sortedIndexOf(array, value) {\n var length = array == null ? 0 : array.length;\n if (length) {\n var index = baseSortedIndex(array, value);\n if (index < length && eq(array[index], value)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * This method is like `_.sortedIndex` except that it returns the highest\n * index at which `value` should be inserted into `array` in order to\n * maintain its sort order.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * _.sortedLastIndex([4, 5, 5, 5, 6], 5);\n * // => 4\n */\n function sortedLastIndex(array, value) {\n return baseSortedIndex(array, value, true);\n }\n\n /**\n * This method is like `_.sortedLastIndex` except that it accepts `iteratee`\n * which is invoked for `value` and each element of `array` to compute their\n * sort ranking. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * var objects = [{ 'x': 4 }, { 'x': 5 }];\n *\n * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });\n * // => 1\n *\n * // The `_.property` iteratee shorthand.\n * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');\n * // => 1\n */\n function sortedLastIndexBy(array, value, iteratee) {\n return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);\n }\n\n /**\n * This method is like `_.lastIndexOf` except that it performs a binary\n * search on a sorted `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);\n * // => 3\n */\n function sortedLastIndexOf(array, value) {\n var length = array == null ? 0 : array.length;\n if (length) {\n var index = baseSortedIndex(array, value, true) - 1;\n if (eq(array[index], value)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * This method is like `_.uniq` except that it's designed and optimized\n * for sorted arrays.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.sortedUniq([1, 1, 2]);\n * // => [1, 2]\n */\n function sortedUniq(array) {\n return (array && array.length)\n ? baseSortedUniq(array)\n : [];\n }\n\n /**\n * This method is like `_.uniqBy` except that it's designed and optimized\n * for sorted arrays.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);\n * // => [1.1, 2.3]\n */\n function sortedUniqBy(array, iteratee) {\n return (array && array.length)\n ? baseSortedUniq(array, getIteratee(iteratee, 2))\n : [];\n }\n\n /**\n * Gets all but the first element of `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.tail([1, 2, 3]);\n * // => [2, 3]\n */\n function tail(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseSlice(array, 1, length) : [];\n }\n\n /**\n * Creates a slice of `array` with `n` elements taken from the beginning.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to take.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.take([1, 2, 3]);\n * // => [1]\n *\n * _.take([1, 2, 3], 2);\n * // => [1, 2]\n *\n * _.take([1, 2, 3], 5);\n * // => [1, 2, 3]\n *\n * _.take([1, 2, 3], 0);\n * // => []\n */\n function take(array, n, guard) {\n if (!(array && array.length)) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n return baseSlice(array, 0, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` with `n` elements taken from the end.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to take.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.takeRight([1, 2, 3]);\n * // => [3]\n *\n * _.takeRight([1, 2, 3], 2);\n * // => [2, 3]\n *\n * _.takeRight([1, 2, 3], 5);\n * // => [1, 2, 3]\n *\n * _.takeRight([1, 2, 3], 0);\n * // => []\n */\n function takeRight(array, n, guard) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return [];\n }\n n = (guard || n === undefined) ? 1 : toInteger(n);\n n = length - n;\n return baseSlice(array, n < 0 ? 0 : n, length);\n }\n\n /**\n * Creates a slice of `array` with elements taken from the end. Elements are\n * taken until `predicate` returns falsey. The predicate is invoked with\n * three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.takeRightWhile(users, function(o) { return !o.active; });\n * // => objects for ['fred', 'pebbles']\n *\n * // The `_.matches` iteratee shorthand.\n * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });\n * // => objects for ['pebbles']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.takeRightWhile(users, ['active', false]);\n * // => objects for ['fred', 'pebbles']\n *\n * // The `_.property` iteratee shorthand.\n * _.takeRightWhile(users, 'active');\n * // => []\n */\n function takeRightWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3), false, true)\n : [];\n }\n\n /**\n * Creates a slice of `array` with elements taken from the beginning. Elements\n * are taken until `predicate` returns falsey. The predicate is invoked with\n * three arguments: (value, index, array).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.takeWhile(users, function(o) { return !o.active; });\n * // => objects for ['barney', 'fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.takeWhile(users, { 'user': 'barney', 'active': false });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.takeWhile(users, ['active', false]);\n * // => objects for ['barney', 'fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.takeWhile(users, 'active');\n * // => []\n */\n function takeWhile(array, predicate) {\n return (array && array.length)\n ? baseWhile(array, getIteratee(predicate, 3))\n : [];\n }\n\n /**\n * Creates an array of unique values, in order, from all given arrays using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * _.union([2], [1, 2]);\n * // => [2, 1]\n */\n var union = baseRest(function(arrays) {\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));\n });\n\n /**\n * This method is like `_.union` except that it accepts `iteratee` which is\n * invoked for each element of each `arrays` to generate the criterion by\n * which uniqueness is computed. Result values are chosen from the first\n * array in which the value occurs. The iteratee is invoked with one argument:\n * (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * _.unionBy([2.1], [1.2, 2.3], Math.floor);\n * // => [2.1, 1.2]\n *\n * // The `_.property` iteratee shorthand.\n * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }, { 'x': 2 }]\n */\n var unionBy = baseRest(function(arrays) {\n var iteratee = last(arrays);\n if (isArrayLikeObject(iteratee)) {\n iteratee = undefined;\n }\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));\n });\n\n /**\n * This method is like `_.union` except that it accepts `comparator` which\n * is invoked to compare elements of `arrays`. Result values are chosen from\n * the first array in which the value occurs. The comparator is invoked\n * with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.unionWith(objects, others, _.isEqual);\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]\n */\n var unionWith = baseRest(function(arrays) {\n var comparator = last(arrays);\n comparator = typeof comparator == 'function' ? comparator : undefined;\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);\n });\n\n /**\n * Creates a duplicate-free version of an array, using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons, in which only the first occurrence of each element\n * is kept. The order of result values is determined by the order they occur\n * in the array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.uniq([2, 1, 2]);\n * // => [2, 1]\n */\n function uniq(array) {\n return (array && array.length) ? baseUniq(array) : [];\n }\n\n /**\n * This method is like `_.uniq` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * uniqueness is computed. The order of result values is determined by the\n * order they occur in the array. The iteratee is invoked with one argument:\n * (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.uniqBy([2.1, 1.2, 2.3], Math.floor);\n * // => [2.1, 1.2]\n *\n * // The `_.property` iteratee shorthand.\n * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }, { 'x': 2 }]\n */\n function uniqBy(array, iteratee) {\n return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];\n }\n\n /**\n * This method is like `_.uniq` except that it accepts `comparator` which\n * is invoked to compare elements of `array`. The order of result values is\n * determined by the order they occur in the array.The comparator is invoked\n * with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.uniqWith(objects, _.isEqual);\n * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]\n */\n function uniqWith(array, comparator) {\n comparator = typeof comparator == 'function' ? comparator : undefined;\n return (array && array.length) ? baseUniq(array, undefined, comparator) : [];\n }\n\n /**\n * This method is like `_.zip` except that it accepts an array of grouped\n * elements and creates an array regrouping the elements to their pre-zip\n * configuration.\n *\n * @static\n * @memberOf _\n * @since 1.2.0\n * @category Array\n * @param {Array} array The array of grouped elements to process.\n * @returns {Array} Returns the new array of regrouped elements.\n * @example\n *\n * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);\n * // => [['a', 1, true], ['b', 2, false]]\n *\n * _.unzip(zipped);\n * // => [['a', 'b'], [1, 2], [true, false]]\n */\n function unzip(array) {\n if (!(array && array.length)) {\n return [];\n }\n var length = 0;\n array = arrayFilter(array, function(group) {\n if (isArrayLikeObject(group)) {\n length = nativeMax(group.length, length);\n return true;\n }\n });\n return baseTimes(length, function(index) {\n return arrayMap(array, baseProperty(index));\n });\n }\n\n /**\n * This method is like `_.unzip` except that it accepts `iteratee` to specify\n * how regrouped values should be combined. The iteratee is invoked with the\n * elements of each group: (...group).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Array\n * @param {Array} array The array of grouped elements to process.\n * @param {Function} [iteratee=_.identity] The function to combine\n * regrouped values.\n * @returns {Array} Returns the new array of regrouped elements.\n * @example\n *\n * var zipped = _.zip([1, 2], [10, 20], [100, 200]);\n * // => [[1, 10, 100], [2, 20, 200]]\n *\n * _.unzipWith(zipped, _.add);\n * // => [3, 30, 300]\n */\n function unzipWith(array, iteratee) {\n if (!(array && array.length)) {\n return [];\n }\n var result = unzip(array);\n if (iteratee == null) {\n return result;\n }\n return arrayMap(result, function(group) {\n return apply(iteratee, undefined, group);\n });\n }\n\n /**\n * Creates an array excluding all given values using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * **Note:** Unlike `_.pull`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...*} [values] The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.difference, _.xor\n * @example\n *\n * _.without([2, 1, 2, 3], 1, 2);\n * // => [3]\n */\n var without = baseRest(function(array, values) {\n return isArrayLikeObject(array)\n ? baseDifference(array, values)\n : [];\n });\n\n /**\n * Creates an array of unique values that is the\n * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)\n * of the given arrays. The order of result values is determined by the order\n * they occur in the arrays.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.difference, _.without\n * @example\n *\n * _.xor([2, 1], [2, 3]);\n * // => [1, 3]\n */\n var xor = baseRest(function(arrays) {\n return baseXor(arrayFilter(arrays, isArrayLikeObject));\n });\n\n /**\n * This method is like `_.xor` except that it accepts `iteratee` which is\n * invoked for each element of each `arrays` to generate the criterion by\n * which by which they're compared. The order of result values is determined\n * by the order they occur in the arrays. The iteratee is invoked with one\n * argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // => [1.2, 3.4]\n *\n * // The `_.property` iteratee shorthand.\n * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 2 }]\n */\n var xorBy = baseRest(function(arrays) {\n var iteratee = last(arrays);\n if (isArrayLikeObject(iteratee)) {\n iteratee = undefined;\n }\n return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));\n });\n\n /**\n * This method is like `_.xor` except that it accepts `comparator` which is\n * invoked to compare elements of `arrays`. The order of result values is\n * determined by the order they occur in the arrays. The comparator is invoked\n * with two arguments: (arrVal, othVal).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n *\n * _.xorWith(objects, others, _.isEqual);\n * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]\n */\n var xorWith = baseRest(function(arrays) {\n var comparator = last(arrays);\n comparator = typeof comparator == 'function' ? comparator : undefined;\n return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);\n });\n\n /**\n * Creates an array of grouped elements, the first of which contains the\n * first elements of the given arrays, the second of which contains the\n * second elements of the given arrays, and so on.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to process.\n * @returns {Array} Returns the new array of grouped elements.\n * @example\n *\n * _.zip(['a', 'b'], [1, 2], [true, false]);\n * // => [['a', 1, true], ['b', 2, false]]\n */\n var zip = baseRest(unzip);\n\n /**\n * This method is like `_.fromPairs` except that it accepts two arrays,\n * one of property identifiers and one of corresponding values.\n *\n * @static\n * @memberOf _\n * @since 0.4.0\n * @category Array\n * @param {Array} [props=[]] The property identifiers.\n * @param {Array} [values=[]] The property values.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.zipObject(['a', 'b'], [1, 2]);\n * // => { 'a': 1, 'b': 2 }\n */\n function zipObject(props, values) {\n return baseZipObject(props || [], values || [], assignValue);\n }\n\n /**\n * This method is like `_.zipObject` except that it supports property paths.\n *\n * @static\n * @memberOf _\n * @since 4.1.0\n * @category Array\n * @param {Array} [props=[]] The property identifiers.\n * @param {Array} [values=[]] The property values.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);\n * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n */\n function zipObjectDeep(props, values) {\n return baseZipObject(props || [], values || [], baseSet);\n }\n\n /**\n * This method is like `_.zip` except that it accepts `iteratee` to specify\n * how grouped values should be combined. The iteratee is invoked with the\n * elements of each group: (...group).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Array\n * @param {...Array} [arrays] The arrays to process.\n * @param {Function} [iteratee=_.identity] The function to combine\n * grouped values.\n * @returns {Array} Returns the new array of grouped elements.\n * @example\n *\n * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {\n * return a + b + c;\n * });\n * // => [111, 222]\n */\n var zipWith = baseRest(function(arrays) {\n var length = arrays.length,\n iteratee = length > 1 ? arrays[length - 1] : undefined;\n\n iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;\n return unzipWith(arrays, iteratee);\n });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a `lodash` wrapper instance that wraps `value` with explicit method\n * chain sequences enabled. The result of such sequences must be unwrapped\n * with `_#value`.\n *\n * @static\n * @memberOf _\n * @since 1.3.0\n * @category Seq\n * @param {*} value The value to wrap.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'pebbles', 'age': 1 }\n * ];\n *\n * var youngest = _\n * .chain(users)\n * .sortBy('age')\n * .map(function(o) {\n * return o.user + ' is ' + o.age;\n * })\n * .head()\n * .value();\n * // => 'pebbles is 1'\n */\n function chain(value) {\n var result = lodash(value);\n result.__chain__ = true;\n return result;\n }\n\n /**\n * This method invokes `interceptor` and returns `value`. The interceptor\n * is invoked with one argument; (value). The purpose of this method is to\n * \"tap into\" a method chain sequence in order to modify intermediate results.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Seq\n * @param {*} value The value to provide to `interceptor`.\n * @param {Function} interceptor The function to invoke.\n * @returns {*} Returns `value`.\n * @example\n *\n * _([1, 2, 3])\n * .tap(function(array) {\n * // Mutate input array.\n * array.pop();\n * })\n * .reverse()\n * .value();\n * // => [2, 1]\n */\n function tap(value, interceptor) {\n interceptor(value);\n return value;\n }\n\n /**\n * This method is like `_.tap` except that it returns the result of `interceptor`.\n * The purpose of this method is to \"pass thru\" values replacing intermediate\n * results in a method chain sequence.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Seq\n * @param {*} value The value to provide to `interceptor`.\n * @param {Function} interceptor The function to invoke.\n * @returns {*} Returns the result of `interceptor`.\n * @example\n *\n * _(' abc ')\n * .chain()\n * .trim()\n * .thru(function(value) {\n * return [value];\n * })\n * .value();\n * // => ['abc']\n */\n function thru(value, interceptor) {\n return interceptor(value);\n }\n\n /**\n * This method is the wrapper version of `_.at`.\n *\n * @name at\n * @memberOf _\n * @since 1.0.0\n * @category Seq\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };\n *\n * _(object).at(['a[0].b.c', 'a[1]']).value();\n * // => [3, 4]\n */\n var wrapperAt = flatRest(function(paths) {\n var length = paths.length,\n start = length ? paths[0] : 0,\n value = this.__wrapped__,\n interceptor = function(object) { return baseAt(object, paths); };\n\n if (length > 1 || this.__actions__.length ||\n !(value instanceof LazyWrapper) || !isIndex(start)) {\n return this.thru(interceptor);\n }\n value = value.slice(start, +start + (length ? 1 : 0));\n value.__actions__.push({\n 'func': thru,\n 'args': [interceptor],\n 'thisArg': undefined\n });\n return new LodashWrapper(value, this.__chain__).thru(function(array) {\n if (length && !array.length) {\n array.push(undefined);\n }\n return array;\n });\n });\n\n /**\n * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.\n *\n * @name chain\n * @memberOf _\n * @since 0.1.0\n * @category Seq\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * // A sequence without explicit chaining.\n * _(users).head();\n * // => { 'user': 'barney', 'age': 36 }\n *\n * // A sequence with explicit chaining.\n * _(users)\n * .chain()\n * .head()\n * .pick('user')\n * .value();\n * // => { 'user': 'barney' }\n */\n function wrapperChain() {\n return chain(this);\n }\n\n /**\n * Executes the chain sequence and returns the wrapped result.\n *\n * @name commit\n * @memberOf _\n * @since 3.2.0\n * @category Seq\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2];\n * var wrapped = _(array).push(3);\n *\n * console.log(array);\n * // => [1, 2]\n *\n * wrapped = wrapped.commit();\n * console.log(array);\n * // => [1, 2, 3]\n *\n * wrapped.last();\n * // => 3\n *\n * console.log(array);\n * // => [1, 2, 3]\n */\n function wrapperCommit() {\n return new LodashWrapper(this.value(), this.__chain__);\n }\n\n /**\n * Gets the next value on a wrapped object following the\n * [iterator protocol](https://mdn.io/iteration_protocols#iterator).\n *\n * @name next\n * @memberOf _\n * @since 4.0.0\n * @category Seq\n * @returns {Object} Returns the next iterator value.\n * @example\n *\n * var wrapped = _([1, 2]);\n *\n * wrapped.next();\n * // => { 'done': false, 'value': 1 }\n *\n * wrapped.next();\n * // => { 'done': false, 'value': 2 }\n *\n * wrapped.next();\n * // => { 'done': true, 'value': undefined }\n */\n function wrapperNext() {\n if (this.__values__ === undefined) {\n this.__values__ = toArray(this.value());\n }\n var done = this.__index__ >= this.__values__.length,\n value = done ? undefined : this.__values__[this.__index__++];\n\n return { 'done': done, 'value': value };\n }\n\n /**\n * Enables the wrapper to be iterable.\n *\n * @name Symbol.iterator\n * @memberOf _\n * @since 4.0.0\n * @category Seq\n * @returns {Object} Returns the wrapper object.\n * @example\n *\n * var wrapped = _([1, 2]);\n *\n * wrapped[Symbol.iterator]() === wrapped;\n * // => true\n *\n * Array.from(wrapped);\n * // => [1, 2]\n */\n function wrapperToIterator() {\n return this;\n }\n\n /**\n * Creates a clone of the chain sequence planting `value` as the wrapped value.\n *\n * @name plant\n * @memberOf _\n * @since 3.2.0\n * @category Seq\n * @param {*} value The value to plant.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var wrapped = _([1, 2]).map(square);\n * var other = wrapped.plant([3, 4]);\n *\n * other.value();\n * // => [9, 16]\n *\n * wrapped.value();\n * // => [1, 4]\n */\n function wrapperPlant(value) {\n var result,\n parent = this;\n\n while (parent instanceof baseLodash) {\n var clone = wrapperClone(parent);\n clone.__index__ = 0;\n clone.__values__ = undefined;\n if (result) {\n previous.__wrapped__ = clone;\n } else {\n result = clone;\n }\n var previous = clone;\n parent = parent.__wrapped__;\n }\n previous.__wrapped__ = value;\n return result;\n }\n\n /**\n * This method is the wrapper version of `_.reverse`.\n *\n * **Note:** This method mutates the wrapped array.\n *\n * @name reverse\n * @memberOf _\n * @since 0.1.0\n * @category Seq\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _(array).reverse().value()\n * // => [3, 2, 1]\n *\n * console.log(array);\n * // => [3, 2, 1]\n */\n function wrapperReverse() {\n var value = this.__wrapped__;\n if (value instanceof LazyWrapper) {\n var wrapped = value;\n if (this.__actions__.length) {\n wrapped = new LazyWrapper(this);\n }\n wrapped = wrapped.reverse();\n wrapped.__actions__.push({\n 'func': thru,\n 'args': [reverse],\n 'thisArg': undefined\n });\n return new LodashWrapper(wrapped, this.__chain__);\n }\n return this.thru(reverse);\n }\n\n /**\n * Executes the chain sequence to resolve the unwrapped value.\n *\n * @name value\n * @memberOf _\n * @since 0.1.0\n * @alias toJSON, valueOf\n * @category Seq\n * @returns {*} Returns the resolved unwrapped value.\n * @example\n *\n * _([1, 2, 3]).value();\n * // => [1, 2, 3]\n */\n function wrapperValue() {\n return baseWrapperValue(this.__wrapped__, this.__actions__);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The corresponding value of\n * each key is the number of times the key was returned by `iteratee`. The\n * iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.countBy([6.1, 4.2, 6.3], Math.floor);\n * // => { '4': 1, '6': 2 }\n *\n * // The `_.property` iteratee shorthand.\n * _.countBy(['one', 'two', 'three'], 'length');\n * // => { '3': 2, '5': 1 }\n */\n var countBy = createAggregator(function(result, value, key) {\n if (hasOwnProperty.call(result, key)) {\n ++result[key];\n } else {\n baseAssignValue(result, key, 1);\n }\n });\n\n /**\n * Checks if `predicate` returns truthy for **all** elements of `collection`.\n * Iteration is stopped once `predicate` returns falsey. The predicate is\n * invoked with three arguments: (value, index|key, collection).\n *\n * **Note:** This method returns `true` for\n * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because\n * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of\n * elements of empty collections.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`.\n * @example\n *\n * _.every([true, 1, null, 'yes'], Boolean);\n * // => false\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.every(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.every(users, ['active', false]);\n * // => true\n *\n * // The `_.property` iteratee shorthand.\n * _.every(users, 'active');\n * // => false\n */\n function every(collection, predicate, guard) {\n var func = isArray(collection) ? arrayEvery : baseEvery;\n if (guard && isIterateeCall(collection, predicate, guard)) {\n predicate = undefined;\n }\n return func(collection, getIteratee(predicate, 3));\n }\n\n /**\n * Iterates over elements of `collection`, returning an array of all elements\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * **Note:** Unlike `_.remove`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n * @see _.reject\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * _.filter(users, function(o) { return !o.active; });\n * // => objects for ['fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.filter(users, { 'age': 36, 'active': true });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.filter(users, ['active', false]);\n * // => objects for ['fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.filter(users, 'active');\n * // => objects for ['barney']\n *\n * // Combining several predicates using `_.overEvery` or `_.overSome`.\n * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));\n * // => objects for ['fred', 'barney']\n */\n function filter(collection, predicate) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n return func(collection, getIteratee(predicate, 3));\n }\n\n /**\n * Iterates over elements of `collection`, returning the first element\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false },\n * { 'user': 'pebbles', 'age': 1, 'active': true }\n * ];\n *\n * _.find(users, function(o) { return o.age < 40; });\n * // => object for 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.find(users, { 'age': 1, 'active': true });\n * // => object for 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.find(users, ['active', false]);\n * // => object for 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.find(users, 'active');\n * // => object for 'barney'\n */\n var find = createFind(findIndex);\n\n /**\n * This method is like `_.find` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=collection.length-1] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * _.findLast([1, 2, 3, 4], function(n) {\n * return n % 2 == 1;\n * });\n * // => 3\n */\n var findLast = createFind(findLastIndex);\n\n /**\n * Creates a flattened array of values by running each element in `collection`\n * thru `iteratee` and flattening the mapped results. The iteratee is invoked\n * with three arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * function duplicate(n) {\n * return [n, n];\n * }\n *\n * _.flatMap([1, 2], duplicate);\n * // => [1, 1, 2, 2]\n */\n function flatMap(collection, iteratee) {\n return baseFlatten(map(collection, iteratee), 1);\n }\n\n /**\n * This method is like `_.flatMap` except that it recursively flattens the\n * mapped results.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * function duplicate(n) {\n * return [[[n, n]]];\n * }\n *\n * _.flatMapDeep([1, 2], duplicate);\n * // => [1, 1, 2, 2]\n */\n function flatMapDeep(collection, iteratee) {\n return baseFlatten(map(collection, iteratee), INFINITY);\n }\n\n /**\n * This method is like `_.flatMap` except that it recursively flattens the\n * mapped results up to `depth` times.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {number} [depth=1] The maximum recursion depth.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * function duplicate(n) {\n * return [[[n, n]]];\n * }\n *\n * _.flatMapDepth([1, 2], duplicate, 2);\n * // => [[1, 1], [2, 2]]\n */\n function flatMapDepth(collection, iteratee, depth) {\n depth = depth === undefined ? 1 : toInteger(depth);\n return baseFlatten(map(collection, iteratee), depth);\n }\n\n /**\n * Iterates over elements of `collection` and invokes `iteratee` for each element.\n * The iteratee is invoked with three arguments: (value, index|key, collection).\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * **Note:** As with other \"Collections\" methods, objects with a \"length\"\n * property are iterated like arrays. To avoid this behavior use `_.forIn`\n * or `_.forOwn` for object iteration.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @alias each\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n * @see _.forEachRight\n * @example\n *\n * _.forEach([1, 2], function(value) {\n * console.log(value);\n * });\n * // => Logs `1` then `2`.\n *\n * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a' then 'b' (iteration order is not guaranteed).\n */\n function forEach(collection, iteratee) {\n var func = isArray(collection) ? arrayEach : baseEach;\n return func(collection, getIteratee(iteratee, 3));\n }\n\n /**\n * This method is like `_.forEach` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @alias eachRight\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n * @see _.forEach\n * @example\n *\n * _.forEachRight([1, 2], function(value) {\n * console.log(value);\n * });\n * // => Logs `2` then `1`.\n */\n function forEachRight(collection, iteratee) {\n var func = isArray(collection) ? arrayEachRight : baseEachRight;\n return func(collection, getIteratee(iteratee, 3));\n }\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The order of grouped values\n * is determined by the order they occur in `collection`. The corresponding\n * value of each key is an array of elements responsible for generating the\n * key. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.groupBy([6.1, 4.2, 6.3], Math.floor);\n * // => { '4': [4.2], '6': [6.1, 6.3] }\n *\n * // The `_.property` iteratee shorthand.\n * _.groupBy(['one', 'two', 'three'], 'length');\n * // => { '3': ['one', 'two'], '5': ['three'] }\n */\n var groupBy = createAggregator(function(result, value, key) {\n if (hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n baseAssignValue(result, key, [value]);\n }\n });\n\n /**\n * Checks if `value` is in `collection`. If `collection` is a string, it's\n * checked for a substring of `value`, otherwise\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * is used for equality comparisons. If `fromIndex` is negative, it's used as\n * the offset from the end of `collection`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object|string} collection The collection to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {boolean} Returns `true` if `value` is found, else `false`.\n * @example\n *\n * _.includes([1, 2, 3], 1);\n * // => true\n *\n * _.includes([1, 2, 3], 1, 2);\n * // => false\n *\n * _.includes({ 'a': 1, 'b': 2 }, 1);\n * // => true\n *\n * _.includes('abcd', 'bc');\n * // => true\n */\n function includes(collection, value, fromIndex, guard) {\n collection = isArrayLike(collection) ? collection : values(collection);\n fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;\n\n var length = collection.length;\n if (fromIndex < 0) {\n fromIndex = nativeMax(length + fromIndex, 0);\n }\n return isString(collection)\n ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)\n : (!!length && baseIndexOf(collection, value, fromIndex) > -1);\n }\n\n /**\n * Invokes the method at `path` of each element in `collection`, returning\n * an array of the results of each invoked method. Any additional arguments\n * are provided to each invoked method. If `path` is a function, it's invoked\n * for, and `this` bound to, each element in `collection`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Array|Function|string} path The path of the method to invoke or\n * the function invoked per iteration.\n * @param {...*} [args] The arguments to invoke each method with.\n * @returns {Array} Returns the array of results.\n * @example\n *\n * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');\n * // => [[1, 5, 7], [1, 2, 3]]\n *\n * _.invokeMap([123, 456], String.prototype.split, '');\n * // => [['1', '2', '3'], ['4', '5', '6']]\n */\n var invokeMap = baseRest(function(collection, path, args) {\n var index = -1,\n isFunc = typeof path == 'function',\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value) {\n result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);\n });\n return result;\n });\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The corresponding value of\n * each key is the last element responsible for generating the key. The\n * iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * var array = [\n * { 'dir': 'left', 'code': 97 },\n * { 'dir': 'right', 'code': 100 }\n * ];\n *\n * _.keyBy(array, function(o) {\n * return String.fromCharCode(o.code);\n * });\n * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }\n *\n * _.keyBy(array, 'dir');\n * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }\n */\n var keyBy = createAggregator(function(result, value, key) {\n baseAssignValue(result, key, value);\n });\n\n /**\n * Creates an array of values by running each element in `collection` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.\n *\n * The guarded methods are:\n * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,\n * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,\n * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,\n * `template`, `trim`, `trimEnd`, `trimStart`, and `words`\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * _.map([4, 8], square);\n * // => [16, 64]\n *\n * _.map({ 'a': 4, 'b': 8 }, square);\n * // => [16, 64] (iteration order is not guaranteed)\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * // The `_.property` iteratee shorthand.\n * _.map(users, 'user');\n * // => ['barney', 'fred']\n */\n function map(collection, iteratee) {\n var func = isArray(collection) ? arrayMap : baseMap;\n return func(collection, getIteratee(iteratee, 3));\n }\n\n /**\n * This method is like `_.sortBy` except that it allows specifying the sort\n * orders of the iteratees to sort by. If `orders` is unspecified, all values\n * are sorted in ascending order. Otherwise, specify an order of \"desc\" for\n * descending or \"asc\" for ascending sort order of corresponding values.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]\n * The iteratees to sort by.\n * @param {string[]} [orders] The sort orders of `iteratees`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 34 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'barney', 'age': 36 }\n * ];\n *\n * // Sort by `user` in ascending order and by `age` in descending order.\n * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]\n */\n function orderBy(collection, iteratees, orders, guard) {\n if (collection == null) {\n return [];\n }\n if (!isArray(iteratees)) {\n iteratees = iteratees == null ? [] : [iteratees];\n }\n orders = guard ? undefined : orders;\n if (!isArray(orders)) {\n orders = orders == null ? [] : [orders];\n }\n return baseOrderBy(collection, iteratees, orders);\n }\n\n /**\n * Creates an array of elements split into two groups, the first of which\n * contains elements `predicate` returns truthy for, the second of which\n * contains elements `predicate` returns falsey for. The predicate is\n * invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the array of grouped elements.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': true },\n * { 'user': 'pebbles', 'age': 1, 'active': false }\n * ];\n *\n * _.partition(users, function(o) { return o.active; });\n * // => objects for [['fred'], ['barney', 'pebbles']]\n *\n * // The `_.matches` iteratee shorthand.\n * _.partition(users, { 'age': 1, 'active': false });\n * // => objects for [['pebbles'], ['barney', 'fred']]\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.partition(users, ['active', false]);\n * // => objects for [['barney', 'pebbles'], ['fred']]\n *\n * // The `_.property` iteratee shorthand.\n * _.partition(users, 'active');\n * // => objects for [['fred'], ['barney', 'pebbles']]\n */\n var partition = createAggregator(function(result, value, key) {\n result[key ? 0 : 1].push(value);\n }, function() { return [[], []]; });\n\n /**\n * Reduces `collection` to a value which is the accumulated result of running\n * each element in `collection` thru `iteratee`, where each successive\n * invocation is supplied the return value of the previous. If `accumulator`\n * is not given, the first element of `collection` is used as the initial\n * value. The iteratee is invoked with four arguments:\n * (accumulator, value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.reduce`, `_.reduceRight`, and `_.transform`.\n *\n * The guarded methods are:\n * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,\n * and `sortBy`\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @returns {*} Returns the accumulated value.\n * @see _.reduceRight\n * @example\n *\n * _.reduce([1, 2], function(sum, n) {\n * return sum + n;\n * }, 0);\n * // => 3\n *\n * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {\n * (result[value] || (result[value] = [])).push(key);\n * return result;\n * }, {});\n * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)\n */\n function reduce(collection, iteratee, accumulator) {\n var func = isArray(collection) ? arrayReduce : baseReduce,\n initAccum = arguments.length < 3;\n\n return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);\n }\n\n /**\n * This method is like `_.reduce` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @returns {*} Returns the accumulated value.\n * @see _.reduce\n * @example\n *\n * var array = [[0, 1], [2, 3], [4, 5]];\n *\n * _.reduceRight(array, function(flattened, other) {\n * return flattened.concat(other);\n * }, []);\n * // => [4, 5, 2, 3, 0, 1]\n */\n function reduceRight(collection, iteratee, accumulator) {\n var func = isArray(collection) ? arrayReduceRight : baseReduce,\n initAccum = arguments.length < 3;\n\n return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);\n }\n\n /**\n * The opposite of `_.filter`; this method returns the elements of `collection`\n * that `predicate` does **not** return truthy for.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n * @see _.filter\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': true }\n * ];\n *\n * _.reject(users, function(o) { return !o.active; });\n * // => objects for ['fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.reject(users, { 'age': 40, 'active': true });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.reject(users, ['active', false]);\n * // => objects for ['fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.reject(users, 'active');\n * // => objects for ['barney']\n */\n function reject(collection, predicate) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n return func(collection, negate(getIteratee(predicate, 3)));\n }\n\n /**\n * Gets a random element from `collection`.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to sample.\n * @returns {*} Returns the random element.\n * @example\n *\n * _.sample([1, 2, 3, 4]);\n * // => 2\n */\n function sample(collection) {\n var func = isArray(collection) ? arraySample : baseSample;\n return func(collection);\n }\n\n /**\n * Gets `n` random elements at unique keys from `collection` up to the\n * size of `collection`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to sample.\n * @param {number} [n=1] The number of elements to sample.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the random elements.\n * @example\n *\n * _.sampleSize([1, 2, 3], 2);\n * // => [3, 1]\n *\n * _.sampleSize([1, 2, 3], 4);\n * // => [2, 3, 1]\n */\n function sampleSize(collection, n, guard) {\n if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {\n n = 1;\n } else {\n n = toInteger(n);\n }\n var func = isArray(collection) ? arraySampleSize : baseSampleSize;\n return func(collection, n);\n }\n\n /**\n * Creates an array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to shuffle.\n * @returns {Array} Returns the new shuffled array.\n * @example\n *\n * _.shuffle([1, 2, 3, 4]);\n * // => [4, 1, 3, 2]\n */\n function shuffle(collection) {\n var func = isArray(collection) ? arrayShuffle : baseShuffle;\n return func(collection);\n }\n\n /**\n * Gets the size of `collection` by returning its length for array-like\n * values or the number of own enumerable string keyed properties for objects.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object|string} collection The collection to inspect.\n * @returns {number} Returns the collection size.\n * @example\n *\n * _.size([1, 2, 3]);\n * // => 3\n *\n * _.size({ 'a': 1, 'b': 2 });\n * // => 2\n *\n * _.size('pebbles');\n * // => 7\n */\n function size(collection) {\n if (collection == null) {\n return 0;\n }\n if (isArrayLike(collection)) {\n return isString(collection) ? stringSize(collection) : collection.length;\n }\n var tag = getTag(collection);\n if (tag == mapTag || tag == setTag) {\n return collection.size;\n }\n return baseKeys(collection).length;\n }\n\n /**\n * Checks if `predicate` returns truthy for **any** element of `collection`.\n * Iteration is stopped once `predicate` returns truthy. The predicate is\n * invoked with three arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n * @example\n *\n * _.some([null, 0, 'yes', false], Boolean);\n * // => true\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.some(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.some(users, ['active', false]);\n * // => true\n *\n * // The `_.property` iteratee shorthand.\n * _.some(users, 'active');\n * // => true\n */\n function some(collection, predicate, guard) {\n var func = isArray(collection) ? arraySome : baseSome;\n if (guard && isIterateeCall(collection, predicate, guard)) {\n predicate = undefined;\n }\n return func(collection, getIteratee(predicate, 3));\n }\n\n /**\n * Creates an array of elements, sorted in ascending order by the results of\n * running each element in a collection thru each iteratee. This method\n * performs a stable sort, that is, it preserves the original sort order of\n * equal elements. The iteratees are invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {...(Function|Function[])} [iteratees=[_.identity]]\n * The iteratees to sort by.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 30 },\n * { 'user': 'barney', 'age': 34 }\n * ];\n *\n * _.sortBy(users, [function(o) { return o.user; }]);\n * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]\n *\n * _.sortBy(users, ['user', 'age']);\n * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]\n */\n var sortBy = baseRest(function(collection, iteratees) {\n if (collection == null) {\n return [];\n }\n var length = iteratees.length;\n if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {\n iteratees = [];\n } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {\n iteratees = [iteratees[0]];\n }\n return baseOrderBy(collection, baseFlatten(iteratees, 1), []);\n });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\n var now = ctxNow || function() {\n return root.Date.now();\n };\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The opposite of `_.before`; this method creates a function that invokes\n * `func` once it's called `n` or more times.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {number} n The number of calls before `func` is invoked.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var saves = ['profile', 'settings'];\n *\n * var done = _.after(saves.length, function() {\n * console.log('done saving!');\n * });\n *\n * _.forEach(saves, function(type) {\n * asyncSave({ 'type': type, 'complete': done });\n * });\n * // => Logs 'done saving!' after the two async saves have completed.\n */\n function after(n, func) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n n = toInteger(n);\n return function() {\n if (--n < 1) {\n return func.apply(this, arguments);\n }\n };\n }\n\n /**\n * Creates a function that invokes `func`, with up to `n` arguments,\n * ignoring any additional arguments.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} func The function to cap arguments for.\n * @param {number} [n=func.length] The arity cap.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the new capped function.\n * @example\n *\n * _.map(['6', '8', '10'], _.ary(parseInt, 1));\n * // => [6, 8, 10]\n */\n function ary(func, n, guard) {\n n = guard ? undefined : n;\n n = (func && n == null) ? func.length : n;\n return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);\n }\n\n /**\n * Creates a function that invokes `func`, with the `this` binding and arguments\n * of the created function, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {number} n The number of calls at which `func` is no longer invoked.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * jQuery(element).on('click', _.before(5, addContactToList));\n * // => Allows adding up to 4 contacts to the list.\n */\n function before(n, func) {\n var result;\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n n = toInteger(n);\n return function() {\n if (--n > 0) {\n result = func.apply(this, arguments);\n }\n if (n <= 1) {\n func = undefined;\n }\n return result;\n };\n }\n\n /**\n * Creates a function that invokes `func` with the `this` binding of `thisArg`\n * and `partials` prepended to the arguments it receives.\n *\n * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for partially applied arguments.\n *\n * **Note:** Unlike native `Function#bind`, this method doesn't set the \"length\"\n * property of bound functions.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to bind.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * function greet(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n *\n * var object = { 'user': 'fred' };\n *\n * var bound = _.bind(greet, object, 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * // Bound with placeholders.\n * var bound = _.bind(greet, object, _, '!');\n * bound('hi');\n * // => 'hi fred!'\n */\n var bind = baseRest(function(func, thisArg, partials) {\n var bitmask = WRAP_BIND_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, getHolder(bind));\n bitmask |= WRAP_PARTIAL_FLAG;\n }\n return createWrap(func, bitmask, thisArg, partials, holders);\n });\n\n /**\n * Creates a function that invokes the method at `object[key]` with `partials`\n * prepended to the arguments it receives.\n *\n * This method differs from `_.bind` by allowing bound functions to reference\n * methods that may be redefined or don't yet exist. See\n * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)\n * for more details.\n *\n * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * @static\n * @memberOf _\n * @since 0.10.0\n * @category Function\n * @param {Object} object The object to invoke the method on.\n * @param {string} key The key of the method.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * var object = {\n * 'user': 'fred',\n * 'greet': function(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n * };\n *\n * var bound = _.bindKey(object, 'greet', 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * object.greet = function(greeting, punctuation) {\n * return greeting + 'ya ' + this.user + punctuation;\n * };\n *\n * bound('!');\n * // => 'hiya fred!'\n *\n * // Bound with placeholders.\n * var bound = _.bindKey(object, 'greet', _, '!');\n * bound('hi');\n * // => 'hiya fred!'\n */\n var bindKey = baseRest(function(object, key, partials) {\n var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, getHolder(bindKey));\n bitmask |= WRAP_PARTIAL_FLAG;\n }\n return createWrap(key, bitmask, object, partials, holders);\n });\n\n /**\n * Creates a function that accepts arguments of `func` and either invokes\n * `func` returning its result, if at least `arity` number of arguments have\n * been provided, or returns a function that accepts the remaining `func`\n * arguments, and so on. The arity of `func` may be specified if `func.length`\n * is not sufficient.\n *\n * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for provided arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of curried functions.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Function\n * @param {Function} func The function to curry.\n * @param {number} [arity=func.length] The arity of `func`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the new curried function.\n * @example\n *\n * var abc = function(a, b, c) {\n * return [a, b, c];\n * };\n *\n * var curried = _.curry(abc);\n *\n * curried(1)(2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // Curried with placeholders.\n * curried(1)(_, 3)(2);\n * // => [1, 2, 3]\n */\n function curry(func, arity, guard) {\n arity = guard ? undefined : arity;\n var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);\n result.placeholder = curry.placeholder;\n return result;\n }\n\n /**\n * This method is like `_.curry` except that arguments are applied to `func`\n * in the manner of `_.partialRight` instead of `_.partial`.\n *\n * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for provided arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of curried functions.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} func The function to curry.\n * @param {number} [arity=func.length] The arity of `func`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the new curried function.\n * @example\n *\n * var abc = function(a, b, c) {\n * return [a, b, c];\n * };\n *\n * var curried = _.curryRight(abc);\n *\n * curried(3)(2)(1);\n * // => [1, 2, 3]\n *\n * curried(2, 3)(1);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // Curried with placeholders.\n * curried(3)(1, _)(2);\n * // => [1, 2, 3]\n */\n function curryRight(func, arity, guard) {\n arity = guard ? undefined : arity;\n var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);\n result.placeholder = curryRight.placeholder;\n return result;\n }\n\n /**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\n function debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n }\n\n /**\n * Defers invoking the `func` until the current call stack has cleared. Any\n * additional arguments are provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to defer.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {number} Returns the timer id.\n * @example\n *\n * _.defer(function(text) {\n * console.log(text);\n * }, 'deferred');\n * // => Logs 'deferred' after one millisecond.\n */\n var defer = baseRest(function(func, args) {\n return baseDelay(func, 1, args);\n });\n\n /**\n * Invokes `func` after `wait` milliseconds. Any additional arguments are\n * provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {number} Returns the timer id.\n * @example\n *\n * _.delay(function(text) {\n * console.log(text);\n * }, 1000, 'later');\n * // => Logs 'later' after one second.\n */\n var delay = baseRest(function(func, wait, args) {\n return baseDelay(func, toNumber(wait) || 0, args);\n });\n\n /**\n * Creates a function that invokes `func` with arguments reversed.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Function\n * @param {Function} func The function to flip arguments for.\n * @returns {Function} Returns the new flipped function.\n * @example\n *\n * var flipped = _.flip(function() {\n * return _.toArray(arguments);\n * });\n *\n * flipped('a', 'b', 'c', 'd');\n * // => ['d', 'c', 'b', 'a']\n */\n function flip(func) {\n return createWrap(func, WRAP_FLIP_FLAG);\n }\n\n /**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\n function memoize(func, resolver) {\n if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result) || cache;\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n }\n\n // Expose `MapCache`.\n memoize.Cache = MapCache;\n\n /**\n * Creates a function that negates the result of the predicate `func`. The\n * `func` predicate is invoked with the `this` binding and arguments of the\n * created function.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} predicate The predicate to negate.\n * @returns {Function} Returns the new negated function.\n * @example\n *\n * function isEven(n) {\n * return n % 2 == 0;\n * }\n *\n * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));\n * // => [1, 3, 5]\n */\n function negate(predicate) {\n if (typeof predicate != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return function() {\n var args = arguments;\n switch (args.length) {\n case 0: return !predicate.call(this);\n case 1: return !predicate.call(this, args[0]);\n case 2: return !predicate.call(this, args[0], args[1]);\n case 3: return !predicate.call(this, args[0], args[1], args[2]);\n }\n return !predicate.apply(this, args);\n };\n }\n\n /**\n * Creates a function that is restricted to invoking `func` once. Repeat calls\n * to the function return the value of the first invocation. The `func` is\n * invoked with the `this` binding and arguments of the created function.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var initialize = _.once(createApplication);\n * initialize();\n * initialize();\n * // => `createApplication` is invoked once\n */\n function once(func) {\n return before(2, func);\n }\n\n /**\n * Creates a function that invokes `func` with its arguments transformed.\n *\n * @static\n * @since 4.0.0\n * @memberOf _\n * @category Function\n * @param {Function} func The function to wrap.\n * @param {...(Function|Function[])} [transforms=[_.identity]]\n * The argument transforms.\n * @returns {Function} Returns the new function.\n * @example\n *\n * function doubled(n) {\n * return n * 2;\n * }\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var func = _.overArgs(function(x, y) {\n * return [x, y];\n * }, [square, doubled]);\n *\n * func(9, 3);\n * // => [81, 6]\n *\n * func(10, 5);\n * // => [100, 10]\n */\n var overArgs = castRest(function(func, transforms) {\n transforms = (transforms.length == 1 && isArray(transforms[0]))\n ? arrayMap(transforms[0], baseUnary(getIteratee()))\n : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));\n\n var funcsLength = transforms.length;\n return baseRest(function(args) {\n var index = -1,\n length = nativeMin(args.length, funcsLength);\n\n while (++index < length) {\n args[index] = transforms[index].call(this, args[index]);\n }\n return apply(func, this, args);\n });\n });\n\n /**\n * Creates a function that invokes `func` with `partials` prepended to the\n * arguments it receives. This method is like `_.bind` except it does **not**\n * alter the `this` binding.\n *\n * The `_.partial.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @since 0.2.0\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * var sayHelloTo = _.partial(greet, 'hello');\n * sayHelloTo('fred');\n * // => 'hello fred'\n *\n * // Partially applied with placeholders.\n * var greetFred = _.partial(greet, _, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n */\n var partial = baseRest(function(func, partials) {\n var holders = replaceHolders(partials, getHolder(partial));\n return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);\n });\n\n /**\n * This method is like `_.partial` except that partially applied arguments\n * are appended to the arguments it receives.\n *\n * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * var greetFred = _.partialRight(greet, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n *\n * // Partially applied with placeholders.\n * var sayHelloTo = _.partialRight(greet, 'hello', _);\n * sayHelloTo('fred');\n * // => 'hello fred'\n */\n var partialRight = baseRest(function(func, partials) {\n var holders = replaceHolders(partials, getHolder(partialRight));\n return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);\n });\n\n /**\n * Creates a function that invokes `func` with arguments arranged according\n * to the specified `indexes` where the argument value at the first index is\n * provided as the first argument, the argument value at the second index is\n * provided as the second argument, and so on.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Function\n * @param {Function} func The function to rearrange arguments for.\n * @param {...(number|number[])} indexes The arranged argument indexes.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var rearged = _.rearg(function(a, b, c) {\n * return [a, b, c];\n * }, [2, 0, 1]);\n *\n * rearged('b', 'c', 'a')\n * // => ['a', 'b', 'c']\n */\n var rearg = flatRest(function(func, indexes) {\n return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);\n });\n\n /**\n * Creates a function that invokes `func` with the `this` binding of the\n * created function and arguments from `start` and beyond provided as\n * an array.\n *\n * **Note:** This method is based on the\n * [rest parameter](https://mdn.io/rest_parameters).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Function\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var say = _.rest(function(what, names) {\n * return what + ' ' + _.initial(names).join(', ') +\n * (_.size(names) > 1 ? ', & ' : '') + _.last(names);\n * });\n *\n * say('hello', 'fred', 'barney', 'pebbles');\n * // => 'hello fred, barney, & pebbles'\n */\n function rest(func, start) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n start = start === undefined ? start : toInteger(start);\n return baseRest(func, start);\n }\n\n /**\n * Creates a function that invokes `func` with the `this` binding of the\n * create function and an array of arguments much like\n * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).\n *\n * **Note:** This method is based on the\n * [spread operator](https://mdn.io/spread_operator).\n *\n * @static\n * @memberOf _\n * @since 3.2.0\n * @category Function\n * @param {Function} func The function to spread arguments over.\n * @param {number} [start=0] The start position of the spread.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var say = _.spread(function(who, what) {\n * return who + ' says ' + what;\n * });\n *\n * say(['fred', 'hello']);\n * // => 'fred says hello'\n *\n * var numbers = Promise.all([\n * Promise.resolve(40),\n * Promise.resolve(36)\n * ]);\n *\n * numbers.then(_.spread(function(x, y) {\n * return x + y;\n * }));\n * // => a Promise of 76\n */\n function spread(func, start) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n start = start == null ? 0 : nativeMax(toInteger(start), 0);\n return baseRest(function(args) {\n var array = args[start],\n otherArgs = castSlice(args, 0, start);\n\n if (array) {\n arrayPush(otherArgs, array);\n }\n return apply(func, this, otherArgs);\n });\n }\n\n /**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\n function throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n }\n\n /**\n * Creates a function that accepts up to one argument, ignoring any\n * additional arguments.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Function\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n * @example\n *\n * _.map(['6', '8', '10'], _.unary(parseInt));\n * // => [6, 8, 10]\n */\n function unary(func) {\n return ary(func, 1);\n }\n\n /**\n * Creates a function that provides `value` to `wrapper` as its first\n * argument. Any additional arguments provided to the function are appended\n * to those provided to the `wrapper`. The wrapper is invoked with the `this`\n * binding of the created function.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {*} value The value to wrap.\n * @param {Function} [wrapper=identity] The wrapper function.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var p = _.wrap(_.escape, function(func, text) {\n * return '<p>' + func(text) + '</p>';\n * });\n *\n * p('fred, barney, & pebbles');\n * // => '<p>fred, barney, & pebbles</p>'\n */\n function wrap(value, wrapper) {\n return partial(castFunction(wrapper), value);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Casts `value` as an array if it's not one.\n *\n * @static\n * @memberOf _\n * @since 4.4.0\n * @category Lang\n * @param {*} value The value to inspect.\n * @returns {Array} Returns the cast array.\n * @example\n *\n * _.castArray(1);\n * // => [1]\n *\n * _.castArray({ 'a': 1 });\n * // => [{ 'a': 1 }]\n *\n * _.castArray('abc');\n * // => ['abc']\n *\n * _.castArray(null);\n * // => [null]\n *\n * _.castArray(undefined);\n * // => [undefined]\n *\n * _.castArray();\n * // => []\n *\n * var array = [1, 2, 3];\n * console.log(_.castArray(array) === array);\n * // => true\n */\n function castArray() {\n if (!arguments.length) {\n return [];\n }\n var value = arguments[0];\n return isArray(value) ? value : [value];\n }\n\n /**\n * Creates a shallow clone of `value`.\n *\n * **Note:** This method is loosely based on the\n * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)\n * and supports cloning arrays, array buffers, booleans, date objects, maps,\n * numbers, `Object` objects, regexes, sets, strings, symbols, and typed\n * arrays. The own enumerable properties of `arguments` objects are cloned\n * as plain objects. An empty object is returned for uncloneable values such\n * as error objects, functions, DOM nodes, and WeakMaps.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to clone.\n * @returns {*} Returns the cloned value.\n * @see _.cloneDeep\n * @example\n *\n * var objects = [{ 'a': 1 }, { 'b': 2 }];\n *\n * var shallow = _.clone(objects);\n * console.log(shallow[0] === objects[0]);\n * // => true\n */\n function clone(value) {\n return baseClone(value, CLONE_SYMBOLS_FLAG);\n }\n\n /**\n * This method is like `_.clone` except that it accepts `customizer` which\n * is invoked to produce the cloned value. If `customizer` returns `undefined`,\n * cloning is handled by the method instead. The `customizer` is invoked with\n * up to four arguments; (value [, index|key, object, stack]).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to clone.\n * @param {Function} [customizer] The function to customize cloning.\n * @returns {*} Returns the cloned value.\n * @see _.cloneDeepWith\n * @example\n *\n * function customizer(value) {\n * if (_.isElement(value)) {\n * return value.cloneNode(false);\n * }\n * }\n *\n * var el = _.cloneWith(document.body, customizer);\n *\n * console.log(el === document.body);\n * // => false\n * console.log(el.nodeName);\n * // => 'BODY'\n * console.log(el.childNodes.length);\n * // => 0\n */\n function cloneWith(value, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);\n }\n\n /**\n * This method is like `_.clone` except that it recursively clones `value`.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Lang\n * @param {*} value The value to recursively clone.\n * @returns {*} Returns the deep cloned value.\n * @see _.clone\n * @example\n *\n * var objects = [{ 'a': 1 }, { 'b': 2 }];\n *\n * var deep = _.cloneDeep(objects);\n * console.log(deep[0] === objects[0]);\n * // => false\n */\n function cloneDeep(value) {\n return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);\n }\n\n /**\n * This method is like `_.cloneWith` except that it recursively clones `value`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to recursively clone.\n * @param {Function} [customizer] The function to customize cloning.\n * @returns {*} Returns the deep cloned value.\n * @see _.cloneWith\n * @example\n *\n * function customizer(value) {\n * if (_.isElement(value)) {\n * return value.cloneNode(true);\n * }\n * }\n *\n * var el = _.cloneDeepWith(document.body, customizer);\n *\n * console.log(el === document.body);\n * // => false\n * console.log(el.nodeName);\n * // => 'BODY'\n * console.log(el.childNodes.length);\n * // => 20\n */\n function cloneDeepWith(value, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);\n }\n\n /**\n * Checks if `object` conforms to `source` by invoking the predicate\n * properties of `source` with the corresponding property values of `object`.\n *\n * **Note:** This method is equivalent to `_.conforms` when `source` is\n * partially applied.\n *\n * @static\n * @memberOf _\n * @since 4.14.0\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property predicates to conform to.\n * @returns {boolean} Returns `true` if `object` conforms, else `false`.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n *\n * _.conformsTo(object, { 'b': function(n) { return n > 1; } });\n * // => true\n *\n * _.conformsTo(object, { 'b': function(n) { return n > 2; } });\n * // => false\n */\n function conformsTo(object, source) {\n return source == null || baseConformsTo(object, source, keys(source));\n }\n\n /**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\n function eq(value, other) {\n return value === other || (value !== value && other !== other);\n }\n\n /**\n * Checks if `value` is greater than `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than `other`,\n * else `false`.\n * @see _.lt\n * @example\n *\n * _.gt(3, 1);\n * // => true\n *\n * _.gt(3, 3);\n * // => false\n *\n * _.gt(1, 3);\n * // => false\n */\n var gt = createRelationalOperation(baseGt);\n\n /**\n * Checks if `value` is greater than or equal to `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than or equal to\n * `other`, else `false`.\n * @see _.lte\n * @example\n *\n * _.gte(3, 1);\n * // => true\n *\n * _.gte(3, 3);\n * // => true\n *\n * _.gte(1, 3);\n * // => false\n */\n var gte = createRelationalOperation(function(value, other) {\n return value >= other;\n });\n\n /**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\n var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n };\n\n /**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\n var isArray = Array.isArray;\n\n /**\n * Checks if `value` is classified as an `ArrayBuffer` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.\n * @example\n *\n * _.isArrayBuffer(new ArrayBuffer(2));\n * // => true\n *\n * _.isArrayBuffer(new Array(2));\n * // => false\n */\n var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;\n\n /**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\n function isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n }\n\n /**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\n function isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n }\n\n /**\n * Checks if `value` is classified as a boolean primitive or object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.\n * @example\n *\n * _.isBoolean(false);\n * // => true\n *\n * _.isBoolean(null);\n * // => false\n */\n function isBoolean(value) {\n return value === true || value === false ||\n (isObjectLike(value) && baseGetTag(value) == boolTag);\n }\n\n /**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\n var isBuffer = nativeIsBuffer || stubFalse;\n\n /**\n * Checks if `value` is classified as a `Date` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n * @example\n *\n * _.isDate(new Date);\n * // => true\n *\n * _.isDate('Mon April 23 2012');\n * // => false\n */\n var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;\n\n /**\n * Checks if `value` is likely a DOM element.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.\n * @example\n *\n * _.isElement(document.body);\n * // => true\n *\n * _.isElement('<body>');\n * // => false\n */\n function isElement(value) {\n return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);\n }\n\n /**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * jQuery-like collections are considered empty if they have a `length` of `0`.\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is empty, else `false`.\n * @example\n *\n * _.isEmpty(null);\n * // => true\n *\n * _.isEmpty(true);\n * // => true\n *\n * _.isEmpty(1);\n * // => true\n *\n * _.isEmpty([1, 2, 3]);\n * // => false\n *\n * _.isEmpty({ 'a': 1 });\n * // => false\n */\n function isEmpty(value) {\n if (value == null) {\n return true;\n }\n if (isArrayLike(value) &&\n (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||\n isBuffer(value) || isTypedArray(value) || isArguments(value))) {\n return !value.length;\n }\n var tag = getTag(value);\n if (tag == mapTag || tag == setTag) {\n return !value.size;\n }\n if (isPrototype(value)) {\n return !baseKeys(value).length;\n }\n for (var key in value) {\n if (hasOwnProperty.call(value, key)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\n function isEqual(value, other) {\n return baseIsEqual(value, other);\n }\n\n /**\n * This method is like `_.isEqual` except that it accepts `customizer` which\n * is invoked to compare values. If `customizer` returns `undefined`, comparisons\n * are handled by the method instead. The `customizer` is invoked with up to\n * six arguments: (objValue, othValue [, index|key, object, other, stack]).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * function isGreeting(value) {\n * return /^h(?:i|ello)$/.test(value);\n * }\n *\n * function customizer(objValue, othValue) {\n * if (isGreeting(objValue) && isGreeting(othValue)) {\n * return true;\n * }\n * }\n *\n * var array = ['hello', 'goodbye'];\n * var other = ['hi', 'goodbye'];\n *\n * _.isEqualWith(array, other, customizer);\n * // => true\n */\n function isEqualWith(value, other, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n var result = customizer ? customizer(value, other) : undefined;\n return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;\n }\n\n /**\n * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,\n * `SyntaxError`, `TypeError`, or `URIError` object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an error object, else `false`.\n * @example\n *\n * _.isError(new Error);\n * // => true\n *\n * _.isError(Error);\n * // => false\n */\n function isError(value) {\n if (!isObjectLike(value)) {\n return false;\n }\n var tag = baseGetTag(value);\n return tag == errorTag || tag == domExcTag ||\n (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));\n }\n\n /**\n * Checks if `value` is a finite primitive number.\n *\n * **Note:** This method is based on\n * [`Number.isFinite`](https://mdn.io/Number/isFinite).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.\n * @example\n *\n * _.isFinite(3);\n * // => true\n *\n * _.isFinite(Number.MIN_VALUE);\n * // => true\n *\n * _.isFinite(Infinity);\n * // => false\n *\n * _.isFinite('3');\n * // => false\n */\n function isFinite(value) {\n return typeof value == 'number' && nativeIsFinite(value);\n }\n\n /**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\n function isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n }\n\n /**\n * Checks if `value` is an integer.\n *\n * **Note:** This method is based on\n * [`Number.isInteger`](https://mdn.io/Number/isInteger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an integer, else `false`.\n * @example\n *\n * _.isInteger(3);\n * // => true\n *\n * _.isInteger(Number.MIN_VALUE);\n * // => false\n *\n * _.isInteger(Infinity);\n * // => false\n *\n * _.isInteger('3');\n * // => false\n */\n function isInteger(value) {\n return typeof value == 'number' && value == toInteger(value);\n }\n\n /**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\n function isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n }\n\n /**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\n function isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n }\n\n /**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\n function isObjectLike(value) {\n return value != null && typeof value == 'object';\n }\n\n /**\n * Checks if `value` is classified as a `Map` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n * @example\n *\n * _.isMap(new Map);\n * // => true\n *\n * _.isMap(new WeakMap);\n * // => false\n */\n var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;\n\n /**\n * Performs a partial deep comparison between `object` and `source` to\n * determine if `object` contains equivalent property values.\n *\n * **Note:** This method is equivalent to `_.matches` when `source` is\n * partially applied.\n *\n * Partial comparisons will match empty array and empty object `source`\n * values against any array or object value, respectively. See `_.isEqual`\n * for a list of supported value comparisons.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n *\n * _.isMatch(object, { 'b': 2 });\n * // => true\n *\n * _.isMatch(object, { 'b': 1 });\n * // => false\n */\n function isMatch(object, source) {\n return object === source || baseIsMatch(object, source, getMatchData(source));\n }\n\n /**\n * This method is like `_.isMatch` except that it accepts `customizer` which\n * is invoked to compare values. If `customizer` returns `undefined`, comparisons\n * are handled by the method instead. The `customizer` is invoked with five\n * arguments: (objValue, srcValue, index|key, object, source).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n * @example\n *\n * function isGreeting(value) {\n * return /^h(?:i|ello)$/.test(value);\n * }\n *\n * function customizer(objValue, srcValue) {\n * if (isGreeting(objValue) && isGreeting(srcValue)) {\n * return true;\n * }\n * }\n *\n * var object = { 'greeting': 'hello' };\n * var source = { 'greeting': 'hi' };\n *\n * _.isMatchWith(object, source, customizer);\n * // => true\n */\n function isMatchWith(object, source, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return baseIsMatch(object, source, getMatchData(source), customizer);\n }\n\n /**\n * Checks if `value` is `NaN`.\n *\n * **Note:** This method is based on\n * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as\n * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for\n * `undefined` and other non-number values.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n * @example\n *\n * _.isNaN(NaN);\n * // => true\n *\n * _.isNaN(new Number(NaN));\n * // => true\n *\n * isNaN(undefined);\n * // => true\n *\n * _.isNaN(undefined);\n * // => false\n */\n function isNaN(value) {\n // An `NaN` primitive is the only value that is not equal to itself.\n // Perform the `toStringTag` check first to avoid errors with some\n // ActiveX objects in IE.\n return isNumber(value) && value != +value;\n }\n\n /**\n * Checks if `value` is a pristine native function.\n *\n * **Note:** This method can't reliably detect native functions in the presence\n * of the core-js package because core-js circumvents this kind of detection.\n * Despite multiple requests, the core-js maintainer has made it clear: any\n * attempt to fix the detection will be obstructed. As a result, we're left\n * with little choice but to throw an error. Unfortunately, this also affects\n * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),\n * which rely on core-js.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n * @example\n *\n * _.isNative(Array.prototype.push);\n * // => true\n *\n * _.isNative(_);\n * // => false\n */\n function isNative(value) {\n if (isMaskable(value)) {\n throw new Error(CORE_ERROR_TEXT);\n }\n return baseIsNative(value);\n }\n\n /**\n * Checks if `value` is `null`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `null`, else `false`.\n * @example\n *\n * _.isNull(null);\n * // => true\n *\n * _.isNull(void 0);\n * // => false\n */\n function isNull(value) {\n return value === null;\n }\n\n /**\n * Checks if `value` is `null` or `undefined`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is nullish, else `false`.\n * @example\n *\n * _.isNil(null);\n * // => true\n *\n * _.isNil(void 0);\n * // => true\n *\n * _.isNil(NaN);\n * // => false\n */\n function isNil(value) {\n return value == null;\n }\n\n /**\n * Checks if `value` is classified as a `Number` primitive or object.\n *\n * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are\n * classified as numbers, use the `_.isFinite` method.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a number, else `false`.\n * @example\n *\n * _.isNumber(3);\n * // => true\n *\n * _.isNumber(Number.MIN_VALUE);\n * // => true\n *\n * _.isNumber(Infinity);\n * // => true\n *\n * _.isNumber('3');\n * // => false\n */\n function isNumber(value) {\n return typeof value == 'number' ||\n (isObjectLike(value) && baseGetTag(value) == numberTag);\n }\n\n /**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\n function isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n }\n\n /**\n * Checks if `value` is classified as a `RegExp` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.\n * @example\n *\n * _.isRegExp(/abc/);\n * // => true\n *\n * _.isRegExp('/abc/');\n * // => false\n */\n var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;\n\n /**\n * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754\n * double precision number which isn't the result of a rounded unsafe integer.\n *\n * **Note:** This method is based on\n * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.\n * @example\n *\n * _.isSafeInteger(3);\n * // => true\n *\n * _.isSafeInteger(Number.MIN_VALUE);\n * // => false\n *\n * _.isSafeInteger(Infinity);\n * // => false\n *\n * _.isSafeInteger('3');\n * // => false\n */\n function isSafeInteger(value) {\n return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;\n }\n\n /**\n * Checks if `value` is classified as a `Set` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n * @example\n *\n * _.isSet(new Set);\n * // => true\n *\n * _.isSet(new WeakSet);\n * // => false\n */\n var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;\n\n /**\n * Checks if `value` is classified as a `String` primitive or object.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a string, else `false`.\n * @example\n *\n * _.isString('abc');\n * // => true\n *\n * _.isString(1);\n * // => false\n */\n function isString(value) {\n return typeof value == 'string' ||\n (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);\n }\n\n /**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\n function isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n }\n\n /**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\n var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\n /**\n * Checks if `value` is `undefined`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.\n * @example\n *\n * _.isUndefined(void 0);\n * // => true\n *\n * _.isUndefined(null);\n * // => false\n */\n function isUndefined(value) {\n return value === undefined;\n }\n\n /**\n * Checks if `value` is classified as a `WeakMap` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.\n * @example\n *\n * _.isWeakMap(new WeakMap);\n * // => true\n *\n * _.isWeakMap(new Map);\n * // => false\n */\n function isWeakMap(value) {\n return isObjectLike(value) && getTag(value) == weakMapTag;\n }\n\n /**\n * Checks if `value` is classified as a `WeakSet` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.\n * @example\n *\n * _.isWeakSet(new WeakSet);\n * // => true\n *\n * _.isWeakSet(new Set);\n * // => false\n */\n function isWeakSet(value) {\n return isObjectLike(value) && baseGetTag(value) == weakSetTag;\n }\n\n /**\n * Checks if `value` is less than `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than `other`,\n * else `false`.\n * @see _.gt\n * @example\n *\n * _.lt(1, 3);\n * // => true\n *\n * _.lt(3, 3);\n * // => false\n *\n * _.lt(3, 1);\n * // => false\n */\n var lt = createRelationalOperation(baseLt);\n\n /**\n * Checks if `value` is less than or equal to `other`.\n *\n * @static\n * @memberOf _\n * @since 3.9.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than or equal to\n * `other`, else `false`.\n * @see _.gte\n * @example\n *\n * _.lte(1, 3);\n * // => true\n *\n * _.lte(3, 3);\n * // => true\n *\n * _.lte(3, 1);\n * // => false\n */\n var lte = createRelationalOperation(function(value, other) {\n return value <= other;\n });\n\n /**\n * Converts `value` to an array.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Array} Returns the converted array.\n * @example\n *\n * _.toArray({ 'a': 1, 'b': 2 });\n * // => [1, 2]\n *\n * _.toArray('abc');\n * // => ['a', 'b', 'c']\n *\n * _.toArray(1);\n * // => []\n *\n * _.toArray(null);\n * // => []\n */\n function toArray(value) {\n if (!value) {\n return [];\n }\n if (isArrayLike(value)) {\n return isString(value) ? stringToArray(value) : copyArray(value);\n }\n if (symIterator && value[symIterator]) {\n return iteratorToArray(value[symIterator]());\n }\n var tag = getTag(value),\n func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);\n\n return func(value);\n }\n\n /**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\n function toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n }\n\n /**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\n function toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n }\n\n /**\n * Converts `value` to an integer suitable for use as the length of an\n * array-like object.\n *\n * **Note:** This method is based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toLength(3.2);\n * // => 3\n *\n * _.toLength(Number.MIN_VALUE);\n * // => 0\n *\n * _.toLength(Infinity);\n * // => 4294967295\n *\n * _.toLength('3.2');\n * // => 3\n */\n function toLength(value) {\n return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;\n }\n\n /**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\n function toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = baseTrim(value);\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n }\n\n /**\n * Converts `value` to a plain object flattening inherited enumerable string\n * keyed properties of `value` to own properties of the plain object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Object} Returns the converted plain object.\n * @example\n *\n * function Foo() {\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.assign({ 'a': 1 }, new Foo);\n * // => { 'a': 1, 'b': 2 }\n *\n * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));\n * // => { 'a': 1, 'b': 2, 'c': 3 }\n */\n function toPlainObject(value) {\n return copyObject(value, keysIn(value));\n }\n\n /**\n * Converts `value` to a safe integer. A safe integer can be compared and\n * represented correctly.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toSafeInteger(3.2);\n * // => 3\n *\n * _.toSafeInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toSafeInteger(Infinity);\n * // => 9007199254740991\n *\n * _.toSafeInteger('3.2');\n * // => 3\n */\n function toSafeInteger(value) {\n return value\n ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)\n : (value === 0 ? value : 0);\n }\n\n /**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\n function toString(value) {\n return value == null ? '' : baseToString(value);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Assigns own enumerable string keyed properties of source objects to the\n * destination object. Source objects are applied from left to right.\n * Subsequent sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object` and is loosely based on\n * [`Object.assign`](https://mdn.io/Object/assign).\n *\n * @static\n * @memberOf _\n * @since 0.10.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.assignIn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * function Bar() {\n * this.c = 3;\n * }\n *\n * Foo.prototype.b = 2;\n * Bar.prototype.d = 4;\n *\n * _.assign({ 'a': 0 }, new Foo, new Bar);\n * // => { 'a': 1, 'c': 3 }\n */\n var assign = createAssigner(function(object, source) {\n if (isPrototype(source) || isArrayLike(source)) {\n copyObject(source, keys(source), object);\n return;\n }\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n assignValue(object, key, source[key]);\n }\n }\n });\n\n /**\n * This method is like `_.assign` except that it iterates over own and\n * inherited source properties.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias extend\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.assign\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * function Bar() {\n * this.c = 3;\n * }\n *\n * Foo.prototype.b = 2;\n * Bar.prototype.d = 4;\n *\n * _.assignIn({ 'a': 0 }, new Foo, new Bar);\n * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }\n */\n var assignIn = createAssigner(function(object, source) {\n copyObject(source, keysIn(source), object);\n });\n\n /**\n * This method is like `_.assignIn` except that it accepts `customizer`\n * which is invoked to produce the assigned values. If `customizer` returns\n * `undefined`, assignment is handled by the method instead. The `customizer`\n * is invoked with five arguments: (objValue, srcValue, key, object, source).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias extendWith\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @see _.assignWith\n * @example\n *\n * function customizer(objValue, srcValue) {\n * return _.isUndefined(objValue) ? srcValue : objValue;\n * }\n *\n * var defaults = _.partialRight(_.assignInWith, customizer);\n *\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\n var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {\n copyObject(source, keysIn(source), object, customizer);\n });\n\n /**\n * This method is like `_.assign` except that it accepts `customizer`\n * which is invoked to produce the assigned values. If `customizer` returns\n * `undefined`, assignment is handled by the method instead. The `customizer`\n * is invoked with five arguments: (objValue, srcValue, key, object, source).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @see _.assignInWith\n * @example\n *\n * function customizer(objValue, srcValue) {\n * return _.isUndefined(objValue) ? srcValue : objValue;\n * }\n *\n * var defaults = _.partialRight(_.assignWith, customizer);\n *\n * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\n var assignWith = createAssigner(function(object, source, srcIndex, customizer) {\n copyObject(source, keys(source), object, customizer);\n });\n\n /**\n * Creates an array of values corresponding to `paths` of `object`.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Array} Returns the picked values.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };\n *\n * _.at(object, ['a[0].b.c', 'a[1]']);\n * // => [3, 4]\n */\n var at = flatRest(baseAt);\n\n /**\n * Creates an object that inherits from the `prototype` object. If a\n * `properties` object is given, its own enumerable string keyed properties\n * are assigned to the created object.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Object\n * @param {Object} prototype The object to inherit from.\n * @param {Object} [properties] The properties to assign to the object.\n * @returns {Object} Returns the new object.\n * @example\n *\n * function Shape() {\n * this.x = 0;\n * this.y = 0;\n * }\n *\n * function Circle() {\n * Shape.call(this);\n * }\n *\n * Circle.prototype = _.create(Shape.prototype, {\n * 'constructor': Circle\n * });\n *\n * var circle = new Circle;\n * circle instanceof Circle;\n * // => true\n *\n * circle instanceof Shape;\n * // => true\n */\n function create(prototype, properties) {\n var result = baseCreate(prototype);\n return properties == null ? result : baseAssign(result, properties);\n }\n\n /**\n * Assigns own and inherited enumerable string keyed properties of source\n * objects to the destination object for all destination properties that\n * resolve to `undefined`. Source objects are applied from left to right.\n * Once a property is set, additional values of the same property are ignored.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.defaultsDeep\n * @example\n *\n * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\n var defaults = baseRest(function(object, sources) {\n object = Object(object);\n\n var index = -1;\n var length = sources.length;\n var guard = length > 2 ? sources[2] : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n length = 1;\n }\n\n while (++index < length) {\n var source = sources[index];\n var props = keysIn(source);\n var propsIndex = -1;\n var propsLength = props.length;\n\n while (++propsIndex < propsLength) {\n var key = props[propsIndex];\n var value = object[key];\n\n if (value === undefined ||\n (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n object[key] = source[key];\n }\n }\n }\n\n return object;\n });\n\n /**\n * This method is like `_.defaults` except that it recursively assigns\n * default properties.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.defaults\n * @example\n *\n * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });\n * // => { 'a': { 'b': 2, 'c': 3 } }\n */\n var defaultsDeep = baseRest(function(args) {\n args.push(undefined, customDefaultsMerge);\n return apply(mergeWith, undefined, args);\n });\n\n /**\n * This method is like `_.find` except that it returns the key of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Object\n * @param {Object} object The object to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {string|undefined} Returns the key of the matched element,\n * else `undefined`.\n * @example\n *\n * var users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n *\n * _.findKey(users, function(o) { return o.age < 40; });\n * // => 'barney' (iteration order is not guaranteed)\n *\n * // The `_.matches` iteratee shorthand.\n * _.findKey(users, { 'age': 1, 'active': true });\n * // => 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findKey(users, ['active', false]);\n * // => 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.findKey(users, 'active');\n * // => 'barney'\n */\n function findKey(object, predicate) {\n return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);\n }\n\n /**\n * This method is like `_.findKey` except that it iterates over elements of\n * a collection in the opposite order.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Object\n * @param {Object} object The object to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {string|undefined} Returns the key of the matched element,\n * else `undefined`.\n * @example\n *\n * var users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n *\n * _.findLastKey(users, function(o) { return o.age < 40; });\n * // => returns 'pebbles' assuming `_.findKey` returns 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.findLastKey(users, { 'age': 36, 'active': true });\n * // => 'barney'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findLastKey(users, ['active', false]);\n * // => 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.findLastKey(users, 'active');\n * // => 'pebbles'\n */\n function findLastKey(object, predicate) {\n return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);\n }\n\n /**\n * Iterates over own and inherited enumerable string keyed properties of an\n * object and invokes `iteratee` for each property. The iteratee is invoked\n * with three arguments: (value, key, object). Iteratee functions may exit\n * iteration early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 0.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forInRight\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forIn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).\n */\n function forIn(object, iteratee) {\n return object == null\n ? object\n : baseFor(object, getIteratee(iteratee, 3), keysIn);\n }\n\n /**\n * This method is like `_.forIn` except that it iterates over properties of\n * `object` in the opposite order.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forIn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forInRight(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.\n */\n function forInRight(object, iteratee) {\n return object == null\n ? object\n : baseForRight(object, getIteratee(iteratee, 3), keysIn);\n }\n\n /**\n * Iterates over own enumerable string keyed properties of an object and\n * invokes `iteratee` for each property. The iteratee is invoked with three\n * arguments: (value, key, object). Iteratee functions may exit iteration\n * early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 0.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forOwnRight\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a' then 'b' (iteration order is not guaranteed).\n */\n function forOwn(object, iteratee) {\n return object && baseForOwn(object, getIteratee(iteratee, 3));\n }\n\n /**\n * This method is like `_.forOwn` except that it iterates over properties of\n * `object` in the opposite order.\n *\n * @static\n * @memberOf _\n * @since 2.0.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forOwn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwnRight(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.\n */\n function forOwnRight(object, iteratee) {\n return object && baseForOwnRight(object, getIteratee(iteratee, 3));\n }\n\n /**\n * Creates an array of function property names from own enumerable properties\n * of `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns the function names.\n * @see _.functionsIn\n * @example\n *\n * function Foo() {\n * this.a = _.constant('a');\n * this.b = _.constant('b');\n * }\n *\n * Foo.prototype.c = _.constant('c');\n *\n * _.functions(new Foo);\n * // => ['a', 'b']\n */\n function functions(object) {\n return object == null ? [] : baseFunctions(object, keys(object));\n }\n\n /**\n * Creates an array of function property names from own and inherited\n * enumerable properties of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns the function names.\n * @see _.functions\n * @example\n *\n * function Foo() {\n * this.a = _.constant('a');\n * this.b = _.constant('b');\n * }\n *\n * Foo.prototype.c = _.constant('c');\n *\n * _.functionsIn(new Foo);\n * // => ['a', 'b', 'c']\n */\n function functionsIn(object) {\n return object == null ? [] : baseFunctions(object, keysIn(object));\n }\n\n /**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\n function get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n }\n\n /**\n * Checks if `path` is a direct property of `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = { 'a': { 'b': 2 } };\n * var other = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.has(object, 'a');\n * // => true\n *\n * _.has(object, 'a.b');\n * // => true\n *\n * _.has(object, ['a', 'b']);\n * // => true\n *\n * _.has(other, 'a');\n * // => false\n */\n function has(object, path) {\n return object != null && hasPath(object, path, baseHas);\n }\n\n /**\n * Checks if `path` is a direct or inherited property of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.hasIn(object, 'a');\n * // => true\n *\n * _.hasIn(object, 'a.b');\n * // => true\n *\n * _.hasIn(object, ['a', 'b']);\n * // => true\n *\n * _.hasIn(object, 'b');\n * // => false\n */\n function hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n }\n\n /**\n * Creates an object composed of the inverted keys and values of `object`.\n * If `object` contains duplicate values, subsequent values overwrite\n * property assignments of previous values.\n *\n * @static\n * @memberOf _\n * @since 0.7.0\n * @category Object\n * @param {Object} object The object to invert.\n * @returns {Object} Returns the new inverted object.\n * @example\n *\n * var object = { 'a': 1, 'b': 2, 'c': 1 };\n *\n * _.invert(object);\n * // => { '1': 'c', '2': 'b' }\n */\n var invert = createInverter(function(result, value, key) {\n if (value != null &&\n typeof value.toString != 'function') {\n value = nativeObjectToString.call(value);\n }\n\n result[value] = key;\n }, constant(identity));\n\n /**\n * This method is like `_.invert` except that the inverted object is generated\n * from the results of running each element of `object` thru `iteratee`. The\n * corresponding inverted value of each inverted key is an array of keys\n * responsible for generating the inverted value. The iteratee is invoked\n * with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.1.0\n * @category Object\n * @param {Object} object The object to invert.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {Object} Returns the new inverted object.\n * @example\n *\n * var object = { 'a': 1, 'b': 2, 'c': 1 };\n *\n * _.invertBy(object);\n * // => { '1': ['a', 'c'], '2': ['b'] }\n *\n * _.invertBy(object, function(value) {\n * return 'group' + value;\n * });\n * // => { 'group1': ['a', 'c'], 'group2': ['b'] }\n */\n var invertBy = createInverter(function(result, value, key) {\n if (value != null &&\n typeof value.toString != 'function') {\n value = nativeObjectToString.call(value);\n }\n\n if (hasOwnProperty.call(result, value)) {\n result[value].push(key);\n } else {\n result[value] = [key];\n }\n }, getIteratee);\n\n /**\n * Invokes the method at `path` of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the method to invoke.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {*} Returns the result of the invoked method.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };\n *\n * _.invoke(object, 'a[0].b.c.slice', 1, 3);\n * // => [2, 3]\n */\n var invoke = baseRest(baseInvoke);\n\n /**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\n function keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n }\n\n /**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\n function keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n }\n\n /**\n * The opposite of `_.mapValues`; this method creates an object with the\n * same values as `object` and keys generated by running each own enumerable\n * string keyed property of `object` thru `iteratee`. The iteratee is invoked\n * with three arguments: (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapValues\n * @example\n *\n * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {\n * return key + value;\n * });\n * // => { 'a1': 1, 'b2': 2 }\n */\n function mapKeys(object, iteratee) {\n var result = {};\n iteratee = getIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, iteratee(value, key, object), value);\n });\n return result;\n }\n\n /**\n * Creates an object with the same keys as `object` and values generated\n * by running each own enumerable string keyed property of `object` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapKeys\n * @example\n *\n * var users = {\n * 'fred': { 'user': 'fred', 'age': 40 },\n * 'pebbles': { 'user': 'pebbles', 'age': 1 }\n * };\n *\n * _.mapValues(users, function(o) { return o.age; });\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n *\n * // The `_.property` iteratee shorthand.\n * _.mapValues(users, 'age');\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n */\n function mapValues(object, iteratee) {\n var result = {};\n iteratee = getIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, key, iteratee(value, key, object));\n });\n return result;\n }\n\n /**\n * This method is like `_.assign` except that it recursively merges own and\n * inherited enumerable string keyed properties of source objects into the\n * destination object. Source properties that resolve to `undefined` are\n * skipped if a destination value exists. Array and plain object properties\n * are merged recursively. Other objects and value types are overridden by\n * assignment. Source objects are applied from left to right. Subsequent\n * sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {\n * 'a': [{ 'b': 2 }, { 'd': 4 }]\n * };\n *\n * var other = {\n * 'a': [{ 'c': 3 }, { 'e': 5 }]\n * };\n *\n * _.merge(object, other);\n * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }\n */\n var merge = createAssigner(function(object, source, srcIndex) {\n baseMerge(object, source, srcIndex);\n });\n\n /**\n * This method is like `_.merge` except that it accepts `customizer` which\n * is invoked to produce the merged values of the destination and source\n * properties. If `customizer` returns `undefined`, merging is handled by the\n * method instead. The `customizer` is invoked with six arguments:\n * (objValue, srcValue, key, object, source, stack).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} sources The source objects.\n * @param {Function} customizer The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function customizer(objValue, srcValue) {\n * if (_.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * }\n *\n * var object = { 'a': [1], 'b': [2] };\n * var other = { 'a': [3], 'b': [4] };\n *\n * _.mergeWith(object, other, customizer);\n * // => { 'a': [1, 3], 'b': [2, 4] }\n */\n var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {\n baseMerge(object, source, srcIndex, customizer);\n });\n\n /**\n * The opposite of `_.pick`; this method creates an object composed of the\n * own and inherited enumerable property paths of `object` that are not omitted.\n *\n * **Note:** This method is considerably slower than `_.pick`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [paths] The property paths to omit.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.omit(object, ['a', 'c']);\n * // => { 'b': '2' }\n */\n var omit = flatRest(function(object, paths) {\n var result = {};\n if (object == null) {\n return result;\n }\n var isDeep = false;\n paths = arrayMap(paths, function(path) {\n path = castPath(path, object);\n isDeep || (isDeep = path.length > 1);\n return path;\n });\n copyObject(object, getAllKeysIn(object), result);\n if (isDeep) {\n result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);\n }\n var length = paths.length;\n while (length--) {\n baseUnset(result, paths[length]);\n }\n return result;\n });\n\n /**\n * The opposite of `_.pickBy`; this method creates an object composed of\n * the own and inherited enumerable string keyed properties of `object` that\n * `predicate` doesn't return truthy for. The predicate is invoked with two\n * arguments: (value, key).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The source object.\n * @param {Function} [predicate=_.identity] The function invoked per property.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.omitBy(object, _.isNumber);\n * // => { 'b': '2' }\n */\n function omitBy(object, predicate) {\n return pickBy(object, negate(getIteratee(predicate)));\n }\n\n /**\n * Creates an object composed of the picked `object` properties.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.pick(object, ['a', 'c']);\n * // => { 'a': 1, 'c': 3 }\n */\n var pick = flatRest(function(object, paths) {\n return object == null ? {} : basePick(object, paths);\n });\n\n /**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The source object.\n * @param {Function} [predicate=_.identity] The function invoked per property.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.pickBy(object, _.isNumber);\n * // => { 'a': 1, 'c': 3 }\n */\n function pickBy(object, predicate) {\n if (object == null) {\n return {};\n }\n var props = arrayMap(getAllKeysIn(object), function(prop) {\n return [prop];\n });\n predicate = getIteratee(predicate);\n return basePickBy(object, props, function(value, path) {\n return predicate(value, path[0]);\n });\n }\n\n /**\n * This method is like `_.get` except that if the resolved value is a\n * function it's invoked with the `this` binding of its parent object and\n * its result is returned.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to resolve.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };\n *\n * _.result(object, 'a[0].b.c1');\n * // => 3\n *\n * _.result(object, 'a[0].b.c2');\n * // => 4\n *\n * _.result(object, 'a[0].b.c3', 'default');\n * // => 'default'\n *\n * _.result(object, 'a[0].b.c3', _.constant('default'));\n * // => 'default'\n */\n function result(object, path, defaultValue) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length;\n\n // Ensure the loop is entered when path is empty.\n if (!length) {\n length = 1;\n object = undefined;\n }\n while (++index < length) {\n var value = object == null ? undefined : object[toKey(path[index])];\n if (value === undefined) {\n index = length;\n value = defaultValue;\n }\n object = isFunction(value) ? value.call(object) : value;\n }\n return object;\n }\n\n /**\n * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,\n * it's created. Arrays are created for missing index properties while objects\n * are created for all other missing properties. Use `_.setWith` to customize\n * `path` creation.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.set(object, 'a[0].b.c', 4);\n * console.log(object.a[0].b.c);\n * // => 4\n *\n * _.set(object, ['x', '0', 'y', 'z'], 5);\n * console.log(object.x[0].y.z);\n * // => 5\n */\n function set(object, path, value) {\n return object == null ? object : baseSet(object, path, value);\n }\n\n /**\n * This method is like `_.set` except that it accepts `customizer` which is\n * invoked to produce the objects of `path`. If `customizer` returns `undefined`\n * path creation is handled by the method instead. The `customizer` is invoked\n * with three arguments: (nsValue, key, nsObject).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {};\n *\n * _.setWith(object, '[0][1]', 'a', Object);\n * // => { '0': { '1': 'a' } }\n */\n function setWith(object, path, value, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return object == null ? object : baseSet(object, path, value, customizer);\n }\n\n /**\n * Creates an array of own enumerable string keyed-value pairs for `object`\n * which can be consumed by `_.fromPairs`. If `object` is a map or set, its\n * entries are returned.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias entries\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the key-value pairs.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.toPairs(new Foo);\n * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)\n */\n var toPairs = createToPairs(keys);\n\n /**\n * Creates an array of own and inherited enumerable string keyed-value pairs\n * for `object` which can be consumed by `_.fromPairs`. If `object` is a map\n * or set, its entries are returned.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @alias entriesIn\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the key-value pairs.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.toPairsIn(new Foo);\n * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)\n */\n var toPairsIn = createToPairs(keysIn);\n\n /**\n * An alternative to `_.reduce`; this method transforms `object` to a new\n * `accumulator` object which is the result of running each of its own\n * enumerable string keyed properties thru `iteratee`, with each invocation\n * potentially mutating the `accumulator` object. If `accumulator` is not\n * provided, a new object with the same `[[Prototype]]` will be used. The\n * iteratee is invoked with four arguments: (accumulator, value, key, object).\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 1.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The custom accumulator value.\n * @returns {*} Returns the accumulated value.\n * @example\n *\n * _.transform([2, 3, 4], function(result, n) {\n * result.push(n *= n);\n * return n % 2 == 0;\n * }, []);\n * // => [4, 9]\n *\n * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {\n * (result[value] || (result[value] = [])).push(key);\n * }, {});\n * // => { '1': ['a', 'c'], '2': ['b'] }\n */\n function transform(object, iteratee, accumulator) {\n var isArr = isArray(object),\n isArrLike = isArr || isBuffer(object) || isTypedArray(object);\n\n iteratee = getIteratee(iteratee, 4);\n if (accumulator == null) {\n var Ctor = object && object.constructor;\n if (isArrLike) {\n accumulator = isArr ? new Ctor : [];\n }\n else if (isObject(object)) {\n accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};\n }\n else {\n accumulator = {};\n }\n }\n (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {\n return iteratee(accumulator, value, index, object);\n });\n return accumulator;\n }\n\n /**\n * Removes the property at `path` of `object`.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to unset.\n * @returns {boolean} Returns `true` if the property is deleted, else `false`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 7 } }] };\n * _.unset(object, 'a[0].b.c');\n * // => true\n *\n * console.log(object);\n * // => { 'a': [{ 'b': {} }] };\n *\n * _.unset(object, ['a', '0', 'b', 'c']);\n * // => true\n *\n * console.log(object);\n * // => { 'a': [{ 'b': {} }] };\n */\n function unset(object, path) {\n return object == null ? true : baseUnset(object, path);\n }\n\n /**\n * This method is like `_.set` except that accepts `updater` to produce the\n * value to set. Use `_.updateWith` to customize `path` creation. The `updater`\n * is invoked with one argument: (value).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.6.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {Function} updater The function to produce the updated value.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.update(object, 'a[0].b.c', function(n) { return n * n; });\n * console.log(object.a[0].b.c);\n * // => 9\n *\n * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });\n * console.log(object.x[0].y.z);\n * // => 0\n */\n function update(object, path, updater) {\n return object == null ? object : baseUpdate(object, path, castFunction(updater));\n }\n\n /**\n * This method is like `_.update` except that it accepts `customizer` which is\n * invoked to produce the objects of `path`. If `customizer` returns `undefined`\n * path creation is handled by the method instead. The `customizer` is invoked\n * with three arguments: (nsValue, key, nsObject).\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 4.6.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {Function} updater The function to produce the updated value.\n * @param {Function} [customizer] The function to customize assigned values.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {};\n *\n * _.updateWith(object, '[0][1]', _.constant('a'), Object);\n * // => { '0': { '1': 'a' } }\n */\n function updateWith(object, path, updater, customizer) {\n customizer = typeof customizer == 'function' ? customizer : undefined;\n return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);\n }\n\n /**\n * Creates an array of the own enumerable string keyed property values of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.values(new Foo);\n * // => [1, 2] (iteration order is not guaranteed)\n *\n * _.values('hi');\n * // => ['h', 'i']\n */\n function values(object) {\n return object == null ? [] : baseValues(object, keys(object));\n }\n\n /**\n * Creates an array of the own and inherited enumerable string keyed property\n * values of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.valuesIn(new Foo);\n * // => [1, 2, 3] (iteration order is not guaranteed)\n */\n function valuesIn(object) {\n return object == null ? [] : baseValues(object, keysIn(object));\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Clamps `number` within the inclusive `lower` and `upper` bounds.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Number\n * @param {number} number The number to clamp.\n * @param {number} [lower] The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the clamped number.\n * @example\n *\n * _.clamp(-10, -5, 5);\n * // => -5\n *\n * _.clamp(10, -5, 5);\n * // => 5\n */\n function clamp(number, lower, upper) {\n if (upper === undefined) {\n upper = lower;\n lower = undefined;\n }\n if (upper !== undefined) {\n upper = toNumber(upper);\n upper = upper === upper ? upper : 0;\n }\n if (lower !== undefined) {\n lower = toNumber(lower);\n lower = lower === lower ? lower : 0;\n }\n return baseClamp(toNumber(number), lower, upper);\n }\n\n /**\n * Checks if `n` is between `start` and up to, but not including, `end`. If\n * `end` is not specified, it's set to `start` with `start` then set to `0`.\n * If `start` is greater than `end` the params are swapped to support\n * negative ranges.\n *\n * @static\n * @memberOf _\n * @since 3.3.0\n * @category Number\n * @param {number} number The number to check.\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n * @see _.range, _.rangeRight\n * @example\n *\n * _.inRange(3, 2, 4);\n * // => true\n *\n * _.inRange(4, 8);\n * // => true\n *\n * _.inRange(4, 2);\n * // => false\n *\n * _.inRange(2, 2);\n * // => false\n *\n * _.inRange(1.2, 2);\n * // => true\n *\n * _.inRange(5.2, 4);\n * // => false\n *\n * _.inRange(-3, -2, -6);\n * // => true\n */\n function inRange(number, start, end) {\n start = toFinite(start);\n if (end === undefined) {\n end = start;\n start = 0;\n } else {\n end = toFinite(end);\n }\n number = toNumber(number);\n return baseInRange(number, start, end);\n }\n\n /**\n * Produces a random number between the inclusive `lower` and `upper` bounds.\n * If only one argument is provided a number between `0` and the given number\n * is returned. If `floating` is `true`, or either `lower` or `upper` are\n * floats, a floating-point number is returned instead of an integer.\n *\n * **Note:** JavaScript follows the IEEE-754 standard for resolving\n * floating-point values which can produce unexpected results.\n *\n * @static\n * @memberOf _\n * @since 0.7.0\n * @category Number\n * @param {number} [lower=0] The lower bound.\n * @param {number} [upper=1] The upper bound.\n * @param {boolean} [floating] Specify returning a floating-point number.\n * @returns {number} Returns the random number.\n * @example\n *\n * _.random(0, 5);\n * // => an integer between 0 and 5\n *\n * _.random(5);\n * // => also an integer between 0 and 5\n *\n * _.random(5, true);\n * // => a floating-point number between 0 and 5\n *\n * _.random(1.2, 5.2);\n * // => a floating-point number between 1.2 and 5.2\n */\n function random(lower, upper, floating) {\n if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {\n upper = floating = undefined;\n }\n if (floating === undefined) {\n if (typeof upper == 'boolean') {\n floating = upper;\n upper = undefined;\n }\n else if (typeof lower == 'boolean') {\n floating = lower;\n lower = undefined;\n }\n }\n if (lower === undefined && upper === undefined) {\n lower = 0;\n upper = 1;\n }\n else {\n lower = toFinite(lower);\n if (upper === undefined) {\n upper = lower;\n lower = 0;\n } else {\n upper = toFinite(upper);\n }\n }\n if (lower > upper) {\n var temp = lower;\n lower = upper;\n upper = temp;\n }\n if (floating || lower % 1 || upper % 1) {\n var rand = nativeRandom();\n return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);\n }\n return baseRandom(lower, upper);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the camel cased string.\n * @example\n *\n * _.camelCase('Foo Bar');\n * // => 'fooBar'\n *\n * _.camelCase('--foo-bar--');\n * // => 'fooBar'\n *\n * _.camelCase('__FOO_BAR__');\n * // => 'fooBar'\n */\n var camelCase = createCompounder(function(result, word, index) {\n word = word.toLowerCase();\n return result + (index ? capitalize(word) : word);\n });\n\n /**\n * Converts the first character of `string` to upper case and the remaining\n * to lower case.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to capitalize.\n * @returns {string} Returns the capitalized string.\n * @example\n *\n * _.capitalize('FRED');\n * // => 'Fred'\n */\n function capitalize(string) {\n return upperFirst(toString(string).toLowerCase());\n }\n\n /**\n * Deburrs `string` by converting\n * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)\n * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)\n * letters to basic Latin letters and removing\n * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to deburr.\n * @returns {string} Returns the deburred string.\n * @example\n *\n * _.deburr('déjà vu');\n * // => 'deja vu'\n */\n function deburr(string) {\n string = toString(string);\n return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');\n }\n\n /**\n * Checks if `string` ends with the given target string.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {string} [target] The string to search for.\n * @param {number} [position=string.length] The position to search up to.\n * @returns {boolean} Returns `true` if `string` ends with `target`,\n * else `false`.\n * @example\n *\n * _.endsWith('abc', 'c');\n * // => true\n *\n * _.endsWith('abc', 'b');\n * // => false\n *\n * _.endsWith('abc', 'b', 2);\n * // => true\n */\n function endsWith(string, target, position) {\n string = toString(string);\n target = baseToString(target);\n\n var length = string.length;\n position = position === undefined\n ? length\n : baseClamp(toInteger(position), 0, length);\n\n var end = position;\n position -= target.length;\n return position >= 0 && string.slice(position, end) == target;\n }\n\n /**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `string` to their\n * corresponding HTML entities.\n *\n * **Note:** No other characters are escaped. To escape additional\n * characters use a third-party library like [_he_](https://mths.be/he).\n *\n * Though the \">\" character is escaped for symmetry, characters like\n * \">\" and \"/\" don't need escaping in HTML and have no special meaning\n * unless they're part of a tag or unquoted attribute value. See\n * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)\n * (under \"semi-related fun fact\") for more details.\n *\n * When working with HTML you should always\n * [quote attribute values](http://wonko.com/post/html-escaping) to reduce\n * XSS vectors.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escape('fred, barney, & pebbles');\n * // => 'fred, barney, & pebbles'\n */\n function escape(string) {\n string = toString(string);\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, escapeHtmlChar)\n : string;\n }\n\n /**\n * Escapes the `RegExp` special characters \"^\", \"$\", \"\\\", \".\", \"*\", \"+\",\n * \"?\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", and \"|\" in `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escapeRegExp('[lodash](https://lodash.com/)');\n * // => '\\[lodash\\]\\(https://lodash\\.com/\\)'\n */\n function escapeRegExp(string) {\n string = toString(string);\n return (string && reHasRegExpChar.test(string))\n ? string.replace(reRegExpChar, '\\\\$&')\n : string;\n }\n\n /**\n * Converts `string` to\n * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the kebab cased string.\n * @example\n *\n * _.kebabCase('Foo Bar');\n * // => 'foo-bar'\n *\n * _.kebabCase('fooBar');\n * // => 'foo-bar'\n *\n * _.kebabCase('__FOO_BAR__');\n * // => 'foo-bar'\n */\n var kebabCase = createCompounder(function(result, word, index) {\n return result + (index ? '-' : '') + word.toLowerCase();\n });\n\n /**\n * Converts `string`, as space separated words, to lower case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the lower cased string.\n * @example\n *\n * _.lowerCase('--Foo-Bar--');\n * // => 'foo bar'\n *\n * _.lowerCase('fooBar');\n * // => 'foo bar'\n *\n * _.lowerCase('__FOO_BAR__');\n * // => 'foo bar'\n */\n var lowerCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + word.toLowerCase();\n });\n\n /**\n * Converts the first character of `string` to lower case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.lowerFirst('Fred');\n * // => 'fred'\n *\n * _.lowerFirst('FRED');\n * // => 'fRED'\n */\n var lowerFirst = createCaseFirst('toLowerCase');\n\n /**\n * Pads `string` on the left and right sides if it's shorter than `length`.\n * Padding characters are truncated if they can't be evenly divided by `length`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.pad('abc', 8);\n * // => ' abc '\n *\n * _.pad('abc', 8, '_-');\n * // => '_-abc_-_'\n *\n * _.pad('abc', 3);\n * // => 'abc'\n */\n function pad(string, length, chars) {\n string = toString(string);\n length = toInteger(length);\n\n var strLength = length ? stringSize(string) : 0;\n if (!length || strLength >= length) {\n return string;\n }\n var mid = (length - strLength) / 2;\n return (\n createPadding(nativeFloor(mid), chars) +\n string +\n createPadding(nativeCeil(mid), chars)\n );\n }\n\n /**\n * Pads `string` on the right side if it's shorter than `length`. Padding\n * characters are truncated if they exceed `length`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.padEnd('abc', 6);\n * // => 'abc '\n *\n * _.padEnd('abc', 6, '_-');\n * // => 'abc_-_'\n *\n * _.padEnd('abc', 3);\n * // => 'abc'\n */\n function padEnd(string, length, chars) {\n string = toString(string);\n length = toInteger(length);\n\n var strLength = length ? stringSize(string) : 0;\n return (length && strLength < length)\n ? (string + createPadding(length - strLength, chars))\n : string;\n }\n\n /**\n * Pads `string` on the left side if it's shorter than `length`. Padding\n * characters are truncated if they exceed `length`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.padStart('abc', 6);\n * // => ' abc'\n *\n * _.padStart('abc', 6, '_-');\n * // => '_-_abc'\n *\n * _.padStart('abc', 3);\n * // => 'abc'\n */\n function padStart(string, length, chars) {\n string = toString(string);\n length = toInteger(length);\n\n var strLength = length ? stringSize(string) : 0;\n return (length && strLength < length)\n ? (createPadding(length - strLength, chars) + string)\n : string;\n }\n\n /**\n * Converts `string` to an integer of the specified radix. If `radix` is\n * `undefined` or `0`, a `radix` of `10` is used unless `value` is a\n * hexadecimal, in which case a `radix` of `16` is used.\n *\n * **Note:** This method aligns with the\n * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category String\n * @param {string} string The string to convert.\n * @param {number} [radix=10] The radix to interpret `value` by.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.parseInt('08');\n * // => 8\n *\n * _.map(['6', '08', '10'], _.parseInt);\n * // => [6, 8, 10]\n */\n function parseInt(string, radix, guard) {\n if (guard || radix == null) {\n radix = 0;\n } else if (radix) {\n radix = +radix;\n }\n return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);\n }\n\n /**\n * Repeats the given string `n` times.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to repeat.\n * @param {number} [n=1] The number of times to repeat the string.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the repeated string.\n * @example\n *\n * _.repeat('*', 3);\n * // => '***'\n *\n * _.repeat('abc', 2);\n * // => 'abcabc'\n *\n * _.repeat('abc', 0);\n * // => ''\n */\n function repeat(string, n, guard) {\n if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {\n n = 1;\n } else {\n n = toInteger(n);\n }\n return baseRepeat(toString(string), n);\n }\n\n /**\n * Replaces matches for `pattern` in `string` with `replacement`.\n *\n * **Note:** This method is based on\n * [`String#replace`](https://mdn.io/String/replace).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to modify.\n * @param {RegExp|string} pattern The pattern to replace.\n * @param {Function|string} replacement The match replacement.\n * @returns {string} Returns the modified string.\n * @example\n *\n * _.replace('Hi Fred', 'Fred', 'Barney');\n * // => 'Hi Barney'\n */\n function replace() {\n var args = arguments,\n string = toString(args[0]);\n\n return args.length < 3 ? string : string.replace(args[1], args[2]);\n }\n\n /**\n * Converts `string` to\n * [snake case](https://en.wikipedia.org/wiki/Snake_case).\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the snake cased string.\n * @example\n *\n * _.snakeCase('Foo Bar');\n * // => 'foo_bar'\n *\n * _.snakeCase('fooBar');\n * // => 'foo_bar'\n *\n * _.snakeCase('--FOO-BAR--');\n * // => 'foo_bar'\n */\n var snakeCase = createCompounder(function(result, word, index) {\n return result + (index ? '_' : '') + word.toLowerCase();\n });\n\n /**\n * Splits `string` by `separator`.\n *\n * **Note:** This method is based on\n * [`String#split`](https://mdn.io/String/split).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to split.\n * @param {RegExp|string} separator The separator pattern to split by.\n * @param {number} [limit] The length to truncate results to.\n * @returns {Array} Returns the string segments.\n * @example\n *\n * _.split('a-b-c', '-', 2);\n * // => ['a', 'b']\n */\n function split(string, separator, limit) {\n if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {\n separator = limit = undefined;\n }\n limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;\n if (!limit) {\n return [];\n }\n string = toString(string);\n if (string && (\n typeof separator == 'string' ||\n (separator != null && !isRegExp(separator))\n )) {\n separator = baseToString(separator);\n if (!separator && hasUnicode(string)) {\n return castSlice(stringToArray(string), 0, limit);\n }\n }\n return string.split(separator, limit);\n }\n\n /**\n * Converts `string` to\n * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).\n *\n * @static\n * @memberOf _\n * @since 3.1.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the start cased string.\n * @example\n *\n * _.startCase('--foo-bar--');\n * // => 'Foo Bar'\n *\n * _.startCase('fooBar');\n * // => 'Foo Bar'\n *\n * _.startCase('__FOO_BAR__');\n * // => 'FOO BAR'\n */\n var startCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + upperFirst(word);\n });\n\n /**\n * Checks if `string` starts with the given target string.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {string} [target] The string to search for.\n * @param {number} [position=0] The position to search from.\n * @returns {boolean} Returns `true` if `string` starts with `target`,\n * else `false`.\n * @example\n *\n * _.startsWith('abc', 'a');\n * // => true\n *\n * _.startsWith('abc', 'b');\n * // => false\n *\n * _.startsWith('abc', 'b', 1);\n * // => true\n */\n function startsWith(string, target, position) {\n string = toString(string);\n position = position == null\n ? 0\n : baseClamp(toInteger(position), 0, string.length);\n\n target = baseToString(target);\n return string.slice(position, position + target.length) == target;\n }\n\n /**\n * Creates a compiled template function that can interpolate data properties\n * in \"interpolate\" delimiters, HTML-escape interpolated data properties in\n * \"escape\" delimiters, and execute JavaScript in \"evaluate\" delimiters. Data\n * properties may be accessed as free variables in the template. If a setting\n * object is given, it takes precedence over `_.templateSettings` values.\n *\n * **Note:** In the development build `_.template` utilizes\n * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)\n * for easier debugging.\n *\n * For more information on precompiling templates see\n * [lodash's custom builds documentation](https://lodash.com/custom-builds).\n *\n * For more information on Chrome extension sandboxes see\n * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category String\n * @param {string} [string=''] The template string.\n * @param {Object} [options={}] The options object.\n * @param {RegExp} [options.escape=_.templateSettings.escape]\n * The HTML \"escape\" delimiter.\n * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]\n * The \"evaluate\" delimiter.\n * @param {Object} [options.imports=_.templateSettings.imports]\n * An object to import into the template as free variables.\n * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]\n * The \"interpolate\" delimiter.\n * @param {string} [options.sourceURL='lodash.templateSources[n]']\n * The sourceURL of the compiled template.\n * @param {string} [options.variable='obj']\n * The data object variable name.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Function} Returns the compiled template function.\n * @example\n *\n * // Use the \"interpolate\" delimiter to create a compiled template.\n * var compiled = _.template('hello <%= user %>!');\n * compiled({ 'user': 'fred' });\n * // => 'hello fred!'\n *\n * // Use the HTML \"escape\" delimiter to escape data property values.\n * var compiled = _.template('<b><%- value %></b>');\n * compiled({ 'value': '<script>' });\n * // => '<b><script></b>'\n *\n * // Use the \"evaluate\" delimiter to execute JavaScript and generate HTML.\n * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the internal `print` function in \"evaluate\" delimiters.\n * var compiled = _.template('<% print(\"hello \" + user); %>!');\n * compiled({ 'user': 'barney' });\n * // => 'hello barney!'\n *\n * // Use the ES template literal delimiter as an \"interpolate\" delimiter.\n * // Disable support by replacing the \"interpolate\" delimiter.\n * var compiled = _.template('hello ${ user }!');\n * compiled({ 'user': 'pebbles' });\n * // => 'hello pebbles!'\n *\n * // Use backslashes to treat delimiters as plain text.\n * var compiled = _.template('<%= \"\\\\<%- value %\\\\>\" %>');\n * compiled({ 'value': 'ignored' });\n * // => '<%- value %>'\n *\n * // Use the `imports` option to import `jQuery` as `jq`.\n * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';\n * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // Use the `sourceURL` option to specify a custom sourceURL for the template.\n * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });\n * compiled(data);\n * // => Find the source of \"greeting.jst\" under the Sources tab or Resources panel of the web inspector.\n *\n * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.\n * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });\n * compiled.source;\n * // => function(data) {\n * // var __t, __p = '';\n * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';\n * // return __p;\n * // }\n *\n * // Use custom template delimiters.\n * _.templateSettings.interpolate = /{{([\\s\\S]+?)}}/g;\n * var compiled = _.template('hello {{ user }}!');\n * compiled({ 'user': 'mustache' });\n * // => 'hello mustache!'\n *\n * // Use the `source` property to inline compiled templates for meaningful\n * // line numbers in error messages and stack traces.\n * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\\\n * var JST = {\\\n * \"main\": ' + _.template(mainText).source + '\\\n * };\\\n * ');\n */\n function template(string, options, guard) {\n // Based on John Resig's `tmpl` implementation\n // (http://ejohn.org/blog/javascript-micro-templating/)\n // and Laura Doktorova's doT.js (https://github.com/olado/doT).\n var settings = lodash.templateSettings;\n\n if (guard && isIterateeCall(string, options, guard)) {\n options = undefined;\n }\n string = toString(string);\n options = assignInWith({}, options, settings, customDefaultsAssignIn);\n\n var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),\n importsKeys = keys(imports),\n importsValues = baseValues(imports, importsKeys);\n\n var isEscaping,\n isEvaluating,\n index = 0,\n interpolate = options.interpolate || reNoMatch,\n source = \"__p += '\";\n\n // Compile the regexp to match each delimiter.\n var reDelimiters = RegExp(\n (options.escape || reNoMatch).source + '|' +\n interpolate.source + '|' +\n (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +\n (options.evaluate || reNoMatch).source + '|$'\n , 'g');\n\n // Use a sourceURL for easier debugging.\n // The sourceURL gets injected into the source that's eval-ed, so be careful\n // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in\n // and escape the comment, thus injecting code that gets evaled.\n var sourceURL = '//# sourceURL=' +\n (hasOwnProperty.call(options, 'sourceURL')\n ? (options.sourceURL + '').replace(/\\s/g, ' ')\n : ('lodash.templateSources[' + (++templateCounter) + ']')\n ) + '\\n';\n\n string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {\n interpolateValue || (interpolateValue = esTemplateValue);\n\n // Escape characters that can't be included in string literals.\n source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);\n\n // Replace delimiters with snippets.\n if (escapeValue) {\n isEscaping = true;\n source += \"' +\\n__e(\" + escapeValue + \") +\\n'\";\n }\n if (evaluateValue) {\n isEvaluating = true;\n source += \"';\\n\" + evaluateValue + \";\\n__p += '\";\n }\n if (interpolateValue) {\n source += \"' +\\n((__t = (\" + interpolateValue + \")) == null ? '' : __t) +\\n'\";\n }\n index = offset + match.length;\n\n // The JS engine embedded in Adobe products needs `match` returned in\n // order to produce the correct `offset` value.\n return match;\n });\n\n source += \"';\\n\";\n\n // If `variable` is not specified wrap a with-statement around the generated\n // code to add the data object to the top of the scope chain.\n var variable = hasOwnProperty.call(options, 'variable') && options.variable;\n if (!variable) {\n source = 'with (obj) {\\n' + source + '\\n}\\n';\n }\n // Throw an error if a forbidden character was found in `variable`, to prevent\n // potential command injection attacks.\n else if (reForbiddenIdentifierChars.test(variable)) {\n throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);\n }\n\n // Cleanup code by stripping empty strings.\n source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)\n .replace(reEmptyStringMiddle, '$1')\n .replace(reEmptyStringTrailing, '$1;');\n\n // Frame code as the function body.\n source = 'function(' + (variable || 'obj') + ') {\\n' +\n (variable\n ? ''\n : 'obj || (obj = {});\\n'\n ) +\n \"var __t, __p = ''\" +\n (isEscaping\n ? ', __e = _.escape'\n : ''\n ) +\n (isEvaluating\n ? ', __j = Array.prototype.join;\\n' +\n \"function print() { __p += __j.call(arguments, '') }\\n\"\n : ';\\n'\n ) +\n source +\n 'return __p\\n}';\n\n var result = attempt(function() {\n return Function(importsKeys, sourceURL + 'return ' + source)\n .apply(undefined, importsValues);\n });\n\n // Provide the compiled function's source by its `toString` method or\n // the `source` property as a convenience for inlining compiled templates.\n result.source = source;\n if (isError(result)) {\n throw result;\n }\n return result;\n }\n\n /**\n * Converts `string`, as a whole, to lower case just like\n * [String#toLowerCase](https://mdn.io/toLowerCase).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the lower cased string.\n * @example\n *\n * _.toLower('--Foo-Bar--');\n * // => '--foo-bar--'\n *\n * _.toLower('fooBar');\n * // => 'foobar'\n *\n * _.toLower('__FOO_BAR__');\n * // => '__foo_bar__'\n */\n function toLower(value) {\n return toString(value).toLowerCase();\n }\n\n /**\n * Converts `string`, as a whole, to upper case just like\n * [String#toUpperCase](https://mdn.io/toUpperCase).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the upper cased string.\n * @example\n *\n * _.toUpper('--foo-bar--');\n * // => '--FOO-BAR--'\n *\n * _.toUpper('fooBar');\n * // => 'FOOBAR'\n *\n * _.toUpper('__foo_bar__');\n * // => '__FOO_BAR__'\n */\n function toUpper(value) {\n return toString(value).toUpperCase();\n }\n\n /**\n * Removes leading and trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trim(' abc ');\n * // => 'abc'\n *\n * _.trim('-_-abc-_-', '_-');\n * // => 'abc'\n *\n * _.map([' foo ', ' bar '], _.trim);\n * // => ['foo', 'bar']\n */\n function trim(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return baseTrim(string);\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n chrSymbols = stringToArray(chars),\n start = charsStartIndex(strSymbols, chrSymbols),\n end = charsEndIndex(strSymbols, chrSymbols) + 1;\n\n return castSlice(strSymbols, start, end).join('');\n }\n\n /**\n * Removes trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trimEnd(' abc ');\n * // => ' abc'\n *\n * _.trimEnd('-_-abc-_-', '_-');\n * // => '-_-abc'\n */\n function trimEnd(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return string.slice(0, trimmedEndIndex(string) + 1);\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;\n\n return castSlice(strSymbols, 0, end).join('');\n }\n\n /**\n * Removes leading whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trimStart(' abc ');\n * // => 'abc '\n *\n * _.trimStart('-_-abc-_-', '_-');\n * // => 'abc-_-'\n */\n function trimStart(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return string.replace(reTrimStart, '');\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n start = charsStartIndex(strSymbols, stringToArray(chars));\n\n return castSlice(strSymbols, start).join('');\n }\n\n /**\n * Truncates `string` if it's longer than the given maximum string length.\n * The last characters of the truncated string are replaced with the omission\n * string which defaults to \"...\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to truncate.\n * @param {Object} [options={}] The options object.\n * @param {number} [options.length=30] The maximum string length.\n * @param {string} [options.omission='...'] The string to indicate text is omitted.\n * @param {RegExp|string} [options.separator] The separator pattern to truncate to.\n * @returns {string} Returns the truncated string.\n * @example\n *\n * _.truncate('hi-diddly-ho there, neighborino');\n * // => 'hi-diddly-ho there, neighbo...'\n *\n * _.truncate('hi-diddly-ho there, neighborino', {\n * 'length': 24,\n * 'separator': ' '\n * });\n * // => 'hi-diddly-ho there,...'\n *\n * _.truncate('hi-diddly-ho there, neighborino', {\n * 'length': 24,\n * 'separator': /,? +/\n * });\n * // => 'hi-diddly-ho there...'\n *\n * _.truncate('hi-diddly-ho there, neighborino', {\n * 'omission': ' [...]'\n * });\n * // => 'hi-diddly-ho there, neig [...]'\n */\n function truncate(string, options) {\n var length = DEFAULT_TRUNC_LENGTH,\n omission = DEFAULT_TRUNC_OMISSION;\n\n if (isObject(options)) {\n var separator = 'separator' in options ? options.separator : separator;\n length = 'length' in options ? toInteger(options.length) : length;\n omission = 'omission' in options ? baseToString(options.omission) : omission;\n }\n string = toString(string);\n\n var strLength = string.length;\n if (hasUnicode(string)) {\n var strSymbols = stringToArray(string);\n strLength = strSymbols.length;\n }\n if (length >= strLength) {\n return string;\n }\n var end = length - stringSize(omission);\n if (end < 1) {\n return omission;\n }\n var result = strSymbols\n ? castSlice(strSymbols, 0, end).join('')\n : string.slice(0, end);\n\n if (separator === undefined) {\n return result + omission;\n }\n if (strSymbols) {\n end += (result.length - end);\n }\n if (isRegExp(separator)) {\n if (string.slice(end).search(separator)) {\n var match,\n substring = result;\n\n if (!separator.global) {\n separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');\n }\n separator.lastIndex = 0;\n while ((match = separator.exec(substring))) {\n var newEnd = match.index;\n }\n result = result.slice(0, newEnd === undefined ? end : newEnd);\n }\n } else if (string.indexOf(baseToString(separator), end) != end) {\n var index = result.lastIndexOf(separator);\n if (index > -1) {\n result = result.slice(0, index);\n }\n }\n return result + omission;\n }\n\n /**\n * The inverse of `_.escape`; this method converts the HTML entities\n * `&`, `<`, `>`, `"`, and `'` in `string` to\n * their corresponding characters.\n *\n * **Note:** No other HTML entities are unescaped. To unescape additional\n * HTML entities use a third-party library like [_he_](https://mths.be/he).\n *\n * @static\n * @memberOf _\n * @since 0.6.0\n * @category String\n * @param {string} [string=''] The string to unescape.\n * @returns {string} Returns the unescaped string.\n * @example\n *\n * _.unescape('fred, barney, & pebbles');\n * // => 'fred, barney, & pebbles'\n */\n function unescape(string) {\n string = toString(string);\n return (string && reHasEscapedHtml.test(string))\n ? string.replace(reEscapedHtml, unescapeHtmlChar)\n : string;\n }\n\n /**\n * Converts `string`, as space separated words, to upper case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the upper cased string.\n * @example\n *\n * _.upperCase('--foo-bar');\n * // => 'FOO BAR'\n *\n * _.upperCase('fooBar');\n * // => 'FOO BAR'\n *\n * _.upperCase('__foo_bar__');\n * // => 'FOO BAR'\n */\n var upperCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + word.toUpperCase();\n });\n\n /**\n * Converts the first character of `string` to upper case.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.upperFirst('fred');\n * // => 'Fred'\n *\n * _.upperFirst('FRED');\n * // => 'FRED'\n */\n var upperFirst = createCaseFirst('toUpperCase');\n\n /**\n * Splits `string` into an array of its words.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {RegExp|string} [pattern] The pattern to match words.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the words of `string`.\n * @example\n *\n * _.words('fred, barney, & pebbles');\n * // => ['fred', 'barney', 'pebbles']\n *\n * _.words('fred, barney, & pebbles', /[^, ]+/g);\n * // => ['fred', 'barney', '&', 'pebbles']\n */\n function words(string, pattern, guard) {\n string = toString(string);\n pattern = guard ? undefined : pattern;\n\n if (pattern === undefined) {\n return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);\n }\n return string.match(pattern) || [];\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Attempts to invoke `func`, returning either the result or the caught error\n * object. Any additional arguments are provided to `func` when it's invoked.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Function} func The function to attempt.\n * @param {...*} [args] The arguments to invoke `func` with.\n * @returns {*} Returns the `func` result or error object.\n * @example\n *\n * // Avoid throwing errors for invalid selectors.\n * var elements = _.attempt(function(selector) {\n * return document.querySelectorAll(selector);\n * }, '>_>');\n *\n * if (_.isError(elements)) {\n * elements = [];\n * }\n */\n var attempt = baseRest(function(func, args) {\n try {\n return apply(func, undefined, args);\n } catch (e) {\n return isError(e) ? e : new Error(e);\n }\n });\n\n /**\n * Binds methods of an object to the object itself, overwriting the existing\n * method.\n *\n * **Note:** This method doesn't set the \"length\" property of bound functions.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {Object} object The object to bind and assign the bound methods to.\n * @param {...(string|string[])} methodNames The object method names to bind.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var view = {\n * 'label': 'docs',\n * 'click': function() {\n * console.log('clicked ' + this.label);\n * }\n * };\n *\n * _.bindAll(view, ['click']);\n * jQuery(element).on('click', view.click);\n * // => Logs 'clicked docs' when clicked.\n */\n var bindAll = flatRest(function(object, methodNames) {\n arrayEach(methodNames, function(key) {\n key = toKey(key);\n baseAssignValue(object, key, bind(object[key], object));\n });\n return object;\n });\n\n /**\n * Creates a function that iterates over `pairs` and invokes the corresponding\n * function of the first predicate to return truthy. The predicate-function\n * pairs are invoked with the `this` binding and arguments of the created\n * function.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {Array} pairs The predicate-function pairs.\n * @returns {Function} Returns the new composite function.\n * @example\n *\n * var func = _.cond([\n * [_.matches({ 'a': 1 }), _.constant('matches A')],\n * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],\n * [_.stubTrue, _.constant('no match')]\n * ]);\n *\n * func({ 'a': 1, 'b': 2 });\n * // => 'matches A'\n *\n * func({ 'a': 0, 'b': 1 });\n * // => 'matches B'\n *\n * func({ 'a': '1', 'b': '2' });\n * // => 'no match'\n */\n function cond(pairs) {\n var length = pairs == null ? 0 : pairs.length,\n toIteratee = getIteratee();\n\n pairs = !length ? [] : arrayMap(pairs, function(pair) {\n if (typeof pair[1] != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return [toIteratee(pair[0]), pair[1]];\n });\n\n return baseRest(function(args) {\n var index = -1;\n while (++index < length) {\n var pair = pairs[index];\n if (apply(pair[0], this, args)) {\n return apply(pair[1], this, args);\n }\n }\n });\n }\n\n /**\n * Creates a function that invokes the predicate properties of `source` with\n * the corresponding property values of a given object, returning `true` if\n * all predicates return truthy, else `false`.\n *\n * **Note:** The created function is equivalent to `_.conformsTo` with\n * `source` partially applied.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {Object} source The object of property predicates to conform to.\n * @returns {Function} Returns the new spec function.\n * @example\n *\n * var objects = [\n * { 'a': 2, 'b': 1 },\n * { 'a': 1, 'b': 2 }\n * ];\n *\n * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));\n * // => [{ 'a': 1, 'b': 2 }]\n */\n function conforms(source) {\n return baseConforms(baseClone(source, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new constant function.\n * @example\n *\n * var objects = _.times(2, _.constant({ 'a': 1 }));\n *\n * console.log(objects);\n * // => [{ 'a': 1 }, { 'a': 1 }]\n *\n * console.log(objects[0] === objects[1]);\n * // => true\n */\n function constant(value) {\n return function() {\n return value;\n };\n }\n\n /**\n * Checks `value` to determine whether a default value should be returned in\n * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,\n * or `undefined`.\n *\n * @static\n * @memberOf _\n * @since 4.14.0\n * @category Util\n * @param {*} value The value to check.\n * @param {*} defaultValue The default value.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * _.defaultTo(1, 10);\n * // => 1\n *\n * _.defaultTo(undefined, 10);\n * // => 10\n */\n function defaultTo(value, defaultValue) {\n return (value == null || value !== value) ? defaultValue : value;\n }\n\n /**\n * Creates a function that returns the result of invoking the given functions\n * with the `this` binding of the created function, where each successive\n * invocation is supplied the return value of the previous.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {...(Function|Function[])} [funcs] The functions to invoke.\n * @returns {Function} Returns the new composite function.\n * @see _.flowRight\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var addSquare = _.flow([_.add, square]);\n * addSquare(1, 2);\n * // => 9\n */\n var flow = createFlow();\n\n /**\n * This method is like `_.flow` except that it creates a function that\n * invokes the given functions from right to left.\n *\n * @static\n * @since 3.0.0\n * @memberOf _\n * @category Util\n * @param {...(Function|Function[])} [funcs] The functions to invoke.\n * @returns {Function} Returns the new composite function.\n * @see _.flow\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var addSquare = _.flowRight([square, _.add]);\n * addSquare(1, 2);\n * // => 9\n */\n var flowRight = createFlow(true);\n\n /**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\n function identity(value) {\n return value;\n }\n\n /**\n * Creates a function that invokes `func` with the arguments of the created\n * function. If `func` is a property name, the created function returns the\n * property value for a given element. If `func` is an array or object, the\n * created function returns `true` for elements that contain the equivalent\n * source properties, otherwise it returns `false`.\n *\n * @static\n * @since 4.0.0\n * @memberOf _\n * @category Util\n * @param {*} [func=_.identity] The value to convert to a callback.\n * @returns {Function} Returns the callback.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));\n * // => [{ 'user': 'barney', 'age': 36, 'active': true }]\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.filter(users, _.iteratee(['user', 'fred']));\n * // => [{ 'user': 'fred', 'age': 40 }]\n *\n * // The `_.property` iteratee shorthand.\n * _.map(users, _.iteratee('user'));\n * // => ['barney', 'fred']\n *\n * // Create custom iteratee shorthands.\n * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {\n * return !_.isRegExp(func) ? iteratee(func) : function(string) {\n * return func.test(string);\n * };\n * });\n *\n * _.filter(['abc', 'def'], /ef/);\n * // => ['def']\n */\n function iteratee(func) {\n return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that performs a partial deep comparison between a given\n * object and `source`, returning `true` if the given object has equivalent\n * property values, else `false`.\n *\n * **Note:** The created function is equivalent to `_.isMatch` with `source`\n * partially applied.\n *\n * Partial comparisons will match empty array and empty object `source`\n * values against any array or object value, respectively. See `_.isEqual`\n * for a list of supported value comparisons.\n *\n * **Note:** Multiple values can be checked by combining several matchers\n * using `_.overSome`\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n * @example\n *\n * var objects = [\n * { 'a': 1, 'b': 2, 'c': 3 },\n * { 'a': 4, 'b': 5, 'c': 6 }\n * ];\n *\n * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));\n * // => [{ 'a': 4, 'b': 5, 'c': 6 }]\n *\n * // Checking for several possible values\n * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));\n * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]\n */\n function matches(source) {\n return baseMatches(baseClone(source, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that performs a partial deep comparison between the\n * value at `path` of a given object to `srcValue`, returning `true` if the\n * object value is equivalent, else `false`.\n *\n * **Note:** Partial comparisons will match empty array and empty object\n * `srcValue` values against any array or object value, respectively. See\n * `_.isEqual` for a list of supported value comparisons.\n *\n * **Note:** Multiple values can be checked by combining several matchers\n * using `_.overSome`\n *\n * @static\n * @memberOf _\n * @since 3.2.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n * @example\n *\n * var objects = [\n * { 'a': 1, 'b': 2, 'c': 3 },\n * { 'a': 4, 'b': 5, 'c': 6 }\n * ];\n *\n * _.find(objects, _.matchesProperty('a', 4));\n * // => { 'a': 4, 'b': 5, 'c': 6 }\n *\n * // Checking for several possible values\n * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));\n * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]\n */\n function matchesProperty(path, srcValue) {\n return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));\n }\n\n /**\n * Creates a function that invokes the method at `path` of a given object.\n * Any additional arguments are provided to the invoked method.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Util\n * @param {Array|string} path The path of the method to invoke.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Function} Returns the new invoker function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': _.constant(2) } },\n * { 'a': { 'b': _.constant(1) } }\n * ];\n *\n * _.map(objects, _.method('a.b'));\n * // => [2, 1]\n *\n * _.map(objects, _.method(['a', 'b']));\n * // => [2, 1]\n */\n var method = baseRest(function(path, args) {\n return function(object) {\n return baseInvoke(object, path, args);\n };\n });\n\n /**\n * The opposite of `_.method`; this method creates a function that invokes\n * the method at a given path of `object`. Any additional arguments are\n * provided to the invoked method.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Util\n * @param {Object} object The object to query.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Function} Returns the new invoker function.\n * @example\n *\n * var array = _.times(3, _.constant),\n * object = { 'a': array, 'b': array, 'c': array };\n *\n * _.map(['a[2]', 'c[0]'], _.methodOf(object));\n * // => [2, 0]\n *\n * _.map([['a', '2'], ['c', '0']], _.methodOf(object));\n * // => [2, 0]\n */\n var methodOf = baseRest(function(object, args) {\n return function(path) {\n return baseInvoke(object, path, args);\n };\n });\n\n /**\n * Adds all own enumerable string keyed function properties of a source\n * object to the destination object. If `object` is a function, then methods\n * are added to its prototype as well.\n *\n * **Note:** Use `_.runInContext` to create a pristine `lodash` function to\n * avoid conflicts caused by modifying the original.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {Function|Object} [object=lodash] The destination object.\n * @param {Object} source The object of functions to add.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.chain=true] Specify whether mixins are chainable.\n * @returns {Function|Object} Returns `object`.\n * @example\n *\n * function vowels(string) {\n * return _.filter(string, function(v) {\n * return /[aeiou]/i.test(v);\n * });\n * }\n *\n * _.mixin({ 'vowels': vowels });\n * _.vowels('fred');\n * // => ['e']\n *\n * _('fred').vowels().value();\n * // => ['e']\n *\n * _.mixin({ 'vowels': vowels }, { 'chain': false });\n * _('fred').vowels();\n * // => ['e']\n */\n function mixin(object, source, options) {\n var props = keys(source),\n methodNames = baseFunctions(source, props);\n\n if (options == null &&\n !(isObject(source) && (methodNames.length || !props.length))) {\n options = source;\n source = object;\n object = this;\n methodNames = baseFunctions(source, keys(source));\n }\n var chain = !(isObject(options) && 'chain' in options) || !!options.chain,\n isFunc = isFunction(object);\n\n arrayEach(methodNames, function(methodName) {\n var func = source[methodName];\n object[methodName] = func;\n if (isFunc) {\n object.prototype[methodName] = function() {\n var chainAll = this.__chain__;\n if (chain || chainAll) {\n var result = object(this.__wrapped__),\n actions = result.__actions__ = copyArray(this.__actions__);\n\n actions.push({ 'func': func, 'args': arguments, 'thisArg': object });\n result.__chain__ = chainAll;\n return result;\n }\n return func.apply(object, arrayPush([this.value()], arguments));\n };\n }\n });\n\n return object;\n }\n\n /**\n * Reverts the `_` variable to its previous value and returns a reference to\n * the `lodash` function.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @returns {Function} Returns the `lodash` function.\n * @example\n *\n * var lodash = _.noConflict();\n */\n function noConflict() {\n if (root._ === this) {\n root._ = oldDash;\n }\n return this;\n }\n\n /**\n * This method returns `undefined`.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Util\n * @example\n *\n * _.times(2, _.noop);\n * // => [undefined, undefined]\n */\n function noop() {\n // No operation performed.\n }\n\n /**\n * Creates a function that gets the argument at index `n`. If `n` is negative,\n * the nth argument from the end is returned.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {number} [n=0] The index of the argument to return.\n * @returns {Function} Returns the new pass-thru function.\n * @example\n *\n * var func = _.nthArg(1);\n * func('a', 'b', 'c', 'd');\n * // => 'b'\n *\n * var func = _.nthArg(-2);\n * func('a', 'b', 'c', 'd');\n * // => 'c'\n */\n function nthArg(n) {\n n = toInteger(n);\n return baseRest(function(args) {\n return baseNth(args, n);\n });\n }\n\n /**\n * Creates a function that invokes `iteratees` with the arguments it receives\n * and returns their results.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {...(Function|Function[])} [iteratees=[_.identity]]\n * The iteratees to invoke.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var func = _.over([Math.max, Math.min]);\n *\n * func(1, 2, 3, 4);\n * // => [4, 1]\n */\n var over = createOver(arrayMap);\n\n /**\n * Creates a function that checks if **all** of the `predicates` return\n * truthy when invoked with the arguments it receives.\n *\n * Following shorthands are possible for providing predicates.\n * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.\n * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {...(Function|Function[])} [predicates=[_.identity]]\n * The predicates to check.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var func = _.overEvery([Boolean, isFinite]);\n *\n * func('1');\n * // => true\n *\n * func(null);\n * // => false\n *\n * func(NaN);\n * // => false\n */\n var overEvery = createOver(arrayEvery);\n\n /**\n * Creates a function that checks if **any** of the `predicates` return\n * truthy when invoked with the arguments it receives.\n *\n * Following shorthands are possible for providing predicates.\n * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.\n * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {...(Function|Function[])} [predicates=[_.identity]]\n * The predicates to check.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var func = _.overSome([Boolean, isFinite]);\n *\n * func('1');\n * // => true\n *\n * func(null);\n * // => true\n *\n * func(NaN);\n * // => false\n *\n * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])\n * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])\n */\n var overSome = createOver(arraySome);\n\n /**\n * Creates a function that returns the value at `path` of a given object.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': 2 } },\n * { 'a': { 'b': 1 } }\n * ];\n *\n * _.map(objects, _.property('a.b'));\n * // => [2, 1]\n *\n * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');\n * // => [1, 2]\n */\n function property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n }\n\n /**\n * The opposite of `_.property`; this method creates a function that returns\n * the value at a given path of `object`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Util\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var array = [0, 1, 2],\n * object = { 'a': array, 'b': array, 'c': array };\n *\n * _.map(['a[2]', 'c[0]'], _.propertyOf(object));\n * // => [2, 0]\n *\n * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));\n * // => [2, 0]\n */\n function propertyOf(object) {\n return function(path) {\n return object == null ? undefined : baseGet(object, path);\n };\n }\n\n /**\n * Creates an array of numbers (positive and/or negative) progressing from\n * `start` up to, but not including, `end`. A step of `-1` is used if a negative\n * `start` is specified without an `end` or `step`. If `end` is not specified,\n * it's set to `start` with `start` then set to `0`.\n *\n * **Note:** JavaScript follows the IEEE-754 standard for resolving\n * floating-point values which can produce unexpected results.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @param {number} [step=1] The value to increment or decrement by.\n * @returns {Array} Returns the range of numbers.\n * @see _.inRange, _.rangeRight\n * @example\n *\n * _.range(4);\n * // => [0, 1, 2, 3]\n *\n * _.range(-4);\n * // => [0, -1, -2, -3]\n *\n * _.range(1, 5);\n * // => [1, 2, 3, 4]\n *\n * _.range(0, 20, 5);\n * // => [0, 5, 10, 15]\n *\n * _.range(0, -4, -1);\n * // => [0, -1, -2, -3]\n *\n * _.range(1, 4, 0);\n * // => [1, 1, 1]\n *\n * _.range(0);\n * // => []\n */\n var range = createRange();\n\n /**\n * This method is like `_.range` except that it populates values in\n * descending order.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @param {number} [step=1] The value to increment or decrement by.\n * @returns {Array} Returns the range of numbers.\n * @see _.inRange, _.range\n * @example\n *\n * _.rangeRight(4);\n * // => [3, 2, 1, 0]\n *\n * _.rangeRight(-4);\n * // => [-3, -2, -1, 0]\n *\n * _.rangeRight(1, 5);\n * // => [4, 3, 2, 1]\n *\n * _.rangeRight(0, 20, 5);\n * // => [15, 10, 5, 0]\n *\n * _.rangeRight(0, -4, -1);\n * // => [-3, -2, -1, 0]\n *\n * _.rangeRight(1, 4, 0);\n * // => [1, 1, 1]\n *\n * _.rangeRight(0);\n * // => []\n */\n var rangeRight = createRange(true);\n\n /**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\n function stubArray() {\n return [];\n }\n\n /**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\n function stubFalse() {\n return false;\n }\n\n /**\n * This method returns a new empty object.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Object} Returns the new empty object.\n * @example\n *\n * var objects = _.times(2, _.stubObject);\n *\n * console.log(objects);\n * // => [{}, {}]\n *\n * console.log(objects[0] === objects[1]);\n * // => false\n */\n function stubObject() {\n return {};\n }\n\n /**\n * This method returns an empty string.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {string} Returns the empty string.\n * @example\n *\n * _.times(2, _.stubString);\n * // => ['', '']\n */\n function stubString() {\n return '';\n }\n\n /**\n * This method returns `true`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `true`.\n * @example\n *\n * _.times(2, _.stubTrue);\n * // => [true, true]\n */\n function stubTrue() {\n return true;\n }\n\n /**\n * Invokes the iteratee `n` times, returning an array of the results of\n * each invocation. The iteratee is invoked with one argument; (index).\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n * @example\n *\n * _.times(3, String);\n * // => ['0', '1', '2']\n *\n * _.times(4, _.constant(0));\n * // => [0, 0, 0, 0]\n */\n function times(n, iteratee) {\n n = toInteger(n);\n if (n < 1 || n > MAX_SAFE_INTEGER) {\n return [];\n }\n var index = MAX_ARRAY_LENGTH,\n length = nativeMin(n, MAX_ARRAY_LENGTH);\n\n iteratee = getIteratee(iteratee);\n n -= MAX_ARRAY_LENGTH;\n\n var result = baseTimes(length, iteratee);\n while (++index < n) {\n iteratee(index);\n }\n return result;\n }\n\n /**\n * Converts `value` to a property path array.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Util\n * @param {*} value The value to convert.\n * @returns {Array} Returns the new property path array.\n * @example\n *\n * _.toPath('a.b.c');\n * // => ['a', 'b', 'c']\n *\n * _.toPath('a[0].b.c');\n * // => ['a', '0', 'b', 'c']\n */\n function toPath(value) {\n if (isArray(value)) {\n return arrayMap(value, toKey);\n }\n return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));\n }\n\n /**\n * Generates a unique ID. If `prefix` is given, the ID is appended to it.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {string} [prefix=''] The value to prefix the ID with.\n * @returns {string} Returns the unique ID.\n * @example\n *\n * _.uniqueId('contact_');\n * // => 'contact_104'\n *\n * _.uniqueId();\n * // => '105'\n */\n function uniqueId(prefix) {\n var id = ++idCounter;\n return toString(prefix) + id;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Adds two numbers.\n *\n * @static\n * @memberOf _\n * @since 3.4.0\n * @category Math\n * @param {number} augend The first number in an addition.\n * @param {number} addend The second number in an addition.\n * @returns {number} Returns the total.\n * @example\n *\n * _.add(6, 4);\n * // => 10\n */\n var add = createMathOperation(function(augend, addend) {\n return augend + addend;\n }, 0);\n\n /**\n * Computes `number` rounded up to `precision`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Math\n * @param {number} number The number to round up.\n * @param {number} [precision=0] The precision to round up to.\n * @returns {number} Returns the rounded up number.\n * @example\n *\n * _.ceil(4.006);\n * // => 5\n *\n * _.ceil(6.004, 2);\n * // => 6.01\n *\n * _.ceil(6040, -2);\n * // => 6100\n */\n var ceil = createRound('ceil');\n\n /**\n * Divide two numbers.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Math\n * @param {number} dividend The first number in a division.\n * @param {number} divisor The second number in a division.\n * @returns {number} Returns the quotient.\n * @example\n *\n * _.divide(6, 4);\n * // => 1.5\n */\n var divide = createMathOperation(function(dividend, divisor) {\n return dividend / divisor;\n }, 1);\n\n /**\n * Computes `number` rounded down to `precision`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Math\n * @param {number} number The number to round down.\n * @param {number} [precision=0] The precision to round down to.\n * @returns {number} Returns the rounded down number.\n * @example\n *\n * _.floor(4.006);\n * // => 4\n *\n * _.floor(0.046, 2);\n * // => 0.04\n *\n * _.floor(4060, -2);\n * // => 4000\n */\n var floor = createRound('floor');\n\n /**\n * Computes the maximum value of `array`. If `array` is empty or falsey,\n * `undefined` is returned.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {*} Returns the maximum value.\n * @example\n *\n * _.max([4, 2, 8, 6]);\n * // => 8\n *\n * _.max([]);\n * // => undefined\n */\n function max(array) {\n return (array && array.length)\n ? baseExtremum(array, identity, baseGt)\n : undefined;\n }\n\n /**\n * This method is like `_.max` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * the value is ranked. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {*} Returns the maximum value.\n * @example\n *\n * var objects = [{ 'n': 1 }, { 'n': 2 }];\n *\n * _.maxBy(objects, function(o) { return o.n; });\n * // => { 'n': 2 }\n *\n * // The `_.property` iteratee shorthand.\n * _.maxBy(objects, 'n');\n * // => { 'n': 2 }\n */\n function maxBy(array, iteratee) {\n return (array && array.length)\n ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)\n : undefined;\n }\n\n /**\n * Computes the mean of the values in `array`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {number} Returns the mean.\n * @example\n *\n * _.mean([4, 2, 8, 6]);\n * // => 5\n */\n function mean(array) {\n return baseMean(array, identity);\n }\n\n /**\n * This method is like `_.mean` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the value to be averaged.\n * The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the mean.\n * @example\n *\n * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];\n *\n * _.meanBy(objects, function(o) { return o.n; });\n * // => 5\n *\n * // The `_.property` iteratee shorthand.\n * _.meanBy(objects, 'n');\n * // => 5\n */\n function meanBy(array, iteratee) {\n return baseMean(array, getIteratee(iteratee, 2));\n }\n\n /**\n * Computes the minimum value of `array`. If `array` is empty or falsey,\n * `undefined` is returned.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {*} Returns the minimum value.\n * @example\n *\n * _.min([4, 2, 8, 6]);\n * // => 2\n *\n * _.min([]);\n * // => undefined\n */\n function min(array) {\n return (array && array.length)\n ? baseExtremum(array, identity, baseLt)\n : undefined;\n }\n\n /**\n * This method is like `_.min` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * the value is ranked. The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {*} Returns the minimum value.\n * @example\n *\n * var objects = [{ 'n': 1 }, { 'n': 2 }];\n *\n * _.minBy(objects, function(o) { return o.n; });\n * // => { 'n': 1 }\n *\n * // The `_.property` iteratee shorthand.\n * _.minBy(objects, 'n');\n * // => { 'n': 1 }\n */\n function minBy(array, iteratee) {\n return (array && array.length)\n ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)\n : undefined;\n }\n\n /**\n * Multiply two numbers.\n *\n * @static\n * @memberOf _\n * @since 4.7.0\n * @category Math\n * @param {number} multiplier The first number in a multiplication.\n * @param {number} multiplicand The second number in a multiplication.\n * @returns {number} Returns the product.\n * @example\n *\n * _.multiply(6, 4);\n * // => 24\n */\n var multiply = createMathOperation(function(multiplier, multiplicand) {\n return multiplier * multiplicand;\n }, 1);\n\n /**\n * Computes `number` rounded to `precision`.\n *\n * @static\n * @memberOf _\n * @since 3.10.0\n * @category Math\n * @param {number} number The number to round.\n * @param {number} [precision=0] The precision to round to.\n * @returns {number} Returns the rounded number.\n * @example\n *\n * _.round(4.006);\n * // => 4\n *\n * _.round(4.006, 2);\n * // => 4.01\n *\n * _.round(4060, -2);\n * // => 4100\n */\n var round = createRound('round');\n\n /**\n * Subtract two numbers.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {number} minuend The first number in a subtraction.\n * @param {number} subtrahend The second number in a subtraction.\n * @returns {number} Returns the difference.\n * @example\n *\n * _.subtract(6, 4);\n * // => 2\n */\n var subtract = createMathOperation(function(minuend, subtrahend) {\n return minuend - subtrahend;\n }, 0);\n\n /**\n * Computes the sum of the values in `array`.\n *\n * @static\n * @memberOf _\n * @since 3.4.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @returns {number} Returns the sum.\n * @example\n *\n * _.sum([4, 2, 8, 6]);\n * // => 20\n */\n function sum(array) {\n return (array && array.length)\n ? baseSum(array, identity)\n : 0;\n }\n\n /**\n * This method is like `_.sum` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the value to be summed.\n * The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the sum.\n * @example\n *\n * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];\n *\n * _.sumBy(objects, function(o) { return o.n; });\n * // => 20\n *\n * // The `_.property` iteratee shorthand.\n * _.sumBy(objects, 'n');\n * // => 20\n */\n function sumBy(array, iteratee) {\n return (array && array.length)\n ? baseSum(array, getIteratee(iteratee, 2))\n : 0;\n }\n\n /*------------------------------------------------------------------------*/\n\n // Add methods that return wrapped values in chain sequences.\n lodash.after = after;\n lodash.ary = ary;\n lodash.assign = assign;\n lodash.assignIn = assignIn;\n lodash.assignInWith = assignInWith;\n lodash.assignWith = assignWith;\n lodash.at = at;\n lodash.before = before;\n lodash.bind = bind;\n lodash.bindAll = bindAll;\n lodash.bindKey = bindKey;\n lodash.castArray = castArray;\n lodash.chain = chain;\n lodash.chunk = chunk;\n lodash.compact = compact;\n lodash.concat = concat;\n lodash.cond = cond;\n lodash.conforms = conforms;\n lodash.constant = constant;\n lodash.countBy = countBy;\n lodash.create = create;\n lodash.curry = curry;\n lodash.curryRight = curryRight;\n lodash.debounce = debounce;\n lodash.defaults = defaults;\n lodash.defaultsDeep = defaultsDeep;\n lodash.defer = defer;\n lodash.delay = delay;\n lodash.difference = difference;\n lodash.differenceBy = differenceBy;\n lodash.differenceWith = differenceWith;\n lodash.drop = drop;\n lodash.dropRight = dropRight;\n lodash.dropRightWhile = dropRightWhile;\n lodash.dropWhile = dropWhile;\n lodash.fill = fill;\n lodash.filter = filter;\n lodash.flatMap = flatMap;\n lodash.flatMapDeep = flatMapDeep;\n lodash.flatMapDepth = flatMapDepth;\n lodash.flatten = flatten;\n lodash.flattenDeep = flattenDeep;\n lodash.flattenDepth = flattenDepth;\n lodash.flip = flip;\n lodash.flow = flow;\n lodash.flowRight = flowRight;\n lodash.fromPairs = fromPairs;\n lodash.functions = functions;\n lodash.functionsIn = functionsIn;\n lodash.groupBy = groupBy;\n lodash.initial = initial;\n lodash.intersection = intersection;\n lodash.intersectionBy = intersectionBy;\n lodash.intersectionWith = intersectionWith;\n lodash.invert = invert;\n lodash.invertBy = invertBy;\n lodash.invokeMap = invokeMap;\n lodash.iteratee = iteratee;\n lodash.keyBy = keyBy;\n lodash.keys = keys;\n lodash.keysIn = keysIn;\n lodash.map = map;\n lodash.mapKeys = mapKeys;\n lodash.mapValues = mapValues;\n lodash.matches = matches;\n lodash.matchesProperty = matchesProperty;\n lodash.memoize = memoize;\n lodash.merge = merge;\n lodash.mergeWith = mergeWith;\n lodash.method = method;\n lodash.methodOf = methodOf;\n lodash.mixin = mixin;\n lodash.negate = negate;\n lodash.nthArg = nthArg;\n lodash.omit = omit;\n lodash.omitBy = omitBy;\n lodash.once = once;\n lodash.orderBy = orderBy;\n lodash.over = over;\n lodash.overArgs = overArgs;\n lodash.overEvery = overEvery;\n lodash.overSome = overSome;\n lodash.partial = partial;\n lodash.partialRight = partialRight;\n lodash.partition = partition;\n lodash.pick = pick;\n lodash.pickBy = pickBy;\n lodash.property = property;\n lodash.propertyOf = propertyOf;\n lodash.pull = pull;\n lodash.pullAll = pullAll;\n lodash.pullAllBy = pullAllBy;\n lodash.pullAllWith = pullAllWith;\n lodash.pullAt = pullAt;\n lodash.range = range;\n lodash.rangeRight = rangeRight;\n lodash.rearg = rearg;\n lodash.reject = reject;\n lodash.remove = remove;\n lodash.rest = rest;\n lodash.reverse = reverse;\n lodash.sampleSize = sampleSize;\n lodash.set = set;\n lodash.setWith = setWith;\n lodash.shuffle = shuffle;\n lodash.slice = slice;\n lodash.sortBy = sortBy;\n lodash.sortedUniq = sortedUniq;\n lodash.sortedUniqBy = sortedUniqBy;\n lodash.split = split;\n lodash.spread = spread;\n lodash.tail = tail;\n lodash.take = take;\n lodash.takeRight = takeRight;\n lodash.takeRightWhile = takeRightWhile;\n lodash.takeWhile = takeWhile;\n lodash.tap = tap;\n lodash.throttle = throttle;\n lodash.thru = thru;\n lodash.toArray = toArray;\n lodash.toPairs = toPairs;\n lodash.toPairsIn = toPairsIn;\n lodash.toPath = toPath;\n lodash.toPlainObject = toPlainObject;\n lodash.transform = transform;\n lodash.unary = unary;\n lodash.union = union;\n lodash.unionBy = unionBy;\n lodash.unionWith = unionWith;\n lodash.uniq = uniq;\n lodash.uniqBy = uniqBy;\n lodash.uniqWith = uniqWith;\n lodash.unset = unset;\n lodash.unzip = unzip;\n lodash.unzipWith = unzipWith;\n lodash.update = update;\n lodash.updateWith = updateWith;\n lodash.values = values;\n lodash.valuesIn = valuesIn;\n lodash.without = without;\n lodash.words = words;\n lodash.wrap = wrap;\n lodash.xor = xor;\n lodash.xorBy = xorBy;\n lodash.xorWith = xorWith;\n lodash.zip = zip;\n lodash.zipObject = zipObject;\n lodash.zipObjectDeep = zipObjectDeep;\n lodash.zipWith = zipWith;\n\n // Add aliases.\n lodash.entries = toPairs;\n lodash.entriesIn = toPairsIn;\n lodash.extend = assignIn;\n lodash.extendWith = assignInWith;\n\n // Add methods to `lodash.prototype`.\n mixin(lodash, lodash);\n\n /*------------------------------------------------------------------------*/\n\n // Add methods that return unwrapped values in chain sequences.\n lodash.add = add;\n lodash.attempt = attempt;\n lodash.camelCase = camelCase;\n lodash.capitalize = capitalize;\n lodash.ceil = ceil;\n lodash.clamp = clamp;\n lodash.clone = clone;\n lodash.cloneDeep = cloneDeep;\n lodash.cloneDeepWith = cloneDeepWith;\n lodash.cloneWith = cloneWith;\n lodash.conformsTo = conformsTo;\n lodash.deburr = deburr;\n lodash.defaultTo = defaultTo;\n lodash.divide = divide;\n lodash.endsWith = endsWith;\n lodash.eq = eq;\n lodash.escape = escape;\n lodash.escapeRegExp = escapeRegExp;\n lodash.every = every;\n lodash.find = find;\n lodash.findIndex = findIndex;\n lodash.findKey = findKey;\n lodash.findLast = findLast;\n lodash.findLastIndex = findLastIndex;\n lodash.findLastKey = findLastKey;\n lodash.floor = floor;\n lodash.forEach = forEach;\n lodash.forEachRight = forEachRight;\n lodash.forIn = forIn;\n lodash.forInRight = forInRight;\n lodash.forOwn = forOwn;\n lodash.forOwnRight = forOwnRight;\n lodash.get = get;\n lodash.gt = gt;\n lodash.gte = gte;\n lodash.has = has;\n lodash.hasIn = hasIn;\n lodash.head = head;\n lodash.identity = identity;\n lodash.includes = includes;\n lodash.indexOf = indexOf;\n lodash.inRange = inRange;\n lodash.invoke = invoke;\n lodash.isArguments = isArguments;\n lodash.isArray = isArray;\n lodash.isArrayBuffer = isArrayBuffer;\n lodash.isArrayLike = isArrayLike;\n lodash.isArrayLikeObject = isArrayLikeObject;\n lodash.isBoolean = isBoolean;\n lodash.isBuffer = isBuffer;\n lodash.isDate = isDate;\n lodash.isElement = isElement;\n lodash.isEmpty = isEmpty;\n lodash.isEqual = isEqual;\n lodash.isEqualWith = isEqualWith;\n lodash.isError = isError;\n lodash.isFinite = isFinite;\n lodash.isFunction = isFunction;\n lodash.isInteger = isInteger;\n lodash.isLength = isLength;\n lodash.isMap = isMap;\n lodash.isMatch = isMatch;\n lodash.isMatchWith = isMatchWith;\n lodash.isNaN = isNaN;\n lodash.isNative = isNative;\n lodash.isNil = isNil;\n lodash.isNull = isNull;\n lodash.isNumber = isNumber;\n lodash.isObject = isObject;\n lodash.isObjectLike = isObjectLike;\n lodash.isPlainObject = isPlainObject;\n lodash.isRegExp = isRegExp;\n lodash.isSafeInteger = isSafeInteger;\n lodash.isSet = isSet;\n lodash.isString = isString;\n lodash.isSymbol = isSymbol;\n lodash.isTypedArray = isTypedArray;\n lodash.isUndefined = isUndefined;\n lodash.isWeakMap = isWeakMap;\n lodash.isWeakSet = isWeakSet;\n lodash.join = join;\n lodash.kebabCase = kebabCase;\n lodash.last = last;\n lodash.lastIndexOf = lastIndexOf;\n lodash.lowerCase = lowerCase;\n lodash.lowerFirst = lowerFirst;\n lodash.lt = lt;\n lodash.lte = lte;\n lodash.max = max;\n lodash.maxBy = maxBy;\n lodash.mean = mean;\n lodash.meanBy = meanBy;\n lodash.min = min;\n lodash.minBy = minBy;\n lodash.stubArray = stubArray;\n lodash.stubFalse = stubFalse;\n lodash.stubObject = stubObject;\n lodash.stubString = stubString;\n lodash.stubTrue = stubTrue;\n lodash.multiply = multiply;\n lodash.nth = nth;\n lodash.noConflict = noConflict;\n lodash.noop = noop;\n lodash.now = now;\n lodash.pad = pad;\n lodash.padEnd = padEnd;\n lodash.padStart = padStart;\n lodash.parseInt = parseInt;\n lodash.random = random;\n lodash.reduce = reduce;\n lodash.reduceRight = reduceRight;\n lodash.repeat = repeat;\n lodash.replace = replace;\n lodash.result = result;\n lodash.round = round;\n lodash.runInContext = runInContext;\n lodash.sample = sample;\n lodash.size = size;\n lodash.snakeCase = snakeCase;\n lodash.some = some;\n lodash.sortedIndex = sortedIndex;\n lodash.sortedIndexBy = sortedIndexBy;\n lodash.sortedIndexOf = sortedIndexOf;\n lodash.sortedLastIndex = sortedLastIndex;\n lodash.sortedLastIndexBy = sortedLastIndexBy;\n lodash.sortedLastIndexOf = sortedLastIndexOf;\n lodash.startCase = startCase;\n lodash.startsWith = startsWith;\n lodash.subtract = subtract;\n lodash.sum = sum;\n lodash.sumBy = sumBy;\n lodash.template = template;\n lodash.times = times;\n lodash.toFinite = toFinite;\n lodash.toInteger = toInteger;\n lodash.toLength = toLength;\n lodash.toLower = toLower;\n lodash.toNumber = toNumber;\n lodash.toSafeInteger = toSafeInteger;\n lodash.toString = toString;\n lodash.toUpper = toUpper;\n lodash.trim = trim;\n lodash.trimEnd = trimEnd;\n lodash.trimStart = trimStart;\n lodash.truncate = truncate;\n lodash.unescape = unescape;\n lodash.uniqueId = uniqueId;\n lodash.upperCase = upperCase;\n lodash.upperFirst = upperFirst;\n\n // Add aliases.\n lodash.each = forEach;\n lodash.eachRight = forEachRight;\n lodash.first = head;\n\n mixin(lodash, (function() {\n var source = {};\n baseForOwn(lodash, function(func, methodName) {\n if (!hasOwnProperty.call(lodash.prototype, methodName)) {\n source[methodName] = func;\n }\n });\n return source;\n }()), { 'chain': false });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The semantic version number.\n *\n * @static\n * @memberOf _\n * @type {string}\n */\n lodash.VERSION = VERSION;\n\n // Assign default placeholders.\n arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {\n lodash[methodName].placeholder = lodash;\n });\n\n // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.\n arrayEach(['drop', 'take'], function(methodName, index) {\n LazyWrapper.prototype[methodName] = function(n) {\n n = n === undefined ? 1 : nativeMax(toInteger(n), 0);\n\n var result = (this.__filtered__ && !index)\n ? new LazyWrapper(this)\n : this.clone();\n\n if (result.__filtered__) {\n result.__takeCount__ = nativeMin(n, result.__takeCount__);\n } else {\n result.__views__.push({\n 'size': nativeMin(n, MAX_ARRAY_LENGTH),\n 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')\n });\n }\n return result;\n };\n\n LazyWrapper.prototype[methodName + 'Right'] = function(n) {\n return this.reverse()[methodName](n).reverse();\n };\n });\n\n // Add `LazyWrapper` methods that accept an `iteratee` value.\n arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {\n var type = index + 1,\n isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;\n\n LazyWrapper.prototype[methodName] = function(iteratee) {\n var result = this.clone();\n result.__iteratees__.push({\n 'iteratee': getIteratee(iteratee, 3),\n 'type': type\n });\n result.__filtered__ = result.__filtered__ || isFilter;\n return result;\n };\n });\n\n // Add `LazyWrapper` methods for `_.head` and `_.last`.\n arrayEach(['head', 'last'], function(methodName, index) {\n var takeName = 'take' + (index ? 'Right' : '');\n\n LazyWrapper.prototype[methodName] = function() {\n return this[takeName](1).value()[0];\n };\n });\n\n // Add `LazyWrapper` methods for `_.initial` and `_.tail`.\n arrayEach(['initial', 'tail'], function(methodName, index) {\n var dropName = 'drop' + (index ? '' : 'Right');\n\n LazyWrapper.prototype[methodName] = function() {\n return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);\n };\n });\n\n LazyWrapper.prototype.compact = function() {\n return this.filter(identity);\n };\n\n LazyWrapper.prototype.find = function(predicate) {\n return this.filter(predicate).head();\n };\n\n LazyWrapper.prototype.findLast = function(predicate) {\n return this.reverse().find(predicate);\n };\n\n LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {\n if (typeof path == 'function') {\n return new LazyWrapper(this);\n }\n return this.map(function(value) {\n return baseInvoke(value, path, args);\n });\n });\n\n LazyWrapper.prototype.reject = function(predicate) {\n return this.filter(negate(getIteratee(predicate)));\n };\n\n LazyWrapper.prototype.slice = function(start, end) {\n start = toInteger(start);\n\n var result = this;\n if (result.__filtered__ && (start > 0 || end < 0)) {\n return new LazyWrapper(result);\n }\n if (start < 0) {\n result = result.takeRight(-start);\n } else if (start) {\n result = result.drop(start);\n }\n if (end !== undefined) {\n end = toInteger(end);\n result = end < 0 ? result.dropRight(-end) : result.take(end - start);\n }\n return result;\n };\n\n LazyWrapper.prototype.takeRightWhile = function(predicate) {\n return this.reverse().takeWhile(predicate).reverse();\n };\n\n LazyWrapper.prototype.toArray = function() {\n return this.take(MAX_ARRAY_LENGTH);\n };\n\n // Add `LazyWrapper` methods to `lodash.prototype`.\n baseForOwn(LazyWrapper.prototype, function(func, methodName) {\n var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),\n isTaker = /^(?:head|last)$/.test(methodName),\n lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],\n retUnwrapped = isTaker || /^find/.test(methodName);\n\n if (!lodashFunc) {\n return;\n }\n lodash.prototype[methodName] = function() {\n var value = this.__wrapped__,\n args = isTaker ? [1] : arguments,\n isLazy = value instanceof LazyWrapper,\n iteratee = args[0],\n useLazy = isLazy || isArray(value);\n\n var interceptor = function(value) {\n var result = lodashFunc.apply(lodash, arrayPush([value], args));\n return (isTaker && chainAll) ? result[0] : result;\n };\n\n if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {\n // Avoid lazy use if the iteratee has a \"length\" value other than `1`.\n isLazy = useLazy = false;\n }\n var chainAll = this.__chain__,\n isHybrid = !!this.__actions__.length,\n isUnwrapped = retUnwrapped && !chainAll,\n onlyLazy = isLazy && !isHybrid;\n\n if (!retUnwrapped && useLazy) {\n value = onlyLazy ? value : new LazyWrapper(this);\n var result = func.apply(value, args);\n result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });\n return new LodashWrapper(result, chainAll);\n }\n if (isUnwrapped && onlyLazy) {\n return func.apply(this, args);\n }\n result = this.thru(interceptor);\n return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;\n };\n });\n\n // Add `Array` methods to `lodash.prototype`.\n arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {\n var func = arrayProto[methodName],\n chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',\n retUnwrapped = /^(?:pop|shift)$/.test(methodName);\n\n lodash.prototype[methodName] = function() {\n var args = arguments;\n if (retUnwrapped && !this.__chain__) {\n var value = this.value();\n return func.apply(isArray(value) ? value : [], args);\n }\n return this[chainName](function(value) {\n return func.apply(isArray(value) ? value : [], args);\n });\n };\n });\n\n // Map minified method names to their real names.\n baseForOwn(LazyWrapper.prototype, function(func, methodName) {\n var lodashFunc = lodash[methodName];\n if (lodashFunc) {\n var key = lodashFunc.name + '';\n if (!hasOwnProperty.call(realNames, key)) {\n realNames[key] = [];\n }\n realNames[key].push({ 'name': methodName, 'func': lodashFunc });\n }\n });\n\n realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{\n 'name': 'wrapper',\n 'func': undefined\n }];\n\n // Add methods to `LazyWrapper`.\n LazyWrapper.prototype.clone = lazyClone;\n LazyWrapper.prototype.reverse = lazyReverse;\n LazyWrapper.prototype.value = lazyValue;\n\n // Add chain sequence methods to the `lodash` wrapper.\n lodash.prototype.at = wrapperAt;\n lodash.prototype.chain = wrapperChain;\n lodash.prototype.commit = wrapperCommit;\n lodash.prototype.next = wrapperNext;\n lodash.prototype.plant = wrapperPlant;\n lodash.prototype.reverse = wrapperReverse;\n lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;\n\n // Add lazy aliases.\n lodash.prototype.first = lodash.prototype.head;\n\n if (symIterator) {\n lodash.prototype[symIterator] = wrapperToIterator;\n }\n return lodash;\n });\n\n /*--------------------------------------------------------------------------*/\n\n // Export lodash.\n var _ = runInContext();\n\n // Some AMD build optimizers, like r.js, check for condition patterns like:\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n // Expose Lodash on the global object to prevent errors when Lodash is\n // loaded by a script tag in the presence of an AMD loader.\n // See http://requirejs.org/docs/errors.html#mismatch for more details.\n // Use `_.noConflict` to remove Lodash from the global object.\n root._ = _;\n\n // Define as an anonymous module so, through path mapping, it can be\n // referenced as the \"underscore\" module.\n define(function() {\n return _;\n });\n }\n // Check for `exports` after `define` in case a build optimizer adds it.\n else if (freeModule) {\n // Export for Node.js.\n (freeModule.exports = _)._ = _;\n // Export for CommonJS support.\n freeExports._ = _;\n }\n else {\n // Export to the global object.\n root._ = _;\n }\n}.call(this));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/lodash/lodash.js\n// module id = 36\n// module chunks = 0","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/node-libs-browser/~/events/events.js\n// module id = 37\n// module chunks = 0","/* MIT license */\n\nmodule.exports = {\n rgb2hsl: rgb2hsl,\n rgb2hsv: rgb2hsv,\n rgb2hwb: rgb2hwb,\n rgb2cmyk: rgb2cmyk,\n rgb2keyword: rgb2keyword,\n rgb2xyz: rgb2xyz,\n rgb2lab: rgb2lab,\n rgb2lch: rgb2lch,\n\n hsl2rgb: hsl2rgb,\n hsl2hsv: hsl2hsv,\n hsl2hwb: hsl2hwb,\n hsl2cmyk: hsl2cmyk,\n hsl2keyword: hsl2keyword,\n\n hsv2rgb: hsv2rgb,\n hsv2hsl: hsv2hsl,\n hsv2hwb: hsv2hwb,\n hsv2cmyk: hsv2cmyk,\n hsv2keyword: hsv2keyword,\n\n hwb2rgb: hwb2rgb,\n hwb2hsl: hwb2hsl,\n hwb2hsv: hwb2hsv,\n hwb2cmyk: hwb2cmyk,\n hwb2keyword: hwb2keyword,\n\n cmyk2rgb: cmyk2rgb,\n cmyk2hsl: cmyk2hsl,\n cmyk2hsv: cmyk2hsv,\n cmyk2hwb: cmyk2hwb,\n cmyk2keyword: cmyk2keyword,\n\n keyword2rgb: keyword2rgb,\n keyword2hsl: keyword2hsl,\n keyword2hsv: keyword2hsv,\n keyword2hwb: keyword2hwb,\n keyword2cmyk: keyword2cmyk,\n keyword2lab: keyword2lab,\n keyword2xyz: keyword2xyz,\n\n xyz2rgb: xyz2rgb,\n xyz2lab: xyz2lab,\n xyz2lch: xyz2lch,\n\n lab2xyz: lab2xyz,\n lab2rgb: lab2rgb,\n lab2lch: lab2lch,\n\n lch2lab: lch2lab,\n lch2xyz: lch2xyz,\n lch2rgb: lch2rgb\n}\n\n\nfunction rgb2hsl(rgb) {\n var r = rgb[0]/255,\n g = rgb[1]/255,\n b = rgb[2]/255,\n min = Math.min(r, g, b),\n max = Math.max(r, g, b),\n delta = max - min,\n h, s, l;\n\n if (max == min)\n h = 0;\n else if (r == max)\n h = (g - b) / delta;\n else if (g == max)\n h = 2 + (b - r) / delta;\n else if (b == max)\n h = 4 + (r - g)/ delta;\n\n h = Math.min(h * 60, 360);\n\n if (h < 0)\n h += 360;\n\n l = (min + max) / 2;\n\n if (max == min)\n s = 0;\n else if (l <= 0.5)\n s = delta / (max + min);\n else\n s = delta / (2 - max - min);\n\n return [h, s * 100, l * 100];\n}\n\nfunction rgb2hsv(rgb) {\n var r = rgb[0],\n g = rgb[1],\n b = rgb[2],\n min = Math.min(r, g, b),\n max = Math.max(r, g, b),\n delta = max - min,\n h, s, v;\n\n if (max == 0)\n s = 0;\n else\n s = (delta/max * 1000)/10;\n\n if (max == min)\n h = 0;\n else if (r == max)\n h = (g - b) / delta;\n else if (g == max)\n h = 2 + (b - r) / delta;\n else if (b == max)\n h = 4 + (r - g) / delta;\n\n h = Math.min(h * 60, 360);\n\n if (h < 0)\n h += 360;\n\n v = ((max / 255) * 1000) / 10;\n\n return [h, s, v];\n}\n\nfunction rgb2hwb(rgb) {\n var r = rgb[0],\n g = rgb[1],\n b = rgb[2],\n h = rgb2hsl(rgb)[0],\n w = 1/255 * Math.min(r, Math.min(g, b)),\n b = 1 - 1/255 * Math.max(r, Math.max(g, b));\n\n return [h, w * 100, b * 100];\n}\n\nfunction rgb2cmyk(rgb) {\n var r = rgb[0] / 255,\n g = rgb[1] / 255,\n b = rgb[2] / 255,\n c, m, y, k;\n\n k = Math.min(1 - r, 1 - g, 1 - b);\n c = (1 - r - k) / (1 - k) || 0;\n m = (1 - g - k) / (1 - k) || 0;\n y = (1 - b - k) / (1 - k) || 0;\n return [c * 100, m * 100, y * 100, k * 100];\n}\n\nfunction rgb2keyword(rgb) {\n return reverseKeywords[JSON.stringify(rgb)];\n}\n\nfunction rgb2xyz(rgb) {\n var r = rgb[0] / 255,\n g = rgb[1] / 255,\n b = rgb[2] / 255;\n\n // assume sRGB\n r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n\n return [x * 100, y *100, z * 100];\n}\n\nfunction rgb2lab(rgb) {\n var xyz = rgb2xyz(rgb),\n x = xyz[0],\n y = xyz[1],\n z = xyz[2],\n l, a, b;\n\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n\n x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);\n y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);\n z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);\n\n l = (116 * y) - 16;\n a = 500 * (x - y);\n b = 200 * (y - z);\n\n return [l, a, b];\n}\n\nfunction rgb2lch(args) {\n return lab2lch(rgb2lab(args));\n}\n\nfunction hsl2rgb(hsl) {\n var h = hsl[0] / 360,\n s = hsl[1] / 100,\n l = hsl[2] / 100,\n t1, t2, t3, rgb, val;\n\n if (s == 0) {\n val = l * 255;\n return [val, val, val];\n }\n\n if (l < 0.5)\n t2 = l * (1 + s);\n else\n t2 = l + s - l * s;\n t1 = 2 * l - t2;\n\n rgb = [0, 0, 0];\n for (var i = 0; i < 3; i++) {\n t3 = h + 1 / 3 * - (i - 1);\n t3 < 0 && t3++;\n t3 > 1 && t3--;\n\n if (6 * t3 < 1)\n val = t1 + (t2 - t1) * 6 * t3;\n else if (2 * t3 < 1)\n val = t2;\n else if (3 * t3 < 2)\n val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n else\n val = t1;\n\n rgb[i] = val * 255;\n }\n\n return rgb;\n}\n\nfunction hsl2hsv(hsl) {\n var h = hsl[0],\n s = hsl[1] / 100,\n l = hsl[2] / 100,\n sv, v;\n\n if(l === 0) {\n // no need to do calc on black\n // also avoids divide by 0 error\n return [0, 0, 0];\n }\n\n l *= 2;\n s *= (l <= 1) ? l : 2 - l;\n v = (l + s) / 2;\n sv = (2 * s) / (l + s);\n return [h, sv * 100, v * 100];\n}\n\nfunction hsl2hwb(args) {\n return rgb2hwb(hsl2rgb(args));\n}\n\nfunction hsl2cmyk(args) {\n return rgb2cmyk(hsl2rgb(args));\n}\n\nfunction hsl2keyword(args) {\n return rgb2keyword(hsl2rgb(args));\n}\n\n\nfunction hsv2rgb(hsv) {\n var h = hsv[0] / 60,\n s = hsv[1] / 100,\n v = hsv[2] / 100,\n hi = Math.floor(h) % 6;\n\n var f = h - Math.floor(h),\n p = 255 * v * (1 - s),\n q = 255 * v * (1 - (s * f)),\n t = 255 * v * (1 - (s * (1 - f))),\n v = 255 * v;\n\n switch(hi) {\n case 0:\n return [v, t, p];\n case 1:\n return [q, v, p];\n case 2:\n return [p, v, t];\n case 3:\n return [p, q, v];\n case 4:\n return [t, p, v];\n case 5:\n return [v, p, q];\n }\n}\n\nfunction hsv2hsl(hsv) {\n var h = hsv[0],\n s = hsv[1] / 100,\n v = hsv[2] / 100,\n sl, l;\n\n l = (2 - s) * v;\n sl = s * v;\n sl /= (l <= 1) ? l : 2 - l;\n sl = sl || 0;\n l /= 2;\n return [h, sl * 100, l * 100];\n}\n\nfunction hsv2hwb(args) {\n return rgb2hwb(hsv2rgb(args))\n}\n\nfunction hsv2cmyk(args) {\n return rgb2cmyk(hsv2rgb(args));\n}\n\nfunction hsv2keyword(args) {\n return rgb2keyword(hsv2rgb(args));\n}\n\n// http://dev.w3.org/csswg/css-color/#hwb-to-rgb\nfunction hwb2rgb(hwb) {\n var h = hwb[0] / 360,\n wh = hwb[1] / 100,\n bl = hwb[2] / 100,\n ratio = wh + bl,\n i, v, f, n;\n\n // wh + bl cant be > 1\n if (ratio > 1) {\n wh /= ratio;\n bl /= ratio;\n }\n\n i = Math.floor(6 * h);\n v = 1 - bl;\n f = 6 * h - i;\n if ((i & 0x01) != 0) {\n f = 1 - f;\n }\n n = wh + f * (v - wh); // linear interpolation\n\n switch (i) {\n default:\n case 6:\n case 0: r = v; g = n; b = wh; break;\n case 1: r = n; g = v; b = wh; break;\n case 2: r = wh; g = v; b = n; break;\n case 3: r = wh; g = n; b = v; break;\n case 4: r = n; g = wh; b = v; break;\n case 5: r = v; g = wh; b = n; break;\n }\n\n return [r * 255, g * 255, b * 255];\n}\n\nfunction hwb2hsl(args) {\n return rgb2hsl(hwb2rgb(args));\n}\n\nfunction hwb2hsv(args) {\n return rgb2hsv(hwb2rgb(args));\n}\n\nfunction hwb2cmyk(args) {\n return rgb2cmyk(hwb2rgb(args));\n}\n\nfunction hwb2keyword(args) {\n return rgb2keyword(hwb2rgb(args));\n}\n\nfunction cmyk2rgb(cmyk) {\n var c = cmyk[0] / 100,\n m = cmyk[1] / 100,\n y = cmyk[2] / 100,\n k = cmyk[3] / 100,\n r, g, b;\n\n r = 1 - Math.min(1, c * (1 - k) + k);\n g = 1 - Math.min(1, m * (1 - k) + k);\n b = 1 - Math.min(1, y * (1 - k) + k);\n return [r * 255, g * 255, b * 255];\n}\n\nfunction cmyk2hsl(args) {\n return rgb2hsl(cmyk2rgb(args));\n}\n\nfunction cmyk2hsv(args) {\n return rgb2hsv(cmyk2rgb(args));\n}\n\nfunction cmyk2hwb(args) {\n return rgb2hwb(cmyk2rgb(args));\n}\n\nfunction cmyk2keyword(args) {\n return rgb2keyword(cmyk2rgb(args));\n}\n\n\nfunction xyz2rgb(xyz) {\n var x = xyz[0] / 100,\n y = xyz[1] / 100,\n z = xyz[2] / 100,\n r, g, b;\n\n r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n // assume sRGB\n r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)\n : r = (r * 12.92);\n\n g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)\n : g = (g * 12.92);\n\n b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)\n : b = (b * 12.92);\n\n r = Math.min(Math.max(0, r), 1);\n g = Math.min(Math.max(0, g), 1);\n b = Math.min(Math.max(0, b), 1);\n\n return [r * 255, g * 255, b * 255];\n}\n\nfunction xyz2lab(xyz) {\n var x = xyz[0],\n y = xyz[1],\n z = xyz[2],\n l, a, b;\n\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n\n x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);\n y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);\n z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);\n\n l = (116 * y) - 16;\n a = 500 * (x - y);\n b = 200 * (y - z);\n\n return [l, a, b];\n}\n\nfunction xyz2lch(args) {\n return lab2lch(xyz2lab(args));\n}\n\nfunction lab2xyz(lab) {\n var l = lab[0],\n a = lab[1],\n b = lab[2],\n x, y, z, y2;\n\n if (l <= 8) {\n y = (l * 100) / 903.3;\n y2 = (7.787 * (y / 100)) + (16 / 116);\n } else {\n y = 100 * Math.pow((l + 16) / 116, 3);\n y2 = Math.pow(y / 100, 1/3);\n }\n\n x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);\n\n z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);\n\n return [x, y, z];\n}\n\nfunction lab2lch(lab) {\n var l = lab[0],\n a = lab[1],\n b = lab[2],\n hr, h, c;\n\n hr = Math.atan2(b, a);\n h = hr * 360 / 2 / Math.PI;\n if (h < 0) {\n h += 360;\n }\n c = Math.sqrt(a * a + b * b);\n return [l, c, h];\n}\n\nfunction lab2rgb(args) {\n return xyz2rgb(lab2xyz(args));\n}\n\nfunction lch2lab(lch) {\n var l = lch[0],\n c = lch[1],\n h = lch[2],\n a, b, hr;\n\n hr = h / 360 * 2 * Math.PI;\n a = c * Math.cos(hr);\n b = c * Math.sin(hr);\n return [l, a, b];\n}\n\nfunction lch2xyz(args) {\n return lab2xyz(lch2lab(args));\n}\n\nfunction lch2rgb(args) {\n return lab2rgb(lch2lab(args));\n}\n\nfunction keyword2rgb(keyword) {\n return cssKeywords[keyword];\n}\n\nfunction keyword2hsl(args) {\n return rgb2hsl(keyword2rgb(args));\n}\n\nfunction keyword2hsv(args) {\n return rgb2hsv(keyword2rgb(args));\n}\n\nfunction keyword2hwb(args) {\n return rgb2hwb(keyword2rgb(args));\n}\n\nfunction keyword2cmyk(args) {\n return rgb2cmyk(keyword2rgb(args));\n}\n\nfunction keyword2lab(args) {\n return rgb2lab(keyword2rgb(args));\n}\n\nfunction keyword2xyz(args) {\n return rgb2xyz(keyword2rgb(args));\n}\n\nvar cssKeywords = {\n aliceblue: [240,248,255],\n antiquewhite: [250,235,215],\n aqua: [0,255,255],\n aquamarine: [127,255,212],\n azure: [240,255,255],\n beige: [245,245,220],\n bisque: [255,228,196],\n black: [0,0,0],\n blanchedalmond: [255,235,205],\n blue: [0,0,255],\n blueviolet: [138,43,226],\n brown: [165,42,42],\n burlywood: [222,184,135],\n cadetblue: [95,158,160],\n chartreuse: [127,255,0],\n chocolate: [210,105,30],\n coral: [255,127,80],\n cornflowerblue: [100,149,237],\n cornsilk: [255,248,220],\n crimson: [220,20,60],\n cyan: [0,255,255],\n darkblue: [0,0,139],\n darkcyan: [0,139,139],\n darkgoldenrod: [184,134,11],\n darkgray: [169,169,169],\n darkgreen: [0,100,0],\n darkgrey: [169,169,169],\n darkkhaki: [189,183,107],\n darkmagenta: [139,0,139],\n darkolivegreen: [85,107,47],\n darkorange: [255,140,0],\n darkorchid: [153,50,204],\n darkred: [139,0,0],\n darksalmon: [233,150,122],\n darkseagreen: [143,188,143],\n darkslateblue: [72,61,139],\n darkslategray: [47,79,79],\n darkslategrey: [47,79,79],\n darkturquoise: [0,206,209],\n darkviolet: [148,0,211],\n deeppink: [255,20,147],\n deepskyblue: [0,191,255],\n dimgray: [105,105,105],\n dimgrey: [105,105,105],\n dodgerblue: [30,144,255],\n firebrick: [178,34,34],\n floralwhite: [255,250,240],\n forestgreen: [34,139,34],\n fuchsia: [255,0,255],\n gainsboro: [220,220,220],\n ghostwhite: [248,248,255],\n gold: [255,215,0],\n goldenrod: [218,165,32],\n gray: [128,128,128],\n green: [0,128,0],\n greenyellow: [173,255,47],\n grey: [128,128,128],\n honeydew: [240,255,240],\n hotpink: [255,105,180],\n indianred: [205,92,92],\n indigo: [75,0,130],\n ivory: [255,255,240],\n khaki: [240,230,140],\n lavender: [230,230,250],\n lavenderblush: [255,240,245],\n lawngreen: [124,252,0],\n lemonchiffon: [255,250,205],\n lightblue: [173,216,230],\n lightcoral: [240,128,128],\n lightcyan: [224,255,255],\n lightgoldenrodyellow: [250,250,210],\n lightgray: [211,211,211],\n lightgreen: [144,238,144],\n lightgrey: [211,211,211],\n lightpink: [255,182,193],\n lightsalmon: [255,160,122],\n lightseagreen: [32,178,170],\n lightskyblue: [135,206,250],\n lightslategray: [119,136,153],\n lightslategrey: [119,136,153],\n lightsteelblue: [176,196,222],\n lightyellow: [255,255,224],\n lime: [0,255,0],\n limegreen: [50,205,50],\n linen: [250,240,230],\n magenta: [255,0,255],\n maroon: [128,0,0],\n mediumaquamarine: [102,205,170],\n mediumblue: [0,0,205],\n mediumorchid: [186,85,211],\n mediumpurple: [147,112,219],\n mediumseagreen: [60,179,113],\n mediumslateblue: [123,104,238],\n mediumspringgreen: [0,250,154],\n mediumturquoise: [72,209,204],\n mediumvioletred: [199,21,133],\n midnightblue: [25,25,112],\n mintcream: [245,255,250],\n mistyrose: [255,228,225],\n moccasin: [255,228,181],\n navajowhite: [255,222,173],\n navy: [0,0,128],\n oldlace: [253,245,230],\n olive: [128,128,0],\n olivedrab: [107,142,35],\n orange: [255,165,0],\n orangered: [255,69,0],\n orchid: [218,112,214],\n palegoldenrod: [238,232,170],\n palegreen: [152,251,152],\n paleturquoise: [175,238,238],\n palevioletred: [219,112,147],\n papayawhip: [255,239,213],\n peachpuff: [255,218,185],\n peru: [205,133,63],\n pink: [255,192,203],\n plum: [221,160,221],\n powderblue: [176,224,230],\n purple: [128,0,128],\n rebeccapurple: [102, 51, 153],\n red: [255,0,0],\n rosybrown: [188,143,143],\n royalblue: [65,105,225],\n saddlebrown: [139,69,19],\n salmon: [250,128,114],\n sandybrown: [244,164,96],\n seagreen: [46,139,87],\n seashell: [255,245,238],\n sienna: [160,82,45],\n silver: [192,192,192],\n skyblue: [135,206,235],\n slateblue: [106,90,205],\n slategray: [112,128,144],\n slategrey: [112,128,144],\n snow: [255,250,250],\n springgreen: [0,255,127],\n steelblue: [70,130,180],\n tan: [210,180,140],\n teal: [0,128,128],\n thistle: [216,191,216],\n tomato: [255,99,71],\n turquoise: [64,224,208],\n violet: [238,130,238],\n wheat: [245,222,179],\n white: [255,255,255],\n whitesmoke: [245,245,245],\n yellow: [255,255,0],\n yellowgreen: [154,205,50]\n};\n\nvar reverseKeywords = {};\nfor (var key in cssKeywords) {\n reverseKeywords[JSON.stringify(cssKeywords[key])] = key;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/parse-color/~/color-convert/conversions.js\n// module id = 38\n// module chunks = 0","var conversions = require(\"./conversions\");\n\nvar convert = function() {\n return new Converter();\n}\n\nfor (var func in conversions) {\n // export Raw versions\n convert[func + \"Raw\"] = (function(func) {\n // accept array or plain args\n return function(arg) {\n if (typeof arg == \"number\")\n arg = Array.prototype.slice.call(arguments);\n return conversions[func](arg);\n }\n })(func);\n\n var pair = /(\\w+)2(\\w+)/.exec(func),\n from = pair[1],\n to = pair[2];\n\n // export rgb2hsl and [\"rgb\"][\"hsl\"]\n convert[from] = convert[from] || {};\n\n convert[from][to] = convert[func] = (function(func) { \n return function(arg) {\n if (typeof arg == \"number\")\n arg = Array.prototype.slice.call(arguments);\n \n var val = conversions[func](arg);\n if (typeof val == \"string\" || val === undefined)\n return val; // keyword\n\n for (var i = 0; i < val.length; i++)\n val[i] = Math.round(val[i]);\n return val;\n }\n })(func);\n}\n\n\n/* Converter does lazy conversion and caching */\nvar Converter = function() {\n this.convs = {};\n};\n\n/* Either get the values for a space or\n set the values for a space, depending on args */\nConverter.prototype.routeSpace = function(space, args) {\n var values = args[0];\n if (values === undefined) {\n // color.rgb()\n return this.getValues(space);\n }\n // color.rgb(10, 10, 10)\n if (typeof values == \"number\") {\n values = Array.prototype.slice.call(args); \n }\n\n return this.setValues(space, values);\n};\n \n/* Set the values for a space, invalidating cache */\nConverter.prototype.setValues = function(space, values) {\n this.space = space;\n this.convs = {};\n this.convs[space] = values;\n return this;\n};\n\n/* Get the values for a space. If there's already\n a conversion for the space, fetch it, otherwise\n compute it */\nConverter.prototype.getValues = function(space) {\n var vals = this.convs[space];\n if (!vals) {\n var fspace = this.space,\n from = this.convs[fspace];\n vals = convert[fspace][space](from);\n\n this.convs[space] = vals;\n }\n return vals;\n};\n\n[\"rgb\", \"hsl\", \"hsv\", \"cmyk\", \"keyword\"].forEach(function(space) {\n Converter.prototype[space] = function(vals) {\n return this.routeSpace(space, arguments);\n }\n});\n\nmodule.exports = convert;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/parse-color/~/color-convert/index.js\n// module id = 39\n// module chunks = 0","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.createREGL = factory());\n}(this, (function () { 'use strict';\n\nvar isTypedArray = function (x) {\n return (\n x instanceof Uint8Array ||\n x instanceof Uint16Array ||\n x instanceof Uint32Array ||\n x instanceof Int8Array ||\n x instanceof Int16Array ||\n x instanceof Int32Array ||\n x instanceof Float32Array ||\n x instanceof Float64Array ||\n x instanceof Uint8ClampedArray\n )\n}\n\nvar extend = function (base, opts) {\n var keys = Object.keys(opts)\n for (var i = 0; i < keys.length; ++i) {\n base[keys[i]] = opts[keys[i]]\n }\n return base\n}\n\n// Error checking and parameter validation.\n//\n// Statements for the form `check.someProcedure(...)` get removed by\n// a browserify transform for optimized/minified bundles.\n//\n/* globals atob */\nvar endl = '\\n'\n\n// only used for extracting shader names. if atob not present, then errors\n// will be slightly crappier\nfunction decodeB64 (str) {\n if (typeof atob !== 'undefined') {\n return atob(str)\n }\n return 'base64:' + str\n}\n\nfunction raise (message) {\n var error = new Error('(regl) ' + message)\n console.error(error)\n throw error\n}\n\nfunction check (pred, message) {\n if (!pred) {\n raise(message)\n }\n}\n\nfunction encolon (message) {\n if (message) {\n return ': ' + message\n }\n return ''\n}\n\nfunction checkParameter (param, possibilities, message) {\n if (!(param in possibilities)) {\n raise('unknown parameter (' + param + ')' + encolon(message) +\n '. possible values: ' + Object.keys(possibilities).join())\n }\n}\n\nfunction checkIsTypedArray (data, message) {\n if (!isTypedArray(data)) {\n raise(\n 'invalid parameter type' + encolon(message) +\n '. must be a typed array')\n }\n}\n\nfunction standardTypeEh (value, type) {\n switch (type) {\n case 'number': return typeof value === 'number'\n case 'object': return typeof value === 'object'\n case 'string': return typeof value === 'string'\n case 'boolean': return typeof value === 'boolean'\n case 'function': return typeof value === 'function'\n case 'undefined': return typeof value === 'undefined'\n case 'symbol': return typeof value === 'symbol'\n }\n}\n\nfunction checkTypeOf (value, type, message) {\n if (!standardTypeEh(value, type)) {\n raise(\n 'invalid parameter type' + encolon(message) +\n '. expected ' + type + ', got ' + (typeof value))\n }\n}\n\nfunction checkNonNegativeInt (value, message) {\n if (!((value >= 0) &&\n ((value | 0) === value))) {\n raise('invalid parameter type, (' + value + ')' + encolon(message) +\n '. must be a nonnegative integer')\n }\n}\n\nfunction checkOneOf (value, list, message) {\n if (list.indexOf(value) < 0) {\n raise('invalid value' + encolon(message) + '. must be one of: ' + list)\n }\n}\n\nvar constructorKeys = [\n 'gl',\n 'canvas',\n 'container',\n 'attributes',\n 'pixelRatio',\n 'extensions',\n 'optionalExtensions',\n 'profile',\n 'onDone'\n]\n\nfunction checkConstructor (obj) {\n Object.keys(obj).forEach(function (key) {\n if (constructorKeys.indexOf(key) < 0) {\n raise('invalid regl constructor argument \"' + key + '\". must be one of ' + constructorKeys)\n }\n })\n}\n\nfunction leftPad (str, n) {\n str = str + ''\n while (str.length < n) {\n str = ' ' + str\n }\n return str\n}\n\nfunction ShaderFile () {\n this.name = 'unknown'\n this.lines = []\n this.index = {}\n this.hasErrors = false\n}\n\nfunction ShaderLine (number, line) {\n this.number = number\n this.line = line\n this.errors = []\n}\n\nfunction ShaderError (fileNumber, lineNumber, message) {\n this.file = fileNumber\n this.line = lineNumber\n this.message = message\n}\n\nfunction guessCommand () {\n var error = new Error()\n var stack = (error.stack || error).toString()\n var pat = /compileProcedure.*\\n\\s*at.*\\((.*)\\)/.exec(stack)\n if (pat) {\n return pat[1]\n }\n var pat2 = /compileProcedure.*\\n\\s*at\\s+(.*)(\\n|$)/.exec(stack)\n if (pat2) {\n return pat2[1]\n }\n return 'unknown'\n}\n\nfunction guessCallSite () {\n var error = new Error()\n var stack = (error.stack || error).toString()\n var pat = /at REGLCommand.*\\n\\s+at.*\\((.*)\\)/.exec(stack)\n if (pat) {\n return pat[1]\n }\n var pat2 = /at REGLCommand.*\\n\\s+at\\s+(.*)\\n/.exec(stack)\n if (pat2) {\n return pat2[1]\n }\n return 'unknown'\n}\n\nfunction parseSource (source, command) {\n var lines = source.split('\\n')\n var lineNumber = 1\n var fileNumber = 0\n var files = {\n unknown: new ShaderFile(),\n 0: new ShaderFile()\n }\n files.unknown.name = files[0].name = command || guessCommand()\n files.unknown.lines.push(new ShaderLine(0, ''))\n for (var i = 0; i < lines.length; ++i) {\n var line = lines[i]\n var parts = /^\\s*#\\s*(\\w+)\\s+(.+)\\s*$/.exec(line)\n if (parts) {\n switch (parts[1]) {\n case 'line':\n var lineNumberInfo = /(\\d+)(\\s+\\d+)?/.exec(parts[2])\n if (lineNumberInfo) {\n lineNumber = lineNumberInfo[1] | 0\n if (lineNumberInfo[2]) {\n fileNumber = lineNumberInfo[2] | 0\n if (!(fileNumber in files)) {\n files[fileNumber] = new ShaderFile()\n }\n }\n }\n break\n case 'define':\n var nameInfo = /SHADER_NAME(_B64)?\\s+(.*)$/.exec(parts[2])\n if (nameInfo) {\n files[fileNumber].name = (nameInfo[1]\n ? decodeB64(nameInfo[2])\n : nameInfo[2])\n }\n break\n }\n }\n files[fileNumber].lines.push(new ShaderLine(lineNumber++, line))\n }\n Object.keys(files).forEach(function (fileNumber) {\n var file = files[fileNumber]\n file.lines.forEach(function (line) {\n file.index[line.number] = line\n })\n })\n return files\n}\n\nfunction parseErrorLog (errLog) {\n var result = []\n errLog.split('\\n').forEach(function (errMsg) {\n if (errMsg.length < 5) {\n return\n }\n var parts = /^ERROR:\\s+(\\d+):(\\d+):\\s*(.*)$/.exec(errMsg)\n if (parts) {\n result.push(new ShaderError(\n parts[1] | 0,\n parts[2] | 0,\n parts[3].trim()))\n } else if (errMsg.length > 0) {\n result.push(new ShaderError('unknown', 0, errMsg))\n }\n })\n return result\n}\n\nfunction annotateFiles (files, errors) {\n errors.forEach(function (error) {\n var file = files[error.file]\n if (file) {\n var line = file.index[error.line]\n if (line) {\n line.errors.push(error)\n file.hasErrors = true\n return\n }\n }\n files.unknown.hasErrors = true\n files.unknown.lines[0].errors.push(error)\n })\n}\n\nfunction checkShaderError (gl, shader, source, type, command) {\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n var errLog = gl.getShaderInfoLog(shader)\n var typeName = type === gl.FRAGMENT_SHADER ? 'fragment' : 'vertex'\n checkCommandType(source, 'string', typeName + ' shader source must be a string', command)\n var files = parseSource(source, command)\n var errors = parseErrorLog(errLog)\n annotateFiles(files, errors)\n\n Object.keys(files).forEach(function (fileNumber) {\n var file = files[fileNumber]\n if (!file.hasErrors) {\n return\n }\n\n var strings = ['']\n var styles = ['']\n\n function push (str, style) {\n strings.push(str)\n styles.push(style || '')\n }\n\n push('file number ' + fileNumber + ': ' + file.name + '\\n', 'color:red;text-decoration:underline;font-weight:bold')\n\n file.lines.forEach(function (line) {\n if (line.errors.length > 0) {\n push(leftPad(line.number, 4) + '| ', 'background-color:yellow; font-weight:bold')\n push(line.line + endl, 'color:red; background-color:yellow; font-weight:bold')\n\n // try to guess token\n var offset = 0\n line.errors.forEach(function (error) {\n var message = error.message\n var token = /^\\s*'(.*)'\\s*:\\s*(.*)$/.exec(message)\n if (token) {\n var tokenPat = token[1]\n message = token[2]\n switch (tokenPat) {\n case 'assign':\n tokenPat = '='\n break\n }\n offset = Math.max(line.line.indexOf(tokenPat, offset), 0)\n } else {\n offset = 0\n }\n\n push(leftPad('| ', 6))\n push(leftPad('^^^', offset + 3) + endl, 'font-weight:bold')\n push(leftPad('| ', 6))\n push(message + endl, 'font-weight:bold')\n })\n push(leftPad('| ', 6) + endl)\n } else {\n push(leftPad(line.number, 4) + '| ')\n push(line.line + endl, 'color:red')\n }\n })\n if (typeof document !== 'undefined' && !window.chrome) {\n styles[0] = strings.join('%c')\n console.log.apply(console, styles)\n } else {\n console.log(strings.join(''))\n }\n })\n\n check.raise('Error compiling ' + typeName + ' shader, ' + files[0].name)\n }\n}\n\nfunction checkLinkError (gl, program, fragShader, vertShader, command) {\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n var errLog = gl.getProgramInfoLog(program)\n var fragParse = parseSource(fragShader, command)\n var vertParse = parseSource(vertShader, command)\n\n var header = 'Error linking program with vertex shader, \"' +\n vertParse[0].name + '\", and fragment shader \"' + fragParse[0].name + '\"'\n\n if (typeof document !== 'undefined') {\n console.log('%c' + header + endl + '%c' + errLog,\n 'color:red;text-decoration:underline;font-weight:bold',\n 'color:red')\n } else {\n console.log(header + endl + errLog)\n }\n check.raise(header)\n }\n}\n\nfunction saveCommandRef (object) {\n object._commandRef = guessCommand()\n}\n\nfunction saveDrawCommandInfo (opts, uniforms, attributes, stringStore) {\n saveCommandRef(opts)\n\n function id (str) {\n if (str) {\n return stringStore.id(str)\n }\n return 0\n }\n opts._fragId = id(opts.static.frag)\n opts._vertId = id(opts.static.vert)\n\n function addProps (dict, set) {\n Object.keys(set).forEach(function (u) {\n dict[stringStore.id(u)] = true\n })\n }\n\n var uniformSet = opts._uniformSet = {}\n addProps(uniformSet, uniforms.static)\n addProps(uniformSet, uniforms.dynamic)\n\n var attributeSet = opts._attributeSet = {}\n addProps(attributeSet, attributes.static)\n addProps(attributeSet, attributes.dynamic)\n\n opts._hasCount = (\n 'count' in opts.static ||\n 'count' in opts.dynamic ||\n 'elements' in opts.static ||\n 'elements' in opts.dynamic)\n}\n\nfunction commandRaise (message, command) {\n var callSite = guessCallSite()\n raise(message +\n ' in command ' + (command || guessCommand()) +\n (callSite === 'unknown' ? '' : ' called from ' + callSite))\n}\n\nfunction checkCommand (pred, message, command) {\n if (!pred) {\n commandRaise(message, command || guessCommand())\n }\n}\n\nfunction checkParameterCommand (param, possibilities, message, command) {\n if (!(param in possibilities)) {\n commandRaise(\n 'unknown parameter (' + param + ')' + encolon(message) +\n '. possible values: ' + Object.keys(possibilities).join(),\n command || guessCommand())\n }\n}\n\nfunction checkCommandType (value, type, message, command) {\n if (!standardTypeEh(value, type)) {\n commandRaise(\n 'invalid parameter type' + encolon(message) +\n '. expected ' + type + ', got ' + (typeof value),\n command || guessCommand())\n }\n}\n\nfunction checkOptional (block) {\n block()\n}\n\nfunction checkFramebufferFormat (attachment, texFormats, rbFormats) {\n if (attachment.texture) {\n checkOneOf(\n attachment.texture._texture.internalformat,\n texFormats,\n 'unsupported texture format for attachment')\n } else {\n checkOneOf(\n attachment.renderbuffer._renderbuffer.format,\n rbFormats,\n 'unsupported renderbuffer format for attachment')\n }\n}\n\nvar GL_CLAMP_TO_EDGE = 0x812F\n\nvar GL_NEAREST = 0x2600\nvar GL_NEAREST_MIPMAP_NEAREST = 0x2700\nvar GL_LINEAR_MIPMAP_NEAREST = 0x2701\nvar GL_NEAREST_MIPMAP_LINEAR = 0x2702\nvar GL_LINEAR_MIPMAP_LINEAR = 0x2703\n\nvar GL_BYTE = 5120\nvar GL_UNSIGNED_BYTE = 5121\nvar GL_SHORT = 5122\nvar GL_UNSIGNED_SHORT = 5123\nvar GL_INT = 5124\nvar GL_UNSIGNED_INT = 5125\nvar GL_FLOAT = 5126\n\nvar GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033\nvar GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034\nvar GL_UNSIGNED_SHORT_5_6_5 = 0x8363\nvar GL_UNSIGNED_INT_24_8_WEBGL = 0x84FA\n\nvar GL_HALF_FLOAT_OES = 0x8D61\n\nvar TYPE_SIZE = {}\n\nTYPE_SIZE[GL_BYTE] =\nTYPE_SIZE[GL_UNSIGNED_BYTE] = 1\n\nTYPE_SIZE[GL_SHORT] =\nTYPE_SIZE[GL_UNSIGNED_SHORT] =\nTYPE_SIZE[GL_HALF_FLOAT_OES] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_5_6_5] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_4_4_4_4] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_5_5_5_1] = 2\n\nTYPE_SIZE[GL_INT] =\nTYPE_SIZE[GL_UNSIGNED_INT] =\nTYPE_SIZE[GL_FLOAT] =\nTYPE_SIZE[GL_UNSIGNED_INT_24_8_WEBGL] = 4\n\nfunction pixelSize (type, channels) {\n if (type === GL_UNSIGNED_SHORT_5_5_5_1 ||\n type === GL_UNSIGNED_SHORT_4_4_4_4 ||\n type === GL_UNSIGNED_SHORT_5_6_5) {\n return 2\n } else if (type === GL_UNSIGNED_INT_24_8_WEBGL) {\n return 4\n } else {\n return TYPE_SIZE[type] * channels\n }\n}\n\nfunction isPow2 (v) {\n return !(v & (v - 1)) && (!!v)\n}\n\nfunction checkTexture2D (info, mipData, limits) {\n var i\n var w = mipData.width\n var h = mipData.height\n var c = mipData.channels\n\n // Check texture shape\n check(w > 0 && w <= limits.maxTextureSize &&\n h > 0 && h <= limits.maxTextureSize,\n 'invalid texture shape')\n\n // check wrap mode\n if (info.wrapS !== GL_CLAMP_TO_EDGE || info.wrapT !== GL_CLAMP_TO_EDGE) {\n check(isPow2(w) && isPow2(h),\n 'incompatible wrap mode for texture, both width and height must be power of 2')\n }\n\n if (mipData.mipmask === 1) {\n if (w !== 1 && h !== 1) {\n check(\n info.minFilter !== GL_NEAREST_MIPMAP_NEAREST &&\n info.minFilter !== GL_NEAREST_MIPMAP_LINEAR &&\n info.minFilter !== GL_LINEAR_MIPMAP_NEAREST &&\n info.minFilter !== GL_LINEAR_MIPMAP_LINEAR,\n 'min filter requires mipmap')\n }\n } else {\n // texture must be power of 2\n check(isPow2(w) && isPow2(h),\n 'texture must be a square power of 2 to support mipmapping')\n check(mipData.mipmask === (w << 1) - 1,\n 'missing or incomplete mipmap data')\n }\n\n if (mipData.type === GL_FLOAT) {\n if (limits.extensions.indexOf('oes_texture_float_linear') < 0) {\n check(info.minFilter === GL_NEAREST && info.magFilter === GL_NEAREST,\n 'filter not supported, must enable oes_texture_float_linear')\n }\n check(!info.genMipmaps,\n 'mipmap generation not supported with float textures')\n }\n\n // check image complete\n var mipimages = mipData.images\n for (i = 0; i < 16; ++i) {\n if (mipimages[i]) {\n var mw = w >> i\n var mh = h >> i\n check(mipData.mipmask & (1 << i), 'missing mipmap data')\n\n var img = mipimages[i]\n\n check(\n img.width === mw &&\n img.height === mh,\n 'invalid shape for mip images')\n\n check(\n img.format === mipData.format &&\n img.internalformat === mipData.internalformat &&\n img.type === mipData.type,\n 'incompatible type for mip image')\n\n if (img.compressed) {\n // TODO: check size for compressed images\n } else if (img.data) {\n // check(img.data.byteLength === mw * mh *\n // Math.max(pixelSize(img.type, c), img.unpackAlignment),\n var rowSize = Math.ceil(pixelSize(img.type, c) * mw / img.unpackAlignment) * img.unpackAlignment\n check(img.data.byteLength === rowSize * mh,\n 'invalid data for image, buffer size is inconsistent with image format')\n } else if (img.element) {\n // TODO: check element can be loaded\n } else if (img.copy) {\n // TODO: check compatible format and type\n }\n } else if (!info.genMipmaps) {\n check((mipData.mipmask & (1 << i)) === 0, 'extra mipmap data')\n }\n }\n\n if (mipData.compressed) {\n check(!info.genMipmaps,\n 'mipmap generation for compressed images not supported')\n }\n}\n\nfunction checkTextureCube (texture, info, faces, limits) {\n var w = texture.width\n var h = texture.height\n var c = texture.channels\n\n // Check texture shape\n check(\n w > 0 && w <= limits.maxTextureSize && h > 0 && h <= limits.maxTextureSize,\n 'invalid texture shape')\n check(\n w === h,\n 'cube map must be square')\n check(\n info.wrapS === GL_CLAMP_TO_EDGE && info.wrapT === GL_CLAMP_TO_EDGE,\n 'wrap mode not supported by cube map')\n\n for (var i = 0; i < faces.length; ++i) {\n var face = faces[i]\n check(\n face.width === w && face.height === h,\n 'inconsistent cube map face shape')\n\n if (info.genMipmaps) {\n check(!face.compressed,\n 'can not generate mipmap for compressed textures')\n check(face.mipmask === 1,\n 'can not specify mipmaps and generate mipmaps')\n } else {\n // TODO: check mip and filter mode\n }\n\n var mipmaps = face.images\n for (var j = 0; j < 16; ++j) {\n var img = mipmaps[j]\n if (img) {\n var mw = w >> j\n var mh = h >> j\n check(face.mipmask & (1 << j), 'missing mipmap data')\n check(\n img.width === mw &&\n img.height === mh,\n 'invalid shape for mip images')\n check(\n img.format === texture.format &&\n img.internalformat === texture.internalformat &&\n img.type === texture.type,\n 'incompatible type for mip image')\n\n if (img.compressed) {\n // TODO: check size for compressed images\n } else if (img.data) {\n check(img.data.byteLength === mw * mh *\n Math.max(pixelSize(img.type, c), img.unpackAlignment),\n 'invalid data for image, buffer size is inconsistent with image format')\n } else if (img.element) {\n // TODO: check element can be loaded\n } else if (img.copy) {\n // TODO: check compatible format and type\n }\n }\n }\n }\n}\n\nvar check$1 = extend(check, {\n optional: checkOptional,\n raise: raise,\n commandRaise: commandRaise,\n command: checkCommand,\n parameter: checkParameter,\n commandParameter: checkParameterCommand,\n constructor: checkConstructor,\n type: checkTypeOf,\n commandType: checkCommandType,\n isTypedArray: checkIsTypedArray,\n nni: checkNonNegativeInt,\n oneOf: checkOneOf,\n shaderError: checkShaderError,\n linkError: checkLinkError,\n callSite: guessCallSite,\n saveCommandRef: saveCommandRef,\n saveDrawInfo: saveDrawCommandInfo,\n framebufferFormat: checkFramebufferFormat,\n guessCommand: guessCommand,\n texture2D: checkTexture2D,\n textureCube: checkTextureCube\n});\n\nvar VARIABLE_COUNTER = 0\n\nvar DYN_FUNC = 0\nvar DYN_CONSTANT = 5\nvar DYN_ARRAY = 6\n\nfunction DynamicVariable (type, data) {\n this.id = (VARIABLE_COUNTER++)\n this.type = type\n this.data = data\n}\n\nfunction escapeStr (str) {\n return str.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n}\n\nfunction splitParts (str) {\n if (str.length === 0) {\n return []\n }\n\n var firstChar = str.charAt(0)\n var lastChar = str.charAt(str.length - 1)\n\n if (str.length > 1 &&\n firstChar === lastChar &&\n (firstChar === '\"' || firstChar === \"'\")) {\n return ['\"' + escapeStr(str.substr(1, str.length - 2)) + '\"']\n }\n\n var parts = /\\[(false|true|null|\\d+|'[^']*'|\"[^\"]*\")\\]/.exec(str)\n if (parts) {\n return (\n splitParts(str.substr(0, parts.index))\n .concat(splitParts(parts[1]))\n .concat(splitParts(str.substr(parts.index + parts[0].length)))\n )\n }\n\n var subparts = str.split('.')\n if (subparts.length === 1) {\n return ['\"' + escapeStr(str) + '\"']\n }\n\n var result = []\n for (var i = 0; i < subparts.length; ++i) {\n result = result.concat(splitParts(subparts[i]))\n }\n return result\n}\n\nfunction toAccessorString (str) {\n return '[' + splitParts(str).join('][') + ']'\n}\n\nfunction defineDynamic (type, data) {\n return new DynamicVariable(type, toAccessorString(data + ''))\n}\n\nfunction isDynamic (x) {\n return (typeof x === 'function' && !x._reglType) || (x instanceof DynamicVariable)\n}\n\nfunction unbox (x, path) {\n if (typeof x === 'function') {\n return new DynamicVariable(DYN_FUNC, x)\n } else if (typeof x === 'number' || typeof x === 'boolean') {\n return new DynamicVariable(DYN_CONSTANT, x)\n } else if (Array.isArray(x)) {\n return new DynamicVariable(DYN_ARRAY, x.map((y, i) => unbox(y, path + '[' + i + ']')))\n } else if (x instanceof DynamicVariable) {\n return x\n }\n check$1(false, 'invalid option type in uniform ' + path)\n}\n\nvar dynamic = {\n DynamicVariable: DynamicVariable,\n define: defineDynamic,\n isDynamic: isDynamic,\n unbox: unbox,\n accessor: toAccessorString\n};\n\n/* globals requestAnimationFrame, cancelAnimationFrame */\nvar raf = {\n next: typeof requestAnimationFrame === 'function'\n ? function (cb) { return requestAnimationFrame(cb) }\n : function (cb) { return setTimeout(cb, 16) },\n cancel: typeof cancelAnimationFrame === 'function'\n ? function (raf) { return cancelAnimationFrame(raf) }\n : clearTimeout\n};\n\n/* globals performance */\nvar clock = (typeof performance !== 'undefined' && performance.now)\n ? function () { return performance.now() }\n : function () { return +(new Date()) };\n\nfunction createStringStore () {\n var stringIds = { '': 0 }\n var stringValues = ['']\n return {\n id: function (str) {\n var result = stringIds[str]\n if (result) {\n return result\n }\n result = stringIds[str] = stringValues.length\n stringValues.push(str)\n return result\n },\n\n str: function (id) {\n return stringValues[id]\n }\n }\n}\n\n// Context and canvas creation helper functions\nfunction createCanvas (element, onDone, pixelRatio) {\n var canvas = document.createElement('canvas')\n extend(canvas.style, {\n border: 0,\n margin: 0,\n padding: 0,\n top: 0,\n left: 0\n })\n element.appendChild(canvas)\n\n if (element === document.body) {\n canvas.style.position = 'absolute'\n extend(element.style, {\n margin: 0,\n padding: 0\n })\n }\n\n function resize () {\n var w = window.innerWidth\n var h = window.innerHeight\n if (element !== document.body) {\n var bounds = element.getBoundingClientRect()\n w = bounds.right - bounds.left\n h = bounds.bottom - bounds.top\n }\n canvas.width = pixelRatio * w\n canvas.height = pixelRatio * h\n extend(canvas.style, {\n width: w + 'px',\n height: h + 'px'\n })\n }\n\n var resizeObserver\n if (element !== document.body && typeof ResizeObserver === 'function') {\n // ignore 'ResizeObserver' is not defined\n // eslint-disable-next-line\n resizeObserver = new ResizeObserver(function () {\n // setTimeout to avoid flicker\n setTimeout(resize)\n })\n resizeObserver.observe(element)\n } else {\n window.addEventListener('resize', resize, false)\n }\n\n function onDestroy () {\n if (resizeObserver) {\n resizeObserver.disconnect()\n } else {\n window.removeEventListener('resize', resize)\n }\n element.removeChild(canvas)\n }\n\n resize()\n\n return {\n canvas: canvas,\n onDestroy: onDestroy\n }\n}\n\nfunction createContext (canvas, contextAttributes) {\n function get (name) {\n try {\n return canvas.getContext(name, contextAttributes)\n } catch (e) {\n return null\n }\n }\n return (\n get('webgl') ||\n get('experimental-webgl') ||\n get('webgl-experimental')\n )\n}\n\nfunction isHTMLElement (obj) {\n return (\n typeof obj.nodeName === 'string' &&\n typeof obj.appendChild === 'function' &&\n typeof obj.getBoundingClientRect === 'function'\n )\n}\n\nfunction isWebGLContext (obj) {\n return (\n typeof obj.drawArrays === 'function' ||\n typeof obj.drawElements === 'function'\n )\n}\n\nfunction parseExtensions (input) {\n if (typeof input === 'string') {\n return input.split()\n }\n check$1(Array.isArray(input), 'invalid extension array')\n return input\n}\n\nfunction getElement (desc) {\n if (typeof desc === 'string') {\n check$1(typeof document !== 'undefined', 'not supported outside of DOM')\n return document.querySelector(desc)\n }\n return desc\n}\n\nfunction parseArgs (args_) {\n var args = args_ || {}\n var element, container, canvas, gl\n var contextAttributes = {}\n var extensions = []\n var optionalExtensions = []\n var pixelRatio = (typeof window === 'undefined' ? 1 : window.devicePixelRatio)\n var profile = false\n var onDone = function (err) {\n if (err) {\n check$1.raise(err)\n }\n }\n var onDestroy = function () {}\n if (typeof args === 'string') {\n check$1(\n typeof document !== 'undefined',\n 'selector queries only supported in DOM enviroments')\n element = document.querySelector(args)\n check$1(element, 'invalid query string for element')\n } else if (typeof args === 'object') {\n if (isHTMLElement(args)) {\n element = args\n } else if (isWebGLContext(args)) {\n gl = args\n canvas = gl.canvas\n } else {\n check$1.constructor(args)\n if ('gl' in args) {\n gl = args.gl\n } else if ('canvas' in args) {\n canvas = getElement(args.canvas)\n } else if ('container' in args) {\n container = getElement(args.container)\n }\n if ('attributes' in args) {\n contextAttributes = args.attributes\n check$1.type(contextAttributes, 'object', 'invalid context attributes')\n }\n if ('extensions' in args) {\n extensions = parseExtensions(args.extensions)\n }\n if ('optionalExtensions' in args) {\n optionalExtensions = parseExtensions(args.optionalExtensions)\n }\n if ('onDone' in args) {\n check$1.type(\n args.onDone, 'function',\n 'invalid or missing onDone callback')\n onDone = args.onDone\n }\n if ('profile' in args) {\n profile = !!args.profile\n }\n if ('pixelRatio' in args) {\n pixelRatio = +args.pixelRatio\n check$1(pixelRatio > 0, 'invalid pixel ratio')\n }\n }\n } else {\n check$1.raise('invalid arguments to regl')\n }\n\n if (element) {\n if (element.nodeName.toLowerCase() === 'canvas') {\n canvas = element\n } else {\n container = element\n }\n }\n\n if (!gl) {\n if (!canvas) {\n check$1(\n typeof document !== 'undefined',\n 'must manually specify webgl context outside of DOM environments')\n var result = createCanvas(container || document.body, onDone, pixelRatio)\n if (!result) {\n return null\n }\n canvas = result.canvas\n onDestroy = result.onDestroy\n }\n // workaround for chromium bug, premultiplied alpha value is platform dependent\n if (contextAttributes.premultipliedAlpha === undefined) contextAttributes.premultipliedAlpha = true\n gl = createContext(canvas, contextAttributes)\n }\n\n if (!gl) {\n onDestroy()\n onDone('webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org')\n return null\n }\n\n return {\n gl: gl,\n canvas: canvas,\n container: container,\n extensions: extensions,\n optionalExtensions: optionalExtensions,\n pixelRatio: pixelRatio,\n profile: profile,\n onDone: onDone,\n onDestroy: onDestroy\n }\n}\n\nfunction createExtensionCache (gl, config) {\n var extensions = {}\n\n function tryLoadExtension (name_) {\n check$1.type(name_, 'string', 'extension name must be string')\n var name = name_.toLowerCase()\n var ext\n try {\n ext = extensions[name] = gl.getExtension(name)\n } catch (e) {}\n return !!ext\n }\n\n for (var i = 0; i < config.extensions.length; ++i) {\n var name = config.extensions[i]\n if (!tryLoadExtension(name)) {\n config.onDestroy()\n config.onDone('\"' + name + '\" extension is not supported by the current WebGL context, try upgrading your system or a different browser')\n return null\n }\n }\n\n config.optionalExtensions.forEach(tryLoadExtension)\n\n return {\n extensions: extensions,\n restore: function () {\n Object.keys(extensions).forEach(function (name) {\n if (extensions[name] && !tryLoadExtension(name)) {\n throw new Error('(regl): error restoring extension ' + name)\n }\n })\n }\n }\n}\n\nfunction loop (n, f) {\n var result = Array(n)\n for (var i = 0; i < n; ++i) {\n result[i] = f(i)\n }\n return result\n}\n\nvar GL_BYTE$1 = 5120\nvar GL_UNSIGNED_BYTE$2 = 5121\nvar GL_SHORT$1 = 5122\nvar GL_UNSIGNED_SHORT$1 = 5123\nvar GL_INT$1 = 5124\nvar GL_UNSIGNED_INT$1 = 5125\nvar GL_FLOAT$2 = 5126\n\nfunction nextPow16 (v) {\n for (var i = 16; i <= (1 << 28); i *= 16) {\n if (v <= i) {\n return i\n }\n }\n return 0\n}\n\nfunction log2 (v) {\n var r, shift\n r = (v > 0xFFFF) << 4\n v >>>= r\n shift = (v > 0xFF) << 3\n v >>>= shift; r |= shift\n shift = (v > 0xF) << 2\n v >>>= shift; r |= shift\n shift = (v > 0x3) << 1\n v >>>= shift; r |= shift\n return r | (v >> 1)\n}\n\nfunction createPool () {\n var bufferPool = loop(8, function () {\n return []\n })\n\n function alloc (n) {\n var sz = nextPow16(n)\n var bin = bufferPool[log2(sz) >> 2]\n if (bin.length > 0) {\n return bin.pop()\n }\n return new ArrayBuffer(sz)\n }\n\n function free (buf) {\n bufferPool[log2(buf.byteLength) >> 2].push(buf)\n }\n\n function allocType (type, n) {\n var result = null\n switch (type) {\n case GL_BYTE$1:\n result = new Int8Array(alloc(n), 0, n)\n break\n case GL_UNSIGNED_BYTE$2:\n result = new Uint8Array(alloc(n), 0, n)\n break\n case GL_SHORT$1:\n result = new Int16Array(alloc(2 * n), 0, n)\n break\n case GL_UNSIGNED_SHORT$1:\n result = new Uint16Array(alloc(2 * n), 0, n)\n break\n case GL_INT$1:\n result = new Int32Array(alloc(4 * n), 0, n)\n break\n case GL_UNSIGNED_INT$1:\n result = new Uint32Array(alloc(4 * n), 0, n)\n break\n case GL_FLOAT$2:\n result = new Float32Array(alloc(4 * n), 0, n)\n break\n default:\n return null\n }\n if (result.length !== n) {\n return result.subarray(0, n)\n }\n return result\n }\n\n function freeType (array) {\n free(array.buffer)\n }\n\n return {\n alloc: alloc,\n free: free,\n allocType: allocType,\n freeType: freeType\n }\n}\n\nvar pool = createPool()\n\n// zero pool for initial zero data\npool.zero = createPool()\n\nvar GL_SUBPIXEL_BITS = 0x0D50\nvar GL_RED_BITS = 0x0D52\nvar GL_GREEN_BITS = 0x0D53\nvar GL_BLUE_BITS = 0x0D54\nvar GL_ALPHA_BITS = 0x0D55\nvar GL_DEPTH_BITS = 0x0D56\nvar GL_STENCIL_BITS = 0x0D57\n\nvar GL_ALIASED_POINT_SIZE_RANGE = 0x846D\nvar GL_ALIASED_LINE_WIDTH_RANGE = 0x846E\n\nvar GL_MAX_TEXTURE_SIZE = 0x0D33\nvar GL_MAX_VIEWPORT_DIMS = 0x0D3A\nvar GL_MAX_VERTEX_ATTRIBS = 0x8869\nvar GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB\nvar GL_MAX_VARYING_VECTORS = 0x8DFC\nvar GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D\nvar GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C\nvar GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872\nvar GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD\nvar GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C\nvar GL_MAX_RENDERBUFFER_SIZE = 0x84E8\n\nvar GL_VENDOR = 0x1F00\nvar GL_RENDERER = 0x1F01\nvar GL_VERSION = 0x1F02\nvar GL_SHADING_LANGUAGE_VERSION = 0x8B8C\n\nvar GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF\n\nvar GL_MAX_COLOR_ATTACHMENTS_WEBGL = 0x8CDF\nvar GL_MAX_DRAW_BUFFERS_WEBGL = 0x8824\n\nvar GL_TEXTURE_2D = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP = 0x8513\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515\nvar GL_TEXTURE0 = 0x84C0\nvar GL_RGBA = 0x1908\nvar GL_FLOAT$1 = 0x1406\nvar GL_UNSIGNED_BYTE$1 = 0x1401\nvar GL_FRAMEBUFFER = 0x8D40\nvar GL_FRAMEBUFFER_COMPLETE = 0x8CD5\nvar GL_COLOR_ATTACHMENT0 = 0x8CE0\nvar GL_COLOR_BUFFER_BIT$1 = 0x4000\n\nvar wrapLimits = function (gl, extensions) {\n var maxAnisotropic = 1\n if (extensions.ext_texture_filter_anisotropic) {\n maxAnisotropic = gl.getParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)\n }\n\n var maxDrawbuffers = 1\n var maxColorAttachments = 1\n if (extensions.webgl_draw_buffers) {\n maxDrawbuffers = gl.getParameter(GL_MAX_DRAW_BUFFERS_WEBGL)\n maxColorAttachments = gl.getParameter(GL_MAX_COLOR_ATTACHMENTS_WEBGL)\n }\n\n // detect if reading float textures is available (Safari doesn't support)\n var readFloat = !!extensions.oes_texture_float\n if (readFloat) {\n var readFloatTexture = gl.createTexture()\n gl.bindTexture(GL_TEXTURE_2D, readFloatTexture)\n gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_FLOAT$1, null)\n\n var fbo = gl.createFramebuffer()\n gl.bindFramebuffer(GL_FRAMEBUFFER, fbo)\n gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, readFloatTexture, 0)\n gl.bindTexture(GL_TEXTURE_2D, null)\n\n if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) !== GL_FRAMEBUFFER_COMPLETE) readFloat = false\n\n else {\n gl.viewport(0, 0, 1, 1)\n gl.clearColor(1.0, 0.0, 0.0, 1.0)\n gl.clear(GL_COLOR_BUFFER_BIT$1)\n var pixels = pool.allocType(GL_FLOAT$1, 4)\n gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT$1, pixels)\n\n if (gl.getError()) readFloat = false\n else {\n gl.deleteFramebuffer(fbo)\n gl.deleteTexture(readFloatTexture)\n\n readFloat = pixels[0] === 1.0\n }\n\n pool.freeType(pixels)\n }\n }\n\n // detect non power of two cube textures support (IE doesn't support)\n var isIE = typeof navigator !== 'undefined' && (/MSIE/.test(navigator.userAgent) || /Trident\\//.test(navigator.appVersion) || /Edge/.test(navigator.userAgent))\n\n var npotTextureCube = true\n\n if (!isIE) {\n var cubeTexture = gl.createTexture()\n var data = pool.allocType(GL_UNSIGNED_BYTE$1, 36)\n gl.activeTexture(GL_TEXTURE0)\n gl.bindTexture(GL_TEXTURE_CUBE_MAP, cubeTexture)\n gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE$1, data)\n pool.freeType(data)\n gl.bindTexture(GL_TEXTURE_CUBE_MAP, null)\n gl.deleteTexture(cubeTexture)\n npotTextureCube = !gl.getError()\n }\n\n return {\n // drawing buffer bit depth\n colorBits: [\n gl.getParameter(GL_RED_BITS),\n gl.getParameter(GL_GREEN_BITS),\n gl.getParameter(GL_BLUE_BITS),\n gl.getParameter(GL_ALPHA_BITS)\n ],\n depthBits: gl.getParameter(GL_DEPTH_BITS),\n stencilBits: gl.getParameter(GL_STENCIL_BITS),\n subpixelBits: gl.getParameter(GL_SUBPIXEL_BITS),\n\n // supported extensions\n extensions: Object.keys(extensions).filter(function (ext) {\n return !!extensions[ext]\n }),\n\n // max aniso samples\n maxAnisotropic: maxAnisotropic,\n\n // max draw buffers\n maxDrawbuffers: maxDrawbuffers,\n maxColorAttachments: maxColorAttachments,\n\n // point and line size ranges\n pointSizeDims: gl.getParameter(GL_ALIASED_POINT_SIZE_RANGE),\n lineWidthDims: gl.getParameter(GL_ALIASED_LINE_WIDTH_RANGE),\n maxViewportDims: gl.getParameter(GL_MAX_VIEWPORT_DIMS),\n maxCombinedTextureUnits: gl.getParameter(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n maxCubeMapSize: gl.getParameter(GL_MAX_CUBE_MAP_TEXTURE_SIZE),\n maxRenderbufferSize: gl.getParameter(GL_MAX_RENDERBUFFER_SIZE),\n maxTextureUnits: gl.getParameter(GL_MAX_TEXTURE_IMAGE_UNITS),\n maxTextureSize: gl.getParameter(GL_MAX_TEXTURE_SIZE),\n maxAttributes: gl.getParameter(GL_MAX_VERTEX_ATTRIBS),\n maxVertexUniforms: gl.getParameter(GL_MAX_VERTEX_UNIFORM_VECTORS),\n maxVertexTextureUnits: gl.getParameter(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS),\n maxVaryingVectors: gl.getParameter(GL_MAX_VARYING_VECTORS),\n maxFragmentUniforms: gl.getParameter(GL_MAX_FRAGMENT_UNIFORM_VECTORS),\n\n // vendor info\n glsl: gl.getParameter(GL_SHADING_LANGUAGE_VERSION),\n renderer: gl.getParameter(GL_RENDERER),\n vendor: gl.getParameter(GL_VENDOR),\n version: gl.getParameter(GL_VERSION),\n\n // quirks\n readFloat: readFloat,\n npotTextureCube: npotTextureCube\n }\n}\n\nfunction isNDArrayLike (obj) {\n return (\n !!obj &&\n typeof obj === 'object' &&\n Array.isArray(obj.shape) &&\n Array.isArray(obj.stride) &&\n typeof obj.offset === 'number' &&\n obj.shape.length === obj.stride.length &&\n (Array.isArray(obj.data) ||\n isTypedArray(obj.data)))\n}\n\nvar values = function (obj) {\n return Object.keys(obj).map(function (key) { return obj[key] })\n}\n\nvar flattenUtils = {\n shape: arrayShape$1,\n flatten: flattenArray\n};\n\nfunction flatten1D (array, nx, out) {\n for (var i = 0; i < nx; ++i) {\n out[i] = array[i]\n }\n}\n\nfunction flatten2D (array, nx, ny, out) {\n var ptr = 0\n for (var i = 0; i < nx; ++i) {\n var row = array[i]\n for (var j = 0; j < ny; ++j) {\n out[ptr++] = row[j]\n }\n }\n}\n\nfunction flatten3D (array, nx, ny, nz, out, ptr_) {\n var ptr = ptr_\n for (var i = 0; i < nx; ++i) {\n var row = array[i]\n for (var j = 0; j < ny; ++j) {\n var col = row[j]\n for (var k = 0; k < nz; ++k) {\n out[ptr++] = col[k]\n }\n }\n }\n}\n\nfunction flattenRec (array, shape, level, out, ptr) {\n var stride = 1\n for (var i = level + 1; i < shape.length; ++i) {\n stride *= shape[i]\n }\n var n = shape[level]\n if (shape.length - level === 4) {\n var nx = shape[level + 1]\n var ny = shape[level + 2]\n var nz = shape[level + 3]\n for (i = 0; i < n; ++i) {\n flatten3D(array[i], nx, ny, nz, out, ptr)\n ptr += stride\n }\n } else {\n for (i = 0; i < n; ++i) {\n flattenRec(array[i], shape, level + 1, out, ptr)\n ptr += stride\n }\n }\n}\n\nfunction flattenArray (array, shape, type, out_) {\n var sz = 1\n if (shape.length) {\n for (var i = 0; i < shape.length; ++i) {\n sz *= shape[i]\n }\n } else {\n sz = 0\n }\n var out = out_ || pool.allocType(type, sz)\n switch (shape.length) {\n case 0:\n break\n case 1:\n flatten1D(array, shape[0], out)\n break\n case 2:\n flatten2D(array, shape[0], shape[1], out)\n break\n case 3:\n flatten3D(array, shape[0], shape[1], shape[2], out, 0)\n break\n default:\n flattenRec(array, shape, 0, out, 0)\n }\n return out\n}\n\nfunction arrayShape$1 (array_) {\n var shape = []\n for (var array = array_; array.length; array = array[0]) {\n shape.push(array.length)\n }\n return shape\n}\n\nvar arrayTypes = {\n\t\"[object Int8Array]\": 5120,\n\t\"[object Int16Array]\": 5122,\n\t\"[object Int32Array]\": 5124,\n\t\"[object Uint8Array]\": 5121,\n\t\"[object Uint8ClampedArray]\": 5121,\n\t\"[object Uint16Array]\": 5123,\n\t\"[object Uint32Array]\": 5125,\n\t\"[object Float32Array]\": 5126,\n\t\"[object Float64Array]\": 5121,\n\t\"[object ArrayBuffer]\": 5121\n};\n\nvar int8 = 5120;\nvar int16 = 5122;\nvar int32 = 5124;\nvar uint8 = 5121;\nvar uint16 = 5123;\nvar uint32 = 5125;\nvar float = 5126;\nvar float32 = 5126;\nvar glTypes = {\n\tint8: int8,\n\tint16: int16,\n\tint32: int32,\n\tuint8: uint8,\n\tuint16: uint16,\n\tuint32: uint32,\n\tfloat: float,\n\tfloat32: float32\n};\n\nvar dynamic$1 = 35048;\nvar stream = 35040;\nvar usageTypes = {\n\tdynamic: dynamic$1,\n\tstream: stream,\n\t\"static\": 35044\n};\n\nvar arrayFlatten = flattenUtils.flatten\nvar arrayShape = flattenUtils.shape\n\nvar GL_STATIC_DRAW = 0x88E4\nvar GL_STREAM_DRAW = 0x88E0\n\nvar GL_UNSIGNED_BYTE$3 = 5121\nvar GL_FLOAT$3 = 5126\n\nvar DTYPES_SIZES = []\nDTYPES_SIZES[5120] = 1 // int8\nDTYPES_SIZES[5122] = 2 // int16\nDTYPES_SIZES[5124] = 4 // int32\nDTYPES_SIZES[5121] = 1 // uint8\nDTYPES_SIZES[5123] = 2 // uint16\nDTYPES_SIZES[5125] = 4 // uint32\nDTYPES_SIZES[5126] = 4 // float32\n\nfunction typedArrayCode (data) {\n return arrayTypes[Object.prototype.toString.call(data)] | 0\n}\n\nfunction copyArray (out, inp) {\n for (var i = 0; i < inp.length; ++i) {\n out[i] = inp[i]\n }\n}\n\nfunction transpose (\n result, data, shapeX, shapeY, strideX, strideY, offset) {\n var ptr = 0\n for (var i = 0; i < shapeX; ++i) {\n for (var j = 0; j < shapeY; ++j) {\n result[ptr++] = data[strideX * i + strideY * j + offset]\n }\n }\n}\n\nfunction wrapBufferState (gl, stats, config, destroyBuffer) {\n var bufferCount = 0\n var bufferSet = {}\n\n function REGLBuffer (type) {\n this.id = bufferCount++\n this.buffer = gl.createBuffer()\n this.type = type\n this.usage = GL_STATIC_DRAW\n this.byteLength = 0\n this.dimension = 1\n this.dtype = GL_UNSIGNED_BYTE$3\n\n this.persistentData = null\n\n if (config.profile) {\n this.stats = { size: 0 }\n }\n }\n\n REGLBuffer.prototype.bind = function () {\n gl.bindBuffer(this.type, this.buffer)\n }\n\n REGLBuffer.prototype.destroy = function () {\n destroy(this)\n }\n\n var streamPool = []\n\n function createStream (type, data) {\n var buffer = streamPool.pop()\n if (!buffer) {\n buffer = new REGLBuffer(type)\n }\n buffer.bind()\n initBufferFromData(buffer, data, GL_STREAM_DRAW, 0, 1, false)\n return buffer\n }\n\n function destroyStream (stream$$1) {\n streamPool.push(stream$$1)\n }\n\n function initBufferFromTypedArray (buffer, data, usage) {\n buffer.byteLength = data.byteLength\n gl.bufferData(buffer.type, data, usage)\n }\n\n function initBufferFromData (buffer, data, usage, dtype, dimension, persist) {\n var shape\n buffer.usage = usage\n if (Array.isArray(data)) {\n buffer.dtype = dtype || GL_FLOAT$3\n if (data.length > 0) {\n var flatData\n if (Array.isArray(data[0])) {\n shape = arrayShape(data)\n var dim = 1\n for (var i = 1; i < shape.length; ++i) {\n dim *= shape[i]\n }\n buffer.dimension = dim\n flatData = arrayFlatten(data, shape, buffer.dtype)\n initBufferFromTypedArray(buffer, flatData, usage)\n if (persist) {\n buffer.persistentData = flatData\n } else {\n pool.freeType(flatData)\n }\n } else if (typeof data[0] === 'number') {\n buffer.dimension = dimension\n var typedData = pool.allocType(buffer.dtype, data.length)\n copyArray(typedData, data)\n initBufferFromTypedArray(buffer, typedData, usage)\n if (persist) {\n buffer.persistentData = typedData\n } else {\n pool.freeType(typedData)\n }\n } else if (isTypedArray(data[0])) {\n buffer.dimension = data[0].length\n buffer.dtype = dtype || typedArrayCode(data[0]) || GL_FLOAT$3\n flatData = arrayFlatten(\n data,\n [data.length, data[0].length],\n buffer.dtype)\n initBufferFromTypedArray(buffer, flatData, usage)\n if (persist) {\n buffer.persistentData = flatData\n } else {\n pool.freeType(flatData)\n }\n } else {\n check$1.raise('invalid buffer data')\n }\n }\n } else if (isTypedArray(data)) {\n buffer.dtype = dtype || typedArrayCode(data)\n buffer.dimension = dimension\n initBufferFromTypedArray(buffer, data, usage)\n if (persist) {\n buffer.persistentData = new Uint8Array(new Uint8Array(data.buffer))\n }\n } else if (isNDArrayLike(data)) {\n shape = data.shape\n var stride = data.stride\n var offset = data.offset\n\n var shapeX = 0\n var shapeY = 0\n var strideX = 0\n var strideY = 0\n if (shape.length === 1) {\n shapeX = shape[0]\n shapeY = 1\n strideX = stride[0]\n strideY = 0\n } else if (shape.length === 2) {\n shapeX = shape[0]\n shapeY = shape[1]\n strideX = stride[0]\n strideY = stride[1]\n } else {\n check$1.raise('invalid shape')\n }\n\n buffer.dtype = dtype || typedArrayCode(data.data) || GL_FLOAT$3\n buffer.dimension = shapeY\n\n var transposeData = pool.allocType(buffer.dtype, shapeX * shapeY)\n transpose(transposeData,\n data.data,\n shapeX, shapeY,\n strideX, strideY,\n offset)\n initBufferFromTypedArray(buffer, transposeData, usage)\n if (persist) {\n buffer.persistentData = transposeData\n } else {\n pool.freeType(transposeData)\n }\n } else if (data instanceof ArrayBuffer) {\n buffer.dtype = GL_UNSIGNED_BYTE$3\n buffer.dimension = dimension\n initBufferFromTypedArray(buffer, data, usage)\n if (persist) {\n buffer.persistentData = new Uint8Array(new Uint8Array(data))\n }\n } else {\n check$1.raise('invalid buffer data')\n }\n }\n\n function destroy (buffer) {\n stats.bufferCount--\n\n // remove attribute link\n destroyBuffer(buffer)\n\n var handle = buffer.buffer\n check$1(handle, 'buffer must not be deleted already')\n gl.deleteBuffer(handle)\n buffer.buffer = null\n delete bufferSet[buffer.id]\n }\n\n function createBuffer (options, type, deferInit, persistent) {\n stats.bufferCount++\n\n var buffer = new REGLBuffer(type)\n bufferSet[buffer.id] = buffer\n\n function reglBuffer (options) {\n var usage = GL_STATIC_DRAW\n var data = null\n var byteLength = 0\n var dtype = 0\n var dimension = 1\n if (Array.isArray(options) ||\n isTypedArray(options) ||\n isNDArrayLike(options) ||\n options instanceof ArrayBuffer) {\n data = options\n } else if (typeof options === 'number') {\n byteLength = options | 0\n } else if (options) {\n check$1.type(\n options, 'object',\n 'buffer arguments must be an object, a number or an array')\n\n if ('data' in options) {\n check$1(\n data === null ||\n Array.isArray(data) ||\n isTypedArray(data) ||\n isNDArrayLike(data),\n 'invalid data for buffer')\n data = options.data\n }\n\n if ('usage' in options) {\n check$1.parameter(options.usage, usageTypes, 'invalid buffer usage')\n usage = usageTypes[options.usage]\n }\n\n if ('type' in options) {\n check$1.parameter(options.type, glTypes, 'invalid buffer type')\n dtype = glTypes[options.type]\n }\n\n if ('dimension' in options) {\n check$1.type(options.dimension, 'number', 'invalid dimension')\n dimension = options.dimension | 0\n }\n\n if ('length' in options) {\n check$1.nni(byteLength, 'buffer length must be a nonnegative integer')\n byteLength = options.length | 0\n }\n }\n\n buffer.bind()\n if (!data) {\n // #475\n if (byteLength) gl.bufferData(buffer.type, byteLength, usage)\n buffer.dtype = dtype || GL_UNSIGNED_BYTE$3\n buffer.usage = usage\n buffer.dimension = dimension\n buffer.byteLength = byteLength\n } else {\n initBufferFromData(buffer, data, usage, dtype, dimension, persistent)\n }\n\n if (config.profile) {\n buffer.stats.size = buffer.byteLength * DTYPES_SIZES[buffer.dtype]\n }\n\n return reglBuffer\n }\n\n function setSubData (data, offset) {\n check$1(offset + data.byteLength <= buffer.byteLength,\n 'invalid buffer subdata call, buffer is too small. ' + ' Can\\'t write data of size ' + data.byteLength + ' starting from offset ' + offset + ' to a buffer of size ' + buffer.byteLength)\n\n gl.bufferSubData(buffer.type, offset, data)\n }\n\n function subdata (data, offset_) {\n var offset = (offset_ || 0) | 0\n var shape\n buffer.bind()\n if (isTypedArray(data) || data instanceof ArrayBuffer) {\n setSubData(data, offset)\n } else if (Array.isArray(data)) {\n if (data.length > 0) {\n if (typeof data[0] === 'number') {\n var converted = pool.allocType(buffer.dtype, data.length)\n copyArray(converted, data)\n setSubData(converted, offset)\n pool.freeType(converted)\n } else if (Array.isArray(data[0]) || isTypedArray(data[0])) {\n shape = arrayShape(data)\n var flatData = arrayFlatten(data, shape, buffer.dtype)\n setSubData(flatData, offset)\n pool.freeType(flatData)\n } else {\n check$1.raise('invalid buffer data')\n }\n }\n } else if (isNDArrayLike(data)) {\n shape = data.shape\n var stride = data.stride\n\n var shapeX = 0\n var shapeY = 0\n var strideX = 0\n var strideY = 0\n if (shape.length === 1) {\n shapeX = shape[0]\n shapeY = 1\n strideX = stride[0]\n strideY = 0\n } else if (shape.length === 2) {\n shapeX = shape[0]\n shapeY = shape[1]\n strideX = stride[0]\n strideY = stride[1]\n } else {\n check$1.raise('invalid shape')\n }\n var dtype = Array.isArray(data.data)\n ? buffer.dtype\n : typedArrayCode(data.data)\n\n var transposeData = pool.allocType(dtype, shapeX * shapeY)\n transpose(transposeData,\n data.data,\n shapeX, shapeY,\n strideX, strideY,\n data.offset)\n setSubData(transposeData, offset)\n pool.freeType(transposeData)\n } else {\n check$1.raise('invalid data for buffer subdata')\n }\n return reglBuffer\n }\n\n if (!deferInit) {\n reglBuffer(options)\n }\n\n reglBuffer._reglType = 'buffer'\n reglBuffer._buffer = buffer\n reglBuffer.subdata = subdata\n if (config.profile) {\n reglBuffer.stats = buffer.stats\n }\n reglBuffer.destroy = function () { destroy(buffer) }\n\n return reglBuffer\n }\n\n function restoreBuffers () {\n values(bufferSet).forEach(function (buffer) {\n buffer.buffer = gl.createBuffer()\n gl.bindBuffer(buffer.type, buffer.buffer)\n gl.bufferData(\n buffer.type, buffer.persistentData || buffer.byteLength, buffer.usage)\n })\n }\n\n if (config.profile) {\n stats.getTotalBufferSize = function () {\n var total = 0\n // TODO: Right now, the streams are not part of the total count.\n Object.keys(bufferSet).forEach(function (key) {\n total += bufferSet[key].stats.size\n })\n return total\n }\n }\n\n return {\n create: createBuffer,\n\n createStream: createStream,\n destroyStream: destroyStream,\n\n clear: function () {\n values(bufferSet).forEach(destroy)\n streamPool.forEach(destroy)\n },\n\n getBuffer: function (wrapper) {\n if (wrapper && wrapper._buffer instanceof REGLBuffer) {\n return wrapper._buffer\n }\n return null\n },\n\n restore: restoreBuffers,\n\n _initBuffer: initBufferFromData\n }\n}\n\nvar points = 0;\nvar point = 0;\nvar lines = 1;\nvar line = 1;\nvar triangles = 4;\nvar triangle = 4;\nvar primTypes = {\n\tpoints: points,\n\tpoint: point,\n\tlines: lines,\n\tline: line,\n\ttriangles: triangles,\n\ttriangle: triangle,\n\t\"line loop\": 2,\n\t\"line strip\": 3,\n\t\"triangle strip\": 5,\n\t\"triangle fan\": 6\n};\n\nvar GL_POINTS = 0\nvar GL_LINES = 1\nvar GL_TRIANGLES = 4\n\nvar GL_BYTE$2 = 5120\nvar GL_UNSIGNED_BYTE$4 = 5121\nvar GL_SHORT$2 = 5122\nvar GL_UNSIGNED_SHORT$2 = 5123\nvar GL_INT$2 = 5124\nvar GL_UNSIGNED_INT$2 = 5125\n\nvar GL_ELEMENT_ARRAY_BUFFER = 34963\n\nvar GL_STREAM_DRAW$1 = 0x88E0\nvar GL_STATIC_DRAW$1 = 0x88E4\n\nfunction wrapElementsState (gl, extensions, bufferState, stats) {\n var elementSet = {}\n var elementCount = 0\n\n var elementTypes = {\n 'uint8': GL_UNSIGNED_BYTE$4,\n 'uint16': GL_UNSIGNED_SHORT$2\n }\n\n if (extensions.oes_element_index_uint) {\n elementTypes.uint32 = GL_UNSIGNED_INT$2\n }\n\n function REGLElementBuffer (buffer) {\n this.id = elementCount++\n elementSet[this.id] = this\n this.buffer = buffer\n this.primType = GL_TRIANGLES\n this.vertCount = 0\n this.type = 0\n }\n\n REGLElementBuffer.prototype.bind = function () {\n this.buffer.bind()\n }\n\n var bufferPool = []\n\n function createElementStream (data) {\n var result = bufferPool.pop()\n if (!result) {\n result = new REGLElementBuffer(bufferState.create(\n null,\n GL_ELEMENT_ARRAY_BUFFER,\n true,\n false)._buffer)\n }\n initElements(result, data, GL_STREAM_DRAW$1, -1, -1, 0, 0)\n return result\n }\n\n function destroyElementStream (elements) {\n bufferPool.push(elements)\n }\n\n function initElements (\n elements,\n data,\n usage,\n prim,\n count,\n byteLength,\n type) {\n elements.buffer.bind()\n var dtype\n if (data) {\n var predictedType = type\n if (!type && (\n !isTypedArray(data) ||\n (isNDArrayLike(data) && !isTypedArray(data.data)))) {\n predictedType = extensions.oes_element_index_uint\n ? GL_UNSIGNED_INT$2\n : GL_UNSIGNED_SHORT$2\n }\n bufferState._initBuffer(\n elements.buffer,\n data,\n usage,\n predictedType,\n 3)\n } else {\n gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, byteLength, usage)\n elements.buffer.dtype = dtype || GL_UNSIGNED_BYTE$4\n elements.buffer.usage = usage\n elements.buffer.dimension = 3\n elements.buffer.byteLength = byteLength\n }\n\n dtype = type\n if (!type) {\n switch (elements.buffer.dtype) {\n case GL_UNSIGNED_BYTE$4:\n case GL_BYTE$2:\n dtype = GL_UNSIGNED_BYTE$4\n break\n\n case GL_UNSIGNED_SHORT$2:\n case GL_SHORT$2:\n dtype = GL_UNSIGNED_SHORT$2\n break\n\n case GL_UNSIGNED_INT$2:\n case GL_INT$2:\n dtype = GL_UNSIGNED_INT$2\n break\n\n default:\n check$1.raise('unsupported type for element array')\n }\n elements.buffer.dtype = dtype\n }\n elements.type = dtype\n\n // Check oes_element_index_uint extension\n check$1(\n dtype !== GL_UNSIGNED_INT$2 ||\n !!extensions.oes_element_index_uint,\n '32 bit element buffers not supported, enable oes_element_index_uint first')\n\n // try to guess default primitive type and arguments\n var vertCount = count\n if (vertCount < 0) {\n vertCount = elements.buffer.byteLength\n if (dtype === GL_UNSIGNED_SHORT$2) {\n vertCount >>= 1\n } else if (dtype === GL_UNSIGNED_INT$2) {\n vertCount >>= 2\n }\n }\n elements.vertCount = vertCount\n\n // try to guess primitive type from cell dimension\n var primType = prim\n if (prim < 0) {\n primType = GL_TRIANGLES\n var dimension = elements.buffer.dimension\n if (dimension === 1) primType = GL_POINTS\n if (dimension === 2) primType = GL_LINES\n if (dimension === 3) primType = GL_TRIANGLES\n }\n elements.primType = primType\n }\n\n function destroyElements (elements) {\n stats.elementsCount--\n\n check$1(elements.buffer !== null, 'must not double destroy elements')\n delete elementSet[elements.id]\n elements.buffer.destroy()\n elements.buffer = null\n }\n\n function createElements (options, persistent) {\n var buffer = bufferState.create(null, GL_ELEMENT_ARRAY_BUFFER, true)\n var elements = new REGLElementBuffer(buffer._buffer)\n stats.elementsCount++\n\n function reglElements (options) {\n if (!options) {\n buffer()\n elements.primType = GL_TRIANGLES\n elements.vertCount = 0\n elements.type = GL_UNSIGNED_BYTE$4\n } else if (typeof options === 'number') {\n buffer(options)\n elements.primType = GL_TRIANGLES\n elements.vertCount = options | 0\n elements.type = GL_UNSIGNED_BYTE$4\n } else {\n var data = null\n var usage = GL_STATIC_DRAW$1\n var primType = -1\n var vertCount = -1\n var byteLength = 0\n var dtype = 0\n if (Array.isArray(options) ||\n isTypedArray(options) ||\n isNDArrayLike(options)) {\n data = options\n } else {\n check$1.type(options, 'object', 'invalid arguments for elements')\n if ('data' in options) {\n data = options.data\n check$1(\n Array.isArray(data) ||\n isTypedArray(data) ||\n isNDArrayLike(data),\n 'invalid data for element buffer')\n }\n if ('usage' in options) {\n check$1.parameter(\n options.usage,\n usageTypes,\n 'invalid element buffer usage')\n usage = usageTypes[options.usage]\n }\n if ('primitive' in options) {\n check$1.parameter(\n options.primitive,\n primTypes,\n 'invalid element buffer primitive')\n primType = primTypes[options.primitive]\n }\n if ('count' in options) {\n check$1(\n typeof options.count === 'number' && options.count >= 0,\n 'invalid vertex count for elements')\n vertCount = options.count | 0\n }\n if ('type' in options) {\n check$1.parameter(\n options.type,\n elementTypes,\n 'invalid buffer type')\n dtype = elementTypes[options.type]\n }\n if ('length' in options) {\n byteLength = options.length | 0\n } else {\n byteLength = vertCount\n if (dtype === GL_UNSIGNED_SHORT$2 || dtype === GL_SHORT$2) {\n byteLength *= 2\n } else if (dtype === GL_UNSIGNED_INT$2 || dtype === GL_INT$2) {\n byteLength *= 4\n }\n }\n }\n initElements(\n elements,\n data,\n usage,\n primType,\n vertCount,\n byteLength,\n dtype)\n }\n\n return reglElements\n }\n\n reglElements(options)\n\n reglElements._reglType = 'elements'\n reglElements._elements = elements\n reglElements.subdata = function (data, offset) {\n buffer.subdata(data, offset)\n return reglElements\n }\n reglElements.destroy = function () {\n destroyElements(elements)\n }\n\n return reglElements\n }\n\n return {\n create: createElements,\n createStream: createElementStream,\n destroyStream: destroyElementStream,\n getElements: function (elements) {\n if (typeof elements === 'function' &&\n elements._elements instanceof REGLElementBuffer) {\n return elements._elements\n }\n return null\n },\n clear: function () {\n values(elementSet).forEach(destroyElements)\n }\n }\n}\n\nvar FLOAT = new Float32Array(1)\nvar INT = new Uint32Array(FLOAT.buffer)\n\nvar GL_UNSIGNED_SHORT$4 = 5123\n\nfunction convertToHalfFloat (array) {\n var ushorts = pool.allocType(GL_UNSIGNED_SHORT$4, array.length)\n\n for (var i = 0; i < array.length; ++i) {\n if (isNaN(array[i])) {\n ushorts[i] = 0xffff\n } else if (array[i] === Infinity) {\n ushorts[i] = 0x7c00\n } else if (array[i] === -Infinity) {\n ushorts[i] = 0xfc00\n } else {\n FLOAT[0] = array[i]\n var x = INT[0]\n\n var sgn = (x >>> 31) << 15\n var exp = ((x << 1) >>> 24) - 127\n var frac = (x >> 13) & ((1 << 10) - 1)\n\n if (exp < -24) {\n // round non-representable denormals to 0\n ushorts[i] = sgn\n } else if (exp < -14) {\n // handle denormals\n var s = -14 - exp\n ushorts[i] = sgn + ((frac + (1 << 10)) >> s)\n } else if (exp > 15) {\n // round overflow to +/- Infinity\n ushorts[i] = sgn + 0x7c00\n } else {\n // otherwise convert directly\n ushorts[i] = sgn + ((exp + 15) << 10) + frac\n }\n }\n }\n\n return ushorts\n}\n\nfunction isArrayLike (s) {\n return Array.isArray(s) || isTypedArray(s)\n}\n\nvar isPow2$1 = function (v) {\n return !(v & (v - 1)) && (!!v)\n}\n\nvar GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3\n\nvar GL_TEXTURE_2D$1 = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP$1 = 0x8513\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 = 0x8515\n\nvar GL_RGBA$1 = 0x1908\nvar GL_ALPHA = 0x1906\nvar GL_RGB = 0x1907\nvar GL_LUMINANCE = 0x1909\nvar GL_LUMINANCE_ALPHA = 0x190A\n\nvar GL_RGBA4 = 0x8056\nvar GL_RGB5_A1 = 0x8057\nvar GL_RGB565 = 0x8D62\n\nvar GL_UNSIGNED_SHORT_4_4_4_4$1 = 0x8033\nvar GL_UNSIGNED_SHORT_5_5_5_1$1 = 0x8034\nvar GL_UNSIGNED_SHORT_5_6_5$1 = 0x8363\nvar GL_UNSIGNED_INT_24_8_WEBGL$1 = 0x84FA\n\nvar GL_DEPTH_COMPONENT = 0x1902\nvar GL_DEPTH_STENCIL = 0x84F9\n\nvar GL_SRGB_EXT = 0x8C40\nvar GL_SRGB_ALPHA_EXT = 0x8C42\n\nvar GL_HALF_FLOAT_OES$1 = 0x8D61\n\nvar GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0\nvar GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1\nvar GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2\nvar GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3\n\nvar GL_COMPRESSED_RGB_ATC_WEBGL = 0x8C92\nvar GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93\nvar GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE\n\nvar GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00\nvar GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01\nvar GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02\nvar GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03\n\nvar GL_COMPRESSED_RGB_ETC1_WEBGL = 0x8D64\n\nvar GL_UNSIGNED_BYTE$5 = 0x1401\nvar GL_UNSIGNED_SHORT$3 = 0x1403\nvar GL_UNSIGNED_INT$3 = 0x1405\nvar GL_FLOAT$4 = 0x1406\n\nvar GL_TEXTURE_WRAP_S = 0x2802\nvar GL_TEXTURE_WRAP_T = 0x2803\n\nvar GL_REPEAT = 0x2901\nvar GL_CLAMP_TO_EDGE$1 = 0x812F\nvar GL_MIRRORED_REPEAT = 0x8370\n\nvar GL_TEXTURE_MAG_FILTER = 0x2800\nvar GL_TEXTURE_MIN_FILTER = 0x2801\n\nvar GL_NEAREST$1 = 0x2600\nvar GL_LINEAR = 0x2601\nvar GL_NEAREST_MIPMAP_NEAREST$1 = 0x2700\nvar GL_LINEAR_MIPMAP_NEAREST$1 = 0x2701\nvar GL_NEAREST_MIPMAP_LINEAR$1 = 0x2702\nvar GL_LINEAR_MIPMAP_LINEAR$1 = 0x2703\n\nvar GL_GENERATE_MIPMAP_HINT = 0x8192\nvar GL_DONT_CARE = 0x1100\nvar GL_FASTEST = 0x1101\nvar GL_NICEST = 0x1102\n\nvar GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE\n\nvar GL_UNPACK_ALIGNMENT = 0x0CF5\nvar GL_UNPACK_FLIP_Y_WEBGL = 0x9240\nvar GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241\nvar GL_UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243\n\nvar GL_BROWSER_DEFAULT_WEBGL = 0x9244\n\nvar GL_TEXTURE0$1 = 0x84C0\n\nvar MIPMAP_FILTERS = [\n GL_NEAREST_MIPMAP_NEAREST$1,\n GL_NEAREST_MIPMAP_LINEAR$1,\n GL_LINEAR_MIPMAP_NEAREST$1,\n GL_LINEAR_MIPMAP_LINEAR$1\n]\n\nvar CHANNELS_FORMAT = [\n 0,\n GL_LUMINANCE,\n GL_LUMINANCE_ALPHA,\n GL_RGB,\n GL_RGBA$1\n]\n\nvar FORMAT_CHANNELS = {}\nFORMAT_CHANNELS[GL_LUMINANCE] =\nFORMAT_CHANNELS[GL_ALPHA] =\nFORMAT_CHANNELS[GL_DEPTH_COMPONENT] = 1\nFORMAT_CHANNELS[GL_DEPTH_STENCIL] =\nFORMAT_CHANNELS[GL_LUMINANCE_ALPHA] = 2\nFORMAT_CHANNELS[GL_RGB] =\nFORMAT_CHANNELS[GL_SRGB_EXT] = 3\nFORMAT_CHANNELS[GL_RGBA$1] =\nFORMAT_CHANNELS[GL_SRGB_ALPHA_EXT] = 4\n\nfunction objectName (str) {\n return '[object ' + str + ']'\n}\n\nvar CANVAS_CLASS = objectName('HTMLCanvasElement')\nvar OFFSCREENCANVAS_CLASS = objectName('OffscreenCanvas')\nvar CONTEXT2D_CLASS = objectName('CanvasRenderingContext2D')\nvar BITMAP_CLASS = objectName('ImageBitmap')\nvar IMAGE_CLASS = objectName('HTMLImageElement')\nvar VIDEO_CLASS = objectName('HTMLVideoElement')\n\nvar PIXEL_CLASSES = Object.keys(arrayTypes).concat([\n CANVAS_CLASS,\n OFFSCREENCANVAS_CLASS,\n CONTEXT2D_CLASS,\n BITMAP_CLASS,\n IMAGE_CLASS,\n VIDEO_CLASS\n])\n\n// for every texture type, store\n// the size in bytes.\nvar TYPE_SIZES = []\nTYPE_SIZES[GL_UNSIGNED_BYTE$5] = 1\nTYPE_SIZES[GL_FLOAT$4] = 4\nTYPE_SIZES[GL_HALF_FLOAT_OES$1] = 2\n\nTYPE_SIZES[GL_UNSIGNED_SHORT$3] = 2\nTYPE_SIZES[GL_UNSIGNED_INT$3] = 4\n\nvar FORMAT_SIZES_SPECIAL = []\nFORMAT_SIZES_SPECIAL[GL_RGBA4] = 2\nFORMAT_SIZES_SPECIAL[GL_RGB5_A1] = 2\nFORMAT_SIZES_SPECIAL[GL_RGB565] = 2\nFORMAT_SIZES_SPECIAL[GL_DEPTH_STENCIL] = 4\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_S3TC_DXT1_EXT] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT] = 1\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT] = 1\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ATC_WEBGL] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 1\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 1\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 0.25\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 0.25\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ETC1_WEBGL] = 0.5\n\nfunction isNumericArray (arr) {\n return (\n Array.isArray(arr) &&\n (arr.length === 0 ||\n typeof arr[0] === 'number'))\n}\n\nfunction isRectArray (arr) {\n if (!Array.isArray(arr)) {\n return false\n }\n var width = arr.length\n if (width === 0 || !isArrayLike(arr[0])) {\n return false\n }\n return true\n}\n\nfunction classString (x) {\n return Object.prototype.toString.call(x)\n}\n\nfunction isCanvasElement (object) {\n return classString(object) === CANVAS_CLASS\n}\n\nfunction isOffscreenCanvas (object) {\n return classString(object) === OFFSCREENCANVAS_CLASS\n}\n\nfunction isContext2D (object) {\n return classString(object) === CONTEXT2D_CLASS\n}\n\nfunction isBitmap (object) {\n return classString(object) === BITMAP_CLASS\n}\n\nfunction isImageElement (object) {\n return classString(object) === IMAGE_CLASS\n}\n\nfunction isVideoElement (object) {\n return classString(object) === VIDEO_CLASS\n}\n\nfunction isPixelData (object) {\n if (!object) {\n return false\n }\n var className = classString(object)\n if (PIXEL_CLASSES.indexOf(className) >= 0) {\n return true\n }\n return (\n isNumericArray(object) ||\n isRectArray(object) ||\n isNDArrayLike(object))\n}\n\nfunction typedArrayCode$1 (data) {\n return arrayTypes[Object.prototype.toString.call(data)] | 0\n}\n\nfunction convertData (result, data) {\n var n = data.length\n switch (result.type) {\n case GL_UNSIGNED_BYTE$5:\n case GL_UNSIGNED_SHORT$3:\n case GL_UNSIGNED_INT$3:\n case GL_FLOAT$4:\n var converted = pool.allocType(result.type, n)\n converted.set(data)\n result.data = converted\n break\n\n case GL_HALF_FLOAT_OES$1:\n result.data = convertToHalfFloat(data)\n break\n\n default:\n check$1.raise('unsupported texture type, must specify a typed array')\n }\n}\n\nfunction preConvert (image, n) {\n return pool.allocType(\n image.type === GL_HALF_FLOAT_OES$1\n ? GL_FLOAT$4\n : image.type, n)\n}\n\nfunction postConvert (image, data) {\n if (image.type === GL_HALF_FLOAT_OES$1) {\n image.data = convertToHalfFloat(data)\n pool.freeType(data)\n } else {\n image.data = data\n }\n}\n\nfunction transposeData (image, array, strideX, strideY, strideC, offset) {\n var w = image.width\n var h = image.height\n var c = image.channels\n var n = w * h * c\n var data = preConvert(image, n)\n\n var p = 0\n for (var i = 0; i < h; ++i) {\n for (var j = 0; j < w; ++j) {\n for (var k = 0; k < c; ++k) {\n data[p++] = array[strideX * j + strideY * i + strideC * k + offset]\n }\n }\n }\n\n postConvert(image, data)\n}\n\nfunction getTextureSize (format, type, width, height, isMipmap, isCube) {\n var s\n if (typeof FORMAT_SIZES_SPECIAL[format] !== 'undefined') {\n // we have a special array for dealing with weird color formats such as RGB5A1\n s = FORMAT_SIZES_SPECIAL[format]\n } else {\n s = FORMAT_CHANNELS[format] * TYPE_SIZES[type]\n }\n\n if (isCube) {\n s *= 6\n }\n\n if (isMipmap) {\n // compute the total size of all the mipmaps.\n var total = 0\n\n var w = width\n while (w >= 1) {\n // we can only use mipmaps on a square image,\n // so we can simply use the width and ignore the height:\n total += s * w * w\n w /= 2\n }\n return total\n } else {\n return s * width * height\n }\n}\n\nfunction createTextureSet (\n gl, extensions, limits, reglPoll, contextState, stats, config) {\n // -------------------------------------------------------\n // Initialize constants and parameter tables here\n // -------------------------------------------------------\n var mipmapHint = {\n \"don't care\": GL_DONT_CARE,\n 'dont care': GL_DONT_CARE,\n 'nice': GL_NICEST,\n 'fast': GL_FASTEST\n }\n\n var wrapModes = {\n 'repeat': GL_REPEAT,\n 'clamp': GL_CLAMP_TO_EDGE$1,\n 'mirror': GL_MIRRORED_REPEAT\n }\n\n var magFilters = {\n 'nearest': GL_NEAREST$1,\n 'linear': GL_LINEAR\n }\n\n var minFilters = extend({\n 'mipmap': GL_LINEAR_MIPMAP_LINEAR$1,\n 'nearest mipmap nearest': GL_NEAREST_MIPMAP_NEAREST$1,\n 'linear mipmap nearest': GL_LINEAR_MIPMAP_NEAREST$1,\n 'nearest mipmap linear': GL_NEAREST_MIPMAP_LINEAR$1,\n 'linear mipmap linear': GL_LINEAR_MIPMAP_LINEAR$1\n }, magFilters)\n\n var colorSpace = {\n 'none': 0,\n 'browser': GL_BROWSER_DEFAULT_WEBGL\n }\n\n var textureTypes = {\n 'uint8': GL_UNSIGNED_BYTE$5,\n 'rgba4': GL_UNSIGNED_SHORT_4_4_4_4$1,\n 'rgb565': GL_UNSIGNED_SHORT_5_6_5$1,\n 'rgb5 a1': GL_UNSIGNED_SHORT_5_5_5_1$1\n }\n\n var textureFormats = {\n 'alpha': GL_ALPHA,\n 'luminance': GL_LUMINANCE,\n 'luminance alpha': GL_LUMINANCE_ALPHA,\n 'rgb': GL_RGB,\n 'rgba': GL_RGBA$1,\n 'rgba4': GL_RGBA4,\n 'rgb5 a1': GL_RGB5_A1,\n 'rgb565': GL_RGB565\n }\n\n var compressedTextureFormats = {}\n\n if (extensions.ext_srgb) {\n textureFormats.srgb = GL_SRGB_EXT\n textureFormats.srgba = GL_SRGB_ALPHA_EXT\n }\n\n if (extensions.oes_texture_float) {\n textureTypes.float32 = textureTypes.float = GL_FLOAT$4\n }\n\n if (extensions.oes_texture_half_float) {\n textureTypes['float16'] = textureTypes['half float'] = GL_HALF_FLOAT_OES$1\n }\n\n if (extensions.webgl_depth_texture) {\n extend(textureFormats, {\n 'depth': GL_DEPTH_COMPONENT,\n 'depth stencil': GL_DEPTH_STENCIL\n })\n\n extend(textureTypes, {\n 'uint16': GL_UNSIGNED_SHORT$3,\n 'uint32': GL_UNSIGNED_INT$3,\n 'depth stencil': GL_UNSIGNED_INT_24_8_WEBGL$1\n })\n }\n\n if (extensions.webgl_compressed_texture_s3tc) {\n extend(compressedTextureFormats, {\n 'rgb s3tc dxt1': GL_COMPRESSED_RGB_S3TC_DXT1_EXT,\n 'rgba s3tc dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,\n 'rgba s3tc dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,\n 'rgba s3tc dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\n })\n }\n\n if (extensions.webgl_compressed_texture_atc) {\n extend(compressedTextureFormats, {\n 'rgb atc': GL_COMPRESSED_RGB_ATC_WEBGL,\n 'rgba atc explicit alpha': GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,\n 'rgba atc interpolated alpha': GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL\n })\n }\n\n if (extensions.webgl_compressed_texture_pvrtc) {\n extend(compressedTextureFormats, {\n 'rgb pvrtc 4bppv1': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,\n 'rgb pvrtc 2bppv1': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,\n 'rgba pvrtc 4bppv1': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,\n 'rgba pvrtc 2bppv1': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG\n })\n }\n\n if (extensions.webgl_compressed_texture_etc1) {\n compressedTextureFormats['rgb etc1'] = GL_COMPRESSED_RGB_ETC1_WEBGL\n }\n\n // Copy over all texture formats\n var supportedCompressedFormats = Array.prototype.slice.call(\n gl.getParameter(GL_COMPRESSED_TEXTURE_FORMATS))\n Object.keys(compressedTextureFormats).forEach(function (name) {\n var format = compressedTextureFormats[name]\n if (supportedCompressedFormats.indexOf(format) >= 0) {\n textureFormats[name] = format\n }\n })\n\n var supportedFormats = Object.keys(textureFormats)\n limits.textureFormats = supportedFormats\n\n // associate with every format string its\n // corresponding GL-value.\n var textureFormatsInvert = []\n Object.keys(textureFormats).forEach(function (key) {\n var val = textureFormats[key]\n textureFormatsInvert[val] = key\n })\n\n // associate with every type string its\n // corresponding GL-value.\n var textureTypesInvert = []\n Object.keys(textureTypes).forEach(function (key) {\n var val = textureTypes[key]\n textureTypesInvert[val] = key\n })\n\n var magFiltersInvert = []\n Object.keys(magFilters).forEach(function (key) {\n var val = magFilters[key]\n magFiltersInvert[val] = key\n })\n\n var minFiltersInvert = []\n Object.keys(minFilters).forEach(function (key) {\n var val = minFilters[key]\n minFiltersInvert[val] = key\n })\n\n var wrapModesInvert = []\n Object.keys(wrapModes).forEach(function (key) {\n var val = wrapModes[key]\n wrapModesInvert[val] = key\n })\n\n // colorFormats[] gives the format (channels) associated to an\n // internalformat\n var colorFormats = supportedFormats.reduce(function (color, key) {\n var glenum = textureFormats[key]\n if (glenum === GL_LUMINANCE ||\n glenum === GL_ALPHA ||\n glenum === GL_LUMINANCE ||\n glenum === GL_LUMINANCE_ALPHA ||\n glenum === GL_DEPTH_COMPONENT ||\n glenum === GL_DEPTH_STENCIL ||\n (extensions.ext_srgb &&\n (glenum === GL_SRGB_EXT ||\n glenum === GL_SRGB_ALPHA_EXT))) {\n color[glenum] = glenum\n } else if (glenum === GL_RGB5_A1 || key.indexOf('rgba') >= 0) {\n color[glenum] = GL_RGBA$1\n } else {\n color[glenum] = GL_RGB\n }\n return color\n }, {})\n\n function TexFlags () {\n // format info\n this.internalformat = GL_RGBA$1\n this.format = GL_RGBA$1\n this.type = GL_UNSIGNED_BYTE$5\n this.compressed = false\n\n // pixel storage\n this.premultiplyAlpha = false\n this.flipY = false\n this.unpackAlignment = 1\n this.colorSpace = GL_BROWSER_DEFAULT_WEBGL\n\n // shape info\n this.width = 0\n this.height = 0\n this.channels = 0\n }\n\n function copyFlags (result, other) {\n result.internalformat = other.internalformat\n result.format = other.format\n result.type = other.type\n result.compressed = other.compressed\n\n result.premultiplyAlpha = other.premultiplyAlpha\n result.flipY = other.flipY\n result.unpackAlignment = other.unpackAlignment\n result.colorSpace = other.colorSpace\n\n result.width = other.width\n result.height = other.height\n result.channels = other.channels\n }\n\n function parseFlags (flags, options) {\n if (typeof options !== 'object' || !options) {\n return\n }\n\n if ('premultiplyAlpha' in options) {\n check$1.type(options.premultiplyAlpha, 'boolean',\n 'invalid premultiplyAlpha')\n flags.premultiplyAlpha = options.premultiplyAlpha\n }\n\n if ('flipY' in options) {\n check$1.type(options.flipY, 'boolean',\n 'invalid texture flip')\n flags.flipY = options.flipY\n }\n\n if ('alignment' in options) {\n check$1.oneOf(options.alignment, [1, 2, 4, 8],\n 'invalid texture unpack alignment')\n flags.unpackAlignment = options.alignment\n }\n\n if ('colorSpace' in options) {\n check$1.parameter(options.colorSpace, colorSpace,\n 'invalid colorSpace')\n flags.colorSpace = colorSpace[options.colorSpace]\n }\n\n if ('type' in options) {\n var type = options.type\n check$1(extensions.oes_texture_float ||\n !(type === 'float' || type === 'float32'),\n 'you must enable the OES_texture_float extension in order to use floating point textures.')\n check$1(extensions.oes_texture_half_float ||\n !(type === 'half float' || type === 'float16'),\n 'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.')\n check$1(extensions.webgl_depth_texture ||\n !(type === 'uint16' || type === 'uint32' || type === 'depth stencil'),\n 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')\n check$1.parameter(type, textureTypes,\n 'invalid texture type')\n flags.type = textureTypes[type]\n }\n\n var w = flags.width\n var h = flags.height\n var c = flags.channels\n var hasChannels = false\n if ('shape' in options) {\n check$1(Array.isArray(options.shape) && options.shape.length >= 2,\n 'shape must be an array')\n w = options.shape[0]\n h = options.shape[1]\n if (options.shape.length === 3) {\n c = options.shape[2]\n check$1(c > 0 && c <= 4, 'invalid number of channels')\n hasChannels = true\n }\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width')\n check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height')\n } else {\n if ('radius' in options) {\n w = h = options.radius\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid radius')\n }\n if ('width' in options) {\n w = options.width\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width')\n }\n if ('height' in options) {\n h = options.height\n check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height')\n }\n if ('channels' in options) {\n c = options.channels\n check$1(c > 0 && c <= 4, 'invalid number of channels')\n hasChannels = true\n }\n }\n flags.width = w | 0\n flags.height = h | 0\n flags.channels = c | 0\n\n var hasFormat = false\n if ('format' in options) {\n var formatStr = options.format\n check$1(extensions.webgl_depth_texture ||\n !(formatStr === 'depth' || formatStr === 'depth stencil'),\n 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')\n check$1.parameter(formatStr, textureFormats,\n 'invalid texture format')\n var internalformat = flags.internalformat = textureFormats[formatStr]\n flags.format = colorFormats[internalformat]\n if (formatStr in textureTypes) {\n if (!('type' in options)) {\n flags.type = textureTypes[formatStr]\n }\n }\n if (formatStr in compressedTextureFormats) {\n flags.compressed = true\n }\n hasFormat = true\n }\n\n // Reconcile channels and format\n if (!hasChannels && hasFormat) {\n flags.channels = FORMAT_CHANNELS[flags.format]\n } else if (hasChannels && !hasFormat) {\n if (flags.channels !== CHANNELS_FORMAT[flags.format]) {\n flags.format = flags.internalformat = CHANNELS_FORMAT[flags.channels]\n }\n } else if (hasFormat && hasChannels) {\n check$1(\n flags.channels === FORMAT_CHANNELS[flags.format],\n 'number of channels inconsistent with specified format')\n }\n }\n\n function setFlags (flags) {\n gl.pixelStorei(GL_UNPACK_FLIP_Y_WEBGL, flags.flipY)\n gl.pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL, flags.premultiplyAlpha)\n gl.pixelStorei(GL_UNPACK_COLORSPACE_CONVERSION_WEBGL, flags.colorSpace)\n gl.pixelStorei(GL_UNPACK_ALIGNMENT, flags.unpackAlignment)\n }\n\n // -------------------------------------------------------\n // Tex image data\n // -------------------------------------------------------\n function TexImage () {\n TexFlags.call(this)\n\n this.xOffset = 0\n this.yOffset = 0\n\n // data\n this.data = null\n this.needsFree = false\n\n // html element\n this.element = null\n\n // copyTexImage info\n this.needsCopy = false\n }\n\n function parseImage (image, options) {\n var data = null\n if (isPixelData(options)) {\n data = options\n } else if (options) {\n check$1.type(options, 'object', 'invalid pixel data type')\n parseFlags(image, options)\n if ('x' in options) {\n image.xOffset = options.x | 0\n }\n if ('y' in options) {\n image.yOffset = options.y | 0\n }\n if (isPixelData(options.data)) {\n data = options.data\n }\n }\n\n check$1(\n !image.compressed ||\n data instanceof Uint8Array,\n 'compressed texture data must be stored in a uint8array')\n\n if (options.copy) {\n check$1(!data, 'can not specify copy and data field for the same texture')\n var viewW = contextState.viewportWidth\n var viewH = contextState.viewportHeight\n image.width = image.width || (viewW - image.xOffset)\n image.height = image.height || (viewH - image.yOffset)\n image.needsCopy = true\n check$1(image.xOffset >= 0 && image.xOffset < viewW &&\n image.yOffset >= 0 && image.yOffset < viewH &&\n image.width > 0 && image.width <= viewW &&\n image.height > 0 && image.height <= viewH,\n 'copy texture read out of bounds')\n } else if (!data) {\n image.width = image.width || 1\n image.height = image.height || 1\n image.channels = image.channels || 4\n } else if (isTypedArray(data)) {\n image.channels = image.channels || 4\n image.data = data\n if (!('type' in options) && image.type === GL_UNSIGNED_BYTE$5) {\n image.type = typedArrayCode$1(data)\n }\n } else if (isNumericArray(data)) {\n image.channels = image.channels || 4\n convertData(image, data)\n image.alignment = 1\n image.needsFree = true\n } else if (isNDArrayLike(data)) {\n var array = data.data\n if (!Array.isArray(array) && image.type === GL_UNSIGNED_BYTE$5) {\n image.type = typedArrayCode$1(array)\n }\n var shape = data.shape\n var stride = data.stride\n var shapeX, shapeY, shapeC, strideX, strideY, strideC\n if (shape.length === 3) {\n shapeC = shape[2]\n strideC = stride[2]\n } else {\n check$1(shape.length === 2, 'invalid ndarray pixel data, must be 2 or 3D')\n shapeC = 1\n strideC = 1\n }\n shapeX = shape[0]\n shapeY = shape[1]\n strideX = stride[0]\n strideY = stride[1]\n image.alignment = 1\n image.width = shapeX\n image.height = shapeY\n image.channels = shapeC\n image.format = image.internalformat = CHANNELS_FORMAT[shapeC]\n image.needsFree = true\n transposeData(image, array, strideX, strideY, strideC, data.offset)\n } else if (isCanvasElement(data) || isOffscreenCanvas(data) || isContext2D(data)) {\n if (isCanvasElement(data) || isOffscreenCanvas(data)) {\n image.element = data\n } else {\n image.element = data.canvas\n }\n image.width = image.element.width\n image.height = image.element.height\n image.channels = 4\n } else if (isBitmap(data)) {\n image.element = data\n image.width = data.width\n image.height = data.height\n image.channels = 4\n } else if (isImageElement(data)) {\n image.element = data\n image.width = data.naturalWidth\n image.height = data.naturalHeight\n image.channels = 4\n } else if (isVideoElement(data)) {\n image.element = data\n image.width = data.videoWidth\n image.height = data.videoHeight\n image.channels = 4\n } else if (isRectArray(data)) {\n var w = image.width || data[0].length\n var h = image.height || data.length\n var c = image.channels\n if (isArrayLike(data[0][0])) {\n c = c || data[0][0].length\n } else {\n c = c || 1\n }\n var arrayShape = flattenUtils.shape(data)\n var n = 1\n for (var dd = 0; dd < arrayShape.length; ++dd) {\n n *= arrayShape[dd]\n }\n var allocData = preConvert(image, n)\n flattenUtils.flatten(data, arrayShape, '', allocData)\n postConvert(image, allocData)\n image.alignment = 1\n image.width = w\n image.height = h\n image.channels = c\n image.format = image.internalformat = CHANNELS_FORMAT[c]\n image.needsFree = true\n }\n\n if (image.type === GL_FLOAT$4) {\n check$1(limits.extensions.indexOf('oes_texture_float') >= 0,\n 'oes_texture_float extension not enabled')\n } else if (image.type === GL_HALF_FLOAT_OES$1) {\n check$1(limits.extensions.indexOf('oes_texture_half_float') >= 0,\n 'oes_texture_half_float extension not enabled')\n }\n\n // do compressed texture validation here.\n }\n\n function setImage (info, target, miplevel) {\n var element = info.element\n var data = info.data\n var internalformat = info.internalformat\n var format = info.format\n var type = info.type\n var width = info.width\n var height = info.height\n\n setFlags(info)\n\n if (element) {\n gl.texImage2D(target, miplevel, format, format, type, element)\n } else if (info.compressed) {\n gl.compressedTexImage2D(target, miplevel, internalformat, width, height, 0, data)\n } else if (info.needsCopy) {\n reglPoll()\n gl.copyTexImage2D(\n target, miplevel, format, info.xOffset, info.yOffset, width, height, 0)\n } else {\n gl.texImage2D(target, miplevel, format, width, height, 0, format, type, data || null)\n }\n }\n\n function setSubImage (info, target, x, y, miplevel) {\n var element = info.element\n var data = info.data\n var internalformat = info.internalformat\n var format = info.format\n var type = info.type\n var width = info.width\n var height = info.height\n\n setFlags(info)\n\n if (element) {\n gl.texSubImage2D(\n target, miplevel, x, y, format, type, element)\n } else if (info.compressed) {\n gl.compressedTexSubImage2D(\n target, miplevel, x, y, internalformat, width, height, data)\n } else if (info.needsCopy) {\n reglPoll()\n gl.copyTexSubImage2D(\n target, miplevel, x, y, info.xOffset, info.yOffset, width, height)\n } else {\n gl.texSubImage2D(\n target, miplevel, x, y, width, height, format, type, data)\n }\n }\n\n // texImage pool\n var imagePool = []\n\n function allocImage () {\n return imagePool.pop() || new TexImage()\n }\n\n function freeImage (image) {\n if (image.needsFree) {\n pool.freeType(image.data)\n }\n TexImage.call(image)\n imagePool.push(image)\n }\n\n // -------------------------------------------------------\n // Mip map\n // -------------------------------------------------------\n function MipMap () {\n TexFlags.call(this)\n\n this.genMipmaps = false\n this.mipmapHint = GL_DONT_CARE\n this.mipmask = 0\n this.images = Array(16)\n }\n\n function parseMipMapFromShape (mipmap, width, height) {\n var img = mipmap.images[0] = allocImage()\n mipmap.mipmask = 1\n img.width = mipmap.width = width\n img.height = mipmap.height = height\n img.channels = mipmap.channels = 4\n }\n\n function parseMipMapFromObject (mipmap, options) {\n var imgData = null\n if (isPixelData(options)) {\n imgData = mipmap.images[0] = allocImage()\n copyFlags(imgData, mipmap)\n parseImage(imgData, options)\n mipmap.mipmask = 1\n } else {\n parseFlags(mipmap, options)\n if (Array.isArray(options.mipmap)) {\n var mipData = options.mipmap\n for (var i = 0; i < mipData.length; ++i) {\n imgData = mipmap.images[i] = allocImage()\n copyFlags(imgData, mipmap)\n imgData.width >>= i\n imgData.height >>= i\n parseImage(imgData, mipData[i])\n mipmap.mipmask |= (1 << i)\n }\n } else {\n imgData = mipmap.images[0] = allocImage()\n copyFlags(imgData, mipmap)\n parseImage(imgData, options)\n mipmap.mipmask = 1\n }\n }\n copyFlags(mipmap, mipmap.images[0])\n\n // For textures of the compressed format WEBGL_compressed_texture_s3tc\n // we must have that\n //\n // \"When level equals zero width and height must be a multiple of 4.\n // When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. \"\n //\n // but we do not yet support having multiple mipmap levels for compressed textures,\n // so we only test for level zero.\n\n if (\n mipmap.compressed &&\n (\n mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||\n mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||\n mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||\n mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\n )\n ) {\n check$1(mipmap.width % 4 === 0 && mipmap.height % 4 === 0,\n 'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4')\n }\n }\n\n function setMipMap (mipmap, target) {\n var images = mipmap.images\n for (var i = 0; i < images.length; ++i) {\n if (!images[i]) {\n return\n }\n setImage(images[i], target, i)\n }\n }\n\n var mipPool = []\n\n function allocMipMap () {\n var result = mipPool.pop() || new MipMap()\n TexFlags.call(result)\n result.mipmask = 0\n for (var i = 0; i < 16; ++i) {\n result.images[i] = null\n }\n return result\n }\n\n function freeMipMap (mipmap) {\n var images = mipmap.images\n for (var i = 0; i < images.length; ++i) {\n if (images[i]) {\n freeImage(images[i])\n }\n images[i] = null\n }\n mipPool.push(mipmap)\n }\n\n // -------------------------------------------------------\n // Tex info\n // -------------------------------------------------------\n function TexInfo () {\n this.minFilter = GL_NEAREST$1\n this.magFilter = GL_NEAREST$1\n\n this.wrapS = GL_CLAMP_TO_EDGE$1\n this.wrapT = GL_CLAMP_TO_EDGE$1\n\n this.anisotropic = 1\n\n this.genMipmaps = false\n this.mipmapHint = GL_DONT_CARE\n }\n\n function parseTexInfo (info, options) {\n if ('min' in options) {\n var minFilter = options.min\n check$1.parameter(minFilter, minFilters)\n info.minFilter = minFilters[minFilter]\n if (MIPMAP_FILTERS.indexOf(info.minFilter) >= 0 && !('faces' in options)) {\n info.genMipmaps = true\n }\n }\n\n if ('mag' in options) {\n var magFilter = options.mag\n check$1.parameter(magFilter, magFilters)\n info.magFilter = magFilters[magFilter]\n }\n\n var wrapS = info.wrapS\n var wrapT = info.wrapT\n if ('wrap' in options) {\n var wrap = options.wrap\n if (typeof wrap === 'string') {\n check$1.parameter(wrap, wrapModes)\n wrapS = wrapT = wrapModes[wrap]\n } else if (Array.isArray(wrap)) {\n check$1.parameter(wrap[0], wrapModes)\n check$1.parameter(wrap[1], wrapModes)\n wrapS = wrapModes[wrap[0]]\n wrapT = wrapModes[wrap[1]]\n }\n } else {\n if ('wrapS' in options) {\n var optWrapS = options.wrapS\n check$1.parameter(optWrapS, wrapModes)\n wrapS = wrapModes[optWrapS]\n }\n if ('wrapT' in options) {\n var optWrapT = options.wrapT\n check$1.parameter(optWrapT, wrapModes)\n wrapT = wrapModes[optWrapT]\n }\n }\n info.wrapS = wrapS\n info.wrapT = wrapT\n\n if ('anisotropic' in options) {\n var anisotropic = options.anisotropic\n check$1(typeof anisotropic === 'number' &&\n anisotropic >= 1 && anisotropic <= limits.maxAnisotropic,\n 'aniso samples must be between 1 and ')\n info.anisotropic = options.anisotropic\n }\n\n if ('mipmap' in options) {\n var hasMipMap = false\n switch (typeof options.mipmap) {\n case 'string':\n check$1.parameter(options.mipmap, mipmapHint,\n 'invalid mipmap hint')\n info.mipmapHint = mipmapHint[options.mipmap]\n info.genMipmaps = true\n hasMipMap = true\n break\n\n case 'boolean':\n hasMipMap = info.genMipmaps = options.mipmap\n break\n\n case 'object':\n check$1(Array.isArray(options.mipmap), 'invalid mipmap type')\n info.genMipmaps = false\n hasMipMap = true\n break\n\n default:\n check$1.raise('invalid mipmap type')\n }\n if (hasMipMap && !('min' in options)) {\n info.minFilter = GL_NEAREST_MIPMAP_NEAREST$1\n }\n }\n }\n\n function setTexInfo (info, target) {\n gl.texParameteri(target, GL_TEXTURE_MIN_FILTER, info.minFilter)\n gl.texParameteri(target, GL_TEXTURE_MAG_FILTER, info.magFilter)\n gl.texParameteri(target, GL_TEXTURE_WRAP_S, info.wrapS)\n gl.texParameteri(target, GL_TEXTURE_WRAP_T, info.wrapT)\n if (extensions.ext_texture_filter_anisotropic) {\n gl.texParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, info.anisotropic)\n }\n if (info.genMipmaps) {\n gl.hint(GL_GENERATE_MIPMAP_HINT, info.mipmapHint)\n gl.generateMipmap(target)\n }\n }\n\n // -------------------------------------------------------\n // Full texture object\n // -------------------------------------------------------\n var textureCount = 0\n var textureSet = {}\n var numTexUnits = limits.maxTextureUnits\n var textureUnits = Array(numTexUnits).map(function () {\n return null\n })\n\n function REGLTexture (target) {\n TexFlags.call(this)\n this.mipmask = 0\n this.internalformat = GL_RGBA$1\n\n this.id = textureCount++\n\n this.refCount = 1\n\n this.target = target\n this.texture = gl.createTexture()\n\n this.unit = -1\n this.bindCount = 0\n\n this.texInfo = new TexInfo()\n\n if (config.profile) {\n this.stats = { size: 0 }\n }\n }\n\n function tempBind (texture) {\n gl.activeTexture(GL_TEXTURE0$1)\n gl.bindTexture(texture.target, texture.texture)\n }\n\n function tempRestore () {\n var prev = textureUnits[0]\n if (prev) {\n gl.bindTexture(prev.target, prev.texture)\n } else {\n gl.bindTexture(GL_TEXTURE_2D$1, null)\n }\n }\n\n function destroy (texture) {\n var handle = texture.texture\n check$1(handle, 'must not double destroy texture')\n var unit = texture.unit\n var target = texture.target\n if (unit >= 0) {\n gl.activeTexture(GL_TEXTURE0$1 + unit)\n gl.bindTexture(target, null)\n textureUnits[unit] = null\n }\n gl.deleteTexture(handle)\n texture.texture = null\n texture.params = null\n texture.pixels = null\n texture.refCount = 0\n delete textureSet[texture.id]\n stats.textureCount--\n }\n\n extend(REGLTexture.prototype, {\n bind: function () {\n var texture = this\n texture.bindCount += 1\n var unit = texture.unit\n if (unit < 0) {\n for (var i = 0; i < numTexUnits; ++i) {\n var other = textureUnits[i]\n if (other) {\n if (other.bindCount > 0) {\n continue\n }\n other.unit = -1\n }\n textureUnits[i] = texture\n unit = i\n break\n }\n if (unit >= numTexUnits) {\n check$1.raise('insufficient number of texture units')\n }\n if (config.profile && stats.maxTextureUnits < (unit + 1)) {\n stats.maxTextureUnits = unit + 1 // +1, since the units are zero-based\n }\n texture.unit = unit\n gl.activeTexture(GL_TEXTURE0$1 + unit)\n gl.bindTexture(texture.target, texture.texture)\n }\n return unit\n },\n\n unbind: function () {\n this.bindCount -= 1\n },\n\n decRef: function () {\n if (--this.refCount <= 0) {\n destroy(this)\n }\n }\n })\n\n function createTexture2D (a, b) {\n var texture = new REGLTexture(GL_TEXTURE_2D$1)\n textureSet[texture.id] = texture\n stats.textureCount++\n\n function reglTexture2D (a, b) {\n var texInfo = texture.texInfo\n TexInfo.call(texInfo)\n var mipData = allocMipMap()\n\n if (typeof a === 'number') {\n if (typeof b === 'number') {\n parseMipMapFromShape(mipData, a | 0, b | 0)\n } else {\n parseMipMapFromShape(mipData, a | 0, a | 0)\n }\n } else if (a) {\n check$1.type(a, 'object', 'invalid arguments to regl.texture')\n parseTexInfo(texInfo, a)\n parseMipMapFromObject(mipData, a)\n } else {\n // empty textures get assigned a default shape of 1x1\n parseMipMapFromShape(mipData, 1, 1)\n }\n\n if (texInfo.genMipmaps) {\n mipData.mipmask = (mipData.width << 1) - 1\n }\n texture.mipmask = mipData.mipmask\n\n copyFlags(texture, mipData)\n\n check$1.texture2D(texInfo, mipData, limits)\n texture.internalformat = mipData.internalformat\n\n reglTexture2D.width = mipData.width\n reglTexture2D.height = mipData.height\n\n tempBind(texture)\n setMipMap(mipData, GL_TEXTURE_2D$1)\n setTexInfo(texInfo, GL_TEXTURE_2D$1)\n tempRestore()\n\n freeMipMap(mipData)\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n mipData.width,\n mipData.height,\n texInfo.genMipmaps,\n false)\n }\n reglTexture2D.format = textureFormatsInvert[texture.internalformat]\n reglTexture2D.type = textureTypesInvert[texture.type]\n\n reglTexture2D.mag = magFiltersInvert[texInfo.magFilter]\n reglTexture2D.min = minFiltersInvert[texInfo.minFilter]\n\n reglTexture2D.wrapS = wrapModesInvert[texInfo.wrapS]\n reglTexture2D.wrapT = wrapModesInvert[texInfo.wrapT]\n\n return reglTexture2D\n }\n\n function subimage (image, x_, y_, level_) {\n check$1(!!image, 'must specify image data')\n\n var x = x_ | 0\n var y = y_ | 0\n var level = level_ | 0\n\n var imageData = allocImage()\n copyFlags(imageData, texture)\n imageData.width = 0\n imageData.height = 0\n parseImage(imageData, image)\n imageData.width = imageData.width || ((texture.width >> level) - x)\n imageData.height = imageData.height || ((texture.height >> level) - y)\n\n check$1(\n texture.type === imageData.type &&\n texture.format === imageData.format &&\n texture.internalformat === imageData.internalformat,\n 'incompatible format for texture.subimage')\n check$1(\n x >= 0 && y >= 0 &&\n x + imageData.width <= texture.width &&\n y + imageData.height <= texture.height,\n 'texture.subimage write out of bounds')\n check$1(\n texture.mipmask & (1 << level),\n 'missing mipmap data')\n check$1(\n imageData.data || imageData.element || imageData.needsCopy,\n 'missing image data')\n\n tempBind(texture)\n setSubImage(imageData, GL_TEXTURE_2D$1, x, y, level)\n tempRestore()\n\n freeImage(imageData)\n\n return reglTexture2D\n }\n\n function resize (w_, h_) {\n var w = w_ | 0\n var h = (h_ | 0) || w\n if (w === texture.width && h === texture.height) {\n return reglTexture2D\n }\n\n reglTexture2D.width = texture.width = w\n reglTexture2D.height = texture.height = h\n\n tempBind(texture)\n\n for (var i = 0; texture.mipmask >> i; ++i) {\n var _w = w >> i\n var _h = h >> i\n if (!_w || !_h) break\n gl.texImage2D(\n GL_TEXTURE_2D$1,\n i,\n texture.format,\n _w,\n _h,\n 0,\n texture.format,\n texture.type,\n null)\n }\n tempRestore()\n\n // also, recompute the texture size.\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n w,\n h,\n false,\n false)\n }\n\n return reglTexture2D\n }\n\n reglTexture2D(a, b)\n\n reglTexture2D.subimage = subimage\n reglTexture2D.resize = resize\n reglTexture2D._reglType = 'texture2d'\n reglTexture2D._texture = texture\n if (config.profile) {\n reglTexture2D.stats = texture.stats\n }\n reglTexture2D.destroy = function () {\n texture.decRef()\n }\n\n return reglTexture2D\n }\n\n function createTextureCube (a0, a1, a2, a3, a4, a5) {\n var texture = new REGLTexture(GL_TEXTURE_CUBE_MAP$1)\n textureSet[texture.id] = texture\n stats.cubeCount++\n\n var faces = new Array(6)\n\n function reglTextureCube (a0, a1, a2, a3, a4, a5) {\n var i\n var texInfo = texture.texInfo\n TexInfo.call(texInfo)\n for (i = 0; i < 6; ++i) {\n faces[i] = allocMipMap()\n }\n\n if (typeof a0 === 'number' || !a0) {\n var s = (a0 | 0) || 1\n for (i = 0; i < 6; ++i) {\n parseMipMapFromShape(faces[i], s, s)\n }\n } else if (typeof a0 === 'object') {\n if (a1) {\n parseMipMapFromObject(faces[0], a0)\n parseMipMapFromObject(faces[1], a1)\n parseMipMapFromObject(faces[2], a2)\n parseMipMapFromObject(faces[3], a3)\n parseMipMapFromObject(faces[4], a4)\n parseMipMapFromObject(faces[5], a5)\n } else {\n parseTexInfo(texInfo, a0)\n parseFlags(texture, a0)\n if ('faces' in a0) {\n var faceInput = a0.faces\n check$1(Array.isArray(faceInput) && faceInput.length === 6,\n 'cube faces must be a length 6 array')\n for (i = 0; i < 6; ++i) {\n check$1(typeof faceInput[i] === 'object' && !!faceInput[i],\n 'invalid input for cube map face')\n copyFlags(faces[i], texture)\n parseMipMapFromObject(faces[i], faceInput[i])\n }\n } else {\n for (i = 0; i < 6; ++i) {\n parseMipMapFromObject(faces[i], a0)\n }\n }\n }\n } else {\n check$1.raise('invalid arguments to cube map')\n }\n\n copyFlags(texture, faces[0])\n\n if (!limits.npotTextureCube) {\n check$1(isPow2$1(texture.width) && isPow2$1(texture.height), 'your browser does not support non power or two texture dimensions')\n }\n\n if (texInfo.genMipmaps) {\n texture.mipmask = (faces[0].width << 1) - 1\n } else {\n texture.mipmask = faces[0].mipmask\n }\n\n check$1.textureCube(texture, texInfo, faces, limits)\n texture.internalformat = faces[0].internalformat\n\n reglTextureCube.width = faces[0].width\n reglTextureCube.height = faces[0].height\n\n tempBind(texture)\n for (i = 0; i < 6; ++i) {\n setMipMap(faces[i], GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i)\n }\n setTexInfo(texInfo, GL_TEXTURE_CUBE_MAP$1)\n tempRestore()\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n reglTextureCube.width,\n reglTextureCube.height,\n texInfo.genMipmaps,\n true)\n }\n\n reglTextureCube.format = textureFormatsInvert[texture.internalformat]\n reglTextureCube.type = textureTypesInvert[texture.type]\n\n reglTextureCube.mag = magFiltersInvert[texInfo.magFilter]\n reglTextureCube.min = minFiltersInvert[texInfo.minFilter]\n\n reglTextureCube.wrapS = wrapModesInvert[texInfo.wrapS]\n reglTextureCube.wrapT = wrapModesInvert[texInfo.wrapT]\n\n for (i = 0; i < 6; ++i) {\n freeMipMap(faces[i])\n }\n\n return reglTextureCube\n }\n\n function subimage (face, image, x_, y_, level_) {\n check$1(!!image, 'must specify image data')\n check$1(typeof face === 'number' && face === (face | 0) &&\n face >= 0 && face < 6, 'invalid face')\n\n var x = x_ | 0\n var y = y_ | 0\n var level = level_ | 0\n\n var imageData = allocImage()\n copyFlags(imageData, texture)\n imageData.width = 0\n imageData.height = 0\n parseImage(imageData, image)\n imageData.width = imageData.width || ((texture.width >> level) - x)\n imageData.height = imageData.height || ((texture.height >> level) - y)\n\n check$1(\n texture.type === imageData.type &&\n texture.format === imageData.format &&\n texture.internalformat === imageData.internalformat,\n 'incompatible format for texture.subimage')\n check$1(\n x >= 0 && y >= 0 &&\n x + imageData.width <= texture.width &&\n y + imageData.height <= texture.height,\n 'texture.subimage write out of bounds')\n check$1(\n texture.mipmask & (1 << level),\n 'missing mipmap data')\n check$1(\n imageData.data || imageData.element || imageData.needsCopy,\n 'missing image data')\n\n tempBind(texture)\n setSubImage(imageData, GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + face, x, y, level)\n tempRestore()\n\n freeImage(imageData)\n\n return reglTextureCube\n }\n\n function resize (radius_) {\n var radius = radius_ | 0\n if (radius === texture.width) {\n return\n }\n\n reglTextureCube.width = texture.width = radius\n reglTextureCube.height = texture.height = radius\n\n tempBind(texture)\n for (var i = 0; i < 6; ++i) {\n for (var j = 0; texture.mipmask >> j; ++j) {\n gl.texImage2D(\n GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i,\n j,\n texture.format,\n radius >> j,\n radius >> j,\n 0,\n texture.format,\n texture.type,\n null)\n }\n }\n tempRestore()\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n reglTextureCube.width,\n reglTextureCube.height,\n false,\n true)\n }\n\n return reglTextureCube\n }\n\n reglTextureCube(a0, a1, a2, a3, a4, a5)\n\n reglTextureCube.subimage = subimage\n reglTextureCube.resize = resize\n reglTextureCube._reglType = 'textureCube'\n reglTextureCube._texture = texture\n if (config.profile) {\n reglTextureCube.stats = texture.stats\n }\n reglTextureCube.destroy = function () {\n texture.decRef()\n }\n\n return reglTextureCube\n }\n\n // Called when regl is destroyed\n function destroyTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n gl.activeTexture(GL_TEXTURE0$1 + i)\n gl.bindTexture(GL_TEXTURE_2D$1, null)\n textureUnits[i] = null\n }\n values(textureSet).forEach(destroy)\n\n stats.cubeCount = 0\n stats.textureCount = 0\n }\n\n if (config.profile) {\n stats.getTotalTextureSize = function () {\n var total = 0\n Object.keys(textureSet).forEach(function (key) {\n total += textureSet[key].stats.size\n })\n return total\n }\n }\n\n function restoreTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n var tex = textureUnits[i]\n if (tex) {\n tex.bindCount = 0\n tex.unit = -1\n textureUnits[i] = null\n }\n }\n\n values(textureSet).forEach(function (texture) {\n texture.texture = gl.createTexture()\n gl.bindTexture(texture.target, texture.texture)\n for (var i = 0; i < 32; ++i) {\n if ((texture.mipmask & (1 << i)) === 0) {\n continue\n }\n if (texture.target === GL_TEXTURE_2D$1) {\n gl.texImage2D(GL_TEXTURE_2D$1,\n i,\n texture.internalformat,\n texture.width >> i,\n texture.height >> i,\n 0,\n texture.internalformat,\n texture.type,\n null)\n } else {\n for (var j = 0; j < 6; ++j) {\n gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + j,\n i,\n texture.internalformat,\n texture.width >> i,\n texture.height >> i,\n 0,\n texture.internalformat,\n texture.type,\n null)\n }\n }\n }\n setTexInfo(texture.texInfo, texture.target)\n })\n }\n\n function refreshTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n var tex = textureUnits[i]\n if (tex) {\n tex.bindCount = 0\n tex.unit = -1\n textureUnits[i] = null\n }\n gl.activeTexture(GL_TEXTURE0$1 + i)\n gl.bindTexture(GL_TEXTURE_2D$1, null)\n gl.bindTexture(GL_TEXTURE_CUBE_MAP$1, null)\n }\n }\n\n return {\n create2D: createTexture2D,\n createCube: createTextureCube,\n clear: destroyTextures,\n getTexture: function (wrapper) {\n return null\n },\n restore: restoreTextures,\n refresh: refreshTextures\n }\n}\n\nvar GL_RENDERBUFFER = 0x8D41\n\nvar GL_RGBA4$1 = 0x8056\nvar GL_RGB5_A1$1 = 0x8057\nvar GL_RGB565$1 = 0x8D62\nvar GL_DEPTH_COMPONENT16 = 0x81A5\nvar GL_STENCIL_INDEX8 = 0x8D48\nvar GL_DEPTH_STENCIL$1 = 0x84F9\n\nvar GL_SRGB8_ALPHA8_EXT = 0x8C43\n\nvar GL_RGBA32F_EXT = 0x8814\n\nvar GL_RGBA16F_EXT = 0x881A\nvar GL_RGB16F_EXT = 0x881B\n\nvar FORMAT_SIZES = []\n\nFORMAT_SIZES[GL_RGBA4$1] = 2\nFORMAT_SIZES[GL_RGB5_A1$1] = 2\nFORMAT_SIZES[GL_RGB565$1] = 2\n\nFORMAT_SIZES[GL_DEPTH_COMPONENT16] = 2\nFORMAT_SIZES[GL_STENCIL_INDEX8] = 1\nFORMAT_SIZES[GL_DEPTH_STENCIL$1] = 4\n\nFORMAT_SIZES[GL_SRGB8_ALPHA8_EXT] = 4\nFORMAT_SIZES[GL_RGBA32F_EXT] = 16\nFORMAT_SIZES[GL_RGBA16F_EXT] = 8\nFORMAT_SIZES[GL_RGB16F_EXT] = 6\n\nfunction getRenderbufferSize (format, width, height) {\n return FORMAT_SIZES[format] * width * height\n}\n\nvar wrapRenderbuffers = function (gl, extensions, limits, stats, config) {\n var formatTypes = {\n 'rgba4': GL_RGBA4$1,\n 'rgb565': GL_RGB565$1,\n 'rgb5 a1': GL_RGB5_A1$1,\n 'depth': GL_DEPTH_COMPONENT16,\n 'stencil': GL_STENCIL_INDEX8,\n 'depth stencil': GL_DEPTH_STENCIL$1\n }\n\n if (extensions.ext_srgb) {\n formatTypes['srgba'] = GL_SRGB8_ALPHA8_EXT\n }\n\n if (extensions.ext_color_buffer_half_float) {\n formatTypes['rgba16f'] = GL_RGBA16F_EXT\n formatTypes['rgb16f'] = GL_RGB16F_EXT\n }\n\n if (extensions.webgl_color_buffer_float) {\n formatTypes['rgba32f'] = GL_RGBA32F_EXT\n }\n\n var formatTypesInvert = []\n Object.keys(formatTypes).forEach(function (key) {\n var val = formatTypes[key]\n formatTypesInvert[val] = key\n })\n\n var renderbufferCount = 0\n var renderbufferSet = {}\n\n function REGLRenderbuffer (renderbuffer) {\n this.id = renderbufferCount++\n this.refCount = 1\n\n this.renderbuffer = renderbuffer\n\n this.format = GL_RGBA4$1\n this.width = 0\n this.height = 0\n\n if (config.profile) {\n this.stats = { size: 0 }\n }\n }\n\n REGLRenderbuffer.prototype.decRef = function () {\n if (--this.refCount <= 0) {\n destroy(this)\n }\n }\n\n function destroy (rb) {\n var handle = rb.renderbuffer\n check$1(handle, 'must not double destroy renderbuffer')\n gl.bindRenderbuffer(GL_RENDERBUFFER, null)\n gl.deleteRenderbuffer(handle)\n rb.renderbuffer = null\n rb.refCount = 0\n delete renderbufferSet[rb.id]\n stats.renderbufferCount--\n }\n\n function createRenderbuffer (a, b) {\n var renderbuffer = new REGLRenderbuffer(gl.createRenderbuffer())\n renderbufferSet[renderbuffer.id] = renderbuffer\n stats.renderbufferCount++\n\n function reglRenderbuffer (a, b) {\n var w = 0\n var h = 0\n var format = GL_RGBA4$1\n\n if (typeof a === 'object' && a) {\n var options = a\n if ('shape' in options) {\n var shape = options.shape\n check$1(Array.isArray(shape) && shape.length >= 2,\n 'invalid renderbuffer shape')\n w = shape[0] | 0\n h = shape[1] | 0\n } else {\n if ('radius' in options) {\n w = h = options.radius | 0\n }\n if ('width' in options) {\n w = options.width | 0\n }\n if ('height' in options) {\n h = options.height | 0\n }\n }\n if ('format' in options) {\n check$1.parameter(options.format, formatTypes,\n 'invalid renderbuffer format')\n format = formatTypes[options.format]\n }\n } else if (typeof a === 'number') {\n w = a | 0\n if (typeof b === 'number') {\n h = b | 0\n } else {\n h = w\n }\n } else if (!a) {\n w = h = 1\n } else {\n check$1.raise('invalid arguments to renderbuffer constructor')\n }\n\n // check shape\n check$1(\n w > 0 && h > 0 &&\n w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize,\n 'invalid renderbuffer size')\n\n if (w === renderbuffer.width &&\n h === renderbuffer.height &&\n format === renderbuffer.format) {\n return\n }\n\n reglRenderbuffer.width = renderbuffer.width = w\n reglRenderbuffer.height = renderbuffer.height = h\n renderbuffer.format = format\n\n gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer)\n gl.renderbufferStorage(GL_RENDERBUFFER, format, w, h)\n\n check$1(\n gl.getError() === 0,\n 'invalid render buffer format')\n\n if (config.profile) {\n renderbuffer.stats.size = getRenderbufferSize(renderbuffer.format, renderbuffer.width, renderbuffer.height)\n }\n reglRenderbuffer.format = formatTypesInvert[renderbuffer.format]\n\n return reglRenderbuffer\n }\n\n function resize (w_, h_) {\n var w = w_ | 0\n var h = (h_ | 0) || w\n\n if (w === renderbuffer.width && h === renderbuffer.height) {\n return reglRenderbuffer\n }\n\n // check shape\n check$1(\n w > 0 && h > 0 &&\n w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize,\n 'invalid renderbuffer size')\n\n reglRenderbuffer.width = renderbuffer.width = w\n reglRenderbuffer.height = renderbuffer.height = h\n\n gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer)\n gl.renderbufferStorage(GL_RENDERBUFFER, renderbuffer.format, w, h)\n\n check$1(\n gl.getError() === 0,\n 'invalid render buffer format')\n\n // also, recompute size.\n if (config.profile) {\n renderbuffer.stats.size = getRenderbufferSize(\n renderbuffer.format, renderbuffer.width, renderbuffer.height)\n }\n\n return reglRenderbuffer\n }\n\n reglRenderbuffer(a, b)\n\n reglRenderbuffer.resize = resize\n reglRenderbuffer._reglType = 'renderbuffer'\n reglRenderbuffer._renderbuffer = renderbuffer\n if (config.profile) {\n reglRenderbuffer.stats = renderbuffer.stats\n }\n reglRenderbuffer.destroy = function () {\n renderbuffer.decRef()\n }\n\n return reglRenderbuffer\n }\n\n if (config.profile) {\n stats.getTotalRenderbufferSize = function () {\n var total = 0\n Object.keys(renderbufferSet).forEach(function (key) {\n total += renderbufferSet[key].stats.size\n })\n return total\n }\n }\n\n function restoreRenderbuffers () {\n values(renderbufferSet).forEach(function (rb) {\n rb.renderbuffer = gl.createRenderbuffer()\n gl.bindRenderbuffer(GL_RENDERBUFFER, rb.renderbuffer)\n gl.renderbufferStorage(GL_RENDERBUFFER, rb.format, rb.width, rb.height)\n })\n gl.bindRenderbuffer(GL_RENDERBUFFER, null)\n }\n\n return {\n create: createRenderbuffer,\n clear: function () {\n values(renderbufferSet).forEach(destroy)\n },\n restore: restoreRenderbuffers\n }\n}\n\n// We store these constants so that the minifier can inline them\nvar GL_FRAMEBUFFER$1 = 0x8D40\nvar GL_RENDERBUFFER$1 = 0x8D41\n\nvar GL_TEXTURE_2D$2 = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 = 0x8515\n\nvar GL_COLOR_ATTACHMENT0$1 = 0x8CE0\nvar GL_DEPTH_ATTACHMENT = 0x8D00\nvar GL_STENCIL_ATTACHMENT = 0x8D20\nvar GL_DEPTH_STENCIL_ATTACHMENT = 0x821A\n\nvar GL_FRAMEBUFFER_COMPLETE$1 = 0x8CD5\nvar GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6\nvar GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7\nvar GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9\nvar GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD\n\nvar GL_HALF_FLOAT_OES$2 = 0x8D61\nvar GL_UNSIGNED_BYTE$6 = 0x1401\nvar GL_FLOAT$5 = 0x1406\n\nvar GL_RGB$1 = 0x1907\nvar GL_RGBA$2 = 0x1908\n\nvar GL_DEPTH_COMPONENT$1 = 0x1902\n\nvar colorTextureFormatEnums = [\n GL_RGB$1,\n GL_RGBA$2\n]\n\n// for every texture format, store\n// the number of channels\nvar textureFormatChannels = []\ntextureFormatChannels[GL_RGBA$2] = 4\ntextureFormatChannels[GL_RGB$1] = 3\n\n// for every texture type, store\n// the size in bytes.\nvar textureTypeSizes = []\ntextureTypeSizes[GL_UNSIGNED_BYTE$6] = 1\ntextureTypeSizes[GL_FLOAT$5] = 4\ntextureTypeSizes[GL_HALF_FLOAT_OES$2] = 2\n\nvar GL_RGBA4$2 = 0x8056\nvar GL_RGB5_A1$2 = 0x8057\nvar GL_RGB565$2 = 0x8D62\nvar GL_DEPTH_COMPONENT16$1 = 0x81A5\nvar GL_STENCIL_INDEX8$1 = 0x8D48\nvar GL_DEPTH_STENCIL$2 = 0x84F9\n\nvar GL_SRGB8_ALPHA8_EXT$1 = 0x8C43\n\nvar GL_RGBA32F_EXT$1 = 0x8814\n\nvar GL_RGBA16F_EXT$1 = 0x881A\nvar GL_RGB16F_EXT$1 = 0x881B\n\nvar colorRenderbufferFormatEnums = [\n GL_RGBA4$2,\n GL_RGB5_A1$2,\n GL_RGB565$2,\n GL_SRGB8_ALPHA8_EXT$1,\n GL_RGBA16F_EXT$1,\n GL_RGB16F_EXT$1,\n GL_RGBA32F_EXT$1\n]\n\nvar statusCode = {}\nstatusCode[GL_FRAMEBUFFER_COMPLETE$1] = 'complete'\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT] = 'incomplete attachment'\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS] = 'incomplete dimensions'\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT] = 'incomplete, missing attachment'\nstatusCode[GL_FRAMEBUFFER_UNSUPPORTED] = 'unsupported'\n\nfunction wrapFBOState (\n gl,\n extensions,\n limits,\n textureState,\n renderbufferState,\n stats) {\n var framebufferState = {\n cur: null,\n next: null,\n dirty: false,\n setFBO: null\n }\n\n var colorTextureFormats = ['rgba']\n var colorRenderbufferFormats = ['rgba4', 'rgb565', 'rgb5 a1']\n\n if (extensions.ext_srgb) {\n colorRenderbufferFormats.push('srgba')\n }\n\n if (extensions.ext_color_buffer_half_float) {\n colorRenderbufferFormats.push('rgba16f', 'rgb16f')\n }\n\n if (extensions.webgl_color_buffer_float) {\n colorRenderbufferFormats.push('rgba32f')\n }\n\n var colorTypes = ['uint8']\n if (extensions.oes_texture_half_float) {\n colorTypes.push('half float', 'float16')\n }\n if (extensions.oes_texture_float) {\n colorTypes.push('float', 'float32')\n }\n\n function FramebufferAttachment (target, texture, renderbuffer) {\n this.target = target\n this.texture = texture\n this.renderbuffer = renderbuffer\n\n var w = 0\n var h = 0\n if (texture) {\n w = texture.width\n h = texture.height\n } else if (renderbuffer) {\n w = renderbuffer.width\n h = renderbuffer.height\n }\n this.width = w\n this.height = h\n }\n\n function decRef (attachment) {\n if (attachment) {\n if (attachment.texture) {\n attachment.texture._texture.decRef()\n }\n if (attachment.renderbuffer) {\n attachment.renderbuffer._renderbuffer.decRef()\n }\n }\n }\n\n function incRefAndCheckShape (attachment, width, height) {\n if (!attachment) {\n return\n }\n if (attachment.texture) {\n var texture = attachment.texture._texture\n var tw = Math.max(1, texture.width)\n var th = Math.max(1, texture.height)\n check$1(tw === width && th === height,\n 'inconsistent width/height for supplied texture')\n texture.refCount += 1\n } else {\n var renderbuffer = attachment.renderbuffer._renderbuffer\n check$1(\n renderbuffer.width === width && renderbuffer.height === height,\n 'inconsistent width/height for renderbuffer')\n renderbuffer.refCount += 1\n }\n }\n\n function attach (location, attachment) {\n if (attachment) {\n if (attachment.texture) {\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n location,\n attachment.target,\n attachment.texture._texture.texture,\n 0)\n } else {\n gl.framebufferRenderbuffer(\n GL_FRAMEBUFFER$1,\n location,\n GL_RENDERBUFFER$1,\n attachment.renderbuffer._renderbuffer.renderbuffer)\n }\n }\n }\n\n function parseAttachment (attachment) {\n var target = GL_TEXTURE_2D$2\n var texture = null\n var renderbuffer = null\n\n var data = attachment\n if (typeof attachment === 'object') {\n data = attachment.data\n if ('target' in attachment) {\n target = attachment.target | 0\n }\n }\n\n check$1.type(data, 'function', 'invalid attachment data')\n\n var type = data._reglType\n if (type === 'texture2d') {\n texture = data\n check$1(target === GL_TEXTURE_2D$2)\n } else if (type === 'textureCube') {\n texture = data\n check$1(\n target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 &&\n target < GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 + 6,\n 'invalid cube map target')\n } else if (type === 'renderbuffer') {\n renderbuffer = data\n target = GL_RENDERBUFFER$1\n } else {\n check$1.raise('invalid regl object for attachment')\n }\n\n return new FramebufferAttachment(target, texture, renderbuffer)\n }\n\n function allocAttachment (\n width,\n height,\n isTexture,\n format,\n type) {\n if (isTexture) {\n var texture = textureState.create2D({\n width: width,\n height: height,\n format: format,\n type: type\n })\n texture._texture.refCount = 0\n return new FramebufferAttachment(GL_TEXTURE_2D$2, texture, null)\n } else {\n var rb = renderbufferState.create({\n width: width,\n height: height,\n format: format\n })\n rb._renderbuffer.refCount = 0\n return new FramebufferAttachment(GL_RENDERBUFFER$1, null, rb)\n }\n }\n\n function unwrapAttachment (attachment) {\n return attachment && (attachment.texture || attachment.renderbuffer)\n }\n\n function resizeAttachment (attachment, w, h) {\n if (attachment) {\n if (attachment.texture) {\n attachment.texture.resize(w, h)\n } else if (attachment.renderbuffer) {\n attachment.renderbuffer.resize(w, h)\n }\n attachment.width = w\n attachment.height = h\n }\n }\n\n var framebufferCount = 0\n var framebufferSet = {}\n\n function REGLFramebuffer () {\n this.id = framebufferCount++\n framebufferSet[this.id] = this\n\n this.framebuffer = gl.createFramebuffer()\n this.width = 0\n this.height = 0\n\n this.colorAttachments = []\n this.depthAttachment = null\n this.stencilAttachment = null\n this.depthStencilAttachment = null\n }\n\n function decFBORefs (framebuffer) {\n framebuffer.colorAttachments.forEach(decRef)\n decRef(framebuffer.depthAttachment)\n decRef(framebuffer.stencilAttachment)\n decRef(framebuffer.depthStencilAttachment)\n }\n\n function destroy (framebuffer) {\n var handle = framebuffer.framebuffer\n check$1(handle, 'must not double destroy framebuffer')\n gl.deleteFramebuffer(handle)\n framebuffer.framebuffer = null\n stats.framebufferCount--\n delete framebufferSet[framebuffer.id]\n }\n\n function updateFramebuffer (framebuffer) {\n var i\n\n gl.bindFramebuffer(GL_FRAMEBUFFER$1, framebuffer.framebuffer)\n var colorAttachments = framebuffer.colorAttachments\n for (i = 0; i < colorAttachments.length; ++i) {\n attach(GL_COLOR_ATTACHMENT0$1 + i, colorAttachments[i])\n }\n for (i = colorAttachments.length; i < limits.maxColorAttachments; ++i) {\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_COLOR_ATTACHMENT0$1 + i,\n GL_TEXTURE_2D$2,\n null,\n 0)\n }\n\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_DEPTH_STENCIL_ATTACHMENT,\n GL_TEXTURE_2D$2,\n null,\n 0)\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_DEPTH_ATTACHMENT,\n GL_TEXTURE_2D$2,\n null,\n 0)\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_STENCIL_ATTACHMENT,\n GL_TEXTURE_2D$2,\n null,\n 0)\n\n attach(GL_DEPTH_ATTACHMENT, framebuffer.depthAttachment)\n attach(GL_STENCIL_ATTACHMENT, framebuffer.stencilAttachment)\n attach(GL_DEPTH_STENCIL_ATTACHMENT, framebuffer.depthStencilAttachment)\n\n // Check status code\n var status = gl.checkFramebufferStatus(GL_FRAMEBUFFER$1)\n if (!gl.isContextLost() && status !== GL_FRAMEBUFFER_COMPLETE$1) {\n check$1.raise('framebuffer configuration not supported, status = ' +\n statusCode[status])\n }\n\n gl.bindFramebuffer(GL_FRAMEBUFFER$1, framebufferState.next ? framebufferState.next.framebuffer : null)\n framebufferState.cur = framebufferState.next\n\n // FIXME: Clear error code here. This is a work around for a bug in\n // headless-gl\n gl.getError()\n }\n\n function createFBO (a0, a1) {\n var framebuffer = new REGLFramebuffer()\n stats.framebufferCount++\n\n function reglFramebuffer (a, b) {\n var i\n\n check$1(framebufferState.next !== framebuffer,\n 'can not update framebuffer which is currently in use')\n\n var width = 0\n var height = 0\n\n var needsDepth = true\n var needsStencil = true\n\n var colorBuffer = null\n var colorTexture = true\n var colorFormat = 'rgba'\n var colorType = 'uint8'\n var colorCount = 1\n\n var depthBuffer = null\n var stencilBuffer = null\n var depthStencilBuffer = null\n var depthStencilTexture = false\n\n if (typeof a === 'number') {\n width = a | 0\n height = (b | 0) || width\n } else if (!a) {\n width = height = 1\n } else {\n check$1.type(a, 'object', 'invalid arguments for framebuffer')\n var options = a\n\n if ('shape' in options) {\n var shape = options.shape\n check$1(Array.isArray(shape) && shape.length >= 2,\n 'invalid shape for framebuffer')\n width = shape[0]\n height = shape[1]\n } else {\n if ('radius' in options) {\n width = height = options.radius\n }\n if ('width' in options) {\n width = options.width\n }\n if ('height' in options) {\n height = options.height\n }\n }\n\n if ('color' in options ||\n 'colors' in options) {\n colorBuffer =\n options.color ||\n options.colors\n if (Array.isArray(colorBuffer)) {\n check$1(\n colorBuffer.length === 1 || extensions.webgl_draw_buffers,\n 'multiple render targets not supported')\n }\n }\n\n if (!colorBuffer) {\n if ('colorCount' in options) {\n colorCount = options.colorCount | 0\n check$1(colorCount > 0, 'invalid color buffer count')\n }\n\n if ('colorTexture' in options) {\n colorTexture = !!options.colorTexture\n colorFormat = 'rgba4'\n }\n\n if ('colorType' in options) {\n colorType = options.colorType\n if (!colorTexture) {\n if (colorType === 'half float' || colorType === 'float16') {\n check$1(extensions.ext_color_buffer_half_float,\n 'you must enable EXT_color_buffer_half_float to use 16-bit render buffers')\n colorFormat = 'rgba16f'\n } else if (colorType === 'float' || colorType === 'float32') {\n check$1(extensions.webgl_color_buffer_float,\n 'you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers')\n colorFormat = 'rgba32f'\n }\n } else {\n check$1(extensions.oes_texture_float ||\n !(colorType === 'float' || colorType === 'float32'),\n 'you must enable OES_texture_float in order to use floating point framebuffer objects')\n check$1(extensions.oes_texture_half_float ||\n !(colorType === 'half float' || colorType === 'float16'),\n 'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects')\n }\n check$1.oneOf(colorType, colorTypes, 'invalid color type')\n }\n\n if ('colorFormat' in options) {\n colorFormat = options.colorFormat\n if (colorTextureFormats.indexOf(colorFormat) >= 0) {\n colorTexture = true\n } else if (colorRenderbufferFormats.indexOf(colorFormat) >= 0) {\n colorTexture = false\n } else {\n if (colorTexture) {\n check$1.oneOf(\n options.colorFormat, colorTextureFormats,\n 'invalid color format for texture')\n } else {\n check$1.oneOf(\n options.colorFormat, colorRenderbufferFormats,\n 'invalid color format for renderbuffer')\n }\n }\n }\n }\n\n if ('depthTexture' in options || 'depthStencilTexture' in options) {\n depthStencilTexture = !!(options.depthTexture ||\n options.depthStencilTexture)\n check$1(!depthStencilTexture || extensions.webgl_depth_texture,\n 'webgl_depth_texture extension not supported')\n }\n\n if ('depth' in options) {\n if (typeof options.depth === 'boolean') {\n needsDepth = options.depth\n } else {\n depthBuffer = options.depth\n needsStencil = false\n }\n }\n\n if ('stencil' in options) {\n if (typeof options.stencil === 'boolean') {\n needsStencil = options.stencil\n } else {\n stencilBuffer = options.stencil\n needsDepth = false\n }\n }\n\n if ('depthStencil' in options) {\n if (typeof options.depthStencil === 'boolean') {\n needsDepth = needsStencil = options.depthStencil\n } else {\n depthStencilBuffer = options.depthStencil\n needsDepth = false\n needsStencil = false\n }\n }\n }\n\n // parse attachments\n var colorAttachments = null\n var depthAttachment = null\n var stencilAttachment = null\n var depthStencilAttachment = null\n\n // Set up color attachments\n if (Array.isArray(colorBuffer)) {\n colorAttachments = colorBuffer.map(parseAttachment)\n } else if (colorBuffer) {\n colorAttachments = [parseAttachment(colorBuffer)]\n } else {\n colorAttachments = new Array(colorCount)\n for (i = 0; i < colorCount; ++i) {\n colorAttachments[i] = allocAttachment(\n width,\n height,\n colorTexture,\n colorFormat,\n colorType)\n }\n }\n\n check$1(extensions.webgl_draw_buffers || colorAttachments.length <= 1,\n 'you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers.')\n check$1(colorAttachments.length <= limits.maxColorAttachments,\n 'too many color attachments, not supported')\n\n width = width || colorAttachments[0].width\n height = height || colorAttachments[0].height\n\n if (depthBuffer) {\n depthAttachment = parseAttachment(depthBuffer)\n } else if (needsDepth && !needsStencil) {\n depthAttachment = allocAttachment(\n width,\n height,\n depthStencilTexture,\n 'depth',\n 'uint32')\n }\n\n if (stencilBuffer) {\n stencilAttachment = parseAttachment(stencilBuffer)\n } else if (needsStencil && !needsDepth) {\n stencilAttachment = allocAttachment(\n width,\n height,\n false,\n 'stencil',\n 'uint8')\n }\n\n if (depthStencilBuffer) {\n depthStencilAttachment = parseAttachment(depthStencilBuffer)\n } else if (!depthBuffer && !stencilBuffer && needsStencil && needsDepth) {\n depthStencilAttachment = allocAttachment(\n width,\n height,\n depthStencilTexture,\n 'depth stencil',\n 'depth stencil')\n }\n\n check$1(\n (!!depthBuffer) + (!!stencilBuffer) + (!!depthStencilBuffer) <= 1,\n 'invalid framebuffer configuration, can specify exactly one depth/stencil attachment')\n\n var commonColorAttachmentSize = null\n\n for (i = 0; i < colorAttachments.length; ++i) {\n incRefAndCheckShape(colorAttachments[i], width, height)\n check$1(!colorAttachments[i] ||\n (colorAttachments[i].texture &&\n colorTextureFormatEnums.indexOf(colorAttachments[i].texture._texture.format) >= 0) ||\n (colorAttachments[i].renderbuffer &&\n colorRenderbufferFormatEnums.indexOf(colorAttachments[i].renderbuffer._renderbuffer.format) >= 0),\n 'framebuffer color attachment ' + i + ' is invalid')\n\n if (colorAttachments[i] && colorAttachments[i].texture) {\n var colorAttachmentSize =\n textureFormatChannels[colorAttachments[i].texture._texture.format] *\n textureTypeSizes[colorAttachments[i].texture._texture.type]\n\n if (commonColorAttachmentSize === null) {\n commonColorAttachmentSize = colorAttachmentSize\n } else {\n // We need to make sure that all color attachments have the same number of bitplanes\n // (that is, the same numer of bits per pixel)\n // This is required by the GLES2.0 standard. See the beginning of Chapter 4 in that document.\n check$1(commonColorAttachmentSize === colorAttachmentSize,\n 'all color attachments much have the same number of bits per pixel.')\n }\n }\n }\n incRefAndCheckShape(depthAttachment, width, height)\n check$1(!depthAttachment ||\n (depthAttachment.texture &&\n depthAttachment.texture._texture.format === GL_DEPTH_COMPONENT$1) ||\n (depthAttachment.renderbuffer &&\n depthAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_COMPONENT16$1),\n 'invalid depth attachment for framebuffer object')\n incRefAndCheckShape(stencilAttachment, width, height)\n check$1(!stencilAttachment ||\n (stencilAttachment.renderbuffer &&\n stencilAttachment.renderbuffer._renderbuffer.format === GL_STENCIL_INDEX8$1),\n 'invalid stencil attachment for framebuffer object')\n incRefAndCheckShape(depthStencilAttachment, width, height)\n check$1(!depthStencilAttachment ||\n (depthStencilAttachment.texture &&\n depthStencilAttachment.texture._texture.format === GL_DEPTH_STENCIL$2) ||\n (depthStencilAttachment.renderbuffer &&\n depthStencilAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_STENCIL$2),\n 'invalid depth-stencil attachment for framebuffer object')\n\n // decrement references\n decFBORefs(framebuffer)\n\n framebuffer.width = width\n framebuffer.height = height\n\n framebuffer.colorAttachments = colorAttachments\n framebuffer.depthAttachment = depthAttachment\n framebuffer.stencilAttachment = stencilAttachment\n framebuffer.depthStencilAttachment = depthStencilAttachment\n\n reglFramebuffer.color = colorAttachments.map(unwrapAttachment)\n reglFramebuffer.depth = unwrapAttachment(depthAttachment)\n reglFramebuffer.stencil = unwrapAttachment(stencilAttachment)\n reglFramebuffer.depthStencil = unwrapAttachment(depthStencilAttachment)\n\n reglFramebuffer.width = framebuffer.width\n reglFramebuffer.height = framebuffer.height\n\n updateFramebuffer(framebuffer)\n\n return reglFramebuffer\n }\n\n function resize (w_, h_) {\n check$1(framebufferState.next !== framebuffer,\n 'can not resize a framebuffer which is currently in use')\n\n var w = Math.max(w_ | 0, 1)\n var h = Math.max((h_ | 0) || w, 1)\n if (w === framebuffer.width && h === framebuffer.height) {\n return reglFramebuffer\n }\n\n // resize all buffers\n var colorAttachments = framebuffer.colorAttachments\n for (var i = 0; i < colorAttachments.length; ++i) {\n resizeAttachment(colorAttachments[i], w, h)\n }\n resizeAttachment(framebuffer.depthAttachment, w, h)\n resizeAttachment(framebuffer.stencilAttachment, w, h)\n resizeAttachment(framebuffer.depthStencilAttachment, w, h)\n\n framebuffer.width = reglFramebuffer.width = w\n framebuffer.height = reglFramebuffer.height = h\n\n updateFramebuffer(framebuffer)\n\n return reglFramebuffer\n }\n\n reglFramebuffer(a0, a1)\n\n return extend(reglFramebuffer, {\n resize: resize,\n _reglType: 'framebuffer',\n _framebuffer: framebuffer,\n destroy: function () {\n destroy(framebuffer)\n decFBORefs(framebuffer)\n },\n use: function (block) {\n framebufferState.setFBO({\n framebuffer: reglFramebuffer\n }, block)\n }\n })\n }\n\n function createCubeFBO (options) {\n var faces = Array(6)\n\n function reglFramebufferCube (a) {\n var i\n\n check$1(faces.indexOf(framebufferState.next) < 0,\n 'can not update framebuffer which is currently in use')\n\n var params = {\n color: null\n }\n\n var radius = 0\n\n var colorBuffer = null\n var colorFormat = 'rgba'\n var colorType = 'uint8'\n var colorCount = 1\n\n if (typeof a === 'number') {\n radius = a | 0\n } else if (!a) {\n radius = 1\n } else {\n check$1.type(a, 'object', 'invalid arguments for framebuffer')\n var options = a\n\n if ('shape' in options) {\n var shape = options.shape\n check$1(\n Array.isArray(shape) && shape.length >= 2,\n 'invalid shape for framebuffer')\n check$1(\n shape[0] === shape[1],\n 'cube framebuffer must be square')\n radius = shape[0]\n } else {\n if ('radius' in options) {\n radius = options.radius | 0\n }\n if ('width' in options) {\n radius = options.width | 0\n if ('height' in options) {\n check$1(options.height === radius, 'must be square')\n }\n } else if ('height' in options) {\n radius = options.height | 0\n }\n }\n\n if ('color' in options ||\n 'colors' in options) {\n colorBuffer =\n options.color ||\n options.colors\n if (Array.isArray(colorBuffer)) {\n check$1(\n colorBuffer.length === 1 || extensions.webgl_draw_buffers,\n 'multiple render targets not supported')\n }\n }\n\n if (!colorBuffer) {\n if ('colorCount' in options) {\n colorCount = options.colorCount | 0\n check$1(colorCount > 0, 'invalid color buffer count')\n }\n\n if ('colorType' in options) {\n check$1.oneOf(\n options.colorType, colorTypes,\n 'invalid color type')\n colorType = options.colorType\n }\n\n if ('colorFormat' in options) {\n colorFormat = options.colorFormat\n check$1.oneOf(\n options.colorFormat, colorTextureFormats,\n 'invalid color format for texture')\n }\n }\n\n if ('depth' in options) {\n params.depth = options.depth\n }\n\n if ('stencil' in options) {\n params.stencil = options.stencil\n }\n\n if ('depthStencil' in options) {\n params.depthStencil = options.depthStencil\n }\n }\n\n var colorCubes\n if (colorBuffer) {\n if (Array.isArray(colorBuffer)) {\n colorCubes = []\n for (i = 0; i < colorBuffer.length; ++i) {\n colorCubes[i] = colorBuffer[i]\n }\n } else {\n colorCubes = [ colorBuffer ]\n }\n } else {\n colorCubes = Array(colorCount)\n var cubeMapParams = {\n radius: radius,\n format: colorFormat,\n type: colorType\n }\n for (i = 0; i < colorCount; ++i) {\n colorCubes[i] = textureState.createCube(cubeMapParams)\n }\n }\n\n // Check color cubes\n params.color = Array(colorCubes.length)\n for (i = 0; i < colorCubes.length; ++i) {\n var cube = colorCubes[i]\n check$1(\n typeof cube === 'function' && cube._reglType === 'textureCube',\n 'invalid cube map')\n radius = radius || cube.width\n check$1(\n cube.width === radius && cube.height === radius,\n 'invalid cube map shape')\n params.color[i] = {\n target: GL_TEXTURE_CUBE_MAP_POSITIVE_X$2,\n data: colorCubes[i]\n }\n }\n\n for (i = 0; i < 6; ++i) {\n for (var j = 0; j < colorCubes.length; ++j) {\n params.color[j].target = GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 + i\n }\n // reuse depth-stencil attachments across all cube maps\n if (i > 0) {\n params.depth = faces[0].depth\n params.stencil = faces[0].stencil\n params.depthStencil = faces[0].depthStencil\n }\n if (faces[i]) {\n (faces[i])(params)\n } else {\n faces[i] = createFBO(params)\n }\n }\n\n return extend(reglFramebufferCube, {\n width: radius,\n height: radius,\n color: colorCubes\n })\n }\n\n function resize (radius_) {\n var i\n var radius = radius_ | 0\n check$1(radius > 0 && radius <= limits.maxCubeMapSize,\n 'invalid radius for cube fbo')\n\n if (radius === reglFramebufferCube.width) {\n return reglFramebufferCube\n }\n\n var colors = reglFramebufferCube.color\n for (i = 0; i < colors.length; ++i) {\n colors[i].resize(radius)\n }\n\n for (i = 0; i < 6; ++i) {\n faces[i].resize(radius)\n }\n\n reglFramebufferCube.width = reglFramebufferCube.height = radius\n\n return reglFramebufferCube\n }\n\n reglFramebufferCube(options)\n\n return extend(reglFramebufferCube, {\n faces: faces,\n resize: resize,\n _reglType: 'framebufferCube',\n destroy: function () {\n faces.forEach(function (f) {\n f.destroy()\n })\n }\n })\n }\n\n function restoreFramebuffers () {\n framebufferState.cur = null\n framebufferState.next = null\n framebufferState.dirty = true\n values(framebufferSet).forEach(function (fb) {\n fb.framebuffer = gl.createFramebuffer()\n updateFramebuffer(fb)\n })\n }\n\n return extend(framebufferState, {\n getFramebuffer: function (object) {\n if (typeof object === 'function' && object._reglType === 'framebuffer') {\n var fbo = object._framebuffer\n if (fbo instanceof REGLFramebuffer) {\n return fbo\n }\n }\n return null\n },\n create: createFBO,\n createCube: createCubeFBO,\n clear: function () {\n values(framebufferSet).forEach(destroy)\n },\n restore: restoreFramebuffers\n })\n}\n\nvar GL_FLOAT$6 = 5126\nvar GL_ARRAY_BUFFER$1 = 34962\n\nfunction AttributeRecord () {\n this.state = 0\n\n this.x = 0.0\n this.y = 0.0\n this.z = 0.0\n this.w = 0.0\n\n this.buffer = null\n this.size = 0\n this.normalized = false\n this.type = GL_FLOAT$6\n this.offset = 0\n this.stride = 0\n this.divisor = 0\n}\n\nfunction wrapAttributeState (\n gl,\n extensions,\n limits,\n stats,\n bufferState) {\n var NUM_ATTRIBUTES = limits.maxAttributes\n var attributeBindings = new Array(NUM_ATTRIBUTES)\n for (var i = 0; i < NUM_ATTRIBUTES; ++i) {\n attributeBindings[i] = new AttributeRecord()\n }\n var vaoCount = 0\n var vaoSet = {}\n\n var state = {\n Record: AttributeRecord,\n scope: {},\n state: attributeBindings,\n currentVAO: null,\n targetVAO: null,\n restore: extVAO() ? restoreVAO : function () {},\n createVAO: createVAO,\n getVAO: getVAO,\n destroyBuffer: destroyBuffer,\n setVAO: extVAO() ? setVAOEXT : setVAOEmulated,\n clear: extVAO() ? destroyVAOEXT : function () {}\n }\n\n function destroyBuffer (buffer) {\n for (var i = 0; i < attributeBindings.length; ++i) {\n var record = attributeBindings[i]\n if (record.buffer === buffer) {\n gl.disableVertexAttribArray(i)\n record.buffer = null\n }\n }\n }\n\n function extVAO () {\n return extensions.oes_vertex_array_object\n }\n\n function extInstanced () {\n return extensions.angle_instanced_arrays\n }\n\n function getVAO (vao) {\n if (typeof vao === 'function' && vao._vao) {\n return vao._vao\n }\n return null\n }\n\n function setVAOEXT (vao) {\n if (vao === state.currentVAO) {\n return\n }\n var ext = extVAO()\n if (vao) {\n ext.bindVertexArrayOES(vao.vao)\n } else {\n ext.bindVertexArrayOES(null)\n }\n state.currentVAO = vao\n }\n\n function setVAOEmulated (vao) {\n if (vao === state.currentVAO) {\n return\n }\n if (vao) {\n vao.bindAttrs()\n } else {\n var exti = extInstanced()\n for (var i = 0; i < attributeBindings.length; ++i) {\n var binding = attributeBindings[i]\n if (binding.buffer) {\n gl.enableVertexAttribArray(i)\n gl.vertexAttribPointer(i, binding.size, binding.type, binding.normalized, binding.stride, binding.offfset)\n if (exti && binding.divisor) {\n exti.vertexAttribDivisorANGLE(i, binding.divisor)\n }\n } else {\n gl.disableVertexAttribArray(i)\n gl.vertexAttrib4f(i, binding.x, binding.y, binding.z, binding.w)\n }\n }\n }\n state.currentVAO = vao\n }\n\n function destroyVAOEXT () {\n values(vaoSet).forEach(function (vao) {\n vao.destroy()\n })\n }\n\n function REGLVAO () {\n this.id = ++vaoCount\n this.attributes = []\n var extension = extVAO()\n if (extension) {\n this.vao = extension.createVertexArrayOES()\n } else {\n this.vao = null\n }\n vaoSet[this.id] = this\n this.buffers = []\n }\n\n REGLVAO.prototype.bindAttrs = function () {\n var exti = extInstanced()\n var attributes = this.attributes\n for (var i = 0; i < attributes.length; ++i) {\n var attr = attributes[i]\n if (attr.buffer) {\n gl.enableVertexAttribArray(i)\n gl.bindBuffer(GL_ARRAY_BUFFER$1, attr.buffer.buffer)\n gl.vertexAttribPointer(i, attr.size, attr.type, attr.normalized, attr.stride, attr.offset)\n if (exti && attr.divisor) {\n exti.vertexAttribDivisorANGLE(i, attr.divisor)\n }\n } else {\n gl.disableVertexAttribArray(i)\n gl.vertexAttrib4f(i, attr.x, attr.y, attr.z, attr.w)\n }\n }\n for (var j = attributes.length; j < NUM_ATTRIBUTES; ++j) {\n gl.disableVertexAttribArray(j)\n }\n }\n\n REGLVAO.prototype.refresh = function () {\n var ext = extVAO()\n if (ext) {\n ext.bindVertexArrayOES(this.vao)\n this.bindAttrs()\n state.currentVAO = this\n }\n }\n\n REGLVAO.prototype.destroy = function () {\n if (this.vao) {\n var extension = extVAO()\n if (this === state.currentVAO) {\n state.currentVAO = null\n extension.bindVertexArrayOES(null)\n }\n extension.deleteVertexArrayOES(this.vao)\n this.vao = null\n }\n if (vaoSet[this.id]) {\n delete vaoSet[this.id]\n stats.vaoCount -= 1\n }\n }\n\n function restoreVAO () {\n var ext = extVAO()\n if (ext) {\n values(vaoSet).forEach(function (vao) {\n vao.refresh()\n })\n }\n }\n\n function createVAO (_attr) {\n var vao = new REGLVAO()\n stats.vaoCount += 1\n\n function updateVAO (attributes) {\n check$1(Array.isArray(attributes), 'arguments to vertex array constructor must be an array')\n check$1(attributes.length < NUM_ATTRIBUTES, 'too many attributes')\n check$1(attributes.length > 0, 'must specify at least one attribute')\n\n var bufUpdated = {}\n var nattributes = vao.attributes\n nattributes.length = attributes.length\n for (var i = 0; i < attributes.length; ++i) {\n var spec = attributes[i]\n var rec = nattributes[i] = new AttributeRecord()\n var data = spec.data || spec\n if (Array.isArray(data) || isTypedArray(data) || isNDArrayLike(data)) {\n var buf\n if (vao.buffers[i]) {\n buf = vao.buffers[i]\n if (isTypedArray(data) && buf._buffer.byteLength >= data.byteLength) {\n buf.subdata(data)\n } else {\n buf.destroy()\n vao.buffers[i] = null\n }\n }\n if (!vao.buffers[i]) {\n buf = vao.buffers[i] = bufferState.create(spec, GL_ARRAY_BUFFER$1, false, true)\n }\n rec.buffer = bufferState.getBuffer(buf)\n rec.size = rec.buffer.dimension | 0\n rec.normalized = false\n rec.type = rec.buffer.dtype\n rec.offset = 0\n rec.stride = 0\n rec.divisor = 0\n rec.state = 1\n bufUpdated[i] = 1\n } else if (bufferState.getBuffer(spec)) {\n rec.buffer = bufferState.getBuffer(spec)\n rec.size = rec.buffer.dimension | 0\n rec.normalized = false\n rec.type = rec.buffer.dtype\n rec.offset = 0\n rec.stride = 0\n rec.divisor = 0\n rec.state = 1\n } else if (bufferState.getBuffer(spec.buffer)) {\n rec.buffer = bufferState.getBuffer(spec.buffer)\n rec.size = ((+spec.size) || rec.buffer.dimension) | 0\n rec.normalized = !!spec.normalized || false\n if ('type' in spec) {\n check$1.parameter(spec.type, glTypes, 'invalid buffer type')\n rec.type = glTypes[spec.type]\n } else {\n rec.type = rec.buffer.dtype\n }\n rec.offset = (spec.offset || 0) | 0\n rec.stride = (spec.stride || 0) | 0\n rec.divisor = (spec.divisor || 0) | 0\n rec.state = 1\n\n check$1(rec.size >= 1 && rec.size <= 4, 'size must be between 1 and 4')\n check$1(rec.offset >= 0, 'invalid offset')\n check$1(rec.stride >= 0 && rec.stride <= 255, 'stride must be between 0 and 255')\n check$1(rec.divisor >= 0, 'divisor must be positive')\n check$1(!rec.divisor || !!extensions.angle_instanced_arrays, 'ANGLE_instanced_arrays must be enabled to use divisor')\n } else if ('x' in spec) {\n check$1(i > 0, 'first attribute must not be a constant')\n rec.x = +spec.x || 0\n rec.y = +spec.y || 0\n rec.z = +spec.z || 0\n rec.w = +spec.w || 0\n rec.state = 2\n } else {\n check$1(false, 'invalid attribute spec for location ' + i)\n }\n }\n\n // retire unused buffers\n for (var j = 0; j < vao.buffers.length; ++j) {\n if (!bufUpdated[j] && vao.buffers[j]) {\n vao.buffers[j].destroy()\n vao.buffers[j] = null\n }\n }\n\n vao.refresh()\n return updateVAO\n }\n\n updateVAO.destroy = function () {\n for (var j = 0; j < vao.buffers.length; ++j) {\n if (vao.buffers[j]) {\n vao.buffers[j].destroy()\n }\n }\n vao.buffers.length = 0\n vao.destroy()\n }\n\n updateVAO._vao = vao\n updateVAO._reglType = 'vao'\n\n return updateVAO(_attr)\n }\n\n return state\n}\n\nvar GL_FRAGMENT_SHADER = 35632\nvar GL_VERTEX_SHADER = 35633\n\nvar GL_ACTIVE_UNIFORMS = 0x8B86\nvar GL_ACTIVE_ATTRIBUTES = 0x8B89\n\nfunction wrapShaderState (gl, stringStore, stats, config) {\n // ===================================================\n // glsl compilation and linking\n // ===================================================\n var fragShaders = {}\n var vertShaders = {}\n\n function ActiveInfo (name, id, location, info) {\n this.name = name\n this.id = id\n this.location = location\n this.info = info\n }\n\n function insertActiveInfo (list, info) {\n for (var i = 0; i < list.length; ++i) {\n if (list[i].id === info.id) {\n list[i].location = info.location\n return\n }\n }\n list.push(info)\n }\n\n function getShader (type, id, command) {\n var cache = type === GL_FRAGMENT_SHADER ? fragShaders : vertShaders\n var shader = cache[id]\n\n if (!shader) {\n var source = stringStore.str(id)\n shader = gl.createShader(type)\n gl.shaderSource(shader, source)\n gl.compileShader(shader)\n check$1.shaderError(gl, shader, source, type, command)\n cache[id] = shader\n }\n\n return shader\n }\n\n // ===================================================\n // program linking\n // ===================================================\n var programCache = {}\n var programList = []\n\n var PROGRAM_COUNTER = 0\n\n function REGLProgram (fragId, vertId) {\n this.id = PROGRAM_COUNTER++\n this.fragId = fragId\n this.vertId = vertId\n this.program = null\n this.uniforms = []\n this.attributes = []\n this.refCount = 1\n\n if (config.profile) {\n this.stats = {\n uniformsCount: 0,\n attributesCount: 0\n }\n }\n }\n\n function linkProgram (desc, command, attributeLocations) {\n var i, info\n\n // -------------------------------\n // compile & link\n // -------------------------------\n var fragShader = getShader(GL_FRAGMENT_SHADER, desc.fragId)\n var vertShader = getShader(GL_VERTEX_SHADER, desc.vertId)\n\n var program = desc.program = gl.createProgram()\n gl.attachShader(program, fragShader)\n gl.attachShader(program, vertShader)\n if (attributeLocations) {\n for (i = 0; i < attributeLocations.length; ++i) {\n var binding = attributeLocations[i]\n gl.bindAttribLocation(program, binding[0], binding[1])\n }\n }\n\n gl.linkProgram(program)\n check$1.linkError(\n gl,\n program,\n stringStore.str(desc.fragId),\n stringStore.str(desc.vertId),\n command)\n\n // -------------------------------\n // grab uniforms\n // -------------------------------\n var numUniforms = gl.getProgramParameter(program, GL_ACTIVE_UNIFORMS)\n if (config.profile) {\n desc.stats.uniformsCount = numUniforms\n }\n var uniforms = desc.uniforms\n for (i = 0; i < numUniforms; ++i) {\n info = gl.getActiveUniform(program, i)\n if (info) {\n if (info.size > 1) {\n for (var j = 0; j < info.size; ++j) {\n var name = info.name.replace('[0]', '[' + j + ']')\n insertActiveInfo(uniforms, new ActiveInfo(\n name,\n stringStore.id(name),\n gl.getUniformLocation(program, name),\n info))\n }\n } else {\n insertActiveInfo(uniforms, new ActiveInfo(\n info.name,\n stringStore.id(info.name),\n gl.getUniformLocation(program, info.name),\n info))\n }\n }\n }\n\n // -------------------------------\n // grab attributes\n // -------------------------------\n var numAttributes = gl.getProgramParameter(program, GL_ACTIVE_ATTRIBUTES)\n if (config.profile) {\n desc.stats.attributesCount = numAttributes\n }\n\n var attributes = desc.attributes\n for (i = 0; i < numAttributes; ++i) {\n info = gl.getActiveAttrib(program, i)\n if (info) {\n insertActiveInfo(attributes, new ActiveInfo(\n info.name,\n stringStore.id(info.name),\n gl.getAttribLocation(program, info.name),\n info))\n }\n }\n }\n\n if (config.profile) {\n stats.getMaxUniformsCount = function () {\n var m = 0\n programList.forEach(function (desc) {\n if (desc.stats.uniformsCount > m) {\n m = desc.stats.uniformsCount\n }\n })\n return m\n }\n\n stats.getMaxAttributesCount = function () {\n var m = 0\n programList.forEach(function (desc) {\n if (desc.stats.attributesCount > m) {\n m = desc.stats.attributesCount\n }\n })\n return m\n }\n }\n\n function restoreShaders () {\n fragShaders = {}\n vertShaders = {}\n for (var i = 0; i < programList.length; ++i) {\n linkProgram(programList[i], null, programList[i].attributes.map(function (info) {\n return [info.location, info.name]\n }))\n }\n }\n\n return {\n clear: function () {\n var deleteShader = gl.deleteShader.bind(gl)\n values(fragShaders).forEach(deleteShader)\n fragShaders = {}\n values(vertShaders).forEach(deleteShader)\n vertShaders = {}\n\n programList.forEach(function (desc) {\n gl.deleteProgram(desc.program)\n })\n programList.length = 0\n programCache = {}\n\n stats.shaderCount = 0\n },\n\n program: function (vertId, fragId, command, attribLocations) {\n check$1.command(vertId >= 0, 'missing vertex shader', command)\n check$1.command(fragId >= 0, 'missing fragment shader', command)\n\n var cache = programCache[fragId]\n if (!cache) {\n cache = programCache[fragId] = {}\n }\n var prevProgram = cache[vertId]\n if (prevProgram) {\n prevProgram.refCount++\n if (!attribLocations) {\n return prevProgram\n }\n }\n var program = new REGLProgram(fragId, vertId)\n stats.shaderCount++\n linkProgram(program, command, attribLocations)\n if (!prevProgram) {\n cache[vertId] = program\n }\n programList.push(program)\n return extend(program, {\n destroy: function () {\n program.refCount--\n if (program.refCount <= 0) {\n gl.deleteProgram(program.program)\n var idx = programList.indexOf(program)\n programList.splice(idx, 1)\n stats.shaderCount--\n }\n // no program is linked to this vert anymore\n if (cache[program.vertId].refCount <= 0) {\n gl.deleteShader(vertShaders[program.vertId])\n delete vertShaders[program.vertId]\n delete programCache[program.fragId][program.vertId]\n }\n // no program is linked to this frag anymore\n if (!Object.keys(programCache[program.fragId]).length) {\n gl.deleteShader(fragShaders[program.fragId])\n delete fragShaders[program.fragId]\n delete programCache[program.fragId]\n }\n }\n })\n },\n\n restore: restoreShaders,\n\n shader: getShader,\n\n frag: -1,\n vert: -1\n }\n}\n\nvar GL_RGBA$3 = 6408\nvar GL_UNSIGNED_BYTE$7 = 5121\nvar GL_PACK_ALIGNMENT = 0x0D05\nvar GL_FLOAT$7 = 0x1406 // 5126\n\nfunction wrapReadPixels (\n gl,\n framebufferState,\n reglPoll,\n context,\n glAttributes,\n extensions,\n limits) {\n function readPixelsImpl (input) {\n var type\n if (framebufferState.next === null) {\n check$1(\n glAttributes.preserveDrawingBuffer,\n 'you must create a webgl context with \"preserveDrawingBuffer\":true in order to read pixels from the drawing buffer')\n type = GL_UNSIGNED_BYTE$7\n } else {\n check$1(\n framebufferState.next.colorAttachments[0].texture !== null,\n 'You cannot read from a renderbuffer')\n type = framebufferState.next.colorAttachments[0].texture._texture.type\n\n if (extensions.oes_texture_float) {\n check$1(\n type === GL_UNSIGNED_BYTE$7 || type === GL_FLOAT$7,\n 'Reading from a framebuffer is only allowed for the types \\'uint8\\' and \\'float\\'')\n\n if (type === GL_FLOAT$7) {\n check$1(limits.readFloat, 'Reading \\'float\\' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float')\n }\n } else {\n check$1(\n type === GL_UNSIGNED_BYTE$7,\n 'Reading from a framebuffer is only allowed for the type \\'uint8\\'')\n }\n }\n\n var x = 0\n var y = 0\n var width = context.framebufferWidth\n var height = context.framebufferHeight\n var data = null\n\n if (isTypedArray(input)) {\n data = input\n } else if (input) {\n check$1.type(input, 'object', 'invalid arguments to regl.read()')\n x = input.x | 0\n y = input.y | 0\n check$1(\n x >= 0 && x < context.framebufferWidth,\n 'invalid x offset for regl.read')\n check$1(\n y >= 0 && y < context.framebufferHeight,\n 'invalid y offset for regl.read')\n width = (input.width || (context.framebufferWidth - x)) | 0\n height = (input.height || (context.framebufferHeight - y)) | 0\n data = input.data || null\n }\n\n // sanity check input.data\n if (data) {\n if (type === GL_UNSIGNED_BYTE$7) {\n check$1(\n data instanceof Uint8Array,\n 'buffer must be \\'Uint8Array\\' when reading from a framebuffer of type \\'uint8\\'')\n } else if (type === GL_FLOAT$7) {\n check$1(\n data instanceof Float32Array,\n 'buffer must be \\'Float32Array\\' when reading from a framebuffer of type \\'float\\'')\n }\n }\n\n check$1(\n width > 0 && width + x <= context.framebufferWidth,\n 'invalid width for read pixels')\n check$1(\n height > 0 && height + y <= context.framebufferHeight,\n 'invalid height for read pixels')\n\n // Update WebGL state\n reglPoll()\n\n // Compute size\n var size = width * height * 4\n\n // Allocate data\n if (!data) {\n if (type === GL_UNSIGNED_BYTE$7) {\n data = new Uint8Array(size)\n } else if (type === GL_FLOAT$7) {\n data = data || new Float32Array(size)\n }\n }\n\n // Type check\n check$1.isTypedArray(data, 'data buffer for regl.read() must be a typedarray')\n check$1(data.byteLength >= size, 'data buffer for regl.read() too small')\n\n // Run read pixels\n gl.pixelStorei(GL_PACK_ALIGNMENT, 4)\n gl.readPixels(x, y, width, height, GL_RGBA$3,\n type,\n data)\n\n return data\n }\n\n function readPixelsFBO (options) {\n var result\n framebufferState.setFBO({\n framebuffer: options.framebuffer\n }, function () {\n result = readPixelsImpl(options)\n })\n return result\n }\n\n function readPixels (options) {\n if (!options || !('framebuffer' in options)) {\n return readPixelsImpl(options)\n } else {\n return readPixelsFBO(options)\n }\n }\n\n return readPixels\n}\n\nfunction slice (x) {\n return Array.prototype.slice.call(x)\n}\n\nfunction join (x) {\n return slice(x).join('')\n}\n\nfunction createEnvironment () {\n // Unique variable id counter\n var varCounter = 0\n\n // Linked values are passed from this scope into the generated code block\n // Calling link() passes a value into the generated scope and returns\n // the variable name which it is bound to\n var linkedNames = []\n var linkedValues = []\n function link (value) {\n for (var i = 0; i < linkedValues.length; ++i) {\n if (linkedValues[i] === value) {\n return linkedNames[i]\n }\n }\n\n var name = 'g' + (varCounter++)\n linkedNames.push(name)\n linkedValues.push(value)\n return name\n }\n\n // create a code block\n function block () {\n var code = []\n function push () {\n code.push.apply(code, slice(arguments))\n }\n\n var vars = []\n function def () {\n var name = 'v' + (varCounter++)\n vars.push(name)\n\n if (arguments.length > 0) {\n code.push(name, '=')\n code.push.apply(code, slice(arguments))\n code.push(';')\n }\n\n return name\n }\n\n return extend(push, {\n def: def,\n toString: function () {\n return join([\n (vars.length > 0 ? 'var ' + vars.join(',') + ';' : ''),\n join(code)\n ])\n }\n })\n }\n\n function scope () {\n var entry = block()\n var exit = block()\n\n var entryToString = entry.toString\n var exitToString = exit.toString\n\n function save (object, prop) {\n exit(object, prop, '=', entry.def(object, prop), ';')\n }\n\n return extend(function () {\n entry.apply(entry, slice(arguments))\n }, {\n def: entry.def,\n entry: entry,\n exit: exit,\n save: save,\n set: function (object, prop, value) {\n save(object, prop)\n entry(object, prop, '=', value, ';')\n },\n toString: function () {\n return entryToString() + exitToString()\n }\n })\n }\n\n function conditional () {\n var pred = join(arguments)\n var thenBlock = scope()\n var elseBlock = scope()\n\n var thenToString = thenBlock.toString\n var elseToString = elseBlock.toString\n\n return extend(thenBlock, {\n then: function () {\n thenBlock.apply(thenBlock, slice(arguments))\n return this\n },\n else: function () {\n elseBlock.apply(elseBlock, slice(arguments))\n return this\n },\n toString: function () {\n var elseClause = elseToString()\n if (elseClause) {\n elseClause = 'else{' + elseClause + '}'\n }\n return join([\n 'if(', pred, '){',\n thenToString(),\n '}', elseClause\n ])\n }\n })\n }\n\n // procedure list\n var globalBlock = block()\n var procedures = {}\n function proc (name, count) {\n var args = []\n function arg () {\n var name = 'a' + args.length\n args.push(name)\n return name\n }\n\n count = count || 0\n for (var i = 0; i < count; ++i) {\n arg()\n }\n\n var body = scope()\n var bodyToString = body.toString\n\n var result = procedures[name] = extend(body, {\n arg: arg,\n toString: function () {\n return join([\n 'function(', args.join(), '){',\n bodyToString(),\n '}'\n ])\n }\n })\n\n return result\n }\n\n function compile () {\n var code = ['\"use strict\";',\n globalBlock,\n 'return {']\n Object.keys(procedures).forEach(function (name) {\n code.push('\"', name, '\":', procedures[name].toString(), ',')\n })\n code.push('}')\n var src = join(code)\n .replace(/;/g, ';\\n')\n .replace(/}/g, '}\\n')\n .replace(/{/g, '{\\n')\n var proc = Function.apply(null, linkedNames.concat(src))\n return proc.apply(null, linkedValues)\n }\n\n return {\n global: globalBlock,\n link: link,\n block: block,\n proc: proc,\n scope: scope,\n cond: conditional,\n compile: compile\n }\n}\n\n// \"cute\" names for vector components\nvar CUTE_COMPONENTS = 'xyzw'.split('')\n\nvar GL_UNSIGNED_BYTE$8 = 5121\n\nvar ATTRIB_STATE_POINTER = 1\nvar ATTRIB_STATE_CONSTANT = 2\n\nvar DYN_FUNC$1 = 0\nvar DYN_PROP$1 = 1\nvar DYN_CONTEXT$1 = 2\nvar DYN_STATE$1 = 3\nvar DYN_THUNK = 4\nvar DYN_CONSTANT$1 = 5\nvar DYN_ARRAY$1 = 6\n\nvar S_DITHER = 'dither'\nvar S_BLEND_ENABLE = 'blend.enable'\nvar S_BLEND_COLOR = 'blend.color'\nvar S_BLEND_EQUATION = 'blend.equation'\nvar S_BLEND_FUNC = 'blend.func'\nvar S_DEPTH_ENABLE = 'depth.enable'\nvar S_DEPTH_FUNC = 'depth.func'\nvar S_DEPTH_RANGE = 'depth.range'\nvar S_DEPTH_MASK = 'depth.mask'\nvar S_COLOR_MASK = 'colorMask'\nvar S_CULL_ENABLE = 'cull.enable'\nvar S_CULL_FACE = 'cull.face'\nvar S_FRONT_FACE = 'frontFace'\nvar S_LINE_WIDTH = 'lineWidth'\nvar S_POLYGON_OFFSET_ENABLE = 'polygonOffset.enable'\nvar S_POLYGON_OFFSET_OFFSET = 'polygonOffset.offset'\nvar S_SAMPLE_ALPHA = 'sample.alpha'\nvar S_SAMPLE_ENABLE = 'sample.enable'\nvar S_SAMPLE_COVERAGE = 'sample.coverage'\nvar S_STENCIL_ENABLE = 'stencil.enable'\nvar S_STENCIL_MASK = 'stencil.mask'\nvar S_STENCIL_FUNC = 'stencil.func'\nvar S_STENCIL_OPFRONT = 'stencil.opFront'\nvar S_STENCIL_OPBACK = 'stencil.opBack'\nvar S_SCISSOR_ENABLE = 'scissor.enable'\nvar S_SCISSOR_BOX = 'scissor.box'\nvar S_VIEWPORT = 'viewport'\n\nvar S_PROFILE = 'profile'\n\nvar S_FRAMEBUFFER = 'framebuffer'\nvar S_VERT = 'vert'\nvar S_FRAG = 'frag'\nvar S_ELEMENTS = 'elements'\nvar S_PRIMITIVE = 'primitive'\nvar S_COUNT = 'count'\nvar S_OFFSET = 'offset'\nvar S_INSTANCES = 'instances'\nvar S_VAO = 'vao'\n\nvar SUFFIX_WIDTH = 'Width'\nvar SUFFIX_HEIGHT = 'Height'\n\nvar S_FRAMEBUFFER_WIDTH = S_FRAMEBUFFER + SUFFIX_WIDTH\nvar S_FRAMEBUFFER_HEIGHT = S_FRAMEBUFFER + SUFFIX_HEIGHT\nvar S_VIEWPORT_WIDTH = S_VIEWPORT + SUFFIX_WIDTH\nvar S_VIEWPORT_HEIGHT = S_VIEWPORT + SUFFIX_HEIGHT\nvar S_DRAWINGBUFFER = 'drawingBuffer'\nvar S_DRAWINGBUFFER_WIDTH = S_DRAWINGBUFFER + SUFFIX_WIDTH\nvar S_DRAWINGBUFFER_HEIGHT = S_DRAWINGBUFFER + SUFFIX_HEIGHT\n\nvar NESTED_OPTIONS = [\n S_BLEND_FUNC,\n S_BLEND_EQUATION,\n S_STENCIL_FUNC,\n S_STENCIL_OPFRONT,\n S_STENCIL_OPBACK,\n S_SAMPLE_COVERAGE,\n S_VIEWPORT,\n S_SCISSOR_BOX,\n S_POLYGON_OFFSET_OFFSET\n]\n\nvar GL_ARRAY_BUFFER$2 = 34962\nvar GL_ELEMENT_ARRAY_BUFFER$1 = 34963\n\nvar GL_FRAGMENT_SHADER$1 = 35632\nvar GL_VERTEX_SHADER$1 = 35633\n\nvar GL_TEXTURE_2D$3 = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP$2 = 0x8513\n\nvar GL_CULL_FACE = 0x0B44\nvar GL_BLEND = 0x0BE2\nvar GL_DITHER = 0x0BD0\nvar GL_STENCIL_TEST = 0x0B90\nvar GL_DEPTH_TEST = 0x0B71\nvar GL_SCISSOR_TEST = 0x0C11\nvar GL_POLYGON_OFFSET_FILL = 0x8037\nvar GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E\nvar GL_SAMPLE_COVERAGE = 0x80A0\n\nvar GL_FLOAT$8 = 5126\nvar GL_FLOAT_VEC2 = 35664\nvar GL_FLOAT_VEC3 = 35665\nvar GL_FLOAT_VEC4 = 35666\nvar GL_INT$3 = 5124\nvar GL_INT_VEC2 = 35667\nvar GL_INT_VEC3 = 35668\nvar GL_INT_VEC4 = 35669\nvar GL_BOOL = 35670\nvar GL_BOOL_VEC2 = 35671\nvar GL_BOOL_VEC3 = 35672\nvar GL_BOOL_VEC4 = 35673\nvar GL_FLOAT_MAT2 = 35674\nvar GL_FLOAT_MAT3 = 35675\nvar GL_FLOAT_MAT4 = 35676\nvar GL_SAMPLER_2D = 35678\nvar GL_SAMPLER_CUBE = 35680\n\nvar GL_TRIANGLES$1 = 4\n\nvar GL_FRONT = 1028\nvar GL_BACK = 1029\nvar GL_CW = 0x0900\nvar GL_CCW = 0x0901\nvar GL_MIN_EXT = 0x8007\nvar GL_MAX_EXT = 0x8008\nvar GL_ALWAYS = 519\nvar GL_KEEP = 7680\nvar GL_ZERO = 0\nvar GL_ONE = 1\nvar GL_FUNC_ADD = 0x8006\nvar GL_LESS = 513\n\nvar GL_FRAMEBUFFER$2 = 0x8D40\nvar GL_COLOR_ATTACHMENT0$2 = 0x8CE0\n\nvar blendFuncs = {\n '0': 0,\n '1': 1,\n 'zero': 0,\n 'one': 1,\n 'src color': 768,\n 'one minus src color': 769,\n 'src alpha': 770,\n 'one minus src alpha': 771,\n 'dst color': 774,\n 'one minus dst color': 775,\n 'dst alpha': 772,\n 'one minus dst alpha': 773,\n 'constant color': 32769,\n 'one minus constant color': 32770,\n 'constant alpha': 32771,\n 'one minus constant alpha': 32772,\n 'src alpha saturate': 776\n}\n\n// There are invalid values for srcRGB and dstRGB. See:\n// https://www.khronos.org/registry/webgl/specs/1.0/#6.13\n// https://github.com/KhronosGroup/WebGL/blob/0d3201f5f7ec3c0060bc1f04077461541f1987b9/conformance-suites/1.0.3/conformance/misc/webgl-specific.html#L56\nvar invalidBlendCombinations = [\n 'constant color, constant alpha',\n 'one minus constant color, constant alpha',\n 'constant color, one minus constant alpha',\n 'one minus constant color, one minus constant alpha',\n 'constant alpha, constant color',\n 'constant alpha, one minus constant color',\n 'one minus constant alpha, constant color',\n 'one minus constant alpha, one minus constant color'\n]\n\nvar compareFuncs = {\n 'never': 512,\n 'less': 513,\n '<': 513,\n 'equal': 514,\n '=': 514,\n '==': 514,\n '===': 514,\n 'lequal': 515,\n '<=': 515,\n 'greater': 516,\n '>': 516,\n 'notequal': 517,\n '!=': 517,\n '!==': 517,\n 'gequal': 518,\n '>=': 518,\n 'always': 519\n}\n\nvar stencilOps = {\n '0': 0,\n 'zero': 0,\n 'keep': 7680,\n 'replace': 7681,\n 'increment': 7682,\n 'decrement': 7683,\n 'increment wrap': 34055,\n 'decrement wrap': 34056,\n 'invert': 5386\n}\n\nvar shaderType = {\n 'frag': GL_FRAGMENT_SHADER$1,\n 'vert': GL_VERTEX_SHADER$1\n}\n\nvar orientationType = {\n 'cw': GL_CW,\n 'ccw': GL_CCW\n}\n\nfunction isBufferArgs (x) {\n return Array.isArray(x) ||\n isTypedArray(x) ||\n isNDArrayLike(x)\n}\n\n// Make sure viewport is processed first\nfunction sortState (state) {\n return state.sort(function (a, b) {\n if (a === S_VIEWPORT) {\n return -1\n } else if (b === S_VIEWPORT) {\n return 1\n }\n return (a < b) ? -1 : 1\n })\n}\n\nfunction Declaration (thisDep, contextDep, propDep, append) {\n this.thisDep = thisDep\n this.contextDep = contextDep\n this.propDep = propDep\n this.append = append\n}\n\nfunction isStatic (decl) {\n return decl && !(decl.thisDep || decl.contextDep || decl.propDep)\n}\n\nfunction createStaticDecl (append) {\n return new Declaration(false, false, false, append)\n}\n\nfunction createDynamicDecl (dyn, append) {\n var type = dyn.type\n if (type === DYN_FUNC$1) {\n var numArgs = dyn.data.length\n return new Declaration(\n true,\n numArgs >= 1,\n numArgs >= 2,\n append)\n } else if (type === DYN_THUNK) {\n var data = dyn.data\n return new Declaration(\n data.thisDep,\n data.contextDep,\n data.propDep,\n append)\n } else if (type === DYN_CONSTANT$1) {\n return new Declaration(\n false,\n false,\n false,\n append)\n } else if (type === DYN_ARRAY$1) {\n var thisDep = false\n var contextDep = false\n var propDep = false\n for (var i = 0; i < dyn.data.length; ++i) {\n var subDyn = dyn.data[i]\n if (subDyn.type === DYN_PROP$1) {\n propDep = true\n } else if (subDyn.type === DYN_CONTEXT$1) {\n contextDep = true\n } else if (subDyn.type === DYN_STATE$1) {\n thisDep = true\n } else if (subDyn.type === DYN_FUNC$1) {\n thisDep = true\n var subArgs = subDyn.data\n if (subArgs >= 1) {\n contextDep = true\n }\n if (subArgs >= 2) {\n propDep = true\n }\n } else if (subDyn.type === DYN_THUNK) {\n thisDep = thisDep || subDyn.data.thisDep\n contextDep = contextDep || subDyn.data.contextDep\n propDep = propDep || subDyn.data.propDep\n }\n }\n return new Declaration(\n thisDep,\n contextDep,\n propDep,\n append)\n } else {\n return new Declaration(\n type === DYN_STATE$1,\n type === DYN_CONTEXT$1,\n type === DYN_PROP$1,\n append)\n }\n}\n\nvar SCOPE_DECL = new Declaration(false, false, false, function () {})\n\nfunction reglCore (\n gl,\n stringStore,\n extensions,\n limits,\n bufferState,\n elementState,\n textureState,\n framebufferState,\n uniformState,\n attributeState,\n shaderState,\n drawState,\n contextState,\n timer,\n config) {\n var AttributeRecord = attributeState.Record\n\n var blendEquations = {\n 'add': 32774,\n 'subtract': 32778,\n 'reverse subtract': 32779\n }\n if (extensions.ext_blend_minmax) {\n blendEquations.min = GL_MIN_EXT\n blendEquations.max = GL_MAX_EXT\n }\n\n var extInstancing = extensions.angle_instanced_arrays\n var extDrawBuffers = extensions.webgl_draw_buffers\n\n // ===================================================\n // ===================================================\n // WEBGL STATE\n // ===================================================\n // ===================================================\n var currentState = {\n dirty: true,\n profile: config.profile\n }\n var nextState = {}\n var GL_STATE_NAMES = []\n var GL_FLAGS = {}\n var GL_VARIABLES = {}\n\n function propName (name) {\n return name.replace('.', '_')\n }\n\n function stateFlag (sname, cap, init) {\n var name = propName(sname)\n GL_STATE_NAMES.push(sname)\n nextState[name] = currentState[name] = !!init\n GL_FLAGS[name] = cap\n }\n\n function stateVariable (sname, func, init) {\n var name = propName(sname)\n GL_STATE_NAMES.push(sname)\n if (Array.isArray(init)) {\n currentState[name] = init.slice()\n nextState[name] = init.slice()\n } else {\n currentState[name] = nextState[name] = init\n }\n GL_VARIABLES[name] = func\n }\n\n // Dithering\n stateFlag(S_DITHER, GL_DITHER)\n\n // Blending\n stateFlag(S_BLEND_ENABLE, GL_BLEND)\n stateVariable(S_BLEND_COLOR, 'blendColor', [0, 0, 0, 0])\n stateVariable(S_BLEND_EQUATION, 'blendEquationSeparate',\n [GL_FUNC_ADD, GL_FUNC_ADD])\n stateVariable(S_BLEND_FUNC, 'blendFuncSeparate',\n [GL_ONE, GL_ZERO, GL_ONE, GL_ZERO])\n\n // Depth\n stateFlag(S_DEPTH_ENABLE, GL_DEPTH_TEST, true)\n stateVariable(S_DEPTH_FUNC, 'depthFunc', GL_LESS)\n stateVariable(S_DEPTH_RANGE, 'depthRange', [0, 1])\n stateVariable(S_DEPTH_MASK, 'depthMask', true)\n\n // Color mask\n stateVariable(S_COLOR_MASK, S_COLOR_MASK, [true, true, true, true])\n\n // Face culling\n stateFlag(S_CULL_ENABLE, GL_CULL_FACE)\n stateVariable(S_CULL_FACE, 'cullFace', GL_BACK)\n\n // Front face orientation\n stateVariable(S_FRONT_FACE, S_FRONT_FACE, GL_CCW)\n\n // Line width\n stateVariable(S_LINE_WIDTH, S_LINE_WIDTH, 1)\n\n // Polygon offset\n stateFlag(S_POLYGON_OFFSET_ENABLE, GL_POLYGON_OFFSET_FILL)\n stateVariable(S_POLYGON_OFFSET_OFFSET, 'polygonOffset', [0, 0])\n\n // Sample coverage\n stateFlag(S_SAMPLE_ALPHA, GL_SAMPLE_ALPHA_TO_COVERAGE)\n stateFlag(S_SAMPLE_ENABLE, GL_SAMPLE_COVERAGE)\n stateVariable(S_SAMPLE_COVERAGE, 'sampleCoverage', [1, false])\n\n // Stencil\n stateFlag(S_STENCIL_ENABLE, GL_STENCIL_TEST)\n stateVariable(S_STENCIL_MASK, 'stencilMask', -1)\n stateVariable(S_STENCIL_FUNC, 'stencilFunc', [GL_ALWAYS, 0, -1])\n stateVariable(S_STENCIL_OPFRONT, 'stencilOpSeparate',\n [GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP])\n stateVariable(S_STENCIL_OPBACK, 'stencilOpSeparate',\n [GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP])\n\n // Scissor\n stateFlag(S_SCISSOR_ENABLE, GL_SCISSOR_TEST)\n stateVariable(S_SCISSOR_BOX, 'scissor',\n [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight])\n\n // Viewport\n stateVariable(S_VIEWPORT, S_VIEWPORT,\n [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight])\n\n // ===================================================\n // ===================================================\n // ENVIRONMENT\n // ===================================================\n // ===================================================\n var sharedState = {\n gl: gl,\n context: contextState,\n strings: stringStore,\n next: nextState,\n current: currentState,\n draw: drawState,\n elements: elementState,\n buffer: bufferState,\n shader: shaderState,\n attributes: attributeState.state,\n vao: attributeState,\n uniforms: uniformState,\n framebuffer: framebufferState,\n extensions: extensions,\n\n timer: timer,\n isBufferArgs: isBufferArgs\n }\n\n var sharedConstants = {\n primTypes: primTypes,\n compareFuncs: compareFuncs,\n blendFuncs: blendFuncs,\n blendEquations: blendEquations,\n stencilOps: stencilOps,\n glTypes: glTypes,\n orientationType: orientationType\n }\n\n check$1.optional(function () {\n sharedState.isArrayLike = isArrayLike\n })\n\n if (extDrawBuffers) {\n sharedConstants.backBuffer = [GL_BACK]\n sharedConstants.drawBuffer = loop(limits.maxDrawbuffers, function (i) {\n if (i === 0) {\n return [0]\n }\n return loop(i, function (j) {\n return GL_COLOR_ATTACHMENT0$2 + j\n })\n })\n }\n\n var drawCallCounter = 0\n function createREGLEnvironment () {\n var env = createEnvironment()\n var link = env.link\n var global = env.global\n env.id = drawCallCounter++\n\n env.batchId = '0'\n\n // link shared state\n var SHARED = link(sharedState)\n var shared = env.shared = {\n props: 'a0'\n }\n Object.keys(sharedState).forEach(function (prop) {\n shared[prop] = global.def(SHARED, '.', prop)\n })\n\n // Inject runtime assertion stuff for debug builds\n check$1.optional(function () {\n env.CHECK = link(check$1)\n env.commandStr = check$1.guessCommand()\n env.command = link(env.commandStr)\n env.assert = function (block, pred, message) {\n block(\n 'if(!(', pred, '))',\n this.CHECK, '.commandRaise(', link(message), ',', this.command, ');')\n }\n\n sharedConstants.invalidBlendCombinations = invalidBlendCombinations\n })\n\n // Copy GL state variables over\n var nextVars = env.next = {}\n var currentVars = env.current = {}\n Object.keys(GL_VARIABLES).forEach(function (variable) {\n if (Array.isArray(currentState[variable])) {\n nextVars[variable] = global.def(shared.next, '.', variable)\n currentVars[variable] = global.def(shared.current, '.', variable)\n }\n })\n\n // Initialize shared constants\n var constants = env.constants = {}\n Object.keys(sharedConstants).forEach(function (name) {\n constants[name] = global.def(JSON.stringify(sharedConstants[name]))\n })\n\n // Helper function for calling a block\n env.invoke = function (block, x) {\n switch (x.type) {\n case DYN_FUNC$1:\n var argList = [\n 'this',\n shared.context,\n shared.props,\n env.batchId\n ]\n return block.def(\n link(x.data), '.call(',\n argList.slice(0, Math.max(x.data.length + 1, 4)),\n ')')\n case DYN_PROP$1:\n return block.def(shared.props, x.data)\n case DYN_CONTEXT$1:\n return block.def(shared.context, x.data)\n case DYN_STATE$1:\n return block.def('this', x.data)\n case DYN_THUNK:\n x.data.append(env, block)\n return x.data.ref\n case DYN_CONSTANT$1:\n return x.data.toString()\n case DYN_ARRAY$1:\n return x.data.map(function (y) {\n return env.invoke(block, y)\n })\n }\n }\n\n env.attribCache = {}\n\n var scopeAttribs = {}\n env.scopeAttrib = function (name) {\n var id = stringStore.id(name)\n if (id in scopeAttribs) {\n return scopeAttribs[id]\n }\n var binding = attributeState.scope[id]\n if (!binding) {\n binding = attributeState.scope[id] = new AttributeRecord()\n }\n var result = scopeAttribs[id] = link(binding)\n return result\n }\n\n return env\n }\n\n // ===================================================\n // ===================================================\n // PARSING\n // ===================================================\n // ===================================================\n function parseProfile (options) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n var profileEnable\n if (S_PROFILE in staticOptions) {\n var value = !!staticOptions[S_PROFILE]\n profileEnable = createStaticDecl(function (env, scope) {\n return value\n })\n profileEnable.enable = value\n } else if (S_PROFILE in dynamicOptions) {\n var dyn = dynamicOptions[S_PROFILE]\n profileEnable = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n })\n }\n\n return profileEnable\n }\n\n function parseFramebuffer (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n if (S_FRAMEBUFFER in staticOptions) {\n var framebuffer = staticOptions[S_FRAMEBUFFER]\n if (framebuffer) {\n framebuffer = framebufferState.getFramebuffer(framebuffer)\n check$1.command(framebuffer, 'invalid framebuffer object')\n return createStaticDecl(function (env, block) {\n var FRAMEBUFFER = env.link(framebuffer)\n var shared = env.shared\n block.set(\n shared.framebuffer,\n '.next',\n FRAMEBUFFER)\n var CONTEXT = shared.context\n block.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n FRAMEBUFFER + '.width')\n block.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n FRAMEBUFFER + '.height')\n return FRAMEBUFFER\n })\n } else {\n return createStaticDecl(function (env, scope) {\n var shared = env.shared\n scope.set(\n shared.framebuffer,\n '.next',\n 'null')\n var CONTEXT = shared.context\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH)\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT)\n return 'null'\n })\n }\n } else if (S_FRAMEBUFFER in dynamicOptions) {\n var dyn = dynamicOptions[S_FRAMEBUFFER]\n return createDynamicDecl(dyn, function (env, scope) {\n var FRAMEBUFFER_FUNC = env.invoke(scope, dyn)\n var shared = env.shared\n var FRAMEBUFFER_STATE = shared.framebuffer\n var FRAMEBUFFER = scope.def(\n FRAMEBUFFER_STATE, '.getFramebuffer(', FRAMEBUFFER_FUNC, ')')\n\n check$1.optional(function () {\n env.assert(scope,\n '!' + FRAMEBUFFER_FUNC + '||' + FRAMEBUFFER,\n 'invalid framebuffer object')\n })\n\n scope.set(\n FRAMEBUFFER_STATE,\n '.next',\n FRAMEBUFFER)\n var CONTEXT = shared.context\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n FRAMEBUFFER + '?' + FRAMEBUFFER + '.width:' +\n CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH)\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n FRAMEBUFFER +\n '?' + FRAMEBUFFER + '.height:' +\n CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT)\n return FRAMEBUFFER\n })\n } else {\n return null\n }\n }\n\n function parseViewportScissor (options, framebuffer, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n function parseBox (param) {\n if (param in staticOptions) {\n var box = staticOptions[param]\n check$1.commandType(box, 'object', 'invalid ' + param, env.commandStr)\n\n var isStatic = true\n var x = box.x | 0\n var y = box.y | 0\n var w, h\n if ('width' in box) {\n w = box.width | 0\n check$1.command(w >= 0, 'invalid ' + param, env.commandStr)\n } else {\n isStatic = false\n }\n if ('height' in box) {\n h = box.height | 0\n check$1.command(h >= 0, 'invalid ' + param, env.commandStr)\n } else {\n isStatic = false\n }\n\n return new Declaration(\n !isStatic && framebuffer && framebuffer.thisDep,\n !isStatic && framebuffer && framebuffer.contextDep,\n !isStatic && framebuffer && framebuffer.propDep,\n function (env, scope) {\n var CONTEXT = env.shared.context\n var BOX_W = w\n if (!('width' in box)) {\n BOX_W = scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', x)\n }\n var BOX_H = h\n if (!('height' in box)) {\n BOX_H = scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', y)\n }\n return [x, y, BOX_W, BOX_H]\n })\n } else if (param in dynamicOptions) {\n var dynBox = dynamicOptions[param]\n var result = createDynamicDecl(dynBox, function (env, scope) {\n var BOX = env.invoke(scope, dynBox)\n\n check$1.optional(function () {\n env.assert(scope,\n BOX + '&&typeof ' + BOX + '===\"object\"',\n 'invalid ' + param)\n })\n\n var CONTEXT = env.shared.context\n var BOX_X = scope.def(BOX, '.x|0')\n var BOX_Y = scope.def(BOX, '.y|0')\n var BOX_W = scope.def(\n '\"width\" in ', BOX, '?', BOX, '.width|0:',\n '(', CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', BOX_X, ')')\n var BOX_H = scope.def(\n '\"height\" in ', BOX, '?', BOX, '.height|0:',\n '(', CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', BOX_Y, ')')\n\n check$1.optional(function () {\n env.assert(scope,\n BOX_W + '>=0&&' +\n BOX_H + '>=0',\n 'invalid ' + param)\n })\n\n return [BOX_X, BOX_Y, BOX_W, BOX_H]\n })\n if (framebuffer) {\n result.thisDep = result.thisDep || framebuffer.thisDep\n result.contextDep = result.contextDep || framebuffer.contextDep\n result.propDep = result.propDep || framebuffer.propDep\n }\n return result\n } else if (framebuffer) {\n return new Declaration(\n framebuffer.thisDep,\n framebuffer.contextDep,\n framebuffer.propDep,\n function (env, scope) {\n var CONTEXT = env.shared.context\n return [\n 0, 0,\n scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH),\n scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT)]\n })\n } else {\n return null\n }\n }\n\n var viewport = parseBox(S_VIEWPORT)\n\n if (viewport) {\n var prevViewport = viewport\n viewport = new Declaration(\n viewport.thisDep,\n viewport.contextDep,\n viewport.propDep,\n function (env, scope) {\n var VIEWPORT = prevViewport.append(env, scope)\n var CONTEXT = env.shared.context\n scope.set(\n CONTEXT,\n '.' + S_VIEWPORT_WIDTH,\n VIEWPORT[2])\n scope.set(\n CONTEXT,\n '.' + S_VIEWPORT_HEIGHT,\n VIEWPORT[3])\n return VIEWPORT\n })\n }\n\n return {\n viewport: viewport,\n scissor_box: parseBox(S_SCISSOR_BOX)\n }\n }\n\n function parseAttribLocations (options, attributes) {\n var staticOptions = options.static\n var staticProgram =\n typeof staticOptions[S_FRAG] === 'string' &&\n typeof staticOptions[S_VERT] === 'string'\n if (staticProgram) {\n if (Object.keys(attributes.dynamic).length > 0) {\n return null\n }\n var staticAttributes = attributes.static\n var sAttributes = Object.keys(staticAttributes)\n if (sAttributes.length > 0 && typeof staticAttributes[sAttributes[0]] === 'number') {\n var bindings = []\n for (var i = 0; i < sAttributes.length; ++i) {\n check$1(typeof staticAttributes[sAttributes[i]] === 'number', 'must specify all vertex attribute locations when using vaos')\n bindings.push([staticAttributes[sAttributes[i]] | 0, sAttributes[i]])\n }\n return bindings\n }\n }\n return null\n }\n\n function parseProgram (options, env, attribLocations) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n function parseShader (name) {\n if (name in staticOptions) {\n var id = stringStore.id(staticOptions[name])\n check$1.optional(function () {\n shaderState.shader(shaderType[name], id, check$1.guessCommand())\n })\n var result = createStaticDecl(function () {\n return id\n })\n result.id = id\n return result\n } else if (name in dynamicOptions) {\n var dyn = dynamicOptions[name]\n return createDynamicDecl(dyn, function (env, scope) {\n var str = env.invoke(scope, dyn)\n var id = scope.def(env.shared.strings, '.id(', str, ')')\n check$1.optional(function () {\n scope(\n env.shared.shader, '.shader(',\n shaderType[name], ',',\n id, ',',\n env.command, ');')\n })\n return id\n })\n }\n return null\n }\n\n var frag = parseShader(S_FRAG)\n var vert = parseShader(S_VERT)\n\n var program = null\n var progVar\n if (isStatic(frag) && isStatic(vert)) {\n program = shaderState.program(vert.id, frag.id, null, attribLocations)\n progVar = createStaticDecl(function (env, scope) {\n return env.link(program)\n })\n } else {\n progVar = new Declaration(\n (frag && frag.thisDep) || (vert && vert.thisDep),\n (frag && frag.contextDep) || (vert && vert.contextDep),\n (frag && frag.propDep) || (vert && vert.propDep),\n function (env, scope) {\n var SHADER_STATE = env.shared.shader\n var fragId\n if (frag) {\n fragId = frag.append(env, scope)\n } else {\n fragId = scope.def(SHADER_STATE, '.', S_FRAG)\n }\n var vertId\n if (vert) {\n vertId = vert.append(env, scope)\n } else {\n vertId = scope.def(SHADER_STATE, '.', S_VERT)\n }\n var progDef = SHADER_STATE + '.program(' + vertId + ',' + fragId\n check$1.optional(function () {\n progDef += ',' + env.command\n })\n return scope.def(progDef + ')')\n })\n }\n\n return {\n frag: frag,\n vert: vert,\n progVar: progVar,\n program: program\n }\n }\n\n function parseDraw (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n function parseElements () {\n if (S_ELEMENTS in staticOptions) {\n var elements = staticOptions[S_ELEMENTS]\n if (isBufferArgs(elements)) {\n elements = elementState.getElements(elementState.create(elements, true))\n } else if (elements) {\n elements = elementState.getElements(elements)\n check$1.command(elements, 'invalid elements', env.commandStr)\n }\n var result = createStaticDecl(function (env, scope) {\n if (elements) {\n var result = env.link(elements)\n env.ELEMENTS = result\n return result\n }\n env.ELEMENTS = null\n return null\n })\n result.value = elements\n return result\n } else if (S_ELEMENTS in dynamicOptions) {\n var dyn = dynamicOptions[S_ELEMENTS]\n return createDynamicDecl(dyn, function (env, scope) {\n var shared = env.shared\n\n var IS_BUFFER_ARGS = shared.isBufferArgs\n var ELEMENT_STATE = shared.elements\n\n var elementDefn = env.invoke(scope, dyn)\n var elements = scope.def('null')\n var elementStream = scope.def(IS_BUFFER_ARGS, '(', elementDefn, ')')\n\n var ifte = env.cond(elementStream)\n .then(elements, '=', ELEMENT_STATE, '.createStream(', elementDefn, ');')\n .else(elements, '=', ELEMENT_STATE, '.getElements(', elementDefn, ');')\n\n check$1.optional(function () {\n env.assert(ifte.else,\n '!' + elementDefn + '||' + elements,\n 'invalid elements')\n })\n\n scope.entry(ifte)\n scope.exit(\n env.cond(elementStream)\n .then(ELEMENT_STATE, '.destroyStream(', elements, ');'))\n\n env.ELEMENTS = elements\n\n return elements\n })\n }\n\n return null\n }\n\n var elements = parseElements()\n\n function parsePrimitive () {\n if (S_PRIMITIVE in staticOptions) {\n var primitive = staticOptions[S_PRIMITIVE]\n check$1.commandParameter(primitive, primTypes, 'invalid primitve', env.commandStr)\n return createStaticDecl(function (env, scope) {\n return primTypes[primitive]\n })\n } else if (S_PRIMITIVE in dynamicOptions) {\n var dynPrimitive = dynamicOptions[S_PRIMITIVE]\n return createDynamicDecl(dynPrimitive, function (env, scope) {\n var PRIM_TYPES = env.constants.primTypes\n var prim = env.invoke(scope, dynPrimitive)\n check$1.optional(function () {\n env.assert(scope,\n prim + ' in ' + PRIM_TYPES,\n 'invalid primitive, must be one of ' + Object.keys(primTypes))\n })\n return scope.def(PRIM_TYPES, '[', prim, ']')\n })\n } else if (elements) {\n if (isStatic(elements)) {\n if (elements.value) {\n return createStaticDecl(function (env, scope) {\n return scope.def(env.ELEMENTS, '.primType')\n })\n } else {\n return createStaticDecl(function () {\n return GL_TRIANGLES$1\n })\n }\n } else {\n return new Declaration(\n elements.thisDep,\n elements.contextDep,\n elements.propDep,\n function (env, scope) {\n var elements = env.ELEMENTS\n return scope.def(elements, '?', elements, '.primType:', GL_TRIANGLES$1)\n })\n }\n }\n return null\n }\n\n function parseParam (param, isOffset) {\n if (param in staticOptions) {\n var value = staticOptions[param] | 0\n check$1.command(!isOffset || value >= 0, 'invalid ' + param, env.commandStr)\n return createStaticDecl(function (env, scope) {\n if (isOffset) {\n env.OFFSET = value\n }\n return value\n })\n } else if (param in dynamicOptions) {\n var dynValue = dynamicOptions[param]\n return createDynamicDecl(dynValue, function (env, scope) {\n var result = env.invoke(scope, dynValue)\n if (isOffset) {\n env.OFFSET = result\n check$1.optional(function () {\n env.assert(scope,\n result + '>=0',\n 'invalid ' + param)\n })\n }\n return result\n })\n } else if (isOffset && elements) {\n return createStaticDecl(function (env, scope) {\n env.OFFSET = '0'\n return 0\n })\n }\n return null\n }\n\n var OFFSET = parseParam(S_OFFSET, true)\n\n function parseVertCount () {\n if (S_COUNT in staticOptions) {\n var count = staticOptions[S_COUNT] | 0\n check$1.command(\n typeof count === 'number' && count >= 0, 'invalid vertex count', env.commandStr)\n return createStaticDecl(function () {\n return count\n })\n } else if (S_COUNT in dynamicOptions) {\n var dynCount = dynamicOptions[S_COUNT]\n return createDynamicDecl(dynCount, function (env, scope) {\n var result = env.invoke(scope, dynCount)\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + result + '===\"number\"&&' +\n result + '>=0&&' +\n result + '===(' + result + '|0)',\n 'invalid vertex count')\n })\n return result\n })\n } else if (elements) {\n if (isStatic(elements)) {\n if (elements) {\n if (OFFSET) {\n return new Declaration(\n OFFSET.thisDep,\n OFFSET.contextDep,\n OFFSET.propDep,\n function (env, scope) {\n var result = scope.def(\n env.ELEMENTS, '.vertCount-', env.OFFSET)\n\n check$1.optional(function () {\n env.assert(scope,\n result + '>=0',\n 'invalid vertex offset/element buffer too small')\n })\n\n return result\n })\n } else {\n return createStaticDecl(function (env, scope) {\n return scope.def(env.ELEMENTS, '.vertCount')\n })\n }\n } else {\n var result = createStaticDecl(function () {\n return -1\n })\n check$1.optional(function () {\n result.MISSING = true\n })\n return result\n }\n } else {\n var variable = new Declaration(\n elements.thisDep || OFFSET.thisDep,\n elements.contextDep || OFFSET.contextDep,\n elements.propDep || OFFSET.propDep,\n function (env, scope) {\n var elements = env.ELEMENTS\n if (env.OFFSET) {\n return scope.def(elements, '?', elements, '.vertCount-',\n env.OFFSET, ':-1')\n }\n return scope.def(elements, '?', elements, '.vertCount:-1')\n })\n check$1.optional(function () {\n variable.DYNAMIC = true\n })\n return variable\n }\n }\n return null\n }\n\n return {\n elements: elements,\n primitive: parsePrimitive(),\n count: parseVertCount(),\n instances: parseParam(S_INSTANCES, false),\n offset: OFFSET\n }\n }\n\n function parseGLState (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n var STATE = {}\n\n GL_STATE_NAMES.forEach(function (prop) {\n var param = propName(prop)\n\n function parseParam (parseStatic, parseDynamic) {\n if (prop in staticOptions) {\n var value = parseStatic(staticOptions[prop])\n STATE[param] = createStaticDecl(function () {\n return value\n })\n } else if (prop in dynamicOptions) {\n var dyn = dynamicOptions[prop]\n STATE[param] = createDynamicDecl(dyn, function (env, scope) {\n return parseDynamic(env, scope, env.invoke(scope, dyn))\n })\n }\n }\n\n switch (prop) {\n case S_CULL_ENABLE:\n case S_BLEND_ENABLE:\n case S_DITHER:\n case S_STENCIL_ENABLE:\n case S_DEPTH_ENABLE:\n case S_SCISSOR_ENABLE:\n case S_POLYGON_OFFSET_ENABLE:\n case S_SAMPLE_ALPHA:\n case S_SAMPLE_ENABLE:\n case S_DEPTH_MASK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'boolean', prop, env.commandStr)\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"boolean\"',\n 'invalid flag ' + prop, env.commandStr)\n })\n return value\n })\n\n case S_DEPTH_FUNC:\n return parseParam(\n function (value) {\n check$1.commandParameter(value, compareFuncs, 'invalid ' + prop, env.commandStr)\n return compareFuncs[value]\n },\n function (env, scope, value) {\n var COMPARE_FUNCS = env.constants.compareFuncs\n check$1.optional(function () {\n env.assert(scope,\n value + ' in ' + COMPARE_FUNCS,\n 'invalid ' + prop + ', must be one of ' + Object.keys(compareFuncs))\n })\n return scope.def(COMPARE_FUNCS, '[', value, ']')\n })\n\n case S_DEPTH_RANGE:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) &&\n value.length === 2 &&\n typeof value[0] === 'number' &&\n typeof value[1] === 'number' &&\n value[0] <= value[1],\n 'depth range is 2d array',\n env.commandStr)\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===2&&' +\n 'typeof ' + value + '[0]===\"number\"&&' +\n 'typeof ' + value + '[1]===\"number\"&&' +\n value + '[0]<=' + value + '[1]',\n 'depth range must be a 2d array')\n })\n\n var Z_NEAR = scope.def('+', value, '[0]')\n var Z_FAR = scope.def('+', value, '[1]')\n return [Z_NEAR, Z_FAR]\n })\n\n case S_BLEND_FUNC:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', 'blend.func', env.commandStr)\n var srcRGB = ('srcRGB' in value ? value.srcRGB : value.src)\n var srcAlpha = ('srcAlpha' in value ? value.srcAlpha : value.src)\n var dstRGB = ('dstRGB' in value ? value.dstRGB : value.dst)\n var dstAlpha = ('dstAlpha' in value ? value.dstAlpha : value.dst)\n check$1.commandParameter(srcRGB, blendFuncs, param + '.srcRGB', env.commandStr)\n check$1.commandParameter(srcAlpha, blendFuncs, param + '.srcAlpha', env.commandStr)\n check$1.commandParameter(dstRGB, blendFuncs, param + '.dstRGB', env.commandStr)\n check$1.commandParameter(dstAlpha, blendFuncs, param + '.dstAlpha', env.commandStr)\n\n check$1.command(\n (invalidBlendCombinations.indexOf(srcRGB + ', ' + dstRGB) === -1),\n 'unallowed blending combination (srcRGB, dstRGB) = (' + srcRGB + ', ' + dstRGB + ')', env.commandStr)\n\n return [\n blendFuncs[srcRGB],\n blendFuncs[dstRGB],\n blendFuncs[srcAlpha],\n blendFuncs[dstAlpha]\n ]\n },\n function (env, scope, value) {\n var BLEND_FUNCS = env.constants.blendFuncs\n\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid blend func, must be an object')\n })\n\n function read (prefix, suffix) {\n var func = scope.def(\n '\"', prefix, suffix, '\" in ', value,\n '?', value, '.', prefix, suffix,\n ':', value, '.', prefix)\n\n check$1.optional(function () {\n env.assert(scope,\n func + ' in ' + BLEND_FUNCS,\n 'invalid ' + prop + '.' + prefix + suffix + ', must be one of ' + Object.keys(blendFuncs))\n })\n\n return func\n }\n\n var srcRGB = read('src', 'RGB')\n var dstRGB = read('dst', 'RGB')\n\n check$1.optional(function () {\n var INVALID_BLEND_COMBINATIONS = env.constants.invalidBlendCombinations\n\n env.assert(scope,\n INVALID_BLEND_COMBINATIONS +\n '.indexOf(' + srcRGB + '+\", \"+' + dstRGB + ') === -1 ',\n 'unallowed blending combination for (srcRGB, dstRGB)'\n )\n })\n\n var SRC_RGB = scope.def(BLEND_FUNCS, '[', srcRGB, ']')\n var SRC_ALPHA = scope.def(BLEND_FUNCS, '[', read('src', 'Alpha'), ']')\n var DST_RGB = scope.def(BLEND_FUNCS, '[', dstRGB, ']')\n var DST_ALPHA = scope.def(BLEND_FUNCS, '[', read('dst', 'Alpha'), ']')\n\n return [SRC_RGB, DST_RGB, SRC_ALPHA, DST_ALPHA]\n })\n\n case S_BLEND_EQUATION:\n return parseParam(\n function (value) {\n if (typeof value === 'string') {\n check$1.commandParameter(value, blendEquations, 'invalid ' + prop, env.commandStr)\n return [\n blendEquations[value],\n blendEquations[value]\n ]\n } else if (typeof value === 'object') {\n check$1.commandParameter(\n value.rgb, blendEquations, prop + '.rgb', env.commandStr)\n check$1.commandParameter(\n value.alpha, blendEquations, prop + '.alpha', env.commandStr)\n return [\n blendEquations[value.rgb],\n blendEquations[value.alpha]\n ]\n } else {\n check$1.commandRaise('invalid blend.equation', env.commandStr)\n }\n },\n function (env, scope, value) {\n var BLEND_EQUATIONS = env.constants.blendEquations\n\n var RGB = scope.def()\n var ALPHA = scope.def()\n\n var ifte = env.cond('typeof ', value, '===\"string\"')\n\n check$1.optional(function () {\n function checkProp (block, name, value) {\n env.assert(block,\n value + ' in ' + BLEND_EQUATIONS,\n 'invalid ' + name + ', must be one of ' + Object.keys(blendEquations))\n }\n checkProp(ifte.then, prop, value)\n\n env.assert(ifte.else,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop)\n checkProp(ifte.else, prop + '.rgb', value + '.rgb')\n checkProp(ifte.else, prop + '.alpha', value + '.alpha')\n })\n\n ifte.then(\n RGB, '=', ALPHA, '=', BLEND_EQUATIONS, '[', value, '];')\n ifte.else(\n RGB, '=', BLEND_EQUATIONS, '[', value, '.rgb];',\n ALPHA, '=', BLEND_EQUATIONS, '[', value, '.alpha];')\n\n scope(ifte)\n\n return [RGB, ALPHA]\n })\n\n case S_BLEND_COLOR:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) &&\n value.length === 4,\n 'blend.color must be a 4d array', env.commandStr)\n return loop(4, function (i) {\n return +value[i]\n })\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===4',\n 'blend.color must be a 4d array')\n })\n return loop(4, function (i) {\n return scope.def('+', value, '[', i, ']')\n })\n })\n\n case S_STENCIL_MASK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'number', param, env.commandStr)\n return value | 0\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"number\"',\n 'invalid stencil.mask')\n })\n return scope.def(value, '|0')\n })\n\n case S_STENCIL_FUNC:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr)\n var cmp = value.cmp || 'keep'\n var ref = value.ref || 0\n var mask = 'mask' in value ? value.mask : -1\n check$1.commandParameter(cmp, compareFuncs, prop + '.cmp', env.commandStr)\n check$1.commandType(ref, 'number', prop + '.ref', env.commandStr)\n check$1.commandType(mask, 'number', prop + '.mask', env.commandStr)\n return [\n compareFuncs[cmp],\n ref,\n mask\n ]\n },\n function (env, scope, value) {\n var COMPARE_FUNCS = env.constants.compareFuncs\n check$1.optional(function () {\n function assert () {\n env.assert(scope,\n Array.prototype.join.call(arguments, ''),\n 'invalid stencil.func')\n }\n assert(value + '&&typeof ', value, '===\"object\"')\n assert('!(\"cmp\" in ', value, ')||(',\n value, '.cmp in ', COMPARE_FUNCS, ')')\n })\n var cmp = scope.def(\n '\"cmp\" in ', value,\n '?', COMPARE_FUNCS, '[', value, '.cmp]',\n ':', GL_KEEP)\n var ref = scope.def(value, '.ref|0')\n var mask = scope.def(\n '\"mask\" in ', value,\n '?', value, '.mask|0:-1')\n return [cmp, ref, mask]\n })\n\n case S_STENCIL_OPFRONT:\n case S_STENCIL_OPBACK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr)\n var fail = value.fail || 'keep'\n var zfail = value.zfail || 'keep'\n var zpass = value.zpass || 'keep'\n check$1.commandParameter(fail, stencilOps, prop + '.fail', env.commandStr)\n check$1.commandParameter(zfail, stencilOps, prop + '.zfail', env.commandStr)\n check$1.commandParameter(zpass, stencilOps, prop + '.zpass', env.commandStr)\n return [\n prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT,\n stencilOps[fail],\n stencilOps[zfail],\n stencilOps[zpass]\n ]\n },\n function (env, scope, value) {\n var STENCIL_OPS = env.constants.stencilOps\n\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop)\n })\n\n function read (name) {\n check$1.optional(function () {\n env.assert(scope,\n '!(\"' + name + '\" in ' + value + ')||' +\n '(' + value + '.' + name + ' in ' + STENCIL_OPS + ')',\n 'invalid ' + prop + '.' + name + ', must be one of ' + Object.keys(stencilOps))\n })\n\n return scope.def(\n '\"', name, '\" in ', value,\n '?', STENCIL_OPS, '[', value, '.', name, ']:',\n GL_KEEP)\n }\n\n return [\n prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT,\n read('fail'),\n read('zfail'),\n read('zpass')\n ]\n })\n\n case S_POLYGON_OFFSET_OFFSET:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr)\n var factor = value.factor | 0\n var units = value.units | 0\n check$1.commandType(factor, 'number', param + '.factor', env.commandStr)\n check$1.commandType(units, 'number', param + '.units', env.commandStr)\n return [factor, units]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop)\n })\n\n var FACTOR = scope.def(value, '.factor|0')\n var UNITS = scope.def(value, '.units|0')\n\n return [FACTOR, UNITS]\n })\n\n case S_CULL_FACE:\n return parseParam(\n function (value) {\n var face = 0\n if (value === 'front') {\n face = GL_FRONT\n } else if (value === 'back') {\n face = GL_BACK\n }\n check$1.command(!!face, param, env.commandStr)\n return face\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '===\"front\"||' +\n value + '===\"back\"',\n 'invalid cull.face')\n })\n return scope.def(value, '===\"front\"?', GL_FRONT, ':', GL_BACK)\n })\n\n case S_LINE_WIDTH:\n return parseParam(\n function (value) {\n check$1.command(\n typeof value === 'number' &&\n value >= limits.lineWidthDims[0] &&\n value <= limits.lineWidthDims[1],\n 'invalid line width, must be a positive number between ' +\n limits.lineWidthDims[0] + ' and ' + limits.lineWidthDims[1], env.commandStr)\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"number\"&&' +\n value + '>=' + limits.lineWidthDims[0] + '&&' +\n value + '<=' + limits.lineWidthDims[1],\n 'invalid line width')\n })\n\n return value\n })\n\n case S_FRONT_FACE:\n return parseParam(\n function (value) {\n check$1.commandParameter(value, orientationType, param, env.commandStr)\n return orientationType[value]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '===\"cw\"||' +\n value + '===\"ccw\"',\n 'invalid frontFace, must be one of cw,ccw')\n })\n return scope.def(value + '===\"cw\"?' + GL_CW + ':' + GL_CCW)\n })\n\n case S_COLOR_MASK:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'color.mask must be length 4 array', env.commandStr)\n return value.map(function (v) { return !!v })\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===4',\n 'invalid color.mask')\n })\n return loop(4, function (i) {\n return '!!' + value + '[' + i + ']'\n })\n })\n\n case S_SAMPLE_COVERAGE:\n return parseParam(\n function (value) {\n check$1.command(typeof value === 'object' && value, param, env.commandStr)\n var sampleValue = 'value' in value ? value.value : 1\n var sampleInvert = !!value.invert\n check$1.command(\n typeof sampleValue === 'number' &&\n sampleValue >= 0 && sampleValue <= 1,\n 'sample.coverage.value must be a number between 0 and 1', env.commandStr)\n return [sampleValue, sampleInvert]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid sample.coverage')\n })\n var VALUE = scope.def(\n '\"value\" in ', value, '?+', value, '.value:1')\n var INVERT = scope.def('!!', value, '.invert')\n return [VALUE, INVERT]\n })\n }\n })\n\n return STATE\n }\n\n function parseUniforms (uniforms, env) {\n var staticUniforms = uniforms.static\n var dynamicUniforms = uniforms.dynamic\n\n var UNIFORMS = {}\n\n Object.keys(staticUniforms).forEach(function (name) {\n var value = staticUniforms[name]\n var result\n if (typeof value === 'number' ||\n typeof value === 'boolean') {\n result = createStaticDecl(function () {\n return value\n })\n } else if (typeof value === 'function') {\n var reglType = value._reglType\n if (reglType === 'texture2d' ||\n reglType === 'textureCube') {\n result = createStaticDecl(function (env) {\n return env.link(value)\n })\n } else if (reglType === 'framebuffer' ||\n reglType === 'framebufferCube') {\n check$1.command(value.color.length > 0,\n 'missing color attachment for framebuffer sent to uniform \"' + name + '\"', env.commandStr)\n result = createStaticDecl(function (env) {\n return env.link(value.color[0])\n })\n } else {\n check$1.commandRaise('invalid data for uniform \"' + name + '\"', env.commandStr)\n }\n } else if (isArrayLike(value)) {\n result = createStaticDecl(function (env) {\n var ITEM = env.global.def('[',\n loop(value.length, function (i) {\n check$1.command(\n typeof value[i] === 'number' ||\n typeof value[i] === 'boolean',\n 'invalid uniform ' + name, env.commandStr)\n return value[i]\n }), ']')\n return ITEM\n })\n } else {\n check$1.commandRaise('invalid or missing data for uniform \"' + name + '\"', env.commandStr)\n }\n result.value = value\n UNIFORMS[name] = result\n })\n\n Object.keys(dynamicUniforms).forEach(function (key) {\n var dyn = dynamicUniforms[key]\n UNIFORMS[key] = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n })\n })\n\n return UNIFORMS\n }\n\n function parseAttributes (attributes, env) {\n var staticAttributes = attributes.static\n var dynamicAttributes = attributes.dynamic\n\n var attributeDefs = {}\n\n Object.keys(staticAttributes).forEach(function (attribute) {\n var value = staticAttributes[attribute]\n var id = stringStore.id(attribute)\n\n var record = new AttributeRecord()\n if (isBufferArgs(value)) {\n record.state = ATTRIB_STATE_POINTER\n record.buffer = bufferState.getBuffer(\n bufferState.create(value, GL_ARRAY_BUFFER$2, false, true))\n record.type = 0\n } else {\n var buffer = bufferState.getBuffer(value)\n if (buffer) {\n record.state = ATTRIB_STATE_POINTER\n record.buffer = buffer\n record.type = 0\n } else {\n check$1.command(typeof value === 'object' && value,\n 'invalid data for attribute ' + attribute, env.commandStr)\n if ('constant' in value) {\n var constant = value.constant\n record.buffer = 'null'\n record.state = ATTRIB_STATE_CONSTANT\n if (typeof constant === 'number') {\n record.x = constant\n } else {\n check$1.command(\n isArrayLike(constant) &&\n constant.length > 0 &&\n constant.length <= 4,\n 'invalid constant for attribute ' + attribute, env.commandStr)\n CUTE_COMPONENTS.forEach(function (c, i) {\n if (i < constant.length) {\n record[c] = constant[i]\n }\n })\n }\n } else {\n if (isBufferArgs(value.buffer)) {\n buffer = bufferState.getBuffer(\n bufferState.create(value.buffer, GL_ARRAY_BUFFER$2, false, true))\n } else {\n buffer = bufferState.getBuffer(value.buffer)\n }\n check$1.command(!!buffer, 'missing buffer for attribute \"' + attribute + '\"', env.commandStr)\n\n var offset = value.offset | 0\n check$1.command(offset >= 0,\n 'invalid offset for attribute \"' + attribute + '\"', env.commandStr)\n\n var stride = value.stride | 0\n check$1.command(stride >= 0 && stride < 256,\n 'invalid stride for attribute \"' + attribute + '\", must be integer betweeen [0, 255]', env.commandStr)\n\n var size = value.size | 0\n check$1.command(!('size' in value) || (size > 0 && size <= 4),\n 'invalid size for attribute \"' + attribute + '\", must be 1,2,3,4', env.commandStr)\n\n var normalized = !!value.normalized\n\n var type = 0\n if ('type' in value) {\n check$1.commandParameter(\n value.type, glTypes,\n 'invalid type for attribute ' + attribute, env.commandStr)\n type = glTypes[value.type]\n }\n\n var divisor = value.divisor | 0\n if ('divisor' in value) {\n check$1.command(divisor === 0 || extInstancing,\n 'cannot specify divisor for attribute \"' + attribute + '\", instancing not supported', env.commandStr)\n check$1.command(divisor >= 0,\n 'invalid divisor for attribute \"' + attribute + '\"', env.commandStr)\n }\n\n check$1.optional(function () {\n var command = env.commandStr\n\n var VALID_KEYS = [\n 'buffer',\n 'offset',\n 'divisor',\n 'normalized',\n 'type',\n 'size',\n 'stride'\n ]\n\n Object.keys(value).forEach(function (prop) {\n check$1.command(\n VALID_KEYS.indexOf(prop) >= 0,\n 'unknown parameter \"' + prop + '\" for attribute pointer \"' + attribute + '\" (valid parameters are ' + VALID_KEYS + ')',\n command)\n })\n })\n\n record.buffer = buffer\n record.state = ATTRIB_STATE_POINTER\n record.size = size\n record.normalized = normalized\n record.type = type || buffer.dtype\n record.offset = offset\n record.stride = stride\n record.divisor = divisor\n }\n }\n }\n\n attributeDefs[attribute] = createStaticDecl(function (env, scope) {\n var cache = env.attribCache\n if (id in cache) {\n return cache[id]\n }\n var result = {\n isStream: false\n }\n Object.keys(record).forEach(function (key) {\n result[key] = record[key]\n })\n if (record.buffer) {\n result.buffer = env.link(record.buffer)\n result.type = result.type || (result.buffer + '.dtype')\n }\n cache[id] = result\n return result\n })\n })\n\n Object.keys(dynamicAttributes).forEach(function (attribute) {\n var dyn = dynamicAttributes[attribute]\n\n function appendAttributeCode (env, block) {\n var VALUE = env.invoke(block, dyn)\n\n var shared = env.shared\n var constants = env.constants\n\n var IS_BUFFER_ARGS = shared.isBufferArgs\n var BUFFER_STATE = shared.buffer\n\n // Perform validation on attribute\n check$1.optional(function () {\n env.assert(block,\n VALUE + '&&(typeof ' + VALUE + '===\"object\"||typeof ' +\n VALUE + '===\"function\")&&(' +\n IS_BUFFER_ARGS + '(' + VALUE + ')||' +\n BUFFER_STATE + '.getBuffer(' + VALUE + ')||' +\n BUFFER_STATE + '.getBuffer(' + VALUE + '.buffer)||' +\n IS_BUFFER_ARGS + '(' + VALUE + '.buffer)||' +\n '(\"constant\" in ' + VALUE +\n '&&(typeof ' + VALUE + '.constant===\"number\"||' +\n shared.isArrayLike + '(' + VALUE + '.constant))))',\n 'invalid dynamic attribute \"' + attribute + '\"')\n })\n\n // allocate names for result\n var result = {\n isStream: block.def(false)\n }\n var defaultRecord = new AttributeRecord()\n defaultRecord.state = ATTRIB_STATE_POINTER\n Object.keys(defaultRecord).forEach(function (key) {\n result[key] = block.def('' + defaultRecord[key])\n })\n\n var BUFFER = result.buffer\n var TYPE = result.type\n block(\n 'if(', IS_BUFFER_ARGS, '(', VALUE, ')){',\n result.isStream, '=true;',\n BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$2, ',', VALUE, ');',\n TYPE, '=', BUFFER, '.dtype;',\n '}else{',\n BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, ');',\n 'if(', BUFFER, '){',\n TYPE, '=', BUFFER, '.dtype;',\n '}else if(\"constant\" in ', VALUE, '){',\n result.state, '=', ATTRIB_STATE_CONSTANT, ';',\n 'if(typeof ' + VALUE + '.constant === \"number\"){',\n result[CUTE_COMPONENTS[0]], '=', VALUE, '.constant;',\n CUTE_COMPONENTS.slice(1).map(function (n) {\n return result[n]\n }).join('='), '=0;',\n '}else{',\n CUTE_COMPONENTS.map(function (name, i) {\n return (\n result[name] + '=' + VALUE + '.constant.length>' + i +\n '?' + VALUE + '.constant[' + i + ']:0;'\n )\n }).join(''),\n '}}else{',\n 'if(', IS_BUFFER_ARGS, '(', VALUE, '.buffer)){',\n BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$2, ',', VALUE, '.buffer);',\n '}else{',\n BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, '.buffer);',\n '}',\n TYPE, '=\"type\" in ', VALUE, '?',\n constants.glTypes, '[', VALUE, '.type]:', BUFFER, '.dtype;',\n result.normalized, '=!!', VALUE, '.normalized;')\n function emitReadRecord (name) {\n block(result[name], '=', VALUE, '.', name, '|0;')\n }\n emitReadRecord('size')\n emitReadRecord('offset')\n emitReadRecord('stride')\n emitReadRecord('divisor')\n\n block('}}')\n\n block.exit(\n 'if(', result.isStream, '){',\n BUFFER_STATE, '.destroyStream(', BUFFER, ');',\n '}')\n\n return result\n }\n\n attributeDefs[attribute] = createDynamicDecl(dyn, appendAttributeCode)\n })\n\n return attributeDefs\n }\n\n function parseVAO (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n if (S_VAO in staticOptions) {\n var vao = staticOptions[S_VAO]\n if (vao !== null && attributeState.getVAO(vao) === null) {\n vao = attributeState.createVAO(vao)\n }\n return createStaticDecl(function (env) {\n return env.link(attributeState.getVAO(vao))\n })\n } else if (S_VAO in dynamicOptions) {\n var dyn = dynamicOptions[S_VAO]\n return createDynamicDecl(dyn, function (env, scope) {\n var vaoRef = env.invoke(scope, dyn)\n return scope.def(env.shared.vao + '.getVAO(' + vaoRef + ')')\n })\n }\n return null\n }\n\n function parseContext (context) {\n var staticContext = context.static\n var dynamicContext = context.dynamic\n var result = {}\n\n Object.keys(staticContext).forEach(function (name) {\n var value = staticContext[name]\n result[name] = createStaticDecl(function (env, scope) {\n if (typeof value === 'number' || typeof value === 'boolean') {\n return '' + value\n } else {\n return env.link(value)\n }\n })\n })\n\n Object.keys(dynamicContext).forEach(function (name) {\n var dyn = dynamicContext[name]\n result[name] = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n })\n })\n\n return result\n }\n\n function parseArguments (options, attributes, uniforms, context, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n check$1.optional(function () {\n var KEY_NAMES = [\n S_FRAMEBUFFER,\n S_VERT,\n S_FRAG,\n S_ELEMENTS,\n S_PRIMITIVE,\n S_OFFSET,\n S_COUNT,\n S_INSTANCES,\n S_PROFILE,\n S_VAO\n ].concat(GL_STATE_NAMES)\n\n function checkKeys (dict) {\n Object.keys(dict).forEach(function (key) {\n check$1.command(\n KEY_NAMES.indexOf(key) >= 0,\n 'unknown parameter \"' + key + '\"',\n env.commandStr)\n })\n }\n\n checkKeys(staticOptions)\n checkKeys(dynamicOptions)\n })\n\n var attribLocations = parseAttribLocations(options, attributes)\n\n var framebuffer = parseFramebuffer(options, env)\n var viewportAndScissor = parseViewportScissor(options, framebuffer, env)\n var draw = parseDraw(options, env)\n var state = parseGLState(options, env)\n var shader = parseProgram(options, env, attribLocations)\n\n function copyBox (name) {\n var defn = viewportAndScissor[name]\n if (defn) {\n state[name] = defn\n }\n }\n copyBox(S_VIEWPORT)\n copyBox(propName(S_SCISSOR_BOX))\n\n var dirty = Object.keys(state).length > 0\n\n var result = {\n framebuffer: framebuffer,\n draw: draw,\n shader: shader,\n state: state,\n dirty: dirty,\n scopeVAO: null,\n drawVAO: null,\n useVAO: false,\n attributes: {}\n }\n\n result.profile = parseProfile(options, env)\n result.uniforms = parseUniforms(uniforms, env)\n result.drawVAO = result.scopeVAO = parseVAO(options, env)\n // special case: check if we can statically allocate a vertex array object for this program\n if (!result.drawVAO && shader.program && !attribLocations && extensions.angle_instanced_arrays) {\n var useVAO = true\n var staticBindings = shader.program.attributes.map(function (attr) {\n var binding = attributes.static[attr]\n useVAO = useVAO && !!binding\n return binding\n })\n if (useVAO && staticBindings.length > 0) {\n var vao = attributeState.getVAO(attributeState.createVAO(staticBindings))\n result.drawVAO = new Declaration(null, null, null, function (env, scope) {\n return env.link(vao)\n })\n result.useVAO = true\n }\n }\n if (attribLocations) {\n result.useVAO = true\n } else {\n result.attributes = parseAttributes(attributes, env)\n }\n result.context = parseContext(context, env)\n return result\n }\n\n // ===================================================\n // ===================================================\n // COMMON UPDATE FUNCTIONS\n // ===================================================\n // ===================================================\n function emitContext (env, scope, context) {\n var shared = env.shared\n var CONTEXT = shared.context\n\n var contextEnter = env.scope()\n\n Object.keys(context).forEach(function (name) {\n scope.save(CONTEXT, '.' + name)\n var defn = context[name]\n var value = defn.append(env, scope)\n if (Array.isArray(value)) {\n contextEnter(CONTEXT, '.', name, '=[', value.join(), '];')\n } else {\n contextEnter(CONTEXT, '.', name, '=', value, ';')\n }\n })\n\n scope(contextEnter)\n }\n\n // ===================================================\n // ===================================================\n // COMMON DRAWING FUNCTIONS\n // ===================================================\n // ===================================================\n function emitPollFramebuffer (env, scope, framebuffer, skipCheck) {\n var shared = env.shared\n\n var GL = shared.gl\n var FRAMEBUFFER_STATE = shared.framebuffer\n var EXT_DRAW_BUFFERS\n if (extDrawBuffers) {\n EXT_DRAW_BUFFERS = scope.def(shared.extensions, '.webgl_draw_buffers')\n }\n\n var constants = env.constants\n\n var DRAW_BUFFERS = constants.drawBuffer\n var BACK_BUFFER = constants.backBuffer\n\n var NEXT\n if (framebuffer) {\n NEXT = framebuffer.append(env, scope)\n } else {\n NEXT = scope.def(FRAMEBUFFER_STATE, '.next')\n }\n\n if (!skipCheck) {\n scope('if(', NEXT, '!==', FRAMEBUFFER_STATE, '.cur){')\n }\n scope(\n 'if(', NEXT, '){',\n GL, '.bindFramebuffer(', GL_FRAMEBUFFER$2, ',', NEXT, '.framebuffer);')\n if (extDrawBuffers) {\n scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(',\n DRAW_BUFFERS, '[', NEXT, '.colorAttachments.length]);')\n }\n scope('}else{',\n GL, '.bindFramebuffer(', GL_FRAMEBUFFER$2, ',null);')\n if (extDrawBuffers) {\n scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', BACK_BUFFER, ');')\n }\n scope(\n '}',\n FRAMEBUFFER_STATE, '.cur=', NEXT, ';')\n if (!skipCheck) {\n scope('}')\n }\n }\n\n function emitPollState (env, scope, args) {\n var shared = env.shared\n\n var GL = shared.gl\n\n var CURRENT_VARS = env.current\n var NEXT_VARS = env.next\n var CURRENT_STATE = shared.current\n var NEXT_STATE = shared.next\n\n var block = env.cond(CURRENT_STATE, '.dirty')\n\n GL_STATE_NAMES.forEach(function (prop) {\n var param = propName(prop)\n if (param in args.state) {\n return\n }\n\n var NEXT, CURRENT\n if (param in NEXT_VARS) {\n NEXT = NEXT_VARS[param]\n CURRENT = CURRENT_VARS[param]\n var parts = loop(currentState[param].length, function (i) {\n return block.def(NEXT, '[', i, ']')\n })\n block(env.cond(parts.map(function (p, i) {\n return p + '!==' + CURRENT + '[' + i + ']'\n }).join('||'))\n .then(\n GL, '.', GL_VARIABLES[param], '(', parts, ');',\n parts.map(function (p, i) {\n return CURRENT + '[' + i + ']=' + p\n }).join(';'), ';'))\n } else {\n NEXT = block.def(NEXT_STATE, '.', param)\n var ifte = env.cond(NEXT, '!==', CURRENT_STATE, '.', param)\n block(ifte)\n if (param in GL_FLAGS) {\n ifte(\n env.cond(NEXT)\n .then(GL, '.enable(', GL_FLAGS[param], ');')\n .else(GL, '.disable(', GL_FLAGS[param], ');'),\n CURRENT_STATE, '.', param, '=', NEXT, ';')\n } else {\n ifte(\n GL, '.', GL_VARIABLES[param], '(', NEXT, ');',\n CURRENT_STATE, '.', param, '=', NEXT, ';')\n }\n }\n })\n if (Object.keys(args.state).length === 0) {\n block(CURRENT_STATE, '.dirty=false;')\n }\n scope(block)\n }\n\n function emitSetOptions (env, scope, options, filter) {\n var shared = env.shared\n var CURRENT_VARS = env.current\n var CURRENT_STATE = shared.current\n var GL = shared.gl\n sortState(Object.keys(options)).forEach(function (param) {\n var defn = options[param]\n if (filter && !filter(defn)) {\n return\n }\n var variable = defn.append(env, scope)\n if (GL_FLAGS[param]) {\n var flag = GL_FLAGS[param]\n if (isStatic(defn)) {\n if (variable) {\n scope(GL, '.enable(', flag, ');')\n } else {\n scope(GL, '.disable(', flag, ');')\n }\n } else {\n scope(env.cond(variable)\n .then(GL, '.enable(', flag, ');')\n .else(GL, '.disable(', flag, ');'))\n }\n scope(CURRENT_STATE, '.', param, '=', variable, ';')\n } else if (isArrayLike(variable)) {\n var CURRENT = CURRENT_VARS[param]\n scope(\n GL, '.', GL_VARIABLES[param], '(', variable, ');',\n variable.map(function (v, i) {\n return CURRENT + '[' + i + ']=' + v\n }).join(';'), ';')\n } else {\n scope(\n GL, '.', GL_VARIABLES[param], '(', variable, ');',\n CURRENT_STATE, '.', param, '=', variable, ';')\n }\n })\n }\n\n function injectExtensions (env, scope) {\n if (extInstancing) {\n env.instancing = scope.def(\n env.shared.extensions, '.angle_instanced_arrays')\n }\n }\n\n function emitProfile (env, scope, args, useScope, incrementCounter) {\n var shared = env.shared\n var STATS = env.stats\n var CURRENT_STATE = shared.current\n var TIMER = shared.timer\n var profileArg = args.profile\n\n function perfCounter () {\n if (typeof performance === 'undefined') {\n return 'Date.now()'\n } else {\n return 'performance.now()'\n }\n }\n\n var CPU_START, QUERY_COUNTER\n function emitProfileStart (block) {\n CPU_START = scope.def()\n block(CPU_START, '=', perfCounter(), ';')\n if (typeof incrementCounter === 'string') {\n block(STATS, '.count+=', incrementCounter, ';')\n } else {\n block(STATS, '.count++;')\n }\n if (timer) {\n if (useScope) {\n QUERY_COUNTER = scope.def()\n block(QUERY_COUNTER, '=', TIMER, '.getNumPendingQueries();')\n } else {\n block(TIMER, '.beginQuery(', STATS, ');')\n }\n }\n }\n\n function emitProfileEnd (block) {\n block(STATS, '.cpuTime+=', perfCounter(), '-', CPU_START, ';')\n if (timer) {\n if (useScope) {\n block(TIMER, '.pushScopeStats(',\n QUERY_COUNTER, ',',\n TIMER, '.getNumPendingQueries(),',\n STATS, ');')\n } else {\n block(TIMER, '.endQuery();')\n }\n }\n }\n\n function scopeProfile (value) {\n var prev = scope.def(CURRENT_STATE, '.profile')\n scope(CURRENT_STATE, '.profile=', value, ';')\n scope.exit(CURRENT_STATE, '.profile=', prev, ';')\n }\n\n var USE_PROFILE\n if (profileArg) {\n if (isStatic(profileArg)) {\n if (profileArg.enable) {\n emitProfileStart(scope)\n emitProfileEnd(scope.exit)\n scopeProfile('true')\n } else {\n scopeProfile('false')\n }\n return\n }\n USE_PROFILE = profileArg.append(env, scope)\n scopeProfile(USE_PROFILE)\n } else {\n USE_PROFILE = scope.def(CURRENT_STATE, '.profile')\n }\n\n var start = env.block()\n emitProfileStart(start)\n scope('if(', USE_PROFILE, '){', start, '}')\n var end = env.block()\n emitProfileEnd(end)\n scope.exit('if(', USE_PROFILE, '){', end, '}')\n }\n\n function emitAttributes (env, scope, args, attributes, filter) {\n var shared = env.shared\n\n function typeLength (x) {\n switch (x) {\n case GL_FLOAT_VEC2:\n case GL_INT_VEC2:\n case GL_BOOL_VEC2:\n return 2\n case GL_FLOAT_VEC3:\n case GL_INT_VEC3:\n case GL_BOOL_VEC3:\n return 3\n case GL_FLOAT_VEC4:\n case GL_INT_VEC4:\n case GL_BOOL_VEC4:\n return 4\n default:\n return 1\n }\n }\n\n function emitBindAttribute (ATTRIBUTE, size, record) {\n var GL = shared.gl\n\n var LOCATION = scope.def(ATTRIBUTE, '.location')\n var BINDING = scope.def(shared.attributes, '[', LOCATION, ']')\n\n var STATE = record.state\n var BUFFER = record.buffer\n var CONST_COMPONENTS = [\n record.x,\n record.y,\n record.z,\n record.w\n ]\n\n var COMMON_KEYS = [\n 'buffer',\n 'normalized',\n 'offset',\n 'stride'\n ]\n\n function emitBuffer () {\n scope(\n 'if(!', BINDING, '.buffer){',\n GL, '.enableVertexAttribArray(', LOCATION, ');}')\n\n var TYPE = record.type\n var SIZE\n if (!record.size) {\n SIZE = size\n } else {\n SIZE = scope.def(record.size, '||', size)\n }\n\n scope('if(',\n BINDING, '.type!==', TYPE, '||',\n BINDING, '.size!==', SIZE, '||',\n COMMON_KEYS.map(function (key) {\n return BINDING + '.' + key + '!==' + record[key]\n }).join('||'),\n '){',\n GL, '.bindBuffer(', GL_ARRAY_BUFFER$2, ',', BUFFER, '.buffer);',\n GL, '.vertexAttribPointer(', [\n LOCATION,\n SIZE,\n TYPE,\n record.normalized,\n record.stride,\n record.offset\n ], ');',\n BINDING, '.type=', TYPE, ';',\n BINDING, '.size=', SIZE, ';',\n COMMON_KEYS.map(function (key) {\n return BINDING + '.' + key + '=' + record[key] + ';'\n }).join(''),\n '}')\n\n if (extInstancing) {\n var DIVISOR = record.divisor\n scope(\n 'if(', BINDING, '.divisor!==', DIVISOR, '){',\n env.instancing, '.vertexAttribDivisorANGLE(', [LOCATION, DIVISOR], ');',\n BINDING, '.divisor=', DIVISOR, ';}')\n }\n }\n\n function emitConstant () {\n scope(\n 'if(', BINDING, '.buffer){',\n GL, '.disableVertexAttribArray(', LOCATION, ');',\n BINDING, '.buffer=null;',\n '}if(', CUTE_COMPONENTS.map(function (c, i) {\n return BINDING + '.' + c + '!==' + CONST_COMPONENTS[i]\n }).join('||'), '){',\n GL, '.vertexAttrib4f(', LOCATION, ',', CONST_COMPONENTS, ');',\n CUTE_COMPONENTS.map(function (c, i) {\n return BINDING + '.' + c + '=' + CONST_COMPONENTS[i] + ';'\n }).join(''),\n '}')\n }\n\n if (STATE === ATTRIB_STATE_POINTER) {\n emitBuffer()\n } else if (STATE === ATTRIB_STATE_CONSTANT) {\n emitConstant()\n } else {\n scope('if(', STATE, '===', ATTRIB_STATE_POINTER, '){')\n emitBuffer()\n scope('}else{')\n emitConstant()\n scope('}')\n }\n }\n\n attributes.forEach(function (attribute) {\n var name = attribute.name\n var arg = args.attributes[name]\n var record\n if (arg) {\n if (!filter(arg)) {\n return\n }\n record = arg.append(env, scope)\n } else {\n if (!filter(SCOPE_DECL)) {\n return\n }\n var scopeAttrib = env.scopeAttrib(name)\n check$1.optional(function () {\n env.assert(scope,\n scopeAttrib + '.state',\n 'missing attribute ' + name)\n })\n record = {}\n Object.keys(new AttributeRecord()).forEach(function (key) {\n record[key] = scope.def(scopeAttrib, '.', key)\n })\n }\n emitBindAttribute(\n env.link(attribute), typeLength(attribute.info.type), record)\n })\n }\n\n function emitUniforms (env, scope, args, uniforms, filter) {\n var shared = env.shared\n var GL = shared.gl\n\n var infix\n for (var i = 0; i < uniforms.length; ++i) {\n var uniform = uniforms[i]\n var name = uniform.name\n var type = uniform.info.type\n var arg = args.uniforms[name]\n var UNIFORM = env.link(uniform)\n var LOCATION = UNIFORM + '.location'\n\n var VALUE\n if (arg) {\n if (!filter(arg)) {\n continue\n }\n if (isStatic(arg)) {\n var value = arg.value\n check$1.command(\n value !== null && typeof value !== 'undefined',\n 'missing uniform \"' + name + '\"', env.commandStr)\n if (type === GL_SAMPLER_2D || type === GL_SAMPLER_CUBE) {\n check$1.command(\n typeof value === 'function' &&\n ((type === GL_SAMPLER_2D &&\n (value._reglType === 'texture2d' ||\n value._reglType === 'framebuffer')) ||\n (type === GL_SAMPLER_CUBE &&\n (value._reglType === 'textureCube' ||\n value._reglType === 'framebufferCube'))),\n 'invalid texture for uniform ' + name, env.commandStr)\n var TEX_VALUE = env.link(value._texture || value.color[0]._texture)\n scope(GL, '.uniform1i(', LOCATION, ',', TEX_VALUE + '.bind());')\n scope.exit(TEX_VALUE, '.unbind();')\n } else if (\n type === GL_FLOAT_MAT2 ||\n type === GL_FLOAT_MAT3 ||\n type === GL_FLOAT_MAT4) {\n check$1.optional(function () {\n check$1.command(isArrayLike(value),\n 'invalid matrix for uniform ' + name, env.commandStr)\n check$1.command(\n (type === GL_FLOAT_MAT2 && value.length === 4) ||\n (type === GL_FLOAT_MAT3 && value.length === 9) ||\n (type === GL_FLOAT_MAT4 && value.length === 16),\n 'invalid length for matrix uniform ' + name, env.commandStr)\n })\n var MAT_VALUE = env.global.def('new Float32Array([' +\n Array.prototype.slice.call(value) + '])')\n var dim = 2\n if (type === GL_FLOAT_MAT3) {\n dim = 3\n } else if (type === GL_FLOAT_MAT4) {\n dim = 4\n }\n scope(\n GL, '.uniformMatrix', dim, 'fv(',\n LOCATION, ',false,', MAT_VALUE, ');')\n } else {\n switch (type) {\n case GL_FLOAT$8:\n check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr)\n infix = '1f'\n break\n case GL_FLOAT_VEC2:\n check$1.command(\n isArrayLike(value) && value.length === 2,\n 'uniform ' + name, env.commandStr)\n infix = '2f'\n break\n case GL_FLOAT_VEC3:\n check$1.command(\n isArrayLike(value) && value.length === 3,\n 'uniform ' + name, env.commandStr)\n infix = '3f'\n break\n case GL_FLOAT_VEC4:\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'uniform ' + name, env.commandStr)\n infix = '4f'\n break\n case GL_BOOL:\n check$1.commandType(value, 'boolean', 'uniform ' + name, env.commandStr)\n infix = '1i'\n break\n case GL_INT$3:\n check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr)\n infix = '1i'\n break\n case GL_BOOL_VEC2:\n check$1.command(\n isArrayLike(value) && value.length === 2,\n 'uniform ' + name, env.commandStr)\n infix = '2i'\n break\n case GL_INT_VEC2:\n check$1.command(\n isArrayLike(value) && value.length === 2,\n 'uniform ' + name, env.commandStr)\n infix = '2i'\n break\n case GL_BOOL_VEC3:\n check$1.command(\n isArrayLike(value) && value.length === 3,\n 'uniform ' + name, env.commandStr)\n infix = '3i'\n break\n case GL_INT_VEC3:\n check$1.command(\n isArrayLike(value) && value.length === 3,\n 'uniform ' + name, env.commandStr)\n infix = '3i'\n break\n case GL_BOOL_VEC4:\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'uniform ' + name, env.commandStr)\n infix = '4i'\n break\n case GL_INT_VEC4:\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'uniform ' + name, env.commandStr)\n infix = '4i'\n break\n }\n scope(GL, '.uniform', infix, '(', LOCATION, ',',\n isArrayLike(value) ? Array.prototype.slice.call(value) : value,\n ');')\n }\n continue\n } else {\n VALUE = arg.append(env, scope)\n }\n } else {\n if (!filter(SCOPE_DECL)) {\n continue\n }\n VALUE = scope.def(shared.uniforms, '[', stringStore.id(name), ']')\n }\n\n if (type === GL_SAMPLER_2D) {\n check$1(!Array.isArray(VALUE), 'must specify a scalar prop for textures')\n scope(\n 'if(', VALUE, '&&', VALUE, '._reglType===\"framebuffer\"){',\n VALUE, '=', VALUE, '.color[0];',\n '}')\n } else if (type === GL_SAMPLER_CUBE) {\n check$1(!Array.isArray(VALUE), 'must specify a scalar prop for cube maps')\n scope(\n 'if(', VALUE, '&&', VALUE, '._reglType===\"framebufferCube\"){',\n VALUE, '=', VALUE, '.color[0];',\n '}')\n }\n\n // perform type validation\n check$1.optional(function () {\n function emitCheck (pred, message) {\n env.assert(scope, pred,\n 'bad data or missing for uniform \"' + name + '\". ' + message)\n }\n\n function checkType (type) {\n check$1(!Array.isArray(VALUE), 'must not specify an array type for uniform')\n emitCheck(\n 'typeof ' + VALUE + '===\"' + type + '\"',\n 'invalid type, expected ' + type)\n }\n\n function checkVector (n, type) {\n if (Array.isArray(VALUE)) {\n check$1(VALUE.length === n, 'must have length ' + n)\n } else {\n emitCheck(\n shared.isArrayLike + '(' + VALUE + ')&&' + VALUE + '.length===' + n,\n 'invalid vector, should have length ' + n, env.commandStr)\n }\n }\n\n function checkTexture (target) {\n check$1(!Array.isArray(VALUE), 'must not specify a value type')\n emitCheck(\n 'typeof ' + VALUE + '===\"function\"&&' +\n VALUE + '._reglType===\"texture' +\n (target === GL_TEXTURE_2D$3 ? '2d' : 'Cube') + '\"',\n 'invalid texture type', env.commandStr)\n }\n\n switch (type) {\n case GL_INT$3:\n checkType('number')\n break\n case GL_INT_VEC2:\n checkVector(2, 'number')\n break\n case GL_INT_VEC3:\n checkVector(3, 'number')\n break\n case GL_INT_VEC4:\n checkVector(4, 'number')\n break\n case GL_FLOAT$8:\n checkType('number')\n break\n case GL_FLOAT_VEC2:\n checkVector(2, 'number')\n break\n case GL_FLOAT_VEC3:\n checkVector(3, 'number')\n break\n case GL_FLOAT_VEC4:\n checkVector(4, 'number')\n break\n case GL_BOOL:\n checkType('boolean')\n break\n case GL_BOOL_VEC2:\n checkVector(2, 'boolean')\n break\n case GL_BOOL_VEC3:\n checkVector(3, 'boolean')\n break\n case GL_BOOL_VEC4:\n checkVector(4, 'boolean')\n break\n case GL_FLOAT_MAT2:\n checkVector(4, 'number')\n break\n case GL_FLOAT_MAT3:\n checkVector(9, 'number')\n break\n case GL_FLOAT_MAT4:\n checkVector(16, 'number')\n break\n case GL_SAMPLER_2D:\n checkTexture(GL_TEXTURE_2D$3)\n break\n case GL_SAMPLER_CUBE:\n checkTexture(GL_TEXTURE_CUBE_MAP$2)\n break\n }\n })\n\n var unroll = 1\n switch (type) {\n case GL_SAMPLER_2D:\n case GL_SAMPLER_CUBE:\n var TEX = scope.def(VALUE, '._texture')\n scope(GL, '.uniform1i(', LOCATION, ',', TEX, '.bind());')\n scope.exit(TEX, '.unbind();')\n continue\n\n case GL_INT$3:\n case GL_BOOL:\n infix = '1i'\n break\n\n case GL_INT_VEC2:\n case GL_BOOL_VEC2:\n infix = '2i'\n unroll = 2\n break\n\n case GL_INT_VEC3:\n case GL_BOOL_VEC3:\n infix = '3i'\n unroll = 3\n break\n\n case GL_INT_VEC4:\n case GL_BOOL_VEC4:\n infix = '4i'\n unroll = 4\n break\n\n case GL_FLOAT$8:\n infix = '1f'\n break\n\n case GL_FLOAT_VEC2:\n infix = '2f'\n unroll = 2\n break\n\n case GL_FLOAT_VEC3:\n infix = '3f'\n unroll = 3\n break\n\n case GL_FLOAT_VEC4:\n infix = '4f'\n unroll = 4\n break\n\n case GL_FLOAT_MAT2:\n infix = 'Matrix2fv'\n break\n\n case GL_FLOAT_MAT3:\n infix = 'Matrix3fv'\n break\n\n case GL_FLOAT_MAT4:\n infix = 'Matrix4fv'\n break\n }\n\n scope(GL, '.uniform', infix, '(', LOCATION, ',')\n if (infix.charAt(0) === 'M') {\n var matSize = Math.pow(type - GL_FLOAT_MAT2 + 2, 2)\n var STORAGE = env.global.def('new Float32Array(', matSize, ')')\n if (Array.isArray(VALUE)) {\n scope(\n 'false,(',\n loop(matSize, function (i) {\n return STORAGE + '[' + i + ']=' + VALUE[i]\n }), ',', STORAGE, ')')\n } else {\n scope(\n 'false,(Array.isArray(', VALUE, ')||', VALUE, ' instanceof Float32Array)?', VALUE, ':(',\n loop(matSize, function (i) {\n return STORAGE + '[' + i + ']=' + VALUE + '[' + i + ']'\n }), ',', STORAGE, ')')\n }\n } else if (unroll > 1) {\n scope(loop(unroll, function (i) {\n return Array.isArray(VALUE) ? VALUE[i] : VALUE + '[' + i + ']'\n }))\n } else {\n check$1(!Array.isArray(VALUE), 'uniform value must not be an array')\n scope(VALUE)\n }\n scope(');')\n }\n }\n\n function emitDraw (env, outer, inner, args) {\n var shared = env.shared\n var GL = shared.gl\n var DRAW_STATE = shared.draw\n\n var drawOptions = args.draw\n\n function emitElements () {\n var defn = drawOptions.elements\n var ELEMENTS\n var scope = outer\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n scope = inner\n }\n ELEMENTS = defn.append(env, scope)\n } else {\n ELEMENTS = scope.def(DRAW_STATE, '.', S_ELEMENTS)\n }\n if (ELEMENTS) {\n scope(\n 'if(' + ELEMENTS + ')' +\n GL + '.bindBuffer(' + GL_ELEMENT_ARRAY_BUFFER$1 + ',' + ELEMENTS + '.buffer.buffer);')\n }\n return ELEMENTS\n }\n\n function emitCount () {\n var defn = drawOptions.count\n var COUNT\n var scope = outer\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n scope = inner\n }\n COUNT = defn.append(env, scope)\n check$1.optional(function () {\n if (defn.MISSING) {\n env.assert(outer, 'false', 'missing vertex count')\n }\n if (defn.DYNAMIC) {\n env.assert(scope, COUNT + '>=0', 'missing vertex count')\n }\n })\n } else {\n COUNT = scope.def(DRAW_STATE, '.', S_COUNT)\n check$1.optional(function () {\n env.assert(scope, COUNT + '>=0', 'missing vertex count')\n })\n }\n return COUNT\n }\n\n var ELEMENTS = emitElements()\n function emitValue (name) {\n var defn = drawOptions[name]\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n return defn.append(env, inner)\n } else {\n return defn.append(env, outer)\n }\n } else {\n return outer.def(DRAW_STATE, '.', name)\n }\n }\n\n var PRIMITIVE = emitValue(S_PRIMITIVE)\n var OFFSET = emitValue(S_OFFSET)\n\n var COUNT = emitCount()\n if (typeof COUNT === 'number') {\n if (COUNT === 0) {\n return\n }\n } else {\n inner('if(', COUNT, '){')\n inner.exit('}')\n }\n\n var INSTANCES, EXT_INSTANCING\n if (extInstancing) {\n INSTANCES = emitValue(S_INSTANCES)\n EXT_INSTANCING = env.instancing\n }\n\n var ELEMENT_TYPE = ELEMENTS + '.type'\n\n var elementsStatic = drawOptions.elements && isStatic(drawOptions.elements)\n\n function emitInstancing () {\n function drawElements () {\n inner(EXT_INSTANCING, '.drawElementsInstancedANGLE(', [\n PRIMITIVE,\n COUNT,\n ELEMENT_TYPE,\n OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$8 + ')>>1)',\n INSTANCES\n ], ');')\n }\n\n function drawArrays () {\n inner(EXT_INSTANCING, '.drawArraysInstancedANGLE(',\n [PRIMITIVE, OFFSET, COUNT, INSTANCES], ');')\n }\n\n if (ELEMENTS) {\n if (!elementsStatic) {\n inner('if(', ELEMENTS, '){')\n drawElements()\n inner('}else{')\n drawArrays()\n inner('}')\n } else {\n drawElements()\n }\n } else {\n drawArrays()\n }\n }\n\n function emitRegular () {\n function drawElements () {\n inner(GL + '.drawElements(' + [\n PRIMITIVE,\n COUNT,\n ELEMENT_TYPE,\n OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$8 + ')>>1)'\n ] + ');')\n }\n\n function drawArrays () {\n inner(GL + '.drawArrays(' + [PRIMITIVE, OFFSET, COUNT] + ');')\n }\n\n if (ELEMENTS) {\n if (!elementsStatic) {\n inner('if(', ELEMENTS, '){')\n drawElements()\n inner('}else{')\n drawArrays()\n inner('}')\n } else {\n drawElements()\n }\n } else {\n drawArrays()\n }\n }\n\n if (extInstancing && (typeof INSTANCES !== 'number' || INSTANCES >= 0)) {\n if (typeof INSTANCES === 'string') {\n inner('if(', INSTANCES, '>0){')\n emitInstancing()\n inner('}else if(', INSTANCES, '<0){')\n emitRegular()\n inner('}')\n } else {\n emitInstancing()\n }\n } else {\n emitRegular()\n }\n }\n\n function createBody (emitBody, parentEnv, args, program, count) {\n var env = createREGLEnvironment()\n var scope = env.proc('body', count)\n check$1.optional(function () {\n env.commandStr = parentEnv.commandStr\n env.command = env.link(parentEnv.commandStr)\n })\n if (extInstancing) {\n env.instancing = scope.def(\n env.shared.extensions, '.angle_instanced_arrays')\n }\n emitBody(env, scope, args, program)\n return env.compile().body\n }\n\n // ===================================================\n // ===================================================\n // DRAW PROC\n // ===================================================\n // ===================================================\n function emitDrawBody (env, draw, args, program) {\n injectExtensions(env, draw)\n if (args.useVAO) {\n if (args.drawVAO) {\n draw(env.shared.vao, '.setVAO(', args.drawVAO.append(env, draw), ');')\n } else {\n draw(env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);')\n }\n } else {\n draw(env.shared.vao, '.setVAO(null);')\n emitAttributes(env, draw, args, program.attributes, function () {\n return true\n })\n }\n emitUniforms(env, draw, args, program.uniforms, function () {\n return true\n })\n emitDraw(env, draw, draw, args)\n }\n\n function emitDrawProc (env, args) {\n var draw = env.proc('draw', 1)\n\n injectExtensions(env, draw)\n\n emitContext(env, draw, args.context)\n emitPollFramebuffer(env, draw, args.framebuffer)\n\n emitPollState(env, draw, args)\n emitSetOptions(env, draw, args.state)\n\n emitProfile(env, draw, args, false, true)\n\n var program = args.shader.progVar.append(env, draw)\n draw(env.shared.gl, '.useProgram(', program, '.program);')\n\n if (args.shader.program) {\n emitDrawBody(env, draw, args, args.shader.program)\n } else {\n draw(env.shared.vao, '.setVAO(null);')\n var drawCache = env.global.def('{}')\n var PROG_ID = draw.def(program, '.id')\n var CACHED_PROC = draw.def(drawCache, '[', PROG_ID, ']')\n draw(\n env.cond(CACHED_PROC)\n .then(CACHED_PROC, '.call(this,a0);')\n .else(\n CACHED_PROC, '=', drawCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(emitDrawBody, env, args, program, 1)\n }), '(', program, ');',\n CACHED_PROC, '.call(this,a0);'))\n }\n\n if (Object.keys(args.state).length > 0) {\n draw(env.shared.current, '.dirty=true;')\n }\n }\n\n // ===================================================\n // ===================================================\n // BATCH PROC\n // ===================================================\n // ===================================================\n\n function emitBatchDynamicShaderBody (env, scope, args, program) {\n env.batchId = 'a1'\n\n injectExtensions(env, scope)\n\n function all () {\n return true\n }\n\n emitAttributes(env, scope, args, program.attributes, all)\n emitUniforms(env, scope, args, program.uniforms, all)\n emitDraw(env, scope, scope, args)\n }\n\n function emitBatchBody (env, scope, args, program) {\n injectExtensions(env, scope)\n\n var contextDynamic = args.contextDep\n\n var BATCH_ID = scope.def()\n var PROP_LIST = 'a0'\n var NUM_PROPS = 'a1'\n var PROPS = scope.def()\n env.shared.props = PROPS\n env.batchId = BATCH_ID\n\n var outer = env.scope()\n var inner = env.scope()\n\n scope(\n outer.entry,\n 'for(', BATCH_ID, '=0;', BATCH_ID, '<', NUM_PROPS, ';++', BATCH_ID, '){',\n PROPS, '=', PROP_LIST, '[', BATCH_ID, '];',\n inner,\n '}',\n outer.exit)\n\n function isInnerDefn (defn) {\n return ((defn.contextDep && contextDynamic) || defn.propDep)\n }\n\n function isOuterDefn (defn) {\n return !isInnerDefn(defn)\n }\n\n if (args.needsContext) {\n emitContext(env, inner, args.context)\n }\n if (args.needsFramebuffer) {\n emitPollFramebuffer(env, inner, args.framebuffer)\n }\n emitSetOptions(env, inner, args.state, isInnerDefn)\n\n if (args.profile && isInnerDefn(args.profile)) {\n emitProfile(env, inner, args, false, true)\n }\n\n if (!program) {\n var progCache = env.global.def('{}')\n var PROGRAM = args.shader.progVar.append(env, inner)\n var PROG_ID = inner.def(PROGRAM, '.id')\n var CACHED_PROC = inner.def(progCache, '[', PROG_ID, ']')\n inner(\n env.shared.gl, '.useProgram(', PROGRAM, '.program);',\n 'if(!', CACHED_PROC, '){',\n CACHED_PROC, '=', progCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(\n emitBatchDynamicShaderBody, env, args, program, 2)\n }), '(', PROGRAM, ');}',\n CACHED_PROC, '.call(this,a0[', BATCH_ID, '],', BATCH_ID, ');')\n } else {\n if (args.useVAO) {\n if (args.drawVAO) {\n if (isInnerDefn(args.drawVAO)) {\n // vao is a prop\n inner(env.shared.vao, '.setVAO(', args.drawVAO.append(env, inner), ');')\n } else {\n // vao is invariant\n outer(env.shared.vao, '.setVAO(', args.drawVAO.append(env, outer), ');')\n }\n } else {\n // scoped vao binding\n outer(env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);')\n }\n } else {\n outer(env.shared.vao, '.setVAO(null);')\n emitAttributes(env, outer, args, program.attributes, isOuterDefn)\n emitAttributes(env, inner, args, program.attributes, isInnerDefn)\n }\n emitUniforms(env, outer, args, program.uniforms, isOuterDefn)\n emitUniforms(env, inner, args, program.uniforms, isInnerDefn)\n emitDraw(env, outer, inner, args)\n }\n }\n\n function emitBatchProc (env, args) {\n var batch = env.proc('batch', 2)\n env.batchId = '0'\n\n injectExtensions(env, batch)\n\n // Check if any context variables depend on props\n var contextDynamic = false\n var needsContext = true\n Object.keys(args.context).forEach(function (name) {\n contextDynamic = contextDynamic || args.context[name].propDep\n })\n if (!contextDynamic) {\n emitContext(env, batch, args.context)\n needsContext = false\n }\n\n // framebuffer state affects framebufferWidth/height context vars\n var framebuffer = args.framebuffer\n var needsFramebuffer = false\n if (framebuffer) {\n if (framebuffer.propDep) {\n contextDynamic = needsFramebuffer = true\n } else if (framebuffer.contextDep && contextDynamic) {\n needsFramebuffer = true\n }\n if (!needsFramebuffer) {\n emitPollFramebuffer(env, batch, framebuffer)\n }\n } else {\n emitPollFramebuffer(env, batch, null)\n }\n\n // viewport is weird because it can affect context vars\n if (args.state.viewport && args.state.viewport.propDep) {\n contextDynamic = true\n }\n\n function isInnerDefn (defn) {\n return (defn.contextDep && contextDynamic) || defn.propDep\n }\n\n // set webgl options\n emitPollState(env, batch, args)\n emitSetOptions(env, batch, args.state, function (defn) {\n return !isInnerDefn(defn)\n })\n\n if (!args.profile || !isInnerDefn(args.profile)) {\n emitProfile(env, batch, args, false, 'a1')\n }\n\n // Save these values to args so that the batch body routine can use them\n args.contextDep = contextDynamic\n args.needsContext = needsContext\n args.needsFramebuffer = needsFramebuffer\n\n // determine if shader is dynamic\n var progDefn = args.shader.progVar\n if ((progDefn.contextDep && contextDynamic) || progDefn.propDep) {\n emitBatchBody(\n env,\n batch,\n args,\n null)\n } else {\n var PROGRAM = progDefn.append(env, batch)\n batch(env.shared.gl, '.useProgram(', PROGRAM, '.program);')\n if (args.shader.program) {\n emitBatchBody(\n env,\n batch,\n args,\n args.shader.program)\n } else {\n batch(env.shared.vao, '.setVAO(null);')\n var batchCache = env.global.def('{}')\n var PROG_ID = batch.def(PROGRAM, '.id')\n var CACHED_PROC = batch.def(batchCache, '[', PROG_ID, ']')\n batch(\n env.cond(CACHED_PROC)\n .then(CACHED_PROC, '.call(this,a0,a1);')\n .else(\n CACHED_PROC, '=', batchCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(emitBatchBody, env, args, program, 2)\n }), '(', PROGRAM, ');',\n CACHED_PROC, '.call(this,a0,a1);'))\n }\n }\n\n if (Object.keys(args.state).length > 0) {\n batch(env.shared.current, '.dirty=true;')\n }\n }\n\n // ===================================================\n // ===================================================\n // SCOPE COMMAND\n // ===================================================\n // ===================================================\n function emitScopeProc (env, args) {\n var scope = env.proc('scope', 3)\n env.batchId = 'a2'\n\n var shared = env.shared\n var CURRENT_STATE = shared.current\n\n emitContext(env, scope, args.context)\n\n if (args.framebuffer) {\n args.framebuffer.append(env, scope)\n }\n\n sortState(Object.keys(args.state)).forEach(function (name) {\n var defn = args.state[name]\n var value = defn.append(env, scope)\n if (isArrayLike(value)) {\n value.forEach(function (v, i) {\n scope.set(env.next[name], '[' + i + ']', v)\n })\n } else {\n scope.set(shared.next, '.' + name, value)\n }\n })\n\n emitProfile(env, scope, args, true, true)\n\n ;[S_ELEMENTS, S_OFFSET, S_COUNT, S_INSTANCES, S_PRIMITIVE].forEach(\n function (opt) {\n var variable = args.draw[opt]\n if (!variable) {\n return\n }\n scope.set(shared.draw, '.' + opt, '' + variable.append(env, scope))\n })\n\n Object.keys(args.uniforms).forEach(function (opt) {\n var value = args.uniforms[opt].append(env, scope)\n if (Array.isArray(value)) {\n value = '[' + value.join() + ']'\n }\n scope.set(\n shared.uniforms,\n '[' + stringStore.id(opt) + ']',\n value)\n })\n\n Object.keys(args.attributes).forEach(function (name) {\n var record = args.attributes[name].append(env, scope)\n var scopeAttrib = env.scopeAttrib(name)\n Object.keys(new AttributeRecord()).forEach(function (prop) {\n scope.set(scopeAttrib, '.' + prop, record[prop])\n })\n })\n\n if (args.scopeVAO) {\n scope.set(shared.vao, '.targetVAO', args.scopeVAO.append(env, scope))\n }\n\n function saveShader (name) {\n var shader = args.shader[name]\n if (shader) {\n scope.set(shared.shader, '.' + name, shader.append(env, scope))\n }\n }\n saveShader(S_VERT)\n saveShader(S_FRAG)\n\n if (Object.keys(args.state).length > 0) {\n scope(CURRENT_STATE, '.dirty=true;')\n scope.exit(CURRENT_STATE, '.dirty=true;')\n }\n\n scope('a1(', env.shared.context, ',a0,', env.batchId, ');')\n }\n\n function isDynamicObject (object) {\n if (typeof object !== 'object' || isArrayLike(object)) {\n return\n }\n var props = Object.keys(object)\n for (var i = 0; i < props.length; ++i) {\n if (dynamic.isDynamic(object[props[i]])) {\n return true\n }\n }\n return false\n }\n\n function splatObject (env, options, name) {\n var object = options.static[name]\n if (!object || !isDynamicObject(object)) {\n return\n }\n\n var globals = env.global\n var keys = Object.keys(object)\n var thisDep = false\n var contextDep = false\n var propDep = false\n var objectRef = env.global.def('{}')\n keys.forEach(function (key) {\n var value = object[key]\n if (dynamic.isDynamic(value)) {\n if (typeof value === 'function') {\n value = object[key] = dynamic.unbox(value)\n }\n var deps = createDynamicDecl(value, null)\n thisDep = thisDep || deps.thisDep\n propDep = propDep || deps.propDep\n contextDep = contextDep || deps.contextDep\n } else {\n globals(objectRef, '.', key, '=')\n switch (typeof value) {\n case 'number':\n globals(value)\n break\n case 'string':\n globals('\"', value, '\"')\n break\n case 'object':\n if (Array.isArray(value)) {\n globals('[', value.join(), ']')\n }\n break\n default:\n globals(env.link(value))\n break\n }\n globals(';')\n }\n })\n\n function appendBlock (env, block) {\n keys.forEach(function (key) {\n var value = object[key]\n if (!dynamic.isDynamic(value)) {\n return\n }\n var ref = env.invoke(block, value)\n block(objectRef, '.', key, '=', ref, ';')\n })\n }\n\n options.dynamic[name] = new dynamic.DynamicVariable(DYN_THUNK, {\n thisDep: thisDep,\n contextDep: contextDep,\n propDep: propDep,\n ref: objectRef,\n append: appendBlock\n })\n delete options.static[name]\n }\n\n // ===========================================================================\n // ===========================================================================\n // MAIN DRAW COMMAND\n // ===========================================================================\n // ===========================================================================\n function compileCommand (options, attributes, uniforms, context, stats) {\n var env = createREGLEnvironment()\n\n // link stats, so that we can easily access it in the program.\n env.stats = env.link(stats)\n\n // splat options and attributes to allow for dynamic nested properties\n Object.keys(attributes.static).forEach(function (key) {\n splatObject(env, attributes, key)\n })\n NESTED_OPTIONS.forEach(function (name) {\n splatObject(env, options, name)\n })\n\n var args = parseArguments(options, attributes, uniforms, context, env)\n\n emitDrawProc(env, args)\n emitScopeProc(env, args)\n emitBatchProc(env, args)\n\n return extend(env.compile(), {\n destroy: function () {\n args.shader.program.destroy()\n }\n })\n }\n\n // ===========================================================================\n // ===========================================================================\n // POLL / REFRESH\n // ===========================================================================\n // ===========================================================================\n return {\n next: nextState,\n current: currentState,\n procs: (function () {\n var env = createREGLEnvironment()\n var poll = env.proc('poll')\n var refresh = env.proc('refresh')\n var common = env.block()\n poll(common)\n refresh(common)\n\n var shared = env.shared\n var GL = shared.gl\n var NEXT_STATE = shared.next\n var CURRENT_STATE = shared.current\n\n common(CURRENT_STATE, '.dirty=false;')\n\n emitPollFramebuffer(env, poll)\n emitPollFramebuffer(env, refresh, null, true)\n\n // Refresh updates all attribute state changes\n var INSTANCING\n if (extInstancing) {\n INSTANCING = env.link(extInstancing)\n }\n\n // update vertex array bindings\n if (extensions.oes_vertex_array_object) {\n refresh(env.link(extensions.oes_vertex_array_object), '.bindVertexArrayOES(null);')\n }\n for (var i = 0; i < limits.maxAttributes; ++i) {\n var BINDING = refresh.def(shared.attributes, '[', i, ']')\n var ifte = env.cond(BINDING, '.buffer')\n ifte.then(\n GL, '.enableVertexAttribArray(', i, ');',\n GL, '.bindBuffer(',\n GL_ARRAY_BUFFER$2, ',',\n BINDING, '.buffer.buffer);',\n GL, '.vertexAttribPointer(',\n i, ',',\n BINDING, '.size,',\n BINDING, '.type,',\n BINDING, '.normalized,',\n BINDING, '.stride,',\n BINDING, '.offset);'\n ).else(\n GL, '.disableVertexAttribArray(', i, ');',\n GL, '.vertexAttrib4f(',\n i, ',',\n BINDING, '.x,',\n BINDING, '.y,',\n BINDING, '.z,',\n BINDING, '.w);',\n BINDING, '.buffer=null;')\n refresh(ifte)\n if (extInstancing) {\n refresh(\n INSTANCING, '.vertexAttribDivisorANGLE(',\n i, ',',\n BINDING, '.divisor);')\n }\n }\n refresh(\n env.shared.vao, '.currentVAO=null;',\n env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);')\n\n Object.keys(GL_FLAGS).forEach(function (flag) {\n var cap = GL_FLAGS[flag]\n var NEXT = common.def(NEXT_STATE, '.', flag)\n var block = env.block()\n block('if(', NEXT, '){',\n GL, '.enable(', cap, ')}else{',\n GL, '.disable(', cap, ')}',\n CURRENT_STATE, '.', flag, '=', NEXT, ';')\n refresh(block)\n poll(\n 'if(', NEXT, '!==', CURRENT_STATE, '.', flag, '){',\n block,\n '}')\n })\n\n Object.keys(GL_VARIABLES).forEach(function (name) {\n var func = GL_VARIABLES[name]\n var init = currentState[name]\n var NEXT, CURRENT\n var block = env.block()\n block(GL, '.', func, '(')\n if (isArrayLike(init)) {\n var n = init.length\n NEXT = env.global.def(NEXT_STATE, '.', name)\n CURRENT = env.global.def(CURRENT_STATE, '.', name)\n block(\n loop(n, function (i) {\n return NEXT + '[' + i + ']'\n }), ');',\n loop(n, function (i) {\n return CURRENT + '[' + i + ']=' + NEXT + '[' + i + '];'\n }).join(''))\n poll(\n 'if(', loop(n, function (i) {\n return NEXT + '[' + i + ']!==' + CURRENT + '[' + i + ']'\n }).join('||'), '){',\n block,\n '}')\n } else {\n NEXT = common.def(NEXT_STATE, '.', name)\n CURRENT = common.def(CURRENT_STATE, '.', name)\n block(\n NEXT, ');',\n CURRENT_STATE, '.', name, '=', NEXT, ';')\n poll(\n 'if(', NEXT, '!==', CURRENT, '){',\n block,\n '}')\n }\n refresh(block)\n })\n\n return env.compile()\n })(),\n compile: compileCommand\n }\n}\n\nfunction stats () {\n return {\n vaoCount: 0,\n bufferCount: 0,\n elementsCount: 0,\n framebufferCount: 0,\n shaderCount: 0,\n textureCount: 0,\n cubeCount: 0,\n renderbufferCount: 0,\n maxTextureUnits: 0\n }\n}\n\nvar GL_QUERY_RESULT_EXT = 0x8866\nvar GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867\nvar GL_TIME_ELAPSED_EXT = 0x88BF\n\nvar createTimer = function (gl, extensions) {\n if (!extensions.ext_disjoint_timer_query) {\n return null\n }\n\n // QUERY POOL BEGIN\n var queryPool = []\n function allocQuery () {\n return queryPool.pop() || extensions.ext_disjoint_timer_query.createQueryEXT()\n }\n function freeQuery (query) {\n queryPool.push(query)\n }\n // QUERY POOL END\n\n var pendingQueries = []\n function beginQuery (stats) {\n var query = allocQuery()\n extensions.ext_disjoint_timer_query.beginQueryEXT(GL_TIME_ELAPSED_EXT, query)\n pendingQueries.push(query)\n pushScopeStats(pendingQueries.length - 1, pendingQueries.length, stats)\n }\n\n function endQuery () {\n extensions.ext_disjoint_timer_query.endQueryEXT(GL_TIME_ELAPSED_EXT)\n }\n\n //\n // Pending stats pool.\n //\n function PendingStats () {\n this.startQueryIndex = -1\n this.endQueryIndex = -1\n this.sum = 0\n this.stats = null\n }\n var pendingStatsPool = []\n function allocPendingStats () {\n return pendingStatsPool.pop() || new PendingStats()\n }\n function freePendingStats (pendingStats) {\n pendingStatsPool.push(pendingStats)\n }\n // Pending stats pool end\n\n var pendingStats = []\n function pushScopeStats (start, end, stats) {\n var ps = allocPendingStats()\n ps.startQueryIndex = start\n ps.endQueryIndex = end\n ps.sum = 0\n ps.stats = stats\n pendingStats.push(ps)\n }\n\n // we should call this at the beginning of the frame,\n // in order to update gpuTime\n var timeSum = []\n var queryPtr = []\n function update () {\n var ptr, i\n\n var n = pendingQueries.length\n if (n === 0) {\n return\n }\n\n // Reserve space\n queryPtr.length = Math.max(queryPtr.length, n + 1)\n timeSum.length = Math.max(timeSum.length, n + 1)\n timeSum[0] = 0\n queryPtr[0] = 0\n\n // Update all pending timer queries\n var queryTime = 0\n ptr = 0\n for (i = 0; i < pendingQueries.length; ++i) {\n var query = pendingQueries[i]\n if (extensions.ext_disjoint_timer_query.getQueryObjectEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT)) {\n queryTime += extensions.ext_disjoint_timer_query.getQueryObjectEXT(query, GL_QUERY_RESULT_EXT)\n freeQuery(query)\n } else {\n pendingQueries[ptr++] = query\n }\n timeSum[i + 1] = queryTime\n queryPtr[i + 1] = ptr\n }\n pendingQueries.length = ptr\n\n // Update all pending stat queries\n ptr = 0\n for (i = 0; i < pendingStats.length; ++i) {\n var stats = pendingStats[i]\n var start = stats.startQueryIndex\n var end = stats.endQueryIndex\n stats.sum += timeSum[end] - timeSum[start]\n var startPtr = queryPtr[start]\n var endPtr = queryPtr[end]\n if (endPtr === startPtr) {\n stats.stats.gpuTime += stats.sum / 1e6\n freePendingStats(stats)\n } else {\n stats.startQueryIndex = startPtr\n stats.endQueryIndex = endPtr\n pendingStats[ptr++] = stats\n }\n }\n pendingStats.length = ptr\n }\n\n return {\n beginQuery: beginQuery,\n endQuery: endQuery,\n pushScopeStats: pushScopeStats,\n update: update,\n getNumPendingQueries: function () {\n return pendingQueries.length\n },\n clear: function () {\n queryPool.push.apply(queryPool, pendingQueries)\n for (var i = 0; i < queryPool.length; i++) {\n extensions.ext_disjoint_timer_query.deleteQueryEXT(queryPool[i])\n }\n pendingQueries.length = 0\n queryPool.length = 0\n },\n restore: function () {\n pendingQueries.length = 0\n queryPool.length = 0\n }\n }\n}\n\nvar GL_COLOR_BUFFER_BIT = 16384\nvar GL_DEPTH_BUFFER_BIT = 256\nvar GL_STENCIL_BUFFER_BIT = 1024\n\nvar GL_ARRAY_BUFFER = 34962\n\nvar CONTEXT_LOST_EVENT = 'webglcontextlost'\nvar CONTEXT_RESTORED_EVENT = 'webglcontextrestored'\n\nvar DYN_PROP = 1\nvar DYN_CONTEXT = 2\nvar DYN_STATE = 3\n\nfunction find (haystack, needle) {\n for (var i = 0; i < haystack.length; ++i) {\n if (haystack[i] === needle) {\n return i\n }\n }\n return -1\n}\n\nfunction wrapREGL (args) {\n var config = parseArgs(args)\n if (!config) {\n return null\n }\n\n var gl = config.gl\n var glAttributes = gl.getContextAttributes()\n var contextLost = gl.isContextLost()\n\n var extensionState = createExtensionCache(gl, config)\n if (!extensionState) {\n return null\n }\n\n var stringStore = createStringStore()\n var stats$$1 = stats()\n var extensions = extensionState.extensions\n var timer = createTimer(gl, extensions)\n\n var START_TIME = clock()\n var WIDTH = gl.drawingBufferWidth\n var HEIGHT = gl.drawingBufferHeight\n\n var contextState = {\n tick: 0,\n time: 0,\n viewportWidth: WIDTH,\n viewportHeight: HEIGHT,\n framebufferWidth: WIDTH,\n framebufferHeight: HEIGHT,\n drawingBufferWidth: WIDTH,\n drawingBufferHeight: HEIGHT,\n pixelRatio: config.pixelRatio\n }\n var uniformState = {}\n var drawState = {\n elements: null,\n primitive: 4, // GL_TRIANGLES\n count: -1,\n offset: 0,\n instances: -1\n }\n\n var limits = wrapLimits(gl, extensions)\n var bufferState = wrapBufferState(\n gl,\n stats$$1,\n config,\n destroyBuffer)\n var attributeState = wrapAttributeState(\n gl,\n extensions,\n limits,\n stats$$1,\n bufferState)\n function destroyBuffer (buffer) {\n return attributeState.destroyBuffer(buffer)\n }\n var elementState = wrapElementsState(gl, extensions, bufferState, stats$$1)\n var shaderState = wrapShaderState(gl, stringStore, stats$$1, config)\n var textureState = createTextureSet(\n gl,\n extensions,\n limits,\n function () { core.procs.poll() },\n contextState,\n stats$$1,\n config)\n var renderbufferState = wrapRenderbuffers(gl, extensions, limits, stats$$1, config)\n var framebufferState = wrapFBOState(\n gl,\n extensions,\n limits,\n textureState,\n renderbufferState,\n stats$$1)\n var core = reglCore(\n gl,\n stringStore,\n extensions,\n limits,\n bufferState,\n elementState,\n textureState,\n framebufferState,\n uniformState,\n attributeState,\n shaderState,\n drawState,\n contextState,\n timer,\n config)\n var readPixels = wrapReadPixels(\n gl,\n framebufferState,\n core.procs.poll,\n contextState,\n glAttributes, extensions, limits)\n\n var nextState = core.next\n var canvas = gl.canvas\n\n var rafCallbacks = []\n var lossCallbacks = []\n var restoreCallbacks = []\n var destroyCallbacks = [config.onDestroy]\n\n var activeRAF = null\n function handleRAF () {\n if (rafCallbacks.length === 0) {\n if (timer) {\n timer.update()\n }\n activeRAF = null\n return\n }\n\n // schedule next animation frame\n activeRAF = raf.next(handleRAF)\n\n // poll for changes\n poll()\n\n // fire a callback for all pending rafs\n for (var i = rafCallbacks.length - 1; i >= 0; --i) {\n var cb = rafCallbacks[i]\n if (cb) {\n cb(contextState, null, 0)\n }\n }\n\n // flush all pending webgl calls\n gl.flush()\n\n // poll GPU timers *after* gl.flush so we don't delay command dispatch\n if (timer) {\n timer.update()\n }\n }\n\n function startRAF () {\n if (!activeRAF && rafCallbacks.length > 0) {\n activeRAF = raf.next(handleRAF)\n }\n }\n\n function stopRAF () {\n if (activeRAF) {\n raf.cancel(handleRAF)\n activeRAF = null\n }\n }\n\n function handleContextLoss (event) {\n event.preventDefault()\n\n // set context lost flag\n contextLost = true\n\n // pause request animation frame\n stopRAF()\n\n // lose context\n lossCallbacks.forEach(function (cb) {\n cb()\n })\n }\n\n function handleContextRestored (event) {\n // clear error code\n gl.getError()\n\n // clear context lost flag\n contextLost = false\n\n // refresh state\n extensionState.restore()\n shaderState.restore()\n bufferState.restore()\n textureState.restore()\n renderbufferState.restore()\n framebufferState.restore()\n attributeState.restore()\n if (timer) {\n timer.restore()\n }\n\n // refresh state\n core.procs.refresh()\n\n // restart RAF\n startRAF()\n\n // restore context\n restoreCallbacks.forEach(function (cb) {\n cb()\n })\n }\n\n if (canvas) {\n canvas.addEventListener(CONTEXT_LOST_EVENT, handleContextLoss, false)\n canvas.addEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored, false)\n }\n\n function destroy () {\n rafCallbacks.length = 0\n stopRAF()\n\n if (canvas) {\n canvas.removeEventListener(CONTEXT_LOST_EVENT, handleContextLoss)\n canvas.removeEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored)\n }\n\n shaderState.clear()\n framebufferState.clear()\n renderbufferState.clear()\n textureState.clear()\n elementState.clear()\n bufferState.clear()\n attributeState.clear()\n\n if (timer) {\n timer.clear()\n }\n\n destroyCallbacks.forEach(function (cb) {\n cb()\n })\n }\n\n function compileProcedure (options) {\n check$1(!!options, 'invalid args to regl({...})')\n check$1.type(options, 'object', 'invalid args to regl({...})')\n\n function flattenNestedOptions (options) {\n var result = extend({}, options)\n delete result.uniforms\n delete result.attributes\n delete result.context\n delete result.vao\n\n if ('stencil' in result && result.stencil.op) {\n result.stencil.opBack = result.stencil.opFront = result.stencil.op\n delete result.stencil.op\n }\n\n function merge (name) {\n if (name in result) {\n var child = result[name]\n delete result[name]\n Object.keys(child).forEach(function (prop) {\n result[name + '.' + prop] = child[prop]\n })\n }\n }\n merge('blend')\n merge('depth')\n merge('cull')\n merge('stencil')\n merge('polygonOffset')\n merge('scissor')\n merge('sample')\n\n if ('vao' in options) {\n result.vao = options.vao\n }\n\n return result\n }\n\n function separateDynamic (object, useArrays) {\n var staticItems = {}\n var dynamicItems = {}\n Object.keys(object).forEach(function (option) {\n var value = object[option]\n if (dynamic.isDynamic(value)) {\n dynamicItems[option] = dynamic.unbox(value, option)\n return\n } else if (useArrays && Array.isArray(value)) {\n for (var i = 0; i < value.length; ++i) {\n if (dynamic.isDynamic(value[i])) {\n dynamicItems[option] = dynamic.unbox(value, option)\n return\n }\n }\n }\n staticItems[option] = value\n })\n return {\n dynamic: dynamicItems,\n static: staticItems\n }\n }\n\n // Treat context variables separate from other dynamic variables\n var context = separateDynamic(options.context || {}, true)\n var uniforms = separateDynamic(options.uniforms || {}, true)\n var attributes = separateDynamic(options.attributes || {}, false)\n var opts = separateDynamic(flattenNestedOptions(options), false)\n\n var stats$$1 = {\n gpuTime: 0.0,\n cpuTime: 0.0,\n count: 0\n }\n\n var compiled = core.compile(opts, attributes, uniforms, context, stats$$1)\n\n var draw = compiled.draw\n var batch = compiled.batch\n var scope = compiled.scope\n\n // FIXME: we should modify code generation for batch commands so this\n // isn't necessary\n var EMPTY_ARRAY = []\n function reserve (count) {\n while (EMPTY_ARRAY.length < count) {\n EMPTY_ARRAY.push(null)\n }\n return EMPTY_ARRAY\n }\n\n function REGLCommand (args, body) {\n var i\n if (contextLost) {\n check$1.raise('context lost')\n }\n if (typeof args === 'function') {\n return scope.call(this, null, args, 0)\n } else if (typeof body === 'function') {\n if (typeof args === 'number') {\n for (i = 0; i < args; ++i) {\n scope.call(this, null, body, i)\n }\n } else if (Array.isArray(args)) {\n for (i = 0; i < args.length; ++i) {\n scope.call(this, args[i], body, i)\n }\n } else {\n return scope.call(this, args, body, 0)\n }\n } else if (typeof args === 'number') {\n if (args > 0) {\n return batch.call(this, reserve(args | 0), args | 0)\n }\n } else if (Array.isArray(args)) {\n if (args.length) {\n return batch.call(this, args, args.length)\n }\n } else {\n return draw.call(this, args)\n }\n }\n\n return extend(REGLCommand, {\n stats: stats$$1,\n destroy: function () {\n compiled.destroy()\n }\n })\n }\n\n var setFBO = framebufferState.setFBO = compileProcedure({\n framebuffer: dynamic.define.call(null, DYN_PROP, 'framebuffer')\n })\n\n function clearImpl (_, options) {\n var clearFlags = 0\n core.procs.poll()\n\n var c = options.color\n if (c) {\n gl.clearColor(+c[0] || 0, +c[1] || 0, +c[2] || 0, +c[3] || 0)\n clearFlags |= GL_COLOR_BUFFER_BIT\n }\n if ('depth' in options) {\n gl.clearDepth(+options.depth)\n clearFlags |= GL_DEPTH_BUFFER_BIT\n }\n if ('stencil' in options) {\n gl.clearStencil(options.stencil | 0)\n clearFlags |= GL_STENCIL_BUFFER_BIT\n }\n\n check$1(!!clearFlags, 'called regl.clear with no buffer specified')\n gl.clear(clearFlags)\n }\n\n function clear (options) {\n check$1(\n typeof options === 'object' && options,\n 'regl.clear() takes an object as input')\n if ('framebuffer' in options) {\n if (options.framebuffer &&\n options.framebuffer_reglType === 'framebufferCube') {\n for (var i = 0; i < 6; ++i) {\n setFBO(extend({\n framebuffer: options.framebuffer.faces[i]\n }, options), clearImpl)\n }\n } else {\n setFBO(options, clearImpl)\n }\n } else {\n clearImpl(null, options)\n }\n }\n\n function frame (cb) {\n check$1.type(cb, 'function', 'regl.frame() callback must be a function')\n rafCallbacks.push(cb)\n\n function cancel () {\n // FIXME: should we check something other than equals cb here?\n // what if a user calls frame twice with the same callback...\n //\n var i = find(rafCallbacks, cb)\n check$1(i >= 0, 'cannot cancel a frame twice')\n function pendingCancel () {\n var index = find(rafCallbacks, pendingCancel)\n rafCallbacks[index] = rafCallbacks[rafCallbacks.length - 1]\n rafCallbacks.length -= 1\n if (rafCallbacks.length <= 0) {\n stopRAF()\n }\n }\n rafCallbacks[i] = pendingCancel\n }\n\n startRAF()\n\n return {\n cancel: cancel\n }\n }\n\n // poll viewport\n function pollViewport () {\n var viewport = nextState.viewport\n var scissorBox = nextState.scissor_box\n viewport[0] = viewport[1] = scissorBox[0] = scissorBox[1] = 0\n contextState.viewportWidth =\n contextState.framebufferWidth =\n contextState.drawingBufferWidth =\n viewport[2] =\n scissorBox[2] = gl.drawingBufferWidth\n contextState.viewportHeight =\n contextState.framebufferHeight =\n contextState.drawingBufferHeight =\n viewport[3] =\n scissorBox[3] = gl.drawingBufferHeight\n }\n\n function poll () {\n contextState.tick += 1\n contextState.time = now()\n pollViewport()\n core.procs.poll()\n }\n\n function refresh () {\n textureState.refresh()\n pollViewport()\n core.procs.refresh()\n if (timer) {\n timer.update()\n }\n }\n\n function now () {\n return (clock() - START_TIME) / 1000.0\n }\n\n refresh()\n\n function addListener (event, callback) {\n check$1.type(callback, 'function', 'listener callback must be a function')\n\n var callbacks\n switch (event) {\n case 'frame':\n return frame(callback)\n case 'lost':\n callbacks = lossCallbacks\n break\n case 'restore':\n callbacks = restoreCallbacks\n break\n case 'destroy':\n callbacks = destroyCallbacks\n break\n default:\n check$1.raise('invalid event, must be one of frame,lost,restore,destroy')\n }\n\n callbacks.push(callback)\n return {\n cancel: function () {\n for (var i = 0; i < callbacks.length; ++i) {\n if (callbacks[i] === callback) {\n callbacks[i] = callbacks[callbacks.length - 1]\n callbacks.pop()\n return\n }\n }\n }\n }\n }\n\n var regl = extend(compileProcedure, {\n // Clear current FBO\n clear: clear,\n\n // Short cuts for dynamic variables\n prop: dynamic.define.bind(null, DYN_PROP),\n context: dynamic.define.bind(null, DYN_CONTEXT),\n this: dynamic.define.bind(null, DYN_STATE),\n\n // executes an empty draw command\n draw: compileProcedure({}),\n\n // Resources\n buffer: function (options) {\n return bufferState.create(options, GL_ARRAY_BUFFER, false, false)\n },\n elements: function (options) {\n return elementState.create(options, false)\n },\n texture: textureState.create2D,\n cube: textureState.createCube,\n renderbuffer: renderbufferState.create,\n framebuffer: framebufferState.create,\n framebufferCube: framebufferState.createCube,\n vao: attributeState.createVAO,\n\n // Expose context attributes\n attributes: glAttributes,\n\n // Frame rendering\n frame: frame,\n on: addListener,\n\n // System limits\n limits: limits,\n hasExtension: function (name) {\n return limits.extensions.indexOf(name.toLowerCase()) >= 0\n },\n\n // Read pixels\n read: readPixels,\n\n // Destroy regl and all associated resources\n destroy: destroy,\n\n // Direct GL state manipulation\n _gl: gl,\n _refresh: refresh,\n\n poll: function () {\n poll()\n if (timer) {\n timer.update()\n }\n },\n\n // Current time\n now: now,\n\n // regl Statistics Information\n stats: stats$$1\n })\n\n config.onDone(null, regl)\n\n return regl\n}\n\nreturn wrapREGL;\n\n})));\n//# sourceMappingURL=regl.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/regl/dist/regl.js\n// module id = 40\n// module chunks = 0","'use strict';\n\nvar isArrayish = require('is-arrayish');\n\nvar concat = Array.prototype.concat;\nvar slice = Array.prototype.slice;\n\nvar swizzle = module.exports = function swizzle(args) {\n\tvar results = [];\n\n\tfor (var i = 0, len = args.length; i < len; i++) {\n\t\tvar arg = args[i];\n\n\t\tif (isArrayish(arg)) {\n\t\t\t// http://jsperf.com/javascript-array-concat-vs-push/98\n\t\t\tresults = concat.call(results, slice.call(arg));\n\t\t} else {\n\t\t\tresults.push(arg);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nswizzle.wrap = function (fn) {\n\treturn function () {\n\t\treturn fn(swizzle(arguments));\n\t};\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/simple-swizzle/index.js\n// module id = 41\n// module chunks = 0","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 42\n// module chunks = 0","module.exports = function(module) {\r\n\tif(!module.webpackPolyfill) {\r\n\t\tmodule.deprecate = function() {};\r\n\t\tmodule.paths = [];\r\n\t\t// module.parent = undefined by default\r\n\t\tif(!module.children) module.children = [];\r\n\t\tObject.defineProperty(module, \"loaded\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.l;\r\n\t\t\t}\r\n\t\t});\r\n\t\tObject.defineProperty(module, \"id\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.i;\r\n\t\t\t}\r\n\t\t});\r\n\t\tmodule.webpackPolyfill = 1;\r\n\t}\r\n\treturn module;\r\n};\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/module.js\n// module id = 43\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/dlgr/griduniverse/static/scripts/dist/difi.js b/dlgr/griduniverse/static/scripts/dist/difi.js index ff730bf2..79625e38 100644 --- a/dlgr/griduniverse/static/scripts/dist/difi.js +++ b/dlgr/griduniverse/static/scripts/dist/difi.js @@ -33,6 +33,9 @@ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { @@ -60,7 +63,7 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 39); +/******/ return __webpack_require__(__webpack_require__.s = 17); /******/ }) /************************************************************************/ /******/ ({ @@ -1028,7 +1031,7 @@ module.exports = function (css) { /***/ }), -/***/ 39: +/***/ 17: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; diff --git a/dlgr/griduniverse/static/scripts/dist/difi.js.map b/dlgr/griduniverse/static/scripts/dist/difi.js.map index 81d44097..55a12e26 100644 --- a/dlgr/griduniverse/static/scripts/dist/difi.js.map +++ b/dlgr/griduniverse/static/scripts/dist/difi.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap b297e754b215368f0363","webpack:///./node_modules/identityfusion/dist/identityfusion.js","webpack:///./dlgr/griduniverse/static/scripts/difi.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;AC7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,cAAc;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,0BAA0B,EAAE;AAC/D,yCAAyC,eAAe;AACxD;AACA;AACA;AACA;AACA;AACA,8DAA8D,+DAA+D;AAC7H;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,gCAAgC,UAAU,EAAE;AAC5C;;AAEA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,QAAQ;AACpB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA,0DAA0D,cAAc;AACxE;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oCAAoC,KAAK;AACzC;;AAEA;AACA,2CAA2C,KAAK;AAChD;AACA;;AAEA;AACA;AACA;AACA;AACA,uCAAuC,mCAAmC;AAC1E;AACA,sCAAsC,6BAA6B;AACnE;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,wBAAwB;AACxE;;AAEA;AACA,gCAAgC,OAAO;AACvC,gCAAgC;AAChC,gCAAgC;AAChC,gCAAgC,OAAO;;AAEvC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,wCAAwC;AACpE;AACA;AACA;AACA;;;;AAIA,OAAO;AACP;AACA;;AAEA;AACA;;;AAGA;AACA,gCAAgC,6BAA6B,kBAAkB,wBAAwB,uBAAuB,yBAAyB,GAAG,oBAAoB,iBAAiB,yBAAyB,yBAAyB,gBAAgB,GAAG,2BAA2B,wBAAwB,wBAAwB,GAAG,iBAAiB,yBAAyB,gBAAgB,iBAAiB,eAAe,uBAAuB,kCAAkC,GAAG,cAAc,gDAAgD,6BAA6B,yBAAyB,mBAAmB,mBAAmB,2BAA2B,uBAAuB,yBAAyB,cAAc,aAAa,iBAAiB,wBAAwB,GAAG,uBAAuB,mBAAmB,uBAAuB,+BAA+B,GAAG,oBAAoB,mBAAmB,mBAAmB,2BAA2B,yBAAyB,gBAAgB,eAAe,uCAAuC,GAAG,iBAAiB,6BAA6B,mCAAmC,6BAA6B,yBAAyB,gBAAgB,uBAAuB,yBAAyB,eAAe,uCAAuC,iBAAiB,GAAG,uBAAuB,yBAAyB,gBAAgB,aAAa,wCAAwC,0BAA0B,GAAG;;AAEj9C;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gBAAgB;AACnD,IAAI;AACJ;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA,YAAY,oBAAoB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,oDAAoD,cAAc;;AAElE;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA,CAAC;;AAED;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,iBAAiB,mBAAmB;AACpC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,iBAAiB,sBAAsB;AACvC;;AAEA;AACA,mBAAmB,2BAA2B;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,mBAAmB;AACnC;AACA;;AAEA;AACA;;AAEA,iBAAiB,2BAA2B;AAC5C;AACA;;AAEA,QAAQ,uBAAuB;AAC/B;AACA;AACA,GAAG;AACH;;AAEA,iBAAiB,uBAAuB;AACxC;AACA;;AAEA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA;AACA,cAAc;;AAEd,kDAAkD,sBAAsB;AACxE;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD;AACvD;;AAEA,6BAA6B,mBAAmB;;AAEhD;;AAEA;;AAEA;AACA;;;AAGA,OAAO;AACP;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,WAAW,EAAE;AACrD,wCAAwC,WAAW,EAAE;;AAErD;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,sCAAsC;AACtC,GAAG;AACH;AACA,8DAA8D;AAC9D;;AAEA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;;AAGA,OAAO;AACP;AACA,CAAC;AACD,0C;;;;;;;;;AC57BA;AAAA;AAAA;AACA;;AAEoB;;AAEpB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC","file":"scripts/dist/difi.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 39);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap b297e754b215368f0363","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"identityfusion\"] = factory();\n\telse\n\t\troot[\"identityfusion\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n// style-loader: Adds some css to the DOM by adding a <style> tag\n\n// load the styles\nvar content = __webpack_require__(3);\nif(typeof content === 'string') content = [[module.i, content, '']];\n// Prepare cssTransformation\nvar transform;\n\nvar options = {}\noptions.transform = transform\n// add the styles to the DOM\nvar update = __webpack_require__(5)(content, options);\nif(content.locals) module.exports = content.locals;\n// Hot Module Replacement\nif(false) {\n\t// When the styles change, update the <style> tags\n\tif(!content.locals) {\n\t\tmodule.hot.accept(\"!!./node_modules/css-loader/index.js!./styles.css\", function() {\n\t\t\tvar newContent = require(\"!!./node_modules/css-loader/index.js!./styles.css\");\n\t\t\tif(typeof newContent === 'string') newContent = [[module.id, newContent, '']];\n\t\t\tupdate(newContent);\n\t\t});\n\t}\n\t// When the module is disposed, remove the <style> tags\n\tmodule.hot.dispose(function() { update(); });\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the\n * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time\n * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,\n * the internal counter is reset)\n * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the throttled-function is executed.\n * @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),\n * schedule `callback` to execute after `delay` ms.\n *\n * @return {Function} A new, throttled, function.\n */\nmodule.exports = function ( delay, noTrailing, callback, debounceMode ) {\n\n\t// After wrapper has stopped being called, this timeout ensures that\n\t// `callback` is executed at the proper times in `throttle` and `end`\n\t// debounce modes.\n\tvar timeoutID;\n\n\t// Keep track of the last time `callback` was executed.\n\tvar lastExec = 0;\n\n\t// `noTrailing` defaults to falsy.\n\tif ( typeof noTrailing !== 'boolean' ) {\n\t\tdebounceMode = callback;\n\t\tcallback = noTrailing;\n\t\tnoTrailing = undefined;\n\t}\n\n\t// The `wrapper` function encapsulates all of the throttling / debouncing\n\t// functionality and when executed will limit the rate at which `callback`\n\t// is executed.\n\tfunction wrapper () {\n\n\t\tvar self = this;\n\t\tvar elapsed = Number(new Date()) - lastExec;\n\t\tvar args = arguments;\n\n\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\tfunction exec () {\n\t\t\tlastExec = Number(new Date());\n\t\t\tcallback.apply(self, args);\n\t\t}\n\n\t\t// If `debounceMode` is true (at begin) this is used to clear the flag\n\t\t// to allow future `callback` executions.\n\t\tfunction clear () {\n\t\t\ttimeoutID = undefined;\n\t\t}\n\n\t\tif ( debounceMode && !timeoutID ) {\n\t\t\t// Since `wrapper` is being called for the first time and\n\t\t\t// `debounceMode` is true (at begin), execute `callback`.\n\t\t\texec();\n\t\t}\n\n\t\t// Clear any existing timeout.\n\t\tif ( timeoutID ) {\n\t\t\tclearTimeout(timeoutID);\n\t\t}\n\n\t\tif ( debounceMode === undefined && elapsed > delay ) {\n\t\t\t// In throttle mode, if `delay` time has been exceeded, execute\n\t\t\t// `callback`.\n\t\t\texec();\n\n\t\t} else if ( noTrailing !== true ) {\n\t\t\t// In trailing throttle mode, since `delay` time has not been\n\t\t\t// exceeded, schedule `callback` to execute `delay` ms after most\n\t\t\t// recent execution.\n\t\t\t//\n\t\t\t// If `debounceMode` is true (at begin), schedule `clear` to execute\n\t\t\t// after `delay` ms.\n\t\t\t//\n\t\t\t// If `debounceMode` is false (at end), schedule `callback` to\n\t\t\t// execute after `delay` ms.\n\t\t\ttimeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n\t\t}\n\n\t}\n\n\t// Return the wrapper function.\n\treturn wrapper;\n\n};\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__styles_css__);\n\n\n\nfunction addButton(container, label, onclick) {\n // Add a button to a container.\n const button = document.createElement('button');\n button.setAttribute('type', 'button');\n button.className = 'button button-outline';\n button.innerHTML = label;\n button.addEventListener('click', onclick);\n container.appendChild(button);\n return button;\n}\n\nfunction calculateOverlap(d, r, R) {\n // Calculate the DIFI overlap.\n // d is the center-to-center spacing between the small and big circles.\n // r is the radius of the small circle.\n // R is the radius of the large circle.\n const x = ((d * d) + (r * r) - (R * R)) / (2 * d * r);\n const y = ((d * d) + (R * R) - (r * r)) / (2 * d * R);\n const z = (-d + r + R) * (d + r - R) * (d - r + R) * (d + r + R);\n const overlapArea = (r * r * Math.acos(x)) + (R * R * Math.acos(y)) - (Math.sqrt(z) / 2);\n if (d > r + R) {\n return 0;\n } else if (d < R - r) {\n return 100;\n }\n return 100 * (overlapArea / (Math.PI * r * r));\n}\n\nfunction outerLeft(el) {\n // Find the left offset of an element (including border)\n // relative to the page\n const rect = el.getBoundingClientRect();\n const left = rect.left + document.body.scrollLeft;\n return left - parseFloat(getComputedStyle(el)['border-left-width'], 10);\n}\n\nfunction outerRight(el) {\n // Find the right offset of an element (including border)\n // relative to the page\n return outerLeft(el) + el.offsetWidth;\n}\n\nclass DIFIInput {\n\n constructor(el, options = {}) {\n this.drag = __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default()(20, this.drag.bind(this));\n this.startDrag = this.startDrag.bind(this);\n this.endDrag = this.endDrag.bind(this);\n\n this.el = el;\n this.options = options;\n this.initializeDOM();\n this.update();\n }\n\n initializeDOM() {\n // Construct the widget.\n const name = this.el.getAttribute('name');\n this.el.setAttribute('name', `${name}_distance`);\n this.el.setAttribute('type', 'hidden');\n\n this.elOverlap = document.createElement('input');\n this.elOverlap.setAttribute('name', `${name}_overlap`);\n this.elOverlap.setAttribute('type', 'hidden');\n this.el.insertAdjacentElement('afterend', this.elOverlap);\n\n const elContent = document.createElement('div');\n elContent.className = 'DIFI';\n elContent.innerHTML = `\n <div class=\"DIFI-controls\"></div>\n <div class=\"DIFI-group\"><label>${this.options.groupLabel || 'Group'}</label></div>\n <div class=\"DIFI-range\">\n <div class=\"DIFI-me\"><label>${this.options.meLabel || 'Me'}</label></div>\n </div>\n `;\n this.me = elContent.querySelector('.DIFI-me');\n this.group = elContent.querySelector('.DIFI-group');\n this.elRange = elContent.querySelector('.DIFI-range');\n\n if (this.options.groupImage) {\n this.group.style.backgroundImage = `url(${this.options.groupImage})`;\n }\n\n const controls = elContent.querySelector('.DIFI-controls');\n addButton(controls, '◀◀', this.nudge.bind(this, -0.5));\n addButton(controls, '◀', this.nudge.bind(this, -0.1));\n addButton(controls, '▶', this.nudge.bind(this, 0.1));\n addButton(controls, '▶▶', this.nudge.bind(this, 0.5));\n\n this.el.insertAdjacentElement('beforebegin', elContent);\n\n this.me.addEventListener('mousedown', this.startDrag.bind(this));\n }\n\n startDrag(e) {\n // Start tracking mouse when clicked.\n e.preventDefault();\n e.stopPropagation();\n this.me.className = 'DIFI-me dragging';\n\n this.dragOrigLeft = parseFloat(getComputedStyle(this.me).left, 10);\n this.dragOrigX = e.pageX;\n document.addEventListener('mousemove', this.drag);\n document.addEventListener('mouseup', this.endDrag);\n }\n\n drag(e) {\n // Update position of Me while dragging.\n e.preventDefault();\n e.stopPropagation();\n if (this.dragOrigX === null) {\n return;\n }\n const deltaPixels = e.pageX - this.dragOrigX;\n this.nudgePixels(deltaPixels, this.dragOrigLeft);\n }\n\n endDrag() {\n // Stop tracking mouse when mouse released.\n this.me.className = 'DIFI-me';\n document.removeEventListener('mousemove', this.drag);\n document.removeEventListener('mouseup', this.endDrag);\n this.dragOrigX = null;\n this.dragOrigLeft = null;\n }\n\n update() {\n // Update distance and overlap values from current position.\n // Distance is based on difference in position:\n // - left circle separated from right circle: -100 to 0\n // - left circle just touching right circle: 0\n // - left circle overlapping right circle: 0 to 100\n // - left circle contained within right circle: 100 to 125\n // - left circle at the center of right circle: 125\n const R = this.group.offsetWidth / 2;\n const r = this.me.offsetWidth / 2;\n const mePos = outerLeft(this.me);\n const groupPos = outerLeft(this.group);\n const d = mePos - groupPos;\n let value = 100 + 50 * d / r;\n // Snap to center\n const elRange = this.me.parentNode;\n if (outerRight(elRange) - outerRight(this.me) < 2) {\n value = 125;\n }\n // Clip value to desired range (-100 to 125)\n value = Math.max(Math.min(Math.round(value * 1000) / 1000, 125), -100);\n this.el.setAttribute('value', value);\n\n // Compute overlap.\n const dCenterToCenter = (groupPos + R) - (mePos + r);\n const overlap = calculateOverlap(dCenterToCenter, r, R);\n this.elOverlap.setAttribute('value', overlap);\n }\n\n nudge(delta) {\n // Move by `delta` units (1 unit = radius of Me circle)\n const unit = this.me.offsetWidth / 2;\n const deltaPixels = delta * unit;\n this.nudgePixels(deltaPixels);\n }\n\n nudgePixels(delta, origLeft) {\n // Move by `delta` pixels\n // (relative to origLeft if specified, or to current position)\n let start = origLeft;\n if (start === undefined) {\n start = parseFloat(getComputedStyle(this.me).left, 10);\n }\n let finish = start + delta;\n if (finish < 0) {\n finish = 0;\n }\n if (finish > this.elRange.offsetWidth - this.me.offsetWidth) {\n finish = this.elRange.offsetWidth - this.me.offsetWidth;\n }\n this.me.style.left = `${finish / this.elRange.offsetWidth * 100}%`;\n this.update();\n }\n}\n/* harmony export (immutable) */ __webpack_exports__[\"DIFIInput\"] = DIFIInput;\n\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\nexports = module.exports = __webpack_require__(4)(undefined);\n// imports\n\n\n// module\nexports.push([module.i, \".DIFI {\\n border: solid 1px #ccc;\\n width: 100%;\\n margin: 10px auto;\\n padding-top: 40%;\\n position: relative;\\n}\\n\\n.DIFI-controls {\\n left: 10px;\\n position: absolute;\\n text-align: center;\\n top: 10px;\\n}\\n\\n.DIFI-controls button {\\n margin-right: 5px;\\n padding: 0 1.5rem;\\n}\\n\\n.DIFI-range {\\n position: absolute;\\n left: 10%;\\n right: 10%;\\n top: 55%;\\n padding-top: 20%;\\n transform: translateY(-50%);\\n}\\n\\n.DIFI-me {\\n background-color: rgba(255, 255, 255, .8);\\n border: solid 1px #000;\\n border-radius: 50%;\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n padding-top: 25%;\\n position: absolute;\\n left: 0;\\n top: 0;\\n width: 25%;\\n user-select: none;\\n}\\n\\n.DIFI-me.dragging {\\n cursor: move;\\n cursor: grabbing;\\n cursor: -webkit-grabbing;\\n}\\n\\n.DIFI-me label {\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n position: absolute;\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.DIFI-group {\\n background-color: #ccc;\\n background-position: 50% 50%;\\n background-size: cover;\\n border-radius: 50%;\\n left: 80%;\\n padding-top: 30%;\\n position: absolute;\\n top: 55%;\\n transform: translate(-50%, -50%);\\n width: 30%;\\n}\\n\\n.DIFI-group label {\\n position: absolute;\\n left: 50%;\\n top: 0;\\n transform: translate(-50%, -100%);\\n white-space: nowrap;\\n}\\n\", \"\"]);\n\n// exports\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\nmodule.exports = function(useSourceMap) {\n\tvar list = [];\n\n\t// return the list of modules as css string\n\tlist.toString = function toString() {\n\t\treturn this.map(function (item) {\n\t\t\tvar content = cssWithMappingToString(item, useSourceMap);\n\t\t\tif(item[2]) {\n\t\t\t\treturn \"@media \" + item[2] + \"{\" + content + \"}\";\n\t\t\t} else {\n\t\t\t\treturn content;\n\t\t\t}\n\t\t}).join(\"\");\n\t};\n\n\t// import a list of modules into the list\n\tlist.i = function(modules, mediaQuery) {\n\t\tif(typeof modules === \"string\")\n\t\t\tmodules = [[null, modules, \"\"]];\n\t\tvar alreadyImportedModules = {};\n\t\tfor(var i = 0; i < this.length; i++) {\n\t\t\tvar id = this[i][0];\n\t\t\tif(typeof id === \"number\")\n\t\t\t\talreadyImportedModules[id] = true;\n\t\t}\n\t\tfor(i = 0; i < modules.length; i++) {\n\t\t\tvar item = modules[i];\n\t\t\t// skip already imported module\n\t\t\t// this implementation is not 100% perfect for weird media query combinations\n\t\t\t// when a module is imported multiple times with different media queries.\n\t\t\t// I hope this will never occur (Hey this way we have smaller bundles)\n\t\t\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]) {\n\t\t\t\tif(mediaQuery && !item[2]) {\n\t\t\t\t\titem[2] = mediaQuery;\n\t\t\t\t} else if(mediaQuery) {\n\t\t\t\t\titem[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";\n\t\t\t\t}\n\t\t\t\tlist.push(item);\n\t\t\t}\n\t\t}\n\t};\n\treturn list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n\tvar content = item[1] || '';\n\tvar cssMapping = item[3];\n\tif (!cssMapping) {\n\t\treturn content;\n\t}\n\n\tif (useSourceMap && typeof btoa === 'function') {\n\t\tvar sourceMapping = toComment(cssMapping);\n\t\tvar sourceURLs = cssMapping.sources.map(function (source) {\n\t\t\treturn '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'\n\t\t});\n\n\t\treturn [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n\t}\n\n\treturn [content].join('\\n');\n}\n\n// Adapted from convert-source-map (MIT)\nfunction toComment(sourceMap) {\n\t// eslint-disable-next-line no-undef\n\tvar base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n\tvar data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;\n\n\treturn '/*# ' + data + ' */';\n}\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === \"undefined\") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(selector) {\n\t\tif (typeof memo[selector] === \"undefined\") {\n\t\t\tmemo[selector] = fn.call(this, selector);\n\t\t}\n\n\t\treturn memo[selector]\n\t};\n})(function (target) {\n\treturn document.querySelector(target)\n});\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = __webpack_require__(6);\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== \"undefined\" && DEBUG) {\n\t\tif (typeof document !== \"object\") throw new Error(\"The style-loader cannot be used in a non-browser environment\");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === \"object\" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>\n\t// tags it will allow on a page\n\tif (!options.singleton) options.singleton = isOldIE();\n\n\t// By default, add <style> tags to the <head> element\n\tif (!options.insertInto) options.insertInto = \"head\";\n\n\t// By default, add <style> tags to the bottom of the target\n\tif (!options.insertAt) options.insertAt = \"bottom\";\n\n\tvar styles = listToStyles(list, options);\n\n\taddStylesToDom(styles, options);\n\n\treturn function update (newList) {\n\t\tvar mayRemove = [];\n\n\t\tfor (var i = 0; i < styles.length; i++) {\n\t\t\tvar item = styles[i];\n\t\t\tvar domStyle = stylesInDom[item.id];\n\n\t\t\tdomStyle.refs--;\n\t\t\tmayRemove.push(domStyle);\n\t\t}\n\n\t\tif(newList) {\n\t\t\tvar newStyles = listToStyles(newList, options);\n\t\t\taddStylesToDom(newStyles, options);\n\t\t}\n\n\t\tfor (var i = 0; i < mayRemove.length; i++) {\n\t\t\tvar domStyle = mayRemove[i];\n\n\t\t\tif(domStyle.refs === 0) {\n\t\t\t\tfor (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();\n\n\t\t\t\tdelete stylesInDom[domStyle.id];\n\t\t\t}\n\t\t}\n\t};\n};\n\nfunction addStylesToDom (styles, options) {\n\tfor (var i = 0; i < styles.length; i++) {\n\t\tvar item = styles[i];\n\t\tvar domStyle = stylesInDom[item.id];\n\n\t\tif(domStyle) {\n\t\t\tdomStyle.refs++;\n\n\t\t\tfor(var j = 0; j < domStyle.parts.length; j++) {\n\t\t\t\tdomStyle.parts[j](item.parts[j]);\n\t\t\t}\n\n\t\t\tfor(; j < item.parts.length; j++) {\n\t\t\t\tdomStyle.parts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\t\t} else {\n\t\t\tvar parts = [];\n\n\t\t\tfor(var j = 0; j < item.parts.length; j++) {\n\t\t\t\tparts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\n\t\t\tstylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};\n\t\t}\n\t}\n}\n\nfunction listToStyles (list, options) {\n\tvar styles = [];\n\tvar newStyles = {};\n\n\tfor (var i = 0; i < list.length; i++) {\n\t\tvar item = list[i];\n\t\tvar id = options.base ? item[0] + options.base : item[0];\n\t\tvar css = item[1];\n\t\tvar media = item[2];\n\t\tvar sourceMap = item[3];\n\t\tvar part = {css: css, media: media, sourceMap: sourceMap};\n\n\t\tif(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});\n\t\telse newStyles[id].parts.push(part);\n\t}\n\n\treturn styles;\n}\n\nfunction insertStyleElement (options, style) {\n\tvar target = getElement(options.insertInto)\n\n\tif (!target) {\n\t\tthrow new Error(\"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.\");\n\t}\n\n\tvar lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];\n\n\tif (options.insertAt === \"top\") {\n\t\tif (!lastStyleElementInsertedAtTop) {\n\t\t\ttarget.insertBefore(style, target.firstChild);\n\t\t} else if (lastStyleElementInsertedAtTop.nextSibling) {\n\t\t\ttarget.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);\n\t\t} else {\n\t\t\ttarget.appendChild(style);\n\t\t}\n\t\tstylesInsertedAtTop.push(style);\n\t} else if (options.insertAt === \"bottom\") {\n\t\ttarget.appendChild(style);\n\t} else {\n\t\tthrow new Error(\"Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.\");\n\t}\n}\n\nfunction removeStyleElement (style) {\n\tstyle.parentNode.removeChild(style);\n\n\tvar idx = stylesInsertedAtTop.indexOf(style);\n\n\tif(idx >= 0) {\n\t\tstylesInsertedAtTop.splice(idx, 1);\n\t}\n}\n\nfunction createStyleElement (options) {\n\tvar style = document.createElement(\"style\");\n\n\toptions.attrs.type = \"text/css\";\n\n\taddAttrs(style, options.attrs);\n\tinsertStyleElement(options, style);\n\n\treturn style;\n}\n\nfunction createLinkElement (options) {\n\tvar link = document.createElement(\"link\");\n\n\toptions.attrs.type = \"text/css\";\n\toptions.attrs.rel = \"stylesheet\";\n\n\taddAttrs(link, options.attrs);\n\tinsertStyleElement(options, link);\n\n\treturn link;\n}\n\nfunction addAttrs (el, attrs) {\n\tObject.keys(attrs).forEach(function (key) {\n\t\tel.setAttribute(key, attrs[key]);\n\t});\n}\n\nfunction addStyle (obj, options) {\n\tvar style, update, remove, result;\n\n\t// If a transform function was defined, run it on the css\n\tif (options.transform && obj.css) {\n\t result = options.transform(obj.css);\n\n\t if (result) {\n\t \t// If transform returns a value, use that instead of the original css.\n\t \t// This allows running runtime transformations on the css.\n\t \tobj.css = result;\n\t } else {\n\t \t// If the transform function returns a falsy value, don't add this css.\n\t \t// This allows conditional loading of css\n\t \treturn function() {\n\t \t\t// noop\n\t \t};\n\t }\n\t}\n\n\tif (options.singleton) {\n\t\tvar styleIndex = singletonCounter++;\n\n\t\tstyle = singleton || (singleton = createStyleElement(options));\n\n\t\tupdate = applyToSingletonTag.bind(null, style, styleIndex, false);\n\t\tremove = applyToSingletonTag.bind(null, style, styleIndex, true);\n\n\t} else if (\n\t\tobj.sourceMap &&\n\t\ttypeof URL === \"function\" &&\n\t\ttypeof URL.createObjectURL === \"function\" &&\n\t\ttypeof URL.revokeObjectURL === \"function\" &&\n\t\ttypeof Blob === \"function\" &&\n\t\ttypeof btoa === \"function\"\n\t) {\n\t\tstyle = createLinkElement(options);\n\t\tupdate = updateLink.bind(null, style, options);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\n\t\t\tif(style.href) URL.revokeObjectURL(style.href);\n\t\t};\n\t} else {\n\t\tstyle = createStyleElement(options);\n\t\tupdate = applyToTag.bind(null, style);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\t\t};\n\t}\n\n\tupdate(obj);\n\n\treturn function updateStyle (newObj) {\n\t\tif (newObj) {\n\t\t\tif (\n\t\t\t\tnewObj.css === obj.css &&\n\t\t\t\tnewObj.media === obj.media &&\n\t\t\t\tnewObj.sourceMap === obj.sourceMap\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdate(obj = newObj);\n\t\t} else {\n\t\t\tremove();\n\t\t}\n\t};\n}\n\nvar replaceText = (function () {\n\tvar textStore = [];\n\n\treturn function (index, replacement) {\n\t\ttextStore[index] = replacement;\n\n\t\treturn textStore.filter(Boolean).join('\\n');\n\t};\n})();\n\nfunction applyToSingletonTag (style, index, remove, obj) {\n\tvar css = remove ? \"\" : obj.css;\n\n\tif (style.styleSheet) {\n\t\tstyle.styleSheet.cssText = replaceText(index, css);\n\t} else {\n\t\tvar cssNode = document.createTextNode(css);\n\t\tvar childNodes = style.childNodes;\n\n\t\tif (childNodes[index]) style.removeChild(childNodes[index]);\n\n\t\tif (childNodes.length) {\n\t\t\tstyle.insertBefore(cssNode, childNodes[index]);\n\t\t} else {\n\t\t\tstyle.appendChild(cssNode);\n\t\t}\n\t}\n}\n\nfunction applyToTag (style, obj) {\n\tvar css = obj.css;\n\tvar media = obj.media;\n\n\tif(media) {\n\t\tstyle.setAttribute(\"media\", media)\n\t}\n\n\tif(style.styleSheet) {\n\t\tstyle.styleSheet.cssText = css;\n\t} else {\n\t\twhile(style.firstChild) {\n\t\t\tstyle.removeChild(style.firstChild);\n\t\t}\n\n\t\tstyle.appendChild(document.createTextNode(css));\n\t}\n}\n\nfunction updateLink (link, options, obj) {\n\tvar css = obj.css;\n\tvar sourceMap = obj.sourceMap;\n\n\t/*\n\t\tIf convertToAbsoluteUrls isn't defined, but sourcemaps are enabled\n\t\tand there is no publicPath defined then lets turn convertToAbsoluteUrls\n\t\ton by default. Otherwise default to the convertToAbsoluteUrls option\n\t\tdirectly\n\t*/\n\tvar autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;\n\n\tif (options.convertToAbsoluteUrls || autoFixUrls) {\n\t\tcss = fixUrls(css);\n\t}\n\n\tif (sourceMap) {\n\t\t// http://stackoverflow.com/a/26603875\n\t\tcss += \"\\n/*# sourceMappingURL=data:application/json;base64,\" + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + \" */\";\n\t}\n\n\tvar blob = new Blob([css], { type: \"text/css\" });\n\n\tvar oldSrc = link.href;\n\n\tlink.href = URL.createObjectURL(blob);\n\n\tif(oldSrc) URL.revokeObjectURL(oldSrc);\n}\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\n/**\n * When source maps are enabled, `style-loader` uses a link element with a data-uri to\n * embed the css on the page. This breaks all relative urls because now they are relative to a\n * bundle instead of the current page.\n *\n * One solution is to only use full urls, but that may be impossible.\n *\n * Instead, this function \"fixes\" the relative urls to be absolute according to the current page location.\n *\n * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.\n *\n */\n\nmodule.exports = function (css) {\n // get current location\n var location = typeof window !== \"undefined\" && window.location;\n\n if (!location) {\n throw new Error(\"fixUrls requires window.location\");\n }\n\n\t// blank or null?\n\tif (!css || typeof css !== \"string\") {\n\t return css;\n }\n\n var baseUrl = location.protocol + \"//\" + location.host;\n var currentDir = baseUrl + location.pathname.replace(/\\/[^\\/]*$/, \"/\");\n\n\t// convert each url(...)\n\t/*\n\tThis regular expression is just a way to recursively match brackets within\n\ta string.\n\n\t /url\\s*\\( = Match on the word \"url\" with any whitespace after it and then a parens\n\t ( = Start a capturing group\n\t (?: = Start a non-capturing group\n\t [^)(] = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t (?: = Start another non-capturing groups\n\t [^)(]+ = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t [^)(]* = Match anything that isn't a parentheses\n\t \\) = Match a end parentheses\n\t ) = End Group\n *\\) = Match anything and then a close parens\n ) = Close non-capturing group\n * = Match anything\n ) = Close capturing group\n\t \\) = Match a close parens\n\n\t /gi = Get all matches, not the first. Be case insensitive.\n\t */\n\tvar fixedCss = css.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi, function(fullMatch, origUrl) {\n\t\t// strip quotes (if they exist)\n\t\tvar unquotedOrigUrl = origUrl\n\t\t\t.trim()\n\t\t\t.replace(/^\"(.*)\"$/, function(o, $1){ return $1; })\n\t\t\t.replace(/^'(.*)'$/, function(o, $1){ return $1; });\n\n\t\t// already a full url? no change\n\t\tif (/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/)/i.test(unquotedOrigUrl)) {\n\t\t return fullMatch;\n\t\t}\n\n\t\t// convert the url to a full url\n\t\tvar newUrl;\n\n\t\tif (unquotedOrigUrl.indexOf(\"//\") === 0) {\n\t\t \t//TODO: should we add protocol?\n\t\t\tnewUrl = unquotedOrigUrl;\n\t\t} else if (unquotedOrigUrl.indexOf(\"/\") === 0) {\n\t\t\t// path should be relative to the base url\n\t\t\tnewUrl = baseUrl + unquotedOrigUrl; // already starts with '/'\n\t\t} else {\n\t\t\t// path should be relative to current directory\n\t\t\tnewUrl = currentDir + unquotedOrigUrl.replace(/^\\.\\//, \"\"); // Strip leading './'\n\t\t}\n\n\t\t// send back the fixed url(...)\n\t\treturn \"url(\" + JSON.stringify(newUrl) + \")\";\n\t});\n\n\t// send back the fixed css\n\treturn fixedCss;\n};\n\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=identityfusion.js.map\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/identityfusion/dist/identityfusion.js\n// module id = 0\n// module chunks = 1 2","/* global dallinger, console */\n/*jshint esversion: 6 */\n\nimport { DIFIInput } from 'identityfusion';\n\n$(document).ready(function() {\n\n // Initialize DIFI widget\n var $DIFI = $('input.DIFI-input'),\n spinner = dallinger.BusyForm();\n\n if ($DIFI.length) {\n var input = new DIFIInput(\n $DIFI.get(0),\n {\n groupLabel: $DIFI.attr('data-group-label'),\n groupImage: $DIFI.attr('data-group-image')\n }\n );\n }\n\n});\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/difi.js\n// module id = 39\n// module chunks = 2"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 387feb8eadb9c5b23992?8f97*","webpack:///./~/identityfusion/dist/identityfusion.js?04c9","webpack:///./dlgr/griduniverse/static/scripts/difi.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA,2CAA2C,cAAc;;QAEzD;QACA;QACA;QACA;QACA;QACA;QACA;QACA,KAAK;QACL;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA;;;;;;;;AChEA;AACA,IAAI,IAAyD;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,cAAc;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,0BAA0B,EAAE;AAC/D,yCAAyC,eAAe;AACxD;AACA;AACA;AACA;AACA;AACA,8DAA8D,+DAA+D;AAC7H;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,gCAAgC,UAAU,EAAE;AAC5C;;AAEA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,QAAQ;AACpB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA,0DAA0D,cAAc;AACxE;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oCAAoC,KAAK;AACzC;;AAEA;AACA,2CAA2C,KAAK;AAChD;AACA;;AAEA;AACA;AACA;AACA;AACA,uCAAuC,mCAAmC;AAC1E;AACA,sCAAsC,6BAA6B;AACnE;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,wBAAwB;AACxE;;AAEA;AACA,gCAAgC,OAAO;AACvC,gCAAgC;AAChC,gCAAgC;AAChC,gCAAgC,OAAO;;AAEvC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,wCAAwC;AACpE;AACA;AACA;AACA;;;;AAIA,OAAO;AACP;AACA;;AAEA;AACA;;;AAGA;AACA,gCAAgC,6BAA6B,kBAAkB,wBAAwB,uBAAuB,yBAAyB,GAAG,oBAAoB,iBAAiB,yBAAyB,yBAAyB,gBAAgB,GAAG,2BAA2B,wBAAwB,wBAAwB,GAAG,iBAAiB,yBAAyB,gBAAgB,iBAAiB,eAAe,uBAAuB,kCAAkC,GAAG,cAAc,gDAAgD,6BAA6B,yBAAyB,mBAAmB,mBAAmB,2BAA2B,uBAAuB,yBAAyB,cAAc,aAAa,iBAAiB,wBAAwB,GAAG,uBAAuB,mBAAmB,uBAAuB,+BAA+B,GAAG,oBAAoB,mBAAmB,mBAAmB,2BAA2B,yBAAyB,gBAAgB,eAAe,uCAAuC,GAAG,iBAAiB,6BAA6B,mCAAmC,6BAA6B,yBAAyB,gBAAgB,uBAAuB,yBAAyB,eAAe,uCAAuC,iBAAiB,GAAG,uBAAuB,yBAAyB,gBAAgB,aAAa,wCAAwC,0BAA0B,GAAG;;AAEj9C;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gBAAgB;AACnD,IAAI;AACJ;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA,YAAY,oBAAoB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,oDAAoD,cAAc;;AAElE;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA,CAAC;;AAED;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,iBAAiB,mBAAmB;AACpC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,iBAAiB,sBAAsB;AACvC;;AAEA;AACA,mBAAmB,2BAA2B;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,mBAAmB;AACnC;AACA;;AAEA;AACA;;AAEA,iBAAiB,2BAA2B;AAC5C;AACA;;AAEA,QAAQ,uBAAuB;AAC/B;AACA;AACA,GAAG;AACH;;AAEA,iBAAiB,uBAAuB;AACxC;AACA;;AAEA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA;AACA,cAAc;;AAEd,kDAAkD,sBAAsB;AACxE;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD;AACvD;;AAEA,6BAA6B,mBAAmB;;AAEhD;;AAEA;;AAEA;AACA;;;AAGA,OAAO;AACP;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,WAAW,EAAE;AACrD,wCAAwC,WAAW,EAAE;;AAErD;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,sCAAsC;AACtC,GAAG;AACH;AACA,8DAA8D;AAC9D;;AAEA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;;AAGA,OAAO;AACP;AACA,CAAC;AACD,0C;;;;;;;;AC57BA;AAAA;AAAA;AAAA;AACA;;AAE2C;;AAE3C;;AAEA;AACA;AACA;;AAEA;AACA,oBAAoB,yDAAS;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC","file":"scripts/dist/difi.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 17);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 387feb8eadb9c5b23992","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"identityfusion\"] = factory();\n\telse\n\t\troot[\"identityfusion\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n// style-loader: Adds some css to the DOM by adding a <style> tag\n\n// load the styles\nvar content = __webpack_require__(3);\nif(typeof content === 'string') content = [[module.i, content, '']];\n// Prepare cssTransformation\nvar transform;\n\nvar options = {}\noptions.transform = transform\n// add the styles to the DOM\nvar update = __webpack_require__(5)(content, options);\nif(content.locals) module.exports = content.locals;\n// Hot Module Replacement\nif(false) {\n\t// When the styles change, update the <style> tags\n\tif(!content.locals) {\n\t\tmodule.hot.accept(\"!!./node_modules/css-loader/index.js!./styles.css\", function() {\n\t\t\tvar newContent = require(\"!!./node_modules/css-loader/index.js!./styles.css\");\n\t\t\tif(typeof newContent === 'string') newContent = [[module.id, newContent, '']];\n\t\t\tupdate(newContent);\n\t\t});\n\t}\n\t// When the module is disposed, remove the <style> tags\n\tmodule.hot.dispose(function() { update(); });\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the\n * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time\n * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,\n * the internal counter is reset)\n * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the throttled-function is executed.\n * @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),\n * schedule `callback` to execute after `delay` ms.\n *\n * @return {Function} A new, throttled, function.\n */\nmodule.exports = function ( delay, noTrailing, callback, debounceMode ) {\n\n\t// After wrapper has stopped being called, this timeout ensures that\n\t// `callback` is executed at the proper times in `throttle` and `end`\n\t// debounce modes.\n\tvar timeoutID;\n\n\t// Keep track of the last time `callback` was executed.\n\tvar lastExec = 0;\n\n\t// `noTrailing` defaults to falsy.\n\tif ( typeof noTrailing !== 'boolean' ) {\n\t\tdebounceMode = callback;\n\t\tcallback = noTrailing;\n\t\tnoTrailing = undefined;\n\t}\n\n\t// The `wrapper` function encapsulates all of the throttling / debouncing\n\t// functionality and when executed will limit the rate at which `callback`\n\t// is executed.\n\tfunction wrapper () {\n\n\t\tvar self = this;\n\t\tvar elapsed = Number(new Date()) - lastExec;\n\t\tvar args = arguments;\n\n\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\tfunction exec () {\n\t\t\tlastExec = Number(new Date());\n\t\t\tcallback.apply(self, args);\n\t\t}\n\n\t\t// If `debounceMode` is true (at begin) this is used to clear the flag\n\t\t// to allow future `callback` executions.\n\t\tfunction clear () {\n\t\t\ttimeoutID = undefined;\n\t\t}\n\n\t\tif ( debounceMode && !timeoutID ) {\n\t\t\t// Since `wrapper` is being called for the first time and\n\t\t\t// `debounceMode` is true (at begin), execute `callback`.\n\t\t\texec();\n\t\t}\n\n\t\t// Clear any existing timeout.\n\t\tif ( timeoutID ) {\n\t\t\tclearTimeout(timeoutID);\n\t\t}\n\n\t\tif ( debounceMode === undefined && elapsed > delay ) {\n\t\t\t// In throttle mode, if `delay` time has been exceeded, execute\n\t\t\t// `callback`.\n\t\t\texec();\n\n\t\t} else if ( noTrailing !== true ) {\n\t\t\t// In trailing throttle mode, since `delay` time has not been\n\t\t\t// exceeded, schedule `callback` to execute `delay` ms after most\n\t\t\t// recent execution.\n\t\t\t//\n\t\t\t// If `debounceMode` is true (at begin), schedule `clear` to execute\n\t\t\t// after `delay` ms.\n\t\t\t//\n\t\t\t// If `debounceMode` is false (at end), schedule `callback` to\n\t\t\t// execute after `delay` ms.\n\t\t\ttimeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n\t\t}\n\n\t}\n\n\t// Return the wrapper function.\n\treturn wrapper;\n\n};\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__styles_css__);\n\n\n\nfunction addButton(container, label, onclick) {\n // Add a button to a container.\n const button = document.createElement('button');\n button.setAttribute('type', 'button');\n button.className = 'button button-outline';\n button.innerHTML = label;\n button.addEventListener('click', onclick);\n container.appendChild(button);\n return button;\n}\n\nfunction calculateOverlap(d, r, R) {\n // Calculate the DIFI overlap.\n // d is the center-to-center spacing between the small and big circles.\n // r is the radius of the small circle.\n // R is the radius of the large circle.\n const x = ((d * d) + (r * r) - (R * R)) / (2 * d * r);\n const y = ((d * d) + (R * R) - (r * r)) / (2 * d * R);\n const z = (-d + r + R) * (d + r - R) * (d - r + R) * (d + r + R);\n const overlapArea = (r * r * Math.acos(x)) + (R * R * Math.acos(y)) - (Math.sqrt(z) / 2);\n if (d > r + R) {\n return 0;\n } else if (d < R - r) {\n return 100;\n }\n return 100 * (overlapArea / (Math.PI * r * r));\n}\n\nfunction outerLeft(el) {\n // Find the left offset of an element (including border)\n // relative to the page\n const rect = el.getBoundingClientRect();\n const left = rect.left + document.body.scrollLeft;\n return left - parseFloat(getComputedStyle(el)['border-left-width'], 10);\n}\n\nfunction outerRight(el) {\n // Find the right offset of an element (including border)\n // relative to the page\n return outerLeft(el) + el.offsetWidth;\n}\n\nclass DIFIInput {\n\n constructor(el, options = {}) {\n this.drag = __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default()(20, this.drag.bind(this));\n this.startDrag = this.startDrag.bind(this);\n this.endDrag = this.endDrag.bind(this);\n\n this.el = el;\n this.options = options;\n this.initializeDOM();\n this.update();\n }\n\n initializeDOM() {\n // Construct the widget.\n const name = this.el.getAttribute('name');\n this.el.setAttribute('name', `${name}_distance`);\n this.el.setAttribute('type', 'hidden');\n\n this.elOverlap = document.createElement('input');\n this.elOverlap.setAttribute('name', `${name}_overlap`);\n this.elOverlap.setAttribute('type', 'hidden');\n this.el.insertAdjacentElement('afterend', this.elOverlap);\n\n const elContent = document.createElement('div');\n elContent.className = 'DIFI';\n elContent.innerHTML = `\n <div class=\"DIFI-controls\"></div>\n <div class=\"DIFI-group\"><label>${this.options.groupLabel || 'Group'}</label></div>\n <div class=\"DIFI-range\">\n <div class=\"DIFI-me\"><label>${this.options.meLabel || 'Me'}</label></div>\n </div>\n `;\n this.me = elContent.querySelector('.DIFI-me');\n this.group = elContent.querySelector('.DIFI-group');\n this.elRange = elContent.querySelector('.DIFI-range');\n\n if (this.options.groupImage) {\n this.group.style.backgroundImage = `url(${this.options.groupImage})`;\n }\n\n const controls = elContent.querySelector('.DIFI-controls');\n addButton(controls, '◀◀', this.nudge.bind(this, -0.5));\n addButton(controls, '◀', this.nudge.bind(this, -0.1));\n addButton(controls, '▶', this.nudge.bind(this, 0.1));\n addButton(controls, '▶▶', this.nudge.bind(this, 0.5));\n\n this.el.insertAdjacentElement('beforebegin', elContent);\n\n this.me.addEventListener('mousedown', this.startDrag.bind(this));\n }\n\n startDrag(e) {\n // Start tracking mouse when clicked.\n e.preventDefault();\n e.stopPropagation();\n this.me.className = 'DIFI-me dragging';\n\n this.dragOrigLeft = parseFloat(getComputedStyle(this.me).left, 10);\n this.dragOrigX = e.pageX;\n document.addEventListener('mousemove', this.drag);\n document.addEventListener('mouseup', this.endDrag);\n }\n\n drag(e) {\n // Update position of Me while dragging.\n e.preventDefault();\n e.stopPropagation();\n if (this.dragOrigX === null) {\n return;\n }\n const deltaPixels = e.pageX - this.dragOrigX;\n this.nudgePixels(deltaPixels, this.dragOrigLeft);\n }\n\n endDrag() {\n // Stop tracking mouse when mouse released.\n this.me.className = 'DIFI-me';\n document.removeEventListener('mousemove', this.drag);\n document.removeEventListener('mouseup', this.endDrag);\n this.dragOrigX = null;\n this.dragOrigLeft = null;\n }\n\n update() {\n // Update distance and overlap values from current position.\n // Distance is based on difference in position:\n // - left circle separated from right circle: -100 to 0\n // - left circle just touching right circle: 0\n // - left circle overlapping right circle: 0 to 100\n // - left circle contained within right circle: 100 to 125\n // - left circle at the center of right circle: 125\n const R = this.group.offsetWidth / 2;\n const r = this.me.offsetWidth / 2;\n const mePos = outerLeft(this.me);\n const groupPos = outerLeft(this.group);\n const d = mePos - groupPos;\n let value = 100 + 50 * d / r;\n // Snap to center\n const elRange = this.me.parentNode;\n if (outerRight(elRange) - outerRight(this.me) < 2) {\n value = 125;\n }\n // Clip value to desired range (-100 to 125)\n value = Math.max(Math.min(Math.round(value * 1000) / 1000, 125), -100);\n this.el.setAttribute('value', value);\n\n // Compute overlap.\n const dCenterToCenter = (groupPos + R) - (mePos + r);\n const overlap = calculateOverlap(dCenterToCenter, r, R);\n this.elOverlap.setAttribute('value', overlap);\n }\n\n nudge(delta) {\n // Move by `delta` units (1 unit = radius of Me circle)\n const unit = this.me.offsetWidth / 2;\n const deltaPixels = delta * unit;\n this.nudgePixels(deltaPixels);\n }\n\n nudgePixels(delta, origLeft) {\n // Move by `delta` pixels\n // (relative to origLeft if specified, or to current position)\n let start = origLeft;\n if (start === undefined) {\n start = parseFloat(getComputedStyle(this.me).left, 10);\n }\n let finish = start + delta;\n if (finish < 0) {\n finish = 0;\n }\n if (finish > this.elRange.offsetWidth - this.me.offsetWidth) {\n finish = this.elRange.offsetWidth - this.me.offsetWidth;\n }\n this.me.style.left = `${finish / this.elRange.offsetWidth * 100}%`;\n this.update();\n }\n}\n/* harmony export (immutable) */ __webpack_exports__[\"DIFIInput\"] = DIFIInput;\n\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\nexports = module.exports = __webpack_require__(4)(undefined);\n// imports\n\n\n// module\nexports.push([module.i, \".DIFI {\\n border: solid 1px #ccc;\\n width: 100%;\\n margin: 10px auto;\\n padding-top: 40%;\\n position: relative;\\n}\\n\\n.DIFI-controls {\\n left: 10px;\\n position: absolute;\\n text-align: center;\\n top: 10px;\\n}\\n\\n.DIFI-controls button {\\n margin-right: 5px;\\n padding: 0 1.5rem;\\n}\\n\\n.DIFI-range {\\n position: absolute;\\n left: 10%;\\n right: 10%;\\n top: 55%;\\n padding-top: 20%;\\n transform: translateY(-50%);\\n}\\n\\n.DIFI-me {\\n background-color: rgba(255, 255, 255, .8);\\n border: solid 1px #000;\\n border-radius: 50%;\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n padding-top: 25%;\\n position: absolute;\\n left: 0;\\n top: 0;\\n width: 25%;\\n user-select: none;\\n}\\n\\n.DIFI-me.dragging {\\n cursor: move;\\n cursor: grabbing;\\n cursor: -webkit-grabbing;\\n}\\n\\n.DIFI-me label {\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n position: absolute;\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.DIFI-group {\\n background-color: #ccc;\\n background-position: 50% 50%;\\n background-size: cover;\\n border-radius: 50%;\\n left: 80%;\\n padding-top: 30%;\\n position: absolute;\\n top: 55%;\\n transform: translate(-50%, -50%);\\n width: 30%;\\n}\\n\\n.DIFI-group label {\\n position: absolute;\\n left: 50%;\\n top: 0;\\n transform: translate(-50%, -100%);\\n white-space: nowrap;\\n}\\n\", \"\"]);\n\n// exports\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\nmodule.exports = function(useSourceMap) {\n\tvar list = [];\n\n\t// return the list of modules as css string\n\tlist.toString = function toString() {\n\t\treturn this.map(function (item) {\n\t\t\tvar content = cssWithMappingToString(item, useSourceMap);\n\t\t\tif(item[2]) {\n\t\t\t\treturn \"@media \" + item[2] + \"{\" + content + \"}\";\n\t\t\t} else {\n\t\t\t\treturn content;\n\t\t\t}\n\t\t}).join(\"\");\n\t};\n\n\t// import a list of modules into the list\n\tlist.i = function(modules, mediaQuery) {\n\t\tif(typeof modules === \"string\")\n\t\t\tmodules = [[null, modules, \"\"]];\n\t\tvar alreadyImportedModules = {};\n\t\tfor(var i = 0; i < this.length; i++) {\n\t\t\tvar id = this[i][0];\n\t\t\tif(typeof id === \"number\")\n\t\t\t\talreadyImportedModules[id] = true;\n\t\t}\n\t\tfor(i = 0; i < modules.length; i++) {\n\t\t\tvar item = modules[i];\n\t\t\t// skip already imported module\n\t\t\t// this implementation is not 100% perfect for weird media query combinations\n\t\t\t// when a module is imported multiple times with different media queries.\n\t\t\t// I hope this will never occur (Hey this way we have smaller bundles)\n\t\t\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]) {\n\t\t\t\tif(mediaQuery && !item[2]) {\n\t\t\t\t\titem[2] = mediaQuery;\n\t\t\t\t} else if(mediaQuery) {\n\t\t\t\t\titem[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";\n\t\t\t\t}\n\t\t\t\tlist.push(item);\n\t\t\t}\n\t\t}\n\t};\n\treturn list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n\tvar content = item[1] || '';\n\tvar cssMapping = item[3];\n\tif (!cssMapping) {\n\t\treturn content;\n\t}\n\n\tif (useSourceMap && typeof btoa === 'function') {\n\t\tvar sourceMapping = toComment(cssMapping);\n\t\tvar sourceURLs = cssMapping.sources.map(function (source) {\n\t\t\treturn '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'\n\t\t});\n\n\t\treturn [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n\t}\n\n\treturn [content].join('\\n');\n}\n\n// Adapted from convert-source-map (MIT)\nfunction toComment(sourceMap) {\n\t// eslint-disable-next-line no-undef\n\tvar base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n\tvar data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;\n\n\treturn '/*# ' + data + ' */';\n}\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === \"undefined\") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(selector) {\n\t\tif (typeof memo[selector] === \"undefined\") {\n\t\t\tmemo[selector] = fn.call(this, selector);\n\t\t}\n\n\t\treturn memo[selector]\n\t};\n})(function (target) {\n\treturn document.querySelector(target)\n});\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = __webpack_require__(6);\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== \"undefined\" && DEBUG) {\n\t\tif (typeof document !== \"object\") throw new Error(\"The style-loader cannot be used in a non-browser environment\");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === \"object\" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>\n\t// tags it will allow on a page\n\tif (!options.singleton) options.singleton = isOldIE();\n\n\t// By default, add <style> tags to the <head> element\n\tif (!options.insertInto) options.insertInto = \"head\";\n\n\t// By default, add <style> tags to the bottom of the target\n\tif (!options.insertAt) options.insertAt = \"bottom\";\n\n\tvar styles = listToStyles(list, options);\n\n\taddStylesToDom(styles, options);\n\n\treturn function update (newList) {\n\t\tvar mayRemove = [];\n\n\t\tfor (var i = 0; i < styles.length; i++) {\n\t\t\tvar item = styles[i];\n\t\t\tvar domStyle = stylesInDom[item.id];\n\n\t\t\tdomStyle.refs--;\n\t\t\tmayRemove.push(domStyle);\n\t\t}\n\n\t\tif(newList) {\n\t\t\tvar newStyles = listToStyles(newList, options);\n\t\t\taddStylesToDom(newStyles, options);\n\t\t}\n\n\t\tfor (var i = 0; i < mayRemove.length; i++) {\n\t\t\tvar domStyle = mayRemove[i];\n\n\t\t\tif(domStyle.refs === 0) {\n\t\t\t\tfor (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();\n\n\t\t\t\tdelete stylesInDom[domStyle.id];\n\t\t\t}\n\t\t}\n\t};\n};\n\nfunction addStylesToDom (styles, options) {\n\tfor (var i = 0; i < styles.length; i++) {\n\t\tvar item = styles[i];\n\t\tvar domStyle = stylesInDom[item.id];\n\n\t\tif(domStyle) {\n\t\t\tdomStyle.refs++;\n\n\t\t\tfor(var j = 0; j < domStyle.parts.length; j++) {\n\t\t\t\tdomStyle.parts[j](item.parts[j]);\n\t\t\t}\n\n\t\t\tfor(; j < item.parts.length; j++) {\n\t\t\t\tdomStyle.parts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\t\t} else {\n\t\t\tvar parts = [];\n\n\t\t\tfor(var j = 0; j < item.parts.length; j++) {\n\t\t\t\tparts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\n\t\t\tstylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};\n\t\t}\n\t}\n}\n\nfunction listToStyles (list, options) {\n\tvar styles = [];\n\tvar newStyles = {};\n\n\tfor (var i = 0; i < list.length; i++) {\n\t\tvar item = list[i];\n\t\tvar id = options.base ? item[0] + options.base : item[0];\n\t\tvar css = item[1];\n\t\tvar media = item[2];\n\t\tvar sourceMap = item[3];\n\t\tvar part = {css: css, media: media, sourceMap: sourceMap};\n\n\t\tif(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});\n\t\telse newStyles[id].parts.push(part);\n\t}\n\n\treturn styles;\n}\n\nfunction insertStyleElement (options, style) {\n\tvar target = getElement(options.insertInto)\n\n\tif (!target) {\n\t\tthrow new Error(\"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.\");\n\t}\n\n\tvar lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];\n\n\tif (options.insertAt === \"top\") {\n\t\tif (!lastStyleElementInsertedAtTop) {\n\t\t\ttarget.insertBefore(style, target.firstChild);\n\t\t} else if (lastStyleElementInsertedAtTop.nextSibling) {\n\t\t\ttarget.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);\n\t\t} else {\n\t\t\ttarget.appendChild(style);\n\t\t}\n\t\tstylesInsertedAtTop.push(style);\n\t} else if (options.insertAt === \"bottom\") {\n\t\ttarget.appendChild(style);\n\t} else {\n\t\tthrow new Error(\"Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.\");\n\t}\n}\n\nfunction removeStyleElement (style) {\n\tstyle.parentNode.removeChild(style);\n\n\tvar idx = stylesInsertedAtTop.indexOf(style);\n\n\tif(idx >= 0) {\n\t\tstylesInsertedAtTop.splice(idx, 1);\n\t}\n}\n\nfunction createStyleElement (options) {\n\tvar style = document.createElement(\"style\");\n\n\toptions.attrs.type = \"text/css\";\n\n\taddAttrs(style, options.attrs);\n\tinsertStyleElement(options, style);\n\n\treturn style;\n}\n\nfunction createLinkElement (options) {\n\tvar link = document.createElement(\"link\");\n\n\toptions.attrs.type = \"text/css\";\n\toptions.attrs.rel = \"stylesheet\";\n\n\taddAttrs(link, options.attrs);\n\tinsertStyleElement(options, link);\n\n\treturn link;\n}\n\nfunction addAttrs (el, attrs) {\n\tObject.keys(attrs).forEach(function (key) {\n\t\tel.setAttribute(key, attrs[key]);\n\t});\n}\n\nfunction addStyle (obj, options) {\n\tvar style, update, remove, result;\n\n\t// If a transform function was defined, run it on the css\n\tif (options.transform && obj.css) {\n\t result = options.transform(obj.css);\n\n\t if (result) {\n\t \t// If transform returns a value, use that instead of the original css.\n\t \t// This allows running runtime transformations on the css.\n\t \tobj.css = result;\n\t } else {\n\t \t// If the transform function returns a falsy value, don't add this css.\n\t \t// This allows conditional loading of css\n\t \treturn function() {\n\t \t\t// noop\n\t \t};\n\t }\n\t}\n\n\tif (options.singleton) {\n\t\tvar styleIndex = singletonCounter++;\n\n\t\tstyle = singleton || (singleton = createStyleElement(options));\n\n\t\tupdate = applyToSingletonTag.bind(null, style, styleIndex, false);\n\t\tremove = applyToSingletonTag.bind(null, style, styleIndex, true);\n\n\t} else if (\n\t\tobj.sourceMap &&\n\t\ttypeof URL === \"function\" &&\n\t\ttypeof URL.createObjectURL === \"function\" &&\n\t\ttypeof URL.revokeObjectURL === \"function\" &&\n\t\ttypeof Blob === \"function\" &&\n\t\ttypeof btoa === \"function\"\n\t) {\n\t\tstyle = createLinkElement(options);\n\t\tupdate = updateLink.bind(null, style, options);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\n\t\t\tif(style.href) URL.revokeObjectURL(style.href);\n\t\t};\n\t} else {\n\t\tstyle = createStyleElement(options);\n\t\tupdate = applyToTag.bind(null, style);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\t\t};\n\t}\n\n\tupdate(obj);\n\n\treturn function updateStyle (newObj) {\n\t\tif (newObj) {\n\t\t\tif (\n\t\t\t\tnewObj.css === obj.css &&\n\t\t\t\tnewObj.media === obj.media &&\n\t\t\t\tnewObj.sourceMap === obj.sourceMap\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdate(obj = newObj);\n\t\t} else {\n\t\t\tremove();\n\t\t}\n\t};\n}\n\nvar replaceText = (function () {\n\tvar textStore = [];\n\n\treturn function (index, replacement) {\n\t\ttextStore[index] = replacement;\n\n\t\treturn textStore.filter(Boolean).join('\\n');\n\t};\n})();\n\nfunction applyToSingletonTag (style, index, remove, obj) {\n\tvar css = remove ? \"\" : obj.css;\n\n\tif (style.styleSheet) {\n\t\tstyle.styleSheet.cssText = replaceText(index, css);\n\t} else {\n\t\tvar cssNode = document.createTextNode(css);\n\t\tvar childNodes = style.childNodes;\n\n\t\tif (childNodes[index]) style.removeChild(childNodes[index]);\n\n\t\tif (childNodes.length) {\n\t\t\tstyle.insertBefore(cssNode, childNodes[index]);\n\t\t} else {\n\t\t\tstyle.appendChild(cssNode);\n\t\t}\n\t}\n}\n\nfunction applyToTag (style, obj) {\n\tvar css = obj.css;\n\tvar media = obj.media;\n\n\tif(media) {\n\t\tstyle.setAttribute(\"media\", media)\n\t}\n\n\tif(style.styleSheet) {\n\t\tstyle.styleSheet.cssText = css;\n\t} else {\n\t\twhile(style.firstChild) {\n\t\t\tstyle.removeChild(style.firstChild);\n\t\t}\n\n\t\tstyle.appendChild(document.createTextNode(css));\n\t}\n}\n\nfunction updateLink (link, options, obj) {\n\tvar css = obj.css;\n\tvar sourceMap = obj.sourceMap;\n\n\t/*\n\t\tIf convertToAbsoluteUrls isn't defined, but sourcemaps are enabled\n\t\tand there is no publicPath defined then lets turn convertToAbsoluteUrls\n\t\ton by default. Otherwise default to the convertToAbsoluteUrls option\n\t\tdirectly\n\t*/\n\tvar autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;\n\n\tif (options.convertToAbsoluteUrls || autoFixUrls) {\n\t\tcss = fixUrls(css);\n\t}\n\n\tif (sourceMap) {\n\t\t// http://stackoverflow.com/a/26603875\n\t\tcss += \"\\n/*# sourceMappingURL=data:application/json;base64,\" + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + \" */\";\n\t}\n\n\tvar blob = new Blob([css], { type: \"text/css\" });\n\n\tvar oldSrc = link.href;\n\n\tlink.href = URL.createObjectURL(blob);\n\n\tif(oldSrc) URL.revokeObjectURL(oldSrc);\n}\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\n/**\n * When source maps are enabled, `style-loader` uses a link element with a data-uri to\n * embed the css on the page. This breaks all relative urls because now they are relative to a\n * bundle instead of the current page.\n *\n * One solution is to only use full urls, but that may be impossible.\n *\n * Instead, this function \"fixes\" the relative urls to be absolute according to the current page location.\n *\n * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.\n *\n */\n\nmodule.exports = function (css) {\n // get current location\n var location = typeof window !== \"undefined\" && window.location;\n\n if (!location) {\n throw new Error(\"fixUrls requires window.location\");\n }\n\n\t// blank or null?\n\tif (!css || typeof css !== \"string\") {\n\t return css;\n }\n\n var baseUrl = location.protocol + \"//\" + location.host;\n var currentDir = baseUrl + location.pathname.replace(/\\/[^\\/]*$/, \"/\");\n\n\t// convert each url(...)\n\t/*\n\tThis regular expression is just a way to recursively match brackets within\n\ta string.\n\n\t /url\\s*\\( = Match on the word \"url\" with any whitespace after it and then a parens\n\t ( = Start a capturing group\n\t (?: = Start a non-capturing group\n\t [^)(] = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t (?: = Start another non-capturing groups\n\t [^)(]+ = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t [^)(]* = Match anything that isn't a parentheses\n\t \\) = Match a end parentheses\n\t ) = End Group\n *\\) = Match anything and then a close parens\n ) = Close non-capturing group\n * = Match anything\n ) = Close capturing group\n\t \\) = Match a close parens\n\n\t /gi = Get all matches, not the first. Be case insensitive.\n\t */\n\tvar fixedCss = css.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi, function(fullMatch, origUrl) {\n\t\t// strip quotes (if they exist)\n\t\tvar unquotedOrigUrl = origUrl\n\t\t\t.trim()\n\t\t\t.replace(/^\"(.*)\"$/, function(o, $1){ return $1; })\n\t\t\t.replace(/^'(.*)'$/, function(o, $1){ return $1; });\n\n\t\t// already a full url? no change\n\t\tif (/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/)/i.test(unquotedOrigUrl)) {\n\t\t return fullMatch;\n\t\t}\n\n\t\t// convert the url to a full url\n\t\tvar newUrl;\n\n\t\tif (unquotedOrigUrl.indexOf(\"//\") === 0) {\n\t\t \t//TODO: should we add protocol?\n\t\t\tnewUrl = unquotedOrigUrl;\n\t\t} else if (unquotedOrigUrl.indexOf(\"/\") === 0) {\n\t\t\t// path should be relative to the base url\n\t\t\tnewUrl = baseUrl + unquotedOrigUrl; // already starts with '/'\n\t\t} else {\n\t\t\t// path should be relative to current directory\n\t\t\tnewUrl = currentDir + unquotedOrigUrl.replace(/^\\.\\//, \"\"); // Strip leading './'\n\t\t}\n\n\t\t// send back the fixed url(...)\n\t\treturn \"url(\" + JSON.stringify(newUrl) + \")\";\n\t});\n\n\t// send back the fixed css\n\treturn fixedCss;\n};\n\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=identityfusion.js.map\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/identityfusion/dist/identityfusion.js\n// module id = 0\n// module chunks = 1 2","/* global dallinger, console */\n/*jshint esversion: 6 */\n\nimport { DIFIInput } from 'identityfusion';\n\n$(document).ready(function() {\n\n // Initialize DIFI widget\n var $DIFI = $('input.DIFI-input'),\n spinner = dallinger.BusyForm();\n\n if ($DIFI.length) {\n var input = new DIFIInput(\n $DIFI.get(0),\n {\n groupLabel: $DIFI.attr('data-group-label'),\n groupImage: $DIFI.attr('data-group-image')\n }\n );\n }\n\n});\n\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/difi.js\n// module id = 17\n// module chunks = 2"],"sourceRoot":""} \ No newline at end of file diff --git a/dlgr/griduniverse/static/scripts/dist/questionnaire.js b/dlgr/griduniverse/static/scripts/dist/questionnaire.js index 9300a73f..4da6b58d 100644 --- a/dlgr/griduniverse/static/scripts/dist/questionnaire.js +++ b/dlgr/griduniverse/static/scripts/dist/questionnaire.js @@ -33,6 +33,9 @@ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { @@ -60,7 +63,7 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 38); +/******/ return __webpack_require__(__webpack_require__.s = 18); /******/ }) /************************************************************************/ /******/ ({ @@ -1028,7 +1031,7 @@ module.exports = function (css) { /***/ }), -/***/ 38: +/***/ 18: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; diff --git a/dlgr/griduniverse/static/scripts/dist/questionnaire.js.map b/dlgr/griduniverse/static/scripts/dist/questionnaire.js.map index b314bb25..215f63a8 100644 --- a/dlgr/griduniverse/static/scripts/dist/questionnaire.js.map +++ b/dlgr/griduniverse/static/scripts/dist/questionnaire.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap b297e754b215368f0363","webpack:///./node_modules/identityfusion/dist/identityfusion.js","webpack:///./dlgr/griduniverse/static/scripts/questionnaire.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;AC7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,cAAc;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,0BAA0B,EAAE;AAC/D,yCAAyC,eAAe;AACxD;AACA;AACA;AACA;AACA;AACA,8DAA8D,+DAA+D;AAC7H;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,gCAAgC,UAAU,EAAE;AAC5C;;AAEA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,QAAQ;AACpB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA,0DAA0D,cAAc;AACxE;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oCAAoC,KAAK;AACzC;;AAEA;AACA,2CAA2C,KAAK;AAChD;AACA;;AAEA;AACA;AACA;AACA;AACA,uCAAuC,mCAAmC;AAC1E;AACA,sCAAsC,6BAA6B;AACnE;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,wBAAwB;AACxE;;AAEA;AACA,gCAAgC,OAAO;AACvC,gCAAgC;AAChC,gCAAgC;AAChC,gCAAgC,OAAO;;AAEvC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,wCAAwC;AACpE;AACA;AACA;AACA;;;;AAIA,OAAO;AACP;AACA;;AAEA;AACA;;;AAGA;AACA,gCAAgC,6BAA6B,kBAAkB,wBAAwB,uBAAuB,yBAAyB,GAAG,oBAAoB,iBAAiB,yBAAyB,yBAAyB,gBAAgB,GAAG,2BAA2B,wBAAwB,wBAAwB,GAAG,iBAAiB,yBAAyB,gBAAgB,iBAAiB,eAAe,uBAAuB,kCAAkC,GAAG,cAAc,gDAAgD,6BAA6B,yBAAyB,mBAAmB,mBAAmB,2BAA2B,uBAAuB,yBAAyB,cAAc,aAAa,iBAAiB,wBAAwB,GAAG,uBAAuB,mBAAmB,uBAAuB,+BAA+B,GAAG,oBAAoB,mBAAmB,mBAAmB,2BAA2B,yBAAyB,gBAAgB,eAAe,uCAAuC,GAAG,iBAAiB,6BAA6B,mCAAmC,6BAA6B,yBAAyB,gBAAgB,uBAAuB,yBAAyB,eAAe,uCAAuC,iBAAiB,GAAG,uBAAuB,yBAAyB,gBAAgB,aAAa,wCAAwC,0BAA0B,GAAG;;AAEj9C;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gBAAgB;AACnD,IAAI;AACJ;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA,YAAY,oBAAoB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,oDAAoD,cAAc;;AAElE;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA,CAAC;;AAED;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,iBAAiB,mBAAmB;AACpC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,iBAAiB,sBAAsB;AACvC;;AAEA;AACA,mBAAmB,2BAA2B;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,mBAAmB;AACnC;AACA;;AAEA;AACA;;AAEA,iBAAiB,2BAA2B;AAC5C;AACA;;AAEA,QAAQ,uBAAuB;AAC/B;AACA;AACA,GAAG;AACH;;AAEA,iBAAiB,uBAAuB;AACxC;AACA;;AAEA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA;AACA,cAAc;;AAEd,kDAAkD,sBAAsB;AACxE;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD;AACvD;;AAEA,6BAA6B,mBAAmB;;AAEhD;;AAEA;;AAEA;AACA;;;AAGA,OAAO;AACP;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,WAAW,EAAE;AACrD,wCAAwC,WAAW,EAAE;;AAErD;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,sCAAsC;AACtC,GAAG;AACH;AACA,8DAA8D;AAC9D;;AAEA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;;AAGA,OAAO;AACP;AACA,CAAC;AACD,0C;;;;;;;;;AC57BA;AAAA;AAAA;AACA;;AAEoB;;AAEpB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL,GAAG;;AAEH,CAAC","file":"scripts/dist/questionnaire.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 38);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap b297e754b215368f0363","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"identityfusion\"] = factory();\n\telse\n\t\troot[\"identityfusion\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n// style-loader: Adds some css to the DOM by adding a <style> tag\n\n// load the styles\nvar content = __webpack_require__(3);\nif(typeof content === 'string') content = [[module.i, content, '']];\n// Prepare cssTransformation\nvar transform;\n\nvar options = {}\noptions.transform = transform\n// add the styles to the DOM\nvar update = __webpack_require__(5)(content, options);\nif(content.locals) module.exports = content.locals;\n// Hot Module Replacement\nif(false) {\n\t// When the styles change, update the <style> tags\n\tif(!content.locals) {\n\t\tmodule.hot.accept(\"!!./node_modules/css-loader/index.js!./styles.css\", function() {\n\t\t\tvar newContent = require(\"!!./node_modules/css-loader/index.js!./styles.css\");\n\t\t\tif(typeof newContent === 'string') newContent = [[module.id, newContent, '']];\n\t\t\tupdate(newContent);\n\t\t});\n\t}\n\t// When the module is disposed, remove the <style> tags\n\tmodule.hot.dispose(function() { update(); });\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the\n * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time\n * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,\n * the internal counter is reset)\n * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the throttled-function is executed.\n * @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),\n * schedule `callback` to execute after `delay` ms.\n *\n * @return {Function} A new, throttled, function.\n */\nmodule.exports = function ( delay, noTrailing, callback, debounceMode ) {\n\n\t// After wrapper has stopped being called, this timeout ensures that\n\t// `callback` is executed at the proper times in `throttle` and `end`\n\t// debounce modes.\n\tvar timeoutID;\n\n\t// Keep track of the last time `callback` was executed.\n\tvar lastExec = 0;\n\n\t// `noTrailing` defaults to falsy.\n\tif ( typeof noTrailing !== 'boolean' ) {\n\t\tdebounceMode = callback;\n\t\tcallback = noTrailing;\n\t\tnoTrailing = undefined;\n\t}\n\n\t// The `wrapper` function encapsulates all of the throttling / debouncing\n\t// functionality and when executed will limit the rate at which `callback`\n\t// is executed.\n\tfunction wrapper () {\n\n\t\tvar self = this;\n\t\tvar elapsed = Number(new Date()) - lastExec;\n\t\tvar args = arguments;\n\n\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\tfunction exec () {\n\t\t\tlastExec = Number(new Date());\n\t\t\tcallback.apply(self, args);\n\t\t}\n\n\t\t// If `debounceMode` is true (at begin) this is used to clear the flag\n\t\t// to allow future `callback` executions.\n\t\tfunction clear () {\n\t\t\ttimeoutID = undefined;\n\t\t}\n\n\t\tif ( debounceMode && !timeoutID ) {\n\t\t\t// Since `wrapper` is being called for the first time and\n\t\t\t// `debounceMode` is true (at begin), execute `callback`.\n\t\t\texec();\n\t\t}\n\n\t\t// Clear any existing timeout.\n\t\tif ( timeoutID ) {\n\t\t\tclearTimeout(timeoutID);\n\t\t}\n\n\t\tif ( debounceMode === undefined && elapsed > delay ) {\n\t\t\t// In throttle mode, if `delay` time has been exceeded, execute\n\t\t\t// `callback`.\n\t\t\texec();\n\n\t\t} else if ( noTrailing !== true ) {\n\t\t\t// In trailing throttle mode, since `delay` time has not been\n\t\t\t// exceeded, schedule `callback` to execute `delay` ms after most\n\t\t\t// recent execution.\n\t\t\t//\n\t\t\t// If `debounceMode` is true (at begin), schedule `clear` to execute\n\t\t\t// after `delay` ms.\n\t\t\t//\n\t\t\t// If `debounceMode` is false (at end), schedule `callback` to\n\t\t\t// execute after `delay` ms.\n\t\t\ttimeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n\t\t}\n\n\t}\n\n\t// Return the wrapper function.\n\treturn wrapper;\n\n};\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__styles_css__);\n\n\n\nfunction addButton(container, label, onclick) {\n // Add a button to a container.\n const button = document.createElement('button');\n button.setAttribute('type', 'button');\n button.className = 'button button-outline';\n button.innerHTML = label;\n button.addEventListener('click', onclick);\n container.appendChild(button);\n return button;\n}\n\nfunction calculateOverlap(d, r, R) {\n // Calculate the DIFI overlap.\n // d is the center-to-center spacing between the small and big circles.\n // r is the radius of the small circle.\n // R is the radius of the large circle.\n const x = ((d * d) + (r * r) - (R * R)) / (2 * d * r);\n const y = ((d * d) + (R * R) - (r * r)) / (2 * d * R);\n const z = (-d + r + R) * (d + r - R) * (d - r + R) * (d + r + R);\n const overlapArea = (r * r * Math.acos(x)) + (R * R * Math.acos(y)) - (Math.sqrt(z) / 2);\n if (d > r + R) {\n return 0;\n } else if (d < R - r) {\n return 100;\n }\n return 100 * (overlapArea / (Math.PI * r * r));\n}\n\nfunction outerLeft(el) {\n // Find the left offset of an element (including border)\n // relative to the page\n const rect = el.getBoundingClientRect();\n const left = rect.left + document.body.scrollLeft;\n return left - parseFloat(getComputedStyle(el)['border-left-width'], 10);\n}\n\nfunction outerRight(el) {\n // Find the right offset of an element (including border)\n // relative to the page\n return outerLeft(el) + el.offsetWidth;\n}\n\nclass DIFIInput {\n\n constructor(el, options = {}) {\n this.drag = __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default()(20, this.drag.bind(this));\n this.startDrag = this.startDrag.bind(this);\n this.endDrag = this.endDrag.bind(this);\n\n this.el = el;\n this.options = options;\n this.initializeDOM();\n this.update();\n }\n\n initializeDOM() {\n // Construct the widget.\n const name = this.el.getAttribute('name');\n this.el.setAttribute('name', `${name}_distance`);\n this.el.setAttribute('type', 'hidden');\n\n this.elOverlap = document.createElement('input');\n this.elOverlap.setAttribute('name', `${name}_overlap`);\n this.elOverlap.setAttribute('type', 'hidden');\n this.el.insertAdjacentElement('afterend', this.elOverlap);\n\n const elContent = document.createElement('div');\n elContent.className = 'DIFI';\n elContent.innerHTML = `\n <div class=\"DIFI-controls\"></div>\n <div class=\"DIFI-group\"><label>${this.options.groupLabel || 'Group'}</label></div>\n <div class=\"DIFI-range\">\n <div class=\"DIFI-me\"><label>${this.options.meLabel || 'Me'}</label></div>\n </div>\n `;\n this.me = elContent.querySelector('.DIFI-me');\n this.group = elContent.querySelector('.DIFI-group');\n this.elRange = elContent.querySelector('.DIFI-range');\n\n if (this.options.groupImage) {\n this.group.style.backgroundImage = `url(${this.options.groupImage})`;\n }\n\n const controls = elContent.querySelector('.DIFI-controls');\n addButton(controls, '◀◀', this.nudge.bind(this, -0.5));\n addButton(controls, '◀', this.nudge.bind(this, -0.1));\n addButton(controls, '▶', this.nudge.bind(this, 0.1));\n addButton(controls, '▶▶', this.nudge.bind(this, 0.5));\n\n this.el.insertAdjacentElement('beforebegin', elContent);\n\n this.me.addEventListener('mousedown', this.startDrag.bind(this));\n }\n\n startDrag(e) {\n // Start tracking mouse when clicked.\n e.preventDefault();\n e.stopPropagation();\n this.me.className = 'DIFI-me dragging';\n\n this.dragOrigLeft = parseFloat(getComputedStyle(this.me).left, 10);\n this.dragOrigX = e.pageX;\n document.addEventListener('mousemove', this.drag);\n document.addEventListener('mouseup', this.endDrag);\n }\n\n drag(e) {\n // Update position of Me while dragging.\n e.preventDefault();\n e.stopPropagation();\n if (this.dragOrigX === null) {\n return;\n }\n const deltaPixels = e.pageX - this.dragOrigX;\n this.nudgePixels(deltaPixels, this.dragOrigLeft);\n }\n\n endDrag() {\n // Stop tracking mouse when mouse released.\n this.me.className = 'DIFI-me';\n document.removeEventListener('mousemove', this.drag);\n document.removeEventListener('mouseup', this.endDrag);\n this.dragOrigX = null;\n this.dragOrigLeft = null;\n }\n\n update() {\n // Update distance and overlap values from current position.\n // Distance is based on difference in position:\n // - left circle separated from right circle: -100 to 0\n // - left circle just touching right circle: 0\n // - left circle overlapping right circle: 0 to 100\n // - left circle contained within right circle: 100 to 125\n // - left circle at the center of right circle: 125\n const R = this.group.offsetWidth / 2;\n const r = this.me.offsetWidth / 2;\n const mePos = outerLeft(this.me);\n const groupPos = outerLeft(this.group);\n const d = mePos - groupPos;\n let value = 100 + 50 * d / r;\n // Snap to center\n const elRange = this.me.parentNode;\n if (outerRight(elRange) - outerRight(this.me) < 2) {\n value = 125;\n }\n // Clip value to desired range (-100 to 125)\n value = Math.max(Math.min(Math.round(value * 1000) / 1000, 125), -100);\n this.el.setAttribute('value', value);\n\n // Compute overlap.\n const dCenterToCenter = (groupPos + R) - (mePos + r);\n const overlap = calculateOverlap(dCenterToCenter, r, R);\n this.elOverlap.setAttribute('value', overlap);\n }\n\n nudge(delta) {\n // Move by `delta` units (1 unit = radius of Me circle)\n const unit = this.me.offsetWidth / 2;\n const deltaPixels = delta * unit;\n this.nudgePixels(deltaPixels);\n }\n\n nudgePixels(delta, origLeft) {\n // Move by `delta` pixels\n // (relative to origLeft if specified, or to current position)\n let start = origLeft;\n if (start === undefined) {\n start = parseFloat(getComputedStyle(this.me).left, 10);\n }\n let finish = start + delta;\n if (finish < 0) {\n finish = 0;\n }\n if (finish > this.elRange.offsetWidth - this.me.offsetWidth) {\n finish = this.elRange.offsetWidth - this.me.offsetWidth;\n }\n this.me.style.left = `${finish / this.elRange.offsetWidth * 100}%`;\n this.update();\n }\n}\n/* harmony export (immutable) */ __webpack_exports__[\"DIFIInput\"] = DIFIInput;\n\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\nexports = module.exports = __webpack_require__(4)(undefined);\n// imports\n\n\n// module\nexports.push([module.i, \".DIFI {\\n border: solid 1px #ccc;\\n width: 100%;\\n margin: 10px auto;\\n padding-top: 40%;\\n position: relative;\\n}\\n\\n.DIFI-controls {\\n left: 10px;\\n position: absolute;\\n text-align: center;\\n top: 10px;\\n}\\n\\n.DIFI-controls button {\\n margin-right: 5px;\\n padding: 0 1.5rem;\\n}\\n\\n.DIFI-range {\\n position: absolute;\\n left: 10%;\\n right: 10%;\\n top: 55%;\\n padding-top: 20%;\\n transform: translateY(-50%);\\n}\\n\\n.DIFI-me {\\n background-color: rgba(255, 255, 255, .8);\\n border: solid 1px #000;\\n border-radius: 50%;\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n padding-top: 25%;\\n position: absolute;\\n left: 0;\\n top: 0;\\n width: 25%;\\n user-select: none;\\n}\\n\\n.DIFI-me.dragging {\\n cursor: move;\\n cursor: grabbing;\\n cursor: -webkit-grabbing;\\n}\\n\\n.DIFI-me label {\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n position: absolute;\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.DIFI-group {\\n background-color: #ccc;\\n background-position: 50% 50%;\\n background-size: cover;\\n border-radius: 50%;\\n left: 80%;\\n padding-top: 30%;\\n position: absolute;\\n top: 55%;\\n transform: translate(-50%, -50%);\\n width: 30%;\\n}\\n\\n.DIFI-group label {\\n position: absolute;\\n left: 50%;\\n top: 0;\\n transform: translate(-50%, -100%);\\n white-space: nowrap;\\n}\\n\", \"\"]);\n\n// exports\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\nmodule.exports = function(useSourceMap) {\n\tvar list = [];\n\n\t// return the list of modules as css string\n\tlist.toString = function toString() {\n\t\treturn this.map(function (item) {\n\t\t\tvar content = cssWithMappingToString(item, useSourceMap);\n\t\t\tif(item[2]) {\n\t\t\t\treturn \"@media \" + item[2] + \"{\" + content + \"}\";\n\t\t\t} else {\n\t\t\t\treturn content;\n\t\t\t}\n\t\t}).join(\"\");\n\t};\n\n\t// import a list of modules into the list\n\tlist.i = function(modules, mediaQuery) {\n\t\tif(typeof modules === \"string\")\n\t\t\tmodules = [[null, modules, \"\"]];\n\t\tvar alreadyImportedModules = {};\n\t\tfor(var i = 0; i < this.length; i++) {\n\t\t\tvar id = this[i][0];\n\t\t\tif(typeof id === \"number\")\n\t\t\t\talreadyImportedModules[id] = true;\n\t\t}\n\t\tfor(i = 0; i < modules.length; i++) {\n\t\t\tvar item = modules[i];\n\t\t\t// skip already imported module\n\t\t\t// this implementation is not 100% perfect for weird media query combinations\n\t\t\t// when a module is imported multiple times with different media queries.\n\t\t\t// I hope this will never occur (Hey this way we have smaller bundles)\n\t\t\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]) {\n\t\t\t\tif(mediaQuery && !item[2]) {\n\t\t\t\t\titem[2] = mediaQuery;\n\t\t\t\t} else if(mediaQuery) {\n\t\t\t\t\titem[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";\n\t\t\t\t}\n\t\t\t\tlist.push(item);\n\t\t\t}\n\t\t}\n\t};\n\treturn list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n\tvar content = item[1] || '';\n\tvar cssMapping = item[3];\n\tif (!cssMapping) {\n\t\treturn content;\n\t}\n\n\tif (useSourceMap && typeof btoa === 'function') {\n\t\tvar sourceMapping = toComment(cssMapping);\n\t\tvar sourceURLs = cssMapping.sources.map(function (source) {\n\t\t\treturn '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'\n\t\t});\n\n\t\treturn [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n\t}\n\n\treturn [content].join('\\n');\n}\n\n// Adapted from convert-source-map (MIT)\nfunction toComment(sourceMap) {\n\t// eslint-disable-next-line no-undef\n\tvar base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n\tvar data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;\n\n\treturn '/*# ' + data + ' */';\n}\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === \"undefined\") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(selector) {\n\t\tif (typeof memo[selector] === \"undefined\") {\n\t\t\tmemo[selector] = fn.call(this, selector);\n\t\t}\n\n\t\treturn memo[selector]\n\t};\n})(function (target) {\n\treturn document.querySelector(target)\n});\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = __webpack_require__(6);\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== \"undefined\" && DEBUG) {\n\t\tif (typeof document !== \"object\") throw new Error(\"The style-loader cannot be used in a non-browser environment\");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === \"object\" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>\n\t// tags it will allow on a page\n\tif (!options.singleton) options.singleton = isOldIE();\n\n\t// By default, add <style> tags to the <head> element\n\tif (!options.insertInto) options.insertInto = \"head\";\n\n\t// By default, add <style> tags to the bottom of the target\n\tif (!options.insertAt) options.insertAt = \"bottom\";\n\n\tvar styles = listToStyles(list, options);\n\n\taddStylesToDom(styles, options);\n\n\treturn function update (newList) {\n\t\tvar mayRemove = [];\n\n\t\tfor (var i = 0; i < styles.length; i++) {\n\t\t\tvar item = styles[i];\n\t\t\tvar domStyle = stylesInDom[item.id];\n\n\t\t\tdomStyle.refs--;\n\t\t\tmayRemove.push(domStyle);\n\t\t}\n\n\t\tif(newList) {\n\t\t\tvar newStyles = listToStyles(newList, options);\n\t\t\taddStylesToDom(newStyles, options);\n\t\t}\n\n\t\tfor (var i = 0; i < mayRemove.length; i++) {\n\t\t\tvar domStyle = mayRemove[i];\n\n\t\t\tif(domStyle.refs === 0) {\n\t\t\t\tfor (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();\n\n\t\t\t\tdelete stylesInDom[domStyle.id];\n\t\t\t}\n\t\t}\n\t};\n};\n\nfunction addStylesToDom (styles, options) {\n\tfor (var i = 0; i < styles.length; i++) {\n\t\tvar item = styles[i];\n\t\tvar domStyle = stylesInDom[item.id];\n\n\t\tif(domStyle) {\n\t\t\tdomStyle.refs++;\n\n\t\t\tfor(var j = 0; j < domStyle.parts.length; j++) {\n\t\t\t\tdomStyle.parts[j](item.parts[j]);\n\t\t\t}\n\n\t\t\tfor(; j < item.parts.length; j++) {\n\t\t\t\tdomStyle.parts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\t\t} else {\n\t\t\tvar parts = [];\n\n\t\t\tfor(var j = 0; j < item.parts.length; j++) {\n\t\t\t\tparts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\n\t\t\tstylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};\n\t\t}\n\t}\n}\n\nfunction listToStyles (list, options) {\n\tvar styles = [];\n\tvar newStyles = {};\n\n\tfor (var i = 0; i < list.length; i++) {\n\t\tvar item = list[i];\n\t\tvar id = options.base ? item[0] + options.base : item[0];\n\t\tvar css = item[1];\n\t\tvar media = item[2];\n\t\tvar sourceMap = item[3];\n\t\tvar part = {css: css, media: media, sourceMap: sourceMap};\n\n\t\tif(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});\n\t\telse newStyles[id].parts.push(part);\n\t}\n\n\treturn styles;\n}\n\nfunction insertStyleElement (options, style) {\n\tvar target = getElement(options.insertInto)\n\n\tif (!target) {\n\t\tthrow new Error(\"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.\");\n\t}\n\n\tvar lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];\n\n\tif (options.insertAt === \"top\") {\n\t\tif (!lastStyleElementInsertedAtTop) {\n\t\t\ttarget.insertBefore(style, target.firstChild);\n\t\t} else if (lastStyleElementInsertedAtTop.nextSibling) {\n\t\t\ttarget.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);\n\t\t} else {\n\t\t\ttarget.appendChild(style);\n\t\t}\n\t\tstylesInsertedAtTop.push(style);\n\t} else if (options.insertAt === \"bottom\") {\n\t\ttarget.appendChild(style);\n\t} else {\n\t\tthrow new Error(\"Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.\");\n\t}\n}\n\nfunction removeStyleElement (style) {\n\tstyle.parentNode.removeChild(style);\n\n\tvar idx = stylesInsertedAtTop.indexOf(style);\n\n\tif(idx >= 0) {\n\t\tstylesInsertedAtTop.splice(idx, 1);\n\t}\n}\n\nfunction createStyleElement (options) {\n\tvar style = document.createElement(\"style\");\n\n\toptions.attrs.type = \"text/css\";\n\n\taddAttrs(style, options.attrs);\n\tinsertStyleElement(options, style);\n\n\treturn style;\n}\n\nfunction createLinkElement (options) {\n\tvar link = document.createElement(\"link\");\n\n\toptions.attrs.type = \"text/css\";\n\toptions.attrs.rel = \"stylesheet\";\n\n\taddAttrs(link, options.attrs);\n\tinsertStyleElement(options, link);\n\n\treturn link;\n}\n\nfunction addAttrs (el, attrs) {\n\tObject.keys(attrs).forEach(function (key) {\n\t\tel.setAttribute(key, attrs[key]);\n\t});\n}\n\nfunction addStyle (obj, options) {\n\tvar style, update, remove, result;\n\n\t// If a transform function was defined, run it on the css\n\tif (options.transform && obj.css) {\n\t result = options.transform(obj.css);\n\n\t if (result) {\n\t \t// If transform returns a value, use that instead of the original css.\n\t \t// This allows running runtime transformations on the css.\n\t \tobj.css = result;\n\t } else {\n\t \t// If the transform function returns a falsy value, don't add this css.\n\t \t// This allows conditional loading of css\n\t \treturn function() {\n\t \t\t// noop\n\t \t};\n\t }\n\t}\n\n\tif (options.singleton) {\n\t\tvar styleIndex = singletonCounter++;\n\n\t\tstyle = singleton || (singleton = createStyleElement(options));\n\n\t\tupdate = applyToSingletonTag.bind(null, style, styleIndex, false);\n\t\tremove = applyToSingletonTag.bind(null, style, styleIndex, true);\n\n\t} else if (\n\t\tobj.sourceMap &&\n\t\ttypeof URL === \"function\" &&\n\t\ttypeof URL.createObjectURL === \"function\" &&\n\t\ttypeof URL.revokeObjectURL === \"function\" &&\n\t\ttypeof Blob === \"function\" &&\n\t\ttypeof btoa === \"function\"\n\t) {\n\t\tstyle = createLinkElement(options);\n\t\tupdate = updateLink.bind(null, style, options);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\n\t\t\tif(style.href) URL.revokeObjectURL(style.href);\n\t\t};\n\t} else {\n\t\tstyle = createStyleElement(options);\n\t\tupdate = applyToTag.bind(null, style);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\t\t};\n\t}\n\n\tupdate(obj);\n\n\treturn function updateStyle (newObj) {\n\t\tif (newObj) {\n\t\t\tif (\n\t\t\t\tnewObj.css === obj.css &&\n\t\t\t\tnewObj.media === obj.media &&\n\t\t\t\tnewObj.sourceMap === obj.sourceMap\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdate(obj = newObj);\n\t\t} else {\n\t\t\tremove();\n\t\t}\n\t};\n}\n\nvar replaceText = (function () {\n\tvar textStore = [];\n\n\treturn function (index, replacement) {\n\t\ttextStore[index] = replacement;\n\n\t\treturn textStore.filter(Boolean).join('\\n');\n\t};\n})();\n\nfunction applyToSingletonTag (style, index, remove, obj) {\n\tvar css = remove ? \"\" : obj.css;\n\n\tif (style.styleSheet) {\n\t\tstyle.styleSheet.cssText = replaceText(index, css);\n\t} else {\n\t\tvar cssNode = document.createTextNode(css);\n\t\tvar childNodes = style.childNodes;\n\n\t\tif (childNodes[index]) style.removeChild(childNodes[index]);\n\n\t\tif (childNodes.length) {\n\t\t\tstyle.insertBefore(cssNode, childNodes[index]);\n\t\t} else {\n\t\t\tstyle.appendChild(cssNode);\n\t\t}\n\t}\n}\n\nfunction applyToTag (style, obj) {\n\tvar css = obj.css;\n\tvar media = obj.media;\n\n\tif(media) {\n\t\tstyle.setAttribute(\"media\", media)\n\t}\n\n\tif(style.styleSheet) {\n\t\tstyle.styleSheet.cssText = css;\n\t} else {\n\t\twhile(style.firstChild) {\n\t\t\tstyle.removeChild(style.firstChild);\n\t\t}\n\n\t\tstyle.appendChild(document.createTextNode(css));\n\t}\n}\n\nfunction updateLink (link, options, obj) {\n\tvar css = obj.css;\n\tvar sourceMap = obj.sourceMap;\n\n\t/*\n\t\tIf convertToAbsoluteUrls isn't defined, but sourcemaps are enabled\n\t\tand there is no publicPath defined then lets turn convertToAbsoluteUrls\n\t\ton by default. Otherwise default to the convertToAbsoluteUrls option\n\t\tdirectly\n\t*/\n\tvar autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;\n\n\tif (options.convertToAbsoluteUrls || autoFixUrls) {\n\t\tcss = fixUrls(css);\n\t}\n\n\tif (sourceMap) {\n\t\t// http://stackoverflow.com/a/26603875\n\t\tcss += \"\\n/*# sourceMappingURL=data:application/json;base64,\" + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + \" */\";\n\t}\n\n\tvar blob = new Blob([css], { type: \"text/css\" });\n\n\tvar oldSrc = link.href;\n\n\tlink.href = URL.createObjectURL(blob);\n\n\tif(oldSrc) URL.revokeObjectURL(oldSrc);\n}\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\n/**\n * When source maps are enabled, `style-loader` uses a link element with a data-uri to\n * embed the css on the page. This breaks all relative urls because now they are relative to a\n * bundle instead of the current page.\n *\n * One solution is to only use full urls, but that may be impossible.\n *\n * Instead, this function \"fixes\" the relative urls to be absolute according to the current page location.\n *\n * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.\n *\n */\n\nmodule.exports = function (css) {\n // get current location\n var location = typeof window !== \"undefined\" && window.location;\n\n if (!location) {\n throw new Error(\"fixUrls requires window.location\");\n }\n\n\t// blank or null?\n\tif (!css || typeof css !== \"string\") {\n\t return css;\n }\n\n var baseUrl = location.protocol + \"//\" + location.host;\n var currentDir = baseUrl + location.pathname.replace(/\\/[^\\/]*$/, \"/\");\n\n\t// convert each url(...)\n\t/*\n\tThis regular expression is just a way to recursively match brackets within\n\ta string.\n\n\t /url\\s*\\( = Match on the word \"url\" with any whitespace after it and then a parens\n\t ( = Start a capturing group\n\t (?: = Start a non-capturing group\n\t [^)(] = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t (?: = Start another non-capturing groups\n\t [^)(]+ = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t [^)(]* = Match anything that isn't a parentheses\n\t \\) = Match a end parentheses\n\t ) = End Group\n *\\) = Match anything and then a close parens\n ) = Close non-capturing group\n * = Match anything\n ) = Close capturing group\n\t \\) = Match a close parens\n\n\t /gi = Get all matches, not the first. Be case insensitive.\n\t */\n\tvar fixedCss = css.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi, function(fullMatch, origUrl) {\n\t\t// strip quotes (if they exist)\n\t\tvar unquotedOrigUrl = origUrl\n\t\t\t.trim()\n\t\t\t.replace(/^\"(.*)\"$/, function(o, $1){ return $1; })\n\t\t\t.replace(/^'(.*)'$/, function(o, $1){ return $1; });\n\n\t\t// already a full url? no change\n\t\tif (/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/)/i.test(unquotedOrigUrl)) {\n\t\t return fullMatch;\n\t\t}\n\n\t\t// convert the url to a full url\n\t\tvar newUrl;\n\n\t\tif (unquotedOrigUrl.indexOf(\"//\") === 0) {\n\t\t \t//TODO: should we add protocol?\n\t\t\tnewUrl = unquotedOrigUrl;\n\t\t} else if (unquotedOrigUrl.indexOf(\"/\") === 0) {\n\t\t\t// path should be relative to the base url\n\t\t\tnewUrl = baseUrl + unquotedOrigUrl; // already starts with '/'\n\t\t} else {\n\t\t\t// path should be relative to current directory\n\t\t\tnewUrl = currentDir + unquotedOrigUrl.replace(/^\\.\\//, \"\"); // Strip leading './'\n\t\t}\n\n\t\t// send back the fixed url(...)\n\t\treturn \"url(\" + JSON.stringify(newUrl) + \")\";\n\t});\n\n\t// send back the fixed css\n\treturn fixedCss;\n};\n\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=identityfusion.js.map\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/identityfusion/dist/identityfusion.js\n// module id = 0\n// module chunks = 1 2","/* global dallinger, console */\n/*jshint esversion: 6 */\n\nimport { DIFIInput } from 'identityfusion';\n\n$(document).ready(function() {\n\n // Initialize DIFI widget\n var $DIFI = $('input.DIFI-input'),\n spinner = dallinger.BusyForm();\n\n if ($DIFI.length) {\n var input = new DIFIInput(\n $DIFI.get(0),\n {\n groupLabel: $DIFI.attr('data-group-label'),\n groupImage: $DIFI.attr('data-group-image')\n }\n );\n }\n\n // Submit the questionnaire.\n $(\"#submit-questionnaire\").click(function() {\n console.log(\"Submitting questionnaire.\");\n var $elements = [$(\"form :input\"), $(this)],\n questionSubmission = dallinger.submitQuestionnaire(\"questionnaire\");\n\n spinner.freeze($elements);\n questionSubmission.done(dallinger.submitAssignment);\n questionSubmission.always(function () {\n spinner.unfreeze();\n });\n\n });\n\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/questionnaire.js\n// module id = 38\n// module chunks = 1"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 387feb8eadb9c5b23992?8f97","webpack:///./~/identityfusion/dist/identityfusion.js","webpack:///./dlgr/griduniverse/static/scripts/questionnaire.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA,2CAA2C,cAAc;;QAEzD;QACA;QACA;QACA;QACA;QACA;QACA;QACA,KAAK;QACL;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA;;;;;;;;AChEA;AACA,IAAI,IAAyD;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,cAAc;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,0BAA0B,EAAE;AAC/D,yCAAyC,eAAe;AACxD;AACA;AACA;AACA;AACA;AACA,8DAA8D,+DAA+D;AAC7H;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,gCAAgC,UAAU,EAAE;AAC5C;;AAEA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,QAAQ;AACpB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA,0DAA0D,cAAc;AACxE;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oCAAoC,KAAK;AACzC;;AAEA;AACA,2CAA2C,KAAK;AAChD;AACA;;AAEA;AACA;AACA;AACA;AACA,uCAAuC,mCAAmC;AAC1E;AACA,sCAAsC,6BAA6B;AACnE;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,wBAAwB;AACxE;;AAEA;AACA,gCAAgC,OAAO;AACvC,gCAAgC;AAChC,gCAAgC;AAChC,gCAAgC,OAAO;;AAEvC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,wCAAwC;AACpE;AACA;AACA;AACA;;;;AAIA,OAAO;AACP;AACA;;AAEA;AACA;;;AAGA;AACA,gCAAgC,6BAA6B,kBAAkB,wBAAwB,uBAAuB,yBAAyB,GAAG,oBAAoB,iBAAiB,yBAAyB,yBAAyB,gBAAgB,GAAG,2BAA2B,wBAAwB,wBAAwB,GAAG,iBAAiB,yBAAyB,gBAAgB,iBAAiB,eAAe,uBAAuB,kCAAkC,GAAG,cAAc,gDAAgD,6BAA6B,yBAAyB,mBAAmB,mBAAmB,2BAA2B,uBAAuB,yBAAyB,cAAc,aAAa,iBAAiB,wBAAwB,GAAG,uBAAuB,mBAAmB,uBAAuB,+BAA+B,GAAG,oBAAoB,mBAAmB,mBAAmB,2BAA2B,yBAAyB,gBAAgB,eAAe,uCAAuC,GAAG,iBAAiB,6BAA6B,mCAAmC,6BAA6B,yBAAyB,gBAAgB,uBAAuB,yBAAyB,eAAe,uCAAuC,iBAAiB,GAAG,uBAAuB,yBAAyB,gBAAgB,aAAa,wCAAwC,0BAA0B,GAAG;;AAEj9C;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gBAAgB;AACnD,IAAI;AACJ;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA,YAAY,oBAAoB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,oDAAoD,cAAc;;AAElE;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA,CAAC;;AAED;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,iBAAiB,mBAAmB;AACpC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,iBAAiB,sBAAsB;AACvC;;AAEA;AACA,mBAAmB,2BAA2B;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,mBAAmB;AACnC;AACA;;AAEA;AACA;;AAEA,iBAAiB,2BAA2B;AAC5C;AACA;;AAEA,QAAQ,uBAAuB;AAC/B;AACA;AACA,GAAG;AACH;;AAEA,iBAAiB,uBAAuB;AACxC;AACA;;AAEA,2BAA2B;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA;AACA,cAAc;;AAEd,kDAAkD,sBAAsB;AACxE;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD;AACvD;;AAEA,6BAA6B,mBAAmB;;AAEhD;;AAEA;;AAEA;AACA;;;AAGA,OAAO;AACP;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,WAAW,EAAE;AACrD,wCAAwC,WAAW,EAAE;;AAErD;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA,sCAAsC;AACtC,GAAG;AACH;AACA,8DAA8D;AAC9D;;AAEA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;;AAGA,OAAO;AACP;AACA,CAAC;AACD,0C;;;;;;;;AC57BA;AAAA;AAAA;AAAA;AACA;;AAE2C;;AAE3C;;AAEA;AACA;AACA;;AAEA;AACA,oBAAoB,yDAAS;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL,GAAG;;AAEH,CAAC","file":"scripts/dist/questionnaire.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 18);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 387feb8eadb9c5b23992","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"identityfusion\"] = factory();\n\telse\n\t\troot[\"identityfusion\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n// style-loader: Adds some css to the DOM by adding a <style> tag\n\n// load the styles\nvar content = __webpack_require__(3);\nif(typeof content === 'string') content = [[module.i, content, '']];\n// Prepare cssTransformation\nvar transform;\n\nvar options = {}\noptions.transform = transform\n// add the styles to the DOM\nvar update = __webpack_require__(5)(content, options);\nif(content.locals) module.exports = content.locals;\n// Hot Module Replacement\nif(false) {\n\t// When the styles change, update the <style> tags\n\tif(!content.locals) {\n\t\tmodule.hot.accept(\"!!./node_modules/css-loader/index.js!./styles.css\", function() {\n\t\t\tvar newContent = require(\"!!./node_modules/css-loader/index.js!./styles.css\");\n\t\t\tif(typeof newContent === 'string') newContent = [[module.id, newContent, '']];\n\t\t\tupdate(newContent);\n\t\t});\n\t}\n\t// When the module is disposed, remove the <style> tags\n\tmodule.hot.dispose(function() { update(); });\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the\n * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time\n * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,\n * the internal counter is reset)\n * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the throttled-function is executed.\n * @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),\n * schedule `callback` to execute after `delay` ms.\n *\n * @return {Function} A new, throttled, function.\n */\nmodule.exports = function ( delay, noTrailing, callback, debounceMode ) {\n\n\t// After wrapper has stopped being called, this timeout ensures that\n\t// `callback` is executed at the proper times in `throttle` and `end`\n\t// debounce modes.\n\tvar timeoutID;\n\n\t// Keep track of the last time `callback` was executed.\n\tvar lastExec = 0;\n\n\t// `noTrailing` defaults to falsy.\n\tif ( typeof noTrailing !== 'boolean' ) {\n\t\tdebounceMode = callback;\n\t\tcallback = noTrailing;\n\t\tnoTrailing = undefined;\n\t}\n\n\t// The `wrapper` function encapsulates all of the throttling / debouncing\n\t// functionality and when executed will limit the rate at which `callback`\n\t// is executed.\n\tfunction wrapper () {\n\n\t\tvar self = this;\n\t\tvar elapsed = Number(new Date()) - lastExec;\n\t\tvar args = arguments;\n\n\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\tfunction exec () {\n\t\t\tlastExec = Number(new Date());\n\t\t\tcallback.apply(self, args);\n\t\t}\n\n\t\t// If `debounceMode` is true (at begin) this is used to clear the flag\n\t\t// to allow future `callback` executions.\n\t\tfunction clear () {\n\t\t\ttimeoutID = undefined;\n\t\t}\n\n\t\tif ( debounceMode && !timeoutID ) {\n\t\t\t// Since `wrapper` is being called for the first time and\n\t\t\t// `debounceMode` is true (at begin), execute `callback`.\n\t\t\texec();\n\t\t}\n\n\t\t// Clear any existing timeout.\n\t\tif ( timeoutID ) {\n\t\t\tclearTimeout(timeoutID);\n\t\t}\n\n\t\tif ( debounceMode === undefined && elapsed > delay ) {\n\t\t\t// In throttle mode, if `delay` time has been exceeded, execute\n\t\t\t// `callback`.\n\t\t\texec();\n\n\t\t} else if ( noTrailing !== true ) {\n\t\t\t// In trailing throttle mode, since `delay` time has not been\n\t\t\t// exceeded, schedule `callback` to execute `delay` ms after most\n\t\t\t// recent execution.\n\t\t\t//\n\t\t\t// If `debounceMode` is true (at begin), schedule `clear` to execute\n\t\t\t// after `delay` ms.\n\t\t\t//\n\t\t\t// If `debounceMode` is false (at end), schedule `callback` to\n\t\t\t// execute after `delay` ms.\n\t\t\ttimeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n\t\t}\n\n\t}\n\n\t// Return the wrapper function.\n\treturn wrapper;\n\n};\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css__ = __webpack_require__(0);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__styles_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__styles_css__);\n\n\n\nfunction addButton(container, label, onclick) {\n // Add a button to a container.\n const button = document.createElement('button');\n button.setAttribute('type', 'button');\n button.className = 'button button-outline';\n button.innerHTML = label;\n button.addEventListener('click', onclick);\n container.appendChild(button);\n return button;\n}\n\nfunction calculateOverlap(d, r, R) {\n // Calculate the DIFI overlap.\n // d is the center-to-center spacing between the small and big circles.\n // r is the radius of the small circle.\n // R is the radius of the large circle.\n const x = ((d * d) + (r * r) - (R * R)) / (2 * d * r);\n const y = ((d * d) + (R * R) - (r * r)) / (2 * d * R);\n const z = (-d + r + R) * (d + r - R) * (d - r + R) * (d + r + R);\n const overlapArea = (r * r * Math.acos(x)) + (R * R * Math.acos(y)) - (Math.sqrt(z) / 2);\n if (d > r + R) {\n return 0;\n } else if (d < R - r) {\n return 100;\n }\n return 100 * (overlapArea / (Math.PI * r * r));\n}\n\nfunction outerLeft(el) {\n // Find the left offset of an element (including border)\n // relative to the page\n const rect = el.getBoundingClientRect();\n const left = rect.left + document.body.scrollLeft;\n return left - parseFloat(getComputedStyle(el)['border-left-width'], 10);\n}\n\nfunction outerRight(el) {\n // Find the right offset of an element (including border)\n // relative to the page\n return outerLeft(el) + el.offsetWidth;\n}\n\nclass DIFIInput {\n\n constructor(el, options = {}) {\n this.drag = __WEBPACK_IMPORTED_MODULE_0_throttle_debounce_throttle___default()(20, this.drag.bind(this));\n this.startDrag = this.startDrag.bind(this);\n this.endDrag = this.endDrag.bind(this);\n\n this.el = el;\n this.options = options;\n this.initializeDOM();\n this.update();\n }\n\n initializeDOM() {\n // Construct the widget.\n const name = this.el.getAttribute('name');\n this.el.setAttribute('name', `${name}_distance`);\n this.el.setAttribute('type', 'hidden');\n\n this.elOverlap = document.createElement('input');\n this.elOverlap.setAttribute('name', `${name}_overlap`);\n this.elOverlap.setAttribute('type', 'hidden');\n this.el.insertAdjacentElement('afterend', this.elOverlap);\n\n const elContent = document.createElement('div');\n elContent.className = 'DIFI';\n elContent.innerHTML = `\n <div class=\"DIFI-controls\"></div>\n <div class=\"DIFI-group\"><label>${this.options.groupLabel || 'Group'}</label></div>\n <div class=\"DIFI-range\">\n <div class=\"DIFI-me\"><label>${this.options.meLabel || 'Me'}</label></div>\n </div>\n `;\n this.me = elContent.querySelector('.DIFI-me');\n this.group = elContent.querySelector('.DIFI-group');\n this.elRange = elContent.querySelector('.DIFI-range');\n\n if (this.options.groupImage) {\n this.group.style.backgroundImage = `url(${this.options.groupImage})`;\n }\n\n const controls = elContent.querySelector('.DIFI-controls');\n addButton(controls, '◀◀', this.nudge.bind(this, -0.5));\n addButton(controls, '◀', this.nudge.bind(this, -0.1));\n addButton(controls, '▶', this.nudge.bind(this, 0.1));\n addButton(controls, '▶▶', this.nudge.bind(this, 0.5));\n\n this.el.insertAdjacentElement('beforebegin', elContent);\n\n this.me.addEventListener('mousedown', this.startDrag.bind(this));\n }\n\n startDrag(e) {\n // Start tracking mouse when clicked.\n e.preventDefault();\n e.stopPropagation();\n this.me.className = 'DIFI-me dragging';\n\n this.dragOrigLeft = parseFloat(getComputedStyle(this.me).left, 10);\n this.dragOrigX = e.pageX;\n document.addEventListener('mousemove', this.drag);\n document.addEventListener('mouseup', this.endDrag);\n }\n\n drag(e) {\n // Update position of Me while dragging.\n e.preventDefault();\n e.stopPropagation();\n if (this.dragOrigX === null) {\n return;\n }\n const deltaPixels = e.pageX - this.dragOrigX;\n this.nudgePixels(deltaPixels, this.dragOrigLeft);\n }\n\n endDrag() {\n // Stop tracking mouse when mouse released.\n this.me.className = 'DIFI-me';\n document.removeEventListener('mousemove', this.drag);\n document.removeEventListener('mouseup', this.endDrag);\n this.dragOrigX = null;\n this.dragOrigLeft = null;\n }\n\n update() {\n // Update distance and overlap values from current position.\n // Distance is based on difference in position:\n // - left circle separated from right circle: -100 to 0\n // - left circle just touching right circle: 0\n // - left circle overlapping right circle: 0 to 100\n // - left circle contained within right circle: 100 to 125\n // - left circle at the center of right circle: 125\n const R = this.group.offsetWidth / 2;\n const r = this.me.offsetWidth / 2;\n const mePos = outerLeft(this.me);\n const groupPos = outerLeft(this.group);\n const d = mePos - groupPos;\n let value = 100 + 50 * d / r;\n // Snap to center\n const elRange = this.me.parentNode;\n if (outerRight(elRange) - outerRight(this.me) < 2) {\n value = 125;\n }\n // Clip value to desired range (-100 to 125)\n value = Math.max(Math.min(Math.round(value * 1000) / 1000, 125), -100);\n this.el.setAttribute('value', value);\n\n // Compute overlap.\n const dCenterToCenter = (groupPos + R) - (mePos + r);\n const overlap = calculateOverlap(dCenterToCenter, r, R);\n this.elOverlap.setAttribute('value', overlap);\n }\n\n nudge(delta) {\n // Move by `delta` units (1 unit = radius of Me circle)\n const unit = this.me.offsetWidth / 2;\n const deltaPixels = delta * unit;\n this.nudgePixels(deltaPixels);\n }\n\n nudgePixels(delta, origLeft) {\n // Move by `delta` pixels\n // (relative to origLeft if specified, or to current position)\n let start = origLeft;\n if (start === undefined) {\n start = parseFloat(getComputedStyle(this.me).left, 10);\n }\n let finish = start + delta;\n if (finish < 0) {\n finish = 0;\n }\n if (finish > this.elRange.offsetWidth - this.me.offsetWidth) {\n finish = this.elRange.offsetWidth - this.me.offsetWidth;\n }\n this.me.style.left = `${finish / this.elRange.offsetWidth * 100}%`;\n this.update();\n }\n}\n/* harmony export (immutable) */ __webpack_exports__[\"DIFIInput\"] = DIFIInput;\n\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\nexports = module.exports = __webpack_require__(4)(undefined);\n// imports\n\n\n// module\nexports.push([module.i, \".DIFI {\\n border: solid 1px #ccc;\\n width: 100%;\\n margin: 10px auto;\\n padding-top: 40%;\\n position: relative;\\n}\\n\\n.DIFI-controls {\\n left: 10px;\\n position: absolute;\\n text-align: center;\\n top: 10px;\\n}\\n\\n.DIFI-controls button {\\n margin-right: 5px;\\n padding: 0 1.5rem;\\n}\\n\\n.DIFI-range {\\n position: absolute;\\n left: 10%;\\n right: 10%;\\n top: 55%;\\n padding-top: 20%;\\n transform: translateY(-50%);\\n}\\n\\n.DIFI-me {\\n background-color: rgba(255, 255, 255, .8);\\n border: solid 1px #000;\\n border-radius: 50%;\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n padding-top: 25%;\\n position: absolute;\\n left: 0;\\n top: 0;\\n width: 25%;\\n user-select: none;\\n}\\n\\n.DIFI-me.dragging {\\n cursor: move;\\n cursor: grabbing;\\n cursor: -webkit-grabbing;\\n}\\n\\n.DIFI-me label {\\n cursor: move;\\n cursor: grab;\\n cursor: -webkit-grab;\\n position: absolute;\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.DIFI-group {\\n background-color: #ccc;\\n background-position: 50% 50%;\\n background-size: cover;\\n border-radius: 50%;\\n left: 80%;\\n padding-top: 30%;\\n position: absolute;\\n top: 55%;\\n transform: translate(-50%, -50%);\\n width: 30%;\\n}\\n\\n.DIFI-group label {\\n position: absolute;\\n left: 50%;\\n top: 0;\\n transform: translate(-50%, -100%);\\n white-space: nowrap;\\n}\\n\", \"\"]);\n\n// exports\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\nmodule.exports = function(useSourceMap) {\n\tvar list = [];\n\n\t// return the list of modules as css string\n\tlist.toString = function toString() {\n\t\treturn this.map(function (item) {\n\t\t\tvar content = cssWithMappingToString(item, useSourceMap);\n\t\t\tif(item[2]) {\n\t\t\t\treturn \"@media \" + item[2] + \"{\" + content + \"}\";\n\t\t\t} else {\n\t\t\t\treturn content;\n\t\t\t}\n\t\t}).join(\"\");\n\t};\n\n\t// import a list of modules into the list\n\tlist.i = function(modules, mediaQuery) {\n\t\tif(typeof modules === \"string\")\n\t\t\tmodules = [[null, modules, \"\"]];\n\t\tvar alreadyImportedModules = {};\n\t\tfor(var i = 0; i < this.length; i++) {\n\t\t\tvar id = this[i][0];\n\t\t\tif(typeof id === \"number\")\n\t\t\t\talreadyImportedModules[id] = true;\n\t\t}\n\t\tfor(i = 0; i < modules.length; i++) {\n\t\t\tvar item = modules[i];\n\t\t\t// skip already imported module\n\t\t\t// this implementation is not 100% perfect for weird media query combinations\n\t\t\t// when a module is imported multiple times with different media queries.\n\t\t\t// I hope this will never occur (Hey this way we have smaller bundles)\n\t\t\tif(typeof item[0] !== \"number\" || !alreadyImportedModules[item[0]]) {\n\t\t\t\tif(mediaQuery && !item[2]) {\n\t\t\t\t\titem[2] = mediaQuery;\n\t\t\t\t} else if(mediaQuery) {\n\t\t\t\t\titem[2] = \"(\" + item[2] + \") and (\" + mediaQuery + \")\";\n\t\t\t\t}\n\t\t\t\tlist.push(item);\n\t\t\t}\n\t\t}\n\t};\n\treturn list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n\tvar content = item[1] || '';\n\tvar cssMapping = item[3];\n\tif (!cssMapping) {\n\t\treturn content;\n\t}\n\n\tif (useSourceMap && typeof btoa === 'function') {\n\t\tvar sourceMapping = toComment(cssMapping);\n\t\tvar sourceURLs = cssMapping.sources.map(function (source) {\n\t\t\treturn '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'\n\t\t});\n\n\t\treturn [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n\t}\n\n\treturn [content].join('\\n');\n}\n\n// Adapted from convert-source-map (MIT)\nfunction toComment(sourceMap) {\n\t// eslint-disable-next-line no-undef\n\tvar base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n\tvar data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;\n\n\treturn '/*# ' + data + ' */';\n}\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === \"undefined\") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(selector) {\n\t\tif (typeof memo[selector] === \"undefined\") {\n\t\t\tmemo[selector] = fn.call(this, selector);\n\t\t}\n\n\t\treturn memo[selector]\n\t};\n})(function (target) {\n\treturn document.querySelector(target)\n});\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = __webpack_require__(6);\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== \"undefined\" && DEBUG) {\n\t\tif (typeof document !== \"object\") throw new Error(\"The style-loader cannot be used in a non-browser environment\");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === \"object\" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>\n\t// tags it will allow on a page\n\tif (!options.singleton) options.singleton = isOldIE();\n\n\t// By default, add <style> tags to the <head> element\n\tif (!options.insertInto) options.insertInto = \"head\";\n\n\t// By default, add <style> tags to the bottom of the target\n\tif (!options.insertAt) options.insertAt = \"bottom\";\n\n\tvar styles = listToStyles(list, options);\n\n\taddStylesToDom(styles, options);\n\n\treturn function update (newList) {\n\t\tvar mayRemove = [];\n\n\t\tfor (var i = 0; i < styles.length; i++) {\n\t\t\tvar item = styles[i];\n\t\t\tvar domStyle = stylesInDom[item.id];\n\n\t\t\tdomStyle.refs--;\n\t\t\tmayRemove.push(domStyle);\n\t\t}\n\n\t\tif(newList) {\n\t\t\tvar newStyles = listToStyles(newList, options);\n\t\t\taddStylesToDom(newStyles, options);\n\t\t}\n\n\t\tfor (var i = 0; i < mayRemove.length; i++) {\n\t\t\tvar domStyle = mayRemove[i];\n\n\t\t\tif(domStyle.refs === 0) {\n\t\t\t\tfor (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();\n\n\t\t\t\tdelete stylesInDom[domStyle.id];\n\t\t\t}\n\t\t}\n\t};\n};\n\nfunction addStylesToDom (styles, options) {\n\tfor (var i = 0; i < styles.length; i++) {\n\t\tvar item = styles[i];\n\t\tvar domStyle = stylesInDom[item.id];\n\n\t\tif(domStyle) {\n\t\t\tdomStyle.refs++;\n\n\t\t\tfor(var j = 0; j < domStyle.parts.length; j++) {\n\t\t\t\tdomStyle.parts[j](item.parts[j]);\n\t\t\t}\n\n\t\t\tfor(; j < item.parts.length; j++) {\n\t\t\t\tdomStyle.parts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\t\t} else {\n\t\t\tvar parts = [];\n\n\t\t\tfor(var j = 0; j < item.parts.length; j++) {\n\t\t\t\tparts.push(addStyle(item.parts[j], options));\n\t\t\t}\n\n\t\t\tstylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};\n\t\t}\n\t}\n}\n\nfunction listToStyles (list, options) {\n\tvar styles = [];\n\tvar newStyles = {};\n\n\tfor (var i = 0; i < list.length; i++) {\n\t\tvar item = list[i];\n\t\tvar id = options.base ? item[0] + options.base : item[0];\n\t\tvar css = item[1];\n\t\tvar media = item[2];\n\t\tvar sourceMap = item[3];\n\t\tvar part = {css: css, media: media, sourceMap: sourceMap};\n\n\t\tif(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});\n\t\telse newStyles[id].parts.push(part);\n\t}\n\n\treturn styles;\n}\n\nfunction insertStyleElement (options, style) {\n\tvar target = getElement(options.insertInto)\n\n\tif (!target) {\n\t\tthrow new Error(\"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.\");\n\t}\n\n\tvar lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];\n\n\tif (options.insertAt === \"top\") {\n\t\tif (!lastStyleElementInsertedAtTop) {\n\t\t\ttarget.insertBefore(style, target.firstChild);\n\t\t} else if (lastStyleElementInsertedAtTop.nextSibling) {\n\t\t\ttarget.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);\n\t\t} else {\n\t\t\ttarget.appendChild(style);\n\t\t}\n\t\tstylesInsertedAtTop.push(style);\n\t} else if (options.insertAt === \"bottom\") {\n\t\ttarget.appendChild(style);\n\t} else {\n\t\tthrow new Error(\"Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.\");\n\t}\n}\n\nfunction removeStyleElement (style) {\n\tstyle.parentNode.removeChild(style);\n\n\tvar idx = stylesInsertedAtTop.indexOf(style);\n\n\tif(idx >= 0) {\n\t\tstylesInsertedAtTop.splice(idx, 1);\n\t}\n}\n\nfunction createStyleElement (options) {\n\tvar style = document.createElement(\"style\");\n\n\toptions.attrs.type = \"text/css\";\n\n\taddAttrs(style, options.attrs);\n\tinsertStyleElement(options, style);\n\n\treturn style;\n}\n\nfunction createLinkElement (options) {\n\tvar link = document.createElement(\"link\");\n\n\toptions.attrs.type = \"text/css\";\n\toptions.attrs.rel = \"stylesheet\";\n\n\taddAttrs(link, options.attrs);\n\tinsertStyleElement(options, link);\n\n\treturn link;\n}\n\nfunction addAttrs (el, attrs) {\n\tObject.keys(attrs).forEach(function (key) {\n\t\tel.setAttribute(key, attrs[key]);\n\t});\n}\n\nfunction addStyle (obj, options) {\n\tvar style, update, remove, result;\n\n\t// If a transform function was defined, run it on the css\n\tif (options.transform && obj.css) {\n\t result = options.transform(obj.css);\n\n\t if (result) {\n\t \t// If transform returns a value, use that instead of the original css.\n\t \t// This allows running runtime transformations on the css.\n\t \tobj.css = result;\n\t } else {\n\t \t// If the transform function returns a falsy value, don't add this css.\n\t \t// This allows conditional loading of css\n\t \treturn function() {\n\t \t\t// noop\n\t \t};\n\t }\n\t}\n\n\tif (options.singleton) {\n\t\tvar styleIndex = singletonCounter++;\n\n\t\tstyle = singleton || (singleton = createStyleElement(options));\n\n\t\tupdate = applyToSingletonTag.bind(null, style, styleIndex, false);\n\t\tremove = applyToSingletonTag.bind(null, style, styleIndex, true);\n\n\t} else if (\n\t\tobj.sourceMap &&\n\t\ttypeof URL === \"function\" &&\n\t\ttypeof URL.createObjectURL === \"function\" &&\n\t\ttypeof URL.revokeObjectURL === \"function\" &&\n\t\ttypeof Blob === \"function\" &&\n\t\ttypeof btoa === \"function\"\n\t) {\n\t\tstyle = createLinkElement(options);\n\t\tupdate = updateLink.bind(null, style, options);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\n\t\t\tif(style.href) URL.revokeObjectURL(style.href);\n\t\t};\n\t} else {\n\t\tstyle = createStyleElement(options);\n\t\tupdate = applyToTag.bind(null, style);\n\t\tremove = function () {\n\t\t\tremoveStyleElement(style);\n\t\t};\n\t}\n\n\tupdate(obj);\n\n\treturn function updateStyle (newObj) {\n\t\tif (newObj) {\n\t\t\tif (\n\t\t\t\tnewObj.css === obj.css &&\n\t\t\t\tnewObj.media === obj.media &&\n\t\t\t\tnewObj.sourceMap === obj.sourceMap\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdate(obj = newObj);\n\t\t} else {\n\t\t\tremove();\n\t\t}\n\t};\n}\n\nvar replaceText = (function () {\n\tvar textStore = [];\n\n\treturn function (index, replacement) {\n\t\ttextStore[index] = replacement;\n\n\t\treturn textStore.filter(Boolean).join('\\n');\n\t};\n})();\n\nfunction applyToSingletonTag (style, index, remove, obj) {\n\tvar css = remove ? \"\" : obj.css;\n\n\tif (style.styleSheet) {\n\t\tstyle.styleSheet.cssText = replaceText(index, css);\n\t} else {\n\t\tvar cssNode = document.createTextNode(css);\n\t\tvar childNodes = style.childNodes;\n\n\t\tif (childNodes[index]) style.removeChild(childNodes[index]);\n\n\t\tif (childNodes.length) {\n\t\t\tstyle.insertBefore(cssNode, childNodes[index]);\n\t\t} else {\n\t\t\tstyle.appendChild(cssNode);\n\t\t}\n\t}\n}\n\nfunction applyToTag (style, obj) {\n\tvar css = obj.css;\n\tvar media = obj.media;\n\n\tif(media) {\n\t\tstyle.setAttribute(\"media\", media)\n\t}\n\n\tif(style.styleSheet) {\n\t\tstyle.styleSheet.cssText = css;\n\t} else {\n\t\twhile(style.firstChild) {\n\t\t\tstyle.removeChild(style.firstChild);\n\t\t}\n\n\t\tstyle.appendChild(document.createTextNode(css));\n\t}\n}\n\nfunction updateLink (link, options, obj) {\n\tvar css = obj.css;\n\tvar sourceMap = obj.sourceMap;\n\n\t/*\n\t\tIf convertToAbsoluteUrls isn't defined, but sourcemaps are enabled\n\t\tand there is no publicPath defined then lets turn convertToAbsoluteUrls\n\t\ton by default. Otherwise default to the convertToAbsoluteUrls option\n\t\tdirectly\n\t*/\n\tvar autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;\n\n\tif (options.convertToAbsoluteUrls || autoFixUrls) {\n\t\tcss = fixUrls(css);\n\t}\n\n\tif (sourceMap) {\n\t\t// http://stackoverflow.com/a/26603875\n\t\tcss += \"\\n/*# sourceMappingURL=data:application/json;base64,\" + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + \" */\";\n\t}\n\n\tvar blob = new Blob([css], { type: \"text/css\" });\n\n\tvar oldSrc = link.href;\n\n\tlink.href = URL.createObjectURL(blob);\n\n\tif(oldSrc) URL.revokeObjectURL(oldSrc);\n}\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\n/**\n * When source maps are enabled, `style-loader` uses a link element with a data-uri to\n * embed the css on the page. This breaks all relative urls because now they are relative to a\n * bundle instead of the current page.\n *\n * One solution is to only use full urls, but that may be impossible.\n *\n * Instead, this function \"fixes\" the relative urls to be absolute according to the current page location.\n *\n * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.\n *\n */\n\nmodule.exports = function (css) {\n // get current location\n var location = typeof window !== \"undefined\" && window.location;\n\n if (!location) {\n throw new Error(\"fixUrls requires window.location\");\n }\n\n\t// blank or null?\n\tif (!css || typeof css !== \"string\") {\n\t return css;\n }\n\n var baseUrl = location.protocol + \"//\" + location.host;\n var currentDir = baseUrl + location.pathname.replace(/\\/[^\\/]*$/, \"/\");\n\n\t// convert each url(...)\n\t/*\n\tThis regular expression is just a way to recursively match brackets within\n\ta string.\n\n\t /url\\s*\\( = Match on the word \"url\" with any whitespace after it and then a parens\n\t ( = Start a capturing group\n\t (?: = Start a non-capturing group\n\t [^)(] = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t (?: = Start another non-capturing groups\n\t [^)(]+ = Match anything that isn't a parentheses\n\t | = OR\n\t \\( = Match a start parentheses\n\t [^)(]* = Match anything that isn't a parentheses\n\t \\) = Match a end parentheses\n\t ) = End Group\n *\\) = Match anything and then a close parens\n ) = Close non-capturing group\n * = Match anything\n ) = Close capturing group\n\t \\) = Match a close parens\n\n\t /gi = Get all matches, not the first. Be case insensitive.\n\t */\n\tvar fixedCss = css.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi, function(fullMatch, origUrl) {\n\t\t// strip quotes (if they exist)\n\t\tvar unquotedOrigUrl = origUrl\n\t\t\t.trim()\n\t\t\t.replace(/^\"(.*)\"$/, function(o, $1){ return $1; })\n\t\t\t.replace(/^'(.*)'$/, function(o, $1){ return $1; });\n\n\t\t// already a full url? no change\n\t\tif (/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/)/i.test(unquotedOrigUrl)) {\n\t\t return fullMatch;\n\t\t}\n\n\t\t// convert the url to a full url\n\t\tvar newUrl;\n\n\t\tif (unquotedOrigUrl.indexOf(\"//\") === 0) {\n\t\t \t//TODO: should we add protocol?\n\t\t\tnewUrl = unquotedOrigUrl;\n\t\t} else if (unquotedOrigUrl.indexOf(\"/\") === 0) {\n\t\t\t// path should be relative to the base url\n\t\t\tnewUrl = baseUrl + unquotedOrigUrl; // already starts with '/'\n\t\t} else {\n\t\t\t// path should be relative to current directory\n\t\t\tnewUrl = currentDir + unquotedOrigUrl.replace(/^\\.\\//, \"\"); // Strip leading './'\n\t\t}\n\n\t\t// send back the fixed url(...)\n\t\treturn \"url(\" + JSON.stringify(newUrl) + \")\";\n\t});\n\n\t// send back the fixed css\n\treturn fixedCss;\n};\n\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=identityfusion.js.map\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/identityfusion/dist/identityfusion.js\n// module id = 0\n// module chunks = 1 2","/* global dallinger, console */\n/*jshint esversion: 6 */\n\nimport { DIFIInput } from 'identityfusion';\n\n$(document).ready(function() {\n\n // Initialize DIFI widget\n var $DIFI = $('input.DIFI-input'),\n spinner = dallinger.BusyForm();\n\n if ($DIFI.length) {\n var input = new DIFIInput(\n $DIFI.get(0),\n {\n groupLabel: $DIFI.attr('data-group-label'),\n groupImage: $DIFI.attr('data-group-image')\n }\n );\n }\n\n // Submit the questionnaire.\n $(\"#submit-questionnaire\").click(function() {\n console.log(\"Submitting questionnaire.\");\n var $elements = [$(\"form :input\"), $(this)],\n questionSubmission = dallinger.submitQuestionnaire(\"questionnaire\");\n\n spinner.freeze($elements);\n questionSubmission.done(dallinger.submitAssignment);\n questionSubmission.always(function () {\n spinner.unfreeze();\n });\n\n });\n\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./dlgr/griduniverse/static/scripts/questionnaire.js\n// module id = 18\n// module chunks = 1"],"sourceRoot":""} \ No newline at end of file