OSDN Git Service

feat: add lock page
[bytom/Byone.git] / js / content.js
1 // [AIV_SHORT]  Build version: 2.2.0 - Thursday, June 4th, 2020, 2:31:20 PM  
2  /******/ (function(modules) { // webpackBootstrap
3 /******/        // The module cache
4 /******/        var installedModules = {};
5 /******/
6 /******/        // The require function
7 /******/        function __webpack_require__(moduleId) {
8 /******/
9 /******/                // Check if module is in cache
10 /******/                if(installedModules[moduleId]) {
11 /******/                        return installedModules[moduleId].exports;
12 /******/                }
13 /******/                // Create a new module (and put it into the cache)
14 /******/                var module = installedModules[moduleId] = {
15 /******/                        i: moduleId,
16 /******/                        l: false,
17 /******/                        exports: {}
18 /******/                };
19 /******/
20 /******/                // Execute the module function
21 /******/                modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22 /******/
23 /******/                // Flag the module as loaded
24 /******/                module.l = true;
25 /******/
26 /******/                // Return the exports of the module
27 /******/                return module.exports;
28 /******/        }
29 /******/
30 /******/
31 /******/        // expose the modules object (__webpack_modules__)
32 /******/        __webpack_require__.m = modules;
33 /******/
34 /******/        // expose the module cache
35 /******/        __webpack_require__.c = installedModules;
36 /******/
37 /******/        // define getter function for harmony exports
38 /******/        __webpack_require__.d = function(exports, name, getter) {
39 /******/                if(!__webpack_require__.o(exports, name)) {
40 /******/                        Object.defineProperty(exports, name, {
41 /******/                                configurable: false,
42 /******/                                enumerable: true,
43 /******/                                get: getter
44 /******/                        });
45 /******/                }
46 /******/        };
47 /******/
48 /******/        // getDefaultExport function for compatibility with non-harmony modules
49 /******/        __webpack_require__.n = function(module) {
50 /******/                var getter = module && module.__esModule ?
51 /******/                        function getDefault() { return module['default']; } :
52 /******/                        function getModuleExports() { return module; };
53 /******/                __webpack_require__.d(getter, 'a', getter);
54 /******/                return getter;
55 /******/        };
56 /******/
57 /******/        // Object.prototype.hasOwnProperty.call
58 /******/        __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
59 /******/
60 /******/        // __webpack_public_path__
61 /******/        __webpack_require__.p = "/";
62 /******/
63 /******/        // Load entry module and return exports
64 /******/        return __webpack_require__(__webpack_require__.s = 567);
65 /******/ })
66 /************************************************************************/
67 /******/ ([
68 /* 0 */,
69 /* 1 */
70 /***/ (function(module, exports) {
71
72 if (typeof Object.create === 'function') {
73   // implementation from standard node.js 'util' module
74   module.exports = function inherits(ctor, superCtor) {
75     ctor.super_ = superCtor
76     ctor.prototype = Object.create(superCtor.prototype, {
77       constructor: {
78         value: ctor,
79         enumerable: false,
80         writable: true,
81         configurable: true
82       }
83     });
84   };
85 } else {
86   // old school shim for old browsers
87   module.exports = function inherits(ctor, superCtor) {
88     ctor.super_ = superCtor
89     var TempCtor = function () {}
90     TempCtor.prototype = superCtor.prototype
91     ctor.prototype = new TempCtor()
92     ctor.prototype.constructor = ctor
93   }
94 }
95
96
97 /***/ }),
98 /* 2 */
99 /***/ (function(module, exports, __webpack_require__) {
100
101 /* eslint-disable node/no-deprecated-api */
102 var buffer = __webpack_require__(3)
103 var Buffer = buffer.Buffer
104
105 // alternative to using Object.keys for old browsers
106 function copyProps (src, dst) {
107   for (var key in src) {
108     dst[key] = src[key]
109   }
110 }
111 if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
112   module.exports = buffer
113 } else {
114   // Copy properties from require('buffer')
115   copyProps(buffer, exports)
116   exports.Buffer = SafeBuffer
117 }
118
119 function SafeBuffer (arg, encodingOrOffset, length) {
120   return Buffer(arg, encodingOrOffset, length)
121 }
122
123 // Copy static methods from Buffer
124 copyProps(Buffer, SafeBuffer)
125
126 SafeBuffer.from = function (arg, encodingOrOffset, length) {
127   if (typeof arg === 'number') {
128     throw new TypeError('Argument must not be a number')
129   }
130   return Buffer(arg, encodingOrOffset, length)
131 }
132
133 SafeBuffer.alloc = function (size, fill, encoding) {
134   if (typeof size !== 'number') {
135     throw new TypeError('Argument must be a number')
136   }
137   var buf = Buffer(size)
138   if (fill !== undefined) {
139     if (typeof encoding === 'string') {
140       buf.fill(fill, encoding)
141     } else {
142       buf.fill(fill)
143     }
144   } else {
145     buf.fill(0)
146   }
147   return buf
148 }
149
150 SafeBuffer.allocUnsafe = function (size) {
151   if (typeof size !== 'number') {
152     throw new TypeError('Argument must be a number')
153   }
154   return Buffer(size)
155 }
156
157 SafeBuffer.allocUnsafeSlow = function (size) {
158   if (typeof size !== 'number') {
159     throw new TypeError('Argument must be a number')
160   }
161   return buffer.SlowBuffer(size)
162 }
163
164
165 /***/ }),
166 /* 3 */
167 /***/ (function(module, exports, __webpack_require__) {
168
169 "use strict";
170 /* WEBPACK VAR INJECTION */(function(global) {/*!
171  * The buffer module from node.js, for the browser.
172  *
173  * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
174  * @license  MIT
175  */
176 /* eslint-disable no-proto */
177
178
179
180 var base64 = __webpack_require__(175)
181 var ieee754 = __webpack_require__(176)
182 var isArray = __webpack_require__(92)
183
184 exports.Buffer = Buffer
185 exports.SlowBuffer = SlowBuffer
186 exports.INSPECT_MAX_BYTES = 50
187
188 /**
189  * If `Buffer.TYPED_ARRAY_SUPPORT`:
190  *   === true    Use Uint8Array implementation (fastest)
191  *   === false   Use Object implementation (most compatible, even IE6)
192  *
193  * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
194  * Opera 11.6+, iOS 4.2+.
195  *
196  * Due to various browser bugs, sometimes the Object implementation will be used even
197  * when the browser supports typed arrays.
198  *
199  * Note:
200  *
201  *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
202  *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
203  *
204  *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
205  *
206  *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
207  *     incorrect length in some situations.
208
209  * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
210  * get the Object implementation, which is slower but behaves correctly.
211  */
212 Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
213   ? global.TYPED_ARRAY_SUPPORT
214   : typedArraySupport()
215
216 /*
217  * Export kMaxLength after typed array support is determined.
218  */
219 exports.kMaxLength = kMaxLength()
220
221 function typedArraySupport () {
222   try {
223     var arr = new Uint8Array(1)
224     arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
225     return arr.foo() === 42 && // typed array instances can be augmented
226         typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
227         arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
228   } catch (e) {
229     return false
230   }
231 }
232
233 function kMaxLength () {
234   return Buffer.TYPED_ARRAY_SUPPORT
235     ? 0x7fffffff
236     : 0x3fffffff
237 }
238
239 function createBuffer (that, length) {
240   if (kMaxLength() < length) {
241     throw new RangeError('Invalid typed array length')
242   }
243   if (Buffer.TYPED_ARRAY_SUPPORT) {
244     // Return an augmented `Uint8Array` instance, for best performance
245     that = new Uint8Array(length)
246     that.__proto__ = Buffer.prototype
247   } else {
248     // Fallback: Return an object instance of the Buffer class
249     if (that === null) {
250       that = new Buffer(length)
251     }
252     that.length = length
253   }
254
255   return that
256 }
257
258 /**
259  * The Buffer constructor returns instances of `Uint8Array` that have their
260  * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
261  * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
262  * and the `Uint8Array` methods. Square bracket notation works as expected -- it
263  * returns a single octet.
264  *
265  * The `Uint8Array` prototype remains unmodified.
266  */
267
268 function Buffer (arg, encodingOrOffset, length) {
269   if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
270     return new Buffer(arg, encodingOrOffset, length)
271   }
272
273   // Common case.
274   if (typeof arg === 'number') {
275     if (typeof encodingOrOffset === 'string') {
276       throw new Error(
277         'If encoding is specified then the first argument must be a string'
278       )
279     }
280     return allocUnsafe(this, arg)
281   }
282   return from(this, arg, encodingOrOffset, length)
283 }
284
285 Buffer.poolSize = 8192 // not used by this implementation
286
287 // TODO: Legacy, not needed anymore. Remove in next major version.
288 Buffer._augment = function (arr) {
289   arr.__proto__ = Buffer.prototype
290   return arr
291 }
292
293 function from (that, value, encodingOrOffset, length) {
294   if (typeof value === 'number') {
295     throw new TypeError('"value" argument must not be a number')
296   }
297
298   if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
299     return fromArrayBuffer(that, value, encodingOrOffset, length)
300   }
301
302   if (typeof value === 'string') {
303     return fromString(that, value, encodingOrOffset)
304   }
305
306   return fromObject(that, value)
307 }
308
309 /**
310  * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
311  * if value is a number.
312  * Buffer.from(str[, encoding])
313  * Buffer.from(array)
314  * Buffer.from(buffer)
315  * Buffer.from(arrayBuffer[, byteOffset[, length]])
316  **/
317 Buffer.from = function (value, encodingOrOffset, length) {
318   return from(null, value, encodingOrOffset, length)
319 }
320
321 if (Buffer.TYPED_ARRAY_SUPPORT) {
322   Buffer.prototype.__proto__ = Uint8Array.prototype
323   Buffer.__proto__ = Uint8Array
324   if (typeof Symbol !== 'undefined' && Symbol.species &&
325       Buffer[Symbol.species] === Buffer) {
326     // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
327     Object.defineProperty(Buffer, Symbol.species, {
328       value: null,
329       configurable: true
330     })
331   }
332 }
333
334 function assertSize (size) {
335   if (typeof size !== 'number') {
336     throw new TypeError('"size" argument must be a number')
337   } else if (size < 0) {
338     throw new RangeError('"size" argument must not be negative')
339   }
340 }
341
342 function alloc (that, size, fill, encoding) {
343   assertSize(size)
344   if (size <= 0) {
345     return createBuffer(that, size)
346   }
347   if (fill !== undefined) {
348     // Only pay attention to encoding if it's a string. This
349     // prevents accidentally sending in a number that would
350     // be interpretted as a start offset.
351     return typeof encoding === 'string'
352       ? createBuffer(that, size).fill(fill, encoding)
353       : createBuffer(that, size).fill(fill)
354   }
355   return createBuffer(that, size)
356 }
357
358 /**
359  * Creates a new filled Buffer instance.
360  * alloc(size[, fill[, encoding]])
361  **/
362 Buffer.alloc = function (size, fill, encoding) {
363   return alloc(null, size, fill, encoding)
364 }
365
366 function allocUnsafe (that, size) {
367   assertSize(size)
368   that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
369   if (!Buffer.TYPED_ARRAY_SUPPORT) {
370     for (var i = 0; i < size; ++i) {
371       that[i] = 0
372     }
373   }
374   return that
375 }
376
377 /**
378  * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
379  * */
380 Buffer.allocUnsafe = function (size) {
381   return allocUnsafe(null, size)
382 }
383 /**
384  * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
385  */
386 Buffer.allocUnsafeSlow = function (size) {
387   return allocUnsafe(null, size)
388 }
389
390 function fromString (that, string, encoding) {
391   if (typeof encoding !== 'string' || encoding === '') {
392     encoding = 'utf8'
393   }
394
395   if (!Buffer.isEncoding(encoding)) {
396     throw new TypeError('"encoding" must be a valid string encoding')
397   }
398
399   var length = byteLength(string, encoding) | 0
400   that = createBuffer(that, length)
401
402   var actual = that.write(string, encoding)
403
404   if (actual !== length) {
405     // Writing a hex string, for example, that contains invalid characters will
406     // cause everything after the first invalid character to be ignored. (e.g.
407     // 'abxxcd' will be treated as 'ab')
408     that = that.slice(0, actual)
409   }
410
411   return that
412 }
413
414 function fromArrayLike (that, array) {
415   var length = array.length < 0 ? 0 : checked(array.length) | 0
416   that = createBuffer(that, length)
417   for (var i = 0; i < length; i += 1) {
418     that[i] = array[i] & 255
419   }
420   return that
421 }
422
423 function fromArrayBuffer (that, array, byteOffset, length) {
424   array.byteLength // this throws if `array` is not a valid ArrayBuffer
425
426   if (byteOffset < 0 || array.byteLength < byteOffset) {
427     throw new RangeError('\'offset\' is out of bounds')
428   }
429
430   if (array.byteLength < byteOffset + (length || 0)) {
431     throw new RangeError('\'length\' is out of bounds')
432   }
433
434   if (byteOffset === undefined && length === undefined) {
435     array = new Uint8Array(array)
436   } else if (length === undefined) {
437     array = new Uint8Array(array, byteOffset)
438   } else {
439     array = new Uint8Array(array, byteOffset, length)
440   }
441
442   if (Buffer.TYPED_ARRAY_SUPPORT) {
443     // Return an augmented `Uint8Array` instance, for best performance
444     that = array
445     that.__proto__ = Buffer.prototype
446   } else {
447     // Fallback: Return an object instance of the Buffer class
448     that = fromArrayLike(that, array)
449   }
450   return that
451 }
452
453 function fromObject (that, obj) {
454   if (Buffer.isBuffer(obj)) {
455     var len = checked(obj.length) | 0
456     that = createBuffer(that, len)
457
458     if (that.length === 0) {
459       return that
460     }
461
462     obj.copy(that, 0, 0, len)
463     return that
464   }
465
466   if (obj) {
467     if ((typeof ArrayBuffer !== 'undefined' &&
468         obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
469       if (typeof obj.length !== 'number' || isnan(obj.length)) {
470         return createBuffer(that, 0)
471       }
472       return fromArrayLike(that, obj)
473     }
474
475     if (obj.type === 'Buffer' && isArray(obj.data)) {
476       return fromArrayLike(that, obj.data)
477     }
478   }
479
480   throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
481 }
482
483 function checked (length) {
484   // Note: cannot use `length < kMaxLength()` here because that fails when
485   // length is NaN (which is otherwise coerced to zero.)
486   if (length >= kMaxLength()) {
487     throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
488                          'size: 0x' + kMaxLength().toString(16) + ' bytes')
489   }
490   return length | 0
491 }
492
493 function SlowBuffer (length) {
494   if (+length != length) { // eslint-disable-line eqeqeq
495     length = 0
496   }
497   return Buffer.alloc(+length)
498 }
499
500 Buffer.isBuffer = function isBuffer (b) {
501   return !!(b != null && b._isBuffer)
502 }
503
504 Buffer.compare = function compare (a, b) {
505   if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
506     throw new TypeError('Arguments must be Buffers')
507   }
508
509   if (a === b) return 0
510
511   var x = a.length
512   var y = b.length
513
514   for (var i = 0, len = Math.min(x, y); i < len; ++i) {
515     if (a[i] !== b[i]) {
516       x = a[i]
517       y = b[i]
518       break
519     }
520   }
521
522   if (x < y) return -1
523   if (y < x) return 1
524   return 0
525 }
526
527 Buffer.isEncoding = function isEncoding (encoding) {
528   switch (String(encoding).toLowerCase()) {
529     case 'hex':
530     case 'utf8':
531     case 'utf-8':
532     case 'ascii':
533     case 'latin1':
534     case 'binary':
535     case 'base64':
536     case 'ucs2':
537     case 'ucs-2':
538     case 'utf16le':
539     case 'utf-16le':
540       return true
541     default:
542       return false
543   }
544 }
545
546 Buffer.concat = function concat (list, length) {
547   if (!isArray(list)) {
548     throw new TypeError('"list" argument must be an Array of Buffers')
549   }
550
551   if (list.length === 0) {
552     return Buffer.alloc(0)
553   }
554
555   var i
556   if (length === undefined) {
557     length = 0
558     for (i = 0; i < list.length; ++i) {
559       length += list[i].length
560     }
561   }
562
563   var buffer = Buffer.allocUnsafe(length)
564   var pos = 0
565   for (i = 0; i < list.length; ++i) {
566     var buf = list[i]
567     if (!Buffer.isBuffer(buf)) {
568       throw new TypeError('"list" argument must be an Array of Buffers')
569     }
570     buf.copy(buffer, pos)
571     pos += buf.length
572   }
573   return buffer
574 }
575
576 function byteLength (string, encoding) {
577   if (Buffer.isBuffer(string)) {
578     return string.length
579   }
580   if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
581       (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
582     return string.byteLength
583   }
584   if (typeof string !== 'string') {
585     string = '' + string
586   }
587
588   var len = string.length
589   if (len === 0) return 0
590
591   // Use a for loop to avoid recursion
592   var loweredCase = false
593   for (;;) {
594     switch (encoding) {
595       case 'ascii':
596       case 'latin1':
597       case 'binary':
598         return len
599       case 'utf8':
600       case 'utf-8':
601       case undefined:
602         return utf8ToBytes(string).length
603       case 'ucs2':
604       case 'ucs-2':
605       case 'utf16le':
606       case 'utf-16le':
607         return len * 2
608       case 'hex':
609         return len >>> 1
610       case 'base64':
611         return base64ToBytes(string).length
612       default:
613         if (loweredCase) return utf8ToBytes(string).length // assume utf8
614         encoding = ('' + encoding).toLowerCase()
615         loweredCase = true
616     }
617   }
618 }
619 Buffer.byteLength = byteLength
620
621 function slowToString (encoding, start, end) {
622   var loweredCase = false
623
624   // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
625   // property of a typed array.
626
627   // This behaves neither like String nor Uint8Array in that we set start/end
628   // to their upper/lower bounds if the value passed is out of range.
629   // undefined is handled specially as per ECMA-262 6th Edition,
630   // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
631   if (start === undefined || start < 0) {
632     start = 0
633   }
634   // Return early if start > this.length. Done here to prevent potential uint32
635   // coercion fail below.
636   if (start > this.length) {
637     return ''
638   }
639
640   if (end === undefined || end > this.length) {
641     end = this.length
642   }
643
644   if (end <= 0) {
645     return ''
646   }
647
648   // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
649   end >>>= 0
650   start >>>= 0
651
652   if (end <= start) {
653     return ''
654   }
655
656   if (!encoding) encoding = 'utf8'
657
658   while (true) {
659     switch (encoding) {
660       case 'hex':
661         return hexSlice(this, start, end)
662
663       case 'utf8':
664       case 'utf-8':
665         return utf8Slice(this, start, end)
666
667       case 'ascii':
668         return asciiSlice(this, start, end)
669
670       case 'latin1':
671       case 'binary':
672         return latin1Slice(this, start, end)
673
674       case 'base64':
675         return base64Slice(this, start, end)
676
677       case 'ucs2':
678       case 'ucs-2':
679       case 'utf16le':
680       case 'utf-16le':
681         return utf16leSlice(this, start, end)
682
683       default:
684         if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
685         encoding = (encoding + '').toLowerCase()
686         loweredCase = true
687     }
688   }
689 }
690
691 // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
692 // Buffer instances.
693 Buffer.prototype._isBuffer = true
694
695 function swap (b, n, m) {
696   var i = b[n]
697   b[n] = b[m]
698   b[m] = i
699 }
700
701 Buffer.prototype.swap16 = function swap16 () {
702   var len = this.length
703   if (len % 2 !== 0) {
704     throw new RangeError('Buffer size must be a multiple of 16-bits')
705   }
706   for (var i = 0; i < len; i += 2) {
707     swap(this, i, i + 1)
708   }
709   return this
710 }
711
712 Buffer.prototype.swap32 = function swap32 () {
713   var len = this.length
714   if (len % 4 !== 0) {
715     throw new RangeError('Buffer size must be a multiple of 32-bits')
716   }
717   for (var i = 0; i < len; i += 4) {
718     swap(this, i, i + 3)
719     swap(this, i + 1, i + 2)
720   }
721   return this
722 }
723
724 Buffer.prototype.swap64 = function swap64 () {
725   var len = this.length
726   if (len % 8 !== 0) {
727     throw new RangeError('Buffer size must be a multiple of 64-bits')
728   }
729   for (var i = 0; i < len; i += 8) {
730     swap(this, i, i + 7)
731     swap(this, i + 1, i + 6)
732     swap(this, i + 2, i + 5)
733     swap(this, i + 3, i + 4)
734   }
735   return this
736 }
737
738 Buffer.prototype.toString = function toString () {
739   var length = this.length | 0
740   if (length === 0) return ''
741   if (arguments.length === 0) return utf8Slice(this, 0, length)
742   return slowToString.apply(this, arguments)
743 }
744
745 Buffer.prototype.equals = function equals (b) {
746   if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
747   if (this === b) return true
748   return Buffer.compare(this, b) === 0
749 }
750
751 Buffer.prototype.inspect = function inspect () {
752   var str = ''
753   var max = exports.INSPECT_MAX_BYTES
754   if (this.length > 0) {
755     str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
756     if (this.length > max) str += ' ... '
757   }
758   return '<Buffer ' + str + '>'
759 }
760
761 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
762   if (!Buffer.isBuffer(target)) {
763     throw new TypeError('Argument must be a Buffer')
764   }
765
766   if (start === undefined) {
767     start = 0
768   }
769   if (end === undefined) {
770     end = target ? target.length : 0
771   }
772   if (thisStart === undefined) {
773     thisStart = 0
774   }
775   if (thisEnd === undefined) {
776     thisEnd = this.length
777   }
778
779   if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
780     throw new RangeError('out of range index')
781   }
782
783   if (thisStart >= thisEnd && start >= end) {
784     return 0
785   }
786   if (thisStart >= thisEnd) {
787     return -1
788   }
789   if (start >= end) {
790     return 1
791   }
792
793   start >>>= 0
794   end >>>= 0
795   thisStart >>>= 0
796   thisEnd >>>= 0
797
798   if (this === target) return 0
799
800   var x = thisEnd - thisStart
801   var y = end - start
802   var len = Math.min(x, y)
803
804   var thisCopy = this.slice(thisStart, thisEnd)
805   var targetCopy = target.slice(start, end)
806
807   for (var i = 0; i < len; ++i) {
808     if (thisCopy[i] !== targetCopy[i]) {
809       x = thisCopy[i]
810       y = targetCopy[i]
811       break
812     }
813   }
814
815   if (x < y) return -1
816   if (y < x) return 1
817   return 0
818 }
819
820 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
821 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
822 //
823 // Arguments:
824 // - buffer - a Buffer to search
825 // - val - a string, Buffer, or number
826 // - byteOffset - an index into `buffer`; will be clamped to an int32
827 // - encoding - an optional encoding, relevant is val is a string
828 // - dir - true for indexOf, false for lastIndexOf
829 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
830   // Empty buffer means no match
831   if (buffer.length === 0) return -1
832
833   // Normalize byteOffset
834   if (typeof byteOffset === 'string') {
835     encoding = byteOffset
836     byteOffset = 0
837   } else if (byteOffset > 0x7fffffff) {
838     byteOffset = 0x7fffffff
839   } else if (byteOffset < -0x80000000) {
840     byteOffset = -0x80000000
841   }
842   byteOffset = +byteOffset  // Coerce to Number.
843   if (isNaN(byteOffset)) {
844     // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
845     byteOffset = dir ? 0 : (buffer.length - 1)
846   }
847
848   // Normalize byteOffset: negative offsets start from the end of the buffer
849   if (byteOffset < 0) byteOffset = buffer.length + byteOffset
850   if (byteOffset >= buffer.length) {
851     if (dir) return -1
852     else byteOffset = buffer.length - 1
853   } else if (byteOffset < 0) {
854     if (dir) byteOffset = 0
855     else return -1
856   }
857
858   // Normalize val
859   if (typeof val === 'string') {
860     val = Buffer.from(val, encoding)
861   }
862
863   // Finally, search either indexOf (if dir is true) or lastIndexOf
864   if (Buffer.isBuffer(val)) {
865     // Special case: looking for empty string/buffer always fails
866     if (val.length === 0) {
867       return -1
868     }
869     return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
870   } else if (typeof val === 'number') {
871     val = val & 0xFF // Search for a byte value [0-255]
872     if (Buffer.TYPED_ARRAY_SUPPORT &&
873         typeof Uint8Array.prototype.indexOf === 'function') {
874       if (dir) {
875         return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
876       } else {
877         return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
878       }
879     }
880     return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
881   }
882
883   throw new TypeError('val must be string, number or Buffer')
884 }
885
886 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
887   var indexSize = 1
888   var arrLength = arr.length
889   var valLength = val.length
890
891   if (encoding !== undefined) {
892     encoding = String(encoding).toLowerCase()
893     if (encoding === 'ucs2' || encoding === 'ucs-2' ||
894         encoding === 'utf16le' || encoding === 'utf-16le') {
895       if (arr.length < 2 || val.length < 2) {
896         return -1
897       }
898       indexSize = 2
899       arrLength /= 2
900       valLength /= 2
901       byteOffset /= 2
902     }
903   }
904
905   function read (buf, i) {
906     if (indexSize === 1) {
907       return buf[i]
908     } else {
909       return buf.readUInt16BE(i * indexSize)
910     }
911   }
912
913   var i
914   if (dir) {
915     var foundIndex = -1
916     for (i = byteOffset; i < arrLength; i++) {
917       if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
918         if (foundIndex === -1) foundIndex = i
919         if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
920       } else {
921         if (foundIndex !== -1) i -= i - foundIndex
922         foundIndex = -1
923       }
924     }
925   } else {
926     if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
927     for (i = byteOffset; i >= 0; i--) {
928       var found = true
929       for (var j = 0; j < valLength; j++) {
930         if (read(arr, i + j) !== read(val, j)) {
931           found = false
932           break
933         }
934       }
935       if (found) return i
936     }
937   }
938
939   return -1
940 }
941
942 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
943   return this.indexOf(val, byteOffset, encoding) !== -1
944 }
945
946 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
947   return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
948 }
949
950 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
951   return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
952 }
953
954 function hexWrite (buf, string, offset, length) {
955   offset = Number(offset) || 0
956   var remaining = buf.length - offset
957   if (!length) {
958     length = remaining
959   } else {
960     length = Number(length)
961     if (length > remaining) {
962       length = remaining
963     }
964   }
965
966   // must be an even number of digits
967   var strLen = string.length
968   if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
969
970   if (length > strLen / 2) {
971     length = strLen / 2
972   }
973   for (var i = 0; i < length; ++i) {
974     var parsed = parseInt(string.substr(i * 2, 2), 16)
975     if (isNaN(parsed)) return i
976     buf[offset + i] = parsed
977   }
978   return i
979 }
980
981 function utf8Write (buf, string, offset, length) {
982   return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
983 }
984
985 function asciiWrite (buf, string, offset, length) {
986   return blitBuffer(asciiToBytes(string), buf, offset, length)
987 }
988
989 function latin1Write (buf, string, offset, length) {
990   return asciiWrite(buf, string, offset, length)
991 }
992
993 function base64Write (buf, string, offset, length) {
994   return blitBuffer(base64ToBytes(string), buf, offset, length)
995 }
996
997 function ucs2Write (buf, string, offset, length) {
998   return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
999 }
1000
1001 Buffer.prototype.write = function write (string, offset, length, encoding) {
1002   // Buffer#write(string)
1003   if (offset === undefined) {
1004     encoding = 'utf8'
1005     length = this.length
1006     offset = 0
1007   // Buffer#write(string, encoding)
1008   } else if (length === undefined && typeof offset === 'string') {
1009     encoding = offset
1010     length = this.length
1011     offset = 0
1012   // Buffer#write(string, offset[, length][, encoding])
1013   } else if (isFinite(offset)) {
1014     offset = offset | 0
1015     if (isFinite(length)) {
1016       length = length | 0
1017       if (encoding === undefined) encoding = 'utf8'
1018     } else {
1019       encoding = length
1020       length = undefined
1021     }
1022   // legacy write(string, encoding, offset, length) - remove in v0.13
1023   } else {
1024     throw new Error(
1025       'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1026     )
1027   }
1028
1029   var remaining = this.length - offset
1030   if (length === undefined || length > remaining) length = remaining
1031
1032   if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1033     throw new RangeError('Attempt to write outside buffer bounds')
1034   }
1035
1036   if (!encoding) encoding = 'utf8'
1037
1038   var loweredCase = false
1039   for (;;) {
1040     switch (encoding) {
1041       case 'hex':
1042         return hexWrite(this, string, offset, length)
1043
1044       case 'utf8':
1045       case 'utf-8':
1046         return utf8Write(this, string, offset, length)
1047
1048       case 'ascii':
1049         return asciiWrite(this, string, offset, length)
1050
1051       case 'latin1':
1052       case 'binary':
1053         return latin1Write(this, string, offset, length)
1054
1055       case 'base64':
1056         // Warning: maxLength not taken into account in base64Write
1057         return base64Write(this, string, offset, length)
1058
1059       case 'ucs2':
1060       case 'ucs-2':
1061       case 'utf16le':
1062       case 'utf-16le':
1063         return ucs2Write(this, string, offset, length)
1064
1065       default:
1066         if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1067         encoding = ('' + encoding).toLowerCase()
1068         loweredCase = true
1069     }
1070   }
1071 }
1072
1073 Buffer.prototype.toJSON = function toJSON () {
1074   return {
1075     type: 'Buffer',
1076     data: Array.prototype.slice.call(this._arr || this, 0)
1077   }
1078 }
1079
1080 function base64Slice (buf, start, end) {
1081   if (start === 0 && end === buf.length) {
1082     return base64.fromByteArray(buf)
1083   } else {
1084     return base64.fromByteArray(buf.slice(start, end))
1085   }
1086 }
1087
1088 function utf8Slice (buf, start, end) {
1089   end = Math.min(buf.length, end)
1090   var res = []
1091
1092   var i = start
1093   while (i < end) {
1094     var firstByte = buf[i]
1095     var codePoint = null
1096     var bytesPerSequence = (firstByte > 0xEF) ? 4
1097       : (firstByte > 0xDF) ? 3
1098       : (firstByte > 0xBF) ? 2
1099       : 1
1100
1101     if (i + bytesPerSequence <= end) {
1102       var secondByte, thirdByte, fourthByte, tempCodePoint
1103
1104       switch (bytesPerSequence) {
1105         case 1:
1106           if (firstByte < 0x80) {
1107             codePoint = firstByte
1108           }
1109           break
1110         case 2:
1111           secondByte = buf[i + 1]
1112           if ((secondByte & 0xC0) === 0x80) {
1113             tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1114             if (tempCodePoint > 0x7F) {
1115               codePoint = tempCodePoint
1116             }
1117           }
1118           break
1119         case 3:
1120           secondByte = buf[i + 1]
1121           thirdByte = buf[i + 2]
1122           if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1123             tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1124             if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1125               codePoint = tempCodePoint
1126             }
1127           }
1128           break
1129         case 4:
1130           secondByte = buf[i + 1]
1131           thirdByte = buf[i + 2]
1132           fourthByte = buf[i + 3]
1133           if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1134             tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1135             if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1136               codePoint = tempCodePoint
1137             }
1138           }
1139       }
1140     }
1141
1142     if (codePoint === null) {
1143       // we did not generate a valid codePoint so insert a
1144       // replacement char (U+FFFD) and advance only 1 byte
1145       codePoint = 0xFFFD
1146       bytesPerSequence = 1
1147     } else if (codePoint > 0xFFFF) {
1148       // encode to utf16 (surrogate pair dance)
1149       codePoint -= 0x10000
1150       res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1151       codePoint = 0xDC00 | codePoint & 0x3FF
1152     }
1153
1154     res.push(codePoint)
1155     i += bytesPerSequence
1156   }
1157
1158   return decodeCodePointsArray(res)
1159 }
1160
1161 // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1162 // the lowest limit is Chrome, with 0x10000 args.
1163 // We go 1 magnitude less, for safety
1164 var MAX_ARGUMENTS_LENGTH = 0x1000
1165
1166 function decodeCodePointsArray (codePoints) {
1167   var len = codePoints.length
1168   if (len <= MAX_ARGUMENTS_LENGTH) {
1169     return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1170   }
1171
1172   // Decode in chunks to avoid "call stack size exceeded".
1173   var res = ''
1174   var i = 0
1175   while (i < len) {
1176     res += String.fromCharCode.apply(
1177       String,
1178       codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1179     )
1180   }
1181   return res
1182 }
1183
1184 function asciiSlice (buf, start, end) {
1185   var ret = ''
1186   end = Math.min(buf.length, end)
1187
1188   for (var i = start; i < end; ++i) {
1189     ret += String.fromCharCode(buf[i] & 0x7F)
1190   }
1191   return ret
1192 }
1193
1194 function latin1Slice (buf, start, end) {
1195   var ret = ''
1196   end = Math.min(buf.length, end)
1197
1198   for (var i = start; i < end; ++i) {
1199     ret += String.fromCharCode(buf[i])
1200   }
1201   return ret
1202 }
1203
1204 function hexSlice (buf, start, end) {
1205   var len = buf.length
1206
1207   if (!start || start < 0) start = 0
1208   if (!end || end < 0 || end > len) end = len
1209
1210   var out = ''
1211   for (var i = start; i < end; ++i) {
1212     out += toHex(buf[i])
1213   }
1214   return out
1215 }
1216
1217 function utf16leSlice (buf, start, end) {
1218   var bytes = buf.slice(start, end)
1219   var res = ''
1220   for (var i = 0; i < bytes.length; i += 2) {
1221     res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1222   }
1223   return res
1224 }
1225
1226 Buffer.prototype.slice = function slice (start, end) {
1227   var len = this.length
1228   start = ~~start
1229   end = end === undefined ? len : ~~end
1230
1231   if (start < 0) {
1232     start += len
1233     if (start < 0) start = 0
1234   } else if (start > len) {
1235     start = len
1236   }
1237
1238   if (end < 0) {
1239     end += len
1240     if (end < 0) end = 0
1241   } else if (end > len) {
1242     end = len
1243   }
1244
1245   if (end < start) end = start
1246
1247   var newBuf
1248   if (Buffer.TYPED_ARRAY_SUPPORT) {
1249     newBuf = this.subarray(start, end)
1250     newBuf.__proto__ = Buffer.prototype
1251   } else {
1252     var sliceLen = end - start
1253     newBuf = new Buffer(sliceLen, undefined)
1254     for (var i = 0; i < sliceLen; ++i) {
1255       newBuf[i] = this[i + start]
1256     }
1257   }
1258
1259   return newBuf
1260 }
1261
1262 /*
1263  * Need to make sure that buffer isn't trying to write out of bounds.
1264  */
1265 function checkOffset (offset, ext, length) {
1266   if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1267   if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1268 }
1269
1270 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1271   offset = offset | 0
1272   byteLength = byteLength | 0
1273   if (!noAssert) checkOffset(offset, byteLength, this.length)
1274
1275   var val = this[offset]
1276   var mul = 1
1277   var i = 0
1278   while (++i < byteLength && (mul *= 0x100)) {
1279     val += this[offset + i] * mul
1280   }
1281
1282   return val
1283 }
1284
1285 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1286   offset = offset | 0
1287   byteLength = byteLength | 0
1288   if (!noAssert) {
1289     checkOffset(offset, byteLength, this.length)
1290   }
1291
1292   var val = this[offset + --byteLength]
1293   var mul = 1
1294   while (byteLength > 0 && (mul *= 0x100)) {
1295     val += this[offset + --byteLength] * mul
1296   }
1297
1298   return val
1299 }
1300
1301 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1302   if (!noAssert) checkOffset(offset, 1, this.length)
1303   return this[offset]
1304 }
1305
1306 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1307   if (!noAssert) checkOffset(offset, 2, this.length)
1308   return this[offset] | (this[offset + 1] << 8)
1309 }
1310
1311 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1312   if (!noAssert) checkOffset(offset, 2, this.length)
1313   return (this[offset] << 8) | this[offset + 1]
1314 }
1315
1316 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1317   if (!noAssert) checkOffset(offset, 4, this.length)
1318
1319   return ((this[offset]) |
1320       (this[offset + 1] << 8) |
1321       (this[offset + 2] << 16)) +
1322       (this[offset + 3] * 0x1000000)
1323 }
1324
1325 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1326   if (!noAssert) checkOffset(offset, 4, this.length)
1327
1328   return (this[offset] * 0x1000000) +
1329     ((this[offset + 1] << 16) |
1330     (this[offset + 2] << 8) |
1331     this[offset + 3])
1332 }
1333
1334 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1335   offset = offset | 0
1336   byteLength = byteLength | 0
1337   if (!noAssert) checkOffset(offset, byteLength, this.length)
1338
1339   var val = this[offset]
1340   var mul = 1
1341   var i = 0
1342   while (++i < byteLength && (mul *= 0x100)) {
1343     val += this[offset + i] * mul
1344   }
1345   mul *= 0x80
1346
1347   if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1348
1349   return val
1350 }
1351
1352 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1353   offset = offset | 0
1354   byteLength = byteLength | 0
1355   if (!noAssert) checkOffset(offset, byteLength, this.length)
1356
1357   var i = byteLength
1358   var mul = 1
1359   var val = this[offset + --i]
1360   while (i > 0 && (mul *= 0x100)) {
1361     val += this[offset + --i] * mul
1362   }
1363   mul *= 0x80
1364
1365   if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1366
1367   return val
1368 }
1369
1370 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1371   if (!noAssert) checkOffset(offset, 1, this.length)
1372   if (!(this[offset] & 0x80)) return (this[offset])
1373   return ((0xff - this[offset] + 1) * -1)
1374 }
1375
1376 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1377   if (!noAssert) checkOffset(offset, 2, this.length)
1378   var val = this[offset] | (this[offset + 1] << 8)
1379   return (val & 0x8000) ? val | 0xFFFF0000 : val
1380 }
1381
1382 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1383   if (!noAssert) checkOffset(offset, 2, this.length)
1384   var val = this[offset + 1] | (this[offset] << 8)
1385   return (val & 0x8000) ? val | 0xFFFF0000 : val
1386 }
1387
1388 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1389   if (!noAssert) checkOffset(offset, 4, this.length)
1390
1391   return (this[offset]) |
1392     (this[offset + 1] << 8) |
1393     (this[offset + 2] << 16) |
1394     (this[offset + 3] << 24)
1395 }
1396
1397 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1398   if (!noAssert) checkOffset(offset, 4, this.length)
1399
1400   return (this[offset] << 24) |
1401     (this[offset + 1] << 16) |
1402     (this[offset + 2] << 8) |
1403     (this[offset + 3])
1404 }
1405
1406 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1407   if (!noAssert) checkOffset(offset, 4, this.length)
1408   return ieee754.read(this, offset, true, 23, 4)
1409 }
1410
1411 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1412   if (!noAssert) checkOffset(offset, 4, this.length)
1413   return ieee754.read(this, offset, false, 23, 4)
1414 }
1415
1416 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1417   if (!noAssert) checkOffset(offset, 8, this.length)
1418   return ieee754.read(this, offset, true, 52, 8)
1419 }
1420
1421 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1422   if (!noAssert) checkOffset(offset, 8, this.length)
1423   return ieee754.read(this, offset, false, 52, 8)
1424 }
1425
1426 function checkInt (buf, value, offset, ext, max, min) {
1427   if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1428   if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1429   if (offset + ext > buf.length) throw new RangeError('Index out of range')
1430 }
1431
1432 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1433   value = +value
1434   offset = offset | 0
1435   byteLength = byteLength | 0
1436   if (!noAssert) {
1437     var maxBytes = Math.pow(2, 8 * byteLength) - 1
1438     checkInt(this, value, offset, byteLength, maxBytes, 0)
1439   }
1440
1441   var mul = 1
1442   var i = 0
1443   this[offset] = value & 0xFF
1444   while (++i < byteLength && (mul *= 0x100)) {
1445     this[offset + i] = (value / mul) & 0xFF
1446   }
1447
1448   return offset + byteLength
1449 }
1450
1451 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1452   value = +value
1453   offset = offset | 0
1454   byteLength = byteLength | 0
1455   if (!noAssert) {
1456     var maxBytes = Math.pow(2, 8 * byteLength) - 1
1457     checkInt(this, value, offset, byteLength, maxBytes, 0)
1458   }
1459
1460   var i = byteLength - 1
1461   var mul = 1
1462   this[offset + i] = value & 0xFF
1463   while (--i >= 0 && (mul *= 0x100)) {
1464     this[offset + i] = (value / mul) & 0xFF
1465   }
1466
1467   return offset + byteLength
1468 }
1469
1470 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1471   value = +value
1472   offset = offset | 0
1473   if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1474   if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1475   this[offset] = (value & 0xff)
1476   return offset + 1
1477 }
1478
1479 function objectWriteUInt16 (buf, value, offset, littleEndian) {
1480   if (value < 0) value = 0xffff + value + 1
1481   for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1482     buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1483       (littleEndian ? i : 1 - i) * 8
1484   }
1485 }
1486
1487 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1488   value = +value
1489   offset = offset | 0
1490   if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1491   if (Buffer.TYPED_ARRAY_SUPPORT) {
1492     this[offset] = (value & 0xff)
1493     this[offset + 1] = (value >>> 8)
1494   } else {
1495     objectWriteUInt16(this, value, offset, true)
1496   }
1497   return offset + 2
1498 }
1499
1500 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1501   value = +value
1502   offset = offset | 0
1503   if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1504   if (Buffer.TYPED_ARRAY_SUPPORT) {
1505     this[offset] = (value >>> 8)
1506     this[offset + 1] = (value & 0xff)
1507   } else {
1508     objectWriteUInt16(this, value, offset, false)
1509   }
1510   return offset + 2
1511 }
1512
1513 function objectWriteUInt32 (buf, value, offset, littleEndian) {
1514   if (value < 0) value = 0xffffffff + value + 1
1515   for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1516     buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1517   }
1518 }
1519
1520 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1521   value = +value
1522   offset = offset | 0
1523   if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1524   if (Buffer.TYPED_ARRAY_SUPPORT) {
1525     this[offset + 3] = (value >>> 24)
1526     this[offset + 2] = (value >>> 16)
1527     this[offset + 1] = (value >>> 8)
1528     this[offset] = (value & 0xff)
1529   } else {
1530     objectWriteUInt32(this, value, offset, true)
1531   }
1532   return offset + 4
1533 }
1534
1535 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1536   value = +value
1537   offset = offset | 0
1538   if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1539   if (Buffer.TYPED_ARRAY_SUPPORT) {
1540     this[offset] = (value >>> 24)
1541     this[offset + 1] = (value >>> 16)
1542     this[offset + 2] = (value >>> 8)
1543     this[offset + 3] = (value & 0xff)
1544   } else {
1545     objectWriteUInt32(this, value, offset, false)
1546   }
1547   return offset + 4
1548 }
1549
1550 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1551   value = +value
1552   offset = offset | 0
1553   if (!noAssert) {
1554     var limit = Math.pow(2, 8 * byteLength - 1)
1555
1556     checkInt(this, value, offset, byteLength, limit - 1, -limit)
1557   }
1558
1559   var i = 0
1560   var mul = 1
1561   var sub = 0
1562   this[offset] = value & 0xFF
1563   while (++i < byteLength && (mul *= 0x100)) {
1564     if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1565       sub = 1
1566     }
1567     this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1568   }
1569
1570   return offset + byteLength
1571 }
1572
1573 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1574   value = +value
1575   offset = offset | 0
1576   if (!noAssert) {
1577     var limit = Math.pow(2, 8 * byteLength - 1)
1578
1579     checkInt(this, value, offset, byteLength, limit - 1, -limit)
1580   }
1581
1582   var i = byteLength - 1
1583   var mul = 1
1584   var sub = 0
1585   this[offset + i] = value & 0xFF
1586   while (--i >= 0 && (mul *= 0x100)) {
1587     if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1588       sub = 1
1589     }
1590     this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1591   }
1592
1593   return offset + byteLength
1594 }
1595
1596 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1597   value = +value
1598   offset = offset | 0
1599   if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1600   if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1601   if (value < 0) value = 0xff + value + 1
1602   this[offset] = (value & 0xff)
1603   return offset + 1
1604 }
1605
1606 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1607   value = +value
1608   offset = offset | 0
1609   if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1610   if (Buffer.TYPED_ARRAY_SUPPORT) {
1611     this[offset] = (value & 0xff)
1612     this[offset + 1] = (value >>> 8)
1613   } else {
1614     objectWriteUInt16(this, value, offset, true)
1615   }
1616   return offset + 2
1617 }
1618
1619 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1620   value = +value
1621   offset = offset | 0
1622   if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1623   if (Buffer.TYPED_ARRAY_SUPPORT) {
1624     this[offset] = (value >>> 8)
1625     this[offset + 1] = (value & 0xff)
1626   } else {
1627     objectWriteUInt16(this, value, offset, false)
1628   }
1629   return offset + 2
1630 }
1631
1632 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1633   value = +value
1634   offset = offset | 0
1635   if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1636   if (Buffer.TYPED_ARRAY_SUPPORT) {
1637     this[offset] = (value & 0xff)
1638     this[offset + 1] = (value >>> 8)
1639     this[offset + 2] = (value >>> 16)
1640     this[offset + 3] = (value >>> 24)
1641   } else {
1642     objectWriteUInt32(this, value, offset, true)
1643   }
1644   return offset + 4
1645 }
1646
1647 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1648   value = +value
1649   offset = offset | 0
1650   if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1651   if (value < 0) value = 0xffffffff + value + 1
1652   if (Buffer.TYPED_ARRAY_SUPPORT) {
1653     this[offset] = (value >>> 24)
1654     this[offset + 1] = (value >>> 16)
1655     this[offset + 2] = (value >>> 8)
1656     this[offset + 3] = (value & 0xff)
1657   } else {
1658     objectWriteUInt32(this, value, offset, false)
1659   }
1660   return offset + 4
1661 }
1662
1663 function checkIEEE754 (buf, value, offset, ext, max, min) {
1664   if (offset + ext > buf.length) throw new RangeError('Index out of range')
1665   if (offset < 0) throw new RangeError('Index out of range')
1666 }
1667
1668 function writeFloat (buf, value, offset, littleEndian, noAssert) {
1669   if (!noAssert) {
1670     checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1671   }
1672   ieee754.write(buf, value, offset, littleEndian, 23, 4)
1673   return offset + 4
1674 }
1675
1676 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1677   return writeFloat(this, value, offset, true, noAssert)
1678 }
1679
1680 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1681   return writeFloat(this, value, offset, false, noAssert)
1682 }
1683
1684 function writeDouble (buf, value, offset, littleEndian, noAssert) {
1685   if (!noAssert) {
1686     checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1687   }
1688   ieee754.write(buf, value, offset, littleEndian, 52, 8)
1689   return offset + 8
1690 }
1691
1692 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1693   return writeDouble(this, value, offset, true, noAssert)
1694 }
1695
1696 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1697   return writeDouble(this, value, offset, false, noAssert)
1698 }
1699
1700 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1701 Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1702   if (!start) start = 0
1703   if (!end && end !== 0) end = this.length
1704   if (targetStart >= target.length) targetStart = target.length
1705   if (!targetStart) targetStart = 0
1706   if (end > 0 && end < start) end = start
1707
1708   // Copy 0 bytes; we're done
1709   if (end === start) return 0
1710   if (target.length === 0 || this.length === 0) return 0
1711
1712   // Fatal error conditions
1713   if (targetStart < 0) {
1714     throw new RangeError('targetStart out of bounds')
1715   }
1716   if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1717   if (end < 0) throw new RangeError('sourceEnd out of bounds')
1718
1719   // Are we oob?
1720   if (end > this.length) end = this.length
1721   if (target.length - targetStart < end - start) {
1722     end = target.length - targetStart + start
1723   }
1724
1725   var len = end - start
1726   var i
1727
1728   if (this === target && start < targetStart && targetStart < end) {
1729     // descending copy from end
1730     for (i = len - 1; i >= 0; --i) {
1731       target[i + targetStart] = this[i + start]
1732     }
1733   } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1734     // ascending copy from start
1735     for (i = 0; i < len; ++i) {
1736       target[i + targetStart] = this[i + start]
1737     }
1738   } else {
1739     Uint8Array.prototype.set.call(
1740       target,
1741       this.subarray(start, start + len),
1742       targetStart
1743     )
1744   }
1745
1746   return len
1747 }
1748
1749 // Usage:
1750 //    buffer.fill(number[, offset[, end]])
1751 //    buffer.fill(buffer[, offset[, end]])
1752 //    buffer.fill(string[, offset[, end]][, encoding])
1753 Buffer.prototype.fill = function fill (val, start, end, encoding) {
1754   // Handle string cases:
1755   if (typeof val === 'string') {
1756     if (typeof start === 'string') {
1757       encoding = start
1758       start = 0
1759       end = this.length
1760     } else if (typeof end === 'string') {
1761       encoding = end
1762       end = this.length
1763     }
1764     if (val.length === 1) {
1765       var code = val.charCodeAt(0)
1766       if (code < 256) {
1767         val = code
1768       }
1769     }
1770     if (encoding !== undefined && typeof encoding !== 'string') {
1771       throw new TypeError('encoding must be a string')
1772     }
1773     if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1774       throw new TypeError('Unknown encoding: ' + encoding)
1775     }
1776   } else if (typeof val === 'number') {
1777     val = val & 255
1778   }
1779
1780   // Invalid ranges are not set to a default, so can range check early.
1781   if (start < 0 || this.length < start || this.length < end) {
1782     throw new RangeError('Out of range index')
1783   }
1784
1785   if (end <= start) {
1786     return this
1787   }
1788
1789   start = start >>> 0
1790   end = end === undefined ? this.length : end >>> 0
1791
1792   if (!val) val = 0
1793
1794   var i
1795   if (typeof val === 'number') {
1796     for (i = start; i < end; ++i) {
1797       this[i] = val
1798     }
1799   } else {
1800     var bytes = Buffer.isBuffer(val)
1801       ? val
1802       : utf8ToBytes(new Buffer(val, encoding).toString())
1803     var len = bytes.length
1804     for (i = 0; i < end - start; ++i) {
1805       this[i + start] = bytes[i % len]
1806     }
1807   }
1808
1809   return this
1810 }
1811
1812 // HELPER FUNCTIONS
1813 // ================
1814
1815 var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
1816
1817 function base64clean (str) {
1818   // Node strips out invalid characters like \n and \t from the string, base64-js does not
1819   str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1820   // Node converts strings with length < 2 to ''
1821   if (str.length < 2) return ''
1822   // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1823   while (str.length % 4 !== 0) {
1824     str = str + '='
1825   }
1826   return str
1827 }
1828
1829 function stringtrim (str) {
1830   if (str.trim) return str.trim()
1831   return str.replace(/^\s+|\s+$/g, '')
1832 }
1833
1834 function toHex (n) {
1835   if (n < 16) return '0' + n.toString(16)
1836   return n.toString(16)
1837 }
1838
1839 function utf8ToBytes (string, units) {
1840   units = units || Infinity
1841   var codePoint
1842   var length = string.length
1843   var leadSurrogate = null
1844   var bytes = []
1845
1846   for (var i = 0; i < length; ++i) {
1847     codePoint = string.charCodeAt(i)
1848
1849     // is surrogate component
1850     if (codePoint > 0xD7FF && codePoint < 0xE000) {
1851       // last char was a lead
1852       if (!leadSurrogate) {
1853         // no lead yet
1854         if (codePoint > 0xDBFF) {
1855           // unexpected trail
1856           if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1857           continue
1858         } else if (i + 1 === length) {
1859           // unpaired lead
1860           if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1861           continue
1862         }
1863
1864         // valid lead
1865         leadSurrogate = codePoint
1866
1867         continue
1868       }
1869
1870       // 2 leads in a row
1871       if (codePoint < 0xDC00) {
1872         if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1873         leadSurrogate = codePoint
1874         continue
1875       }
1876
1877       // valid surrogate pair
1878       codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
1879     } else if (leadSurrogate) {
1880       // valid bmp char, but last char was a lead
1881       if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1882     }
1883
1884     leadSurrogate = null
1885
1886     // encode utf8
1887     if (codePoint < 0x80) {
1888       if ((units -= 1) < 0) break
1889       bytes.push(codePoint)
1890     } else if (codePoint < 0x800) {
1891       if ((units -= 2) < 0) break
1892       bytes.push(
1893         codePoint >> 0x6 | 0xC0,
1894         codePoint & 0x3F | 0x80
1895       )
1896     } else if (codePoint < 0x10000) {
1897       if ((units -= 3) < 0) break
1898       bytes.push(
1899         codePoint >> 0xC | 0xE0,
1900         codePoint >> 0x6 & 0x3F | 0x80,
1901         codePoint & 0x3F | 0x80
1902       )
1903     } else if (codePoint < 0x110000) {
1904       if ((units -= 4) < 0) break
1905       bytes.push(
1906         codePoint >> 0x12 | 0xF0,
1907         codePoint >> 0xC & 0x3F | 0x80,
1908         codePoint >> 0x6 & 0x3F | 0x80,
1909         codePoint & 0x3F | 0x80
1910       )
1911     } else {
1912       throw new Error('Invalid code point')
1913     }
1914   }
1915
1916   return bytes
1917 }
1918
1919 function asciiToBytes (str) {
1920   var byteArray = []
1921   for (var i = 0; i < str.length; ++i) {
1922     // Node's code seems to be doing this and not & 0x7F..
1923     byteArray.push(str.charCodeAt(i) & 0xFF)
1924   }
1925   return byteArray
1926 }
1927
1928 function utf16leToBytes (str, units) {
1929   var c, hi, lo
1930   var byteArray = []
1931   for (var i = 0; i < str.length; ++i) {
1932     if ((units -= 2) < 0) break
1933
1934     c = str.charCodeAt(i)
1935     hi = c >> 8
1936     lo = c % 256
1937     byteArray.push(lo)
1938     byteArray.push(hi)
1939   }
1940
1941   return byteArray
1942 }
1943
1944 function base64ToBytes (str) {
1945   return base64.toByteArray(base64clean(str))
1946 }
1947
1948 function blitBuffer (src, dst, offset, length) {
1949   for (var i = 0; i < length; ++i) {
1950     if ((i + offset >= dst.length) || (i >= src.length)) break
1951     dst[i + offset] = src[i]
1952   }
1953   return i
1954 }
1955
1956 function isnan (val) {
1957   return val !== val // eslint-disable-line no-self-compare
1958 }
1959
1960 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
1961
1962 /***/ }),
1963 /* 4 */
1964 /***/ (function(module, exports, __webpack_require__) {
1965
1966 /* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
1967   'use strict';
1968
1969   // Utils
1970   function assert (val, msg) {
1971     if (!val) throw new Error(msg || 'Assertion failed');
1972   }
1973
1974   // Could use `inherits` module, but don't want to move from single file
1975   // architecture yet.
1976   function inherits (ctor, superCtor) {
1977     ctor.super_ = superCtor;
1978     var TempCtor = function () {};
1979     TempCtor.prototype = superCtor.prototype;
1980     ctor.prototype = new TempCtor();
1981     ctor.prototype.constructor = ctor;
1982   }
1983
1984   // BN
1985
1986   function BN (number, base, endian) {
1987     if (BN.isBN(number)) {
1988       return number;
1989     }
1990
1991     this.negative = 0;
1992     this.words = null;
1993     this.length = 0;
1994
1995     // Reduction context
1996     this.red = null;
1997
1998     if (number !== null) {
1999       if (base === 'le' || base === 'be') {
2000         endian = base;
2001         base = 10;
2002       }
2003
2004       this._init(number || 0, base || 10, endian || 'be');
2005     }
2006   }
2007   if (typeof module === 'object') {
2008     module.exports = BN;
2009   } else {
2010     exports.BN = BN;
2011   }
2012
2013   BN.BN = BN;
2014   BN.wordSize = 26;
2015
2016   var Buffer;
2017   try {
2018     Buffer = __webpack_require__(217).Buffer;
2019   } catch (e) {
2020   }
2021
2022   BN.isBN = function isBN (num) {
2023     if (num instanceof BN) {
2024       return true;
2025     }
2026
2027     return num !== null && typeof num === 'object' &&
2028       num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
2029   };
2030
2031   BN.max = function max (left, right) {
2032     if (left.cmp(right) > 0) return left;
2033     return right;
2034   };
2035
2036   BN.min = function min (left, right) {
2037     if (left.cmp(right) < 0) return left;
2038     return right;
2039   };
2040
2041   BN.prototype._init = function init (number, base, endian) {
2042     if (typeof number === 'number') {
2043       return this._initNumber(number, base, endian);
2044     }
2045
2046     if (typeof number === 'object') {
2047       return this._initArray(number, base, endian);
2048     }
2049
2050     if (base === 'hex') {
2051       base = 16;
2052     }
2053     assert(base === (base | 0) && base >= 2 && base <= 36);
2054
2055     number = number.toString().replace(/\s+/g, '');
2056     var start = 0;
2057     if (number[0] === '-') {
2058       start++;
2059     }
2060
2061     if (base === 16) {
2062       this._parseHex(number, start);
2063     } else {
2064       this._parseBase(number, base, start);
2065     }
2066
2067     if (number[0] === '-') {
2068       this.negative = 1;
2069     }
2070
2071     this.strip();
2072
2073     if (endian !== 'le') return;
2074
2075     this._initArray(this.toArray(), base, endian);
2076   };
2077
2078   BN.prototype._initNumber = function _initNumber (number, base, endian) {
2079     if (number < 0) {
2080       this.negative = 1;
2081       number = -number;
2082     }
2083     if (number < 0x4000000) {
2084       this.words = [ number & 0x3ffffff ];
2085       this.length = 1;
2086     } else if (number < 0x10000000000000) {
2087       this.words = [
2088         number & 0x3ffffff,
2089         (number / 0x4000000) & 0x3ffffff
2090       ];
2091       this.length = 2;
2092     } else {
2093       assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
2094       this.words = [
2095         number & 0x3ffffff,
2096         (number / 0x4000000) & 0x3ffffff,
2097         1
2098       ];
2099       this.length = 3;
2100     }
2101
2102     if (endian !== 'le') return;
2103
2104     // Reverse the bytes
2105     this._initArray(this.toArray(), base, endian);
2106   };
2107
2108   BN.prototype._initArray = function _initArray (number, base, endian) {
2109     // Perhaps a Uint8Array
2110     assert(typeof number.length === 'number');
2111     if (number.length <= 0) {
2112       this.words = [ 0 ];
2113       this.length = 1;
2114       return this;
2115     }
2116
2117     this.length = Math.ceil(number.length / 3);
2118     this.words = new Array(this.length);
2119     for (var i = 0; i < this.length; i++) {
2120       this.words[i] = 0;
2121     }
2122
2123     var j, w;
2124     var off = 0;
2125     if (endian === 'be') {
2126       for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
2127         w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
2128         this.words[j] |= (w << off) & 0x3ffffff;
2129         this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
2130         off += 24;
2131         if (off >= 26) {
2132           off -= 26;
2133           j++;
2134         }
2135       }
2136     } else if (endian === 'le') {
2137       for (i = 0, j = 0; i < number.length; i += 3) {
2138         w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
2139         this.words[j] |= (w << off) & 0x3ffffff;
2140         this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
2141         off += 24;
2142         if (off >= 26) {
2143           off -= 26;
2144           j++;
2145         }
2146       }
2147     }
2148     return this.strip();
2149   };
2150
2151   function parseHex (str, start, end) {
2152     var r = 0;
2153     var len = Math.min(str.length, end);
2154     for (var i = start; i < len; i++) {
2155       var c = str.charCodeAt(i) - 48;
2156
2157       r <<= 4;
2158
2159       // 'a' - 'f'
2160       if (c >= 49 && c <= 54) {
2161         r |= c - 49 + 0xa;
2162
2163       // 'A' - 'F'
2164       } else if (c >= 17 && c <= 22) {
2165         r |= c - 17 + 0xa;
2166
2167       // '0' - '9'
2168       } else {
2169         r |= c & 0xf;
2170       }
2171     }
2172     return r;
2173   }
2174
2175   BN.prototype._parseHex = function _parseHex (number, start) {
2176     // Create possibly bigger array to ensure that it fits the number
2177     this.length = Math.ceil((number.length - start) / 6);
2178     this.words = new Array(this.length);
2179     for (var i = 0; i < this.length; i++) {
2180       this.words[i] = 0;
2181     }
2182
2183     var j, w;
2184     // Scan 24-bit chunks and add them to the number
2185     var off = 0;
2186     for (i = number.length - 6, j = 0; i >= start; i -= 6) {
2187       w = parseHex(number, i, i + 6);
2188       this.words[j] |= (w << off) & 0x3ffffff;
2189       // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
2190       this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
2191       off += 24;
2192       if (off >= 26) {
2193         off -= 26;
2194         j++;
2195       }
2196     }
2197     if (i + 6 !== start) {
2198       w = parseHex(number, start, i + 6);
2199       this.words[j] |= (w << off) & 0x3ffffff;
2200       this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
2201     }
2202     this.strip();
2203   };
2204
2205   function parseBase (str, start, end, mul) {
2206     var r = 0;
2207     var len = Math.min(str.length, end);
2208     for (var i = start; i < len; i++) {
2209       var c = str.charCodeAt(i) - 48;
2210
2211       r *= mul;
2212
2213       // 'a'
2214       if (c >= 49) {
2215         r += c - 49 + 0xa;
2216
2217       // 'A'
2218       } else if (c >= 17) {
2219         r += c - 17 + 0xa;
2220
2221       // '0' - '9'
2222       } else {
2223         r += c;
2224       }
2225     }
2226     return r;
2227   }
2228
2229   BN.prototype._parseBase = function _parseBase (number, base, start) {
2230     // Initialize as zero
2231     this.words = [ 0 ];
2232     this.length = 1;
2233
2234     // Find length of limb in base
2235     for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
2236       limbLen++;
2237     }
2238     limbLen--;
2239     limbPow = (limbPow / base) | 0;
2240
2241     var total = number.length - start;
2242     var mod = total % limbLen;
2243     var end = Math.min(total, total - mod) + start;
2244
2245     var word = 0;
2246     for (var i = start; i < end; i += limbLen) {
2247       word = parseBase(number, i, i + limbLen, base);
2248
2249       this.imuln(limbPow);
2250       if (this.words[0] + word < 0x4000000) {
2251         this.words[0] += word;
2252       } else {
2253         this._iaddn(word);
2254       }
2255     }
2256
2257     if (mod !== 0) {
2258       var pow = 1;
2259       word = parseBase(number, i, number.length, base);
2260
2261       for (i = 0; i < mod; i++) {
2262         pow *= base;
2263       }
2264
2265       this.imuln(pow);
2266       if (this.words[0] + word < 0x4000000) {
2267         this.words[0] += word;
2268       } else {
2269         this._iaddn(word);
2270       }
2271     }
2272   };
2273
2274   BN.prototype.copy = function copy (dest) {
2275     dest.words = new Array(this.length);
2276     for (var i = 0; i < this.length; i++) {
2277       dest.words[i] = this.words[i];
2278     }
2279     dest.length = this.length;
2280     dest.negative = this.negative;
2281     dest.red = this.red;
2282   };
2283
2284   BN.prototype.clone = function clone () {
2285     var r = new BN(null);
2286     this.copy(r);
2287     return r;
2288   };
2289
2290   BN.prototype._expand = function _expand (size) {
2291     while (this.length < size) {
2292       this.words[this.length++] = 0;
2293     }
2294     return this;
2295   };
2296
2297   // Remove leading `0` from `this`
2298   BN.prototype.strip = function strip () {
2299     while (this.length > 1 && this.words[this.length - 1] === 0) {
2300       this.length--;
2301     }
2302     return this._normSign();
2303   };
2304
2305   BN.prototype._normSign = function _normSign () {
2306     // -0 = 0
2307     if (this.length === 1 && this.words[0] === 0) {
2308       this.negative = 0;
2309     }
2310     return this;
2311   };
2312
2313   BN.prototype.inspect = function inspect () {
2314     return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
2315   };
2316
2317   /*
2318
2319   var zeros = [];
2320   var groupSizes = [];
2321   var groupBases = [];
2322
2323   var s = '';
2324   var i = -1;
2325   while (++i < BN.wordSize) {
2326     zeros[i] = s;
2327     s += '0';
2328   }
2329   groupSizes[0] = 0;
2330   groupSizes[1] = 0;
2331   groupBases[0] = 0;
2332   groupBases[1] = 0;
2333   var base = 2 - 1;
2334   while (++base < 36 + 1) {
2335     var groupSize = 0;
2336     var groupBase = 1;
2337     while (groupBase < (1 << BN.wordSize) / base) {
2338       groupBase *= base;
2339       groupSize += 1;
2340     }
2341     groupSizes[base] = groupSize;
2342     groupBases[base] = groupBase;
2343   }
2344
2345   */
2346
2347   var zeros = [
2348     '',
2349     '0',
2350     '00',
2351     '000',
2352     '0000',
2353     '00000',
2354     '000000',
2355     '0000000',
2356     '00000000',
2357     '000000000',
2358     '0000000000',
2359     '00000000000',
2360     '000000000000',
2361     '0000000000000',
2362     '00000000000000',
2363     '000000000000000',
2364     '0000000000000000',
2365     '00000000000000000',
2366     '000000000000000000',
2367     '0000000000000000000',
2368     '00000000000000000000',
2369     '000000000000000000000',
2370     '0000000000000000000000',
2371     '00000000000000000000000',
2372     '000000000000000000000000',
2373     '0000000000000000000000000'
2374   ];
2375
2376   var groupSizes = [
2377     0, 0,
2378     25, 16, 12, 11, 10, 9, 8,
2379     8, 7, 7, 7, 7, 6, 6,
2380     6, 6, 6, 6, 6, 5, 5,
2381     5, 5, 5, 5, 5, 5, 5,
2382     5, 5, 5, 5, 5, 5, 5
2383   ];
2384
2385   var groupBases = [
2386     0, 0,
2387     33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
2388     43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
2389     16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
2390     6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
2391     24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
2392   ];
2393
2394   BN.prototype.toString = function toString (base, padding) {
2395     base = base || 10;
2396     padding = padding | 0 || 1;
2397
2398     var out;
2399     if (base === 16 || base === 'hex') {
2400       out = '';
2401       var off = 0;
2402       var carry = 0;
2403       for (var i = 0; i < this.length; i++) {
2404         var w = this.words[i];
2405         var word = (((w << off) | carry) & 0xffffff).toString(16);
2406         carry = (w >>> (24 - off)) & 0xffffff;
2407         if (carry !== 0 || i !== this.length - 1) {
2408           out = zeros[6 - word.length] + word + out;
2409         } else {
2410           out = word + out;
2411         }
2412         off += 2;
2413         if (off >= 26) {
2414           off -= 26;
2415           i--;
2416         }
2417       }
2418       if (carry !== 0) {
2419         out = carry.toString(16) + out;
2420       }
2421       while (out.length % padding !== 0) {
2422         out = '0' + out;
2423       }
2424       if (this.negative !== 0) {
2425         out = '-' + out;
2426       }
2427       return out;
2428     }
2429
2430     if (base === (base | 0) && base >= 2 && base <= 36) {
2431       // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
2432       var groupSize = groupSizes[base];
2433       // var groupBase = Math.pow(base, groupSize);
2434       var groupBase = groupBases[base];
2435       out = '';
2436       var c = this.clone();
2437       c.negative = 0;
2438       while (!c.isZero()) {
2439         var r = c.modn(groupBase).toString(base);
2440         c = c.idivn(groupBase);
2441
2442         if (!c.isZero()) {
2443           out = zeros[groupSize - r.length] + r + out;
2444         } else {
2445           out = r + out;
2446         }
2447       }
2448       if (this.isZero()) {
2449         out = '0' + out;
2450       }
2451       while (out.length % padding !== 0) {
2452         out = '0' + out;
2453       }
2454       if (this.negative !== 0) {
2455         out = '-' + out;
2456       }
2457       return out;
2458     }
2459
2460     assert(false, 'Base should be between 2 and 36');
2461   };
2462
2463   BN.prototype.toNumber = function toNumber () {
2464     var ret = this.words[0];
2465     if (this.length === 2) {
2466       ret += this.words[1] * 0x4000000;
2467     } else if (this.length === 3 && this.words[2] === 0x01) {
2468       // NOTE: at this stage it is known that the top bit is set
2469       ret += 0x10000000000000 + (this.words[1] * 0x4000000);
2470     } else if (this.length > 2) {
2471       assert(false, 'Number can only safely store up to 53 bits');
2472     }
2473     return (this.negative !== 0) ? -ret : ret;
2474   };
2475
2476   BN.prototype.toJSON = function toJSON () {
2477     return this.toString(16);
2478   };
2479
2480   BN.prototype.toBuffer = function toBuffer (endian, length) {
2481     assert(typeof Buffer !== 'undefined');
2482     return this.toArrayLike(Buffer, endian, length);
2483   };
2484
2485   BN.prototype.toArray = function toArray (endian, length) {
2486     return this.toArrayLike(Array, endian, length);
2487   };
2488
2489   BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
2490     var byteLength = this.byteLength();
2491     var reqLength = length || Math.max(1, byteLength);
2492     assert(byteLength <= reqLength, 'byte array longer than desired length');
2493     assert(reqLength > 0, 'Requested array length <= 0');
2494
2495     this.strip();
2496     var littleEndian = endian === 'le';
2497     var res = new ArrayType(reqLength);
2498
2499     var b, i;
2500     var q = this.clone();
2501     if (!littleEndian) {
2502       // Assume big-endian
2503       for (i = 0; i < reqLength - byteLength; i++) {
2504         res[i] = 0;
2505       }
2506
2507       for (i = 0; !q.isZero(); i++) {
2508         b = q.andln(0xff);
2509         q.iushrn(8);
2510
2511         res[reqLength - i - 1] = b;
2512       }
2513     } else {
2514       for (i = 0; !q.isZero(); i++) {
2515         b = q.andln(0xff);
2516         q.iushrn(8);
2517
2518         res[i] = b;
2519       }
2520
2521       for (; i < reqLength; i++) {
2522         res[i] = 0;
2523       }
2524     }
2525
2526     return res;
2527   };
2528
2529   if (Math.clz32) {
2530     BN.prototype._countBits = function _countBits (w) {
2531       return 32 - Math.clz32(w);
2532     };
2533   } else {
2534     BN.prototype._countBits = function _countBits (w) {
2535       var t = w;
2536       var r = 0;
2537       if (t >= 0x1000) {
2538         r += 13;
2539         t >>>= 13;
2540       }
2541       if (t >= 0x40) {
2542         r += 7;
2543         t >>>= 7;
2544       }
2545       if (t >= 0x8) {
2546         r += 4;
2547         t >>>= 4;
2548       }
2549       if (t >= 0x02) {
2550         r += 2;
2551         t >>>= 2;
2552       }
2553       return r + t;
2554     };
2555   }
2556
2557   BN.prototype._zeroBits = function _zeroBits (w) {
2558     // Short-cut
2559     if (w === 0) return 26;
2560
2561     var t = w;
2562     var r = 0;
2563     if ((t & 0x1fff) === 0) {
2564       r += 13;
2565       t >>>= 13;
2566     }
2567     if ((t & 0x7f) === 0) {
2568       r += 7;
2569       t >>>= 7;
2570     }
2571     if ((t & 0xf) === 0) {
2572       r += 4;
2573       t >>>= 4;
2574     }
2575     if ((t & 0x3) === 0) {
2576       r += 2;
2577       t >>>= 2;
2578     }
2579     if ((t & 0x1) === 0) {
2580       r++;
2581     }
2582     return r;
2583   };
2584
2585   // Return number of used bits in a BN
2586   BN.prototype.bitLength = function bitLength () {
2587     var w = this.words[this.length - 1];
2588     var hi = this._countBits(w);
2589     return (this.length - 1) * 26 + hi;
2590   };
2591
2592   function toBitArray (num) {
2593     var w = new Array(num.bitLength());
2594
2595     for (var bit = 0; bit < w.length; bit++) {
2596       var off = (bit / 26) | 0;
2597       var wbit = bit % 26;
2598
2599       w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
2600     }
2601
2602     return w;
2603   }
2604
2605   // Number of trailing zero bits
2606   BN.prototype.zeroBits = function zeroBits () {
2607     if (this.isZero()) return 0;
2608
2609     var r = 0;
2610     for (var i = 0; i < this.length; i++) {
2611       var b = this._zeroBits(this.words[i]);
2612       r += b;
2613       if (b !== 26) break;
2614     }
2615     return r;
2616   };
2617
2618   BN.prototype.byteLength = function byteLength () {
2619     return Math.ceil(this.bitLength() / 8);
2620   };
2621
2622   BN.prototype.toTwos = function toTwos (width) {
2623     if (this.negative !== 0) {
2624       return this.abs().inotn(width).iaddn(1);
2625     }
2626     return this.clone();
2627   };
2628
2629   BN.prototype.fromTwos = function fromTwos (width) {
2630     if (this.testn(width - 1)) {
2631       return this.notn(width).iaddn(1).ineg();
2632     }
2633     return this.clone();
2634   };
2635
2636   BN.prototype.isNeg = function isNeg () {
2637     return this.negative !== 0;
2638   };
2639
2640   // Return negative clone of `this`
2641   BN.prototype.neg = function neg () {
2642     return this.clone().ineg();
2643   };
2644
2645   BN.prototype.ineg = function ineg () {
2646     if (!this.isZero()) {
2647       this.negative ^= 1;
2648     }
2649
2650     return this;
2651   };
2652
2653   // Or `num` with `this` in-place
2654   BN.prototype.iuor = function iuor (num) {
2655     while (this.length < num.length) {
2656       this.words[this.length++] = 0;
2657     }
2658
2659     for (var i = 0; i < num.length; i++) {
2660       this.words[i] = this.words[i] | num.words[i];
2661     }
2662
2663     return this.strip();
2664   };
2665
2666   BN.prototype.ior = function ior (num) {
2667     assert((this.negative | num.negative) === 0);
2668     return this.iuor(num);
2669   };
2670
2671   // Or `num` with `this`
2672   BN.prototype.or = function or (num) {
2673     if (this.length > num.length) return this.clone().ior(num);
2674     return num.clone().ior(this);
2675   };
2676
2677   BN.prototype.uor = function uor (num) {
2678     if (this.length > num.length) return this.clone().iuor(num);
2679     return num.clone().iuor(this);
2680   };
2681
2682   // And `num` with `this` in-place
2683   BN.prototype.iuand = function iuand (num) {
2684     // b = min-length(num, this)
2685     var b;
2686     if (this.length > num.length) {
2687       b = num;
2688     } else {
2689       b = this;
2690     }
2691
2692     for (var i = 0; i < b.length; i++) {
2693       this.words[i] = this.words[i] & num.words[i];
2694     }
2695
2696     this.length = b.length;
2697
2698     return this.strip();
2699   };
2700
2701   BN.prototype.iand = function iand (num) {
2702     assert((this.negative | num.negative) === 0);
2703     return this.iuand(num);
2704   };
2705
2706   // And `num` with `this`
2707   BN.prototype.and = function and (num) {
2708     if (this.length > num.length) return this.clone().iand(num);
2709     return num.clone().iand(this);
2710   };
2711
2712   BN.prototype.uand = function uand (num) {
2713     if (this.length > num.length) return this.clone().iuand(num);
2714     return num.clone().iuand(this);
2715   };
2716
2717   // Xor `num` with `this` in-place
2718   BN.prototype.iuxor = function iuxor (num) {
2719     // a.length > b.length
2720     var a;
2721     var b;
2722     if (this.length > num.length) {
2723       a = this;
2724       b = num;
2725     } else {
2726       a = num;
2727       b = this;
2728     }
2729
2730     for (var i = 0; i < b.length; i++) {
2731       this.words[i] = a.words[i] ^ b.words[i];
2732     }
2733
2734     if (this !== a) {
2735       for (; i < a.length; i++) {
2736         this.words[i] = a.words[i];
2737       }
2738     }
2739
2740     this.length = a.length;
2741
2742     return this.strip();
2743   };
2744
2745   BN.prototype.ixor = function ixor (num) {
2746     assert((this.negative | num.negative) === 0);
2747     return this.iuxor(num);
2748   };
2749
2750   // Xor `num` with `this`
2751   BN.prototype.xor = function xor (num) {
2752     if (this.length > num.length) return this.clone().ixor(num);
2753     return num.clone().ixor(this);
2754   };
2755
2756   BN.prototype.uxor = function uxor (num) {
2757     if (this.length > num.length) return this.clone().iuxor(num);
2758     return num.clone().iuxor(this);
2759   };
2760
2761   // Not ``this`` with ``width`` bitwidth
2762   BN.prototype.inotn = function inotn (width) {
2763     assert(typeof width === 'number' && width >= 0);
2764
2765     var bytesNeeded = Math.ceil(width / 26) | 0;
2766     var bitsLeft = width % 26;
2767
2768     // Extend the buffer with leading zeroes
2769     this._expand(bytesNeeded);
2770
2771     if (bitsLeft > 0) {
2772       bytesNeeded--;
2773     }
2774
2775     // Handle complete words
2776     for (var i = 0; i < bytesNeeded; i++) {
2777       this.words[i] = ~this.words[i] & 0x3ffffff;
2778     }
2779
2780     // Handle the residue
2781     if (bitsLeft > 0) {
2782       this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
2783     }
2784
2785     // And remove leading zeroes
2786     return this.strip();
2787   };
2788
2789   BN.prototype.notn = function notn (width) {
2790     return this.clone().inotn(width);
2791   };
2792
2793   // Set `bit` of `this`
2794   BN.prototype.setn = function setn (bit, val) {
2795     assert(typeof bit === 'number' && bit >= 0);
2796
2797     var off = (bit / 26) | 0;
2798     var wbit = bit % 26;
2799
2800     this._expand(off + 1);
2801
2802     if (val) {
2803       this.words[off] = this.words[off] | (1 << wbit);
2804     } else {
2805       this.words[off] = this.words[off] & ~(1 << wbit);
2806     }
2807
2808     return this.strip();
2809   };
2810
2811   // Add `num` to `this` in-place
2812   BN.prototype.iadd = function iadd (num) {
2813     var r;
2814
2815     // negative + positive
2816     if (this.negative !== 0 && num.negative === 0) {
2817       this.negative = 0;
2818       r = this.isub(num);
2819       this.negative ^= 1;
2820       return this._normSign();
2821
2822     // positive + negative
2823     } else if (this.negative === 0 && num.negative !== 0) {
2824       num.negative = 0;
2825       r = this.isub(num);
2826       num.negative = 1;
2827       return r._normSign();
2828     }
2829
2830     // a.length > b.length
2831     var a, b;
2832     if (this.length > num.length) {
2833       a = this;
2834       b = num;
2835     } else {
2836       a = num;
2837       b = this;
2838     }
2839
2840     var carry = 0;
2841     for (var i = 0; i < b.length; i++) {
2842       r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
2843       this.words[i] = r & 0x3ffffff;
2844       carry = r >>> 26;
2845     }
2846     for (; carry !== 0 && i < a.length; i++) {
2847       r = (a.words[i] | 0) + carry;
2848       this.words[i] = r & 0x3ffffff;
2849       carry = r >>> 26;
2850     }
2851
2852     this.length = a.length;
2853     if (carry !== 0) {
2854       this.words[this.length] = carry;
2855       this.length++;
2856     // Copy the rest of the words
2857     } else if (a !== this) {
2858       for (; i < a.length; i++) {
2859         this.words[i] = a.words[i];
2860       }
2861     }
2862
2863     return this;
2864   };
2865
2866   // Add `num` to `this`
2867   BN.prototype.add = function add (num) {
2868     var res;
2869     if (num.negative !== 0 && this.negative === 0) {
2870       num.negative = 0;
2871       res = this.sub(num);
2872       num.negative ^= 1;
2873       return res;
2874     } else if (num.negative === 0 && this.negative !== 0) {
2875       this.negative = 0;
2876       res = num.sub(this);
2877       this.negative = 1;
2878       return res;
2879     }
2880
2881     if (this.length > num.length) return this.clone().iadd(num);
2882
2883     return num.clone().iadd(this);
2884   };
2885
2886   // Subtract `num` from `this` in-place
2887   BN.prototype.isub = function isub (num) {
2888     // this - (-num) = this + num
2889     if (num.negative !== 0) {
2890       num.negative = 0;
2891       var r = this.iadd(num);
2892       num.negative = 1;
2893       return r._normSign();
2894
2895     // -this - num = -(this + num)
2896     } else if (this.negative !== 0) {
2897       this.negative = 0;
2898       this.iadd(num);
2899       this.negative = 1;
2900       return this._normSign();
2901     }
2902
2903     // At this point both numbers are positive
2904     var cmp = this.cmp(num);
2905
2906     // Optimization - zeroify
2907     if (cmp === 0) {
2908       this.negative = 0;
2909       this.length = 1;
2910       this.words[0] = 0;
2911       return this;
2912     }
2913
2914     // a > b
2915     var a, b;
2916     if (cmp > 0) {
2917       a = this;
2918       b = num;
2919     } else {
2920       a = num;
2921       b = this;
2922     }
2923
2924     var carry = 0;
2925     for (var i = 0; i < b.length; i++) {
2926       r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
2927       carry = r >> 26;
2928       this.words[i] = r & 0x3ffffff;
2929     }
2930     for (; carry !== 0 && i < a.length; i++) {
2931       r = (a.words[i] | 0) + carry;
2932       carry = r >> 26;
2933       this.words[i] = r & 0x3ffffff;
2934     }
2935
2936     // Copy rest of the words
2937     if (carry === 0 && i < a.length && a !== this) {
2938       for (; i < a.length; i++) {
2939         this.words[i] = a.words[i];
2940       }
2941     }
2942
2943     this.length = Math.max(this.length, i);
2944
2945     if (a !== this) {
2946       this.negative = 1;
2947     }
2948
2949     return this.strip();
2950   };
2951
2952   // Subtract `num` from `this`
2953   BN.prototype.sub = function sub (num) {
2954     return this.clone().isub(num);
2955   };
2956
2957   function smallMulTo (self, num, out) {
2958     out.negative = num.negative ^ self.negative;
2959     var len = (self.length + num.length) | 0;
2960     out.length = len;
2961     len = (len - 1) | 0;
2962
2963     // Peel one iteration (compiler can't do it, because of code complexity)
2964     var a = self.words[0] | 0;
2965     var b = num.words[0] | 0;
2966     var r = a * b;
2967
2968     var lo = r & 0x3ffffff;
2969     var carry = (r / 0x4000000) | 0;
2970     out.words[0] = lo;
2971
2972     for (var k = 1; k < len; k++) {
2973       // Sum all words with the same `i + j = k` and accumulate `ncarry`,
2974       // note that ncarry could be >= 0x3ffffff
2975       var ncarry = carry >>> 26;
2976       var rword = carry & 0x3ffffff;
2977       var maxJ = Math.min(k, num.length - 1);
2978       for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
2979         var i = (k - j) | 0;
2980         a = self.words[i] | 0;
2981         b = num.words[j] | 0;
2982         r = a * b + rword;
2983         ncarry += (r / 0x4000000) | 0;
2984         rword = r & 0x3ffffff;
2985       }
2986       out.words[k] = rword | 0;
2987       carry = ncarry | 0;
2988     }
2989     if (carry !== 0) {
2990       out.words[k] = carry | 0;
2991     } else {
2992       out.length--;
2993     }
2994
2995     return out.strip();
2996   }
2997
2998   // TODO(indutny): it may be reasonable to omit it for users who don't need
2999   // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
3000   // multiplication (like elliptic secp256k1).
3001   var comb10MulTo = function comb10MulTo (self, num, out) {
3002     var a = self.words;
3003     var b = num.words;
3004     var o = out.words;
3005     var c = 0;
3006     var lo;
3007     var mid;
3008     var hi;
3009     var a0 = a[0] | 0;
3010     var al0 = a0 & 0x1fff;
3011     var ah0 = a0 >>> 13;
3012     var a1 = a[1] | 0;
3013     var al1 = a1 & 0x1fff;
3014     var ah1 = a1 >>> 13;
3015     var a2 = a[2] | 0;
3016     var al2 = a2 & 0x1fff;
3017     var ah2 = a2 >>> 13;
3018     var a3 = a[3] | 0;
3019     var al3 = a3 & 0x1fff;
3020     var ah3 = a3 >>> 13;
3021     var a4 = a[4] | 0;
3022     var al4 = a4 & 0x1fff;
3023     var ah4 = a4 >>> 13;
3024     var a5 = a[5] | 0;
3025     var al5 = a5 & 0x1fff;
3026     var ah5 = a5 >>> 13;
3027     var a6 = a[6] | 0;
3028     var al6 = a6 & 0x1fff;
3029     var ah6 = a6 >>> 13;
3030     var a7 = a[7] | 0;
3031     var al7 = a7 & 0x1fff;
3032     var ah7 = a7 >>> 13;
3033     var a8 = a[8] | 0;
3034     var al8 = a8 & 0x1fff;
3035     var ah8 = a8 >>> 13;
3036     var a9 = a[9] | 0;
3037     var al9 = a9 & 0x1fff;
3038     var ah9 = a9 >>> 13;
3039     var b0 = b[0] | 0;
3040     var bl0 = b0 & 0x1fff;
3041     var bh0 = b0 >>> 13;
3042     var b1 = b[1] | 0;
3043     var bl1 = b1 & 0x1fff;
3044     var bh1 = b1 >>> 13;
3045     var b2 = b[2] | 0;
3046     var bl2 = b2 & 0x1fff;
3047     var bh2 = b2 >>> 13;
3048     var b3 = b[3] | 0;
3049     var bl3 = b3 & 0x1fff;
3050     var bh3 = b3 >>> 13;
3051     var b4 = b[4] | 0;
3052     var bl4 = b4 & 0x1fff;
3053     var bh4 = b4 >>> 13;
3054     var b5 = b[5] | 0;
3055     var bl5 = b5 & 0x1fff;
3056     var bh5 = b5 >>> 13;
3057     var b6 = b[6] | 0;
3058     var bl6 = b6 & 0x1fff;
3059     var bh6 = b6 >>> 13;
3060     var b7 = b[7] | 0;
3061     var bl7 = b7 & 0x1fff;
3062     var bh7 = b7 >>> 13;
3063     var b8 = b[8] | 0;
3064     var bl8 = b8 & 0x1fff;
3065     var bh8 = b8 >>> 13;
3066     var b9 = b[9] | 0;
3067     var bl9 = b9 & 0x1fff;
3068     var bh9 = b9 >>> 13;
3069
3070     out.negative = self.negative ^ num.negative;
3071     out.length = 19;
3072     /* k = 0 */
3073     lo = Math.imul(al0, bl0);
3074     mid = Math.imul(al0, bh0);
3075     mid = (mid + Math.imul(ah0, bl0)) | 0;
3076     hi = Math.imul(ah0, bh0);
3077     var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3078     c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
3079     w0 &= 0x3ffffff;
3080     /* k = 1 */
3081     lo = Math.imul(al1, bl0);
3082     mid = Math.imul(al1, bh0);
3083     mid = (mid + Math.imul(ah1, bl0)) | 0;
3084     hi = Math.imul(ah1, bh0);
3085     lo = (lo + Math.imul(al0, bl1)) | 0;
3086     mid = (mid + Math.imul(al0, bh1)) | 0;
3087     mid = (mid + Math.imul(ah0, bl1)) | 0;
3088     hi = (hi + Math.imul(ah0, bh1)) | 0;
3089     var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3090     c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
3091     w1 &= 0x3ffffff;
3092     /* k = 2 */
3093     lo = Math.imul(al2, bl0);
3094     mid = Math.imul(al2, bh0);
3095     mid = (mid + Math.imul(ah2, bl0)) | 0;
3096     hi = Math.imul(ah2, bh0);
3097     lo = (lo + Math.imul(al1, bl1)) | 0;
3098     mid = (mid + Math.imul(al1, bh1)) | 0;
3099     mid = (mid + Math.imul(ah1, bl1)) | 0;
3100     hi = (hi + Math.imul(ah1, bh1)) | 0;
3101     lo = (lo + Math.imul(al0, bl2)) | 0;
3102     mid = (mid + Math.imul(al0, bh2)) | 0;
3103     mid = (mid + Math.imul(ah0, bl2)) | 0;
3104     hi = (hi + Math.imul(ah0, bh2)) | 0;
3105     var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3106     c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
3107     w2 &= 0x3ffffff;
3108     /* k = 3 */
3109     lo = Math.imul(al3, bl0);
3110     mid = Math.imul(al3, bh0);
3111     mid = (mid + Math.imul(ah3, bl0)) | 0;
3112     hi = Math.imul(ah3, bh0);
3113     lo = (lo + Math.imul(al2, bl1)) | 0;
3114     mid = (mid + Math.imul(al2, bh1)) | 0;
3115     mid = (mid + Math.imul(ah2, bl1)) | 0;
3116     hi = (hi + Math.imul(ah2, bh1)) | 0;
3117     lo = (lo + Math.imul(al1, bl2)) | 0;
3118     mid = (mid + Math.imul(al1, bh2)) | 0;
3119     mid = (mid + Math.imul(ah1, bl2)) | 0;
3120     hi = (hi + Math.imul(ah1, bh2)) | 0;
3121     lo = (lo + Math.imul(al0, bl3)) | 0;
3122     mid = (mid + Math.imul(al0, bh3)) | 0;
3123     mid = (mid + Math.imul(ah0, bl3)) | 0;
3124     hi = (hi + Math.imul(ah0, bh3)) | 0;
3125     var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3126     c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
3127     w3 &= 0x3ffffff;
3128     /* k = 4 */
3129     lo = Math.imul(al4, bl0);
3130     mid = Math.imul(al4, bh0);
3131     mid = (mid + Math.imul(ah4, bl0)) | 0;
3132     hi = Math.imul(ah4, bh0);
3133     lo = (lo + Math.imul(al3, bl1)) | 0;
3134     mid = (mid + Math.imul(al3, bh1)) | 0;
3135     mid = (mid + Math.imul(ah3, bl1)) | 0;
3136     hi = (hi + Math.imul(ah3, bh1)) | 0;
3137     lo = (lo + Math.imul(al2, bl2)) | 0;
3138     mid = (mid + Math.imul(al2, bh2)) | 0;
3139     mid = (mid + Math.imul(ah2, bl2)) | 0;
3140     hi = (hi + Math.imul(ah2, bh2)) | 0;
3141     lo = (lo + Math.imul(al1, bl3)) | 0;
3142     mid = (mid + Math.imul(al1, bh3)) | 0;
3143     mid = (mid + Math.imul(ah1, bl3)) | 0;
3144     hi = (hi + Math.imul(ah1, bh3)) | 0;
3145     lo = (lo + Math.imul(al0, bl4)) | 0;
3146     mid = (mid + Math.imul(al0, bh4)) | 0;
3147     mid = (mid + Math.imul(ah0, bl4)) | 0;
3148     hi = (hi + Math.imul(ah0, bh4)) | 0;
3149     var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3150     c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
3151     w4 &= 0x3ffffff;
3152     /* k = 5 */
3153     lo = Math.imul(al5, bl0);
3154     mid = Math.imul(al5, bh0);
3155     mid = (mid + Math.imul(ah5, bl0)) | 0;
3156     hi = Math.imul(ah5, bh0);
3157     lo = (lo + Math.imul(al4, bl1)) | 0;
3158     mid = (mid + Math.imul(al4, bh1)) | 0;
3159     mid = (mid + Math.imul(ah4, bl1)) | 0;
3160     hi = (hi + Math.imul(ah4, bh1)) | 0;
3161     lo = (lo + Math.imul(al3, bl2)) | 0;
3162     mid = (mid + Math.imul(al3, bh2)) | 0;
3163     mid = (mid + Math.imul(ah3, bl2)) | 0;
3164     hi = (hi + Math.imul(ah3, bh2)) | 0;
3165     lo = (lo + Math.imul(al2, bl3)) | 0;
3166     mid = (mid + Math.imul(al2, bh3)) | 0;
3167     mid = (mid + Math.imul(ah2, bl3)) | 0;
3168     hi = (hi + Math.imul(ah2, bh3)) | 0;
3169     lo = (lo + Math.imul(al1, bl4)) | 0;
3170     mid = (mid + Math.imul(al1, bh4)) | 0;
3171     mid = (mid + Math.imul(ah1, bl4)) | 0;
3172     hi = (hi + Math.imul(ah1, bh4)) | 0;
3173     lo = (lo + Math.imul(al0, bl5)) | 0;
3174     mid = (mid + Math.imul(al0, bh5)) | 0;
3175     mid = (mid + Math.imul(ah0, bl5)) | 0;
3176     hi = (hi + Math.imul(ah0, bh5)) | 0;
3177     var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3178     c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
3179     w5 &= 0x3ffffff;
3180     /* k = 6 */
3181     lo = Math.imul(al6, bl0);
3182     mid = Math.imul(al6, bh0);
3183     mid = (mid + Math.imul(ah6, bl0)) | 0;
3184     hi = Math.imul(ah6, bh0);
3185     lo = (lo + Math.imul(al5, bl1)) | 0;
3186     mid = (mid + Math.imul(al5, bh1)) | 0;
3187     mid = (mid + Math.imul(ah5, bl1)) | 0;
3188     hi = (hi + Math.imul(ah5, bh1)) | 0;
3189     lo = (lo + Math.imul(al4, bl2)) | 0;
3190     mid = (mid + Math.imul(al4, bh2)) | 0;
3191     mid = (mid + Math.imul(ah4, bl2)) | 0;
3192     hi = (hi + Math.imul(ah4, bh2)) | 0;
3193     lo = (lo + Math.imul(al3, bl3)) | 0;
3194     mid = (mid + Math.imul(al3, bh3)) | 0;
3195     mid = (mid + Math.imul(ah3, bl3)) | 0;
3196     hi = (hi + Math.imul(ah3, bh3)) | 0;
3197     lo = (lo + Math.imul(al2, bl4)) | 0;
3198     mid = (mid + Math.imul(al2, bh4)) | 0;
3199     mid = (mid + Math.imul(ah2, bl4)) | 0;
3200     hi = (hi + Math.imul(ah2, bh4)) | 0;
3201     lo = (lo + Math.imul(al1, bl5)) | 0;
3202     mid = (mid + Math.imul(al1, bh5)) | 0;
3203     mid = (mid + Math.imul(ah1, bl5)) | 0;
3204     hi = (hi + Math.imul(ah1, bh5)) | 0;
3205     lo = (lo + Math.imul(al0, bl6)) | 0;
3206     mid = (mid + Math.imul(al0, bh6)) | 0;
3207     mid = (mid + Math.imul(ah0, bl6)) | 0;
3208     hi = (hi + Math.imul(ah0, bh6)) | 0;
3209     var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3210     c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
3211     w6 &= 0x3ffffff;
3212     /* k = 7 */
3213     lo = Math.imul(al7, bl0);
3214     mid = Math.imul(al7, bh0);
3215     mid = (mid + Math.imul(ah7, bl0)) | 0;
3216     hi = Math.imul(ah7, bh0);
3217     lo = (lo + Math.imul(al6, bl1)) | 0;
3218     mid = (mid + Math.imul(al6, bh1)) | 0;
3219     mid = (mid + Math.imul(ah6, bl1)) | 0;
3220     hi = (hi + Math.imul(ah6, bh1)) | 0;
3221     lo = (lo + Math.imul(al5, bl2)) | 0;
3222     mid = (mid + Math.imul(al5, bh2)) | 0;
3223     mid = (mid + Math.imul(ah5, bl2)) | 0;
3224     hi = (hi + Math.imul(ah5, bh2)) | 0;
3225     lo = (lo + Math.imul(al4, bl3)) | 0;
3226     mid = (mid + Math.imul(al4, bh3)) | 0;
3227     mid = (mid + Math.imul(ah4, bl3)) | 0;
3228     hi = (hi + Math.imul(ah4, bh3)) | 0;
3229     lo = (lo + Math.imul(al3, bl4)) | 0;
3230     mid = (mid + Math.imul(al3, bh4)) | 0;
3231     mid = (mid + Math.imul(ah3, bl4)) | 0;
3232     hi = (hi + Math.imul(ah3, bh4)) | 0;
3233     lo = (lo + Math.imul(al2, bl5)) | 0;
3234     mid = (mid + Math.imul(al2, bh5)) | 0;
3235     mid = (mid + Math.imul(ah2, bl5)) | 0;
3236     hi = (hi + Math.imul(ah2, bh5)) | 0;
3237     lo = (lo + Math.imul(al1, bl6)) | 0;
3238     mid = (mid + Math.imul(al1, bh6)) | 0;
3239     mid = (mid + Math.imul(ah1, bl6)) | 0;
3240     hi = (hi + Math.imul(ah1, bh6)) | 0;
3241     lo = (lo + Math.imul(al0, bl7)) | 0;
3242     mid = (mid + Math.imul(al0, bh7)) | 0;
3243     mid = (mid + Math.imul(ah0, bl7)) | 0;
3244     hi = (hi + Math.imul(ah0, bh7)) | 0;
3245     var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3246     c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
3247     w7 &= 0x3ffffff;
3248     /* k = 8 */
3249     lo = Math.imul(al8, bl0);
3250     mid = Math.imul(al8, bh0);
3251     mid = (mid + Math.imul(ah8, bl0)) | 0;
3252     hi = Math.imul(ah8, bh0);
3253     lo = (lo + Math.imul(al7, bl1)) | 0;
3254     mid = (mid + Math.imul(al7, bh1)) | 0;
3255     mid = (mid + Math.imul(ah7, bl1)) | 0;
3256     hi = (hi + Math.imul(ah7, bh1)) | 0;
3257     lo = (lo + Math.imul(al6, bl2)) | 0;
3258     mid = (mid + Math.imul(al6, bh2)) | 0;
3259     mid = (mid + Math.imul(ah6, bl2)) | 0;
3260     hi = (hi + Math.imul(ah6, bh2)) | 0;
3261     lo = (lo + Math.imul(al5, bl3)) | 0;
3262     mid = (mid + Math.imul(al5, bh3)) | 0;
3263     mid = (mid + Math.imul(ah5, bl3)) | 0;
3264     hi = (hi + Math.imul(ah5, bh3)) | 0;
3265     lo = (lo + Math.imul(al4, bl4)) | 0;
3266     mid = (mid + Math.imul(al4, bh4)) | 0;
3267     mid = (mid + Math.imul(ah4, bl4)) | 0;
3268     hi = (hi + Math.imul(ah4, bh4)) | 0;
3269     lo = (lo + Math.imul(al3, bl5)) | 0;
3270     mid = (mid + Math.imul(al3, bh5)) | 0;
3271     mid = (mid + Math.imul(ah3, bl5)) | 0;
3272     hi = (hi + Math.imul(ah3, bh5)) | 0;
3273     lo = (lo + Math.imul(al2, bl6)) | 0;
3274     mid = (mid + Math.imul(al2, bh6)) | 0;
3275     mid = (mid + Math.imul(ah2, bl6)) | 0;
3276     hi = (hi + Math.imul(ah2, bh6)) | 0;
3277     lo = (lo + Math.imul(al1, bl7)) | 0;
3278     mid = (mid + Math.imul(al1, bh7)) | 0;
3279     mid = (mid + Math.imul(ah1, bl7)) | 0;
3280     hi = (hi + Math.imul(ah1, bh7)) | 0;
3281     lo = (lo + Math.imul(al0, bl8)) | 0;
3282     mid = (mid + Math.imul(al0, bh8)) | 0;
3283     mid = (mid + Math.imul(ah0, bl8)) | 0;
3284     hi = (hi + Math.imul(ah0, bh8)) | 0;
3285     var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3286     c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
3287     w8 &= 0x3ffffff;
3288     /* k = 9 */
3289     lo = Math.imul(al9, bl0);
3290     mid = Math.imul(al9, bh0);
3291     mid = (mid + Math.imul(ah9, bl0)) | 0;
3292     hi = Math.imul(ah9, bh0);
3293     lo = (lo + Math.imul(al8, bl1)) | 0;
3294     mid = (mid + Math.imul(al8, bh1)) | 0;
3295     mid = (mid + Math.imul(ah8, bl1)) | 0;
3296     hi = (hi + Math.imul(ah8, bh1)) | 0;
3297     lo = (lo + Math.imul(al7, bl2)) | 0;
3298     mid = (mid + Math.imul(al7, bh2)) | 0;
3299     mid = (mid + Math.imul(ah7, bl2)) | 0;
3300     hi = (hi + Math.imul(ah7, bh2)) | 0;
3301     lo = (lo + Math.imul(al6, bl3)) | 0;
3302     mid = (mid + Math.imul(al6, bh3)) | 0;
3303     mid = (mid + Math.imul(ah6, bl3)) | 0;
3304     hi = (hi + Math.imul(ah6, bh3)) | 0;
3305     lo = (lo + Math.imul(al5, bl4)) | 0;
3306     mid = (mid + Math.imul(al5, bh4)) | 0;
3307     mid = (mid + Math.imul(ah5, bl4)) | 0;
3308     hi = (hi + Math.imul(ah5, bh4)) | 0;
3309     lo = (lo + Math.imul(al4, bl5)) | 0;
3310     mid = (mid + Math.imul(al4, bh5)) | 0;
3311     mid = (mid + Math.imul(ah4, bl5)) | 0;
3312     hi = (hi + Math.imul(ah4, bh5)) | 0;
3313     lo = (lo + Math.imul(al3, bl6)) | 0;
3314     mid = (mid + Math.imul(al3, bh6)) | 0;
3315     mid = (mid + Math.imul(ah3, bl6)) | 0;
3316     hi = (hi + Math.imul(ah3, bh6)) | 0;
3317     lo = (lo + Math.imul(al2, bl7)) | 0;
3318     mid = (mid + Math.imul(al2, bh7)) | 0;
3319     mid = (mid + Math.imul(ah2, bl7)) | 0;
3320     hi = (hi + Math.imul(ah2, bh7)) | 0;
3321     lo = (lo + Math.imul(al1, bl8)) | 0;
3322     mid = (mid + Math.imul(al1, bh8)) | 0;
3323     mid = (mid + Math.imul(ah1, bl8)) | 0;
3324     hi = (hi + Math.imul(ah1, bh8)) | 0;
3325     lo = (lo + Math.imul(al0, bl9)) | 0;
3326     mid = (mid + Math.imul(al0, bh9)) | 0;
3327     mid = (mid + Math.imul(ah0, bl9)) | 0;
3328     hi = (hi + Math.imul(ah0, bh9)) | 0;
3329     var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3330     c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
3331     w9 &= 0x3ffffff;
3332     /* k = 10 */
3333     lo = Math.imul(al9, bl1);
3334     mid = Math.imul(al9, bh1);
3335     mid = (mid + Math.imul(ah9, bl1)) | 0;
3336     hi = Math.imul(ah9, bh1);
3337     lo = (lo + Math.imul(al8, bl2)) | 0;
3338     mid = (mid + Math.imul(al8, bh2)) | 0;
3339     mid = (mid + Math.imul(ah8, bl2)) | 0;
3340     hi = (hi + Math.imul(ah8, bh2)) | 0;
3341     lo = (lo + Math.imul(al7, bl3)) | 0;
3342     mid = (mid + Math.imul(al7, bh3)) | 0;
3343     mid = (mid + Math.imul(ah7, bl3)) | 0;
3344     hi = (hi + Math.imul(ah7, bh3)) | 0;
3345     lo = (lo + Math.imul(al6, bl4)) | 0;
3346     mid = (mid + Math.imul(al6, bh4)) | 0;
3347     mid = (mid + Math.imul(ah6, bl4)) | 0;
3348     hi = (hi + Math.imul(ah6, bh4)) | 0;
3349     lo = (lo + Math.imul(al5, bl5)) | 0;
3350     mid = (mid + Math.imul(al5, bh5)) | 0;
3351     mid = (mid + Math.imul(ah5, bl5)) | 0;
3352     hi = (hi + Math.imul(ah5, bh5)) | 0;
3353     lo = (lo + Math.imul(al4, bl6)) | 0;
3354     mid = (mid + Math.imul(al4, bh6)) | 0;
3355     mid = (mid + Math.imul(ah4, bl6)) | 0;
3356     hi = (hi + Math.imul(ah4, bh6)) | 0;
3357     lo = (lo + Math.imul(al3, bl7)) | 0;
3358     mid = (mid + Math.imul(al3, bh7)) | 0;
3359     mid = (mid + Math.imul(ah3, bl7)) | 0;
3360     hi = (hi + Math.imul(ah3, bh7)) | 0;
3361     lo = (lo + Math.imul(al2, bl8)) | 0;
3362     mid = (mid + Math.imul(al2, bh8)) | 0;
3363     mid = (mid + Math.imul(ah2, bl8)) | 0;
3364     hi = (hi + Math.imul(ah2, bh8)) | 0;
3365     lo = (lo + Math.imul(al1, bl9)) | 0;
3366     mid = (mid + Math.imul(al1, bh9)) | 0;
3367     mid = (mid + Math.imul(ah1, bl9)) | 0;
3368     hi = (hi + Math.imul(ah1, bh9)) | 0;
3369     var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3370     c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
3371     w10 &= 0x3ffffff;
3372     /* k = 11 */
3373     lo = Math.imul(al9, bl2);
3374     mid = Math.imul(al9, bh2);
3375     mid = (mid + Math.imul(ah9, bl2)) | 0;
3376     hi = Math.imul(ah9, bh2);
3377     lo = (lo + Math.imul(al8, bl3)) | 0;
3378     mid = (mid + Math.imul(al8, bh3)) | 0;
3379     mid = (mid + Math.imul(ah8, bl3)) | 0;
3380     hi = (hi + Math.imul(ah8, bh3)) | 0;
3381     lo = (lo + Math.imul(al7, bl4)) | 0;
3382     mid = (mid + Math.imul(al7, bh4)) | 0;
3383     mid = (mid + Math.imul(ah7, bl4)) | 0;
3384     hi = (hi + Math.imul(ah7, bh4)) | 0;
3385     lo = (lo + Math.imul(al6, bl5)) | 0;
3386     mid = (mid + Math.imul(al6, bh5)) | 0;
3387     mid = (mid + Math.imul(ah6, bl5)) | 0;
3388     hi = (hi + Math.imul(ah6, bh5)) | 0;
3389     lo = (lo + Math.imul(al5, bl6)) | 0;
3390     mid = (mid + Math.imul(al5, bh6)) | 0;
3391     mid = (mid + Math.imul(ah5, bl6)) | 0;
3392     hi = (hi + Math.imul(ah5, bh6)) | 0;
3393     lo = (lo + Math.imul(al4, bl7)) | 0;
3394     mid = (mid + Math.imul(al4, bh7)) | 0;
3395     mid = (mid + Math.imul(ah4, bl7)) | 0;
3396     hi = (hi + Math.imul(ah4, bh7)) | 0;
3397     lo = (lo + Math.imul(al3, bl8)) | 0;
3398     mid = (mid + Math.imul(al3, bh8)) | 0;
3399     mid = (mid + Math.imul(ah3, bl8)) | 0;
3400     hi = (hi + Math.imul(ah3, bh8)) | 0;
3401     lo = (lo + Math.imul(al2, bl9)) | 0;
3402     mid = (mid + Math.imul(al2, bh9)) | 0;
3403     mid = (mid + Math.imul(ah2, bl9)) | 0;
3404     hi = (hi + Math.imul(ah2, bh9)) | 0;
3405     var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3406     c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
3407     w11 &= 0x3ffffff;
3408     /* k = 12 */
3409     lo = Math.imul(al9, bl3);
3410     mid = Math.imul(al9, bh3);
3411     mid = (mid + Math.imul(ah9, bl3)) | 0;
3412     hi = Math.imul(ah9, bh3);
3413     lo = (lo + Math.imul(al8, bl4)) | 0;
3414     mid = (mid + Math.imul(al8, bh4)) | 0;
3415     mid = (mid + Math.imul(ah8, bl4)) | 0;
3416     hi = (hi + Math.imul(ah8, bh4)) | 0;
3417     lo = (lo + Math.imul(al7, bl5)) | 0;
3418     mid = (mid + Math.imul(al7, bh5)) | 0;
3419     mid = (mid + Math.imul(ah7, bl5)) | 0;
3420     hi = (hi + Math.imul(ah7, bh5)) | 0;
3421     lo = (lo + Math.imul(al6, bl6)) | 0;
3422     mid = (mid + Math.imul(al6, bh6)) | 0;
3423     mid = (mid + Math.imul(ah6, bl6)) | 0;
3424     hi = (hi + Math.imul(ah6, bh6)) | 0;
3425     lo = (lo + Math.imul(al5, bl7)) | 0;
3426     mid = (mid + Math.imul(al5, bh7)) | 0;
3427     mid = (mid + Math.imul(ah5, bl7)) | 0;
3428     hi = (hi + Math.imul(ah5, bh7)) | 0;
3429     lo = (lo + Math.imul(al4, bl8)) | 0;
3430     mid = (mid + Math.imul(al4, bh8)) | 0;
3431     mid = (mid + Math.imul(ah4, bl8)) | 0;
3432     hi = (hi + Math.imul(ah4, bh8)) | 0;
3433     lo = (lo + Math.imul(al3, bl9)) | 0;
3434     mid = (mid + Math.imul(al3, bh9)) | 0;
3435     mid = (mid + Math.imul(ah3, bl9)) | 0;
3436     hi = (hi + Math.imul(ah3, bh9)) | 0;
3437     var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3438     c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
3439     w12 &= 0x3ffffff;
3440     /* k = 13 */
3441     lo = Math.imul(al9, bl4);
3442     mid = Math.imul(al9, bh4);
3443     mid = (mid + Math.imul(ah9, bl4)) | 0;
3444     hi = Math.imul(ah9, bh4);
3445     lo = (lo + Math.imul(al8, bl5)) | 0;
3446     mid = (mid + Math.imul(al8, bh5)) | 0;
3447     mid = (mid + Math.imul(ah8, bl5)) | 0;
3448     hi = (hi + Math.imul(ah8, bh5)) | 0;
3449     lo = (lo + Math.imul(al7, bl6)) | 0;
3450     mid = (mid + Math.imul(al7, bh6)) | 0;
3451     mid = (mid + Math.imul(ah7, bl6)) | 0;
3452     hi = (hi + Math.imul(ah7, bh6)) | 0;
3453     lo = (lo + Math.imul(al6, bl7)) | 0;
3454     mid = (mid + Math.imul(al6, bh7)) | 0;
3455     mid = (mid + Math.imul(ah6, bl7)) | 0;
3456     hi = (hi + Math.imul(ah6, bh7)) | 0;
3457     lo = (lo + Math.imul(al5, bl8)) | 0;
3458     mid = (mid + Math.imul(al5, bh8)) | 0;
3459     mid = (mid + Math.imul(ah5, bl8)) | 0;
3460     hi = (hi + Math.imul(ah5, bh8)) | 0;
3461     lo = (lo + Math.imul(al4, bl9)) | 0;
3462     mid = (mid + Math.imul(al4, bh9)) | 0;
3463     mid = (mid + Math.imul(ah4, bl9)) | 0;
3464     hi = (hi + Math.imul(ah4, bh9)) | 0;
3465     var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3466     c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
3467     w13 &= 0x3ffffff;
3468     /* k = 14 */
3469     lo = Math.imul(al9, bl5);
3470     mid = Math.imul(al9, bh5);
3471     mid = (mid + Math.imul(ah9, bl5)) | 0;
3472     hi = Math.imul(ah9, bh5);
3473     lo = (lo + Math.imul(al8, bl6)) | 0;
3474     mid = (mid + Math.imul(al8, bh6)) | 0;
3475     mid = (mid + Math.imul(ah8, bl6)) | 0;
3476     hi = (hi + Math.imul(ah8, bh6)) | 0;
3477     lo = (lo + Math.imul(al7, bl7)) | 0;
3478     mid = (mid + Math.imul(al7, bh7)) | 0;
3479     mid = (mid + Math.imul(ah7, bl7)) | 0;
3480     hi = (hi + Math.imul(ah7, bh7)) | 0;
3481     lo = (lo + Math.imul(al6, bl8)) | 0;
3482     mid = (mid + Math.imul(al6, bh8)) | 0;
3483     mid = (mid + Math.imul(ah6, bl8)) | 0;
3484     hi = (hi + Math.imul(ah6, bh8)) | 0;
3485     lo = (lo + Math.imul(al5, bl9)) | 0;
3486     mid = (mid + Math.imul(al5, bh9)) | 0;
3487     mid = (mid + Math.imul(ah5, bl9)) | 0;
3488     hi = (hi + Math.imul(ah5, bh9)) | 0;
3489     var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3490     c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
3491     w14 &= 0x3ffffff;
3492     /* k = 15 */
3493     lo = Math.imul(al9, bl6);
3494     mid = Math.imul(al9, bh6);
3495     mid = (mid + Math.imul(ah9, bl6)) | 0;
3496     hi = Math.imul(ah9, bh6);
3497     lo = (lo + Math.imul(al8, bl7)) | 0;
3498     mid = (mid + Math.imul(al8, bh7)) | 0;
3499     mid = (mid + Math.imul(ah8, bl7)) | 0;
3500     hi = (hi + Math.imul(ah8, bh7)) | 0;
3501     lo = (lo + Math.imul(al7, bl8)) | 0;
3502     mid = (mid + Math.imul(al7, bh8)) | 0;
3503     mid = (mid + Math.imul(ah7, bl8)) | 0;
3504     hi = (hi + Math.imul(ah7, bh8)) | 0;
3505     lo = (lo + Math.imul(al6, bl9)) | 0;
3506     mid = (mid + Math.imul(al6, bh9)) | 0;
3507     mid = (mid + Math.imul(ah6, bl9)) | 0;
3508     hi = (hi + Math.imul(ah6, bh9)) | 0;
3509     var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3510     c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
3511     w15 &= 0x3ffffff;
3512     /* k = 16 */
3513     lo = Math.imul(al9, bl7);
3514     mid = Math.imul(al9, bh7);
3515     mid = (mid + Math.imul(ah9, bl7)) | 0;
3516     hi = Math.imul(ah9, bh7);
3517     lo = (lo + Math.imul(al8, bl8)) | 0;
3518     mid = (mid + Math.imul(al8, bh8)) | 0;
3519     mid = (mid + Math.imul(ah8, bl8)) | 0;
3520     hi = (hi + Math.imul(ah8, bh8)) | 0;
3521     lo = (lo + Math.imul(al7, bl9)) | 0;
3522     mid = (mid + Math.imul(al7, bh9)) | 0;
3523     mid = (mid + Math.imul(ah7, bl9)) | 0;
3524     hi = (hi + Math.imul(ah7, bh9)) | 0;
3525     var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3526     c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
3527     w16 &= 0x3ffffff;
3528     /* k = 17 */
3529     lo = Math.imul(al9, bl8);
3530     mid = Math.imul(al9, bh8);
3531     mid = (mid + Math.imul(ah9, bl8)) | 0;
3532     hi = Math.imul(ah9, bh8);
3533     lo = (lo + Math.imul(al8, bl9)) | 0;
3534     mid = (mid + Math.imul(al8, bh9)) | 0;
3535     mid = (mid + Math.imul(ah8, bl9)) | 0;
3536     hi = (hi + Math.imul(ah8, bh9)) | 0;
3537     var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3538     c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
3539     w17 &= 0x3ffffff;
3540     /* k = 18 */
3541     lo = Math.imul(al9, bl9);
3542     mid = Math.imul(al9, bh9);
3543     mid = (mid + Math.imul(ah9, bl9)) | 0;
3544     hi = Math.imul(ah9, bh9);
3545     var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
3546     c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
3547     w18 &= 0x3ffffff;
3548     o[0] = w0;
3549     o[1] = w1;
3550     o[2] = w2;
3551     o[3] = w3;
3552     o[4] = w4;
3553     o[5] = w5;
3554     o[6] = w6;
3555     o[7] = w7;
3556     o[8] = w8;
3557     o[9] = w9;
3558     o[10] = w10;
3559     o[11] = w11;
3560     o[12] = w12;
3561     o[13] = w13;
3562     o[14] = w14;
3563     o[15] = w15;
3564     o[16] = w16;
3565     o[17] = w17;
3566     o[18] = w18;
3567     if (c !== 0) {
3568       o[19] = c;
3569       out.length++;
3570     }
3571     return out;
3572   };
3573
3574   // Polyfill comb
3575   if (!Math.imul) {
3576     comb10MulTo = smallMulTo;
3577   }
3578
3579   function bigMulTo (self, num, out) {
3580     out.negative = num.negative ^ self.negative;
3581     out.length = self.length + num.length;
3582
3583     var carry = 0;
3584     var hncarry = 0;
3585     for (var k = 0; k < out.length - 1; k++) {
3586       // Sum all words with the same `i + j = k` and accumulate `ncarry`,
3587       // note that ncarry could be >= 0x3ffffff
3588       var ncarry = hncarry;
3589       hncarry = 0;
3590       var rword = carry & 0x3ffffff;
3591       var maxJ = Math.min(k, num.length - 1);
3592       for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
3593         var i = k - j;
3594         var a = self.words[i] | 0;
3595         var b = num.words[j] | 0;
3596         var r = a * b;
3597
3598         var lo = r & 0x3ffffff;
3599         ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
3600         lo = (lo + rword) | 0;
3601         rword = lo & 0x3ffffff;
3602         ncarry = (ncarry + (lo >>> 26)) | 0;
3603
3604         hncarry += ncarry >>> 26;
3605         ncarry &= 0x3ffffff;
3606       }
3607       out.words[k] = rword;
3608       carry = ncarry;
3609       ncarry = hncarry;
3610     }
3611     if (carry !== 0) {
3612       out.words[k] = carry;
3613     } else {
3614       out.length--;
3615     }
3616
3617     return out.strip();
3618   }
3619
3620   function jumboMulTo (self, num, out) {
3621     var fftm = new FFTM();
3622     return fftm.mulp(self, num, out);
3623   }
3624
3625   BN.prototype.mulTo = function mulTo (num, out) {
3626     var res;
3627     var len = this.length + num.length;
3628     if (this.length === 10 && num.length === 10) {
3629       res = comb10MulTo(this, num, out);
3630     } else if (len < 63) {
3631       res = smallMulTo(this, num, out);
3632     } else if (len < 1024) {
3633       res = bigMulTo(this, num, out);
3634     } else {
3635       res = jumboMulTo(this, num, out);
3636     }
3637
3638     return res;
3639   };
3640
3641   // Cooley-Tukey algorithm for FFT
3642   // slightly revisited to rely on looping instead of recursion
3643
3644   function FFTM (x, y) {
3645     this.x = x;
3646     this.y = y;
3647   }
3648
3649   FFTM.prototype.makeRBT = function makeRBT (N) {
3650     var t = new Array(N);
3651     var l = BN.prototype._countBits(N) - 1;
3652     for (var i = 0; i < N; i++) {
3653       t[i] = this.revBin(i, l, N);
3654     }
3655
3656     return t;
3657   };
3658
3659   // Returns binary-reversed representation of `x`
3660   FFTM.prototype.revBin = function revBin (x, l, N) {
3661     if (x === 0 || x === N - 1) return x;
3662
3663     var rb = 0;
3664     for (var i = 0; i < l; i++) {
3665       rb |= (x & 1) << (l - i - 1);
3666       x >>= 1;
3667     }
3668
3669     return rb;
3670   };
3671
3672   // Performs "tweedling" phase, therefore 'emulating'
3673   // behaviour of the recursive algorithm
3674   FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
3675     for (var i = 0; i < N; i++) {
3676       rtws[i] = rws[rbt[i]];
3677       itws[i] = iws[rbt[i]];
3678     }
3679   };
3680
3681   FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
3682     this.permute(rbt, rws, iws, rtws, itws, N);
3683
3684     for (var s = 1; s < N; s <<= 1) {
3685       var l = s << 1;
3686
3687       var rtwdf = Math.cos(2 * Math.PI / l);
3688       var itwdf = Math.sin(2 * Math.PI / l);
3689
3690       for (var p = 0; p < N; p += l) {
3691         var rtwdf_ = rtwdf;
3692         var itwdf_ = itwdf;
3693
3694         for (var j = 0; j < s; j++) {
3695           var re = rtws[p + j];
3696           var ie = itws[p + j];
3697
3698           var ro = rtws[p + j + s];
3699           var io = itws[p + j + s];
3700
3701           var rx = rtwdf_ * ro - itwdf_ * io;
3702
3703           io = rtwdf_ * io + itwdf_ * ro;
3704           ro = rx;
3705
3706           rtws[p + j] = re + ro;
3707           itws[p + j] = ie + io;
3708
3709           rtws[p + j + s] = re - ro;
3710           itws[p + j + s] = ie - io;
3711
3712           /* jshint maxdepth : false */
3713           if (j !== l) {
3714             rx = rtwdf * rtwdf_ - itwdf * itwdf_;
3715
3716             itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
3717             rtwdf_ = rx;
3718           }
3719         }
3720       }
3721     }
3722   };
3723
3724   FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
3725     var N = Math.max(m, n) | 1;
3726     var odd = N & 1;
3727     var i = 0;
3728     for (N = N / 2 | 0; N; N = N >>> 1) {
3729       i++;
3730     }
3731
3732     return 1 << i + 1 + odd;
3733   };
3734
3735   FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
3736     if (N <= 1) return;
3737
3738     for (var i = 0; i < N / 2; i++) {
3739       var t = rws[i];
3740
3741       rws[i] = rws[N - i - 1];
3742       rws[N - i - 1] = t;
3743
3744       t = iws[i];
3745
3746       iws[i] = -iws[N - i - 1];
3747       iws[N - i - 1] = -t;
3748     }
3749   };
3750
3751   FFTM.prototype.normalize13b = function normalize13b (ws, N) {
3752     var carry = 0;
3753     for (var i = 0; i < N / 2; i++) {
3754       var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
3755         Math.round(ws[2 * i] / N) +
3756         carry;
3757
3758       ws[i] = w & 0x3ffffff;
3759
3760       if (w < 0x4000000) {
3761         carry = 0;
3762       } else {
3763         carry = w / 0x4000000 | 0;
3764       }
3765     }
3766
3767     return ws;
3768   };
3769
3770   FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
3771     var carry = 0;
3772     for (var i = 0; i < len; i++) {
3773       carry = carry + (ws[i] | 0);
3774
3775       rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
3776       rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
3777     }
3778
3779     // Pad with zeroes
3780     for (i = 2 * len; i < N; ++i) {
3781       rws[i] = 0;
3782     }
3783
3784     assert(carry === 0);
3785     assert((carry & ~0x1fff) === 0);
3786   };
3787
3788   FFTM.prototype.stub = function stub (N) {
3789     var ph = new Array(N);
3790     for (var i = 0; i < N; i++) {
3791       ph[i] = 0;
3792     }
3793
3794     return ph;
3795   };
3796
3797   FFTM.prototype.mulp = function mulp (x, y, out) {
3798     var N = 2 * this.guessLen13b(x.length, y.length);
3799
3800     var rbt = this.makeRBT(N);
3801
3802     var _ = this.stub(N);
3803
3804     var rws = new Array(N);
3805     var rwst = new Array(N);
3806     var iwst = new Array(N);
3807
3808     var nrws = new Array(N);
3809     var nrwst = new Array(N);
3810     var niwst = new Array(N);
3811
3812     var rmws = out.words;
3813     rmws.length = N;
3814
3815     this.convert13b(x.words, x.length, rws, N);
3816     this.convert13b(y.words, y.length, nrws, N);
3817
3818     this.transform(rws, _, rwst, iwst, N, rbt);
3819     this.transform(nrws, _, nrwst, niwst, N, rbt);
3820
3821     for (var i = 0; i < N; i++) {
3822       var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
3823       iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
3824       rwst[i] = rx;
3825     }
3826
3827     this.conjugate(rwst, iwst, N);
3828     this.transform(rwst, iwst, rmws, _, N, rbt);
3829     this.conjugate(rmws, _, N);
3830     this.normalize13b(rmws, N);
3831
3832     out.negative = x.negative ^ y.negative;
3833     out.length = x.length + y.length;
3834     return out.strip();
3835   };
3836
3837   // Multiply `this` by `num`
3838   BN.prototype.mul = function mul (num) {
3839     var out = new BN(null);
3840     out.words = new Array(this.length + num.length);
3841     return this.mulTo(num, out);
3842   };
3843
3844   // Multiply employing FFT
3845   BN.prototype.mulf = function mulf (num) {
3846     var out = new BN(null);
3847     out.words = new Array(this.length + num.length);
3848     return jumboMulTo(this, num, out);
3849   };
3850
3851   // In-place Multiplication
3852   BN.prototype.imul = function imul (num) {
3853     return this.clone().mulTo(num, this);
3854   };
3855
3856   BN.prototype.imuln = function imuln (num) {
3857     assert(typeof num === 'number');
3858     assert(num < 0x4000000);
3859
3860     // Carry
3861     var carry = 0;
3862     for (var i = 0; i < this.length; i++) {
3863       var w = (this.words[i] | 0) * num;
3864       var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
3865       carry >>= 26;
3866       carry += (w / 0x4000000) | 0;
3867       // NOTE: lo is 27bit maximum
3868       carry += lo >>> 26;
3869       this.words[i] = lo & 0x3ffffff;
3870     }
3871
3872     if (carry !== 0) {
3873       this.words[i] = carry;
3874       this.length++;
3875     }
3876
3877     return this;
3878   };
3879
3880   BN.prototype.muln = function muln (num) {
3881     return this.clone().imuln(num);
3882   };
3883
3884   // `this` * `this`
3885   BN.prototype.sqr = function sqr () {
3886     return this.mul(this);
3887   };
3888
3889   // `this` * `this` in-place
3890   BN.prototype.isqr = function isqr () {
3891     return this.imul(this.clone());
3892   };
3893
3894   // Math.pow(`this`, `num`)
3895   BN.prototype.pow = function pow (num) {
3896     var w = toBitArray(num);
3897     if (w.length === 0) return new BN(1);
3898
3899     // Skip leading zeroes
3900     var res = this;
3901     for (var i = 0; i < w.length; i++, res = res.sqr()) {
3902       if (w[i] !== 0) break;
3903     }
3904
3905     if (++i < w.length) {
3906       for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
3907         if (w[i] === 0) continue;
3908
3909         res = res.mul(q);
3910       }
3911     }
3912
3913     return res;
3914   };
3915
3916   // Shift-left in-place
3917   BN.prototype.iushln = function iushln (bits) {
3918     assert(typeof bits === 'number' && bits >= 0);
3919     var r = bits % 26;
3920     var s = (bits - r) / 26;
3921     var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
3922     var i;
3923
3924     if (r !== 0) {
3925       var carry = 0;
3926
3927       for (i = 0; i < this.length; i++) {
3928         var newCarry = this.words[i] & carryMask;
3929         var c = ((this.words[i] | 0) - newCarry) << r;
3930         this.words[i] = c | carry;
3931         carry = newCarry >>> (26 - r);
3932       }
3933
3934       if (carry) {
3935         this.words[i] = carry;
3936         this.length++;
3937       }
3938     }
3939
3940     if (s !== 0) {
3941       for (i = this.length - 1; i >= 0; i--) {
3942         this.words[i + s] = this.words[i];
3943       }
3944
3945       for (i = 0; i < s; i++) {
3946         this.words[i] = 0;
3947       }
3948
3949       this.length += s;
3950     }
3951
3952     return this.strip();
3953   };
3954
3955   BN.prototype.ishln = function ishln (bits) {
3956     // TODO(indutny): implement me
3957     assert(this.negative === 0);
3958     return this.iushln(bits);
3959   };
3960
3961   // Shift-right in-place
3962   // NOTE: `hint` is a lowest bit before trailing zeroes
3963   // NOTE: if `extended` is present - it will be filled with destroyed bits
3964   BN.prototype.iushrn = function iushrn (bits, hint, extended) {
3965     assert(typeof bits === 'number' && bits >= 0);
3966     var h;
3967     if (hint) {
3968       h = (hint - (hint % 26)) / 26;
3969     } else {
3970       h = 0;
3971     }
3972
3973     var r = bits % 26;
3974     var s = Math.min((bits - r) / 26, this.length);
3975     var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
3976     var maskedWords = extended;
3977
3978     h -= s;
3979     h = Math.max(0, h);
3980
3981     // Extended mode, copy masked part
3982     if (maskedWords) {
3983       for (var i = 0; i < s; i++) {
3984         maskedWords.words[i] = this.words[i];
3985       }
3986       maskedWords.length = s;
3987     }
3988
3989     if (s === 0) {
3990       // No-op, we should not move anything at all
3991     } else if (this.length > s) {
3992       this.length -= s;
3993       for (i = 0; i < this.length; i++) {
3994         this.words[i] = this.words[i + s];
3995       }
3996     } else {
3997       this.words[0] = 0;
3998       this.length = 1;
3999     }
4000
4001     var carry = 0;
4002     for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
4003       var word = this.words[i] | 0;
4004       this.words[i] = (carry << (26 - r)) | (word >>> r);
4005       carry = word & mask;
4006     }
4007
4008     // Push carried bits as a mask
4009     if (maskedWords && carry !== 0) {
4010       maskedWords.words[maskedWords.length++] = carry;
4011     }
4012
4013     if (this.length === 0) {
4014       this.words[0] = 0;
4015       this.length = 1;
4016     }
4017
4018     return this.strip();
4019   };
4020
4021   BN.prototype.ishrn = function ishrn (bits, hint, extended) {
4022     // TODO(indutny): implement me
4023     assert(this.negative === 0);
4024     return this.iushrn(bits, hint, extended);
4025   };
4026
4027   // Shift-left
4028   BN.prototype.shln = function shln (bits) {
4029     return this.clone().ishln(bits);
4030   };
4031
4032   BN.prototype.ushln = function ushln (bits) {
4033     return this.clone().iushln(bits);
4034   };
4035
4036   // Shift-right
4037   BN.prototype.shrn = function shrn (bits) {
4038     return this.clone().ishrn(bits);
4039   };
4040
4041   BN.prototype.ushrn = function ushrn (bits) {
4042     return this.clone().iushrn(bits);
4043   };
4044
4045   // Test if n bit is set
4046   BN.prototype.testn = function testn (bit) {
4047     assert(typeof bit === 'number' && bit >= 0);
4048     var r = bit % 26;
4049     var s = (bit - r) / 26;
4050     var q = 1 << r;
4051
4052     // Fast case: bit is much higher than all existing words
4053     if (this.length <= s) return false;
4054
4055     // Check bit and return
4056     var w = this.words[s];
4057
4058     return !!(w & q);
4059   };
4060
4061   // Return only lowers bits of number (in-place)
4062   BN.prototype.imaskn = function imaskn (bits) {
4063     assert(typeof bits === 'number' && bits >= 0);
4064     var r = bits % 26;
4065     var s = (bits - r) / 26;
4066
4067     assert(this.negative === 0, 'imaskn works only with positive numbers');
4068
4069     if (this.length <= s) {
4070       return this;
4071     }
4072
4073     if (r !== 0) {
4074       s++;
4075     }
4076     this.length = Math.min(s, this.length);
4077
4078     if (r !== 0) {
4079       var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
4080       this.words[this.length - 1] &= mask;
4081     }
4082
4083     return this.strip();
4084   };
4085
4086   // Return only lowers bits of number
4087   BN.prototype.maskn = function maskn (bits) {
4088     return this.clone().imaskn(bits);
4089   };
4090
4091   // Add plain number `num` to `this`
4092   BN.prototype.iaddn = function iaddn (num) {
4093     assert(typeof num === 'number');
4094     assert(num < 0x4000000);
4095     if (num < 0) return this.isubn(-num);
4096
4097     // Possible sign change
4098     if (this.negative !== 0) {
4099       if (this.length === 1 && (this.words[0] | 0) < num) {
4100         this.words[0] = num - (this.words[0] | 0);
4101         this.negative = 0;
4102         return this;
4103       }
4104
4105       this.negative = 0;
4106       this.isubn(num);
4107       this.negative = 1;
4108       return this;
4109     }
4110
4111     // Add without checks
4112     return this._iaddn(num);
4113   };
4114
4115   BN.prototype._iaddn = function _iaddn (num) {
4116     this.words[0] += num;
4117
4118     // Carry
4119     for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
4120       this.words[i] -= 0x4000000;
4121       if (i === this.length - 1) {
4122         this.words[i + 1] = 1;
4123       } else {
4124         this.words[i + 1]++;
4125       }
4126     }
4127     this.length = Math.max(this.length, i + 1);
4128
4129     return this;
4130   };
4131
4132   // Subtract plain number `num` from `this`
4133   BN.prototype.isubn = function isubn (num) {
4134     assert(typeof num === 'number');
4135     assert(num < 0x4000000);
4136     if (num < 0) return this.iaddn(-num);
4137
4138     if (this.negative !== 0) {
4139       this.negative = 0;
4140       this.iaddn(num);
4141       this.negative = 1;
4142       return this;
4143     }
4144
4145     this.words[0] -= num;
4146
4147     if (this.length === 1 && this.words[0] < 0) {
4148       this.words[0] = -this.words[0];
4149       this.negative = 1;
4150     } else {
4151       // Carry
4152       for (var i = 0; i < this.length && this.words[i] < 0; i++) {
4153         this.words[i] += 0x4000000;
4154         this.words[i + 1] -= 1;
4155       }
4156     }
4157
4158     return this.strip();
4159   };
4160
4161   BN.prototype.addn = function addn (num) {
4162     return this.clone().iaddn(num);
4163   };
4164
4165   BN.prototype.subn = function subn (num) {
4166     return this.clone().isubn(num);
4167   };
4168
4169   BN.prototype.iabs = function iabs () {
4170     this.negative = 0;
4171
4172     return this;
4173   };
4174
4175   BN.prototype.abs = function abs () {
4176     return this.clone().iabs();
4177   };
4178
4179   BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
4180     var len = num.length + shift;
4181     var i;
4182
4183     this._expand(len);
4184
4185     var w;
4186     var carry = 0;
4187     for (i = 0; i < num.length; i++) {
4188       w = (this.words[i + shift] | 0) + carry;
4189       var right = (num.words[i] | 0) * mul;
4190       w -= right & 0x3ffffff;
4191       carry = (w >> 26) - ((right / 0x4000000) | 0);
4192       this.words[i + shift] = w & 0x3ffffff;
4193     }
4194     for (; i < this.length - shift; i++) {
4195       w = (this.words[i + shift] | 0) + carry;
4196       carry = w >> 26;
4197       this.words[i + shift] = w & 0x3ffffff;
4198     }
4199
4200     if (carry === 0) return this.strip();
4201
4202     // Subtraction overflow
4203     assert(carry === -1);
4204     carry = 0;
4205     for (i = 0; i < this.length; i++) {
4206       w = -(this.words[i] | 0) + carry;
4207       carry = w >> 26;
4208       this.words[i] = w & 0x3ffffff;
4209     }
4210     this.negative = 1;
4211
4212     return this.strip();
4213   };
4214
4215   BN.prototype._wordDiv = function _wordDiv (num, mode) {
4216     var shift = this.length - num.length;
4217
4218     var a = this.clone();
4219     var b = num;
4220
4221     // Normalize
4222     var bhi = b.words[b.length - 1] | 0;
4223     var bhiBits = this._countBits(bhi);
4224     shift = 26 - bhiBits;
4225     if (shift !== 0) {
4226       b = b.ushln(shift);
4227       a.iushln(shift);
4228       bhi = b.words[b.length - 1] | 0;
4229     }
4230
4231     // Initialize quotient
4232     var m = a.length - b.length;
4233     var q;
4234
4235     if (mode !== 'mod') {
4236       q = new BN(null);
4237       q.length = m + 1;
4238       q.words = new Array(q.length);
4239       for (var i = 0; i < q.length; i++) {
4240         q.words[i] = 0;
4241       }
4242     }
4243
4244     var diff = a.clone()._ishlnsubmul(b, 1, m);
4245     if (diff.negative === 0) {
4246       a = diff;
4247       if (q) {
4248         q.words[m] = 1;
4249       }
4250     }
4251
4252     for (var j = m - 1; j >= 0; j--) {
4253       var qj = (a.words[b.length + j] | 0) * 0x4000000 +
4254         (a.words[b.length + j - 1] | 0);
4255
4256       // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
4257       // (0x7ffffff)
4258       qj = Math.min((qj / bhi) | 0, 0x3ffffff);
4259
4260       a._ishlnsubmul(b, qj, j);
4261       while (a.negative !== 0) {
4262         qj--;
4263         a.negative = 0;
4264         a._ishlnsubmul(b, 1, j);
4265         if (!a.isZero()) {
4266           a.negative ^= 1;
4267         }
4268       }
4269       if (q) {
4270         q.words[j] = qj;
4271       }
4272     }
4273     if (q) {
4274       q.strip();
4275     }
4276     a.strip();
4277
4278     // Denormalize
4279     if (mode !== 'div' && shift !== 0) {
4280       a.iushrn(shift);
4281     }
4282
4283     return {
4284       div: q || null,
4285       mod: a
4286     };
4287   };
4288
4289   // NOTE: 1) `mode` can be set to `mod` to request mod only,
4290   //       to `div` to request div only, or be absent to
4291   //       request both div & mod
4292   //       2) `positive` is true if unsigned mod is requested
4293   BN.prototype.divmod = function divmod (num, mode, positive) {
4294     assert(!num.isZero());
4295
4296     if (this.isZero()) {
4297       return {
4298         div: new BN(0),
4299         mod: new BN(0)
4300       };
4301     }
4302
4303     var div, mod, res;
4304     if (this.negative !== 0 && num.negative === 0) {
4305       res = this.neg().divmod(num, mode);
4306
4307       if (mode !== 'mod') {
4308         div = res.div.neg();
4309       }
4310
4311       if (mode !== 'div') {
4312         mod = res.mod.neg();
4313         if (positive && mod.negative !== 0) {
4314           mod.iadd(num);
4315         }
4316       }
4317
4318       return {
4319         div: div,
4320         mod: mod
4321       };
4322     }
4323
4324     if (this.negative === 0 && num.negative !== 0) {
4325       res = this.divmod(num.neg(), mode);
4326
4327       if (mode !== 'mod') {
4328         div = res.div.neg();
4329       }
4330
4331       return {
4332         div: div,
4333         mod: res.mod
4334       };
4335     }
4336
4337     if ((this.negative & num.negative) !== 0) {
4338       res = this.neg().divmod(num.neg(), mode);
4339
4340       if (mode !== 'div') {
4341         mod = res.mod.neg();
4342         if (positive && mod.negative !== 0) {
4343           mod.isub(num);
4344         }
4345       }
4346
4347       return {
4348         div: res.div,
4349         mod: mod
4350       };
4351     }
4352
4353     // Both numbers are positive at this point
4354
4355     // Strip both numbers to approximate shift value
4356     if (num.length > this.length || this.cmp(num) < 0) {
4357       return {
4358         div: new BN(0),
4359         mod: this
4360       };
4361     }
4362
4363     // Very short reduction
4364     if (num.length === 1) {
4365       if (mode === 'div') {
4366         return {
4367           div: this.divn(num.words[0]),
4368           mod: null
4369         };
4370       }
4371
4372       if (mode === 'mod') {
4373         return {
4374           div: null,
4375           mod: new BN(this.modn(num.words[0]))
4376         };
4377       }
4378
4379       return {
4380         div: this.divn(num.words[0]),
4381         mod: new BN(this.modn(num.words[0]))
4382       };
4383     }
4384
4385     return this._wordDiv(num, mode);
4386   };
4387
4388   // Find `this` / `num`
4389   BN.prototype.div = function div (num) {
4390     return this.divmod(num, 'div', false).div;
4391   };
4392
4393   // Find `this` % `num`
4394   BN.prototype.mod = function mod (num) {
4395     return this.divmod(num, 'mod', false).mod;
4396   };
4397
4398   BN.prototype.umod = function umod (num) {
4399     return this.divmod(num, 'mod', true).mod;
4400   };
4401
4402   // Find Round(`this` / `num`)
4403   BN.prototype.divRound = function divRound (num) {
4404     var dm = this.divmod(num);
4405
4406     // Fast case - exact division
4407     if (dm.mod.isZero()) return dm.div;
4408
4409     var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
4410
4411     var half = num.ushrn(1);
4412     var r2 = num.andln(1);
4413     var cmp = mod.cmp(half);
4414
4415     // Round down
4416     if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
4417
4418     // Round up
4419     return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
4420   };
4421
4422   BN.prototype.modn = function modn (num) {
4423     assert(num <= 0x3ffffff);
4424     var p = (1 << 26) % num;
4425
4426     var acc = 0;
4427     for (var i = this.length - 1; i >= 0; i--) {
4428       acc = (p * acc + (this.words[i] | 0)) % num;
4429     }
4430
4431     return acc;
4432   };
4433
4434   // In-place division by number
4435   BN.prototype.idivn = function idivn (num) {
4436     assert(num <= 0x3ffffff);
4437
4438     var carry = 0;
4439     for (var i = this.length - 1; i >= 0; i--) {
4440       var w = (this.words[i] | 0) + carry * 0x4000000;
4441       this.words[i] = (w / num) | 0;
4442       carry = w % num;
4443     }
4444
4445     return this.strip();
4446   };
4447
4448   BN.prototype.divn = function divn (num) {
4449     return this.clone().idivn(num);
4450   };
4451
4452   BN.prototype.egcd = function egcd (p) {
4453     assert(p.negative === 0);
4454     assert(!p.isZero());
4455
4456     var x = this;
4457     var y = p.clone();
4458
4459     if (x.negative !== 0) {
4460       x = x.umod(p);
4461     } else {
4462       x = x.clone();
4463     }
4464
4465     // A * x + B * y = x
4466     var A = new BN(1);
4467     var B = new BN(0);
4468
4469     // C * x + D * y = y
4470     var C = new BN(0);
4471     var D = new BN(1);
4472
4473     var g = 0;
4474
4475     while (x.isEven() && y.isEven()) {
4476       x.iushrn(1);
4477       y.iushrn(1);
4478       ++g;
4479     }
4480
4481     var yp = y.clone();
4482     var xp = x.clone();
4483
4484     while (!x.isZero()) {
4485       for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
4486       if (i > 0) {
4487         x.iushrn(i);
4488         while (i-- > 0) {
4489           if (A.isOdd() || B.isOdd()) {
4490             A.iadd(yp);
4491             B.isub(xp);
4492           }
4493
4494           A.iushrn(1);
4495           B.iushrn(1);
4496         }
4497       }
4498
4499       for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
4500       if (j > 0) {
4501         y.iushrn(j);
4502         while (j-- > 0) {
4503           if (C.isOdd() || D.isOdd()) {
4504             C.iadd(yp);
4505             D.isub(xp);
4506           }
4507
4508           C.iushrn(1);
4509           D.iushrn(1);
4510         }
4511       }
4512
4513       if (x.cmp(y) >= 0) {
4514         x.isub(y);
4515         A.isub(C);
4516         B.isub(D);
4517       } else {
4518         y.isub(x);
4519         C.isub(A);
4520         D.isub(B);
4521       }
4522     }
4523
4524     return {
4525       a: C,
4526       b: D,
4527       gcd: y.iushln(g)
4528     };
4529   };
4530
4531   // This is reduced incarnation of the binary EEA
4532   // above, designated to invert members of the
4533   // _prime_ fields F(p) at a maximal speed
4534   BN.prototype._invmp = function _invmp (p) {
4535     assert(p.negative === 0);
4536     assert(!p.isZero());
4537
4538     var a = this;
4539     var b = p.clone();
4540
4541     if (a.negative !== 0) {
4542       a = a.umod(p);
4543     } else {
4544       a = a.clone();
4545     }
4546
4547     var x1 = new BN(1);
4548     var x2 = new BN(0);
4549
4550     var delta = b.clone();
4551
4552     while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
4553       for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
4554       if (i > 0) {
4555         a.iushrn(i);
4556         while (i-- > 0) {
4557           if (x1.isOdd()) {
4558             x1.iadd(delta);
4559           }
4560
4561           x1.iushrn(1);
4562         }
4563       }
4564
4565       for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
4566       if (j > 0) {
4567         b.iushrn(j);
4568         while (j-- > 0) {
4569           if (x2.isOdd()) {
4570             x2.iadd(delta);
4571           }
4572
4573           x2.iushrn(1);
4574         }
4575       }
4576
4577       if (a.cmp(b) >= 0) {
4578         a.isub(b);
4579         x1.isub(x2);
4580       } else {
4581         b.isub(a);
4582         x2.isub(x1);
4583       }
4584     }
4585
4586     var res;
4587     if (a.cmpn(1) === 0) {
4588       res = x1;
4589     } else {
4590       res = x2;
4591     }
4592
4593     if (res.cmpn(0) < 0) {
4594       res.iadd(p);
4595     }
4596
4597     return res;
4598   };
4599
4600   BN.prototype.gcd = function gcd (num) {
4601     if (this.isZero()) return num.abs();
4602     if (num.isZero()) return this.abs();
4603
4604     var a = this.clone();
4605     var b = num.clone();
4606     a.negative = 0;
4607     b.negative = 0;
4608
4609     // Remove common factor of two
4610     for (var shift = 0; a.isEven() && b.isEven(); shift++) {
4611       a.iushrn(1);
4612       b.iushrn(1);
4613     }
4614
4615     do {
4616       while (a.isEven()) {
4617         a.iushrn(1);
4618       }
4619       while (b.isEven()) {
4620         b.iushrn(1);
4621       }
4622
4623       var r = a.cmp(b);
4624       if (r < 0) {
4625         // Swap `a` and `b` to make `a` always bigger than `b`
4626         var t = a;
4627         a = b;
4628         b = t;
4629       } else if (r === 0 || b.cmpn(1) === 0) {
4630         break;
4631       }
4632
4633       a.isub(b);
4634     } while (true);
4635
4636     return b.iushln(shift);
4637   };
4638
4639   // Invert number in the field F(num)
4640   BN.prototype.invm = function invm (num) {
4641     return this.egcd(num).a.umod(num);
4642   };
4643
4644   BN.prototype.isEven = function isEven () {
4645     return (this.words[0] & 1) === 0;
4646   };
4647
4648   BN.prototype.isOdd = function isOdd () {
4649     return (this.words[0] & 1) === 1;
4650   };
4651
4652   // And first word and num
4653   BN.prototype.andln = function andln (num) {
4654     return this.words[0] & num;
4655   };
4656
4657   // Increment at the bit position in-line
4658   BN.prototype.bincn = function bincn (bit) {
4659     assert(typeof bit === 'number');
4660     var r = bit % 26;
4661     var s = (bit - r) / 26;
4662     var q = 1 << r;
4663
4664     // Fast case: bit is much higher than all existing words
4665     if (this.length <= s) {
4666       this._expand(s + 1);
4667       this.words[s] |= q;
4668       return this;
4669     }
4670
4671     // Add bit and propagate, if needed
4672     var carry = q;
4673     for (var i = s; carry !== 0 && i < this.length; i++) {
4674       var w = this.words[i] | 0;
4675       w += carry;
4676       carry = w >>> 26;
4677       w &= 0x3ffffff;
4678       this.words[i] = w;
4679     }
4680     if (carry !== 0) {
4681       this.words[i] = carry;
4682       this.length++;
4683     }
4684     return this;
4685   };
4686
4687   BN.prototype.isZero = function isZero () {
4688     return this.length === 1 && this.words[0] === 0;
4689   };
4690
4691   BN.prototype.cmpn = function cmpn (num) {
4692     var negative = num < 0;
4693
4694     if (this.negative !== 0 && !negative) return -1;
4695     if (this.negative === 0 && negative) return 1;
4696
4697     this.strip();
4698
4699     var res;
4700     if (this.length > 1) {
4701       res = 1;
4702     } else {
4703       if (negative) {
4704         num = -num;
4705       }
4706
4707       assert(num <= 0x3ffffff, 'Number is too big');
4708
4709       var w = this.words[0] | 0;
4710       res = w === num ? 0 : w < num ? -1 : 1;
4711     }
4712     if (this.negative !== 0) return -res | 0;
4713     return res;
4714   };
4715
4716   // Compare two numbers and return:
4717   // 1 - if `this` > `num`
4718   // 0 - if `this` == `num`
4719   // -1 - if `this` < `num`
4720   BN.prototype.cmp = function cmp (num) {
4721     if (this.negative !== 0 && num.negative === 0) return -1;
4722     if (this.negative === 0 && num.negative !== 0) return 1;
4723
4724     var res = this.ucmp(num);
4725     if (this.negative !== 0) return -res | 0;
4726     return res;
4727   };
4728
4729   // Unsigned comparison
4730   BN.prototype.ucmp = function ucmp (num) {
4731     // At this point both numbers have the same sign
4732     if (this.length > num.length) return 1;
4733     if (this.length < num.length) return -1;
4734
4735     var res = 0;
4736     for (var i = this.length - 1; i >= 0; i--) {
4737       var a = this.words[i] | 0;
4738       var b = num.words[i] | 0;
4739
4740       if (a === b) continue;
4741       if (a < b) {
4742         res = -1;
4743       } else if (a > b) {
4744         res = 1;
4745       }
4746       break;
4747     }
4748     return res;
4749   };
4750
4751   BN.prototype.gtn = function gtn (num) {
4752     return this.cmpn(num) === 1;
4753   };
4754
4755   BN.prototype.gt = function gt (num) {
4756     return this.cmp(num) === 1;
4757   };
4758
4759   BN.prototype.gten = function gten (num) {
4760     return this.cmpn(num) >= 0;
4761   };
4762
4763   BN.prototype.gte = function gte (num) {
4764     return this.cmp(num) >= 0;
4765   };
4766
4767   BN.prototype.ltn = function ltn (num) {
4768     return this.cmpn(num) === -1;
4769   };
4770
4771   BN.prototype.lt = function lt (num) {
4772     return this.cmp(num) === -1;
4773   };
4774
4775   BN.prototype.lten = function lten (num) {
4776     return this.cmpn(num) <= 0;
4777   };
4778
4779   BN.prototype.lte = function lte (num) {
4780     return this.cmp(num) <= 0;
4781   };
4782
4783   BN.prototype.eqn = function eqn (num) {
4784     return this.cmpn(num) === 0;
4785   };
4786
4787   BN.prototype.eq = function eq (num) {
4788     return this.cmp(num) === 0;
4789   };
4790
4791   //
4792   // A reduce context, could be using montgomery or something better, depending
4793   // on the `m` itself.
4794   //
4795   BN.red = function red (num) {
4796     return new Red(num);
4797   };
4798
4799   BN.prototype.toRed = function toRed (ctx) {
4800     assert(!this.red, 'Already a number in reduction context');
4801     assert(this.negative === 0, 'red works only with positives');
4802     return ctx.convertTo(this)._forceRed(ctx);
4803   };
4804
4805   BN.prototype.fromRed = function fromRed () {
4806     assert(this.red, 'fromRed works only with numbers in reduction context');
4807     return this.red.convertFrom(this);
4808   };
4809
4810   BN.prototype._forceRed = function _forceRed (ctx) {
4811     this.red = ctx;
4812     return this;
4813   };
4814
4815   BN.prototype.forceRed = function forceRed (ctx) {
4816     assert(!this.red, 'Already a number in reduction context');
4817     return this._forceRed(ctx);
4818   };
4819
4820   BN.prototype.redAdd = function redAdd (num) {
4821     assert(this.red, 'redAdd works only with red numbers');
4822     return this.red.add(this, num);
4823   };
4824
4825   BN.prototype.redIAdd = function redIAdd (num) {
4826     assert(this.red, 'redIAdd works only with red numbers');
4827     return this.red.iadd(this, num);
4828   };
4829
4830   BN.prototype.redSub = function redSub (num) {
4831     assert(this.red, 'redSub works only with red numbers');
4832     return this.red.sub(this, num);
4833   };
4834
4835   BN.prototype.redISub = function redISub (num) {
4836     assert(this.red, 'redISub works only with red numbers');
4837     return this.red.isub(this, num);
4838   };
4839
4840   BN.prototype.redShl = function redShl (num) {
4841     assert(this.red, 'redShl works only with red numbers');
4842     return this.red.shl(this, num);
4843   };
4844
4845   BN.prototype.redMul = function redMul (num) {
4846     assert(this.red, 'redMul works only with red numbers');
4847     this.red._verify2(this, num);
4848     return this.red.mul(this, num);
4849   };
4850
4851   BN.prototype.redIMul = function redIMul (num) {
4852     assert(this.red, 'redMul works only with red numbers');
4853     this.red._verify2(this, num);
4854     return this.red.imul(this, num);
4855   };
4856
4857   BN.prototype.redSqr = function redSqr () {
4858     assert(this.red, 'redSqr works only with red numbers');
4859     this.red._verify1(this);
4860     return this.red.sqr(this);
4861   };
4862
4863   BN.prototype.redISqr = function redISqr () {
4864     assert(this.red, 'redISqr works only with red numbers');
4865     this.red._verify1(this);
4866     return this.red.isqr(this);
4867   };
4868
4869   // Square root over p
4870   BN.prototype.redSqrt = function redSqrt () {
4871     assert(this.red, 'redSqrt works only with red numbers');
4872     this.red._verify1(this);
4873     return this.red.sqrt(this);
4874   };
4875
4876   BN.prototype.redInvm = function redInvm () {
4877     assert(this.red, 'redInvm works only with red numbers');
4878     this.red._verify1(this);
4879     return this.red.invm(this);
4880   };
4881
4882   // Return negative clone of `this` % `red modulo`
4883   BN.prototype.redNeg = function redNeg () {
4884     assert(this.red, 'redNeg works only with red numbers');
4885     this.red._verify1(this);
4886     return this.red.neg(this);
4887   };
4888
4889   BN.prototype.redPow = function redPow (num) {
4890     assert(this.red && !num.red, 'redPow(normalNum)');
4891     this.red._verify1(this);
4892     return this.red.pow(this, num);
4893   };
4894
4895   // Prime numbers with efficient reduction
4896   var primes = {
4897     k256: null,
4898     p224: null,
4899     p192: null,
4900     p25519: null
4901   };
4902
4903   // Pseudo-Mersenne prime
4904   function MPrime (name, p) {
4905     // P = 2 ^ N - K
4906     this.name = name;
4907     this.p = new BN(p, 16);
4908     this.n = this.p.bitLength();
4909     this.k = new BN(1).iushln(this.n).isub(this.p);
4910
4911     this.tmp = this._tmp();
4912   }
4913
4914   MPrime.prototype._tmp = function _tmp () {
4915     var tmp = new BN(null);
4916     tmp.words = new Array(Math.ceil(this.n / 13));
4917     return tmp;
4918   };
4919
4920   MPrime.prototype.ireduce = function ireduce (num) {
4921     // Assumes that `num` is less than `P^2`
4922     // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
4923     var r = num;
4924     var rlen;
4925
4926     do {
4927       this.split(r, this.tmp);
4928       r = this.imulK(r);
4929       r = r.iadd(this.tmp);
4930       rlen = r.bitLength();
4931     } while (rlen > this.n);
4932
4933     var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
4934     if (cmp === 0) {
4935       r.words[0] = 0;
4936       r.length = 1;
4937     } else if (cmp > 0) {
4938       r.isub(this.p);
4939     } else {
4940       r.strip();
4941     }
4942
4943     return r;
4944   };
4945
4946   MPrime.prototype.split = function split (input, out) {
4947     input.iushrn(this.n, 0, out);
4948   };
4949
4950   MPrime.prototype.imulK = function imulK (num) {
4951     return num.imul(this.k);
4952   };
4953
4954   function K256 () {
4955     MPrime.call(
4956       this,
4957       'k256',
4958       'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
4959   }
4960   inherits(K256, MPrime);
4961
4962   K256.prototype.split = function split (input, output) {
4963     // 256 = 9 * 26 + 22
4964     var mask = 0x3fffff;
4965
4966     var outLen = Math.min(input.length, 9);
4967     for (var i = 0; i < outLen; i++) {
4968       output.words[i] = input.words[i];
4969     }
4970     output.length = outLen;
4971
4972     if (input.length <= 9) {
4973       input.words[0] = 0;
4974       input.length = 1;
4975       return;
4976     }
4977
4978     // Shift by 9 limbs
4979     var prev = input.words[9];
4980     output.words[output.length++] = prev & mask;
4981
4982     for (i = 10; i < input.length; i++) {
4983       var next = input.words[i] | 0;
4984       input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
4985       prev = next;
4986     }
4987     prev >>>= 22;
4988     input.words[i - 10] = prev;
4989     if (prev === 0 && input.length > 10) {
4990       input.length -= 10;
4991     } else {
4992       input.length -= 9;
4993     }
4994   };
4995
4996   K256.prototype.imulK = function imulK (num) {
4997     // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
4998     num.words[num.length] = 0;
4999     num.words[num.length + 1] = 0;
5000     num.length += 2;
5001
5002     // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
5003     var lo = 0;
5004     for (var i = 0; i < num.length; i++) {
5005       var w = num.words[i] | 0;
5006       lo += w * 0x3d1;
5007       num.words[i] = lo & 0x3ffffff;
5008       lo = w * 0x40 + ((lo / 0x4000000) | 0);
5009     }
5010
5011     // Fast length reduction
5012     if (num.words[num.length - 1] === 0) {
5013       num.length--;
5014       if (num.words[num.length - 1] === 0) {
5015         num.length--;
5016       }
5017     }
5018     return num;
5019   };
5020
5021   function P224 () {
5022     MPrime.call(
5023       this,
5024       'p224',
5025       'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
5026   }
5027   inherits(P224, MPrime);
5028
5029   function P192 () {
5030     MPrime.call(
5031       this,
5032       'p192',
5033       'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
5034   }
5035   inherits(P192, MPrime);
5036
5037   function P25519 () {
5038     // 2 ^ 255 - 19
5039     MPrime.call(
5040       this,
5041       '25519',
5042       '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
5043   }
5044   inherits(P25519, MPrime);
5045
5046   P25519.prototype.imulK = function imulK (num) {
5047     // K = 0x13
5048     var carry = 0;
5049     for (var i = 0; i < num.length; i++) {
5050       var hi = (num.words[i] | 0) * 0x13 + carry;
5051       var lo = hi & 0x3ffffff;
5052       hi >>>= 26;
5053
5054       num.words[i] = lo;
5055       carry = hi;
5056     }
5057     if (carry !== 0) {
5058       num.words[num.length++] = carry;
5059     }
5060     return num;
5061   };
5062
5063   // Exported mostly for testing purposes, use plain name instead
5064   BN._prime = function prime (name) {
5065     // Cached version of prime
5066     if (primes[name]) return primes[name];
5067
5068     var prime;
5069     if (name === 'k256') {
5070       prime = new K256();
5071     } else if (name === 'p224') {
5072       prime = new P224();
5073     } else if (name === 'p192') {
5074       prime = new P192();
5075     } else if (name === 'p25519') {
5076       prime = new P25519();
5077     } else {
5078       throw new Error('Unknown prime ' + name);
5079     }
5080     primes[name] = prime;
5081
5082     return prime;
5083   };
5084
5085   //
5086   // Base reduction engine
5087   //
5088   function Red (m) {
5089     if (typeof m === 'string') {
5090       var prime = BN._prime(m);
5091       this.m = prime.p;
5092       this.prime = prime;
5093     } else {
5094       assert(m.gtn(1), 'modulus must be greater than 1');
5095       this.m = m;
5096       this.prime = null;
5097     }
5098   }
5099
5100   Red.prototype._verify1 = function _verify1 (a) {
5101     assert(a.negative === 0, 'red works only with positives');
5102     assert(a.red, 'red works only with red numbers');
5103   };
5104
5105   Red.prototype._verify2 = function _verify2 (a, b) {
5106     assert((a.negative | b.negative) === 0, 'red works only with positives');
5107     assert(a.red && a.red === b.red,
5108       'red works only with red numbers');
5109   };
5110
5111   Red.prototype.imod = function imod (a) {
5112     if (this.prime) return this.prime.ireduce(a)._forceRed(this);
5113     return a.umod(this.m)._forceRed(this);
5114   };
5115
5116   Red.prototype.neg = function neg (a) {
5117     if (a.isZero()) {
5118       return a.clone();
5119     }
5120
5121     return this.m.sub(a)._forceRed(this);
5122   };
5123
5124   Red.prototype.add = function add (a, b) {
5125     this._verify2(a, b);
5126
5127     var res = a.add(b);
5128     if (res.cmp(this.m) >= 0) {
5129       res.isub(this.m);
5130     }
5131     return res._forceRed(this);
5132   };
5133
5134   Red.prototype.iadd = function iadd (a, b) {
5135     this._verify2(a, b);
5136
5137     var res = a.iadd(b);
5138     if (res.cmp(this.m) >= 0) {
5139       res.isub(this.m);
5140     }
5141     return res;
5142   };
5143
5144   Red.prototype.sub = function sub (a, b) {
5145     this._verify2(a, b);
5146
5147     var res = a.sub(b);
5148     if (res.cmpn(0) < 0) {
5149       res.iadd(this.m);
5150     }
5151     return res._forceRed(this);
5152   };
5153
5154   Red.prototype.isub = function isub (a, b) {
5155     this._verify2(a, b);
5156
5157     var res = a.isub(b);
5158     if (res.cmpn(0) < 0) {
5159       res.iadd(this.m);
5160     }
5161     return res;
5162   };
5163
5164   Red.prototype.shl = function shl (a, num) {
5165     this._verify1(a);
5166     return this.imod(a.ushln(num));
5167   };
5168
5169   Red.prototype.imul = function imul (a, b) {
5170     this._verify2(a, b);
5171     return this.imod(a.imul(b));
5172   };
5173
5174   Red.prototype.mul = function mul (a, b) {
5175     this._verify2(a, b);
5176     return this.imod(a.mul(b));
5177   };
5178
5179   Red.prototype.isqr = function isqr (a) {
5180     return this.imul(a, a.clone());
5181   };
5182
5183   Red.prototype.sqr = function sqr (a) {
5184     return this.mul(a, a);
5185   };
5186
5187   Red.prototype.sqrt = function sqrt (a) {
5188     if (a.isZero()) return a.clone();
5189
5190     var mod3 = this.m.andln(3);
5191     assert(mod3 % 2 === 1);
5192
5193     // Fast case
5194     if (mod3 === 3) {
5195       var pow = this.m.add(new BN(1)).iushrn(2);
5196       return this.pow(a, pow);
5197     }
5198
5199     // Tonelli-Shanks algorithm (Totally unoptimized and slow)
5200     //
5201     // Find Q and S, that Q * 2 ^ S = (P - 1)
5202     var q = this.m.subn(1);
5203     var s = 0;
5204     while (!q.isZero() && q.andln(1) === 0) {
5205       s++;
5206       q.iushrn(1);
5207     }
5208     assert(!q.isZero());
5209
5210     var one = new BN(1).toRed(this);
5211     var nOne = one.redNeg();
5212
5213     // Find quadratic non-residue
5214     // NOTE: Max is such because of generalized Riemann hypothesis.
5215     var lpow = this.m.subn(1).iushrn(1);
5216     var z = this.m.bitLength();
5217     z = new BN(2 * z * z).toRed(this);
5218
5219     while (this.pow(z, lpow).cmp(nOne) !== 0) {
5220       z.redIAdd(nOne);
5221     }
5222
5223     var c = this.pow(z, q);
5224     var r = this.pow(a, q.addn(1).iushrn(1));
5225     var t = this.pow(a, q);
5226     var m = s;
5227     while (t.cmp(one) !== 0) {
5228       var tmp = t;
5229       for (var i = 0; tmp.cmp(one) !== 0; i++) {
5230         tmp = tmp.redSqr();
5231       }
5232       assert(i < m);
5233       var b = this.pow(c, new BN(1).iushln(m - i - 1));
5234
5235       r = r.redMul(b);
5236       c = b.redSqr();
5237       t = t.redMul(c);
5238       m = i;
5239     }
5240
5241     return r;
5242   };
5243
5244   Red.prototype.invm = function invm (a) {
5245     var inv = a._invmp(this.m);
5246     if (inv.negative !== 0) {
5247       inv.negative = 0;
5248       return this.imod(inv).redNeg();
5249     } else {
5250       return this.imod(inv);
5251     }
5252   };
5253
5254   Red.prototype.pow = function pow (a, num) {
5255     if (num.isZero()) return new BN(1).toRed(this);
5256     if (num.cmpn(1) === 0) return a.clone();
5257
5258     var windowSize = 4;
5259     var wnd = new Array(1 << windowSize);
5260     wnd[0] = new BN(1).toRed(this);
5261     wnd[1] = a;
5262     for (var i = 2; i < wnd.length; i++) {
5263       wnd[i] = this.mul(wnd[i - 1], a);
5264     }
5265
5266     var res = wnd[0];
5267     var current = 0;
5268     var currentLen = 0;
5269     var start = num.bitLength() % 26;
5270     if (start === 0) {
5271       start = 26;
5272     }
5273
5274     for (i = num.length - 1; i >= 0; i--) {
5275       var word = num.words[i];
5276       for (var j = start - 1; j >= 0; j--) {
5277         var bit = (word >> j) & 1;
5278         if (res !== wnd[0]) {
5279           res = this.sqr(res);
5280         }
5281
5282         if (bit === 0 && current === 0) {
5283           currentLen = 0;
5284           continue;
5285         }
5286
5287         current <<= 1;
5288         current |= bit;
5289         currentLen++;
5290         if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
5291
5292         res = this.mul(res, wnd[current]);
5293         currentLen = 0;
5294         current = 0;
5295       }
5296       start = 26;
5297     }
5298
5299     return res;
5300   };
5301
5302   Red.prototype.convertTo = function convertTo (num) {
5303     var r = num.umod(this.m);
5304
5305     return r === num ? r.clone() : r;
5306   };
5307
5308   Red.prototype.convertFrom = function convertFrom (num) {
5309     var res = num.clone();
5310     res.red = null;
5311     return res;
5312   };
5313
5314   //
5315   // Montgomery method engine
5316   //
5317
5318   BN.mont = function mont (num) {
5319     return new Mont(num);
5320   };
5321
5322   function Mont (m) {
5323     Red.call(this, m);
5324
5325     this.shift = this.m.bitLength();
5326     if (this.shift % 26 !== 0) {
5327       this.shift += 26 - (this.shift % 26);
5328     }
5329
5330     this.r = new BN(1).iushln(this.shift);
5331     this.r2 = this.imod(this.r.sqr());
5332     this.rinv = this.r._invmp(this.m);
5333
5334     this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
5335     this.minv = this.minv.umod(this.r);
5336     this.minv = this.r.sub(this.minv);
5337   }
5338   inherits(Mont, Red);
5339
5340   Mont.prototype.convertTo = function convertTo (num) {
5341     return this.imod(num.ushln(this.shift));
5342   };
5343
5344   Mont.prototype.convertFrom = function convertFrom (num) {
5345     var r = this.imod(num.mul(this.rinv));
5346     r.red = null;
5347     return r;
5348   };
5349
5350   Mont.prototype.imul = function imul (a, b) {
5351     if (a.isZero() || b.isZero()) {
5352       a.words[0] = 0;
5353       a.length = 1;
5354       return a;
5355     }
5356
5357     var t = a.imul(b);
5358     var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
5359     var u = t.isub(c).iushrn(this.shift);
5360     var res = u;
5361
5362     if (u.cmp(this.m) >= 0) {
5363       res = u.isub(this.m);
5364     } else if (u.cmpn(0) < 0) {
5365       res = u.iadd(this.m);
5366     }
5367
5368     return res._forceRed(this);
5369   };
5370
5371   Mont.prototype.mul = function mul (a, b) {
5372     if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
5373
5374     var t = a.mul(b);
5375     var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
5376     var u = t.isub(c).iushrn(this.shift);
5377     var res = u;
5378     if (u.cmp(this.m) >= 0) {
5379       res = u.isub(this.m);
5380     } else if (u.cmpn(0) < 0) {
5381       res = u.iadd(this.m);
5382     }
5383
5384     return res._forceRed(this);
5385   };
5386
5387   Mont.prototype.invm = function invm (a) {
5388     // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
5389     var res = this.imod(a._invmp(this.m).mul(this.r2));
5390     return res._forceRed(this);
5391   };
5392 })(typeof module === 'undefined' || module, this);
5393
5394 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(128)(module)))
5395
5396 /***/ }),
5397 /* 5 */
5398 /***/ (function(module, exports) {
5399
5400 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
5401 var global = module.exports = typeof window != 'undefined' && window.Math == Math
5402   ? window : typeof self != 'undefined' && self.Math == Math ? self
5403   // eslint-disable-next-line no-new-func
5404   : Function('return this')();
5405 if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
5406
5407
5408 /***/ }),
5409 /* 6 */
5410 /***/ (function(module, exports, __webpack_require__) {
5411
5412 "use strict";
5413
5414
5415 var elliptic = exports;
5416
5417 elliptic.version = __webpack_require__(223).version;
5418 elliptic.utils = __webpack_require__(224);
5419 elliptic.rand = __webpack_require__(115);
5420 elliptic.curve = __webpack_require__(45);
5421 elliptic.curves = __webpack_require__(229);
5422
5423 // Protocols
5424 elliptic.ec = __webpack_require__(237);
5425 elliptic.eddsa = __webpack_require__(241);
5426
5427
5428 /***/ }),
5429 /* 7 */
5430 /***/ (function(module, exports, __webpack_require__) {
5431
5432 var store = __webpack_require__(70)('wks');
5433 var uid = __webpack_require__(47);
5434 var Symbol = __webpack_require__(5).Symbol;
5435 var USE_SYMBOL = typeof Symbol == 'function';
5436
5437 var $exports = module.exports = function (name) {
5438   return store[name] || (store[name] =
5439     USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
5440 };
5441
5442 $exports.store = store;
5443
5444
5445 /***/ }),
5446 /* 8 */
5447 /***/ (function(module, exports) {
5448
5449 var core = module.exports = { version: '2.5.7' };
5450 if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
5451
5452
5453 /***/ }),
5454 /* 9 */
5455 /***/ (function(module, exports) {
5456
5457 module.exports = assert;
5458
5459 function assert(val, msg) {
5460   if (!val)
5461     throw new Error(msg || 'Assertion failed');
5462 }
5463
5464 assert.equal = function assertEqual(l, r, msg) {
5465   if (l != r)
5466     throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
5467 };
5468
5469
5470 /***/ }),
5471 /* 10 */
5472 /***/ (function(module, exports) {
5473
5474 var g;\r
5475 \r
5476 // This works in non-strict mode\r
5477 g = (function() {\r
5478         return this;\r
5479 })();\r
5480 \r
5481 try {\r
5482         // This works if eval is allowed (see CSP)\r
5483         g = g || Function("return this")() || (1,eval)("this");\r
5484 } catch(e) {\r
5485         // This works if the window reference is available\r
5486         if(typeof window === "object")\r
5487                 g = window;\r
5488 }\r
5489 \r
5490 // g can still be undefined, but nothing to do about it...\r
5491 // We return undefined, instead of nothing here, so it's\r
5492 // easier to handle this case. if(!global) { ...}\r
5493 \r
5494 module.exports = g;\r
5495
5496
5497 /***/ }),
5498 /* 11 */
5499 /***/ (function(module, exports, __webpack_require__) {
5500
5501 "use strict";
5502
5503
5504 var assert = __webpack_require__(9);
5505 var inherits = __webpack_require__(1);
5506
5507 exports.inherits = inherits;
5508
5509 function toArray(msg, enc) {
5510   if (Array.isArray(msg))
5511     return msg.slice();
5512   if (!msg)
5513     return [];
5514   var res = [];
5515   if (typeof msg === 'string') {
5516     if (!enc) {
5517       for (var i = 0; i < msg.length; i++) {
5518         var c = msg.charCodeAt(i);
5519         var hi = c >> 8;
5520         var lo = c & 0xff;
5521         if (hi)
5522           res.push(hi, lo);
5523         else
5524           res.push(lo);
5525       }
5526     } else if (enc === 'hex') {
5527       msg = msg.replace(/[^a-z0-9]+/ig, '');
5528       if (msg.length % 2 !== 0)
5529         msg = '0' + msg;
5530       for (i = 0; i < msg.length; i += 2)
5531         res.push(parseInt(msg[i] + msg[i + 1], 16));
5532     }
5533   } else {
5534     for (i = 0; i < msg.length; i++)
5535       res[i] = msg[i] | 0;
5536   }
5537   return res;
5538 }
5539 exports.toArray = toArray;
5540
5541 function toHex(msg) {
5542   var res = '';
5543   for (var i = 0; i < msg.length; i++)
5544     res += zero2(msg[i].toString(16));
5545   return res;
5546 }
5547 exports.toHex = toHex;
5548
5549 function htonl(w) {
5550   var res = (w >>> 24) |
5551             ((w >>> 8) & 0xff00) |
5552             ((w << 8) & 0xff0000) |
5553             ((w & 0xff) << 24);
5554   return res >>> 0;
5555 }
5556 exports.htonl = htonl;
5557
5558 function toHex32(msg, endian) {
5559   var res = '';
5560   for (var i = 0; i < msg.length; i++) {
5561     var w = msg[i];
5562     if (endian === 'little')
5563       w = htonl(w);
5564     res += zero8(w.toString(16));
5565   }
5566   return res;
5567 }
5568 exports.toHex32 = toHex32;
5569
5570 function zero2(word) {
5571   if (word.length === 1)
5572     return '0' + word;
5573   else
5574     return word;
5575 }
5576 exports.zero2 = zero2;
5577
5578 function zero8(word) {
5579   if (word.length === 7)
5580     return '0' + word;
5581   else if (word.length === 6)
5582     return '00' + word;
5583   else if (word.length === 5)
5584     return '000' + word;
5585   else if (word.length === 4)
5586     return '0000' + word;
5587   else if (word.length === 3)
5588     return '00000' + word;
5589   else if (word.length === 2)
5590     return '000000' + word;
5591   else if (word.length === 1)
5592     return '0000000' + word;
5593   else
5594     return word;
5595 }
5596 exports.zero8 = zero8;
5597
5598 function join32(msg, start, end, endian) {
5599   var len = end - start;
5600   assert(len % 4 === 0);
5601   var res = new Array(len / 4);
5602   for (var i = 0, k = start; i < res.length; i++, k += 4) {
5603     var w;
5604     if (endian === 'big')
5605       w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
5606     else
5607       w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
5608     res[i] = w >>> 0;
5609   }
5610   return res;
5611 }
5612 exports.join32 = join32;
5613
5614 function split32(msg, endian) {
5615   var res = new Array(msg.length * 4);
5616   for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
5617     var m = msg[i];
5618     if (endian === 'big') {
5619       res[k] = m >>> 24;
5620       res[k + 1] = (m >>> 16) & 0xff;
5621       res[k + 2] = (m >>> 8) & 0xff;
5622       res[k + 3] = m & 0xff;
5623     } else {
5624       res[k + 3] = m >>> 24;
5625       res[k + 2] = (m >>> 16) & 0xff;
5626       res[k + 1] = (m >>> 8) & 0xff;
5627       res[k] = m & 0xff;
5628     }
5629   }
5630   return res;
5631 }
5632 exports.split32 = split32;
5633
5634 function rotr32(w, b) {
5635   return (w >>> b) | (w << (32 - b));
5636 }
5637 exports.rotr32 = rotr32;
5638
5639 function rotl32(w, b) {
5640   return (w << b) | (w >>> (32 - b));
5641 }
5642 exports.rotl32 = rotl32;
5643
5644 function sum32(a, b) {
5645   return (a + b) >>> 0;
5646 }
5647 exports.sum32 = sum32;
5648
5649 function sum32_3(a, b, c) {
5650   return (a + b + c) >>> 0;
5651 }
5652 exports.sum32_3 = sum32_3;
5653
5654 function sum32_4(a, b, c, d) {
5655   return (a + b + c + d) >>> 0;
5656 }
5657 exports.sum32_4 = sum32_4;
5658
5659 function sum32_5(a, b, c, d, e) {
5660   return (a + b + c + d + e) >>> 0;
5661 }
5662 exports.sum32_5 = sum32_5;
5663
5664 function sum64(buf, pos, ah, al) {
5665   var bh = buf[pos];
5666   var bl = buf[pos + 1];
5667
5668   var lo = (al + bl) >>> 0;
5669   var hi = (lo < al ? 1 : 0) + ah + bh;
5670   buf[pos] = hi >>> 0;
5671   buf[pos + 1] = lo;
5672 }
5673 exports.sum64 = sum64;
5674
5675 function sum64_hi(ah, al, bh, bl) {
5676   var lo = (al + bl) >>> 0;
5677   var hi = (lo < al ? 1 : 0) + ah + bh;
5678   return hi >>> 0;
5679 }
5680 exports.sum64_hi = sum64_hi;
5681
5682 function sum64_lo(ah, al, bh, bl) {
5683   var lo = al + bl;
5684   return lo >>> 0;
5685 }
5686 exports.sum64_lo = sum64_lo;
5687
5688 function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
5689   var carry = 0;
5690   var lo = al;
5691   lo = (lo + bl) >>> 0;
5692   carry += lo < al ? 1 : 0;
5693   lo = (lo + cl) >>> 0;
5694   carry += lo < cl ? 1 : 0;
5695   lo = (lo + dl) >>> 0;
5696   carry += lo < dl ? 1 : 0;
5697
5698   var hi = ah + bh + ch + dh + carry;
5699   return hi >>> 0;
5700 }
5701 exports.sum64_4_hi = sum64_4_hi;
5702
5703 function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
5704   var lo = al + bl + cl + dl;
5705   return lo >>> 0;
5706 }
5707 exports.sum64_4_lo = sum64_4_lo;
5708
5709 function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
5710   var carry = 0;
5711   var lo = al;
5712   lo = (lo + bl) >>> 0;
5713   carry += lo < al ? 1 : 0;
5714   lo = (lo + cl) >>> 0;
5715   carry += lo < cl ? 1 : 0;
5716   lo = (lo + dl) >>> 0;
5717   carry += lo < dl ? 1 : 0;
5718   lo = (lo + el) >>> 0;
5719   carry += lo < el ? 1 : 0;
5720
5721   var hi = ah + bh + ch + dh + eh + carry;
5722   return hi >>> 0;
5723 }
5724 exports.sum64_5_hi = sum64_5_hi;
5725
5726 function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
5727   var lo = al + bl + cl + dl + el;
5728
5729   return lo >>> 0;
5730 }
5731 exports.sum64_5_lo = sum64_5_lo;
5732
5733 function rotr64_hi(ah, al, num) {
5734   var r = (al << (32 - num)) | (ah >>> num);
5735   return r >>> 0;
5736 }
5737 exports.rotr64_hi = rotr64_hi;
5738
5739 function rotr64_lo(ah, al, num) {
5740   var r = (ah << (32 - num)) | (al >>> num);
5741   return r >>> 0;
5742 }
5743 exports.rotr64_lo = rotr64_lo;
5744
5745 function shr64_hi(ah, al, num) {
5746   return ah >>> num;
5747 }
5748 exports.shr64_hi = shr64_hi;
5749
5750 function shr64_lo(ah, al, num) {
5751   var r = (ah << (32 - num)) | (al >>> num);
5752   return r >>> 0;
5753 }
5754 exports.shr64_lo = shr64_lo;
5755
5756
5757 /***/ }),
5758 /* 12 */
5759 /***/ (function(module, exports) {
5760
5761 module.exports = function (it) {
5762   return typeof it === 'object' ? it !== null : typeof it === 'function';
5763 };
5764
5765
5766 /***/ }),
5767 /* 13 */
5768 /***/ (function(module, exports, __webpack_require__) {
5769
5770 var global = __webpack_require__(5);
5771 var core = __webpack_require__(8);
5772 var ctx = __webpack_require__(35);
5773 var hide = __webpack_require__(19);
5774 var has = __webpack_require__(20);
5775 var PROTOTYPE = 'prototype';
5776
5777 var $export = function (type, name, source) {
5778   var IS_FORCED = type & $export.F;
5779   var IS_GLOBAL = type & $export.G;
5780   var IS_STATIC = type & $export.S;
5781   var IS_PROTO = type & $export.P;
5782   var IS_BIND = type & $export.B;
5783   var IS_WRAP = type & $export.W;
5784   var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
5785   var expProto = exports[PROTOTYPE];
5786   var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
5787   var key, own, out;
5788   if (IS_GLOBAL) source = name;
5789   for (key in source) {
5790     // contains in native
5791     own = !IS_FORCED && target && target[key] !== undefined;
5792     if (own && has(exports, key)) continue;
5793     // export native or passed
5794     out = own ? target[key] : source[key];
5795     // prevent global pollution for namespaces
5796     exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
5797     // bind timers to global for call from export context
5798     : IS_BIND && own ? ctx(out, global)
5799     // wrap global constructors for prevent change them in library
5800     : IS_WRAP && target[key] == out ? (function (C) {
5801       var F = function (a, b, c) {
5802         if (this instanceof C) {
5803           switch (arguments.length) {
5804             case 0: return new C();
5805             case 1: return new C(a);
5806             case 2: return new C(a, b);
5807           } return new C(a, b, c);
5808         } return C.apply(this, arguments);
5809       };
5810       F[PROTOTYPE] = C[PROTOTYPE];
5811       return F;
5812     // make static versions for prototype methods
5813     })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
5814     // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
5815     if (IS_PROTO) {
5816       (exports.virtual || (exports.virtual = {}))[key] = out;
5817       // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
5818       if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
5819     }
5820   }
5821 };
5822 // type bitmap
5823 $export.F = 1;   // forced
5824 $export.G = 2;   // global
5825 $export.S = 4;   // static
5826 $export.P = 8;   // proto
5827 $export.B = 16;  // bind
5828 $export.W = 32;  // wrap
5829 $export.U = 64;  // safe
5830 $export.R = 128; // real proto method for `library`
5831 module.exports = $export;
5832
5833
5834 /***/ }),
5835 /* 14 */
5836 /***/ (function(module, exports) {
5837
5838 // shim for using process in browser
5839 var process = module.exports = {};
5840
5841 // cached from whatever global is present so that test runners that stub it
5842 // don't break things.  But we need to wrap it in a try catch in case it is
5843 // wrapped in strict mode code which doesn't define any globals.  It's inside a
5844 // function because try/catches deoptimize in certain engines.
5845
5846 var cachedSetTimeout;
5847 var cachedClearTimeout;
5848
5849 function defaultSetTimout() {
5850     throw new Error('setTimeout has not been defined');
5851 }
5852 function defaultClearTimeout () {
5853     throw new Error('clearTimeout has not been defined');
5854 }
5855 (function () {
5856     try {
5857         if (typeof setTimeout === 'function') {
5858             cachedSetTimeout = setTimeout;
5859         } else {
5860             cachedSetTimeout = defaultSetTimout;
5861         }
5862     } catch (e) {
5863         cachedSetTimeout = defaultSetTimout;
5864     }
5865     try {
5866         if (typeof clearTimeout === 'function') {
5867             cachedClearTimeout = clearTimeout;
5868         } else {
5869             cachedClearTimeout = defaultClearTimeout;
5870         }
5871     } catch (e) {
5872         cachedClearTimeout = defaultClearTimeout;
5873     }
5874 } ())
5875 function runTimeout(fun) {
5876     if (cachedSetTimeout === setTimeout) {
5877         //normal enviroments in sane situations
5878         return setTimeout(fun, 0);
5879     }
5880     // if setTimeout wasn't available but was latter defined
5881     if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
5882         cachedSetTimeout = setTimeout;
5883         return setTimeout(fun, 0);
5884     }
5885     try {
5886         // when when somebody has screwed with setTimeout but no I.E. maddness
5887         return cachedSetTimeout(fun, 0);
5888     } catch(e){
5889         try {
5890             // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
5891             return cachedSetTimeout.call(null, fun, 0);
5892         } catch(e){
5893             // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
5894             return cachedSetTimeout.call(this, fun, 0);
5895         }
5896     }
5897
5898
5899 }
5900 function runClearTimeout(marker) {
5901     if (cachedClearTimeout === clearTimeout) {
5902         //normal enviroments in sane situations
5903         return clearTimeout(marker);
5904     }
5905     // if clearTimeout wasn't available but was latter defined
5906     if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
5907         cachedClearTimeout = clearTimeout;
5908         return clearTimeout(marker);
5909     }
5910     try {
5911         // when when somebody has screwed with setTimeout but no I.E. maddness
5912         return cachedClearTimeout(marker);
5913     } catch (e){
5914         try {
5915             // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
5916             return cachedClearTimeout.call(null, marker);
5917         } catch (e){
5918             // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
5919             // Some versions of I.E. have different rules for clearTimeout vs setTimeout
5920             return cachedClearTimeout.call(this, marker);
5921         }
5922     }
5923
5924
5925
5926 }
5927 var queue = [];
5928 var draining = false;
5929 var currentQueue;
5930 var queueIndex = -1;
5931
5932 function cleanUpNextTick() {
5933     if (!draining || !currentQueue) {
5934         return;
5935     }
5936     draining = false;
5937     if (currentQueue.length) {
5938         queue = currentQueue.concat(queue);
5939     } else {
5940         queueIndex = -1;
5941     }
5942     if (queue.length) {
5943         drainQueue();
5944     }
5945 }
5946
5947 function drainQueue() {
5948     if (draining) {
5949         return;
5950     }
5951     var timeout = runTimeout(cleanUpNextTick);
5952     draining = true;
5953
5954     var len = queue.length;
5955     while(len) {
5956         currentQueue = queue;
5957         queue = [];
5958         while (++queueIndex < len) {
5959             if (currentQueue) {
5960                 currentQueue[queueIndex].run();
5961             }
5962         }
5963         queueIndex = -1;
5964         len = queue.length;
5965     }
5966     currentQueue = null;
5967     draining = false;
5968     runClearTimeout(timeout);
5969 }
5970
5971 process.nextTick = function (fun) {
5972     var args = new Array(arguments.length - 1);
5973     if (arguments.length > 1) {
5974         for (var i = 1; i < arguments.length; i++) {
5975             args[i - 1] = arguments[i];
5976         }
5977     }
5978     queue.push(new Item(fun, args));
5979     if (queue.length === 1 && !draining) {
5980         runTimeout(drainQueue);
5981     }
5982 };
5983
5984 // v8 likes predictible objects
5985 function Item(fun, array) {
5986     this.fun = fun;
5987     this.array = array;
5988 }
5989 Item.prototype.run = function () {
5990     this.fun.apply(null, this.array);
5991 };
5992 process.title = 'browser';
5993 process.browser = true;
5994 process.env = {};
5995 process.argv = [];
5996 process.version = ''; // empty string to avoid regexp issues
5997 process.versions = {};
5998
5999 function noop() {}
6000
6001 process.on = noop;
6002 process.addListener = noop;
6003 process.once = noop;
6004 process.off = noop;
6005 process.removeListener = noop;
6006 process.removeAllListeners = noop;
6007 process.emit = noop;
6008 process.prependListener = noop;
6009 process.prependOnceListener = noop;
6010
6011 process.listeners = function (name) { return [] }
6012
6013 process.binding = function (name) {
6014     throw new Error('process.binding is not supported');
6015 };
6016
6017 process.cwd = function () { return '/' };
6018 process.chdir = function (dir) {
6019     throw new Error('process.chdir is not supported');
6020 };
6021 process.umask = function() { return 0; };
6022
6023
6024 /***/ }),
6025 /* 15 */
6026 /***/ (function(module, exports, __webpack_require__) {
6027
6028 var isObject = __webpack_require__(12);
6029 module.exports = function (it) {
6030   if (!isObject(it)) throw TypeError(it + ' is not an object!');
6031   return it;
6032 };
6033
6034
6035 /***/ }),
6036 /* 16 */
6037 /***/ (function(module, exports, __webpack_require__) {
6038
6039 var anObject = __webpack_require__(15);
6040 var IE8_DOM_DEFINE = __webpack_require__(130);
6041 var toPrimitive = __webpack_require__(72);
6042 var dP = Object.defineProperty;
6043
6044 exports.f = __webpack_require__(17) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
6045   anObject(O);
6046   P = toPrimitive(P, true);
6047   anObject(Attributes);
6048   if (IE8_DOM_DEFINE) try {
6049     return dP(O, P, Attributes);
6050   } catch (e) { /* empty */ }
6051   if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
6052   if ('value' in Attributes) O[P] = Attributes.value;
6053   return O;
6054 };
6055
6056
6057 /***/ }),
6058 /* 17 */
6059 /***/ (function(module, exports, __webpack_require__) {
6060
6061 // Thank's IE8 for his funny defineProperty
6062 module.exports = !__webpack_require__(22)(function () {
6063   return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
6064 });
6065
6066
6067 /***/ }),
6068 /* 18 */
6069 /***/ (function(module, exports, __webpack_require__) {
6070
6071 var Buffer = __webpack_require__(2).Buffer
6072 var Transform = __webpack_require__(57).Transform
6073 var StringDecoder = __webpack_require__(61).StringDecoder
6074 var inherits = __webpack_require__(1)
6075
6076 function CipherBase (hashMode) {
6077   Transform.call(this)
6078   this.hashMode = typeof hashMode === 'string'
6079   if (this.hashMode) {
6080     this[hashMode] = this._finalOrDigest
6081   } else {
6082     this.final = this._finalOrDigest
6083   }
6084   if (this._final) {
6085     this.__final = this._final
6086     this._final = null
6087   }
6088   this._decoder = null
6089   this._encoding = null
6090 }
6091 inherits(CipherBase, Transform)
6092
6093 CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
6094   if (typeof data === 'string') {
6095     data = Buffer.from(data, inputEnc)
6096   }
6097
6098   var outData = this._update(data)
6099   if (this.hashMode) return this
6100
6101   if (outputEnc) {
6102     outData = this._toString(outData, outputEnc)
6103   }
6104
6105   return outData
6106 }
6107
6108 CipherBase.prototype.setAutoPadding = function () {}
6109 CipherBase.prototype.getAuthTag = function () {
6110   throw new Error('trying to get auth tag in unsupported state')
6111 }
6112
6113 CipherBase.prototype.setAuthTag = function () {
6114   throw new Error('trying to set auth tag in unsupported state')
6115 }
6116
6117 CipherBase.prototype.setAAD = function () {
6118   throw new Error('trying to set aad in unsupported state')
6119 }
6120
6121 CipherBase.prototype._transform = function (data, _, next) {
6122   var err
6123   try {
6124     if (this.hashMode) {
6125       this._update(data)
6126     } else {
6127       this.push(this._update(data))
6128     }
6129   } catch (e) {
6130     err = e
6131   } finally {
6132     next(err)
6133   }
6134 }
6135 CipherBase.prototype._flush = function (done) {
6136   var err
6137   try {
6138     this.push(this.__final())
6139   } catch (e) {
6140     err = e
6141   }
6142
6143   done(err)
6144 }
6145 CipherBase.prototype._finalOrDigest = function (outputEnc) {
6146   var outData = this.__final() || Buffer.alloc(0)
6147   if (outputEnc) {
6148     outData = this._toString(outData, outputEnc, true)
6149   }
6150   return outData
6151 }
6152
6153 CipherBase.prototype._toString = function (value, enc, fin) {
6154   if (!this._decoder) {
6155     this._decoder = new StringDecoder(enc)
6156     this._encoding = enc
6157   }
6158
6159   if (this._encoding !== enc) throw new Error('can\'t switch encodings')
6160
6161   var out = this._decoder.write(value)
6162   if (fin) {
6163     out += this._decoder.end()
6164   }
6165
6166   return out
6167 }
6168
6169 module.exports = CipherBase
6170
6171
6172 /***/ }),
6173 /* 19 */
6174 /***/ (function(module, exports, __webpack_require__) {
6175
6176 var dP = __webpack_require__(16);
6177 var createDesc = __webpack_require__(48);
6178 module.exports = __webpack_require__(17) ? function (object, key, value) {
6179   return dP.f(object, key, createDesc(1, value));
6180 } : function (object, key, value) {
6181   object[key] = value;
6182   return object;
6183 };
6184
6185
6186 /***/ }),
6187 /* 20 */
6188 /***/ (function(module, exports) {
6189
6190 var hasOwnProperty = {}.hasOwnProperty;
6191 module.exports = function (it, key) {
6192   return hasOwnProperty.call(it, key);
6193 };
6194
6195
6196 /***/ }),
6197 /* 21 */
6198 /***/ (function(module, exports, __webpack_require__) {
6199
6200 "use strict";
6201 // Copyright Joyent, Inc. and other Node contributors.
6202 //
6203 // Permission is hereby granted, free of charge, to any person obtaining a
6204 // copy of this software and associated documentation files (the
6205 // "Software"), to deal in the Software without restriction, including
6206 // without limitation the rights to use, copy, modify, merge, publish,
6207 // distribute, sublicense, and/or sell copies of the Software, and to permit
6208 // persons to whom the Software is furnished to do so, subject to the
6209 // following conditions:
6210 //
6211 // The above copyright notice and this permission notice shall be included
6212 // in all copies or substantial portions of the Software.
6213 //
6214 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
6215 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6216 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
6217 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
6218 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
6219 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
6220 // USE OR OTHER DEALINGS IN THE SOFTWARE.
6221
6222 // a duplex stream is just a stream that is both readable and writable.
6223 // Since JS doesn't have multiple prototypal inheritance, this class
6224 // prototypally inherits from Readable, and then parasitically from
6225 // Writable.
6226
6227
6228
6229 /*<replacement>*/
6230
6231 var pna = __webpack_require__(42);
6232 /*</replacement>*/
6233
6234 /*<replacement>*/
6235 var objectKeys = Object.keys || function (obj) {
6236   var keys = [];
6237   for (var key in obj) {
6238     keys.push(key);
6239   }return keys;
6240 };
6241 /*</replacement>*/
6242
6243 module.exports = Duplex;
6244
6245 /*<replacement>*/
6246 var util = __webpack_require__(30);
6247 util.inherits = __webpack_require__(1);
6248 /*</replacement>*/
6249
6250 var Readable = __webpack_require__(95);
6251 var Writable = __webpack_require__(60);
6252
6253 util.inherits(Duplex, Readable);
6254
6255 {
6256   // avoid scope creep, the keys array can then be collected
6257   var keys = objectKeys(Writable.prototype);
6258   for (var v = 0; v < keys.length; v++) {
6259     var method = keys[v];
6260     if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
6261   }
6262 }
6263
6264 function Duplex(options) {
6265   if (!(this instanceof Duplex)) return new Duplex(options);
6266
6267   Readable.call(this, options);
6268   Writable.call(this, options);
6269
6270   if (options && options.readable === false) this.readable = false;
6271
6272   if (options && options.writable === false) this.writable = false;
6273
6274   this.allowHalfOpen = true;
6275   if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
6276
6277   this.once('end', onend);
6278 }
6279
6280 Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
6281   // making it explicit this property is not enumerable
6282   // because otherwise some prototype manipulation in
6283   // userland will fail
6284   enumerable: false,
6285   get: function () {
6286     return this._writableState.highWaterMark;
6287   }
6288 });
6289
6290 // the no-half-open enforcer
6291 function onend() {
6292   // if we allow half-open state, or if the writable side ended,
6293   // then we're ok.
6294   if (this.allowHalfOpen || this._writableState.ended) return;
6295
6296   // no more data can be written.
6297   // But allow more writes to happen in this tick.
6298   pna.nextTick(onEndNT, this);
6299 }
6300
6301 function onEndNT(self) {
6302   self.end();
6303 }
6304
6305 Object.defineProperty(Duplex.prototype, 'destroyed', {
6306   get: function () {
6307     if (this._readableState === undefined || this._writableState === undefined) {
6308       return false;
6309     }
6310     return this._readableState.destroyed && this._writableState.destroyed;
6311   },
6312   set: function (value) {
6313     // we ignore the value if the stream
6314     // has not been initialized yet
6315     if (this._readableState === undefined || this._writableState === undefined) {
6316       return;
6317     }
6318
6319     // backward compatibility, the user is explicitly
6320     // managing destroyed
6321     this._readableState.destroyed = value;
6322     this._writableState.destroyed = value;
6323   }
6324 });
6325
6326 Duplex.prototype._destroy = function (err, cb) {
6327   this.push(null);
6328   this.end();
6329
6330   pna.nextTick(cb, err);
6331 };
6332
6333 /***/ }),
6334 /* 22 */
6335 /***/ (function(module, exports) {
6336
6337 module.exports = function (exec) {
6338   try {
6339     return !!exec();
6340   } catch (e) {
6341     return true;
6342   }
6343 };
6344
6345
6346 /***/ }),
6347 /* 23 */
6348 /***/ (function(module, exports, __webpack_require__) {
6349
6350 "use strict";
6351 /* WEBPACK VAR INJECTION */(function(global, process) {
6352
6353 function oldBrowser () {
6354   throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
6355 }
6356
6357 var Buffer = __webpack_require__(2).Buffer
6358 var crypto = global.crypto || global.msCrypto
6359
6360 if (crypto && crypto.getRandomValues) {
6361   module.exports = randomBytes
6362 } else {
6363   module.exports = oldBrowser
6364 }
6365
6366 function randomBytes (size, cb) {
6367   // phantomjs needs to throw
6368   if (size > 65536) throw new Error('requested too many random bytes')
6369   // in case browserify  isn't using the Uint8Array version
6370   var rawBytes = new global.Uint8Array(size)
6371
6372   // This will not work in older browsers.
6373   // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
6374   if (size > 0) {  // getRandomValues fails on IE if size == 0
6375     crypto.getRandomValues(rawBytes)
6376   }
6377
6378   // XXX: phantomjs doesn't like a buffer being passed here
6379   var bytes = Buffer.from(rawBytes.buffer)
6380
6381   if (typeof cb === 'function') {
6382     return process.nextTick(function () {
6383       cb(null, bytes)
6384     })
6385   }
6386
6387   return bytes
6388 }
6389
6390 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
6391
6392 /***/ }),
6393 /* 24 */
6394 /***/ (function(module, exports, __webpack_require__) {
6395
6396 var Buffer = __webpack_require__(2).Buffer
6397
6398 // prototype class for hash functions
6399 function Hash (blockSize, finalSize) {
6400   this._block = Buffer.alloc(blockSize)
6401   this._finalSize = finalSize
6402   this._blockSize = blockSize
6403   this._len = 0
6404 }
6405
6406 Hash.prototype.update = function (data, enc) {
6407   if (typeof data === 'string') {
6408     enc = enc || 'utf8'
6409     data = Buffer.from(data, enc)
6410   }
6411
6412   var block = this._block
6413   var blockSize = this._blockSize
6414   var length = data.length
6415   var accum = this._len
6416
6417   for (var offset = 0; offset < length;) {
6418     var assigned = accum % blockSize
6419     var remainder = Math.min(length - offset, blockSize - assigned)
6420
6421     for (var i = 0; i < remainder; i++) {
6422       block[assigned + i] = data[offset + i]
6423     }
6424
6425     accum += remainder
6426     offset += remainder
6427
6428     if ((accum % blockSize) === 0) {
6429       this._update(block)
6430     }
6431   }
6432
6433   this._len += length
6434   return this
6435 }
6436
6437 Hash.prototype.digest = function (enc) {
6438   var rem = this._len % this._blockSize
6439
6440   this._block[rem] = 0x80
6441
6442   // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
6443   // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
6444   this._block.fill(0, rem + 1)
6445
6446   if (rem >= this._finalSize) {
6447     this._update(this._block)
6448     this._block.fill(0)
6449   }
6450
6451   var bits = this._len * 8
6452
6453   // uint32
6454   if (bits <= 0xffffffff) {
6455     this._block.writeUInt32BE(bits, this._blockSize - 4)
6456
6457   // uint64
6458   } else {
6459     var lowBits = (bits & 0xffffffff) >>> 0
6460     var highBits = (bits - lowBits) / 0x100000000
6461
6462     this._block.writeUInt32BE(highBits, this._blockSize - 8)
6463     this._block.writeUInt32BE(lowBits, this._blockSize - 4)
6464   }
6465
6466   this._update(this._block)
6467   var hash = this._hash()
6468
6469   return enc ? hash.toString(enc) : hash
6470 }
6471
6472 Hash.prototype._update = function () {
6473   throw new Error('_update must be implemented by subclass')
6474 }
6475
6476 module.exports = Hash
6477
6478
6479 /***/ }),
6480 /* 25 */
6481 /***/ (function(module, exports, __webpack_require__) {
6482
6483 // to indexed object, toObject with fallback for non-array-like ES3 strings
6484 var IObject = __webpack_require__(74);
6485 var defined = __webpack_require__(51);
6486 module.exports = function (it) {
6487   return IObject(defined(it));
6488 };
6489
6490
6491 /***/ }),
6492 /* 26 */
6493 /***/ (function(module, exports, __webpack_require__) {
6494
6495 "use strict";
6496
6497
6498 exports.__esModule = true;
6499
6500 exports.default = function (instance, Constructor) {
6501   if (!(instance instanceof Constructor)) {
6502     throw new TypeError("Cannot call a class as a function");
6503   }
6504 };
6505
6506 /***/ }),
6507 /* 27 */
6508 /***/ (function(module, exports) {
6509
6510 var toString = {}.toString;
6511
6512 module.exports = function (it) {
6513   return toString.call(it).slice(8, -1);
6514 };
6515
6516
6517 /***/ }),
6518 /* 28 */
6519 /***/ (function(module, exports) {
6520
6521 module.exports = {};
6522
6523
6524 /***/ }),
6525 /* 29 */
6526 /***/ (function(module, exports, __webpack_require__) {
6527
6528 "use strict";
6529
6530 var inherits = __webpack_require__(1)
6531 var MD5 = __webpack_require__(56)
6532 var RIPEMD160 = __webpack_require__(62)
6533 var sha = __webpack_require__(63)
6534 var Base = __webpack_require__(18)
6535
6536 function Hash (hash) {
6537   Base.call(this, 'digest')
6538
6539   this._hash = hash
6540 }
6541
6542 inherits(Hash, Base)
6543
6544 Hash.prototype._update = function (data) {
6545   this._hash.update(data)
6546 }
6547
6548 Hash.prototype._final = function () {
6549   return this._hash.digest()
6550 }
6551
6552 module.exports = function createHash (alg) {
6553   alg = alg.toLowerCase()
6554   if (alg === 'md5') return new MD5()
6555   if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
6556
6557   return new Hash(sha(alg))
6558 }
6559
6560
6561 /***/ }),
6562 /* 30 */
6563 /***/ (function(module, exports, __webpack_require__) {
6564
6565 /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
6566 //
6567 // Permission is hereby granted, free of charge, to any person obtaining a
6568 // copy of this software and associated documentation files (the
6569 // "Software"), to deal in the Software without restriction, including
6570 // without limitation the rights to use, copy, modify, merge, publish,
6571 // distribute, sublicense, and/or sell copies of the Software, and to permit
6572 // persons to whom the Software is furnished to do so, subject to the
6573 // following conditions:
6574 //
6575 // The above copyright notice and this permission notice shall be included
6576 // in all copies or substantial portions of the Software.
6577 //
6578 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
6579 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6580 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
6581 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
6582 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
6583 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
6584 // USE OR OTHER DEALINGS IN THE SOFTWARE.
6585
6586 // NOTE: These type checking functions intentionally don't use `instanceof`
6587 // because it is fragile and can be easily faked with `Object.create()`.
6588
6589 function isArray(arg) {
6590   if (Array.isArray) {
6591     return Array.isArray(arg);
6592   }
6593   return objectToString(arg) === '[object Array]';
6594 }
6595 exports.isArray = isArray;
6596
6597 function isBoolean(arg) {
6598   return typeof arg === 'boolean';
6599 }
6600 exports.isBoolean = isBoolean;
6601
6602 function isNull(arg) {
6603   return arg === null;
6604 }
6605 exports.isNull = isNull;
6606
6607 function isNullOrUndefined(arg) {
6608   return arg == null;
6609 }
6610 exports.isNullOrUndefined = isNullOrUndefined;
6611
6612 function isNumber(arg) {
6613   return typeof arg === 'number';
6614 }
6615 exports.isNumber = isNumber;
6616
6617 function isString(arg) {
6618   return typeof arg === 'string';
6619 }
6620 exports.isString = isString;
6621
6622 function isSymbol(arg) {
6623   return typeof arg === 'symbol';
6624 }
6625 exports.isSymbol = isSymbol;
6626
6627 function isUndefined(arg) {
6628   return arg === void 0;
6629 }
6630 exports.isUndefined = isUndefined;
6631
6632 function isRegExp(re) {
6633   return objectToString(re) === '[object RegExp]';
6634 }
6635 exports.isRegExp = isRegExp;
6636
6637 function isObject(arg) {
6638   return typeof arg === 'object' && arg !== null;
6639 }
6640 exports.isObject = isObject;
6641
6642 function isDate(d) {
6643   return objectToString(d) === '[object Date]';
6644 }
6645 exports.isDate = isDate;
6646
6647 function isError(e) {
6648   return (objectToString(e) === '[object Error]' || e instanceof Error);
6649 }
6650 exports.isError = isError;
6651
6652 function isFunction(arg) {
6653   return typeof arg === 'function';
6654 }
6655 exports.isFunction = isFunction;
6656
6657 function isPrimitive(arg) {
6658   return arg === null ||
6659          typeof arg === 'boolean' ||
6660          typeof arg === 'number' ||
6661          typeof arg === 'string' ||
6662          typeof arg === 'symbol' ||  // ES6 symbol
6663          typeof arg === 'undefined';
6664 }
6665 exports.isPrimitive = isPrimitive;
6666
6667 exports.isBuffer = Buffer.isBuffer;
6668
6669 function objectToString(o) {
6670   return Object.prototype.toString.call(o);
6671 }
6672
6673 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
6674
6675 /***/ }),
6676 /* 31 */
6677 /***/ (function(module, exports, __webpack_require__) {
6678
6679 /* WEBPACK VAR INJECTION */(function(Buffer) {module.exports = function xor (a, b) {
6680   var length = Math.min(a.length, b.length)
6681   var buffer = new Buffer(length)
6682
6683   for (var i = 0; i < length; ++i) {
6684     buffer[i] = a[i] ^ b[i]
6685   }
6686
6687   return buffer
6688 }
6689
6690 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
6691
6692 /***/ }),
6693 /* 32 */
6694 /***/ (function(module, exports, __webpack_require__) {
6695
6696 "use strict";
6697
6698
6699 var utils = __webpack_require__(11);
6700 var assert = __webpack_require__(9);
6701
6702 function BlockHash() {
6703   this.pending = null;
6704   this.pendingTotal = 0;
6705   this.blockSize = this.constructor.blockSize;
6706   this.outSize = this.constructor.outSize;
6707   this.hmacStrength = this.constructor.hmacStrength;
6708   this.padLength = this.constructor.padLength / 8;
6709   this.endian = 'big';
6710
6711   this._delta8 = this.blockSize / 8;
6712   this._delta32 = this.blockSize / 32;
6713 }
6714 exports.BlockHash = BlockHash;
6715
6716 BlockHash.prototype.update = function update(msg, enc) {
6717   // Convert message to array, pad it, and join into 32bit blocks
6718   msg = utils.toArray(msg, enc);
6719   if (!this.pending)
6720     this.pending = msg;
6721   else
6722     this.pending = this.pending.concat(msg);
6723   this.pendingTotal += msg.length;
6724
6725   // Enough data, try updating
6726   if (this.pending.length >= this._delta8) {
6727     msg = this.pending;
6728
6729     // Process pending data in blocks
6730     var r = msg.length % this._delta8;
6731     this.pending = msg.slice(msg.length - r, msg.length);
6732     if (this.pending.length === 0)
6733       this.pending = null;
6734
6735     msg = utils.join32(msg, 0, msg.length - r, this.endian);
6736     for (var i = 0; i < msg.length; i += this._delta32)
6737       this._update(msg, i, i + this._delta32);
6738   }
6739
6740   return this;
6741 };
6742
6743 BlockHash.prototype.digest = function digest(enc) {
6744   this.update(this._pad());
6745   assert(this.pending === null);
6746
6747   return this._digest(enc);
6748 };
6749
6750 BlockHash.prototype._pad = function pad() {
6751   var len = this.pendingTotal;
6752   var bytes = this._delta8;
6753   var k = bytes - ((len + this.padLength) % bytes);
6754   var res = new Array(k + this.padLength);
6755   res[0] = 0x80;
6756   for (var i = 1; i < k; i++)
6757     res[i] = 0;
6758
6759   // Append length
6760   len <<= 3;
6761   if (this.endian === 'big') {
6762     for (var t = 8; t < this.padLength; t++)
6763       res[i++] = 0;
6764
6765     res[i++] = 0;
6766     res[i++] = 0;
6767     res[i++] = 0;
6768     res[i++] = 0;
6769     res[i++] = (len >>> 24) & 0xff;
6770     res[i++] = (len >>> 16) & 0xff;
6771     res[i++] = (len >>> 8) & 0xff;
6772     res[i++] = len & 0xff;
6773   } else {
6774     res[i++] = len & 0xff;
6775     res[i++] = (len >>> 8) & 0xff;
6776     res[i++] = (len >>> 16) & 0xff;
6777     res[i++] = (len >>> 24) & 0xff;
6778     res[i++] = 0;
6779     res[i++] = 0;
6780     res[i++] = 0;
6781     res[i++] = 0;
6782
6783     for (t = 8; t < this.padLength; t++)
6784       res[i++] = 0;
6785   }
6786
6787   return res;
6788 };
6789
6790
6791 /***/ }),
6792 /* 33 */
6793 /***/ (function(module, exports, __webpack_require__) {
6794
6795 var asn1 = exports;
6796
6797 asn1.bignum = __webpack_require__(4);
6798
6799 asn1.define = __webpack_require__(245).define;
6800 asn1.base = __webpack_require__(34);
6801 asn1.constants = __webpack_require__(121);
6802 asn1.decoders = __webpack_require__(251);
6803 asn1.encoders = __webpack_require__(253);
6804
6805
6806 /***/ }),
6807 /* 34 */
6808 /***/ (function(module, exports, __webpack_require__) {
6809
6810 var base = exports;
6811
6812 base.Reporter = __webpack_require__(248).Reporter;
6813 base.DecoderBuffer = __webpack_require__(120).DecoderBuffer;
6814 base.EncoderBuffer = __webpack_require__(120).EncoderBuffer;
6815 base.Node = __webpack_require__(249);
6816
6817
6818 /***/ }),
6819 /* 35 */
6820 /***/ (function(module, exports, __webpack_require__) {
6821
6822 // optional / simple context binding
6823 var aFunction = __webpack_require__(38);
6824 module.exports = function (fn, that, length) {
6825   aFunction(fn);
6826   if (that === undefined) return fn;
6827   switch (length) {
6828     case 1: return function (a) {
6829       return fn.call(that, a);
6830     };
6831     case 2: return function (a, b) {
6832       return fn.call(that, a, b);
6833     };
6834     case 3: return function (a, b, c) {
6835       return fn.call(that, a, b, c);
6836     };
6837   }
6838   return function (/* ...args */) {
6839     return fn.apply(that, arguments);
6840   };
6841 };
6842
6843
6844 /***/ }),
6845 /* 36 */
6846 /***/ (function(module, exports, __webpack_require__) {
6847
6848 "use strict";
6849
6850
6851 exports.__esModule = true;
6852
6853 var _defineProperty = __webpack_require__(136);
6854
6855 var _defineProperty2 = _interopRequireDefault(_defineProperty);
6856
6857 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6858
6859 exports.default = function () {
6860   function defineProperties(target, props) {
6861     for (var i = 0; i < props.length; i++) {
6862       var descriptor = props[i];
6863       descriptor.enumerable = descriptor.enumerable || false;
6864       descriptor.configurable = true;
6865       if ("value" in descriptor) descriptor.writable = true;
6866       (0, _defineProperty2.default)(target, descriptor.key, descriptor);
6867     }
6868   }
6869
6870   return function (Constructor, protoProps, staticProps) {
6871     if (protoProps) defineProperties(Constructor.prototype, protoProps);
6872     if (staticProps) defineProperties(Constructor, staticProps);
6873     return Constructor;
6874   };
6875 }();
6876
6877 /***/ }),
6878 /* 37 */
6879 /***/ (function(module, exports) {
6880
6881 module.exports = true;
6882
6883
6884 /***/ }),
6885 /* 38 */
6886 /***/ (function(module, exports) {
6887
6888 module.exports = function (it) {
6889   if (typeof it != 'function') throw TypeError(it + ' is not a function!');
6890   return it;
6891 };
6892
6893
6894 /***/ }),
6895 /* 39 */
6896 /***/ (function(module, exports, __webpack_require__) {
6897
6898 // 19.1.2.14 / 15.2.3.14 Object.keys(O)
6899 var $keys = __webpack_require__(131);
6900 var enumBugKeys = __webpack_require__(71);
6901
6902 module.exports = Object.keys || function keys(O) {
6903   return $keys(O, enumBugKeys);
6904 };
6905
6906
6907 /***/ }),
6908 /* 40 */
6909 /***/ (function(module, exports, __webpack_require__) {
6910
6911 var def = __webpack_require__(16).f;
6912 var has = __webpack_require__(20);
6913 var TAG = __webpack_require__(7)('toStringTag');
6914
6915 module.exports = function (it, tag, stat) {
6916   if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
6917 };
6918
6919
6920 /***/ }),
6921 /* 41 */,
6922 /* 42 */
6923 /***/ (function(module, exports, __webpack_require__) {
6924
6925 "use strict";
6926 /* WEBPACK VAR INJECTION */(function(process) {
6927
6928 if (!process.version ||
6929     process.version.indexOf('v0.') === 0 ||
6930     process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
6931   module.exports = { nextTick: nextTick };
6932 } else {
6933   module.exports = process
6934 }
6935
6936 function nextTick(fn, arg1, arg2, arg3) {
6937   if (typeof fn !== 'function') {
6938     throw new TypeError('"callback" argument must be a function');
6939   }
6940   var len = arguments.length;
6941   var args, i;
6942   switch (len) {
6943   case 0:
6944   case 1:
6945     return process.nextTick(fn);
6946   case 2:
6947     return process.nextTick(function afterTickOne() {
6948       fn.call(null, arg1);
6949     });
6950   case 3:
6951     return process.nextTick(function afterTickTwo() {
6952       fn.call(null, arg1, arg2);
6953     });
6954   case 4:
6955     return process.nextTick(function afterTickThree() {
6956       fn.call(null, arg1, arg2, arg3);
6957     });
6958   default:
6959     args = new Array(len - 1);
6960     i = 0;
6961     while (i < args.length) {
6962       args[i++] = arguments[i];
6963     }
6964     return process.nextTick(function afterTick() {
6965       fn.apply(null, args);
6966     });
6967   }
6968 }
6969
6970
6971 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(14)))
6972
6973 /***/ }),
6974 /* 43 */
6975 /***/ (function(module, exports, __webpack_require__) {
6976
6977 // based on the aes implimentation in triple sec
6978 // https://github.com/keybase/triplesec
6979 // which is in turn based on the one from crypto-js
6980 // https://code.google.com/p/crypto-js/
6981
6982 var Buffer = __webpack_require__(2).Buffer
6983
6984 function asUInt32Array (buf) {
6985   if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
6986
6987   var len = (buf.length / 4) | 0
6988   var out = new Array(len)
6989
6990   for (var i = 0; i < len; i++) {
6991     out[i] = buf.readUInt32BE(i * 4)
6992   }
6993
6994   return out
6995 }
6996
6997 function scrubVec (v) {
6998   for (var i = 0; i < v.length; v++) {
6999     v[i] = 0
7000   }
7001 }
7002
7003 function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
7004   var SUB_MIX0 = SUB_MIX[0]
7005   var SUB_MIX1 = SUB_MIX[1]
7006   var SUB_MIX2 = SUB_MIX[2]
7007   var SUB_MIX3 = SUB_MIX[3]
7008
7009   var s0 = M[0] ^ keySchedule[0]
7010   var s1 = M[1] ^ keySchedule[1]
7011   var s2 = M[2] ^ keySchedule[2]
7012   var s3 = M[3] ^ keySchedule[3]
7013   var t0, t1, t2, t3
7014   var ksRow = 4
7015
7016   for (var round = 1; round < nRounds; round++) {
7017     t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
7018     t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
7019     t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
7020     t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
7021     s0 = t0
7022     s1 = t1
7023     s2 = t2
7024     s3 = t3
7025   }
7026
7027   t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
7028   t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
7029   t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
7030   t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
7031   t0 = t0 >>> 0
7032   t1 = t1 >>> 0
7033   t2 = t2 >>> 0
7034   t3 = t3 >>> 0
7035
7036   return [t0, t1, t2, t3]
7037 }
7038
7039 // AES constants
7040 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
7041 var G = (function () {
7042   // Compute double table
7043   var d = new Array(256)
7044   for (var j = 0; j < 256; j++) {
7045     if (j < 128) {
7046       d[j] = j << 1
7047     } else {
7048       d[j] = (j << 1) ^ 0x11b
7049     }
7050   }
7051
7052   var SBOX = []
7053   var INV_SBOX = []
7054   var SUB_MIX = [[], [], [], []]
7055   var INV_SUB_MIX = [[], [], [], []]
7056
7057   // Walk GF(2^8)
7058   var x = 0
7059   var xi = 0
7060   for (var i = 0; i < 256; ++i) {
7061     // Compute sbox
7062     var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
7063     sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
7064     SBOX[x] = sx
7065     INV_SBOX[sx] = x
7066
7067     // Compute multiplication
7068     var x2 = d[x]
7069     var x4 = d[x2]
7070     var x8 = d[x4]
7071
7072     // Compute sub bytes, mix columns tables
7073     var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
7074     SUB_MIX[0][x] = (t << 24) | (t >>> 8)
7075     SUB_MIX[1][x] = (t << 16) | (t >>> 16)
7076     SUB_MIX[2][x] = (t << 8) | (t >>> 24)
7077     SUB_MIX[3][x] = t
7078
7079     // Compute inv sub bytes, inv mix columns tables
7080     t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
7081     INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
7082     INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
7083     INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
7084     INV_SUB_MIX[3][sx] = t
7085
7086     if (x === 0) {
7087       x = xi = 1
7088     } else {
7089       x = x2 ^ d[d[d[x8 ^ x2]]]
7090       xi ^= d[d[xi]]
7091     }
7092   }
7093
7094   return {
7095     SBOX: SBOX,
7096     INV_SBOX: INV_SBOX,
7097     SUB_MIX: SUB_MIX,
7098     INV_SUB_MIX: INV_SUB_MIX
7099   }
7100 })()
7101
7102 function AES (key) {
7103   this._key = asUInt32Array(key)
7104   this._reset()
7105 }
7106
7107 AES.blockSize = 4 * 4
7108 AES.keySize = 256 / 8
7109 AES.prototype.blockSize = AES.blockSize
7110 AES.prototype.keySize = AES.keySize
7111 AES.prototype._reset = function () {
7112   var keyWords = this._key
7113   var keySize = keyWords.length
7114   var nRounds = keySize + 6
7115   var ksRows = (nRounds + 1) * 4
7116
7117   var keySchedule = []
7118   for (var k = 0; k < keySize; k++) {
7119     keySchedule[k] = keyWords[k]
7120   }
7121
7122   for (k = keySize; k < ksRows; k++) {
7123     var t = keySchedule[k - 1]
7124
7125     if (k % keySize === 0) {
7126       t = (t << 8) | (t >>> 24)
7127       t =
7128         (G.SBOX[t >>> 24] << 24) |
7129         (G.SBOX[(t >>> 16) & 0xff] << 16) |
7130         (G.SBOX[(t >>> 8) & 0xff] << 8) |
7131         (G.SBOX[t & 0xff])
7132
7133       t ^= RCON[(k / keySize) | 0] << 24
7134     } else if (keySize > 6 && k % keySize === 4) {
7135       t =
7136         (G.SBOX[t >>> 24] << 24) |
7137         (G.SBOX[(t >>> 16) & 0xff] << 16) |
7138         (G.SBOX[(t >>> 8) & 0xff] << 8) |
7139         (G.SBOX[t & 0xff])
7140     }
7141
7142     keySchedule[k] = keySchedule[k - keySize] ^ t
7143   }
7144
7145   var invKeySchedule = []
7146   for (var ik = 0; ik < ksRows; ik++) {
7147     var ksR = ksRows - ik
7148     var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
7149
7150     if (ik < 4 || ksR <= 4) {
7151       invKeySchedule[ik] = tt
7152     } else {
7153       invKeySchedule[ik] =
7154         G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
7155         G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
7156         G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
7157         G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
7158     }
7159   }
7160
7161   this._nRounds = nRounds
7162   this._keySchedule = keySchedule
7163   this._invKeySchedule = invKeySchedule
7164 }
7165
7166 AES.prototype.encryptBlockRaw = function (M) {
7167   M = asUInt32Array(M)
7168   return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
7169 }
7170
7171 AES.prototype.encryptBlock = function (M) {
7172   var out = this.encryptBlockRaw(M)
7173   var buf = Buffer.allocUnsafe(16)
7174   buf.writeUInt32BE(out[0], 0)
7175   buf.writeUInt32BE(out[1], 4)
7176   buf.writeUInt32BE(out[2], 8)
7177   buf.writeUInt32BE(out[3], 12)
7178   return buf
7179 }
7180
7181 AES.prototype.decryptBlock = function (M) {
7182   M = asUInt32Array(M)
7183
7184   // swap
7185   var m1 = M[1]
7186   M[1] = M[3]
7187   M[3] = m1
7188
7189   var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
7190   var buf = Buffer.allocUnsafe(16)
7191   buf.writeUInt32BE(out[0], 0)
7192   buf.writeUInt32BE(out[3], 4)
7193   buf.writeUInt32BE(out[2], 8)
7194   buf.writeUInt32BE(out[1], 12)
7195   return buf
7196 }
7197
7198 AES.prototype.scrub = function () {
7199   scrubVec(this._keySchedule)
7200   scrubVec(this._invKeySchedule)
7201   scrubVec(this._key)
7202 }
7203
7204 module.exports.AES = AES
7205
7206
7207 /***/ }),
7208 /* 44 */
7209 /***/ (function(module, exports, __webpack_require__) {
7210
7211 var Buffer = __webpack_require__(2).Buffer
7212 var MD5 = __webpack_require__(56)
7213
7214 /* eslint-disable camelcase */
7215 function EVP_BytesToKey (password, salt, keyBits, ivLen) {
7216   if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
7217   if (salt) {
7218     if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
7219     if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
7220   }
7221
7222   var keyLen = keyBits / 8
7223   var key = Buffer.alloc(keyLen)
7224   var iv = Buffer.alloc(ivLen || 0)
7225   var tmp = Buffer.alloc(0)
7226
7227   while (keyLen > 0 || ivLen > 0) {
7228     var hash = new MD5()
7229     hash.update(tmp)
7230     hash.update(password)
7231     if (salt) hash.update(salt)
7232     tmp = hash.digest()
7233
7234     var used = 0
7235
7236     if (keyLen > 0) {
7237       var keyStart = key.length - keyLen
7238       used = Math.min(keyLen, tmp.length)
7239       tmp.copy(key, keyStart, 0, used)
7240       keyLen -= used
7241     }
7242
7243     if (used < tmp.length && ivLen > 0) {
7244       var ivStart = iv.length - ivLen
7245       var length = Math.min(ivLen, tmp.length - used)
7246       tmp.copy(iv, ivStart, used, used + length)
7247       ivLen -= length
7248     }
7249   }
7250
7251   tmp.fill(0)
7252   return { key: key, iv: iv }
7253 }
7254
7255 module.exports = EVP_BytesToKey
7256
7257
7258 /***/ }),
7259 /* 45 */
7260 /***/ (function(module, exports, __webpack_require__) {
7261
7262 "use strict";
7263
7264
7265 var curve = exports;
7266
7267 curve.base = __webpack_require__(225);
7268 curve.short = __webpack_require__(226);
7269 curve.mont = __webpack_require__(227);
7270 curve.edwards = __webpack_require__(228);
7271
7272
7273 /***/ }),
7274 /* 46 */
7275 /***/ (function(module, exports, __webpack_require__) {
7276
7277 /* WEBPACK VAR INJECTION */(function(Buffer) {var asn1 = __webpack_require__(244)
7278 var aesid = __webpack_require__(256)
7279 var fixProc = __webpack_require__(257)
7280 var ciphers = __webpack_require__(65)
7281 var compat = __webpack_require__(104)
7282 module.exports = parseKeys
7283
7284 function parseKeys (buffer) {
7285   var password
7286   if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
7287     password = buffer.passphrase
7288     buffer = buffer.key
7289   }
7290   if (typeof buffer === 'string') {
7291     buffer = new Buffer(buffer)
7292   }
7293
7294   var stripped = fixProc(buffer, password)
7295
7296   var type = stripped.tag
7297   var data = stripped.data
7298   var subtype, ndata
7299   switch (type) {
7300     case 'CERTIFICATE':
7301       ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
7302       // falls through
7303     case 'PUBLIC KEY':
7304       if (!ndata) {
7305         ndata = asn1.PublicKey.decode(data, 'der')
7306       }
7307       subtype = ndata.algorithm.algorithm.join('.')
7308       switch (subtype) {
7309         case '1.2.840.113549.1.1.1':
7310           return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
7311         case '1.2.840.10045.2.1':
7312           ndata.subjectPrivateKey = ndata.subjectPublicKey
7313           return {
7314             type: 'ec',
7315             data: ndata
7316           }
7317         case '1.2.840.10040.4.1':
7318           ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
7319           return {
7320             type: 'dsa',
7321             data: ndata.algorithm.params
7322           }
7323         default: throw new Error('unknown key id ' + subtype)
7324       }
7325       throw new Error('unknown key type ' + type)
7326     case 'ENCRYPTED PRIVATE KEY':
7327       data = asn1.EncryptedPrivateKey.decode(data, 'der')
7328       data = decrypt(data, password)
7329       // falls through
7330     case 'PRIVATE KEY':
7331       ndata = asn1.PrivateKey.decode(data, 'der')
7332       subtype = ndata.algorithm.algorithm.join('.')
7333       switch (subtype) {
7334         case '1.2.840.113549.1.1.1':
7335           return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
7336         case '1.2.840.10045.2.1':
7337           return {
7338             curve: ndata.algorithm.curve,
7339             privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
7340           }
7341         case '1.2.840.10040.4.1':
7342           ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
7343           return {
7344             type: 'dsa',
7345             params: ndata.algorithm.params
7346           }
7347         default: throw new Error('unknown key id ' + subtype)
7348       }
7349       throw new Error('unknown key type ' + type)
7350     case 'RSA PUBLIC KEY':
7351       return asn1.RSAPublicKey.decode(data, 'der')
7352     case 'RSA PRIVATE KEY':
7353       return asn1.RSAPrivateKey.decode(data, 'der')
7354     case 'DSA PRIVATE KEY':
7355       return {
7356         type: 'dsa',
7357         params: asn1.DSAPrivateKey.decode(data, 'der')
7358       }
7359     case 'EC PRIVATE KEY':
7360       data = asn1.ECPrivateKey.decode(data, 'der')
7361       return {
7362         curve: data.parameters.value,
7363         privateKey: data.privateKey
7364       }
7365     default: throw new Error('unknown key type ' + type)
7366   }
7367 }
7368 parseKeys.signature = asn1.signature
7369 function decrypt (data, password) {
7370   var salt = data.algorithm.decrypt.kde.kdeparams.salt
7371   var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
7372   var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
7373   var iv = data.algorithm.decrypt.cipher.iv
7374   var cipherText = data.subjectPrivateKey
7375   var keylen = parseInt(algo.split('-')[1], 10) / 8
7376   var key = compat.pbkdf2Sync(password, salt, iters, keylen)
7377   var cipher = ciphers.createDecipheriv(algo, key, iv)
7378   var out = []
7379   out.push(cipher.update(cipherText))
7380   out.push(cipher.final())
7381   return Buffer.concat(out)
7382 }
7383
7384 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
7385
7386 /***/ }),
7387 /* 47 */
7388 /***/ (function(module, exports) {
7389
7390 var id = 0;
7391 var px = Math.random();
7392 module.exports = function (key) {
7393   return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
7394 };
7395
7396
7397 /***/ }),
7398 /* 48 */
7399 /***/ (function(module, exports) {
7400
7401 module.exports = function (bitmap, value) {
7402   return {
7403     enumerable: !(bitmap & 1),
7404     configurable: !(bitmap & 2),
7405     writable: !(bitmap & 4),
7406     value: value
7407   };
7408 };
7409
7410
7411 /***/ }),
7412 /* 49 */
7413 /***/ (function(module, exports) {
7414
7415 exports.f = {}.propertyIsEnumerable;
7416
7417
7418 /***/ }),
7419 /* 50 */
7420 /***/ (function(module, exports, __webpack_require__) {
7421
7422 var isObject = __webpack_require__(12);
7423 var document = __webpack_require__(5).document;
7424 // typeof document.createElement is 'object' in old IE
7425 var is = isObject(document) && isObject(document.createElement);
7426 module.exports = function (it) {
7427   return is ? document.createElement(it) : {};
7428 };
7429
7430
7431 /***/ }),
7432 /* 51 */
7433 /***/ (function(module, exports) {
7434
7435 // 7.2.1 RequireObjectCoercible(argument)
7436 module.exports = function (it) {
7437   if (it == undefined) throw TypeError("Can't call method on  " + it);
7438   return it;
7439 };
7440
7441
7442 /***/ }),
7443 /* 52 */
7444 /***/ (function(module, exports) {
7445
7446 // 7.1.4 ToInteger
7447 var ceil = Math.ceil;
7448 var floor = Math.floor;
7449 module.exports = function (it) {
7450   return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
7451 };
7452
7453
7454 /***/ }),
7455 /* 53 */
7456 /***/ (function(module, exports, __webpack_require__) {
7457
7458 var shared = __webpack_require__(70)('keys');
7459 var uid = __webpack_require__(47);
7460 module.exports = function (key) {
7461   return shared[key] || (shared[key] = uid(key));
7462 };
7463
7464
7465 /***/ }),
7466 /* 54 */
7467 /***/ (function(module, exports, __webpack_require__) {
7468
7469 // 7.1.13 ToObject(argument)
7470 var defined = __webpack_require__(51);
7471 module.exports = function (it) {
7472   return Object(defined(it));
7473 };
7474
7475
7476 /***/ }),
7477 /* 55 */
7478 /***/ (function(module, exports, __webpack_require__) {
7479
7480 "use strict";
7481
7482 // 25.4.1.5 NewPromiseCapability(C)
7483 var aFunction = __webpack_require__(38);
7484
7485 function PromiseCapability(C) {
7486   var resolve, reject;
7487   this.promise = new C(function ($$resolve, $$reject) {
7488     if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
7489     resolve = $$resolve;
7490     reject = $$reject;
7491   });
7492   this.resolve = aFunction(resolve);
7493   this.reject = aFunction(reject);
7494 }
7495
7496 module.exports.f = function (C) {
7497   return new PromiseCapability(C);
7498 };
7499
7500
7501 /***/ }),
7502 /* 56 */
7503 /***/ (function(module, exports, __webpack_require__) {
7504
7505 "use strict";
7506 /* WEBPACK VAR INJECTION */(function(Buffer) {
7507 var inherits = __webpack_require__(1)
7508 var HashBase = __webpack_require__(94)
7509
7510 var ARRAY16 = new Array(16)
7511
7512 function MD5 () {
7513   HashBase.call(this, 64)
7514
7515   // state
7516   this._a = 0x67452301
7517   this._b = 0xefcdab89
7518   this._c = 0x98badcfe
7519   this._d = 0x10325476
7520 }
7521
7522 inherits(MD5, HashBase)
7523
7524 MD5.prototype._update = function () {
7525   var M = ARRAY16
7526   for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
7527
7528   var a = this._a
7529   var b = this._b
7530   var c = this._c
7531   var d = this._d
7532
7533   a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
7534   d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
7535   c = fnF(c, d, a, b, M[2], 0x242070db, 17)
7536   b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
7537   a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
7538   d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
7539   c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
7540   b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
7541   a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
7542   d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
7543   c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
7544   b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
7545   a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
7546   d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
7547   c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
7548   b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
7549
7550   a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
7551   d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
7552   c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
7553   b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
7554   a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
7555   d = fnG(d, a, b, c, M[10], 0x02441453, 9)
7556   c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
7557   b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
7558   a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
7559   d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
7560   c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
7561   b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
7562   a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
7563   d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
7564   c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
7565   b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
7566
7567   a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
7568   d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
7569   c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
7570   b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
7571   a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
7572   d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
7573   c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
7574   b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
7575   a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
7576   d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
7577   c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
7578   b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
7579   a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
7580   d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
7581   c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
7582   b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
7583
7584   a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
7585   d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
7586   c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
7587   b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
7588   a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
7589   d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
7590   c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
7591   b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
7592   a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
7593   d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
7594   c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
7595   b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
7596   a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
7597   d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
7598   c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
7599   b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
7600
7601   this._a = (this._a + a) | 0
7602   this._b = (this._b + b) | 0
7603   this._c = (this._c + c) | 0
7604   this._d = (this._d + d) | 0
7605 }
7606
7607 MD5.prototype._digest = function () {
7608   // create padding and handle blocks
7609   this._block[this._blockOffset++] = 0x80
7610   if (this._blockOffset > 56) {
7611     this._block.fill(0, this._blockOffset, 64)
7612     this._update()
7613     this._blockOffset = 0
7614   }
7615
7616   this._block.fill(0, this._blockOffset, 56)
7617   this._block.writeUInt32LE(this._length[0], 56)
7618   this._block.writeUInt32LE(this._length[1], 60)
7619   this._update()
7620
7621   // produce result
7622   var buffer = new Buffer(16)
7623   buffer.writeInt32LE(this._a, 0)
7624   buffer.writeInt32LE(this._b, 4)
7625   buffer.writeInt32LE(this._c, 8)
7626   buffer.writeInt32LE(this._d, 12)
7627   return buffer
7628 }
7629
7630 function rotl (x, n) {
7631   return (x << n) | (x >>> (32 - n))
7632 }
7633
7634 function fnF (a, b, c, d, m, k, s) {
7635   return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
7636 }
7637
7638 function fnG (a, b, c, d, m, k, s) {
7639   return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
7640 }
7641
7642 function fnH (a, b, c, d, m, k, s) {
7643   return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
7644 }
7645
7646 function fnI (a, b, c, d, m, k, s) {
7647   return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
7648 }
7649
7650 module.exports = MD5
7651
7652 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
7653
7654 /***/ }),
7655 /* 57 */
7656 /***/ (function(module, exports, __webpack_require__) {
7657
7658 // Copyright Joyent, Inc. and other Node contributors.
7659 //
7660 // Permission is hereby granted, free of charge, to any person obtaining a
7661 // copy of this software and associated documentation files (the
7662 // "Software"), to deal in the Software without restriction, including
7663 // without limitation the rights to use, copy, modify, merge, publish,
7664 // distribute, sublicense, and/or sell copies of the Software, and to permit
7665 // persons to whom the Software is furnished to do so, subject to the
7666 // following conditions:
7667 //
7668 // The above copyright notice and this permission notice shall be included
7669 // in all copies or substantial portions of the Software.
7670 //
7671 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
7672 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7673 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
7674 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
7675 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
7676 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
7677 // USE OR OTHER DEALINGS IN THE SOFTWARE.
7678
7679 module.exports = Stream;
7680
7681 var EE = __webpack_require__(58).EventEmitter;
7682 var inherits = __webpack_require__(1);
7683
7684 inherits(Stream, EE);
7685 Stream.Readable = __webpack_require__(59);
7686 Stream.Writable = __webpack_require__(188);
7687 Stream.Duplex = __webpack_require__(189);
7688 Stream.Transform = __webpack_require__(190);
7689 Stream.PassThrough = __webpack_require__(191);
7690
7691 // Backwards-compat with node 0.4.x
7692 Stream.Stream = Stream;
7693
7694
7695
7696 // old-style streams.  Note that the pipe method (the only relevant
7697 // part of this class) is overridden in the Readable class.
7698
7699 function Stream() {
7700   EE.call(this);
7701 }
7702
7703 Stream.prototype.pipe = function(dest, options) {
7704   var source = this;
7705
7706   function ondata(chunk) {
7707     if (dest.writable) {
7708       if (false === dest.write(chunk) && source.pause) {
7709         source.pause();
7710       }
7711     }
7712   }
7713
7714   source.on('data', ondata);
7715
7716   function ondrain() {
7717     if (source.readable && source.resume) {
7718       source.resume();
7719     }
7720   }
7721
7722   dest.on('drain', ondrain);
7723
7724   // If the 'end' option is not supplied, dest.end() will be called when
7725   // source gets the 'end' or 'close' events.  Only dest.end() once.
7726   if (!dest._isStdio && (!options || options.end !== false)) {
7727     source.on('end', onend);
7728     source.on('close', onclose);
7729   }
7730
7731   var didOnEnd = false;
7732   function onend() {
7733     if (didOnEnd) return;
7734     didOnEnd = true;
7735
7736     dest.end();
7737   }
7738
7739
7740   function onclose() {
7741     if (didOnEnd) return;
7742     didOnEnd = true;
7743
7744     if (typeof dest.destroy === 'function') dest.destroy();
7745   }
7746
7747   // don't leave dangling pipes when there are errors.
7748   function onerror(er) {
7749     cleanup();
7750     if (EE.listenerCount(this, 'error') === 0) {
7751       throw er; // Unhandled stream error in pipe.
7752     }
7753   }
7754
7755   source.on('error', onerror);
7756   dest.on('error', onerror);
7757
7758   // remove all the event listeners that were added.
7759   function cleanup() {
7760     source.removeListener('data', ondata);
7761     dest.removeListener('drain', ondrain);
7762
7763     source.removeListener('end', onend);
7764     source.removeListener('close', onclose);
7765
7766     source.removeListener('error', onerror);
7767     dest.removeListener('error', onerror);
7768
7769     source.removeListener('end', cleanup);
7770     source.removeListener('close', cleanup);
7771
7772     dest.removeListener('close', cleanup);
7773   }
7774
7775   source.on('end', cleanup);
7776   source.on('close', cleanup);
7777
7778   dest.on('close', cleanup);
7779
7780   dest.emit('pipe', source);
7781
7782   // Allow for unix-like usage: A.pipe(B).pipe(C)
7783   return dest;
7784 };
7785
7786
7787 /***/ }),
7788 /* 58 */
7789 /***/ (function(module, exports) {
7790
7791 // Copyright Joyent, Inc. and other Node contributors.
7792 //
7793 // Permission is hereby granted, free of charge, to any person obtaining a
7794 // copy of this software and associated documentation files (the
7795 // "Software"), to deal in the Software without restriction, including
7796 // without limitation the rights to use, copy, modify, merge, publish,
7797 // distribute, sublicense, and/or sell copies of the Software, and to permit
7798 // persons to whom the Software is furnished to do so, subject to the
7799 // following conditions:
7800 //
7801 // The above copyright notice and this permission notice shall be included
7802 // in all copies or substantial portions of the Software.
7803 //
7804 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
7805 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7806 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
7807 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
7808 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
7809 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
7810 // USE OR OTHER DEALINGS IN THE SOFTWARE.
7811
7812 function EventEmitter() {
7813   this._events = this._events || {};
7814   this._maxListeners = this._maxListeners || undefined;
7815 }
7816 module.exports = EventEmitter;
7817
7818 // Backwards-compat with node 0.10.x
7819 EventEmitter.EventEmitter = EventEmitter;
7820
7821 EventEmitter.prototype._events = undefined;
7822 EventEmitter.prototype._maxListeners = undefined;
7823
7824 // By default EventEmitters will print a warning if more than 10 listeners are
7825 // added to it. This is a useful default which helps finding memory leaks.
7826 EventEmitter.defaultMaxListeners = 10;
7827
7828 // Obviously not all Emitters should be limited to 10. This function allows
7829 // that to be increased. Set to zero for unlimited.
7830 EventEmitter.prototype.setMaxListeners = function(n) {
7831   if (!isNumber(n) || n < 0 || isNaN(n))
7832     throw TypeError('n must be a positive number');
7833   this._maxListeners = n;
7834   return this;
7835 };
7836
7837 EventEmitter.prototype.emit = function(type) {
7838   var er, handler, len, args, i, listeners;
7839
7840   if (!this._events)
7841     this._events = {};
7842
7843   // If there is no 'error' event listener then throw.
7844   if (type === 'error') {
7845     if (!this._events.error ||
7846         (isObject(this._events.error) && !this._events.error.length)) {
7847       er = arguments[1];
7848       if (er instanceof Error) {
7849         throw er; // Unhandled 'error' event
7850       } else {
7851         // At least give some kind of context to the user
7852         var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
7853         err.context = er;
7854         throw err;
7855       }
7856     }
7857   }
7858
7859   handler = this._events[type];
7860
7861   if (isUndefined(handler))
7862     return false;
7863
7864   if (isFunction(handler)) {
7865     switch (arguments.length) {
7866       // fast cases
7867       case 1:
7868         handler.call(this);
7869         break;
7870       case 2:
7871         handler.call(this, arguments[1]);
7872         break;
7873       case 3:
7874         handler.call(this, arguments[1], arguments[2]);
7875         break;
7876       // slower
7877       default:
7878         args = Array.prototype.slice.call(arguments, 1);
7879         handler.apply(this, args);
7880     }
7881   } else if (isObject(handler)) {
7882     args = Array.prototype.slice.call(arguments, 1);
7883     listeners = handler.slice();
7884     len = listeners.length;
7885     for (i = 0; i < len; i++)
7886       listeners[i].apply(this, args);
7887   }
7888
7889   return true;
7890 };
7891
7892 EventEmitter.prototype.addListener = function(type, listener) {
7893   var m;
7894
7895   if (!isFunction(listener))
7896     throw TypeError('listener must be a function');
7897
7898   if (!this._events)
7899     this._events = {};
7900
7901   // To avoid recursion in the case that type === "newListener"! Before
7902   // adding it to the listeners, first emit "newListener".
7903   if (this._events.newListener)
7904     this.emit('newListener', type,
7905               isFunction(listener.listener) ?
7906               listener.listener : listener);
7907
7908   if (!this._events[type])
7909     // Optimize the case of one listener. Don't need the extra array object.
7910     this._events[type] = listener;
7911   else if (isObject(this._events[type]))
7912     // If we've already got an array, just append.
7913     this._events[type].push(listener);
7914   else
7915     // Adding the second element, need to change to array.
7916     this._events[type] = [this._events[type], listener];
7917
7918   // Check for listener leak
7919   if (isObject(this._events[type]) && !this._events[type].warned) {
7920     if (!isUndefined(this._maxListeners)) {
7921       m = this._maxListeners;
7922     } else {
7923       m = EventEmitter.defaultMaxListeners;
7924     }
7925
7926     if (m && m > 0 && this._events[type].length > m) {
7927       this._events[type].warned = true;
7928       console.error('(node) warning: possible EventEmitter memory ' +
7929                     'leak detected. %d listeners added. ' +
7930                     'Use emitter.setMaxListeners() to increase limit.',
7931                     this._events[type].length);
7932       if (typeof console.trace === 'function') {
7933         // not supported in IE 10
7934         console.trace();
7935       }
7936     }
7937   }
7938
7939   return this;
7940 };
7941
7942 EventEmitter.prototype.on = EventEmitter.prototype.addListener;
7943
7944 EventEmitter.prototype.once = function(type, listener) {
7945   if (!isFunction(listener))
7946     throw TypeError('listener must be a function');
7947
7948   var fired = false;
7949
7950   function g() {
7951     this.removeListener(type, g);
7952
7953     if (!fired) {
7954       fired = true;
7955       listener.apply(this, arguments);
7956     }
7957   }
7958
7959   g.listener = listener;
7960   this.on(type, g);
7961
7962   return this;
7963 };
7964
7965 // emits a 'removeListener' event iff the listener was removed
7966 EventEmitter.prototype.removeListener = function(type, listener) {
7967   var list, position, length, i;
7968
7969   if (!isFunction(listener))
7970     throw TypeError('listener must be a function');
7971
7972   if (!this._events || !this._events[type])
7973     return this;
7974
7975   list = this._events[type];
7976   length = list.length;
7977   position = -1;
7978
7979   if (list === listener ||
7980       (isFunction(list.listener) && list.listener === listener)) {
7981     delete this._events[type];
7982     if (this._events.removeListener)
7983       this.emit('removeListener', type, listener);
7984
7985   } else if (isObject(list)) {
7986     for (i = length; i-- > 0;) {
7987       if (list[i] === listener ||
7988           (list[i].listener && list[i].listener === listener)) {
7989         position = i;
7990         break;
7991       }
7992     }
7993
7994     if (position < 0)
7995       return this;
7996
7997     if (list.length === 1) {
7998       list.length = 0;
7999       delete this._events[type];
8000     } else {
8001       list.splice(position, 1);
8002     }
8003
8004     if (this._events.removeListener)
8005       this.emit('removeListener', type, listener);
8006   }
8007
8008   return this;
8009 };
8010
8011 EventEmitter.prototype.removeAllListeners = function(type) {
8012   var key, listeners;
8013
8014   if (!this._events)
8015     return this;
8016
8017   // not listening for removeListener, no need to emit
8018   if (!this._events.removeListener) {
8019     if (arguments.length === 0)
8020       this._events = {};
8021     else if (this._events[type])
8022       delete this._events[type];
8023     return this;
8024   }
8025
8026   // emit removeListener for all listeners on all events
8027   if (arguments.length === 0) {
8028     for (key in this._events) {
8029       if (key === 'removeListener') continue;
8030       this.removeAllListeners(key);
8031     }
8032     this.removeAllListeners('removeListener');
8033     this._events = {};
8034     return this;
8035   }
8036
8037   listeners = this._events[type];
8038
8039   if (isFunction(listeners)) {
8040     this.removeListener(type, listeners);
8041   } else if (listeners) {
8042     // LIFO order
8043     while (listeners.length)
8044       this.removeListener(type, listeners[listeners.length - 1]);
8045   }
8046   delete this._events[type];
8047
8048   return this;
8049 };
8050
8051 EventEmitter.prototype.listeners = function(type) {
8052   var ret;
8053   if (!this._events || !this._events[type])
8054     ret = [];
8055   else if (isFunction(this._events[type]))
8056     ret = [this._events[type]];
8057   else
8058     ret = this._events[type].slice();
8059   return ret;
8060 };
8061
8062 EventEmitter.prototype.listenerCount = function(type) {
8063   if (this._events) {
8064     var evlistener = this._events[type];
8065
8066     if (isFunction(evlistener))
8067       return 1;
8068     else if (evlistener)
8069       return evlistener.length;
8070   }
8071   return 0;
8072 };
8073
8074 EventEmitter.listenerCount = function(emitter, type) {
8075   return emitter.listenerCount(type);
8076 };
8077
8078 function isFunction(arg) {
8079   return typeof arg === 'function';
8080 }
8081
8082 function isNumber(arg) {
8083   return typeof arg === 'number';
8084 }
8085
8086 function isObject(arg) {
8087   return typeof arg === 'object' && arg !== null;
8088 }
8089
8090 function isUndefined(arg) {
8091   return arg === void 0;
8092 }
8093
8094
8095 /***/ }),
8096 /* 59 */
8097 /***/ (function(module, exports, __webpack_require__) {
8098
8099 exports = module.exports = __webpack_require__(95);
8100 exports.Stream = exports;
8101 exports.Readable = exports;
8102 exports.Writable = __webpack_require__(60);
8103 exports.Duplex = __webpack_require__(21);
8104 exports.Transform = __webpack_require__(98);
8105 exports.PassThrough = __webpack_require__(187);
8106
8107
8108 /***/ }),
8109 /* 60 */
8110 /***/ (function(module, exports, __webpack_require__) {
8111
8112 "use strict";
8113 /* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
8114 //
8115 // Permission is hereby granted, free of charge, to any person obtaining a
8116 // copy of this software and associated documentation files (the
8117 // "Software"), to deal in the Software without restriction, including
8118 // without limitation the rights to use, copy, modify, merge, publish,
8119 // distribute, sublicense, and/or sell copies of the Software, and to permit
8120 // persons to whom the Software is furnished to do so, subject to the
8121 // following conditions:
8122 //
8123 // The above copyright notice and this permission notice shall be included
8124 // in all copies or substantial portions of the Software.
8125 //
8126 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8127 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8128 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
8129 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8130 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
8131 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8132 // USE OR OTHER DEALINGS IN THE SOFTWARE.
8133
8134 // A bit simpler than readable streams.
8135 // Implement an async ._write(chunk, encoding, cb), and it'll handle all
8136 // the drain event emission and buffering.
8137
8138
8139
8140 /*<replacement>*/
8141
8142 var pna = __webpack_require__(42);
8143 /*</replacement>*/
8144
8145 module.exports = Writable;
8146
8147 /* <replacement> */
8148 function WriteReq(chunk, encoding, cb) {
8149   this.chunk = chunk;
8150   this.encoding = encoding;
8151   this.callback = cb;
8152   this.next = null;
8153 }
8154
8155 // It seems a linked list but it is not
8156 // there will be only 2 of these for each stream
8157 function CorkedRequest(state) {
8158   var _this = this;
8159
8160   this.next = null;
8161   this.entry = null;
8162   this.finish = function () {
8163     onCorkedFinish(_this, state);
8164   };
8165 }
8166 /* </replacement> */
8167
8168 /*<replacement>*/
8169 var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
8170 /*</replacement>*/
8171
8172 /*<replacement>*/
8173 var Duplex;
8174 /*</replacement>*/
8175
8176 Writable.WritableState = WritableState;
8177
8178 /*<replacement>*/
8179 var util = __webpack_require__(30);
8180 util.inherits = __webpack_require__(1);
8181 /*</replacement>*/
8182
8183 /*<replacement>*/
8184 var internalUtil = {
8185   deprecate: __webpack_require__(186)
8186 };
8187 /*</replacement>*/
8188
8189 /*<replacement>*/
8190 var Stream = __webpack_require__(96);
8191 /*</replacement>*/
8192
8193 /*<replacement>*/
8194
8195 var Buffer = __webpack_require__(2).Buffer;
8196 var OurUint8Array = global.Uint8Array || function () {};
8197 function _uint8ArrayToBuffer(chunk) {
8198   return Buffer.from(chunk);
8199 }
8200 function _isUint8Array(obj) {
8201   return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
8202 }
8203
8204 /*</replacement>*/
8205
8206 var destroyImpl = __webpack_require__(97);
8207
8208 util.inherits(Writable, Stream);
8209
8210 function nop() {}
8211
8212 function WritableState(options, stream) {
8213   Duplex = Duplex || __webpack_require__(21);
8214
8215   options = options || {};
8216
8217   // Duplex streams are both readable and writable, but share
8218   // the same options object.
8219   // However, some cases require setting options to different
8220   // values for the readable and the writable sides of the duplex stream.
8221   // These options can be provided separately as readableXXX and writableXXX.
8222   var isDuplex = stream instanceof Duplex;
8223
8224   // object stream flag to indicate whether or not this stream
8225   // contains buffers or objects.
8226   this.objectMode = !!options.objectMode;
8227
8228   if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
8229
8230   // the point at which write() starts returning false
8231   // Note: 0 is a valid value, means that we always return false if
8232   // the entire buffer is not flushed immediately on write()
8233   var hwm = options.highWaterMark;
8234   var writableHwm = options.writableHighWaterMark;
8235   var defaultHwm = this.objectMode ? 16 : 16 * 1024;
8236
8237   if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
8238
8239   // cast to ints.
8240   this.highWaterMark = Math.floor(this.highWaterMark);
8241
8242   // if _final has been called
8243   this.finalCalled = false;
8244
8245   // drain event flag.
8246   this.needDrain = false;
8247   // at the start of calling end()
8248   this.ending = false;
8249   // when end() has been called, and returned
8250   this.ended = false;
8251   // when 'finish' is emitted
8252   this.finished = false;
8253
8254   // has it been destroyed
8255   this.destroyed = false;
8256
8257   // should we decode strings into buffers before passing to _write?
8258   // this is here so that some node-core streams can optimize string
8259   // handling at a lower level.
8260   var noDecode = options.decodeStrings === false;
8261   this.decodeStrings = !noDecode;
8262
8263   // Crypto is kind of old and crusty.  Historically, its default string
8264   // encoding is 'binary' so we have to make this configurable.
8265   // Everything else in the universe uses 'utf8', though.
8266   this.defaultEncoding = options.defaultEncoding || 'utf8';
8267
8268   // not an actual buffer we keep track of, but a measurement
8269   // of how much we're waiting to get pushed to some underlying
8270   // socket or file.
8271   this.length = 0;
8272
8273   // a flag to see when we're in the middle of a write.
8274   this.writing = false;
8275
8276   // when true all writes will be buffered until .uncork() call
8277   this.corked = 0;
8278
8279   // a flag to be able to tell if the onwrite cb is called immediately,
8280   // or on a later tick.  We set this to true at first, because any
8281   // actions that shouldn't happen until "later" should generally also
8282   // not happen before the first write call.
8283   this.sync = true;
8284
8285   // a flag to know if we're processing previously buffered items, which
8286   // may call the _write() callback in the same tick, so that we don't
8287   // end up in an overlapped onwrite situation.
8288   this.bufferProcessing = false;
8289
8290   // the callback that's passed to _write(chunk,cb)
8291   this.onwrite = function (er) {
8292     onwrite(stream, er);
8293   };
8294
8295   // the callback that the user supplies to write(chunk,encoding,cb)
8296   this.writecb = null;
8297
8298   // the amount that is being written when _write is called.
8299   this.writelen = 0;
8300
8301   this.bufferedRequest = null;
8302   this.lastBufferedRequest = null;
8303
8304   // number of pending user-supplied write callbacks
8305   // this must be 0 before 'finish' can be emitted
8306   this.pendingcb = 0;
8307
8308   // emit prefinish if the only thing we're waiting for is _write cbs
8309   // This is relevant for synchronous Transform streams
8310   this.prefinished = false;
8311
8312   // True if the error was already emitted and should not be thrown again
8313   this.errorEmitted = false;
8314
8315   // count buffered requests
8316   this.bufferedRequestCount = 0;
8317
8318   // allocate the first CorkedRequest, there is always
8319   // one allocated and free to use, and we maintain at most two
8320   this.corkedRequestsFree = new CorkedRequest(this);
8321 }
8322
8323 WritableState.prototype.getBuffer = function getBuffer() {
8324   var current = this.bufferedRequest;
8325   var out = [];
8326   while (current) {
8327     out.push(current);
8328     current = current.next;
8329   }
8330   return out;
8331 };
8332
8333 (function () {
8334   try {
8335     Object.defineProperty(WritableState.prototype, 'buffer', {
8336       get: internalUtil.deprecate(function () {
8337         return this.getBuffer();
8338       }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
8339     });
8340   } catch (_) {}
8341 })();
8342
8343 // Test _writableState for inheritance to account for Duplex streams,
8344 // whose prototype chain only points to Readable.
8345 var realHasInstance;
8346 if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
8347   realHasInstance = Function.prototype[Symbol.hasInstance];
8348   Object.defineProperty(Writable, Symbol.hasInstance, {
8349     value: function (object) {
8350       if (realHasInstance.call(this, object)) return true;
8351       if (this !== Writable) return false;
8352
8353       return object && object._writableState instanceof WritableState;
8354     }
8355   });
8356 } else {
8357   realHasInstance = function (object) {
8358     return object instanceof this;
8359   };
8360 }
8361
8362 function Writable(options) {
8363   Duplex = Duplex || __webpack_require__(21);
8364
8365   // Writable ctor is applied to Duplexes, too.
8366   // `realHasInstance` is necessary because using plain `instanceof`
8367   // would return false, as no `_writableState` property is attached.
8368
8369   // Trying to use the custom `instanceof` for Writable here will also break the
8370   // Node.js LazyTransform implementation, which has a non-trivial getter for
8371   // `_writableState` that would lead to infinite recursion.
8372   if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
8373     return new Writable(options);
8374   }
8375
8376   this._writableState = new WritableState(options, this);
8377
8378   // legacy.
8379   this.writable = true;
8380
8381   if (options) {
8382     if (typeof options.write === 'function') this._write = options.write;
8383
8384     if (typeof options.writev === 'function') this._writev = options.writev;
8385
8386     if (typeof options.destroy === 'function') this._destroy = options.destroy;
8387
8388     if (typeof options.final === 'function') this._final = options.final;
8389   }
8390
8391   Stream.call(this);
8392 }
8393
8394 // Otherwise people can pipe Writable streams, which is just wrong.
8395 Writable.prototype.pipe = function () {
8396   this.emit('error', new Error('Cannot pipe, not readable'));
8397 };
8398
8399 function writeAfterEnd(stream, cb) {
8400   var er = new Error('write after end');
8401   // TODO: defer error events consistently everywhere, not just the cb
8402   stream.emit('error', er);
8403   pna.nextTick(cb, er);
8404 }
8405
8406 // Checks that a user-supplied chunk is valid, especially for the particular
8407 // mode the stream is in. Currently this means that `null` is never accepted
8408 // and undefined/non-string values are only allowed in object mode.
8409 function validChunk(stream, state, chunk, cb) {
8410   var valid = true;
8411   var er = false;
8412
8413   if (chunk === null) {
8414     er = new TypeError('May not write null values to stream');
8415   } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
8416     er = new TypeError('Invalid non-string/buffer chunk');
8417   }
8418   if (er) {
8419     stream.emit('error', er);
8420     pna.nextTick(cb, er);
8421     valid = false;
8422   }
8423   return valid;
8424 }
8425
8426 Writable.prototype.write = function (chunk, encoding, cb) {
8427   var state = this._writableState;
8428   var ret = false;
8429   var isBuf = !state.objectMode && _isUint8Array(chunk);
8430
8431   if (isBuf && !Buffer.isBuffer(chunk)) {
8432     chunk = _uint8ArrayToBuffer(chunk);
8433   }
8434
8435   if (typeof encoding === 'function') {
8436     cb = encoding;
8437     encoding = null;
8438   }
8439
8440   if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
8441
8442   if (typeof cb !== 'function') cb = nop;
8443
8444   if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
8445     state.pendingcb++;
8446     ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
8447   }
8448
8449   return ret;
8450 };
8451
8452 Writable.prototype.cork = function () {
8453   var state = this._writableState;
8454
8455   state.corked++;
8456 };
8457
8458 Writable.prototype.uncork = function () {
8459   var state = this._writableState;
8460
8461   if (state.corked) {
8462     state.corked--;
8463
8464     if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
8465   }
8466 };
8467
8468 Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
8469   // node::ParseEncoding() requires lower case.
8470   if (typeof encoding === 'string') encoding = encoding.toLowerCase();
8471   if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
8472   this._writableState.defaultEncoding = encoding;
8473   return this;
8474 };
8475
8476 function decodeChunk(state, chunk, encoding) {
8477   if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
8478     chunk = Buffer.from(chunk, encoding);
8479   }
8480   return chunk;
8481 }
8482
8483 Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
8484   // making it explicit this property is not enumerable
8485   // because otherwise some prototype manipulation in
8486   // userland will fail
8487   enumerable: false,
8488   get: function () {
8489     return this._writableState.highWaterMark;
8490   }
8491 });
8492
8493 // if we're already writing something, then just put this
8494 // in the queue, and wait our turn.  Otherwise, call _write
8495 // If we return false, then we need a drain event, so set that flag.
8496 function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
8497   if (!isBuf) {
8498     var newChunk = decodeChunk(state, chunk, encoding);
8499     if (chunk !== newChunk) {
8500       isBuf = true;
8501       encoding = 'buffer';
8502       chunk = newChunk;
8503     }
8504   }
8505   var len = state.objectMode ? 1 : chunk.length;
8506
8507   state.length += len;
8508
8509   var ret = state.length < state.highWaterMark;
8510   // we must ensure that previous needDrain will not be reset to false.
8511   if (!ret) state.needDrain = true;
8512
8513   if (state.writing || state.corked) {
8514     var last = state.lastBufferedRequest;
8515     state.lastBufferedRequest = {
8516       chunk: chunk,
8517       encoding: encoding,
8518       isBuf: isBuf,
8519       callback: cb,
8520       next: null
8521     };
8522     if (last) {
8523       last.next = state.lastBufferedRequest;
8524     } else {
8525       state.bufferedRequest = state.lastBufferedRequest;
8526     }
8527     state.bufferedRequestCount += 1;
8528   } else {
8529     doWrite(stream, state, false, len, chunk, encoding, cb);
8530   }
8531
8532   return ret;
8533 }
8534
8535 function doWrite(stream, state, writev, len, chunk, encoding, cb) {
8536   state.writelen = len;
8537   state.writecb = cb;
8538   state.writing = true;
8539   state.sync = true;
8540   if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
8541   state.sync = false;
8542 }
8543
8544 function onwriteError(stream, state, sync, er, cb) {
8545   --state.pendingcb;
8546
8547   if (sync) {
8548     // defer the callback if we are being called synchronously
8549     // to avoid piling up things on the stack
8550     pna.nextTick(cb, er);
8551     // this can emit finish, and it will always happen
8552     // after error
8553     pna.nextTick(finishMaybe, stream, state);
8554     stream._writableState.errorEmitted = true;
8555     stream.emit('error', er);
8556   } else {
8557     // the caller expect this to happen before if
8558     // it is async
8559     cb(er);
8560     stream._writableState.errorEmitted = true;
8561     stream.emit('error', er);
8562     // this can emit finish, but finish must
8563     // always follow error
8564     finishMaybe(stream, state);
8565   }
8566 }
8567
8568 function onwriteStateUpdate(state) {
8569   state.writing = false;
8570   state.writecb = null;
8571   state.length -= state.writelen;
8572   state.writelen = 0;
8573 }
8574
8575 function onwrite(stream, er) {
8576   var state = stream._writableState;
8577   var sync = state.sync;
8578   var cb = state.writecb;
8579
8580   onwriteStateUpdate(state);
8581
8582   if (er) onwriteError(stream, state, sync, er, cb);else {
8583     // Check if we're actually ready to finish, but don't emit yet
8584     var finished = needFinish(state);
8585
8586     if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
8587       clearBuffer(stream, state);
8588     }
8589
8590     if (sync) {
8591       /*<replacement>*/
8592       asyncWrite(afterWrite, stream, state, finished, cb);
8593       /*</replacement>*/
8594     } else {
8595       afterWrite(stream, state, finished, cb);
8596     }
8597   }
8598 }
8599
8600 function afterWrite(stream, state, finished, cb) {
8601   if (!finished) onwriteDrain(stream, state);
8602   state.pendingcb--;
8603   cb();
8604   finishMaybe(stream, state);
8605 }
8606
8607 // Must force callback to be called on nextTick, so that we don't
8608 // emit 'drain' before the write() consumer gets the 'false' return
8609 // value, and has a chance to attach a 'drain' listener.
8610 function onwriteDrain(stream, state) {
8611   if (state.length === 0 && state.needDrain) {
8612     state.needDrain = false;
8613     stream.emit('drain');
8614   }
8615 }
8616
8617 // if there's something in the buffer waiting, then process it
8618 function clearBuffer(stream, state) {
8619   state.bufferProcessing = true;
8620   var entry = state.bufferedRequest;
8621
8622   if (stream._writev && entry && entry.next) {
8623     // Fast case, write everything using _writev()
8624     var l = state.bufferedRequestCount;
8625     var buffer = new Array(l);
8626     var holder = state.corkedRequestsFree;
8627     holder.entry = entry;
8628
8629     var count = 0;
8630     var allBuffers = true;
8631     while (entry) {
8632       buffer[count] = entry;
8633       if (!entry.isBuf) allBuffers = false;
8634       entry = entry.next;
8635       count += 1;
8636     }
8637     buffer.allBuffers = allBuffers;
8638
8639     doWrite(stream, state, true, state.length, buffer, '', holder.finish);
8640
8641     // doWrite is almost always async, defer these to save a bit of time
8642     // as the hot path ends with doWrite
8643     state.pendingcb++;
8644     state.lastBufferedRequest = null;
8645     if (holder.next) {
8646       state.corkedRequestsFree = holder.next;
8647       holder.next = null;
8648     } else {
8649       state.corkedRequestsFree = new CorkedRequest(state);
8650     }
8651     state.bufferedRequestCount = 0;
8652   } else {
8653     // Slow case, write chunks one-by-one
8654     while (entry) {
8655       var chunk = entry.chunk;
8656       var encoding = entry.encoding;
8657       var cb = entry.callback;
8658       var len = state.objectMode ? 1 : chunk.length;
8659
8660       doWrite(stream, state, false, len, chunk, encoding, cb);
8661       entry = entry.next;
8662       state.bufferedRequestCount--;
8663       // if we didn't call the onwrite immediately, then
8664       // it means that we need to wait until it does.
8665       // also, that means that the chunk and cb are currently
8666       // being processed, so move the buffer counter past them.
8667       if (state.writing) {
8668         break;
8669       }
8670     }
8671
8672     if (entry === null) state.lastBufferedRequest = null;
8673   }
8674
8675   state.bufferedRequest = entry;
8676   state.bufferProcessing = false;
8677 }
8678
8679 Writable.prototype._write = function (chunk, encoding, cb) {
8680   cb(new Error('_write() is not implemented'));
8681 };
8682
8683 Writable.prototype._writev = null;
8684
8685 Writable.prototype.end = function (chunk, encoding, cb) {
8686   var state = this._writableState;
8687
8688   if (typeof chunk === 'function') {
8689     cb = chunk;
8690     chunk = null;
8691     encoding = null;
8692   } else if (typeof encoding === 'function') {
8693     cb = encoding;
8694     encoding = null;
8695   }
8696
8697   if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
8698
8699   // .end() fully uncorks
8700   if (state.corked) {
8701     state.corked = 1;
8702     this.uncork();
8703   }
8704
8705   // ignore unnecessary end() calls.
8706   if (!state.ending && !state.finished) endWritable(this, state, cb);
8707 };
8708
8709 function needFinish(state) {
8710   return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
8711 }
8712 function callFinal(stream, state) {
8713   stream._final(function (err) {
8714     state.pendingcb--;
8715     if (err) {
8716       stream.emit('error', err);
8717     }
8718     state.prefinished = true;
8719     stream.emit('prefinish');
8720     finishMaybe(stream, state);
8721   });
8722 }
8723 function prefinish(stream, state) {
8724   if (!state.prefinished && !state.finalCalled) {
8725     if (typeof stream._final === 'function') {
8726       state.pendingcb++;
8727       state.finalCalled = true;
8728       pna.nextTick(callFinal, stream, state);
8729     } else {
8730       state.prefinished = true;
8731       stream.emit('prefinish');
8732     }
8733   }
8734 }
8735
8736 function finishMaybe(stream, state) {
8737   var need = needFinish(state);
8738   if (need) {
8739     prefinish(stream, state);
8740     if (state.pendingcb === 0) {
8741       state.finished = true;
8742       stream.emit('finish');
8743     }
8744   }
8745   return need;
8746 }
8747
8748 function endWritable(stream, state, cb) {
8749   state.ending = true;
8750   finishMaybe(stream, state);
8751   if (cb) {
8752     if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
8753   }
8754   state.ended = true;
8755   stream.writable = false;
8756 }
8757
8758 function onCorkedFinish(corkReq, state, err) {
8759   var entry = corkReq.entry;
8760   corkReq.entry = null;
8761   while (entry) {
8762     var cb = entry.callback;
8763     state.pendingcb--;
8764     cb(err);
8765     entry = entry.next;
8766   }
8767   if (state.corkedRequestsFree) {
8768     state.corkedRequestsFree.next = corkReq;
8769   } else {
8770     state.corkedRequestsFree = corkReq;
8771   }
8772 }
8773
8774 Object.defineProperty(Writable.prototype, 'destroyed', {
8775   get: function () {
8776     if (this._writableState === undefined) {
8777       return false;
8778     }
8779     return this._writableState.destroyed;
8780   },
8781   set: function (value) {
8782     // we ignore the value if the stream
8783     // has not been initialized yet
8784     if (!this._writableState) {
8785       return;
8786     }
8787
8788     // backward compatibility, the user is explicitly
8789     // managing destroyed
8790     this._writableState.destroyed = value;
8791   }
8792 });
8793
8794 Writable.prototype.destroy = destroyImpl.destroy;
8795 Writable.prototype._undestroy = destroyImpl.undestroy;
8796 Writable.prototype._destroy = function (err, cb) {
8797   this.end();
8798   cb(err);
8799 };
8800 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(14), __webpack_require__(140).setImmediate, __webpack_require__(10)))
8801
8802 /***/ }),
8803 /* 61 */
8804 /***/ (function(module, exports, __webpack_require__) {
8805
8806 "use strict";
8807 // Copyright Joyent, Inc. and other Node contributors.
8808 //
8809 // Permission is hereby granted, free of charge, to any person obtaining a
8810 // copy of this software and associated documentation files (the
8811 // "Software"), to deal in the Software without restriction, including
8812 // without limitation the rights to use, copy, modify, merge, publish,
8813 // distribute, sublicense, and/or sell copies of the Software, and to permit
8814 // persons to whom the Software is furnished to do so, subject to the
8815 // following conditions:
8816 //
8817 // The above copyright notice and this permission notice shall be included
8818 // in all copies or substantial portions of the Software.
8819 //
8820 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8821 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8822 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
8823 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8824 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
8825 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8826 // USE OR OTHER DEALINGS IN THE SOFTWARE.
8827
8828
8829
8830 /*<replacement>*/
8831
8832 var Buffer = __webpack_require__(2).Buffer;
8833 /*</replacement>*/
8834
8835 var isEncoding = Buffer.isEncoding || function (encoding) {
8836   encoding = '' + encoding;
8837   switch (encoding && encoding.toLowerCase()) {
8838     case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
8839       return true;
8840     default:
8841       return false;
8842   }
8843 };
8844
8845 function _normalizeEncoding(enc) {
8846   if (!enc) return 'utf8';
8847   var retried;
8848   while (true) {
8849     switch (enc) {
8850       case 'utf8':
8851       case 'utf-8':
8852         return 'utf8';
8853       case 'ucs2':
8854       case 'ucs-2':
8855       case 'utf16le':
8856       case 'utf-16le':
8857         return 'utf16le';
8858       case 'latin1':
8859       case 'binary':
8860         return 'latin1';
8861       case 'base64':
8862       case 'ascii':
8863       case 'hex':
8864         return enc;
8865       default:
8866         if (retried) return; // undefined
8867         enc = ('' + enc).toLowerCase();
8868         retried = true;
8869     }
8870   }
8871 };
8872
8873 // Do not cache `Buffer.isEncoding` when checking encoding names as some
8874 // modules monkey-patch it to support additional encodings
8875 function normalizeEncoding(enc) {
8876   var nenc = _normalizeEncoding(enc);
8877   if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
8878   return nenc || enc;
8879 }
8880
8881 // StringDecoder provides an interface for efficiently splitting a series of
8882 // buffers into a series of JS strings without breaking apart multi-byte
8883 // characters.
8884 exports.StringDecoder = StringDecoder;
8885 function StringDecoder(encoding) {
8886   this.encoding = normalizeEncoding(encoding);
8887   var nb;
8888   switch (this.encoding) {
8889     case 'utf16le':
8890       this.text = utf16Text;
8891       this.end = utf16End;
8892       nb = 4;
8893       break;
8894     case 'utf8':
8895       this.fillLast = utf8FillLast;
8896       nb = 4;
8897       break;
8898     case 'base64':
8899       this.text = base64Text;
8900       this.end = base64End;
8901       nb = 3;
8902       break;
8903     default:
8904       this.write = simpleWrite;
8905       this.end = simpleEnd;
8906       return;
8907   }
8908   this.lastNeed = 0;
8909   this.lastTotal = 0;
8910   this.lastChar = Buffer.allocUnsafe(nb);
8911 }
8912
8913 StringDecoder.prototype.write = function (buf) {
8914   if (buf.length === 0) return '';
8915   var r;
8916   var i;
8917   if (this.lastNeed) {
8918     r = this.fillLast(buf);
8919     if (r === undefined) return '';
8920     i = this.lastNeed;
8921     this.lastNeed = 0;
8922   } else {
8923     i = 0;
8924   }
8925   if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
8926   return r || '';
8927 };
8928
8929 StringDecoder.prototype.end = utf8End;
8930
8931 // Returns only complete characters in a Buffer
8932 StringDecoder.prototype.text = utf8Text;
8933
8934 // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
8935 StringDecoder.prototype.fillLast = function (buf) {
8936   if (this.lastNeed <= buf.length) {
8937     buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
8938     return this.lastChar.toString(this.encoding, 0, this.lastTotal);
8939   }
8940   buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
8941   this.lastNeed -= buf.length;
8942 };
8943
8944 // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
8945 // continuation byte. If an invalid byte is detected, -2 is returned.
8946 function utf8CheckByte(byte) {
8947   if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
8948   return byte >> 6 === 0x02 ? -1 : -2;
8949 }
8950
8951 // Checks at most 3 bytes at the end of a Buffer in order to detect an
8952 // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
8953 // needed to complete the UTF-8 character (if applicable) are returned.
8954 function utf8CheckIncomplete(self, buf, i) {
8955   var j = buf.length - 1;
8956   if (j < i) return 0;
8957   var nb = utf8CheckByte(buf[j]);
8958   if (nb >= 0) {
8959     if (nb > 0) self.lastNeed = nb - 1;
8960     return nb;
8961   }
8962   if (--j < i || nb === -2) return 0;
8963   nb = utf8CheckByte(buf[j]);
8964   if (nb >= 0) {
8965     if (nb > 0) self.lastNeed = nb - 2;
8966     return nb;
8967   }
8968   if (--j < i || nb === -2) return 0;
8969   nb = utf8CheckByte(buf[j]);
8970   if (nb >= 0) {
8971     if (nb > 0) {
8972       if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
8973     }
8974     return nb;
8975   }
8976   return 0;
8977 }
8978
8979 // Validates as many continuation bytes for a multi-byte UTF-8 character as
8980 // needed or are available. If we see a non-continuation byte where we expect
8981 // one, we "replace" the validated continuation bytes we've seen so far with
8982 // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
8983 // behavior. The continuation byte check is included three times in the case
8984 // where all of the continuation bytes for a character exist in the same buffer.
8985 // It is also done this way as a slight performance increase instead of using a
8986 // loop.
8987 function utf8CheckExtraBytes(self, buf, p) {
8988   if ((buf[0] & 0xC0) !== 0x80) {
8989     self.lastNeed = 0;
8990     return '\ufffd';
8991   }
8992   if (self.lastNeed > 1 && buf.length > 1) {
8993     if ((buf[1] & 0xC0) !== 0x80) {
8994       self.lastNeed = 1;
8995       return '\ufffd';
8996     }
8997     if (self.lastNeed > 2 && buf.length > 2) {
8998       if ((buf[2] & 0xC0) !== 0x80) {
8999         self.lastNeed = 2;
9000         return '\ufffd';
9001       }
9002     }
9003   }
9004 }
9005
9006 // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
9007 function utf8FillLast(buf) {
9008   var p = this.lastTotal - this.lastNeed;
9009   var r = utf8CheckExtraBytes(this, buf, p);
9010   if (r !== undefined) return r;
9011   if (this.lastNeed <= buf.length) {
9012     buf.copy(this.lastChar, p, 0, this.lastNeed);
9013     return this.lastChar.toString(this.encoding, 0, this.lastTotal);
9014   }
9015   buf.copy(this.lastChar, p, 0, buf.length);
9016   this.lastNeed -= buf.length;
9017 }
9018
9019 // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
9020 // partial character, the character's bytes are buffered until the required
9021 // number of bytes are available.
9022 function utf8Text(buf, i) {
9023   var total = utf8CheckIncomplete(this, buf, i);
9024   if (!this.lastNeed) return buf.toString('utf8', i);
9025   this.lastTotal = total;
9026   var end = buf.length - (total - this.lastNeed);
9027   buf.copy(this.lastChar, 0, end);
9028   return buf.toString('utf8', i, end);
9029 }
9030
9031 // For UTF-8, a replacement character is added when ending on a partial
9032 // character.
9033 function utf8End(buf) {
9034   var r = buf && buf.length ? this.write(buf) : '';
9035   if (this.lastNeed) return r + '\ufffd';
9036   return r;
9037 }
9038
9039 // UTF-16LE typically needs two bytes per character, but even if we have an even
9040 // number of bytes available, we need to check if we end on a leading/high
9041 // surrogate. In that case, we need to wait for the next two bytes in order to
9042 // decode the last character properly.
9043 function utf16Text(buf, i) {
9044   if ((buf.length - i) % 2 === 0) {
9045     var r = buf.toString('utf16le', i);
9046     if (r) {
9047       var c = r.charCodeAt(r.length - 1);
9048       if (c >= 0xD800 && c <= 0xDBFF) {
9049         this.lastNeed = 2;
9050         this.lastTotal = 4;
9051         this.lastChar[0] = buf[buf.length - 2];
9052         this.lastChar[1] = buf[buf.length - 1];
9053         return r.slice(0, -1);
9054       }
9055     }
9056     return r;
9057   }
9058   this.lastNeed = 1;
9059   this.lastTotal = 2;
9060   this.lastChar[0] = buf[buf.length - 1];
9061   return buf.toString('utf16le', i, buf.length - 1);
9062 }
9063
9064 // For UTF-16LE we do not explicitly append special replacement characters if we
9065 // end on a partial character, we simply let v8 handle that.
9066 function utf16End(buf) {
9067   var r = buf && buf.length ? this.write(buf) : '';
9068   if (this.lastNeed) {
9069     var end = this.lastTotal - this.lastNeed;
9070     return r + this.lastChar.toString('utf16le', 0, end);
9071   }
9072   return r;
9073 }
9074
9075 function base64Text(buf, i) {
9076   var n = (buf.length - i) % 3;
9077   if (n === 0) return buf.toString('base64', i);
9078   this.lastNeed = 3 - n;
9079   this.lastTotal = 3;
9080   if (n === 1) {
9081     this.lastChar[0] = buf[buf.length - 1];
9082   } else {
9083     this.lastChar[0] = buf[buf.length - 2];
9084     this.lastChar[1] = buf[buf.length - 1];
9085   }
9086   return buf.toString('base64', i, buf.length - n);
9087 }
9088
9089 function base64End(buf) {
9090   var r = buf && buf.length ? this.write(buf) : '';
9091   if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
9092   return r;
9093 }
9094
9095 // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
9096 function simpleWrite(buf) {
9097   return buf.toString(this.encoding);
9098 }
9099
9100 function simpleEnd(buf) {
9101   return buf && buf.length ? this.write(buf) : '';
9102 }
9103
9104 /***/ }),
9105 /* 62 */
9106 /***/ (function(module, exports, __webpack_require__) {
9107
9108 "use strict";
9109
9110 var Buffer = __webpack_require__(3).Buffer
9111 var inherits = __webpack_require__(1)
9112 var HashBase = __webpack_require__(94)
9113
9114 var ARRAY16 = new Array(16)
9115
9116 var zl = [
9117   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
9118   7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
9119   3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
9120   1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
9121   4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
9122 ]
9123
9124 var zr = [
9125   5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
9126   6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
9127   15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
9128   8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
9129   12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
9130 ]
9131
9132 var sl = [
9133   11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
9134   7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
9135   11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
9136   11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
9137   9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
9138 ]
9139
9140 var sr = [
9141   8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
9142   9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
9143   9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
9144   15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
9145   8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
9146 ]
9147
9148 var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
9149 var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
9150
9151 function RIPEMD160 () {
9152   HashBase.call(this, 64)
9153
9154   // state
9155   this._a = 0x67452301
9156   this._b = 0xefcdab89
9157   this._c = 0x98badcfe
9158   this._d = 0x10325476
9159   this._e = 0xc3d2e1f0
9160 }
9161
9162 inherits(RIPEMD160, HashBase)
9163
9164 RIPEMD160.prototype._update = function () {
9165   var words = ARRAY16
9166   for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
9167
9168   var al = this._a | 0
9169   var bl = this._b | 0
9170   var cl = this._c | 0
9171   var dl = this._d | 0
9172   var el = this._e | 0
9173
9174   var ar = this._a | 0
9175   var br = this._b | 0
9176   var cr = this._c | 0
9177   var dr = this._d | 0
9178   var er = this._e | 0
9179
9180   // computation
9181   for (var i = 0; i < 80; i += 1) {
9182     var tl
9183     var tr
9184     if (i < 16) {
9185       tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
9186       tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
9187     } else if (i < 32) {
9188       tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
9189       tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
9190     } else if (i < 48) {
9191       tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
9192       tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
9193     } else if (i < 64) {
9194       tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
9195       tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
9196     } else { // if (i<80) {
9197       tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
9198       tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
9199     }
9200
9201     al = el
9202     el = dl
9203     dl = rotl(cl, 10)
9204     cl = bl
9205     bl = tl
9206
9207     ar = er
9208     er = dr
9209     dr = rotl(cr, 10)
9210     cr = br
9211     br = tr
9212   }
9213
9214   // update state
9215   var t = (this._b + cl + dr) | 0
9216   this._b = (this._c + dl + er) | 0
9217   this._c = (this._d + el + ar) | 0
9218   this._d = (this._e + al + br) | 0
9219   this._e = (this._a + bl + cr) | 0
9220   this._a = t
9221 }
9222
9223 RIPEMD160.prototype._digest = function () {
9224   // create padding and handle blocks
9225   this._block[this._blockOffset++] = 0x80
9226   if (this._blockOffset > 56) {
9227     this._block.fill(0, this._blockOffset, 64)
9228     this._update()
9229     this._blockOffset = 0
9230   }
9231
9232   this._block.fill(0, this._blockOffset, 56)
9233   this._block.writeUInt32LE(this._length[0], 56)
9234   this._block.writeUInt32LE(this._length[1], 60)
9235   this._update()
9236
9237   // produce result
9238   var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
9239   buffer.writeInt32LE(this._a, 0)
9240   buffer.writeInt32LE(this._b, 4)
9241   buffer.writeInt32LE(this._c, 8)
9242   buffer.writeInt32LE(this._d, 12)
9243   buffer.writeInt32LE(this._e, 16)
9244   return buffer
9245 }
9246
9247 function rotl (x, n) {
9248   return (x << n) | (x >>> (32 - n))
9249 }
9250
9251 function fn1 (a, b, c, d, e, m, k, s) {
9252   return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
9253 }
9254
9255 function fn2 (a, b, c, d, e, m, k, s) {
9256   return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
9257 }
9258
9259 function fn3 (a, b, c, d, e, m, k, s) {
9260   return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
9261 }
9262
9263 function fn4 (a, b, c, d, e, m, k, s) {
9264   return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
9265 }
9266
9267 function fn5 (a, b, c, d, e, m, k, s) {
9268   return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
9269 }
9270
9271 module.exports = RIPEMD160
9272
9273
9274 /***/ }),
9275 /* 63 */
9276 /***/ (function(module, exports, __webpack_require__) {
9277
9278 var exports = module.exports = function SHA (algorithm) {
9279   algorithm = algorithm.toLowerCase()
9280
9281   var Algorithm = exports[algorithm]
9282   if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
9283
9284   return new Algorithm()
9285 }
9286
9287 exports.sha = __webpack_require__(192)
9288 exports.sha1 = __webpack_require__(193)
9289 exports.sha224 = __webpack_require__(194)
9290 exports.sha256 = __webpack_require__(99)
9291 exports.sha384 = __webpack_require__(195)
9292 exports.sha512 = __webpack_require__(100)
9293
9294
9295 /***/ }),
9296 /* 64 */
9297 /***/ (function(module, exports, __webpack_require__) {
9298
9299 "use strict";
9300
9301
9302 exports.utils = __webpack_require__(201);
9303 exports.Cipher = __webpack_require__(202);
9304 exports.DES = __webpack_require__(203);
9305 exports.CBC = __webpack_require__(204);
9306 exports.EDE = __webpack_require__(205);
9307
9308
9309 /***/ }),
9310 /* 65 */
9311 /***/ (function(module, exports, __webpack_require__) {
9312
9313 var ciphers = __webpack_require__(206)
9314 var deciphers = __webpack_require__(214)
9315 var modes = __webpack_require__(110)
9316
9317 function getCiphers () {
9318   return Object.keys(modes)
9319 }
9320
9321 exports.createCipher = exports.Cipher = ciphers.createCipher
9322 exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
9323 exports.createDecipher = exports.Decipher = deciphers.createDecipher
9324 exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
9325 exports.listCiphers = exports.getCiphers = getCiphers
9326
9327
9328 /***/ }),
9329 /* 66 */
9330 /***/ (function(module, exports, __webpack_require__) {
9331
9332 var modeModules = {
9333   ECB: __webpack_require__(207),
9334   CBC: __webpack_require__(208),
9335   CFB: __webpack_require__(209),
9336   CFB8: __webpack_require__(210),
9337   CFB1: __webpack_require__(211),
9338   OFB: __webpack_require__(212),
9339   CTR: __webpack_require__(108),
9340   GCM: __webpack_require__(108)
9341 }
9342
9343 var modes = __webpack_require__(110)
9344
9345 for (var key in modes) {
9346   modes[key].module = modeModules[modes[key].mode]
9347 }
9348
9349 module.exports = modes
9350
9351
9352 /***/ }),
9353 /* 67 */
9354 /***/ (function(module, exports, __webpack_require__) {
9355
9356 /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(4);
9357 var randomBytes = __webpack_require__(23);
9358 module.exports = crt;
9359 function blind(priv) {
9360   var r = getr(priv);
9361   var blinder = r.toRed(bn.mont(priv.modulus))
9362   .redPow(new bn(priv.publicExponent)).fromRed();
9363   return {
9364     blinder: blinder,
9365     unblinder:r.invm(priv.modulus)
9366   };
9367 }
9368 function crt(msg, priv) {
9369   var blinds = blind(priv);
9370   var len = priv.modulus.byteLength();
9371   var mod = bn.mont(priv.modulus);
9372   var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
9373   var c1 = blinded.toRed(bn.mont(priv.prime1));
9374   var c2 = blinded.toRed(bn.mont(priv.prime2));
9375   var qinv = priv.coefficient;
9376   var p = priv.prime1;
9377   var q = priv.prime2;
9378   var m1 = c1.redPow(priv.exponent1);
9379   var m2 = c2.redPow(priv.exponent2);
9380   m1 = m1.fromRed();
9381   m2 = m2.fromRed();
9382   var h = m1.isub(m2).imul(qinv).umod(p);
9383   h.imul(q);
9384   m2.iadd(h);
9385   return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
9386 }
9387 crt.getr = getr;
9388 function getr(priv) {
9389   var len = priv.modulus.byteLength();
9390   var r = new bn(randomBytes(len));
9391   while (r.cmp(priv.modulus) >=  0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
9392     r = new bn(randomBytes(len));
9393   }
9394   return r;
9395 }
9396
9397 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
9398
9399 /***/ }),
9400 /* 68 */
9401 /***/ (function(module, exports, __webpack_require__) {
9402
9403 var hash = exports;
9404
9405 hash.utils = __webpack_require__(11);
9406 hash.common = __webpack_require__(32);
9407 hash.sha = __webpack_require__(230);
9408 hash.ripemd = __webpack_require__(234);
9409 hash.hmac = __webpack_require__(235);
9410
9411 // Proxy hash functions to the main object
9412 hash.sha1 = hash.sha.sha1;
9413 hash.sha256 = hash.sha.sha256;
9414 hash.sha224 = hash.sha.sha224;
9415 hash.sha384 = hash.sha.sha384;
9416 hash.sha512 = hash.sha.sha512;
9417 hash.ripemd160 = hash.ripemd.ripemd160;
9418
9419
9420 /***/ }),
9421 /* 69 */
9422 /***/ (function(module, exports, __webpack_require__) {
9423
9424 module.exports = { "default": __webpack_require__(148), __esModule: true };
9425
9426 /***/ }),
9427 /* 70 */
9428 /***/ (function(module, exports, __webpack_require__) {
9429
9430 var core = __webpack_require__(8);
9431 var global = __webpack_require__(5);
9432 var SHARED = '__core-js_shared__';
9433 var store = global[SHARED] || (global[SHARED] = {});
9434
9435 (module.exports = function (key, value) {
9436   return store[key] || (store[key] = value !== undefined ? value : {});
9437 })('versions', []).push({
9438   version: core.version,
9439   mode: __webpack_require__(37) ? 'pure' : 'global',
9440   copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
9441 });
9442
9443
9444 /***/ }),
9445 /* 71 */
9446 /***/ (function(module, exports) {
9447
9448 // IE 8- don't enum bug keys
9449 module.exports = (
9450   'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
9451 ).split(',');
9452
9453
9454 /***/ }),
9455 /* 72 */
9456 /***/ (function(module, exports, __webpack_require__) {
9457
9458 // 7.1.1 ToPrimitive(input [, PreferredType])
9459 var isObject = __webpack_require__(12);
9460 // instead of the ES6 spec version, we didn't implement @@toPrimitive case
9461 // and the second argument - flag - preferred type is a string
9462 module.exports = function (it, S) {
9463   if (!isObject(it)) return it;
9464   var fn, val;
9465   if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
9466   if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
9467   if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
9468   throw TypeError("Can't convert object to primitive value");
9469 };
9470
9471
9472 /***/ }),
9473 /* 73 */
9474 /***/ (function(module, exports) {
9475
9476 exports.f = Object.getOwnPropertySymbols;
9477
9478
9479 /***/ }),
9480 /* 74 */
9481 /***/ (function(module, exports, __webpack_require__) {
9482
9483 // fallback for non-array-like ES3 and non-enumerable old V8 strings
9484 var cof = __webpack_require__(27);
9485 // eslint-disable-next-line no-prototype-builtins
9486 module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
9487   return cof(it) == 'String' ? it.split('') : Object(it);
9488 };
9489
9490
9491 /***/ }),
9492 /* 75 */
9493 /***/ (function(module, exports, __webpack_require__) {
9494
9495 // 7.1.15 ToLength
9496 var toInteger = __webpack_require__(52);
9497 var min = Math.min;
9498 module.exports = function (it) {
9499   return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
9500 };
9501
9502
9503 /***/ }),
9504 /* 76 */
9505 /***/ (function(module, exports, __webpack_require__) {
9506
9507 module.exports = { "default": __webpack_require__(156), __esModule: true };
9508
9509 /***/ }),
9510 /* 77 */
9511 /***/ (function(module, exports) {
9512
9513
9514
9515 /***/ }),
9516 /* 78 */
9517 /***/ (function(module, exports, __webpack_require__) {
9518
9519 module.exports = __webpack_require__(19);
9520
9521
9522 /***/ }),
9523 /* 79 */
9524 /***/ (function(module, exports, __webpack_require__) {
9525
9526 __webpack_require__(161);
9527 var global = __webpack_require__(5);
9528 var hide = __webpack_require__(19);
9529 var Iterators = __webpack_require__(28);
9530 var TO_STRING_TAG = __webpack_require__(7)('toStringTag');
9531
9532 var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
9533   'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
9534   'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
9535   'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
9536   'TextTrackList,TouchList').split(',');
9537
9538 for (var i = 0; i < DOMIterables.length; i++) {
9539   var NAME = DOMIterables[i];
9540   var Collection = global[NAME];
9541   var proto = Collection && Collection.prototype;
9542   if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
9543   Iterators[NAME] = Iterators.Array;
9544 }
9545
9546
9547 /***/ }),
9548 /* 80 */
9549 /***/ (function(module, exports, __webpack_require__) {
9550
9551 var ctx = __webpack_require__(35);
9552 var call = __webpack_require__(165);
9553 var isArrayIter = __webpack_require__(166);
9554 var anObject = __webpack_require__(15);
9555 var toLength = __webpack_require__(75);
9556 var getIterFn = __webpack_require__(167);
9557 var BREAK = {};
9558 var RETURN = {};
9559 var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
9560   var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
9561   var f = ctx(fn, that, entries ? 2 : 1);
9562   var index = 0;
9563   var length, step, iterator, result;
9564   if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
9565   // fast case for arrays with default iterator
9566   if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
9567     result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
9568     if (result === BREAK || result === RETURN) return result;
9569   } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
9570     result = call(iterator, f, step.value, entries);
9571     if (result === BREAK || result === RETURN) return result;
9572   }
9573 };
9574 exports.BREAK = BREAK;
9575 exports.RETURN = RETURN;
9576
9577
9578 /***/ }),
9579 /* 81 */,
9580 /* 82 */,
9581 /* 83 */,
9582 /* 84 */,
9583 /* 85 */
9584 /***/ (function(module, exports, __webpack_require__) {
9585
9586 "use strict";
9587
9588 var LIBRARY = __webpack_require__(37);
9589 var $export = __webpack_require__(13);
9590 var redefine = __webpack_require__(78);
9591 var hide = __webpack_require__(19);
9592 var Iterators = __webpack_require__(28);
9593 var $iterCreate = __webpack_require__(158);
9594 var setToStringTag = __webpack_require__(40);
9595 var getPrototypeOf = __webpack_require__(160);
9596 var ITERATOR = __webpack_require__(7)('iterator');
9597 var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
9598 var FF_ITERATOR = '@@iterator';
9599 var KEYS = 'keys';
9600 var VALUES = 'values';
9601
9602 var returnThis = function () { return this; };
9603
9604 module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
9605   $iterCreate(Constructor, NAME, next);
9606   var getMethod = function (kind) {
9607     if (!BUGGY && kind in proto) return proto[kind];
9608     switch (kind) {
9609       case KEYS: return function keys() { return new Constructor(this, kind); };
9610       case VALUES: return function values() { return new Constructor(this, kind); };
9611     } return function entries() { return new Constructor(this, kind); };
9612   };
9613   var TAG = NAME + ' Iterator';
9614   var DEF_VALUES = DEFAULT == VALUES;
9615   var VALUES_BUG = false;
9616   var proto = Base.prototype;
9617   var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
9618   var $default = $native || getMethod(DEFAULT);
9619   var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
9620   var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
9621   var methods, key, IteratorPrototype;
9622   // Fix native
9623   if ($anyNative) {
9624     IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
9625     if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
9626       // Set @@toStringTag to native iterators
9627       setToStringTag(IteratorPrototype, TAG, true);
9628       // fix for some old engines
9629       if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
9630     }
9631   }
9632   // fix Array#{values, @@iterator}.name in V8 / FF
9633   if (DEF_VALUES && $native && $native.name !== VALUES) {
9634     VALUES_BUG = true;
9635     $default = function values() { return $native.call(this); };
9636   }
9637   // Define iterator
9638   if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
9639     hide(proto, ITERATOR, $default);
9640   }
9641   // Plug for library
9642   Iterators[NAME] = $default;
9643   Iterators[TAG] = returnThis;
9644   if (DEFAULT) {
9645     methods = {
9646       values: DEF_VALUES ? $default : getMethod(VALUES),
9647       keys: IS_SET ? $default : getMethod(KEYS),
9648       entries: $entries
9649     };
9650     if (FORCED) for (key in methods) {
9651       if (!(key in proto)) redefine(proto, key, methods[key]);
9652     } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
9653   }
9654   return methods;
9655 };
9656
9657
9658 /***/ }),
9659 /* 86 */
9660 /***/ (function(module, exports, __webpack_require__) {
9661
9662 var document = __webpack_require__(5).document;
9663 module.exports = document && document.documentElement;
9664
9665
9666 /***/ }),
9667 /* 87 */
9668 /***/ (function(module, exports, __webpack_require__) {
9669
9670 // getting tag from 19.1.3.6 Object.prototype.toString()
9671 var cof = __webpack_require__(27);
9672 var TAG = __webpack_require__(7)('toStringTag');
9673 // ES3 wrong here
9674 var ARG = cof(function () { return arguments; }()) == 'Arguments';
9675
9676 // fallback for IE11 Script Access Denied error
9677 var tryGet = function (it, key) {
9678   try {
9679     return it[key];
9680   } catch (e) { /* empty */ }
9681 };
9682
9683 module.exports = function (it) {
9684   var O, T, B;
9685   return it === undefined ? 'Undefined' : it === null ? 'Null'
9686     // @@toStringTag case
9687     : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
9688     // builtinTag case
9689     : ARG ? cof(O)
9690     // ES3 arguments fallback
9691     : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
9692 };
9693
9694
9695 /***/ }),
9696 /* 88 */
9697 /***/ (function(module, exports, __webpack_require__) {
9698
9699 // 7.3.20 SpeciesConstructor(O, defaultConstructor)
9700 var anObject = __webpack_require__(15);
9701 var aFunction = __webpack_require__(38);
9702 var SPECIES = __webpack_require__(7)('species');
9703 module.exports = function (O, D) {
9704   var C = anObject(O).constructor;
9705   var S;
9706   return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
9707 };
9708
9709
9710 /***/ }),
9711 /* 89 */
9712 /***/ (function(module, exports, __webpack_require__) {
9713
9714 var ctx = __webpack_require__(35);
9715 var invoke = __webpack_require__(168);
9716 var html = __webpack_require__(86);
9717 var cel = __webpack_require__(50);
9718 var global = __webpack_require__(5);
9719 var process = global.process;
9720 var setTask = global.setImmediate;
9721 var clearTask = global.clearImmediate;
9722 var MessageChannel = global.MessageChannel;
9723 var Dispatch = global.Dispatch;
9724 var counter = 0;
9725 var queue = {};
9726 var ONREADYSTATECHANGE = 'onreadystatechange';
9727 var defer, channel, port;
9728 var run = function () {
9729   var id = +this;
9730   // eslint-disable-next-line no-prototype-builtins
9731   if (queue.hasOwnProperty(id)) {
9732     var fn = queue[id];
9733     delete queue[id];
9734     fn();
9735   }
9736 };
9737 var listener = function (event) {
9738   run.call(event.data);
9739 };
9740 // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
9741 if (!setTask || !clearTask) {
9742   setTask = function setImmediate(fn) {
9743     var args = [];
9744     var i = 1;
9745     while (arguments.length > i) args.push(arguments[i++]);
9746     queue[++counter] = function () {
9747       // eslint-disable-next-line no-new-func
9748       invoke(typeof fn == 'function' ? fn : Function(fn), args);
9749     };
9750     defer(counter);
9751     return counter;
9752   };
9753   clearTask = function clearImmediate(id) {
9754     delete queue[id];
9755   };
9756   // Node.js 0.8-
9757   if (__webpack_require__(27)(process) == 'process') {
9758     defer = function (id) {
9759       process.nextTick(ctx(run, id, 1));
9760     };
9761   // Sphere (JS game engine) Dispatch API
9762   } else if (Dispatch && Dispatch.now) {
9763     defer = function (id) {
9764       Dispatch.now(ctx(run, id, 1));
9765     };
9766   // Browsers with MessageChannel, includes WebWorkers
9767   } else if (MessageChannel) {
9768     channel = new MessageChannel();
9769     port = channel.port2;
9770     channel.port1.onmessage = listener;
9771     defer = ctx(port.postMessage, port, 1);
9772   // Browsers with postMessage, skip WebWorkers
9773   // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
9774   } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
9775     defer = function (id) {
9776       global.postMessage(id + '', '*');
9777     };
9778     global.addEventListener('message', listener, false);
9779   // IE8-
9780   } else if (ONREADYSTATECHANGE in cel('script')) {
9781     defer = function (id) {
9782       html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
9783         html.removeChild(this);
9784         run.call(id);
9785       };
9786     };
9787   // Rest old browsers
9788   } else {
9789     defer = function (id) {
9790       setTimeout(ctx(run, id, 1), 0);
9791     };
9792   }
9793 }
9794 module.exports = {
9795   set: setTask,
9796   clear: clearTask
9797 };
9798
9799
9800 /***/ }),
9801 /* 90 */
9802 /***/ (function(module, exports) {
9803
9804 module.exports = function (exec) {
9805   try {
9806     return { e: false, v: exec() };
9807   } catch (e) {
9808     return { e: true, v: e };
9809   }
9810 };
9811
9812
9813 /***/ }),
9814 /* 91 */
9815 /***/ (function(module, exports, __webpack_require__) {
9816
9817 var anObject = __webpack_require__(15);
9818 var isObject = __webpack_require__(12);
9819 var newPromiseCapability = __webpack_require__(55);
9820
9821 module.exports = function (C, x) {
9822   anObject(C);
9823   if (isObject(x) && x.constructor === C) return x;
9824   var promiseCapability = newPromiseCapability.f(C);
9825   var resolve = promiseCapability.resolve;
9826   resolve(x);
9827   return promiseCapability.promise;
9828 };
9829
9830
9831 /***/ }),
9832 /* 92 */
9833 /***/ (function(module, exports) {
9834
9835 var toString = {}.toString;
9836
9837 module.exports = Array.isArray || function (arr) {
9838   return toString.call(arr) == '[object Array]';
9839 };
9840
9841
9842 /***/ }),
9843 /* 93 */
9844 /***/ (function(module, exports, __webpack_require__) {
9845
9846 var META = __webpack_require__(47)('meta');
9847 var isObject = __webpack_require__(12);
9848 var has = __webpack_require__(20);
9849 var setDesc = __webpack_require__(16).f;
9850 var id = 0;
9851 var isExtensible = Object.isExtensible || function () {
9852   return true;
9853 };
9854 var FREEZE = !__webpack_require__(22)(function () {
9855   return isExtensible(Object.preventExtensions({}));
9856 });
9857 var setMeta = function (it) {
9858   setDesc(it, META, { value: {
9859     i: 'O' + ++id, // object ID
9860     w: {}          // weak collections IDs
9861   } });
9862 };
9863 var fastKey = function (it, create) {
9864   // return primitive with prefix
9865   if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
9866   if (!has(it, META)) {
9867     // can't set metadata to uncaught frozen object
9868     if (!isExtensible(it)) return 'F';
9869     // not necessary to add metadata
9870     if (!create) return 'E';
9871     // add missing metadata
9872     setMeta(it);
9873   // return object ID
9874   } return it[META].i;
9875 };
9876 var getWeak = function (it, create) {
9877   if (!has(it, META)) {
9878     // can't set metadata to uncaught frozen object
9879     if (!isExtensible(it)) return true;
9880     // not necessary to add metadata
9881     if (!create) return false;
9882     // add missing metadata
9883     setMeta(it);
9884   // return hash weak collections IDs
9885   } return it[META].w;
9886 };
9887 // add metadata on freeze-family methods calling
9888 var onFreeze = function (it) {
9889   if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
9890   return it;
9891 };
9892 var meta = module.exports = {
9893   KEY: META,
9894   NEED: false,
9895   fastKey: fastKey,
9896   getWeak: getWeak,
9897   onFreeze: onFreeze
9898 };
9899
9900
9901 /***/ }),
9902 /* 94 */
9903 /***/ (function(module, exports, __webpack_require__) {
9904
9905 "use strict";
9906
9907 var Buffer = __webpack_require__(2).Buffer
9908 var Transform = __webpack_require__(57).Transform
9909 var inherits = __webpack_require__(1)
9910
9911 function throwIfNotStringOrBuffer (val, prefix) {
9912   if (!Buffer.isBuffer(val) && typeof val !== 'string') {
9913     throw new TypeError(prefix + ' must be a string or a buffer')
9914   }
9915 }
9916
9917 function HashBase (blockSize) {
9918   Transform.call(this)
9919
9920   this._block = Buffer.allocUnsafe(blockSize)
9921   this._blockSize = blockSize
9922   this._blockOffset = 0
9923   this._length = [0, 0, 0, 0]
9924
9925   this._finalized = false
9926 }
9927
9928 inherits(HashBase, Transform)
9929
9930 HashBase.prototype._transform = function (chunk, encoding, callback) {
9931   var error = null
9932   try {
9933     this.update(chunk, encoding)
9934   } catch (err) {
9935     error = err
9936   }
9937
9938   callback(error)
9939 }
9940
9941 HashBase.prototype._flush = function (callback) {
9942   var error = null
9943   try {
9944     this.push(this.digest())
9945   } catch (err) {
9946     error = err
9947   }
9948
9949   callback(error)
9950 }
9951
9952 HashBase.prototype.update = function (data, encoding) {
9953   throwIfNotStringOrBuffer(data, 'Data')
9954   if (this._finalized) throw new Error('Digest already called')
9955   if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
9956
9957   // consume data
9958   var block = this._block
9959   var offset = 0
9960   while (this._blockOffset + data.length - offset >= this._blockSize) {
9961     for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
9962     this._update()
9963     this._blockOffset = 0
9964   }
9965   while (offset < data.length) block[this._blockOffset++] = data[offset++]
9966
9967   // update length
9968   for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
9969     this._length[j] += carry
9970     carry = (this._length[j] / 0x0100000000) | 0
9971     if (carry > 0) this._length[j] -= 0x0100000000 * carry
9972   }
9973
9974   return this
9975 }
9976
9977 HashBase.prototype._update = function () {
9978   throw new Error('_update is not implemented')
9979 }
9980
9981 HashBase.prototype.digest = function (encoding) {
9982   if (this._finalized) throw new Error('Digest already called')
9983   this._finalized = true
9984
9985   var digest = this._digest()
9986   if (encoding !== undefined) digest = digest.toString(encoding)
9987
9988   // reset state
9989   this._block.fill(0)
9990   this._blockOffset = 0
9991   for (var i = 0; i < 4; ++i) this._length[i] = 0
9992
9993   return digest
9994 }
9995
9996 HashBase.prototype._digest = function () {
9997   throw new Error('_digest is not implemented')
9998 }
9999
10000 module.exports = HashBase
10001
10002
10003 /***/ }),
10004 /* 95 */
10005 /***/ (function(module, exports, __webpack_require__) {
10006
10007 "use strict";
10008 /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
10009 //
10010 // Permission is hereby granted, free of charge, to any person obtaining a
10011 // copy of this software and associated documentation files (the
10012 // "Software"), to deal in the Software without restriction, including
10013 // without limitation the rights to use, copy, modify, merge, publish,
10014 // distribute, sublicense, and/or sell copies of the Software, and to permit
10015 // persons to whom the Software is furnished to do so, subject to the
10016 // following conditions:
10017 //
10018 // The above copyright notice and this permission notice shall be included
10019 // in all copies or substantial portions of the Software.
10020 //
10021 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10022 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10023 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10024 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10025 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10026 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10027 // USE OR OTHER DEALINGS IN THE SOFTWARE.
10028
10029
10030
10031 /*<replacement>*/
10032
10033 var pna = __webpack_require__(42);
10034 /*</replacement>*/
10035
10036 module.exports = Readable;
10037
10038 /*<replacement>*/
10039 var isArray = __webpack_require__(92);
10040 /*</replacement>*/
10041
10042 /*<replacement>*/
10043 var Duplex;
10044 /*</replacement>*/
10045
10046 Readable.ReadableState = ReadableState;
10047
10048 /*<replacement>*/
10049 var EE = __webpack_require__(58).EventEmitter;
10050
10051 var EElistenerCount = function (emitter, type) {
10052   return emitter.listeners(type).length;
10053 };
10054 /*</replacement>*/
10055
10056 /*<replacement>*/
10057 var Stream = __webpack_require__(96);
10058 /*</replacement>*/
10059
10060 /*<replacement>*/
10061
10062 var Buffer = __webpack_require__(2).Buffer;
10063 var OurUint8Array = global.Uint8Array || function () {};
10064 function _uint8ArrayToBuffer(chunk) {
10065   return Buffer.from(chunk);
10066 }
10067 function _isUint8Array(obj) {
10068   return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
10069 }
10070
10071 /*</replacement>*/
10072
10073 /*<replacement>*/
10074 var util = __webpack_require__(30);
10075 util.inherits = __webpack_require__(1);
10076 /*</replacement>*/
10077
10078 /*<replacement>*/
10079 var debugUtil = __webpack_require__(183);
10080 var debug = void 0;
10081 if (debugUtil && debugUtil.debuglog) {
10082   debug = debugUtil.debuglog('stream');
10083 } else {
10084   debug = function () {};
10085 }
10086 /*</replacement>*/
10087
10088 var BufferList = __webpack_require__(184);
10089 var destroyImpl = __webpack_require__(97);
10090 var StringDecoder;
10091
10092 util.inherits(Readable, Stream);
10093
10094 var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
10095
10096 function prependListener(emitter, event, fn) {
10097   // Sadly this is not cacheable as some libraries bundle their own
10098   // event emitter implementation with them.
10099   if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
10100
10101   // This is a hack to make sure that our error handler is attached before any
10102   // userland ones.  NEVER DO THIS. This is here only because this code needs
10103   // to continue to work with older versions of Node.js that do not include
10104   // the prependListener() method. The goal is to eventually remove this hack.
10105   if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
10106 }
10107
10108 function ReadableState(options, stream) {
10109   Duplex = Duplex || __webpack_require__(21);
10110
10111   options = options || {};
10112
10113   // Duplex streams are both readable and writable, but share
10114   // the same options object.
10115   // However, some cases require setting options to different
10116   // values for the readable and the writable sides of the duplex stream.
10117   // These options can be provided separately as readableXXX and writableXXX.
10118   var isDuplex = stream instanceof Duplex;
10119
10120   // object stream flag. Used to make read(n) ignore n and to
10121   // make all the buffer merging and length checks go away
10122   this.objectMode = !!options.objectMode;
10123
10124   if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
10125
10126   // the point at which it stops calling _read() to fill the buffer
10127   // Note: 0 is a valid value, means "don't call _read preemptively ever"
10128   var hwm = options.highWaterMark;
10129   var readableHwm = options.readableHighWaterMark;
10130   var defaultHwm = this.objectMode ? 16 : 16 * 1024;
10131
10132   if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
10133
10134   // cast to ints.
10135   this.highWaterMark = Math.floor(this.highWaterMark);
10136
10137   // A linked list is used to store data chunks instead of an array because the
10138   // linked list can remove elements from the beginning faster than
10139   // array.shift()
10140   this.buffer = new BufferList();
10141   this.length = 0;
10142   this.pipes = null;
10143   this.pipesCount = 0;
10144   this.flowing = null;
10145   this.ended = false;
10146   this.endEmitted = false;
10147   this.reading = false;
10148
10149   // a flag to be able to tell if the event 'readable'/'data' is emitted
10150   // immediately, or on a later tick.  We set this to true at first, because
10151   // any actions that shouldn't happen until "later" should generally also
10152   // not happen before the first read call.
10153   this.sync = true;
10154
10155   // whenever we return null, then we set a flag to say
10156   // that we're awaiting a 'readable' event emission.
10157   this.needReadable = false;
10158   this.emittedReadable = false;
10159   this.readableListening = false;
10160   this.resumeScheduled = false;
10161
10162   // has it been destroyed
10163   this.destroyed = false;
10164
10165   // Crypto is kind of old and crusty.  Historically, its default string
10166   // encoding is 'binary' so we have to make this configurable.
10167   // Everything else in the universe uses 'utf8', though.
10168   this.defaultEncoding = options.defaultEncoding || 'utf8';
10169
10170   // the number of writers that are awaiting a drain event in .pipe()s
10171   this.awaitDrain = 0;
10172
10173   // if true, a maybeReadMore has been scheduled
10174   this.readingMore = false;
10175
10176   this.decoder = null;
10177   this.encoding = null;
10178   if (options.encoding) {
10179     if (!StringDecoder) StringDecoder = __webpack_require__(61).StringDecoder;
10180     this.decoder = new StringDecoder(options.encoding);
10181     this.encoding = options.encoding;
10182   }
10183 }
10184
10185 function Readable(options) {
10186   Duplex = Duplex || __webpack_require__(21);
10187
10188   if (!(this instanceof Readable)) return new Readable(options);
10189
10190   this._readableState = new ReadableState(options, this);
10191
10192   // legacy
10193   this.readable = true;
10194
10195   if (options) {
10196     if (typeof options.read === 'function') this._read = options.read;
10197
10198     if (typeof options.destroy === 'function') this._destroy = options.destroy;
10199   }
10200
10201   Stream.call(this);
10202 }
10203
10204 Object.defineProperty(Readable.prototype, 'destroyed', {
10205   get: function () {
10206     if (this._readableState === undefined) {
10207       return false;
10208     }
10209     return this._readableState.destroyed;
10210   },
10211   set: function (value) {
10212     // we ignore the value if the stream
10213     // has not been initialized yet
10214     if (!this._readableState) {
10215       return;
10216     }
10217
10218     // backward compatibility, the user is explicitly
10219     // managing destroyed
10220     this._readableState.destroyed = value;
10221   }
10222 });
10223
10224 Readable.prototype.destroy = destroyImpl.destroy;
10225 Readable.prototype._undestroy = destroyImpl.undestroy;
10226 Readable.prototype._destroy = function (err, cb) {
10227   this.push(null);
10228   cb(err);
10229 };
10230
10231 // Manually shove something into the read() buffer.
10232 // This returns true if the highWaterMark has not been hit yet,
10233 // similar to how Writable.write() returns true if you should
10234 // write() some more.
10235 Readable.prototype.push = function (chunk, encoding) {
10236   var state = this._readableState;
10237   var skipChunkCheck;
10238
10239   if (!state.objectMode) {
10240     if (typeof chunk === 'string') {
10241       encoding = encoding || state.defaultEncoding;
10242       if (encoding !== state.encoding) {
10243         chunk = Buffer.from(chunk, encoding);
10244         encoding = '';
10245       }
10246       skipChunkCheck = true;
10247     }
10248   } else {
10249     skipChunkCheck = true;
10250   }
10251
10252   return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
10253 };
10254
10255 // Unshift should *always* be something directly out of read()
10256 Readable.prototype.unshift = function (chunk) {
10257   return readableAddChunk(this, chunk, null, true, false);
10258 };
10259
10260 function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
10261   var state = stream._readableState;
10262   if (chunk === null) {
10263     state.reading = false;
10264     onEofChunk(stream, state);
10265   } else {
10266     var er;
10267     if (!skipChunkCheck) er = chunkInvalid(state, chunk);
10268     if (er) {
10269       stream.emit('error', er);
10270     } else if (state.objectMode || chunk && chunk.length > 0) {
10271       if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
10272         chunk = _uint8ArrayToBuffer(chunk);
10273       }
10274
10275       if (addToFront) {
10276         if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
10277       } else if (state.ended) {
10278         stream.emit('error', new Error('stream.push() after EOF'));
10279       } else {
10280         state.reading = false;
10281         if (state.decoder && !encoding) {
10282           chunk = state.decoder.write(chunk);
10283           if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
10284         } else {
10285           addChunk(stream, state, chunk, false);
10286         }
10287       }
10288     } else if (!addToFront) {
10289       state.reading = false;
10290     }
10291   }
10292
10293   return needMoreData(state);
10294 }
10295
10296 function addChunk(stream, state, chunk, addToFront) {
10297   if (state.flowing && state.length === 0 && !state.sync) {
10298     stream.emit('data', chunk);
10299     stream.read(0);
10300   } else {
10301     // update the buffer info.
10302     state.length += state.objectMode ? 1 : chunk.length;
10303     if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
10304
10305     if (state.needReadable) emitReadable(stream);
10306   }
10307   maybeReadMore(stream, state);
10308 }
10309
10310 function chunkInvalid(state, chunk) {
10311   var er;
10312   if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
10313     er = new TypeError('Invalid non-string/buffer chunk');
10314   }
10315   return er;
10316 }
10317
10318 // if it's past the high water mark, we can push in some more.
10319 // Also, if we have no data yet, we can stand some
10320 // more bytes.  This is to work around cases where hwm=0,
10321 // such as the repl.  Also, if the push() triggered a
10322 // readable event, and the user called read(largeNumber) such that
10323 // needReadable was set, then we ought to push more, so that another
10324 // 'readable' event will be triggered.
10325 function needMoreData(state) {
10326   return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
10327 }
10328
10329 Readable.prototype.isPaused = function () {
10330   return this._readableState.flowing === false;
10331 };
10332
10333 // backwards compatibility.
10334 Readable.prototype.setEncoding = function (enc) {
10335   if (!StringDecoder) StringDecoder = __webpack_require__(61).StringDecoder;
10336   this._readableState.decoder = new StringDecoder(enc);
10337   this._readableState.encoding = enc;
10338   return this;
10339 };
10340
10341 // Don't raise the hwm > 8MB
10342 var MAX_HWM = 0x800000;
10343 function computeNewHighWaterMark(n) {
10344   if (n >= MAX_HWM) {
10345     n = MAX_HWM;
10346   } else {
10347     // Get the next highest power of 2 to prevent increasing hwm excessively in
10348     // tiny amounts
10349     n--;
10350     n |= n >>> 1;
10351     n |= n >>> 2;
10352     n |= n >>> 4;
10353     n |= n >>> 8;
10354     n |= n >>> 16;
10355     n++;
10356   }
10357   return n;
10358 }
10359
10360 // This function is designed to be inlinable, so please take care when making
10361 // changes to the function body.
10362 function howMuchToRead(n, state) {
10363   if (n <= 0 || state.length === 0 && state.ended) return 0;
10364   if (state.objectMode) return 1;
10365   if (n !== n) {
10366     // Only flow one buffer at a time
10367     if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
10368   }
10369   // If we're asking for more than the current hwm, then raise the hwm.
10370   if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
10371   if (n <= state.length) return n;
10372   // Don't have enough
10373   if (!state.ended) {
10374     state.needReadable = true;
10375     return 0;
10376   }
10377   return state.length;
10378 }
10379
10380 // you can override either this method, or the async _read(n) below.
10381 Readable.prototype.read = function (n) {
10382   debug('read', n);
10383   n = parseInt(n, 10);
10384   var state = this._readableState;
10385   var nOrig = n;
10386
10387   if (n !== 0) state.emittedReadable = false;
10388
10389   // if we're doing read(0) to trigger a readable event, but we
10390   // already have a bunch of data in the buffer, then just trigger
10391   // the 'readable' event and move on.
10392   if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
10393     debug('read: emitReadable', state.length, state.ended);
10394     if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
10395     return null;
10396   }
10397
10398   n = howMuchToRead(n, state);
10399
10400   // if we've ended, and we're now clear, then finish it up.
10401   if (n === 0 && state.ended) {
10402     if (state.length === 0) endReadable(this);
10403     return null;
10404   }
10405
10406   // All the actual chunk generation logic needs to be
10407   // *below* the call to _read.  The reason is that in certain
10408   // synthetic stream cases, such as passthrough streams, _read
10409   // may be a completely synchronous operation which may change
10410   // the state of the read buffer, providing enough data when
10411   // before there was *not* enough.
10412   //
10413   // So, the steps are:
10414   // 1. Figure out what the state of things will be after we do
10415   // a read from the buffer.
10416   //
10417   // 2. If that resulting state will trigger a _read, then call _read.
10418   // Note that this may be asynchronous, or synchronous.  Yes, it is
10419   // deeply ugly to write APIs this way, but that still doesn't mean
10420   // that the Readable class should behave improperly, as streams are
10421   // designed to be sync/async agnostic.
10422   // Take note if the _read call is sync or async (ie, if the read call
10423   // has returned yet), so that we know whether or not it's safe to emit
10424   // 'readable' etc.
10425   //
10426   // 3. Actually pull the requested chunks out of the buffer and return.
10427
10428   // if we need a readable event, then we need to do some reading.
10429   var doRead = state.needReadable;
10430   debug('need readable', doRead);
10431
10432   // if we currently have less than the highWaterMark, then also read some
10433   if (state.length === 0 || state.length - n < state.highWaterMark) {
10434     doRead = true;
10435     debug('length less than watermark', doRead);
10436   }
10437
10438   // however, if we've ended, then there's no point, and if we're already
10439   // reading, then it's unnecessary.
10440   if (state.ended || state.reading) {
10441     doRead = false;
10442     debug('reading or ended', doRead);
10443   } else if (doRead) {
10444     debug('do read');
10445     state.reading = true;
10446     state.sync = true;
10447     // if the length is currently zero, then we *need* a readable event.
10448     if (state.length === 0) state.needReadable = true;
10449     // call internal read method
10450     this._read(state.highWaterMark);
10451     state.sync = false;
10452     // If _read pushed data synchronously, then `reading` will be false,
10453     // and we need to re-evaluate how much data we can return to the user.
10454     if (!state.reading) n = howMuchToRead(nOrig, state);
10455   }
10456
10457   var ret;
10458   if (n > 0) ret = fromList(n, state);else ret = null;
10459
10460   if (ret === null) {
10461     state.needReadable = true;
10462     n = 0;
10463   } else {
10464     state.length -= n;
10465   }
10466
10467   if (state.length === 0) {
10468     // If we have nothing in the buffer, then we want to know
10469     // as soon as we *do* get something into the buffer.
10470     if (!state.ended) state.needReadable = true;
10471
10472     // If we tried to read() past the EOF, then emit end on the next tick.
10473     if (nOrig !== n && state.ended) endReadable(this);
10474   }
10475
10476   if (ret !== null) this.emit('data', ret);
10477
10478   return ret;
10479 };
10480
10481 function onEofChunk(stream, state) {
10482   if (state.ended) return;
10483   if (state.decoder) {
10484     var chunk = state.decoder.end();
10485     if (chunk && chunk.length) {
10486       state.buffer.push(chunk);
10487       state.length += state.objectMode ? 1 : chunk.length;
10488     }
10489   }
10490   state.ended = true;
10491
10492   // emit 'readable' now to make sure it gets picked up.
10493   emitReadable(stream);
10494 }
10495
10496 // Don't emit readable right away in sync mode, because this can trigger
10497 // another read() call => stack overflow.  This way, it might trigger
10498 // a nextTick recursion warning, but that's not so bad.
10499 function emitReadable(stream) {
10500   var state = stream._readableState;
10501   state.needReadable = false;
10502   if (!state.emittedReadable) {
10503     debug('emitReadable', state.flowing);
10504     state.emittedReadable = true;
10505     if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
10506   }
10507 }
10508
10509 function emitReadable_(stream) {
10510   debug('emit readable');
10511   stream.emit('readable');
10512   flow(stream);
10513 }
10514
10515 // at this point, the user has presumably seen the 'readable' event,
10516 // and called read() to consume some data.  that may have triggered
10517 // in turn another _read(n) call, in which case reading = true if
10518 // it's in progress.
10519 // However, if we're not ended, or reading, and the length < hwm,
10520 // then go ahead and try to read some more preemptively.
10521 function maybeReadMore(stream, state) {
10522   if (!state.readingMore) {
10523     state.readingMore = true;
10524     pna.nextTick(maybeReadMore_, stream, state);
10525   }
10526 }
10527
10528 function maybeReadMore_(stream, state) {
10529   var len = state.length;
10530   while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
10531     debug('maybeReadMore read 0');
10532     stream.read(0);
10533     if (len === state.length)
10534       // didn't get any data, stop spinning.
10535       break;else len = state.length;
10536   }
10537   state.readingMore = false;
10538 }
10539
10540 // abstract method.  to be overridden in specific implementation classes.
10541 // call cb(er, data) where data is <= n in length.
10542 // for virtual (non-string, non-buffer) streams, "length" is somewhat
10543 // arbitrary, and perhaps not very meaningful.
10544 Readable.prototype._read = function (n) {
10545   this.emit('error', new Error('_read() is not implemented'));
10546 };
10547
10548 Readable.prototype.pipe = function (dest, pipeOpts) {
10549   var src = this;
10550   var state = this._readableState;
10551
10552   switch (state.pipesCount) {
10553     case 0:
10554       state.pipes = dest;
10555       break;
10556     case 1:
10557       state.pipes = [state.pipes, dest];
10558       break;
10559     default:
10560       state.pipes.push(dest);
10561       break;
10562   }
10563   state.pipesCount += 1;
10564   debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
10565
10566   var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
10567
10568   var endFn = doEnd ? onend : unpipe;
10569   if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
10570
10571   dest.on('unpipe', onunpipe);
10572   function onunpipe(readable, unpipeInfo) {
10573     debug('onunpipe');
10574     if (readable === src) {
10575       if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
10576         unpipeInfo.hasUnpiped = true;
10577         cleanup();
10578       }
10579     }
10580   }
10581
10582   function onend() {
10583     debug('onend');
10584     dest.end();
10585   }
10586
10587   // when the dest drains, it reduces the awaitDrain counter
10588   // on the source.  This would be more elegant with a .once()
10589   // handler in flow(), but adding and removing repeatedly is
10590   // too slow.
10591   var ondrain = pipeOnDrain(src);
10592   dest.on('drain', ondrain);
10593
10594   var cleanedUp = false;
10595   function cleanup() {
10596     debug('cleanup');
10597     // cleanup event handlers once the pipe is broken
10598     dest.removeListener('close', onclose);
10599     dest.removeListener('finish', onfinish);
10600     dest.removeListener('drain', ondrain);
10601     dest.removeListener('error', onerror);
10602     dest.removeListener('unpipe', onunpipe);
10603     src.removeListener('end', onend);
10604     src.removeListener('end', unpipe);
10605     src.removeListener('data', ondata);
10606
10607     cleanedUp = true;
10608
10609     // if the reader is waiting for a drain event from this
10610     // specific writer, then it would cause it to never start
10611     // flowing again.
10612     // So, if this is awaiting a drain, then we just call it now.
10613     // If we don't know, then assume that we are waiting for one.
10614     if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
10615   }
10616
10617   // If the user pushes more data while we're writing to dest then we'll end up
10618   // in ondata again. However, we only want to increase awaitDrain once because
10619   // dest will only emit one 'drain' event for the multiple writes.
10620   // => Introduce a guard on increasing awaitDrain.
10621   var increasedAwaitDrain = false;
10622   src.on('data', ondata);
10623   function ondata(chunk) {
10624     debug('ondata');
10625     increasedAwaitDrain = false;
10626     var ret = dest.write(chunk);
10627     if (false === ret && !increasedAwaitDrain) {
10628       // If the user unpiped during `dest.write()`, it is possible
10629       // to get stuck in a permanently paused state if that write
10630       // also returned false.
10631       // => Check whether `dest` is still a piping destination.
10632       if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
10633         debug('false write response, pause', src._readableState.awaitDrain);
10634         src._readableState.awaitDrain++;
10635         increasedAwaitDrain = true;
10636       }
10637       src.pause();
10638     }
10639   }
10640
10641   // if the dest has an error, then stop piping into it.
10642   // however, don't suppress the throwing behavior for this.
10643   function onerror(er) {
10644     debug('onerror', er);
10645     unpipe();
10646     dest.removeListener('error', onerror);
10647     if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
10648   }
10649
10650   // Make sure our error handler is attached before userland ones.
10651   prependListener(dest, 'error', onerror);
10652
10653   // Both close and finish should trigger unpipe, but only once.
10654   function onclose() {
10655     dest.removeListener('finish', onfinish);
10656     unpipe();
10657   }
10658   dest.once('close', onclose);
10659   function onfinish() {
10660     debug('onfinish');
10661     dest.removeListener('close', onclose);
10662     unpipe();
10663   }
10664   dest.once('finish', onfinish);
10665
10666   function unpipe() {
10667     debug('unpipe');
10668     src.unpipe(dest);
10669   }
10670
10671   // tell the dest that it's being piped to
10672   dest.emit('pipe', src);
10673
10674   // start the flow if it hasn't been started already.
10675   if (!state.flowing) {
10676     debug('pipe resume');
10677     src.resume();
10678   }
10679
10680   return dest;
10681 };
10682
10683 function pipeOnDrain(src) {
10684   return function () {
10685     var state = src._readableState;
10686     debug('pipeOnDrain', state.awaitDrain);
10687     if (state.awaitDrain) state.awaitDrain--;
10688     if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
10689       state.flowing = true;
10690       flow(src);
10691     }
10692   };
10693 }
10694
10695 Readable.prototype.unpipe = function (dest) {
10696   var state = this._readableState;
10697   var unpipeInfo = { hasUnpiped: false };
10698
10699   // if we're not piping anywhere, then do nothing.
10700   if (state.pipesCount === 0) return this;
10701
10702   // just one destination.  most common case.
10703   if (state.pipesCount === 1) {
10704     // passed in one, but it's not the right one.
10705     if (dest && dest !== state.pipes) return this;
10706
10707     if (!dest) dest = state.pipes;
10708
10709     // got a match.
10710     state.pipes = null;
10711     state.pipesCount = 0;
10712     state.flowing = false;
10713     if (dest) dest.emit('unpipe', this, unpipeInfo);
10714     return this;
10715   }
10716
10717   // slow case. multiple pipe destinations.
10718
10719   if (!dest) {
10720     // remove all.
10721     var dests = state.pipes;
10722     var len = state.pipesCount;
10723     state.pipes = null;
10724     state.pipesCount = 0;
10725     state.flowing = false;
10726
10727     for (var i = 0; i < len; i++) {
10728       dests[i].emit('unpipe', this, unpipeInfo);
10729     }return this;
10730   }
10731
10732   // try to find the right one.
10733   var index = indexOf(state.pipes, dest);
10734   if (index === -1) return this;
10735
10736   state.pipes.splice(index, 1);
10737   state.pipesCount -= 1;
10738   if (state.pipesCount === 1) state.pipes = state.pipes[0];
10739
10740   dest.emit('unpipe', this, unpipeInfo);
10741
10742   return this;
10743 };
10744
10745 // set up data events if they are asked for
10746 // Ensure readable listeners eventually get something
10747 Readable.prototype.on = function (ev, fn) {
10748   var res = Stream.prototype.on.call(this, ev, fn);
10749
10750   if (ev === 'data') {
10751     // Start flowing on next tick if stream isn't explicitly paused
10752     if (this._readableState.flowing !== false) this.resume();
10753   } else if (ev === 'readable') {
10754     var state = this._readableState;
10755     if (!state.endEmitted && !state.readableListening) {
10756       state.readableListening = state.needReadable = true;
10757       state.emittedReadable = false;
10758       if (!state.reading) {
10759         pna.nextTick(nReadingNextTick, this);
10760       } else if (state.length) {
10761         emitReadable(this);
10762       }
10763     }
10764   }
10765
10766   return res;
10767 };
10768 Readable.prototype.addListener = Readable.prototype.on;
10769
10770 function nReadingNextTick(self) {
10771   debug('readable nexttick read 0');
10772   self.read(0);
10773 }
10774
10775 // pause() and resume() are remnants of the legacy readable stream API
10776 // If the user uses them, then switch into old mode.
10777 Readable.prototype.resume = function () {
10778   var state = this._readableState;
10779   if (!state.flowing) {
10780     debug('resume');
10781     state.flowing = true;
10782     resume(this, state);
10783   }
10784   return this;
10785 };
10786
10787 function resume(stream, state) {
10788   if (!state.resumeScheduled) {
10789     state.resumeScheduled = true;
10790     pna.nextTick(resume_, stream, state);
10791   }
10792 }
10793
10794 function resume_(stream, state) {
10795   if (!state.reading) {
10796     debug('resume read 0');
10797     stream.read(0);
10798   }
10799
10800   state.resumeScheduled = false;
10801   state.awaitDrain = 0;
10802   stream.emit('resume');
10803   flow(stream);
10804   if (state.flowing && !state.reading) stream.read(0);
10805 }
10806
10807 Readable.prototype.pause = function () {
10808   debug('call pause flowing=%j', this._readableState.flowing);
10809   if (false !== this._readableState.flowing) {
10810     debug('pause');
10811     this._readableState.flowing = false;
10812     this.emit('pause');
10813   }
10814   return this;
10815 };
10816
10817 function flow(stream) {
10818   var state = stream._readableState;
10819   debug('flow', state.flowing);
10820   while (state.flowing && stream.read() !== null) {}
10821 }
10822
10823 // wrap an old-style stream as the async data source.
10824 // This is *not* part of the readable stream interface.
10825 // It is an ugly unfortunate mess of history.
10826 Readable.prototype.wrap = function (stream) {
10827   var _this = this;
10828
10829   var state = this._readableState;
10830   var paused = false;
10831
10832   stream.on('end', function () {
10833     debug('wrapped end');
10834     if (state.decoder && !state.ended) {
10835       var chunk = state.decoder.end();
10836       if (chunk && chunk.length) _this.push(chunk);
10837     }
10838
10839     _this.push(null);
10840   });
10841
10842   stream.on('data', function (chunk) {
10843     debug('wrapped data');
10844     if (state.decoder) chunk = state.decoder.write(chunk);
10845
10846     // don't skip over falsy values in objectMode
10847     if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
10848
10849     var ret = _this.push(chunk);
10850     if (!ret) {
10851       paused = true;
10852       stream.pause();
10853     }
10854   });
10855
10856   // proxy all the other methods.
10857   // important when wrapping filters and duplexes.
10858   for (var i in stream) {
10859     if (this[i] === undefined && typeof stream[i] === 'function') {
10860       this[i] = function (method) {
10861         return function () {
10862           return stream[method].apply(stream, arguments);
10863         };
10864       }(i);
10865     }
10866   }
10867
10868   // proxy certain important events.
10869   for (var n = 0; n < kProxyEvents.length; n++) {
10870     stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
10871   }
10872
10873   // when we try to consume some more bytes, simply unpause the
10874   // underlying stream.
10875   this._read = function (n) {
10876     debug('wrapped _read', n);
10877     if (paused) {
10878       paused = false;
10879       stream.resume();
10880     }
10881   };
10882
10883   return this;
10884 };
10885
10886 Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
10887   // making it explicit this property is not enumerable
10888   // because otherwise some prototype manipulation in
10889   // userland will fail
10890   enumerable: false,
10891   get: function () {
10892     return this._readableState.highWaterMark;
10893   }
10894 });
10895
10896 // exposed for testing purposes only.
10897 Readable._fromList = fromList;
10898
10899 // Pluck off n bytes from an array of buffers.
10900 // Length is the combined lengths of all the buffers in the list.
10901 // This function is designed to be inlinable, so please take care when making
10902 // changes to the function body.
10903 function fromList(n, state) {
10904   // nothing buffered
10905   if (state.length === 0) return null;
10906
10907   var ret;
10908   if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
10909     // read it all, truncate the list
10910     if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
10911     state.buffer.clear();
10912   } else {
10913     // read part of list
10914     ret = fromListPartial(n, state.buffer, state.decoder);
10915   }
10916
10917   return ret;
10918 }
10919
10920 // Extracts only enough buffered data to satisfy the amount requested.
10921 // This function is designed to be inlinable, so please take care when making
10922 // changes to the function body.
10923 function fromListPartial(n, list, hasStrings) {
10924   var ret;
10925   if (n < list.head.data.length) {
10926     // slice is the same for buffers and strings
10927     ret = list.head.data.slice(0, n);
10928     list.head.data = list.head.data.slice(n);
10929   } else if (n === list.head.data.length) {
10930     // first chunk is a perfect match
10931     ret = list.shift();
10932   } else {
10933     // result spans more than one buffer
10934     ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
10935   }
10936   return ret;
10937 }
10938
10939 // Copies a specified amount of characters from the list of buffered data
10940 // chunks.
10941 // This function is designed to be inlinable, so please take care when making
10942 // changes to the function body.
10943 function copyFromBufferString(n, list) {
10944   var p = list.head;
10945   var c = 1;
10946   var ret = p.data;
10947   n -= ret.length;
10948   while (p = p.next) {
10949     var str = p.data;
10950     var nb = n > str.length ? str.length : n;
10951     if (nb === str.length) ret += str;else ret += str.slice(0, n);
10952     n -= nb;
10953     if (n === 0) {
10954       if (nb === str.length) {
10955         ++c;
10956         if (p.next) list.head = p.next;else list.head = list.tail = null;
10957       } else {
10958         list.head = p;
10959         p.data = str.slice(nb);
10960       }
10961       break;
10962     }
10963     ++c;
10964   }
10965   list.length -= c;
10966   return ret;
10967 }
10968
10969 // Copies a specified amount of bytes from the list of buffered data chunks.
10970 // This function is designed to be inlinable, so please take care when making
10971 // changes to the function body.
10972 function copyFromBuffer(n, list) {
10973   var ret = Buffer.allocUnsafe(n);
10974   var p = list.head;
10975   var c = 1;
10976   p.data.copy(ret);
10977   n -= p.data.length;
10978   while (p = p.next) {
10979     var buf = p.data;
10980     var nb = n > buf.length ? buf.length : n;
10981     buf.copy(ret, ret.length - n, 0, nb);
10982     n -= nb;
10983     if (n === 0) {
10984       if (nb === buf.length) {
10985         ++c;
10986         if (p.next) list.head = p.next;else list.head = list.tail = null;
10987       } else {
10988         list.head = p;
10989         p.data = buf.slice(nb);
10990       }
10991       break;
10992     }
10993     ++c;
10994   }
10995   list.length -= c;
10996   return ret;
10997 }
10998
10999 function endReadable(stream) {
11000   var state = stream._readableState;
11001
11002   // If we get here before consuming all the bytes, then that is a
11003   // bug in node.  Should never happen.
11004   if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
11005
11006   if (!state.endEmitted) {
11007     state.ended = true;
11008     pna.nextTick(endReadableNT, state, stream);
11009   }
11010 }
11011
11012 function endReadableNT(state, stream) {
11013   // Check that we didn't get one last unshift.
11014   if (!state.endEmitted && state.length === 0) {
11015     state.endEmitted = true;
11016     stream.readable = false;
11017     stream.emit('end');
11018   }
11019 }
11020
11021 function indexOf(xs, x) {
11022   for (var i = 0, l = xs.length; i < l; i++) {
11023     if (xs[i] === x) return i;
11024   }
11025   return -1;
11026 }
11027 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
11028
11029 /***/ }),
11030 /* 96 */
11031 /***/ (function(module, exports, __webpack_require__) {
11032
11033 module.exports = __webpack_require__(58).EventEmitter;
11034
11035
11036 /***/ }),
11037 /* 97 */
11038 /***/ (function(module, exports, __webpack_require__) {
11039
11040 "use strict";
11041
11042
11043 /*<replacement>*/
11044
11045 var pna = __webpack_require__(42);
11046 /*</replacement>*/
11047
11048 // undocumented cb() API, needed for core, not for public API
11049 function destroy(err, cb) {
11050   var _this = this;
11051
11052   var readableDestroyed = this._readableState && this._readableState.destroyed;
11053   var writableDestroyed = this._writableState && this._writableState.destroyed;
11054
11055   if (readableDestroyed || writableDestroyed) {
11056     if (cb) {
11057       cb(err);
11058     } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
11059       pna.nextTick(emitErrorNT, this, err);
11060     }
11061     return this;
11062   }
11063
11064   // we set destroyed to true before firing error callbacks in order
11065   // to make it re-entrance safe in case destroy() is called within callbacks
11066
11067   if (this._readableState) {
11068     this._readableState.destroyed = true;
11069   }
11070
11071   // if this is a duplex stream mark the writable part as destroyed as well
11072   if (this._writableState) {
11073     this._writableState.destroyed = true;
11074   }
11075
11076   this._destroy(err || null, function (err) {
11077     if (!cb && err) {
11078       pna.nextTick(emitErrorNT, _this, err);
11079       if (_this._writableState) {
11080         _this._writableState.errorEmitted = true;
11081       }
11082     } else if (cb) {
11083       cb(err);
11084     }
11085   });
11086
11087   return this;
11088 }
11089
11090 function undestroy() {
11091   if (this._readableState) {
11092     this._readableState.destroyed = false;
11093     this._readableState.reading = false;
11094     this._readableState.ended = false;
11095     this._readableState.endEmitted = false;
11096   }
11097
11098   if (this._writableState) {
11099     this._writableState.destroyed = false;
11100     this._writableState.ended = false;
11101     this._writableState.ending = false;
11102     this._writableState.finished = false;
11103     this._writableState.errorEmitted = false;
11104   }
11105 }
11106
11107 function emitErrorNT(self, err) {
11108   self.emit('error', err);
11109 }
11110
11111 module.exports = {
11112   destroy: destroy,
11113   undestroy: undestroy
11114 };
11115
11116 /***/ }),
11117 /* 98 */
11118 /***/ (function(module, exports, __webpack_require__) {
11119
11120 "use strict";
11121 // Copyright Joyent, Inc. and other Node contributors.
11122 //
11123 // Permission is hereby granted, free of charge, to any person obtaining a
11124 // copy of this software and associated documentation files (the
11125 // "Software"), to deal in the Software without restriction, including
11126 // without limitation the rights to use, copy, modify, merge, publish,
11127 // distribute, sublicense, and/or sell copies of the Software, and to permit
11128 // persons to whom the Software is furnished to do so, subject to the
11129 // following conditions:
11130 //
11131 // The above copyright notice and this permission notice shall be included
11132 // in all copies or substantial portions of the Software.
11133 //
11134 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11135 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11136 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
11137 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
11138 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11139 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
11140 // USE OR OTHER DEALINGS IN THE SOFTWARE.
11141
11142 // a transform stream is a readable/writable stream where you do
11143 // something with the data.  Sometimes it's called a "filter",
11144 // but that's not a great name for it, since that implies a thing where
11145 // some bits pass through, and others are simply ignored.  (That would
11146 // be a valid example of a transform, of course.)
11147 //
11148 // While the output is causally related to the input, it's not a
11149 // necessarily symmetric or synchronous transformation.  For example,
11150 // a zlib stream might take multiple plain-text writes(), and then
11151 // emit a single compressed chunk some time in the future.
11152 //
11153 // Here's how this works:
11154 //
11155 // The Transform stream has all the aspects of the readable and writable
11156 // stream classes.  When you write(chunk), that calls _write(chunk,cb)
11157 // internally, and returns false if there's a lot of pending writes
11158 // buffered up.  When you call read(), that calls _read(n) until
11159 // there's enough pending readable data buffered up.
11160 //
11161 // In a transform stream, the written data is placed in a buffer.  When
11162 // _read(n) is called, it transforms the queued up data, calling the
11163 // buffered _write cb's as it consumes chunks.  If consuming a single
11164 // written chunk would result in multiple output chunks, then the first
11165 // outputted bit calls the readcb, and subsequent chunks just go into
11166 // the read buffer, and will cause it to emit 'readable' if necessary.
11167 //
11168 // This way, back-pressure is actually determined by the reading side,
11169 // since _read has to be called to start processing a new chunk.  However,
11170 // a pathological inflate type of transform can cause excessive buffering
11171 // here.  For example, imagine a stream where every byte of input is
11172 // interpreted as an integer from 0-255, and then results in that many
11173 // bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
11174 // 1kb of data being output.  In this case, you could write a very small
11175 // amount of input, and end up with a very large amount of output.  In
11176 // such a pathological inflating mechanism, there'd be no way to tell
11177 // the system to stop doing the transform.  A single 4MB write could
11178 // cause the system to run out of memory.
11179 //
11180 // However, even in such a pathological case, only a single written chunk
11181 // would be consumed, and then the rest would wait (un-transformed) until
11182 // the results of the previous transformed chunk were consumed.
11183
11184
11185
11186 module.exports = Transform;
11187
11188 var Duplex = __webpack_require__(21);
11189
11190 /*<replacement>*/
11191 var util = __webpack_require__(30);
11192 util.inherits = __webpack_require__(1);
11193 /*</replacement>*/
11194
11195 util.inherits(Transform, Duplex);
11196
11197 function afterTransform(er, data) {
11198   var ts = this._transformState;
11199   ts.transforming = false;
11200
11201   var cb = ts.writecb;
11202
11203   if (!cb) {
11204     return this.emit('error', new Error('write callback called multiple times'));
11205   }
11206
11207   ts.writechunk = null;
11208   ts.writecb = null;
11209
11210   if (data != null) // single equals check for both `null` and `undefined`
11211     this.push(data);
11212
11213   cb(er);
11214
11215   var rs = this._readableState;
11216   rs.reading = false;
11217   if (rs.needReadable || rs.length < rs.highWaterMark) {
11218     this._read(rs.highWaterMark);
11219   }
11220 }
11221
11222 function Transform(options) {
11223   if (!(this instanceof Transform)) return new Transform(options);
11224
11225   Duplex.call(this, options);
11226
11227   this._transformState = {
11228     afterTransform: afterTransform.bind(this),
11229     needTransform: false,
11230     transforming: false,
11231     writecb: null,
11232     writechunk: null,
11233     writeencoding: null
11234   };
11235
11236   // start out asking for a readable event once data is transformed.
11237   this._readableState.needReadable = true;
11238
11239   // we have implemented the _read method, and done the other things
11240   // that Readable wants before the first _read call, so unset the
11241   // sync guard flag.
11242   this._readableState.sync = false;
11243
11244   if (options) {
11245     if (typeof options.transform === 'function') this._transform = options.transform;
11246
11247     if (typeof options.flush === 'function') this._flush = options.flush;
11248   }
11249
11250   // When the writable side finishes, then flush out anything remaining.
11251   this.on('prefinish', prefinish);
11252 }
11253
11254 function prefinish() {
11255   var _this = this;
11256
11257   if (typeof this._flush === 'function') {
11258     this._flush(function (er, data) {
11259       done(_this, er, data);
11260     });
11261   } else {
11262     done(this, null, null);
11263   }
11264 }
11265
11266 Transform.prototype.push = function (chunk, encoding) {
11267   this._transformState.needTransform = false;
11268   return Duplex.prototype.push.call(this, chunk, encoding);
11269 };
11270
11271 // This is the part where you do stuff!
11272 // override this function in implementation classes.
11273 // 'chunk' is an input chunk.
11274 //
11275 // Call `push(newChunk)` to pass along transformed output
11276 // to the readable side.  You may call 'push' zero or more times.
11277 //
11278 // Call `cb(err)` when you are done with this chunk.  If you pass
11279 // an error, then that'll put the hurt on the whole operation.  If you
11280 // never call cb(), then you'll never get another chunk.
11281 Transform.prototype._transform = function (chunk, encoding, cb) {
11282   throw new Error('_transform() is not implemented');
11283 };
11284
11285 Transform.prototype._write = function (chunk, encoding, cb) {
11286   var ts = this._transformState;
11287   ts.writecb = cb;
11288   ts.writechunk = chunk;
11289   ts.writeencoding = encoding;
11290   if (!ts.transforming) {
11291     var rs = this._readableState;
11292     if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
11293   }
11294 };
11295
11296 // Doesn't matter what the args are here.
11297 // _transform does all the work.
11298 // That we got here means that the readable side wants more data.
11299 Transform.prototype._read = function (n) {
11300   var ts = this._transformState;
11301
11302   if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
11303     ts.transforming = true;
11304     this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
11305   } else {
11306     // mark that we need a transform, so that any data that comes in
11307     // will get processed, now that we've asked for it.
11308     ts.needTransform = true;
11309   }
11310 };
11311
11312 Transform.prototype._destroy = function (err, cb) {
11313   var _this2 = this;
11314
11315   Duplex.prototype._destroy.call(this, err, function (err2) {
11316     cb(err2);
11317     _this2.emit('close');
11318   });
11319 };
11320
11321 function done(stream, er, data) {
11322   if (er) return stream.emit('error', er);
11323
11324   if (data != null) // single equals check for both `null` and `undefined`
11325     stream.push(data);
11326
11327   // if there's nothing in the write buffer, then that means
11328   // that nothing more will ever be provided
11329   if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
11330
11331   if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
11332
11333   return stream.push(null);
11334 }
11335
11336 /***/ }),
11337 /* 99 */
11338 /***/ (function(module, exports, __webpack_require__) {
11339
11340 /**
11341  * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
11342  * in FIPS 180-2
11343  * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
11344  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
11345  *
11346  */
11347
11348 var inherits = __webpack_require__(1)
11349 var Hash = __webpack_require__(24)
11350 var Buffer = __webpack_require__(2).Buffer
11351
11352 var K = [
11353   0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
11354   0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
11355   0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
11356   0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
11357   0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
11358   0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
11359   0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
11360   0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
11361   0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
11362   0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
11363   0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
11364   0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
11365   0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
11366   0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
11367   0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
11368   0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
11369 ]
11370
11371 var W = new Array(64)
11372
11373 function Sha256 () {
11374   this.init()
11375
11376   this._w = W // new Array(64)
11377
11378   Hash.call(this, 64, 56)
11379 }
11380
11381 inherits(Sha256, Hash)
11382
11383 Sha256.prototype.init = function () {
11384   this._a = 0x6a09e667
11385   this._b = 0xbb67ae85
11386   this._c = 0x3c6ef372
11387   this._d = 0xa54ff53a
11388   this._e = 0x510e527f
11389   this._f = 0x9b05688c
11390   this._g = 0x1f83d9ab
11391   this._h = 0x5be0cd19
11392
11393   return this
11394 }
11395
11396 function ch (x, y, z) {
11397   return z ^ (x & (y ^ z))
11398 }
11399
11400 function maj (x, y, z) {
11401   return (x & y) | (z & (x | y))
11402 }
11403
11404 function sigma0 (x) {
11405   return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
11406 }
11407
11408 function sigma1 (x) {
11409   return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
11410 }
11411
11412 function gamma0 (x) {
11413   return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
11414 }
11415
11416 function gamma1 (x) {
11417   return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
11418 }
11419
11420 Sha256.prototype._update = function (M) {
11421   var W = this._w
11422
11423   var a = this._a | 0
11424   var b = this._b | 0
11425   var c = this._c | 0
11426   var d = this._d | 0
11427   var e = this._e | 0
11428   var f = this._f | 0
11429   var g = this._g | 0
11430   var h = this._h | 0
11431
11432   for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
11433   for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
11434
11435   for (var j = 0; j < 64; ++j) {
11436     var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
11437     var T2 = (sigma0(a) + maj(a, b, c)) | 0
11438
11439     h = g
11440     g = f
11441     f = e
11442     e = (d + T1) | 0
11443     d = c
11444     c = b
11445     b = a
11446     a = (T1 + T2) | 0
11447   }
11448
11449   this._a = (a + this._a) | 0
11450   this._b = (b + this._b) | 0
11451   this._c = (c + this._c) | 0
11452   this._d = (d + this._d) | 0
11453   this._e = (e + this._e) | 0
11454   this._f = (f + this._f) | 0
11455   this._g = (g + this._g) | 0
11456   this._h = (h + this._h) | 0
11457 }
11458
11459 Sha256.prototype._hash = function () {
11460   var H = Buffer.allocUnsafe(32)
11461
11462   H.writeInt32BE(this._a, 0)
11463   H.writeInt32BE(this._b, 4)
11464   H.writeInt32BE(this._c, 8)
11465   H.writeInt32BE(this._d, 12)
11466   H.writeInt32BE(this._e, 16)
11467   H.writeInt32BE(this._f, 20)
11468   H.writeInt32BE(this._g, 24)
11469   H.writeInt32BE(this._h, 28)
11470
11471   return H
11472 }
11473
11474 module.exports = Sha256
11475
11476
11477 /***/ }),
11478 /* 100 */
11479 /***/ (function(module, exports, __webpack_require__) {
11480
11481 var inherits = __webpack_require__(1)
11482 var Hash = __webpack_require__(24)
11483 var Buffer = __webpack_require__(2).Buffer
11484
11485 var K = [
11486   0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
11487   0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
11488   0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
11489   0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
11490   0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
11491   0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
11492   0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
11493   0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
11494   0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
11495   0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
11496   0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
11497   0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
11498   0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
11499   0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
11500   0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
11501   0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
11502   0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
11503   0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
11504   0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
11505   0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
11506   0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
11507   0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
11508   0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
11509   0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
11510   0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
11511   0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
11512   0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
11513   0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
11514   0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
11515   0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
11516   0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
11517   0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
11518   0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
11519   0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
11520   0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
11521   0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
11522   0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
11523   0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
11524   0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
11525   0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
11526 ]
11527
11528 var W = new Array(160)
11529
11530 function Sha512 () {
11531   this.init()
11532   this._w = W
11533
11534   Hash.call(this, 128, 112)
11535 }
11536
11537 inherits(Sha512, Hash)
11538
11539 Sha512.prototype.init = function () {
11540   this._ah = 0x6a09e667
11541   this._bh = 0xbb67ae85
11542   this._ch = 0x3c6ef372
11543   this._dh = 0xa54ff53a
11544   this._eh = 0x510e527f
11545   this._fh = 0x9b05688c
11546   this._gh = 0x1f83d9ab
11547   this._hh = 0x5be0cd19
11548
11549   this._al = 0xf3bcc908
11550   this._bl = 0x84caa73b
11551   this._cl = 0xfe94f82b
11552   this._dl = 0x5f1d36f1
11553   this._el = 0xade682d1
11554   this._fl = 0x2b3e6c1f
11555   this._gl = 0xfb41bd6b
11556   this._hl = 0x137e2179
11557
11558   return this
11559 }
11560
11561 function Ch (x, y, z) {
11562   return z ^ (x & (y ^ z))
11563 }
11564
11565 function maj (x, y, z) {
11566   return (x & y) | (z & (x | y))
11567 }
11568
11569 function sigma0 (x, xl) {
11570   return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
11571 }
11572
11573 function sigma1 (x, xl) {
11574   return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
11575 }
11576
11577 function Gamma0 (x, xl) {
11578   return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
11579 }
11580
11581 function Gamma0l (x, xl) {
11582   return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
11583 }
11584
11585 function Gamma1 (x, xl) {
11586   return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
11587 }
11588
11589 function Gamma1l (x, xl) {
11590   return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
11591 }
11592
11593 function getCarry (a, b) {
11594   return (a >>> 0) < (b >>> 0) ? 1 : 0
11595 }
11596
11597 Sha512.prototype._update = function (M) {
11598   var W = this._w
11599
11600   var ah = this._ah | 0
11601   var bh = this._bh | 0
11602   var ch = this._ch | 0
11603   var dh = this._dh | 0
11604   var eh = this._eh | 0
11605   var fh = this._fh | 0
11606   var gh = this._gh | 0
11607   var hh = this._hh | 0
11608
11609   var al = this._al | 0
11610   var bl = this._bl | 0
11611   var cl = this._cl | 0
11612   var dl = this._dl | 0
11613   var el = this._el | 0
11614   var fl = this._fl | 0
11615   var gl = this._gl | 0
11616   var hl = this._hl | 0
11617
11618   for (var i = 0; i < 32; i += 2) {
11619     W[i] = M.readInt32BE(i * 4)
11620     W[i + 1] = M.readInt32BE(i * 4 + 4)
11621   }
11622   for (; i < 160; i += 2) {
11623     var xh = W[i - 15 * 2]
11624     var xl = W[i - 15 * 2 + 1]
11625     var gamma0 = Gamma0(xh, xl)
11626     var gamma0l = Gamma0l(xl, xh)
11627
11628     xh = W[i - 2 * 2]
11629     xl = W[i - 2 * 2 + 1]
11630     var gamma1 = Gamma1(xh, xl)
11631     var gamma1l = Gamma1l(xl, xh)
11632
11633     // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
11634     var Wi7h = W[i - 7 * 2]
11635     var Wi7l = W[i - 7 * 2 + 1]
11636
11637     var Wi16h = W[i - 16 * 2]
11638     var Wi16l = W[i - 16 * 2 + 1]
11639
11640     var Wil = (gamma0l + Wi7l) | 0
11641     var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
11642     Wil = (Wil + gamma1l) | 0
11643     Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
11644     Wil = (Wil + Wi16l) | 0
11645     Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
11646
11647     W[i] = Wih
11648     W[i + 1] = Wil
11649   }
11650
11651   for (var j = 0; j < 160; j += 2) {
11652     Wih = W[j]
11653     Wil = W[j + 1]
11654
11655     var majh = maj(ah, bh, ch)
11656     var majl = maj(al, bl, cl)
11657
11658     var sigma0h = sigma0(ah, al)
11659     var sigma0l = sigma0(al, ah)
11660     var sigma1h = sigma1(eh, el)
11661     var sigma1l = sigma1(el, eh)
11662
11663     // t1 = h + sigma1 + ch + K[j] + W[j]
11664     var Kih = K[j]
11665     var Kil = K[j + 1]
11666
11667     var chh = Ch(eh, fh, gh)
11668     var chl = Ch(el, fl, gl)
11669
11670     var t1l = (hl + sigma1l) | 0
11671     var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
11672     t1l = (t1l + chl) | 0
11673     t1h = (t1h + chh + getCarry(t1l, chl)) | 0
11674     t1l = (t1l + Kil) | 0
11675     t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
11676     t1l = (t1l + Wil) | 0
11677     t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
11678
11679     // t2 = sigma0 + maj
11680     var t2l = (sigma0l + majl) | 0
11681     var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
11682
11683     hh = gh
11684     hl = gl
11685     gh = fh
11686     gl = fl
11687     fh = eh
11688     fl = el
11689     el = (dl + t1l) | 0
11690     eh = (dh + t1h + getCarry(el, dl)) | 0
11691     dh = ch
11692     dl = cl
11693     ch = bh
11694     cl = bl
11695     bh = ah
11696     bl = al
11697     al = (t1l + t2l) | 0
11698     ah = (t1h + t2h + getCarry(al, t1l)) | 0
11699   }
11700
11701   this._al = (this._al + al) | 0
11702   this._bl = (this._bl + bl) | 0
11703   this._cl = (this._cl + cl) | 0
11704   this._dl = (this._dl + dl) | 0
11705   this._el = (this._el + el) | 0
11706   this._fl = (this._fl + fl) | 0
11707   this._gl = (this._gl + gl) | 0
11708   this._hl = (this._hl + hl) | 0
11709
11710   this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
11711   this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
11712   this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
11713   this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
11714   this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
11715   this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
11716   this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
11717   this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
11718 }
11719
11720 Sha512.prototype._hash = function () {
11721   var H = Buffer.allocUnsafe(64)
11722
11723   function writeInt64BE (h, l, offset) {
11724     H.writeInt32BE(h, offset)
11725     H.writeInt32BE(l, offset + 4)
11726   }
11727
11728   writeInt64BE(this._ah, this._al, 0)
11729   writeInt64BE(this._bh, this._bl, 8)
11730   writeInt64BE(this._ch, this._cl, 16)
11731   writeInt64BE(this._dh, this._dl, 24)
11732   writeInt64BE(this._eh, this._el, 32)
11733   writeInt64BE(this._fh, this._fl, 40)
11734   writeInt64BE(this._gh, this._gl, 48)
11735   writeInt64BE(this._hh, this._hl, 56)
11736
11737   return H
11738 }
11739
11740 module.exports = Sha512
11741
11742
11743 /***/ }),
11744 /* 101 */
11745 /***/ (function(module, exports, __webpack_require__) {
11746
11747 "use strict";
11748
11749 var inherits = __webpack_require__(1)
11750 var Legacy = __webpack_require__(196)
11751 var Base = __webpack_require__(18)
11752 var Buffer = __webpack_require__(2).Buffer
11753 var md5 = __webpack_require__(102)
11754 var RIPEMD160 = __webpack_require__(62)
11755
11756 var sha = __webpack_require__(63)
11757
11758 var ZEROS = Buffer.alloc(128)
11759
11760 function Hmac (alg, key) {
11761   Base.call(this, 'digest')
11762   if (typeof key === 'string') {
11763     key = Buffer.from(key)
11764   }
11765
11766   var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
11767
11768   this._alg = alg
11769   this._key = key
11770   if (key.length > blocksize) {
11771     var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
11772     key = hash.update(key).digest()
11773   } else if (key.length < blocksize) {
11774     key = Buffer.concat([key, ZEROS], blocksize)
11775   }
11776
11777   var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
11778   var opad = this._opad = Buffer.allocUnsafe(blocksize)
11779
11780   for (var i = 0; i < blocksize; i++) {
11781     ipad[i] = key[i] ^ 0x36
11782     opad[i] = key[i] ^ 0x5C
11783   }
11784   this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
11785   this._hash.update(ipad)
11786 }
11787
11788 inherits(Hmac, Base)
11789
11790 Hmac.prototype._update = function (data) {
11791   this._hash.update(data)
11792 }
11793
11794 Hmac.prototype._final = function () {
11795   var h = this._hash.digest()
11796   var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
11797   return hash.update(this._opad).update(h).digest()
11798 }
11799
11800 module.exports = function createHmac (alg, key) {
11801   alg = alg.toLowerCase()
11802   if (alg === 'rmd160' || alg === 'ripemd160') {
11803     return new Hmac('rmd160', key)
11804   }
11805   if (alg === 'md5') {
11806     return new Legacy(md5, key)
11807   }
11808   return new Hmac(alg, key)
11809 }
11810
11811
11812 /***/ }),
11813 /* 102 */
11814 /***/ (function(module, exports, __webpack_require__) {
11815
11816 var MD5 = __webpack_require__(56)
11817
11818 module.exports = function (buffer) {
11819   return new MD5().update(buffer).digest()
11820 }
11821
11822
11823 /***/ }),
11824 /* 103 */
11825 /***/ (function(module, exports) {
11826
11827 module.exports = {"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}
11828
11829 /***/ }),
11830 /* 104 */
11831 /***/ (function(module, exports, __webpack_require__) {
11832
11833 exports.pbkdf2 = __webpack_require__(198)
11834 exports.pbkdf2Sync = __webpack_require__(107)
11835
11836
11837 /***/ }),
11838 /* 105 */
11839 /***/ (function(module, exports, __webpack_require__) {
11840
11841 /* WEBPACK VAR INJECTION */(function(Buffer) {var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
11842
11843 function checkBuffer (buf, name) {
11844   if (typeof buf !== 'string' && !Buffer.isBuffer(buf)) {
11845     throw new TypeError(name + ' must be a buffer or string')
11846   }
11847 }
11848
11849 module.exports = function (password, salt, iterations, keylen) {
11850   checkBuffer(password, 'Password')
11851   checkBuffer(salt, 'Salt')
11852
11853   if (typeof iterations !== 'number') {
11854     throw new TypeError('Iterations not a number')
11855   }
11856
11857   if (iterations < 0) {
11858     throw new TypeError('Bad iterations')
11859   }
11860
11861   if (typeof keylen !== 'number') {
11862     throw new TypeError('Key length not a number')
11863   }
11864
11865   if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
11866     throw new TypeError('Bad key length')
11867   }
11868 }
11869
11870 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
11871
11872 /***/ }),
11873 /* 106 */
11874 /***/ (function(module, exports, __webpack_require__) {
11875
11876 /* WEBPACK VAR INJECTION */(function(process) {var defaultEncoding
11877 /* istanbul ignore next */
11878 if (process.browser) {
11879   defaultEncoding = 'utf-8'
11880 } else {
11881   var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
11882
11883   defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
11884 }
11885 module.exports = defaultEncoding
11886
11887 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(14)))
11888
11889 /***/ }),
11890 /* 107 */
11891 /***/ (function(module, exports, __webpack_require__) {
11892
11893 var md5 = __webpack_require__(102)
11894 var rmd160 = __webpack_require__(62)
11895 var sha = __webpack_require__(63)
11896
11897 var checkParameters = __webpack_require__(105)
11898 var defaultEncoding = __webpack_require__(106)
11899 var Buffer = __webpack_require__(2).Buffer
11900 var ZEROS = Buffer.alloc(128)
11901 var sizes = {
11902   md5: 16,
11903   sha1: 20,
11904   sha224: 28,
11905   sha256: 32,
11906   sha384: 48,
11907   sha512: 64,
11908   rmd160: 20,
11909   ripemd160: 20
11910 }
11911
11912 function Hmac (alg, key, saltLen) {
11913   var hash = getDigest(alg)
11914   var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
11915
11916   if (key.length > blocksize) {
11917     key = hash(key)
11918   } else if (key.length < blocksize) {
11919     key = Buffer.concat([key, ZEROS], blocksize)
11920   }
11921
11922   var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
11923   var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
11924   for (var i = 0; i < blocksize; i++) {
11925     ipad[i] = key[i] ^ 0x36
11926     opad[i] = key[i] ^ 0x5C
11927   }
11928
11929   var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
11930   ipad.copy(ipad1, 0, 0, blocksize)
11931   this.ipad1 = ipad1
11932   this.ipad2 = ipad
11933   this.opad = opad
11934   this.alg = alg
11935   this.blocksize = blocksize
11936   this.hash = hash
11937   this.size = sizes[alg]
11938 }
11939
11940 Hmac.prototype.run = function (data, ipad) {
11941   data.copy(ipad, this.blocksize)
11942   var h = this.hash(ipad)
11943   h.copy(this.opad, this.blocksize)
11944   return this.hash(this.opad)
11945 }
11946
11947 function getDigest (alg) {
11948   function shaFunc (data) {
11949     return sha(alg).update(data).digest()
11950   }
11951
11952   if (alg === 'rmd160' || alg === 'ripemd160') return rmd160
11953   if (alg === 'md5') return md5
11954   return shaFunc
11955 }
11956
11957 function pbkdf2 (password, salt, iterations, keylen, digest) {
11958   checkParameters(password, salt, iterations, keylen)
11959
11960   if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
11961   if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
11962
11963   digest = digest || 'sha1'
11964
11965   var hmac = new Hmac(digest, password, salt.length)
11966
11967   var DK = Buffer.allocUnsafe(keylen)
11968   var block1 = Buffer.allocUnsafe(salt.length + 4)
11969   salt.copy(block1, 0, 0, salt.length)
11970
11971   var destPos = 0
11972   var hLen = sizes[digest]
11973   var l = Math.ceil(keylen / hLen)
11974
11975   for (var i = 1; i <= l; i++) {
11976     block1.writeUInt32BE(i, salt.length)
11977
11978     var T = hmac.run(block1, hmac.ipad1)
11979     var U = T
11980
11981     for (var j = 1; j < iterations; j++) {
11982       U = hmac.run(U, hmac.ipad2)
11983       for (var k = 0; k < hLen; k++) T[k] ^= U[k]
11984     }
11985
11986     T.copy(DK, destPos)
11987     destPos += hLen
11988   }
11989
11990   return DK
11991 }
11992
11993 module.exports = pbkdf2
11994
11995
11996 /***/ }),
11997 /* 108 */
11998 /***/ (function(module, exports, __webpack_require__) {
11999
12000 var xor = __webpack_require__(31)
12001 var Buffer = __webpack_require__(2).Buffer
12002 var incr32 = __webpack_require__(109)
12003
12004 function getBlock (self) {
12005   var out = self._cipher.encryptBlockRaw(self._prev)
12006   incr32(self._prev)
12007   return out
12008 }
12009
12010 var blockSize = 16
12011 exports.encrypt = function (self, chunk) {
12012   var chunkNum = Math.ceil(chunk.length / blockSize)
12013   var start = self._cache.length
12014   self._cache = Buffer.concat([
12015     self._cache,
12016     Buffer.allocUnsafe(chunkNum * blockSize)
12017   ])
12018   for (var i = 0; i < chunkNum; i++) {
12019     var out = getBlock(self)
12020     var offset = start + i * blockSize
12021     self._cache.writeUInt32BE(out[0], offset + 0)
12022     self._cache.writeUInt32BE(out[1], offset + 4)
12023     self._cache.writeUInt32BE(out[2], offset + 8)
12024     self._cache.writeUInt32BE(out[3], offset + 12)
12025   }
12026   var pad = self._cache.slice(0, chunk.length)
12027   self._cache = self._cache.slice(chunk.length)
12028   return xor(chunk, pad)
12029 }
12030
12031
12032 /***/ }),
12033 /* 109 */
12034 /***/ (function(module, exports) {
12035
12036 function incr32 (iv) {
12037   var len = iv.length
12038   var item
12039   while (len--) {
12040     item = iv.readUInt8(len)
12041     if (item === 255) {
12042       iv.writeUInt8(0, len)
12043     } else {
12044       item++
12045       iv.writeUInt8(item, len)
12046       break
12047     }
12048   }
12049 }
12050 module.exports = incr32
12051
12052
12053 /***/ }),
12054 /* 110 */
12055 /***/ (function(module, exports) {
12056
12057 module.exports = {"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}
12058
12059 /***/ }),
12060 /* 111 */
12061 /***/ (function(module, exports, __webpack_require__) {
12062
12063 var aes = __webpack_require__(43)
12064 var Buffer = __webpack_require__(2).Buffer
12065 var Transform = __webpack_require__(18)
12066 var inherits = __webpack_require__(1)
12067 var GHASH = __webpack_require__(213)
12068 var xor = __webpack_require__(31)
12069 var incr32 = __webpack_require__(109)
12070
12071 function xorTest (a, b) {
12072   var out = 0
12073   if (a.length !== b.length) out++
12074
12075   var len = Math.min(a.length, b.length)
12076   for (var i = 0; i < len; ++i) {
12077     out += (a[i] ^ b[i])
12078   }
12079
12080   return out
12081 }
12082
12083 function calcIv (self, iv, ck) {
12084   if (iv.length === 12) {
12085     self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
12086     return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
12087   }
12088   var ghash = new GHASH(ck)
12089   var len = iv.length
12090   var toPad = len % 16
12091   ghash.update(iv)
12092   if (toPad) {
12093     toPad = 16 - toPad
12094     ghash.update(Buffer.alloc(toPad, 0))
12095   }
12096   ghash.update(Buffer.alloc(8, 0))
12097   var ivBits = len * 8
12098   var tail = Buffer.alloc(8)
12099   tail.writeUIntBE(ivBits, 0, 8)
12100   ghash.update(tail)
12101   self._finID = ghash.state
12102   var out = Buffer.from(self._finID)
12103   incr32(out)
12104   return out
12105 }
12106 function StreamCipher (mode, key, iv, decrypt) {
12107   Transform.call(this)
12108
12109   var h = Buffer.alloc(4, 0)
12110
12111   this._cipher = new aes.AES(key)
12112   var ck = this._cipher.encryptBlock(h)
12113   this._ghash = new GHASH(ck)
12114   iv = calcIv(this, iv, ck)
12115
12116   this._prev = Buffer.from(iv)
12117   this._cache = Buffer.allocUnsafe(0)
12118   this._secCache = Buffer.allocUnsafe(0)
12119   this._decrypt = decrypt
12120   this._alen = 0
12121   this._len = 0
12122   this._mode = mode
12123
12124   this._authTag = null
12125   this._called = false
12126 }
12127
12128 inherits(StreamCipher, Transform)
12129
12130 StreamCipher.prototype._update = function (chunk) {
12131   if (!this._called && this._alen) {
12132     var rump = 16 - (this._alen % 16)
12133     if (rump < 16) {
12134       rump = Buffer.alloc(rump, 0)
12135       this._ghash.update(rump)
12136     }
12137   }
12138
12139   this._called = true
12140   var out = this._mode.encrypt(this, chunk)
12141   if (this._decrypt) {
12142     this._ghash.update(chunk)
12143   } else {
12144     this._ghash.update(out)
12145   }
12146   this._len += chunk.length
12147   return out
12148 }
12149
12150 StreamCipher.prototype._final = function () {
12151   if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
12152
12153   var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
12154   if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
12155
12156   this._authTag = tag
12157   this._cipher.scrub()
12158 }
12159
12160 StreamCipher.prototype.getAuthTag = function getAuthTag () {
12161   if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
12162
12163   return this._authTag
12164 }
12165
12166 StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
12167   if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
12168
12169   this._authTag = tag
12170 }
12171
12172 StreamCipher.prototype.setAAD = function setAAD (buf) {
12173   if (this._called) throw new Error('Attempting to set AAD in unsupported state')
12174
12175   this._ghash.update(buf)
12176   this._alen += buf.length
12177 }
12178
12179 module.exports = StreamCipher
12180
12181
12182 /***/ }),
12183 /* 112 */
12184 /***/ (function(module, exports, __webpack_require__) {
12185
12186 var aes = __webpack_require__(43)
12187 var Buffer = __webpack_require__(2).Buffer
12188 var Transform = __webpack_require__(18)
12189 var inherits = __webpack_require__(1)
12190
12191 function StreamCipher (mode, key, iv, decrypt) {
12192   Transform.call(this)
12193
12194   this._cipher = new aes.AES(key)
12195   this._prev = Buffer.from(iv)
12196   this._cache = Buffer.allocUnsafe(0)
12197   this._secCache = Buffer.allocUnsafe(0)
12198   this._decrypt = decrypt
12199   this._mode = mode
12200 }
12201
12202 inherits(StreamCipher, Transform)
12203
12204 StreamCipher.prototype._update = function (chunk) {
12205   return this._mode.encrypt(this, chunk, this._decrypt)
12206 }
12207
12208 StreamCipher.prototype._final = function () {
12209   this._cipher.scrub()
12210 }
12211
12212 module.exports = StreamCipher
12213
12214
12215 /***/ }),
12216 /* 113 */
12217 /***/ (function(module, exports, __webpack_require__) {
12218
12219 var randomBytes = __webpack_require__(23);
12220 module.exports = findPrime;
12221 findPrime.simpleSieve = simpleSieve;
12222 findPrime.fermatTest = fermatTest;
12223 var BN = __webpack_require__(4);
12224 var TWENTYFOUR = new BN(24);
12225 var MillerRabin = __webpack_require__(114);
12226 var millerRabin = new MillerRabin();
12227 var ONE = new BN(1);
12228 var TWO = new BN(2);
12229 var FIVE = new BN(5);
12230 var SIXTEEN = new BN(16);
12231 var EIGHT = new BN(8);
12232 var TEN = new BN(10);
12233 var THREE = new BN(3);
12234 var SEVEN = new BN(7);
12235 var ELEVEN = new BN(11);
12236 var FOUR = new BN(4);
12237 var TWELVE = new BN(12);
12238 var primes = null;
12239
12240 function _getPrimes() {
12241   if (primes !== null)
12242     return primes;
12243
12244   var limit = 0x100000;
12245   var res = [];
12246   res[0] = 2;
12247   for (var i = 1, k = 3; k < limit; k += 2) {
12248     var sqrt = Math.ceil(Math.sqrt(k));
12249     for (var j = 0; j < i && res[j] <= sqrt; j++)
12250       if (k % res[j] === 0)
12251         break;
12252
12253     if (i !== j && res[j] <= sqrt)
12254       continue;
12255
12256     res[i++] = k;
12257   }
12258   primes = res;
12259   return res;
12260 }
12261
12262 function simpleSieve(p) {
12263   var primes = _getPrimes();
12264
12265   for (var i = 0; i < primes.length; i++)
12266     if (p.modn(primes[i]) === 0) {
12267       if (p.cmpn(primes[i]) === 0) {
12268         return true;
12269       } else {
12270         return false;
12271       }
12272     }
12273
12274   return true;
12275 }
12276
12277 function fermatTest(p) {
12278   var red = BN.mont(p);
12279   return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
12280 }
12281
12282 function findPrime(bits, gen) {
12283   if (bits < 16) {
12284     // this is what openssl does
12285     if (gen === 2 || gen === 5) {
12286       return new BN([0x8c, 0x7b]);
12287     } else {
12288       return new BN([0x8c, 0x27]);
12289     }
12290   }
12291   gen = new BN(gen);
12292
12293   var num, n2;
12294
12295   while (true) {
12296     num = new BN(randomBytes(Math.ceil(bits / 8)));
12297     while (num.bitLength() > bits) {
12298       num.ishrn(1);
12299     }
12300     if (num.isEven()) {
12301       num.iadd(ONE);
12302     }
12303     if (!num.testn(1)) {
12304       num.iadd(TWO);
12305     }
12306     if (!gen.cmp(TWO)) {
12307       while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
12308         num.iadd(FOUR);
12309       }
12310     } else if (!gen.cmp(FIVE)) {
12311       while (num.mod(TEN).cmp(THREE)) {
12312         num.iadd(FOUR);
12313       }
12314     }
12315     n2 = num.shrn(1);
12316     if (simpleSieve(n2) && simpleSieve(num) &&
12317       fermatTest(n2) && fermatTest(num) &&
12318       millerRabin.test(n2) && millerRabin.test(num)) {
12319       return num;
12320     }
12321   }
12322
12323 }
12324
12325
12326 /***/ }),
12327 /* 114 */
12328 /***/ (function(module, exports, __webpack_require__) {
12329
12330 var bn = __webpack_require__(4);
12331 var brorand = __webpack_require__(115);
12332
12333 function MillerRabin(rand) {
12334   this.rand = rand || new brorand.Rand();
12335 }
12336 module.exports = MillerRabin;
12337
12338 MillerRabin.create = function create(rand) {
12339   return new MillerRabin(rand);
12340 };
12341
12342 MillerRabin.prototype._randbelow = function _randbelow(n) {
12343   var len = n.bitLength();
12344   var min_bytes = Math.ceil(len / 8);
12345
12346   // Generage random bytes until a number less than n is found.
12347   // This ensures that 0..n-1 have an equal probability of being selected.
12348   do
12349     var a = new bn(this.rand.generate(min_bytes));
12350   while (a.cmp(n) >= 0);
12351
12352   return a;
12353 };
12354
12355 MillerRabin.prototype._randrange = function _randrange(start, stop) {
12356   // Generate a random number greater than or equal to start and less than stop.
12357   var size = stop.sub(start);
12358   return start.add(this._randbelow(size));
12359 };
12360
12361 MillerRabin.prototype.test = function test(n, k, cb) {
12362   var len = n.bitLength();
12363   var red = bn.mont(n);
12364   var rone = new bn(1).toRed(red);
12365
12366   if (!k)
12367     k = Math.max(1, (len / 48) | 0);
12368
12369   // Find d and s, (n - 1) = (2 ^ s) * d;
12370   var n1 = n.subn(1);
12371   for (var s = 0; !n1.testn(s); s++) {}
12372   var d = n.shrn(s);
12373
12374   var rn1 = n1.toRed(red);
12375
12376   var prime = true;
12377   for (; k > 0; k--) {
12378     var a = this._randrange(new bn(2), n1);
12379     if (cb)
12380       cb(a);
12381
12382     var x = a.toRed(red).redPow(d);
12383     if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
12384       continue;
12385
12386     for (var i = 1; i < s; i++) {
12387       x = x.redSqr();
12388
12389       if (x.cmp(rone) === 0)
12390         return false;
12391       if (x.cmp(rn1) === 0)
12392         break;
12393     }
12394
12395     if (i === s)
12396       return false;
12397   }
12398
12399   return prime;
12400 };
12401
12402 MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
12403   var len = n.bitLength();
12404   var red = bn.mont(n);
12405   var rone = new bn(1).toRed(red);
12406
12407   if (!k)
12408     k = Math.max(1, (len / 48) | 0);
12409
12410   // Find d and s, (n - 1) = (2 ^ s) * d;
12411   var n1 = n.subn(1);
12412   for (var s = 0; !n1.testn(s); s++) {}
12413   var d = n.shrn(s);
12414
12415   var rn1 = n1.toRed(red);
12416
12417   for (; k > 0; k--) {
12418     var a = this._randrange(new bn(2), n1);
12419
12420     var g = n.gcd(a);
12421     if (g.cmpn(1) !== 0)
12422       return g;
12423
12424     var x = a.toRed(red).redPow(d);
12425     if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
12426       continue;
12427
12428     for (var i = 1; i < s; i++) {
12429       x = x.redSqr();
12430
12431       if (x.cmp(rone) === 0)
12432         return x.fromRed().subn(1).gcd(n);
12433       if (x.cmp(rn1) === 0)
12434         break;
12435     }
12436
12437     if (i === s) {
12438       x = x.redSqr();
12439       return x.fromRed().subn(1).gcd(n);
12440     }
12441   }
12442
12443   return false;
12444 };
12445
12446
12447 /***/ }),
12448 /* 115 */
12449 /***/ (function(module, exports, __webpack_require__) {
12450
12451 var r;
12452
12453 module.exports = function rand(len) {
12454   if (!r)
12455     r = new Rand(null);
12456
12457   return r.generate(len);
12458 };
12459
12460 function Rand(rand) {
12461   this.rand = rand;
12462 }
12463 module.exports.Rand = Rand;
12464
12465 Rand.prototype.generate = function generate(len) {
12466   return this._rand(len);
12467 };
12468
12469 // Emulate crypto API using randy
12470 Rand.prototype._rand = function _rand(n) {
12471   if (this.rand.getBytes)
12472     return this.rand.getBytes(n);
12473
12474   var res = new Uint8Array(n);
12475   for (var i = 0; i < res.length; i++)
12476     res[i] = this.rand.getByte();
12477   return res;
12478 };
12479
12480 if (typeof self === 'object') {
12481   if (self.crypto && self.crypto.getRandomValues) {
12482     // Modern browsers
12483     Rand.prototype._rand = function _rand(n) {
12484       var arr = new Uint8Array(n);
12485       self.crypto.getRandomValues(arr);
12486       return arr;
12487     };
12488   } else if (self.msCrypto && self.msCrypto.getRandomValues) {
12489     // IE
12490     Rand.prototype._rand = function _rand(n) {
12491       var arr = new Uint8Array(n);
12492       self.msCrypto.getRandomValues(arr);
12493       return arr;
12494     };
12495
12496   // Safari's WebWorkers do not have `crypto`
12497   } else if (typeof window === 'object') {
12498     // Old junk
12499     Rand.prototype._rand = function() {
12500       throw new Error('Not implemented yet');
12501     };
12502   }
12503 } else {
12504   // Node.js or Web worker with no crypto support
12505   try {
12506     var crypto = __webpack_require__(218);
12507     if (typeof crypto.randomBytes !== 'function')
12508       throw new Error('Not supported');
12509
12510     Rand.prototype._rand = function _rand(n) {
12511       return crypto.randomBytes(n);
12512     };
12513   } catch (e) {
12514   }
12515 }
12516
12517
12518 /***/ }),
12519 /* 116 */
12520 /***/ (function(module, exports, __webpack_require__) {
12521
12522 "use strict";
12523
12524
12525 var utils = exports;
12526
12527 function toArray(msg, enc) {
12528   if (Array.isArray(msg))
12529     return msg.slice();
12530   if (!msg)
12531     return [];
12532   var res = [];
12533   if (typeof msg !== 'string') {
12534     for (var i = 0; i < msg.length; i++)
12535       res[i] = msg[i] | 0;
12536     return res;
12537   }
12538   if (enc === 'hex') {
12539     msg = msg.replace(/[^a-z0-9]+/ig, '');
12540     if (msg.length % 2 !== 0)
12541       msg = '0' + msg;
12542     for (var i = 0; i < msg.length; i += 2)
12543       res.push(parseInt(msg[i] + msg[i + 1], 16));
12544   } else {
12545     for (var i = 0; i < msg.length; i++) {
12546       var c = msg.charCodeAt(i);
12547       var hi = c >> 8;
12548       var lo = c & 0xff;
12549       if (hi)
12550         res.push(hi, lo);
12551       else
12552         res.push(lo);
12553     }
12554   }
12555   return res;
12556 }
12557 utils.toArray = toArray;
12558
12559 function zero2(word) {
12560   if (word.length === 1)
12561     return '0' + word;
12562   else
12563     return word;
12564 }
12565 utils.zero2 = zero2;
12566
12567 function toHex(msg) {
12568   var res = '';
12569   for (var i = 0; i < msg.length; i++)
12570     res += zero2(msg[i].toString(16));
12571   return res;
12572 }
12573 utils.toHex = toHex;
12574
12575 utils.encode = function encode(arr, enc) {
12576   if (enc === 'hex')
12577     return toHex(arr);
12578   else
12579     return arr;
12580 };
12581
12582
12583 /***/ }),
12584 /* 117 */
12585 /***/ (function(module, exports, __webpack_require__) {
12586
12587 "use strict";
12588
12589
12590 var utils = __webpack_require__(11);
12591 var rotr32 = utils.rotr32;
12592
12593 function ft_1(s, x, y, z) {
12594   if (s === 0)
12595     return ch32(x, y, z);
12596   if (s === 1 || s === 3)
12597     return p32(x, y, z);
12598   if (s === 2)
12599     return maj32(x, y, z);
12600 }
12601 exports.ft_1 = ft_1;
12602
12603 function ch32(x, y, z) {
12604   return (x & y) ^ ((~x) & z);
12605 }
12606 exports.ch32 = ch32;
12607
12608 function maj32(x, y, z) {
12609   return (x & y) ^ (x & z) ^ (y & z);
12610 }
12611 exports.maj32 = maj32;
12612
12613 function p32(x, y, z) {
12614   return x ^ y ^ z;
12615 }
12616 exports.p32 = p32;
12617
12618 function s0_256(x) {
12619   return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
12620 }
12621 exports.s0_256 = s0_256;
12622
12623 function s1_256(x) {
12624   return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
12625 }
12626 exports.s1_256 = s1_256;
12627
12628 function g0_256(x) {
12629   return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
12630 }
12631 exports.g0_256 = g0_256;
12632
12633 function g1_256(x) {
12634   return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
12635 }
12636 exports.g1_256 = g1_256;
12637
12638
12639 /***/ }),
12640 /* 118 */
12641 /***/ (function(module, exports, __webpack_require__) {
12642
12643 "use strict";
12644
12645
12646 var utils = __webpack_require__(11);
12647 var common = __webpack_require__(32);
12648 var shaCommon = __webpack_require__(117);
12649 var assert = __webpack_require__(9);
12650
12651 var sum32 = utils.sum32;
12652 var sum32_4 = utils.sum32_4;
12653 var sum32_5 = utils.sum32_5;
12654 var ch32 = shaCommon.ch32;
12655 var maj32 = shaCommon.maj32;
12656 var s0_256 = shaCommon.s0_256;
12657 var s1_256 = shaCommon.s1_256;
12658 var g0_256 = shaCommon.g0_256;
12659 var g1_256 = shaCommon.g1_256;
12660
12661 var BlockHash = common.BlockHash;
12662
12663 var sha256_K = [
12664   0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
12665   0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
12666   0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
12667   0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
12668   0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
12669   0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
12670   0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
12671   0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
12672   0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
12673   0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
12674   0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
12675   0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
12676   0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
12677   0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
12678   0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
12679   0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
12680 ];
12681
12682 function SHA256() {
12683   if (!(this instanceof SHA256))
12684     return new SHA256();
12685
12686   BlockHash.call(this);
12687   this.h = [
12688     0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
12689     0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
12690   ];
12691   this.k = sha256_K;
12692   this.W = new Array(64);
12693 }
12694 utils.inherits(SHA256, BlockHash);
12695 module.exports = SHA256;
12696
12697 SHA256.blockSize = 512;
12698 SHA256.outSize = 256;
12699 SHA256.hmacStrength = 192;
12700 SHA256.padLength = 64;
12701
12702 SHA256.prototype._update = function _update(msg, start) {
12703   var W = this.W;
12704
12705   for (var i = 0; i < 16; i++)
12706     W[i] = msg[start + i];
12707   for (; i < W.length; i++)
12708     W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
12709
12710   var a = this.h[0];
12711   var b = this.h[1];
12712   var c = this.h[2];
12713   var d = this.h[3];
12714   var e = this.h[4];
12715   var f = this.h[5];
12716   var g = this.h[6];
12717   var h = this.h[7];
12718
12719   assert(this.k.length === W.length);
12720   for (i = 0; i < W.length; i++) {
12721     var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
12722     var T2 = sum32(s0_256(a), maj32(a, b, c));
12723     h = g;
12724     g = f;
12725     f = e;
12726     e = sum32(d, T1);
12727     d = c;
12728     c = b;
12729     b = a;
12730     a = sum32(T1, T2);
12731   }
12732
12733   this.h[0] = sum32(this.h[0], a);
12734   this.h[1] = sum32(this.h[1], b);
12735   this.h[2] = sum32(this.h[2], c);
12736   this.h[3] = sum32(this.h[3], d);
12737   this.h[4] = sum32(this.h[4], e);
12738   this.h[5] = sum32(this.h[5], f);
12739   this.h[6] = sum32(this.h[6], g);
12740   this.h[7] = sum32(this.h[7], h);
12741 };
12742
12743 SHA256.prototype._digest = function digest(enc) {
12744   if (enc === 'hex')
12745     return utils.toHex32(this.h, 'big');
12746   else
12747     return utils.split32(this.h, 'big');
12748 };
12749
12750
12751 /***/ }),
12752 /* 119 */
12753 /***/ (function(module, exports, __webpack_require__) {
12754
12755 "use strict";
12756
12757
12758 var utils = __webpack_require__(11);
12759 var common = __webpack_require__(32);
12760 var assert = __webpack_require__(9);
12761
12762 var rotr64_hi = utils.rotr64_hi;
12763 var rotr64_lo = utils.rotr64_lo;
12764 var shr64_hi = utils.shr64_hi;
12765 var shr64_lo = utils.shr64_lo;
12766 var sum64 = utils.sum64;
12767 var sum64_hi = utils.sum64_hi;
12768 var sum64_lo = utils.sum64_lo;
12769 var sum64_4_hi = utils.sum64_4_hi;
12770 var sum64_4_lo = utils.sum64_4_lo;
12771 var sum64_5_hi = utils.sum64_5_hi;
12772 var sum64_5_lo = utils.sum64_5_lo;
12773
12774 var BlockHash = common.BlockHash;
12775
12776 var sha512_K = [
12777   0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
12778   0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
12779   0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
12780   0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
12781   0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
12782   0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
12783   0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
12784   0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
12785   0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
12786   0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
12787   0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
12788   0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
12789   0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
12790   0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
12791   0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
12792   0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
12793   0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
12794   0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
12795   0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
12796   0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
12797   0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
12798   0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
12799   0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
12800   0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
12801   0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
12802   0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
12803   0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
12804   0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
12805   0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
12806   0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
12807   0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
12808   0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
12809   0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
12810   0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
12811   0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
12812   0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
12813   0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
12814   0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
12815   0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
12816   0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
12817 ];
12818
12819 function SHA512() {
12820   if (!(this instanceof SHA512))
12821     return new SHA512();
12822
12823   BlockHash.call(this);
12824   this.h = [
12825     0x6a09e667, 0xf3bcc908,
12826     0xbb67ae85, 0x84caa73b,
12827     0x3c6ef372, 0xfe94f82b,
12828     0xa54ff53a, 0x5f1d36f1,
12829     0x510e527f, 0xade682d1,
12830     0x9b05688c, 0x2b3e6c1f,
12831     0x1f83d9ab, 0xfb41bd6b,
12832     0x5be0cd19, 0x137e2179 ];
12833   this.k = sha512_K;
12834   this.W = new Array(160);
12835 }
12836 utils.inherits(SHA512, BlockHash);
12837 module.exports = SHA512;
12838
12839 SHA512.blockSize = 1024;
12840 SHA512.outSize = 512;
12841 SHA512.hmacStrength = 192;
12842 SHA512.padLength = 128;
12843
12844 SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
12845   var W = this.W;
12846
12847   // 32 x 32bit words
12848   for (var i = 0; i < 32; i++)
12849     W[i] = msg[start + i];
12850   for (; i < W.length; i += 2) {
12851     var c0_hi = g1_512_hi(W[i - 4], W[i - 3]);  // i - 2
12852     var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
12853     var c1_hi = W[i - 14];  // i - 7
12854     var c1_lo = W[i - 13];
12855     var c2_hi = g0_512_hi(W[i - 30], W[i - 29]);  // i - 15
12856     var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
12857     var c3_hi = W[i - 32];  // i - 16
12858     var c3_lo = W[i - 31];
12859
12860     W[i] = sum64_4_hi(
12861       c0_hi, c0_lo,
12862       c1_hi, c1_lo,
12863       c2_hi, c2_lo,
12864       c3_hi, c3_lo);
12865     W[i + 1] = sum64_4_lo(
12866       c0_hi, c0_lo,
12867       c1_hi, c1_lo,
12868       c2_hi, c2_lo,
12869       c3_hi, c3_lo);
12870   }
12871 };
12872
12873 SHA512.prototype._update = function _update(msg, start) {
12874   this._prepareBlock(msg, start);
12875
12876   var W = this.W;
12877
12878   var ah = this.h[0];
12879   var al = this.h[1];
12880   var bh = this.h[2];
12881   var bl = this.h[3];
12882   var ch = this.h[4];
12883   var cl = this.h[5];
12884   var dh = this.h[6];
12885   var dl = this.h[7];
12886   var eh = this.h[8];
12887   var el = this.h[9];
12888   var fh = this.h[10];
12889   var fl = this.h[11];
12890   var gh = this.h[12];
12891   var gl = this.h[13];
12892   var hh = this.h[14];
12893   var hl = this.h[15];
12894
12895   assert(this.k.length === W.length);
12896   for (var i = 0; i < W.length; i += 2) {
12897     var c0_hi = hh;
12898     var c0_lo = hl;
12899     var c1_hi = s1_512_hi(eh, el);
12900     var c1_lo = s1_512_lo(eh, el);
12901     var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
12902     var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
12903     var c3_hi = this.k[i];
12904     var c3_lo = this.k[i + 1];
12905     var c4_hi = W[i];
12906     var c4_lo = W[i + 1];
12907
12908     var T1_hi = sum64_5_hi(
12909       c0_hi, c0_lo,
12910       c1_hi, c1_lo,
12911       c2_hi, c2_lo,
12912       c3_hi, c3_lo,
12913       c4_hi, c4_lo);
12914     var T1_lo = sum64_5_lo(
12915       c0_hi, c0_lo,
12916       c1_hi, c1_lo,
12917       c2_hi, c2_lo,
12918       c3_hi, c3_lo,
12919       c4_hi, c4_lo);
12920
12921     c0_hi = s0_512_hi(ah, al);
12922     c0_lo = s0_512_lo(ah, al);
12923     c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
12924     c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
12925
12926     var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
12927     var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
12928
12929     hh = gh;
12930     hl = gl;
12931
12932     gh = fh;
12933     gl = fl;
12934
12935     fh = eh;
12936     fl = el;
12937
12938     eh = sum64_hi(dh, dl, T1_hi, T1_lo);
12939     el = sum64_lo(dl, dl, T1_hi, T1_lo);
12940
12941     dh = ch;
12942     dl = cl;
12943
12944     ch = bh;
12945     cl = bl;
12946
12947     bh = ah;
12948     bl = al;
12949
12950     ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
12951     al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
12952   }
12953
12954   sum64(this.h, 0, ah, al);
12955   sum64(this.h, 2, bh, bl);
12956   sum64(this.h, 4, ch, cl);
12957   sum64(this.h, 6, dh, dl);
12958   sum64(this.h, 8, eh, el);
12959   sum64(this.h, 10, fh, fl);
12960   sum64(this.h, 12, gh, gl);
12961   sum64(this.h, 14, hh, hl);
12962 };
12963
12964 SHA512.prototype._digest = function digest(enc) {
12965   if (enc === 'hex')
12966     return utils.toHex32(this.h, 'big');
12967   else
12968     return utils.split32(this.h, 'big');
12969 };
12970
12971 function ch64_hi(xh, xl, yh, yl, zh) {
12972   var r = (xh & yh) ^ ((~xh) & zh);
12973   if (r < 0)
12974     r += 0x100000000;
12975   return r;
12976 }
12977
12978 function ch64_lo(xh, xl, yh, yl, zh, zl) {
12979   var r = (xl & yl) ^ ((~xl) & zl);
12980   if (r < 0)
12981     r += 0x100000000;
12982   return r;
12983 }
12984
12985 function maj64_hi(xh, xl, yh, yl, zh) {
12986   var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
12987   if (r < 0)
12988     r += 0x100000000;
12989   return r;
12990 }
12991
12992 function maj64_lo(xh, xl, yh, yl, zh, zl) {
12993   var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
12994   if (r < 0)
12995     r += 0x100000000;
12996   return r;
12997 }
12998
12999 function s0_512_hi(xh, xl) {
13000   var c0_hi = rotr64_hi(xh, xl, 28);
13001   var c1_hi = rotr64_hi(xl, xh, 2);  // 34
13002   var c2_hi = rotr64_hi(xl, xh, 7);  // 39
13003
13004   var r = c0_hi ^ c1_hi ^ c2_hi;
13005   if (r < 0)
13006     r += 0x100000000;
13007   return r;
13008 }
13009
13010 function s0_512_lo(xh, xl) {
13011   var c0_lo = rotr64_lo(xh, xl, 28);
13012   var c1_lo = rotr64_lo(xl, xh, 2);  // 34
13013   var c2_lo = rotr64_lo(xl, xh, 7);  // 39
13014
13015   var r = c0_lo ^ c1_lo ^ c2_lo;
13016   if (r < 0)
13017     r += 0x100000000;
13018   return r;
13019 }
13020
13021 function s1_512_hi(xh, xl) {
13022   var c0_hi = rotr64_hi(xh, xl, 14);
13023   var c1_hi = rotr64_hi(xh, xl, 18);
13024   var c2_hi = rotr64_hi(xl, xh, 9);  // 41
13025
13026   var r = c0_hi ^ c1_hi ^ c2_hi;
13027   if (r < 0)
13028     r += 0x100000000;
13029   return r;
13030 }
13031
13032 function s1_512_lo(xh, xl) {
13033   var c0_lo = rotr64_lo(xh, xl, 14);
13034   var c1_lo = rotr64_lo(xh, xl, 18);
13035   var c2_lo = rotr64_lo(xl, xh, 9);  // 41
13036
13037   var r = c0_lo ^ c1_lo ^ c2_lo;
13038   if (r < 0)
13039     r += 0x100000000;
13040   return r;
13041 }
13042
13043 function g0_512_hi(xh, xl) {
13044   var c0_hi = rotr64_hi(xh, xl, 1);
13045   var c1_hi = rotr64_hi(xh, xl, 8);
13046   var c2_hi = shr64_hi(xh, xl, 7);
13047
13048   var r = c0_hi ^ c1_hi ^ c2_hi;
13049   if (r < 0)
13050     r += 0x100000000;
13051   return r;
13052 }
13053
13054 function g0_512_lo(xh, xl) {
13055   var c0_lo = rotr64_lo(xh, xl, 1);
13056   var c1_lo = rotr64_lo(xh, xl, 8);
13057   var c2_lo = shr64_lo(xh, xl, 7);
13058
13059   var r = c0_lo ^ c1_lo ^ c2_lo;
13060   if (r < 0)
13061     r += 0x100000000;
13062   return r;
13063 }
13064
13065 function g1_512_hi(xh, xl) {
13066   var c0_hi = rotr64_hi(xh, xl, 19);
13067   var c1_hi = rotr64_hi(xl, xh, 29);  // 61
13068   var c2_hi = shr64_hi(xh, xl, 6);
13069
13070   var r = c0_hi ^ c1_hi ^ c2_hi;
13071   if (r < 0)
13072     r += 0x100000000;
13073   return r;
13074 }
13075
13076 function g1_512_lo(xh, xl) {
13077   var c0_lo = rotr64_lo(xh, xl, 19);
13078   var c1_lo = rotr64_lo(xl, xh, 29);  // 61
13079   var c2_lo = shr64_lo(xh, xl, 6);
13080
13081   var r = c0_lo ^ c1_lo ^ c2_lo;
13082   if (r < 0)
13083     r += 0x100000000;
13084   return r;
13085 }
13086
13087
13088 /***/ }),
13089 /* 120 */
13090 /***/ (function(module, exports, __webpack_require__) {
13091
13092 var inherits = __webpack_require__(1);
13093 var Reporter = __webpack_require__(34).Reporter;
13094 var Buffer = __webpack_require__(3).Buffer;
13095
13096 function DecoderBuffer(base, options) {
13097   Reporter.call(this, options);
13098   if (!Buffer.isBuffer(base)) {
13099     this.error('Input not Buffer');
13100     return;
13101   }
13102
13103   this.base = base;
13104   this.offset = 0;
13105   this.length = base.length;
13106 }
13107 inherits(DecoderBuffer, Reporter);
13108 exports.DecoderBuffer = DecoderBuffer;
13109
13110 DecoderBuffer.prototype.save = function save() {
13111   return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
13112 };
13113
13114 DecoderBuffer.prototype.restore = function restore(save) {
13115   // Return skipped data
13116   var res = new DecoderBuffer(this.base);
13117   res.offset = save.offset;
13118   res.length = this.offset;
13119
13120   this.offset = save.offset;
13121   Reporter.prototype.restore.call(this, save.reporter);
13122
13123   return res;
13124 };
13125
13126 DecoderBuffer.prototype.isEmpty = function isEmpty() {
13127   return this.offset === this.length;
13128 };
13129
13130 DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
13131   if (this.offset + 1 <= this.length)
13132     return this.base.readUInt8(this.offset++, true);
13133   else
13134     return this.error(fail || 'DecoderBuffer overrun');
13135 }
13136
13137 DecoderBuffer.prototype.skip = function skip(bytes, fail) {
13138   if (!(this.offset + bytes <= this.length))
13139     return this.error(fail || 'DecoderBuffer overrun');
13140
13141   var res = new DecoderBuffer(this.base);
13142
13143   // Share reporter state
13144   res._reporterState = this._reporterState;
13145
13146   res.offset = this.offset;
13147   res.length = this.offset + bytes;
13148   this.offset += bytes;
13149   return res;
13150 }
13151
13152 DecoderBuffer.prototype.raw = function raw(save) {
13153   return this.base.slice(save ? save.offset : this.offset, this.length);
13154 }
13155
13156 function EncoderBuffer(value, reporter) {
13157   if (Array.isArray(value)) {
13158     this.length = 0;
13159     this.value = value.map(function(item) {
13160       if (!(item instanceof EncoderBuffer))
13161         item = new EncoderBuffer(item, reporter);
13162       this.length += item.length;
13163       return item;
13164     }, this);
13165   } else if (typeof value === 'number') {
13166     if (!(0 <= value && value <= 0xff))
13167       return reporter.error('non-byte EncoderBuffer value');
13168     this.value = value;
13169     this.length = 1;
13170   } else if (typeof value === 'string') {
13171     this.value = value;
13172     this.length = Buffer.byteLength(value);
13173   } else if (Buffer.isBuffer(value)) {
13174     this.value = value;
13175     this.length = value.length;
13176   } else {
13177     return reporter.error('Unsupported type: ' + typeof value);
13178   }
13179 }
13180 exports.EncoderBuffer = EncoderBuffer;
13181
13182 EncoderBuffer.prototype.join = function join(out, offset) {
13183   if (!out)
13184     out = new Buffer(this.length);
13185   if (!offset)
13186     offset = 0;
13187
13188   if (this.length === 0)
13189     return out;
13190
13191   if (Array.isArray(this.value)) {
13192     this.value.forEach(function(item) {
13193       item.join(out, offset);
13194       offset += item.length;
13195     });
13196   } else {
13197     if (typeof this.value === 'number')
13198       out[offset] = this.value;
13199     else if (typeof this.value === 'string')
13200       out.write(this.value, offset);
13201     else if (Buffer.isBuffer(this.value))
13202       this.value.copy(out, offset);
13203     offset += this.length;
13204   }
13205
13206   return out;
13207 };
13208
13209
13210 /***/ }),
13211 /* 121 */
13212 /***/ (function(module, exports, __webpack_require__) {
13213
13214 var constants = exports;
13215
13216 // Helper
13217 constants._reverse = function reverse(map) {
13218   var res = {};
13219
13220   Object.keys(map).forEach(function(key) {
13221     // Convert key to integer if it is stringified
13222     if ((key | 0) == key)
13223       key = key | 0;
13224
13225     var value = map[key];
13226     res[value] = key;
13227   });
13228
13229   return res;
13230 };
13231
13232 constants.der = __webpack_require__(250);
13233
13234
13235 /***/ }),
13236 /* 122 */
13237 /***/ (function(module, exports, __webpack_require__) {
13238
13239 var inherits = __webpack_require__(1);
13240
13241 var asn1 = __webpack_require__(33);
13242 var base = asn1.base;
13243 var bignum = asn1.bignum;
13244
13245 // Import DER constants
13246 var der = asn1.constants.der;
13247
13248 function DERDecoder(entity) {
13249   this.enc = 'der';
13250   this.name = entity.name;
13251   this.entity = entity;
13252
13253   // Construct base tree
13254   this.tree = new DERNode();
13255   this.tree._init(entity.body);
13256 };
13257 module.exports = DERDecoder;
13258
13259 DERDecoder.prototype.decode = function decode(data, options) {
13260   if (!(data instanceof base.DecoderBuffer))
13261     data = new base.DecoderBuffer(data, options);
13262
13263   return this.tree._decode(data, options);
13264 };
13265
13266 // Tree methods
13267
13268 function DERNode(parent) {
13269   base.Node.call(this, 'der', parent);
13270 }
13271 inherits(DERNode, base.Node);
13272
13273 DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
13274   if (buffer.isEmpty())
13275     return false;
13276
13277   var state = buffer.save();
13278   var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
13279   if (buffer.isError(decodedTag))
13280     return decodedTag;
13281
13282   buffer.restore(state);
13283
13284   return decodedTag.tag === tag || decodedTag.tagStr === tag ||
13285     (decodedTag.tagStr + 'of') === tag || any;
13286 };
13287
13288 DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
13289   var decodedTag = derDecodeTag(buffer,
13290                                 'Failed to decode tag of "' + tag + '"');
13291   if (buffer.isError(decodedTag))
13292     return decodedTag;
13293
13294   var len = derDecodeLen(buffer,
13295                          decodedTag.primitive,
13296                          'Failed to get length of "' + tag + '"');
13297
13298   // Failure
13299   if (buffer.isError(len))
13300     return len;
13301
13302   if (!any &&
13303       decodedTag.tag !== tag &&
13304       decodedTag.tagStr !== tag &&
13305       decodedTag.tagStr + 'of' !== tag) {
13306     return buffer.error('Failed to match tag: "' + tag + '"');
13307   }
13308
13309   if (decodedTag.primitive || len !== null)
13310     return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
13311
13312   // Indefinite length... find END tag
13313   var state = buffer.save();
13314   var res = this._skipUntilEnd(
13315       buffer,
13316       'Failed to skip indefinite length body: "' + this.tag + '"');
13317   if (buffer.isError(res))
13318     return res;
13319
13320   len = buffer.offset - state.offset;
13321   buffer.restore(state);
13322   return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
13323 };
13324
13325 DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
13326   while (true) {
13327     var tag = derDecodeTag(buffer, fail);
13328     if (buffer.isError(tag))
13329       return tag;
13330     var len = derDecodeLen(buffer, tag.primitive, fail);
13331     if (buffer.isError(len))
13332       return len;
13333
13334     var res;
13335     if (tag.primitive || len !== null)
13336       res = buffer.skip(len)
13337     else
13338       res = this._skipUntilEnd(buffer, fail);
13339
13340     // Failure
13341     if (buffer.isError(res))
13342       return res;
13343
13344     if (tag.tagStr === 'end')
13345       break;
13346   }
13347 };
13348
13349 DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
13350                                                     options) {
13351   var result = [];
13352   while (!buffer.isEmpty()) {
13353     var possibleEnd = this._peekTag(buffer, 'end');
13354     if (buffer.isError(possibleEnd))
13355       return possibleEnd;
13356
13357     var res = decoder.decode(buffer, 'der', options);
13358     if (buffer.isError(res) && possibleEnd)
13359       break;
13360     result.push(res);
13361   }
13362   return result;
13363 };
13364
13365 DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
13366   if (tag === 'bitstr') {
13367     var unused = buffer.readUInt8();
13368     if (buffer.isError(unused))
13369       return unused;
13370     return { unused: unused, data: buffer.raw() };
13371   } else if (tag === 'bmpstr') {
13372     var raw = buffer.raw();
13373     if (raw.length % 2 === 1)
13374       return buffer.error('Decoding of string type: bmpstr length mismatch');
13375
13376     var str = '';
13377     for (var i = 0; i < raw.length / 2; i++) {
13378       str += String.fromCharCode(raw.readUInt16BE(i * 2));
13379     }
13380     return str;
13381   } else if (tag === 'numstr') {
13382     var numstr = buffer.raw().toString('ascii');
13383     if (!this._isNumstr(numstr)) {
13384       return buffer.error('Decoding of string type: ' +
13385                           'numstr unsupported characters');
13386     }
13387     return numstr;
13388   } else if (tag === 'octstr') {
13389     return buffer.raw();
13390   } else if (tag === 'objDesc') {
13391     return buffer.raw();
13392   } else if (tag === 'printstr') {
13393     var printstr = buffer.raw().toString('ascii');
13394     if (!this._isPrintstr(printstr)) {
13395       return buffer.error('Decoding of string type: ' +
13396                           'printstr unsupported characters');
13397     }
13398     return printstr;
13399   } else if (/str$/.test(tag)) {
13400     return buffer.raw().toString();
13401   } else {
13402     return buffer.error('Decoding of string type: ' + tag + ' unsupported');
13403   }
13404 };
13405
13406 DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
13407   var result;
13408   var identifiers = [];
13409   var ident = 0;
13410   while (!buffer.isEmpty()) {
13411     var subident = buffer.readUInt8();
13412     ident <<= 7;
13413     ident |= subident & 0x7f;
13414     if ((subident & 0x80) === 0) {
13415       identifiers.push(ident);
13416       ident = 0;
13417     }
13418   }
13419   if (subident & 0x80)
13420     identifiers.push(ident);
13421
13422   var first = (identifiers[0] / 40) | 0;
13423   var second = identifiers[0] % 40;
13424
13425   if (relative)
13426     result = identifiers;
13427   else
13428     result = [first, second].concat(identifiers.slice(1));
13429
13430   if (values) {
13431     var tmp = values[result.join(' ')];
13432     if (tmp === undefined)
13433       tmp = values[result.join('.')];
13434     if (tmp !== undefined)
13435       result = tmp;
13436   }
13437
13438   return result;
13439 };
13440
13441 DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
13442   var str = buffer.raw().toString();
13443   if (tag === 'gentime') {
13444     var year = str.slice(0, 4) | 0;
13445     var mon = str.slice(4, 6) | 0;
13446     var day = str.slice(6, 8) | 0;
13447     var hour = str.slice(8, 10) | 0;
13448     var min = str.slice(10, 12) | 0;
13449     var sec = str.slice(12, 14) | 0;
13450   } else if (tag === 'utctime') {
13451     var year = str.slice(0, 2) | 0;
13452     var mon = str.slice(2, 4) | 0;
13453     var day = str.slice(4, 6) | 0;
13454     var hour = str.slice(6, 8) | 0;
13455     var min = str.slice(8, 10) | 0;
13456     var sec = str.slice(10, 12) | 0;
13457     if (year < 70)
13458       year = 2000 + year;
13459     else
13460       year = 1900 + year;
13461   } else {
13462     return buffer.error('Decoding ' + tag + ' time is not supported yet');
13463   }
13464
13465   return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
13466 };
13467
13468 DERNode.prototype._decodeNull = function decodeNull(buffer) {
13469   return null;
13470 };
13471
13472 DERNode.prototype._decodeBool = function decodeBool(buffer) {
13473   var res = buffer.readUInt8();
13474   if (buffer.isError(res))
13475     return res;
13476   else
13477     return res !== 0;
13478 };
13479
13480 DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
13481   // Bigint, return as it is (assume big endian)
13482   var raw = buffer.raw();
13483   var res = new bignum(raw);
13484
13485   if (values)
13486     res = values[res.toString(10)] || res;
13487
13488   return res;
13489 };
13490
13491 DERNode.prototype._use = function use(entity, obj) {
13492   if (typeof entity === 'function')
13493     entity = entity(obj);
13494   return entity._getDecoder('der').tree;
13495 };
13496
13497 // Utility methods
13498
13499 function derDecodeTag(buf, fail) {
13500   var tag = buf.readUInt8(fail);
13501   if (buf.isError(tag))
13502     return tag;
13503
13504   var cls = der.tagClass[tag >> 6];
13505   var primitive = (tag & 0x20) === 0;
13506
13507   // Multi-octet tag - load
13508   if ((tag & 0x1f) === 0x1f) {
13509     var oct = tag;
13510     tag = 0;
13511     while ((oct & 0x80) === 0x80) {
13512       oct = buf.readUInt8(fail);
13513       if (buf.isError(oct))
13514         return oct;
13515
13516       tag <<= 7;
13517       tag |= oct & 0x7f;
13518     }
13519   } else {
13520     tag &= 0x1f;
13521   }
13522   var tagStr = der.tag[tag];
13523
13524   return {
13525     cls: cls,
13526     primitive: primitive,
13527     tag: tag,
13528     tagStr: tagStr
13529   };
13530 }
13531
13532 function derDecodeLen(buf, primitive, fail) {
13533   var len = buf.readUInt8(fail);
13534   if (buf.isError(len))
13535     return len;
13536
13537   // Indefinite form
13538   if (!primitive && len === 0x80)
13539     return null;
13540
13541   // Definite form
13542   if ((len & 0x80) === 0) {
13543     // Short form
13544     return len;
13545   }
13546
13547   // Long form
13548   var num = len & 0x7f;
13549   if (num > 4)
13550     return buf.error('length octect is too long');
13551
13552   len = 0;
13553   for (var i = 0; i < num; i++) {
13554     len <<= 8;
13555     var j = buf.readUInt8(fail);
13556     if (buf.isError(j))
13557       return j;
13558     len |= j;
13559   }
13560
13561   return len;
13562 }
13563
13564
13565 /***/ }),
13566 /* 123 */
13567 /***/ (function(module, exports, __webpack_require__) {
13568
13569 var inherits = __webpack_require__(1);
13570 var Buffer = __webpack_require__(3).Buffer;
13571
13572 var asn1 = __webpack_require__(33);
13573 var base = asn1.base;
13574
13575 // Import DER constants
13576 var der = asn1.constants.der;
13577
13578 function DEREncoder(entity) {
13579   this.enc = 'der';
13580   this.name = entity.name;
13581   this.entity = entity;
13582
13583   // Construct base tree
13584   this.tree = new DERNode();
13585   this.tree._init(entity.body);
13586 };
13587 module.exports = DEREncoder;
13588
13589 DEREncoder.prototype.encode = function encode(data, reporter) {
13590   return this.tree._encode(data, reporter).join();
13591 };
13592
13593 // Tree methods
13594
13595 function DERNode(parent) {
13596   base.Node.call(this, 'der', parent);
13597 }
13598 inherits(DERNode, base.Node);
13599
13600 DERNode.prototype._encodeComposite = function encodeComposite(tag,
13601                                                               primitive,
13602                                                               cls,
13603                                                               content) {
13604   var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
13605
13606   // Short form
13607   if (content.length < 0x80) {
13608     var header = new Buffer(2);
13609     header[0] = encodedTag;
13610     header[1] = content.length;
13611     return this._createEncoderBuffer([ header, content ]);
13612   }
13613
13614   // Long form
13615   // Count octets required to store length
13616   var lenOctets = 1;
13617   for (var i = content.length; i >= 0x100; i >>= 8)
13618     lenOctets++;
13619
13620   var header = new Buffer(1 + 1 + lenOctets);
13621   header[0] = encodedTag;
13622   header[1] = 0x80 | lenOctets;
13623
13624   for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
13625     header[i] = j & 0xff;
13626
13627   return this._createEncoderBuffer([ header, content ]);
13628 };
13629
13630 DERNode.prototype._encodeStr = function encodeStr(str, tag) {
13631   if (tag === 'bitstr') {
13632     return this._createEncoderBuffer([ str.unused | 0, str.data ]);
13633   } else if (tag === 'bmpstr') {
13634     var buf = new Buffer(str.length * 2);
13635     for (var i = 0; i < str.length; i++) {
13636       buf.writeUInt16BE(str.charCodeAt(i), i * 2);
13637     }
13638     return this._createEncoderBuffer(buf);
13639   } else if (tag === 'numstr') {
13640     if (!this._isNumstr(str)) {
13641       return this.reporter.error('Encoding of string type: numstr supports ' +
13642                                  'only digits and space');
13643     }
13644     return this._createEncoderBuffer(str);
13645   } else if (tag === 'printstr') {
13646     if (!this._isPrintstr(str)) {
13647       return this.reporter.error('Encoding of string type: printstr supports ' +
13648                                  'only latin upper and lower case letters, ' +
13649                                  'digits, space, apostrophe, left and rigth ' +
13650                                  'parenthesis, plus sign, comma, hyphen, ' +
13651                                  'dot, slash, colon, equal sign, ' +
13652                                  'question mark');
13653     }
13654     return this._createEncoderBuffer(str);
13655   } else if (/str$/.test(tag)) {
13656     return this._createEncoderBuffer(str);
13657   } else if (tag === 'objDesc') {
13658     return this._createEncoderBuffer(str);
13659   } else {
13660     return this.reporter.error('Encoding of string type: ' + tag +
13661                                ' unsupported');
13662   }
13663 };
13664
13665 DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
13666   if (typeof id === 'string') {
13667     if (!values)
13668       return this.reporter.error('string objid given, but no values map found');
13669     if (!values.hasOwnProperty(id))
13670       return this.reporter.error('objid not found in values map');
13671     id = values[id].split(/[\s\.]+/g);
13672     for (var i = 0; i < id.length; i++)
13673       id[i] |= 0;
13674   } else if (Array.isArray(id)) {
13675     id = id.slice();
13676     for (var i = 0; i < id.length; i++)
13677       id[i] |= 0;
13678   }
13679
13680   if (!Array.isArray(id)) {
13681     return this.reporter.error('objid() should be either array or string, ' +
13682                                'got: ' + JSON.stringify(id));
13683   }
13684
13685   if (!relative) {
13686     if (id[1] >= 40)
13687       return this.reporter.error('Second objid identifier OOB');
13688     id.splice(0, 2, id[0] * 40 + id[1]);
13689   }
13690
13691   // Count number of octets
13692   var size = 0;
13693   for (var i = 0; i < id.length; i++) {
13694     var ident = id[i];
13695     for (size++; ident >= 0x80; ident >>= 7)
13696       size++;
13697   }
13698
13699   var objid = new Buffer(size);
13700   var offset = objid.length - 1;
13701   for (var i = id.length - 1; i >= 0; i--) {
13702     var ident = id[i];
13703     objid[offset--] = ident & 0x7f;
13704     while ((ident >>= 7) > 0)
13705       objid[offset--] = 0x80 | (ident & 0x7f);
13706   }
13707
13708   return this._createEncoderBuffer(objid);
13709 };
13710
13711 function two(num) {
13712   if (num < 10)
13713     return '0' + num;
13714   else
13715     return num;
13716 }
13717
13718 DERNode.prototype._encodeTime = function encodeTime(time, tag) {
13719   var str;
13720   var date = new Date(time);
13721
13722   if (tag === 'gentime') {
13723     str = [
13724       two(date.getFullYear()),
13725       two(date.getUTCMonth() + 1),
13726       two(date.getUTCDate()),
13727       two(date.getUTCHours()),
13728       two(date.getUTCMinutes()),
13729       two(date.getUTCSeconds()),
13730       'Z'
13731     ].join('');
13732   } else if (tag === 'utctime') {
13733     str = [
13734       two(date.getFullYear() % 100),
13735       two(date.getUTCMonth() + 1),
13736       two(date.getUTCDate()),
13737       two(date.getUTCHours()),
13738       two(date.getUTCMinutes()),
13739       two(date.getUTCSeconds()),
13740       'Z'
13741     ].join('');
13742   } else {
13743     this.reporter.error('Encoding ' + tag + ' time is not supported yet');
13744   }
13745
13746   return this._encodeStr(str, 'octstr');
13747 };
13748
13749 DERNode.prototype._encodeNull = function encodeNull() {
13750   return this._createEncoderBuffer('');
13751 };
13752
13753 DERNode.prototype._encodeInt = function encodeInt(num, values) {
13754   if (typeof num === 'string') {
13755     if (!values)
13756       return this.reporter.error('String int or enum given, but no values map');
13757     if (!values.hasOwnProperty(num)) {
13758       return this.reporter.error('Values map doesn\'t contain: ' +
13759                                  JSON.stringify(num));
13760     }
13761     num = values[num];
13762   }
13763
13764   // Bignum, assume big endian
13765   if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
13766     var numArray = num.toArray();
13767     if (!num.sign && numArray[0] & 0x80) {
13768       numArray.unshift(0);
13769     }
13770     num = new Buffer(numArray);
13771   }
13772
13773   if (Buffer.isBuffer(num)) {
13774     var size = num.length;
13775     if (num.length === 0)
13776       size++;
13777
13778     var out = new Buffer(size);
13779     num.copy(out);
13780     if (num.length === 0)
13781       out[0] = 0
13782     return this._createEncoderBuffer(out);
13783   }
13784
13785   if (num < 0x80)
13786     return this._createEncoderBuffer(num);
13787
13788   if (num < 0x100)
13789     return this._createEncoderBuffer([0, num]);
13790
13791   var size = 1;
13792   for (var i = num; i >= 0x100; i >>= 8)
13793     size++;
13794
13795   var out = new Array(size);
13796   for (var i = out.length - 1; i >= 0; i--) {
13797     out[i] = num & 0xff;
13798     num >>= 8;
13799   }
13800   if(out[0] & 0x80) {
13801     out.unshift(0);
13802   }
13803
13804   return this._createEncoderBuffer(new Buffer(out));
13805 };
13806
13807 DERNode.prototype._encodeBool = function encodeBool(value) {
13808   return this._createEncoderBuffer(value ? 0xff : 0);
13809 };
13810
13811 DERNode.prototype._use = function use(entity, obj) {
13812   if (typeof entity === 'function')
13813     entity = entity(obj);
13814   return entity._getEncoder('der').tree;
13815 };
13816
13817 DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
13818   var state = this._baseState;
13819   var i;
13820   if (state['default'] === null)
13821     return false;
13822
13823   var data = dataBuffer.join();
13824   if (state.defaultBuffer === undefined)
13825     state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
13826
13827   if (data.length !== state.defaultBuffer.length)
13828     return false;
13829
13830   for (i=0; i < data.length; i++)
13831     if (data[i] !== state.defaultBuffer[i])
13832       return false;
13833
13834   return true;
13835 };
13836
13837 // Utility methods
13838
13839 function encodeTag(tag, primitive, cls, reporter) {
13840   var res;
13841
13842   if (tag === 'seqof')
13843     tag = 'seq';
13844   else if (tag === 'setof')
13845     tag = 'set';
13846
13847   if (der.tagByName.hasOwnProperty(tag))
13848     res = der.tagByName[tag];
13849   else if (typeof tag === 'number' && (tag | 0) === tag)
13850     res = tag;
13851   else
13852     return reporter.error('Unknown tag: ' + tag);
13853
13854   if (res >= 0x1f)
13855     return reporter.error('Multi-octet tag encoding unsupported');
13856
13857   if (!primitive)
13858     res |= 0x20;
13859
13860   res |= (der.tagClassByName[cls || 'universal'] << 6);
13861
13862   return res;
13863 }
13864
13865
13866 /***/ }),
13867 /* 124 */
13868 /***/ (function(module, exports) {
13869
13870 module.exports = {"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}
13871
13872 /***/ }),
13873 /* 125 */
13874 /***/ (function(module, exports, __webpack_require__) {
13875
13876 /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(29);
13877 module.exports = function (seed, len) {
13878   var t = new Buffer('');
13879   var  i = 0, c;
13880   while (t.length < len) {
13881     c = i2ops(i++);
13882     t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
13883   }
13884   return t.slice(0, len);
13885 };
13886
13887 function i2ops(c) {
13888   var out = new Buffer(4);
13889   out.writeUInt32BE(c,0);
13890   return out;
13891 }
13892 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
13893
13894 /***/ }),
13895 /* 126 */
13896 /***/ (function(module, exports) {
13897
13898 module.exports = function xor(a, b) {
13899   var len = a.length;
13900   var i = -1;
13901   while (++i < len) {
13902     a[i] ^= b[i];
13903   }
13904   return a
13905 };
13906
13907 /***/ }),
13908 /* 127 */
13909 /***/ (function(module, exports, __webpack_require__) {
13910
13911 /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(4);
13912 function withPublic(paddedMsg, key) {
13913   return new Buffer(paddedMsg
13914     .toRed(bn.mont(key.modulus))
13915     .redPow(new bn(key.publicExponent))
13916     .fromRed()
13917     .toArray());
13918 }
13919
13920 module.exports = withPublic;
13921 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
13922
13923 /***/ }),
13924 /* 128 */
13925 /***/ (function(module, exports) {
13926
13927 module.exports = function(module) {\r
13928         if(!module.webpackPolyfill) {\r
13929                 module.deprecate = function() {};\r
13930                 module.paths = [];\r
13931                 // module.parent = undefined by default\r
13932                 if(!module.children) module.children = [];\r
13933                 Object.defineProperty(module, "loaded", {\r
13934                         enumerable: true,\r
13935                         get: function() {\r
13936                                 return module.l;\r
13937                         }\r
13938                 });\r
13939                 Object.defineProperty(module, "id", {\r
13940                         enumerable: true,\r
13941                         get: function() {\r
13942                                 return module.i;\r
13943                         }\r
13944                 });\r
13945                 module.webpackPolyfill = 1;\r
13946         }\r
13947         return module;\r
13948 };\r
13949
13950
13951 /***/ }),
13952 /* 129 */
13953 /***/ (function(module, __webpack_exports__, __webpack_require__) {
13954
13955 "use strict";
13956 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return ERROR; });
13957 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return PUSH_BYTOM; });
13958 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return UPDATE_BYTOM; });
13959 /* unused harmony export AUTHENTICATE */
13960 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return TRANSFER; });
13961 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ENABLE; });
13962 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ADVTRANSFER; });
13963 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return SIGNTRANSACTION; });
13964 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return SIGNMESSAGE; });
13965 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return SETCHAIN; });
13966 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return SEND; });
13967 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return LOAD; });
13968 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return UPDATE; });
13969 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return REQUEST_CURRENT_ACCOUNT; });
13970 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return REQUEST_CURRENT_NETWORK; });
13971 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return REQUEST_CURRENT_CHAIN_TYPE; });
13972 /* unused harmony export REQUEST_ACCOUNT_LIST */
13973 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return SET_PROMPT; });
13974 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return GET_PROMPT; });
13975 var ERROR = 'error';
13976
13977 var PUSH_BYTOM = 'pushBytom';
13978 var UPDATE_BYTOM = 'updateBytom';
13979 var AUTHENTICATE = 'authenticate';
13980 var TRANSFER = 'transfer';
13981 var ENABLE = 'enable';
13982 var ADVTRANSFER = 'advTransfer';
13983 var SIGNTRANSACTION = 'signTransaction';
13984 var SIGNMESSAGE = 'signMessage';
13985 var SETCHAIN = 'setChain';
13986 var SEND = 'send';
13987 var LOAD = 'load';
13988 var UPDATE = 'update';
13989
13990 var REQUEST_CURRENT_ACCOUNT = 'defaultAccount';
13991 var REQUEST_CURRENT_NETWORK = 'currentNetwork';
13992 var REQUEST_CURRENT_CHAIN_TYPE = 'currentChain';
13993 var REQUEST_ACCOUNT_LIST = 'accountList';
13994
13995 //Internal Message
13996 var SET_PROMPT = 'setPrompt';
13997 var GET_PROMPT = 'getPrompt';
13998
13999 /***/ }),
14000 /* 130 */
14001 /***/ (function(module, exports, __webpack_require__) {
14002
14003 module.exports = !__webpack_require__(17) && !__webpack_require__(22)(function () {
14004   return Object.defineProperty(__webpack_require__(50)('div'), 'a', { get: function () { return 7; } }).a != 7;
14005 });
14006
14007
14008 /***/ }),
14009 /* 131 */
14010 /***/ (function(module, exports, __webpack_require__) {
14011
14012 var has = __webpack_require__(20);
14013 var toIObject = __webpack_require__(25);
14014 var arrayIndexOf = __webpack_require__(150)(false);
14015 var IE_PROTO = __webpack_require__(53)('IE_PROTO');
14016
14017 module.exports = function (object, names) {
14018   var O = toIObject(object);
14019   var i = 0;
14020   var result = [];
14021   var key;
14022   for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
14023   // Don't enum bug & hidden keys
14024   while (names.length > i) if (has(O, key = names[i++])) {
14025     ~arrayIndexOf(result, key) || result.push(key);
14026   }
14027   return result;
14028 };
14029
14030
14031 /***/ }),
14032 /* 132 */
14033 /***/ (function(module, exports, __webpack_require__) {
14034
14035 "use strict";
14036
14037 var $at = __webpack_require__(157)(true);
14038
14039 // 21.1.3.27 String.prototype[@@iterator]()
14040 __webpack_require__(85)(String, 'String', function (iterated) {
14041   this._t = String(iterated); // target
14042   this._i = 0;                // next index
14043 // 21.1.5.2.1 %StringIteratorPrototype%.next()
14044 }, function () {
14045   var O = this._t;
14046   var index = this._i;
14047   var point;
14048   if (index >= O.length) return { value: undefined, done: true };
14049   point = $at(O, index);
14050   this._i += point.length;
14051   return { value: point, done: false };
14052 });
14053
14054
14055 /***/ }),
14056 /* 133 */
14057 /***/ (function(module, exports, __webpack_require__) {
14058
14059 // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
14060 var anObject = __webpack_require__(15);
14061 var dPs = __webpack_require__(159);
14062 var enumBugKeys = __webpack_require__(71);
14063 var IE_PROTO = __webpack_require__(53)('IE_PROTO');
14064 var Empty = function () { /* empty */ };
14065 var PROTOTYPE = 'prototype';
14066
14067 // Create object with fake `null` prototype: use iframe Object with cleared prototype
14068 var createDict = function () {
14069   // Thrash, waste and sodomy: IE GC bug
14070   var iframe = __webpack_require__(50)('iframe');
14071   var i = enumBugKeys.length;
14072   var lt = '<';
14073   var gt = '>';
14074   var iframeDocument;
14075   iframe.style.display = 'none';
14076   __webpack_require__(86).appendChild(iframe);
14077   iframe.src = 'javascript:'; // eslint-disable-line no-script-url
14078   // createDict = iframe.contentWindow.Object;
14079   // html.removeChild(iframe);
14080   iframeDocument = iframe.contentWindow.document;
14081   iframeDocument.open();
14082   iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
14083   iframeDocument.close();
14084   createDict = iframeDocument.F;
14085   while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
14086   return createDict();
14087 };
14088
14089 module.exports = Object.create || function create(O, Properties) {
14090   var result;
14091   if (O !== null) {
14092     Empty[PROTOTYPE] = anObject(O);
14093     result = new Empty();
14094     Empty[PROTOTYPE] = null;
14095     // add "__proto__" for Object.getPrototypeOf polyfill
14096     result[IE_PROTO] = O;
14097   } else result = createDict();
14098   return Properties === undefined ? result : dPs(result, Properties);
14099 };
14100
14101
14102 /***/ }),
14103 /* 134 */
14104 /***/ (function(module, exports) {
14105
14106 module.exports = function (it, Constructor, name, forbiddenField) {
14107   if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
14108     throw TypeError(name + ': incorrect invocation!');
14109   } return it;
14110 };
14111
14112
14113 /***/ }),
14114 /* 135 */
14115 /***/ (function(module, exports, __webpack_require__) {
14116
14117 var hide = __webpack_require__(19);
14118 module.exports = function (target, src, safe) {
14119   for (var key in src) {
14120     if (safe && target[key]) target[key] = src[key];
14121     else hide(target, key, src[key]);
14122   } return target;
14123 };
14124
14125
14126 /***/ }),
14127 /* 136 */
14128 /***/ (function(module, exports, __webpack_require__) {
14129
14130 module.exports = { "default": __webpack_require__(152), __esModule: true };
14131
14132 /***/ }),
14133 /* 137 */
14134 /***/ (function(module, exports, __webpack_require__) {
14135
14136 "use strict";
14137 \r
14138 Object.defineProperty(exports, "__esModule", { value: true });\r
14139 var EncryptedStream_1 = __webpack_require__(179);\r
14140 exports.EncryptedStream = EncryptedStream_1.EncryptedStream;\r
14141 var LocalStream_1 = __webpack_require__(264);\r
14142 exports.LocalStream = LocalStream_1.LocalStream;\r
14143 //# sourceMappingURL=index.js.map
14144
14145 /***/ }),
14146 /* 138 */
14147 /***/ (function(module, exports, __webpack_require__) {
14148
14149 module.exports = __webpack_require__(154);
14150
14151
14152 /***/ }),
14153 /* 139 */
14154 /***/ (function(module, exports, __webpack_require__) {
14155
14156 "use strict";
14157
14158
14159 exports.__esModule = true;
14160
14161 var _promise = __webpack_require__(76);
14162
14163 var _promise2 = _interopRequireDefault(_promise);
14164
14165 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14166
14167 exports.default = function (fn) {
14168   return function () {
14169     var gen = fn.apply(this, arguments);
14170     return new _promise2.default(function (resolve, reject) {
14171       function step(key, arg) {
14172         try {
14173           var info = gen[key](arg);
14174           var value = info.value;
14175         } catch (error) {
14176           reject(error);
14177           return;
14178         }
14179
14180         if (info.done) {
14181           resolve(value);
14182         } else {
14183           return _promise2.default.resolve(value).then(function (value) {
14184             step("next", value);
14185           }, function (err) {
14186             step("throw", err);
14187           });
14188         }
14189       }
14190
14191       return step("next");
14192     });
14193   };
14194 };
14195
14196 /***/ }),
14197 /* 140 */
14198 /***/ (function(module, exports, __webpack_require__) {
14199
14200 /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
14201             (typeof self !== "undefined" && self) ||
14202             window;
14203 var apply = Function.prototype.apply;
14204
14205 // DOM APIs, for completeness
14206
14207 exports.setTimeout = function() {
14208   return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
14209 };
14210 exports.setInterval = function() {
14211   return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
14212 };
14213 exports.clearTimeout =
14214 exports.clearInterval = function(timeout) {
14215   if (timeout) {
14216     timeout.close();
14217   }
14218 };
14219
14220 function Timeout(id, clearFn) {
14221   this._id = id;
14222   this._clearFn = clearFn;
14223 }
14224 Timeout.prototype.unref = Timeout.prototype.ref = function() {};
14225 Timeout.prototype.close = function() {
14226   this._clearFn.call(scope, this._id);
14227 };
14228
14229 // Does not start the time, just sets up the members needed.
14230 exports.enroll = function(item, msecs) {
14231   clearTimeout(item._idleTimeoutId);
14232   item._idleTimeout = msecs;
14233 };
14234
14235 exports.unenroll = function(item) {
14236   clearTimeout(item._idleTimeoutId);
14237   item._idleTimeout = -1;
14238 };
14239
14240 exports._unrefActive = exports.active = function(item) {
14241   clearTimeout(item._idleTimeoutId);
14242
14243   var msecs = item._idleTimeout;
14244   if (msecs >= 0) {
14245     item._idleTimeoutId = setTimeout(function onTimeout() {
14246       if (item._onTimeout)
14247         item._onTimeout();
14248     }, msecs);
14249   }
14250 };
14251
14252 // setimmediate attaches itself to the global object
14253 __webpack_require__(147);
14254 // On some exotic environments, it's not clear which object `setimmediate` was
14255 // able to install onto.  Search each possibility in the same order as the
14256 // `setimmediate` library.
14257 exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
14258                        (typeof global !== "undefined" && global.setImmediate) ||
14259                        (this && this.setImmediate);
14260 exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
14261                          (typeof global !== "undefined" && global.clearImmediate) ||
14262                          (this && this.clearImmediate);
14263
14264 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
14265
14266 /***/ }),
14267 /* 141 */
14268 /***/ (function(module, exports, __webpack_require__) {
14269
14270 "use strict";
14271
14272 // 19.1.2.1 Object.assign(target, source, ...)
14273 var getKeys = __webpack_require__(39);
14274 var gOPS = __webpack_require__(73);
14275 var pIE = __webpack_require__(49);
14276 var toObject = __webpack_require__(54);
14277 var IObject = __webpack_require__(74);
14278 var $assign = Object.assign;
14279
14280 // should work with symbols and should have deterministic property order (V8 bug)
14281 module.exports = !$assign || __webpack_require__(22)(function () {
14282   var A = {};
14283   var B = {};
14284   // eslint-disable-next-line no-undef
14285   var S = Symbol();
14286   var K = 'abcdefghijklmnopqrst';
14287   A[S] = 7;
14288   K.split('').forEach(function (k) { B[k] = k; });
14289   return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
14290 }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
14291   var T = toObject(target);
14292   var aLen = arguments.length;
14293   var index = 1;
14294   var getSymbols = gOPS.f;
14295   var isEnum = pIE.f;
14296   while (aLen > index) {
14297     var S = IObject(arguments[index++]);
14298     var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
14299     var length = keys.length;
14300     var j = 0;
14301     var key;
14302     while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
14303   } return T;
14304 } : $assign;
14305
14306
14307 /***/ }),
14308 /* 142 */,
14309 /* 143 */
14310 /***/ (function(module, exports, __webpack_require__) {
14311
14312 // 7.2.2 IsArray(argument)
14313 var cof = __webpack_require__(27);
14314 module.exports = Array.isArray || function isArray(arg) {
14315   return cof(arg) == 'Array';
14316 };
14317
14318
14319 /***/ }),
14320 /* 144 */,
14321 /* 145 */,
14322 /* 146 */,
14323 /* 147 */
14324 /***/ (function(module, exports, __webpack_require__) {
14325
14326 /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
14327     "use strict";
14328
14329     if (global.setImmediate) {
14330         return;
14331     }
14332
14333     var nextHandle = 1; // Spec says greater than zero
14334     var tasksByHandle = {};
14335     var currentlyRunningATask = false;
14336     var doc = global.document;
14337     var registerImmediate;
14338
14339     function setImmediate(callback) {
14340       // Callback can either be a function or a string
14341       if (typeof callback !== "function") {
14342         callback = new Function("" + callback);
14343       }
14344       // Copy function arguments
14345       var args = new Array(arguments.length - 1);
14346       for (var i = 0; i < args.length; i++) {
14347           args[i] = arguments[i + 1];
14348       }
14349       // Store and register the task
14350       var task = { callback: callback, args: args };
14351       tasksByHandle[nextHandle] = task;
14352       registerImmediate(nextHandle);
14353       return nextHandle++;
14354     }
14355
14356     function clearImmediate(handle) {
14357         delete tasksByHandle[handle];
14358     }
14359
14360     function run(task) {
14361         var callback = task.callback;
14362         var args = task.args;
14363         switch (args.length) {
14364         case 0:
14365             callback();
14366             break;
14367         case 1:
14368             callback(args[0]);
14369             break;
14370         case 2:
14371             callback(args[0], args[1]);
14372             break;
14373         case 3:
14374             callback(args[0], args[1], args[2]);
14375             break;
14376         default:
14377             callback.apply(undefined, args);
14378             break;
14379         }
14380     }
14381
14382     function runIfPresent(handle) {
14383         // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
14384         // So if we're currently running a task, we'll need to delay this invocation.
14385         if (currentlyRunningATask) {
14386             // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
14387             // "too much recursion" error.
14388             setTimeout(runIfPresent, 0, handle);
14389         } else {
14390             var task = tasksByHandle[handle];
14391             if (task) {
14392                 currentlyRunningATask = true;
14393                 try {
14394                     run(task);
14395                 } finally {
14396                     clearImmediate(handle);
14397                     currentlyRunningATask = false;
14398                 }
14399             }
14400         }
14401     }
14402
14403     function installNextTickImplementation() {
14404         registerImmediate = function(handle) {
14405             process.nextTick(function () { runIfPresent(handle); });
14406         };
14407     }
14408
14409     function canUsePostMessage() {
14410         // The test against `importScripts` prevents this implementation from being installed inside a web worker,
14411         // where `global.postMessage` means something completely different and can't be used for this purpose.
14412         if (global.postMessage && !global.importScripts) {
14413             var postMessageIsAsynchronous = true;
14414             var oldOnMessage = global.onmessage;
14415             global.onmessage = function() {
14416                 postMessageIsAsynchronous = false;
14417             };
14418             global.postMessage("", "*");
14419             global.onmessage = oldOnMessage;
14420             return postMessageIsAsynchronous;
14421         }
14422     }
14423
14424     function installPostMessageImplementation() {
14425         // Installs an event handler on `global` for the `message` event: see
14426         // * https://developer.mozilla.org/en/DOM/window.postMessage
14427         // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
14428
14429         var messagePrefix = "setImmediate$" + Math.random() + "$";
14430         var onGlobalMessage = function(event) {
14431             if (event.source === global &&
14432                 typeof event.data === "string" &&
14433                 event.data.indexOf(messagePrefix) === 0) {
14434                 runIfPresent(+event.data.slice(messagePrefix.length));
14435             }
14436         };
14437
14438         if (global.addEventListener) {
14439             global.addEventListener("message", onGlobalMessage, false);
14440         } else {
14441             global.attachEvent("onmessage", onGlobalMessage);
14442         }
14443
14444         registerImmediate = function(handle) {
14445             global.postMessage(messagePrefix + handle, "*");
14446         };
14447     }
14448
14449     function installMessageChannelImplementation() {
14450         var channel = new MessageChannel();
14451         channel.port1.onmessage = function(event) {
14452             var handle = event.data;
14453             runIfPresent(handle);
14454         };
14455
14456         registerImmediate = function(handle) {
14457             channel.port2.postMessage(handle);
14458         };
14459     }
14460
14461     function installReadyStateChangeImplementation() {
14462         var html = doc.documentElement;
14463         registerImmediate = function(handle) {
14464             // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
14465             // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
14466             var script = doc.createElement("script");
14467             script.onreadystatechange = function () {
14468                 runIfPresent(handle);
14469                 script.onreadystatechange = null;
14470                 html.removeChild(script);
14471                 script = null;
14472             };
14473             html.appendChild(script);
14474         };
14475     }
14476
14477     function installSetTimeoutImplementation() {
14478         registerImmediate = function(handle) {
14479             setTimeout(runIfPresent, 0, handle);
14480         };
14481     }
14482
14483     // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
14484     var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
14485     attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
14486
14487     // Don't get fooled by e.g. browserify environments.
14488     if ({}.toString.call(global.process) === "[object process]") {
14489         // For Node.js before 0.9
14490         installNextTickImplementation();
14491
14492     } else if (canUsePostMessage()) {
14493         // For non-IE10 modern browsers
14494         installPostMessageImplementation();
14495
14496     } else if (global.MessageChannel) {
14497         // For web workers, where supported
14498         installMessageChannelImplementation();
14499
14500     } else if (doc && "onreadystatechange" in doc.createElement("script")) {
14501         // For IE 6–8
14502         installReadyStateChangeImplementation();
14503
14504     } else {
14505         // For older browsers
14506         installSetTimeoutImplementation();
14507     }
14508
14509     attachTo.setImmediate = setImmediate;
14510     attachTo.clearImmediate = clearImmediate;
14511 }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
14512
14513 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
14514
14515 /***/ }),
14516 /* 148 */
14517 /***/ (function(module, exports, __webpack_require__) {
14518
14519 __webpack_require__(149);
14520 module.exports = __webpack_require__(8).Object.assign;
14521
14522
14523 /***/ }),
14524 /* 149 */
14525 /***/ (function(module, exports, __webpack_require__) {
14526
14527 // 19.1.3.1 Object.assign(target, source)
14528 var $export = __webpack_require__(13);
14529
14530 $export($export.S + $export.F, 'Object', { assign: __webpack_require__(141) });
14531
14532
14533 /***/ }),
14534 /* 150 */
14535 /***/ (function(module, exports, __webpack_require__) {
14536
14537 // false -> Array#indexOf
14538 // true  -> Array#includes
14539 var toIObject = __webpack_require__(25);
14540 var toLength = __webpack_require__(75);
14541 var toAbsoluteIndex = __webpack_require__(151);
14542 module.exports = function (IS_INCLUDES) {
14543   return function ($this, el, fromIndex) {
14544     var O = toIObject($this);
14545     var length = toLength(O.length);
14546     var index = toAbsoluteIndex(fromIndex, length);
14547     var value;
14548     // Array#includes uses SameValueZero equality algorithm
14549     // eslint-disable-next-line no-self-compare
14550     if (IS_INCLUDES && el != el) while (length > index) {
14551       value = O[index++];
14552       // eslint-disable-next-line no-self-compare
14553       if (value != value) return true;
14554     // Array#indexOf ignores holes, Array#includes - not
14555     } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
14556       if (O[index] === el) return IS_INCLUDES || index || 0;
14557     } return !IS_INCLUDES && -1;
14558   };
14559 };
14560
14561
14562 /***/ }),
14563 /* 151 */
14564 /***/ (function(module, exports, __webpack_require__) {
14565
14566 var toInteger = __webpack_require__(52);
14567 var max = Math.max;
14568 var min = Math.min;
14569 module.exports = function (index, length) {
14570   index = toInteger(index);
14571   return index < 0 ? max(index + length, 0) : min(index, length);
14572 };
14573
14574
14575 /***/ }),
14576 /* 152 */
14577 /***/ (function(module, exports, __webpack_require__) {
14578
14579 __webpack_require__(153);
14580 var $Object = __webpack_require__(8).Object;
14581 module.exports = function defineProperty(it, key, desc) {
14582   return $Object.defineProperty(it, key, desc);
14583 };
14584
14585
14586 /***/ }),
14587 /* 153 */
14588 /***/ (function(module, exports, __webpack_require__) {
14589
14590 var $export = __webpack_require__(13);
14591 // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
14592 $export($export.S + $export.F * !__webpack_require__(17), 'Object', { defineProperty: __webpack_require__(16).f });
14593
14594
14595 /***/ }),
14596 /* 154 */
14597 /***/ (function(module, exports, __webpack_require__) {
14598
14599 /**
14600  * Copyright (c) 2014-present, Facebook, Inc.
14601  *
14602  * This source code is licensed under the MIT license found in the
14603  * LICENSE file in the root directory of this source tree.
14604  */
14605
14606 // This method of obtaining a reference to the global object needs to be
14607 // kept identical to the way it is obtained in runtime.js
14608 var g = (function() { return this })() || Function("return this")();
14609
14610 // Use `getOwnPropertyNames` because not all browsers support calling
14611 // `hasOwnProperty` on the global `self` object in a worker. See #183.
14612 var hadRuntime = g.regeneratorRuntime &&
14613   Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
14614
14615 // Save the old regeneratorRuntime in case it needs to be restored later.
14616 var oldRuntime = hadRuntime && g.regeneratorRuntime;
14617
14618 // Force reevalutation of runtime.js.
14619 g.regeneratorRuntime = undefined;
14620
14621 module.exports = __webpack_require__(155);
14622
14623 if (hadRuntime) {
14624   // Restore the original runtime.
14625   g.regeneratorRuntime = oldRuntime;
14626 } else {
14627   // Remove the global property added by runtime.js.
14628   try {
14629     delete g.regeneratorRuntime;
14630   } catch(e) {
14631     g.regeneratorRuntime = undefined;
14632   }
14633 }
14634
14635
14636 /***/ }),
14637 /* 155 */
14638 /***/ (function(module, exports) {
14639
14640 /**
14641  * Copyright (c) 2014-present, Facebook, Inc.
14642  *
14643  * This source code is licensed under the MIT license found in the
14644  * LICENSE file in the root directory of this source tree.
14645  */
14646
14647 !(function(global) {
14648   "use strict";
14649
14650   var Op = Object.prototype;
14651   var hasOwn = Op.hasOwnProperty;
14652   var undefined; // More compressible than void 0.
14653   var $Symbol = typeof Symbol === "function" ? Symbol : {};
14654   var iteratorSymbol = $Symbol.iterator || "@@iterator";
14655   var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
14656   var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
14657
14658   var inModule = typeof module === "object";
14659   var runtime = global.regeneratorRuntime;
14660   if (runtime) {
14661     if (inModule) {
14662       // If regeneratorRuntime is defined globally and we're in a module,
14663       // make the exports object identical to regeneratorRuntime.
14664       module.exports = runtime;
14665     }
14666     // Don't bother evaluating the rest of this file if the runtime was
14667     // already defined globally.
14668     return;
14669   }
14670
14671   // Define the runtime globally (as expected by generated code) as either
14672   // module.exports (if we're in a module) or a new, empty object.
14673   runtime = global.regeneratorRuntime = inModule ? module.exports : {};
14674
14675   function wrap(innerFn, outerFn, self, tryLocsList) {
14676     // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
14677     var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
14678     var generator = Object.create(protoGenerator.prototype);
14679     var context = new Context(tryLocsList || []);
14680
14681     // The ._invoke method unifies the implementations of the .next,
14682     // .throw, and .return methods.
14683     generator._invoke = makeInvokeMethod(innerFn, self, context);
14684
14685     return generator;
14686   }
14687   runtime.wrap = wrap;
14688
14689   // Try/catch helper to minimize deoptimizations. Returns a completion
14690   // record like context.tryEntries[i].completion. This interface could
14691   // have been (and was previously) designed to take a closure to be
14692   // invoked without arguments, but in all the cases we care about we
14693   // already have an existing method we want to call, so there's no need
14694   // to create a new function object. We can even get away with assuming
14695   // the method takes exactly one argument, since that happens to be true
14696   // in every case, so we don't have to touch the arguments object. The
14697   // only additional allocation required is the completion record, which
14698   // has a stable shape and so hopefully should be cheap to allocate.
14699   function tryCatch(fn, obj, arg) {
14700     try {
14701       return { type: "normal", arg: fn.call(obj, arg) };
14702     } catch (err) {
14703       return { type: "throw", arg: err };
14704     }
14705   }
14706
14707   var GenStateSuspendedStart = "suspendedStart";
14708   var GenStateSuspendedYield = "suspendedYield";
14709   var GenStateExecuting = "executing";
14710   var GenStateCompleted = "completed";
14711
14712   // Returning this object from the innerFn has the same effect as
14713   // breaking out of the dispatch switch statement.
14714   var ContinueSentinel = {};
14715
14716   // Dummy constructor functions that we use as the .constructor and
14717   // .constructor.prototype properties for functions that return Generator
14718   // objects. For full spec compliance, you may wish to configure your
14719   // minifier not to mangle the names of these two functions.
14720   function Generator() {}
14721   function GeneratorFunction() {}
14722   function GeneratorFunctionPrototype() {}
14723
14724   // This is a polyfill for %IteratorPrototype% for environments that
14725   // don't natively support it.
14726   var IteratorPrototype = {};
14727   IteratorPrototype[iteratorSymbol] = function () {
14728     return this;
14729   };
14730
14731   var getProto = Object.getPrototypeOf;
14732   var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
14733   if (NativeIteratorPrototype &&
14734       NativeIteratorPrototype !== Op &&
14735       hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
14736     // This environment has a native %IteratorPrototype%; use it instead
14737     // of the polyfill.
14738     IteratorPrototype = NativeIteratorPrototype;
14739   }
14740
14741   var Gp = GeneratorFunctionPrototype.prototype =
14742     Generator.prototype = Object.create(IteratorPrototype);
14743   GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
14744   GeneratorFunctionPrototype.constructor = GeneratorFunction;
14745   GeneratorFunctionPrototype[toStringTagSymbol] =
14746     GeneratorFunction.displayName = "GeneratorFunction";
14747
14748   // Helper for defining the .next, .throw, and .return methods of the
14749   // Iterator interface in terms of a single ._invoke method.
14750   function defineIteratorMethods(prototype) {
14751     ["next", "throw", "return"].forEach(function(method) {
14752       prototype[method] = function(arg) {
14753         return this._invoke(method, arg);
14754       };
14755     });
14756   }
14757
14758   runtime.isGeneratorFunction = function(genFun) {
14759     var ctor = typeof genFun === "function" && genFun.constructor;
14760     return ctor
14761       ? ctor === GeneratorFunction ||
14762         // For the native GeneratorFunction constructor, the best we can
14763         // do is to check its .name property.
14764         (ctor.displayName || ctor.name) === "GeneratorFunction"
14765       : false;
14766   };
14767
14768   runtime.mark = function(genFun) {
14769     if (Object.setPrototypeOf) {
14770       Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
14771     } else {
14772       genFun.__proto__ = GeneratorFunctionPrototype;
14773       if (!(toStringTagSymbol in genFun)) {
14774         genFun[toStringTagSymbol] = "GeneratorFunction";
14775       }
14776     }
14777     genFun.prototype = Object.create(Gp);
14778     return genFun;
14779   };
14780
14781   // Within the body of any async function, `await x` is transformed to
14782   // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
14783   // `hasOwn.call(value, "__await")` to determine if the yielded value is
14784   // meant to be awaited.
14785   runtime.awrap = function(arg) {
14786     return { __await: arg };
14787   };
14788
14789   function AsyncIterator(generator) {
14790     function invoke(method, arg, resolve, reject) {
14791       var record = tryCatch(generator[method], generator, arg);
14792       if (record.type === "throw") {
14793         reject(record.arg);
14794       } else {
14795         var result = record.arg;
14796         var value = result.value;
14797         if (value &&
14798             typeof value === "object" &&
14799             hasOwn.call(value, "__await")) {
14800           return Promise.resolve(value.__await).then(function(value) {
14801             invoke("next", value, resolve, reject);
14802           }, function(err) {
14803             invoke("throw", err, resolve, reject);
14804           });
14805         }
14806
14807         return Promise.resolve(value).then(function(unwrapped) {
14808           // When a yielded Promise is resolved, its final value becomes
14809           // the .value of the Promise<{value,done}> result for the
14810           // current iteration. If the Promise is rejected, however, the
14811           // result for this iteration will be rejected with the same
14812           // reason. Note that rejections of yielded Promises are not
14813           // thrown back into the generator function, as is the case
14814           // when an awaited Promise is rejected. This difference in
14815           // behavior between yield and await is important, because it
14816           // allows the consumer to decide what to do with the yielded
14817           // rejection (swallow it and continue, manually .throw it back
14818           // into the generator, abandon iteration, whatever). With
14819           // await, by contrast, there is no opportunity to examine the
14820           // rejection reason outside the generator function, so the
14821           // only option is to throw it from the await expression, and
14822           // let the generator function handle the exception.
14823           result.value = unwrapped;
14824           resolve(result);
14825         }, reject);
14826       }
14827     }
14828
14829     var previousPromise;
14830
14831     function enqueue(method, arg) {
14832       function callInvokeWithMethodAndArg() {
14833         return new Promise(function(resolve, reject) {
14834           invoke(method, arg, resolve, reject);
14835         });
14836       }
14837
14838       return previousPromise =
14839         // If enqueue has been called before, then we want to wait until
14840         // all previous Promises have been resolved before calling invoke,
14841         // so that results are always delivered in the correct order. If
14842         // enqueue has not been called before, then it is important to
14843         // call invoke immediately, without waiting on a callback to fire,
14844         // so that the async generator function has the opportunity to do
14845         // any necessary setup in a predictable way. This predictability
14846         // is why the Promise constructor synchronously invokes its
14847         // executor callback, and why async functions synchronously
14848         // execute code before the first await. Since we implement simple
14849         // async functions in terms of async generators, it is especially
14850         // important to get this right, even though it requires care.
14851         previousPromise ? previousPromise.then(
14852           callInvokeWithMethodAndArg,
14853           // Avoid propagating failures to Promises returned by later
14854           // invocations of the iterator.
14855           callInvokeWithMethodAndArg
14856         ) : callInvokeWithMethodAndArg();
14857     }
14858
14859     // Define the unified helper method that is used to implement .next,
14860     // .throw, and .return (see defineIteratorMethods).
14861     this._invoke = enqueue;
14862   }
14863
14864   defineIteratorMethods(AsyncIterator.prototype);
14865   AsyncIterator.prototype[asyncIteratorSymbol] = function () {
14866     return this;
14867   };
14868   runtime.AsyncIterator = AsyncIterator;
14869
14870   // Note that simple async functions are implemented on top of
14871   // AsyncIterator objects; they just return a Promise for the value of
14872   // the final result produced by the iterator.
14873   runtime.async = function(innerFn, outerFn, self, tryLocsList) {
14874     var iter = new AsyncIterator(
14875       wrap(innerFn, outerFn, self, tryLocsList)
14876     );
14877
14878     return runtime.isGeneratorFunction(outerFn)
14879       ? iter // If outerFn is a generator, return the full iterator.
14880       : iter.next().then(function(result) {
14881           return result.done ? result.value : iter.next();
14882         });
14883   };
14884
14885   function makeInvokeMethod(innerFn, self, context) {
14886     var state = GenStateSuspendedStart;
14887
14888     return function invoke(method, arg) {
14889       if (state === GenStateExecuting) {
14890         throw new Error("Generator is already running");
14891       }
14892
14893       if (state === GenStateCompleted) {
14894         if (method === "throw") {
14895           throw arg;
14896         }
14897
14898         // Be forgiving, per 25.3.3.3.3 of the spec:
14899         // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
14900         return doneResult();
14901       }
14902
14903       context.method = method;
14904       context.arg = arg;
14905
14906       while (true) {
14907         var delegate = context.delegate;
14908         if (delegate) {
14909           var delegateResult = maybeInvokeDelegate(delegate, context);
14910           if (delegateResult) {
14911             if (delegateResult === ContinueSentinel) continue;
14912             return delegateResult;
14913           }
14914         }
14915
14916         if (context.method === "next") {
14917           // Setting context._sent for legacy support of Babel's
14918           // function.sent implementation.
14919           context.sent = context._sent = context.arg;
14920
14921         } else if (context.method === "throw") {
14922           if (state === GenStateSuspendedStart) {
14923             state = GenStateCompleted;
14924             throw context.arg;
14925           }
14926
14927           context.dispatchException(context.arg);
14928
14929         } else if (context.method === "return") {
14930           context.abrupt("return", context.arg);
14931         }
14932
14933         state = GenStateExecuting;
14934
14935         var record = tryCatch(innerFn, self, context);
14936         if (record.type === "normal") {
14937           // If an exception is thrown from innerFn, we leave state ===
14938           // GenStateExecuting and loop back for another invocation.
14939           state = context.done
14940             ? GenStateCompleted
14941             : GenStateSuspendedYield;
14942
14943           if (record.arg === ContinueSentinel) {
14944             continue;
14945           }
14946
14947           return {
14948             value: record.arg,
14949             done: context.done
14950           };
14951
14952         } else if (record.type === "throw") {
14953           state = GenStateCompleted;
14954           // Dispatch the exception by looping back around to the
14955           // context.dispatchException(context.arg) call above.
14956           context.method = "throw";
14957           context.arg = record.arg;
14958         }
14959       }
14960     };
14961   }
14962
14963   // Call delegate.iterator[context.method](context.arg) and handle the
14964   // result, either by returning a { value, done } result from the
14965   // delegate iterator, or by modifying context.method and context.arg,
14966   // setting context.delegate to null, and returning the ContinueSentinel.
14967   function maybeInvokeDelegate(delegate, context) {
14968     var method = delegate.iterator[context.method];
14969     if (method === undefined) {
14970       // A .throw or .return when the delegate iterator has no .throw
14971       // method always terminates the yield* loop.
14972       context.delegate = null;
14973
14974       if (context.method === "throw") {
14975         if (delegate.iterator.return) {
14976           // If the delegate iterator has a return method, give it a
14977           // chance to clean up.
14978           context.method = "return";
14979           context.arg = undefined;
14980           maybeInvokeDelegate(delegate, context);
14981
14982           if (context.method === "throw") {
14983             // If maybeInvokeDelegate(context) changed context.method from
14984             // "return" to "throw", let that override the TypeError below.
14985             return ContinueSentinel;
14986           }
14987         }
14988
14989         context.method = "throw";
14990         context.arg = new TypeError(
14991           "The iterator does not provide a 'throw' method");
14992       }
14993
14994       return ContinueSentinel;
14995     }
14996
14997     var record = tryCatch(method, delegate.iterator, context.arg);
14998
14999     if (record.type === "throw") {
15000       context.method = "throw";
15001       context.arg = record.arg;
15002       context.delegate = null;
15003       return ContinueSentinel;
15004     }
15005
15006     var info = record.arg;
15007
15008     if (! info) {
15009       context.method = "throw";
15010       context.arg = new TypeError("iterator result is not an object");
15011       context.delegate = null;
15012       return ContinueSentinel;
15013     }
15014
15015     if (info.done) {
15016       // Assign the result of the finished delegate to the temporary
15017       // variable specified by delegate.resultName (see delegateYield).
15018       context[delegate.resultName] = info.value;
15019
15020       // Resume execution at the desired location (see delegateYield).
15021       context.next = delegate.nextLoc;
15022
15023       // If context.method was "throw" but the delegate handled the
15024       // exception, let the outer generator proceed normally. If
15025       // context.method was "next", forget context.arg since it has been
15026       // "consumed" by the delegate iterator. If context.method was
15027       // "return", allow the original .return call to continue in the
15028       // outer generator.
15029       if (context.method !== "return") {
15030         context.method = "next";
15031         context.arg = undefined;
15032       }
15033
15034     } else {
15035       // Re-yield the result returned by the delegate method.
15036       return info;
15037     }
15038
15039     // The delegate iterator is finished, so forget it and continue with
15040     // the outer generator.
15041     context.delegate = null;
15042     return ContinueSentinel;
15043   }
15044
15045   // Define Generator.prototype.{next,throw,return} in terms of the
15046   // unified ._invoke helper method.
15047   defineIteratorMethods(Gp);
15048
15049   Gp[toStringTagSymbol] = "Generator";
15050
15051   // A Generator should always return itself as the iterator object when the
15052   // @@iterator function is called on it. Some browsers' implementations of the
15053   // iterator prototype chain incorrectly implement this, causing the Generator
15054   // object to not be returned from this call. This ensures that doesn't happen.
15055   // See https://github.com/facebook/regenerator/issues/274 for more details.
15056   Gp[iteratorSymbol] = function() {
15057     return this;
15058   };
15059
15060   Gp.toString = function() {
15061     return "[object Generator]";
15062   };
15063
15064   function pushTryEntry(locs) {
15065     var entry = { tryLoc: locs[0] };
15066
15067     if (1 in locs) {
15068       entry.catchLoc = locs[1];
15069     }
15070
15071     if (2 in locs) {
15072       entry.finallyLoc = locs[2];
15073       entry.afterLoc = locs[3];
15074     }
15075
15076     this.tryEntries.push(entry);
15077   }
15078
15079   function resetTryEntry(entry) {
15080     var record = entry.completion || {};
15081     record.type = "normal";
15082     delete record.arg;
15083     entry.completion = record;
15084   }
15085
15086   function Context(tryLocsList) {
15087     // The root entry object (effectively a try statement without a catch
15088     // or a finally block) gives us a place to store values thrown from
15089     // locations where there is no enclosing try statement.
15090     this.tryEntries = [{ tryLoc: "root" }];
15091     tryLocsList.forEach(pushTryEntry, this);
15092     this.reset(true);
15093   }
15094
15095   runtime.keys = function(object) {
15096     var keys = [];
15097     for (var key in object) {
15098       keys.push(key);
15099     }
15100     keys.reverse();
15101
15102     // Rather than returning an object with a next method, we keep
15103     // things simple and return the next function itself.
15104     return function next() {
15105       while (keys.length) {
15106         var key = keys.pop();
15107         if (key in object) {
15108           next.value = key;
15109           next.done = false;
15110           return next;
15111         }
15112       }
15113
15114       // To avoid creating an additional object, we just hang the .value
15115       // and .done properties off the next function object itself. This
15116       // also ensures that the minifier will not anonymize the function.
15117       next.done = true;
15118       return next;
15119     };
15120   };
15121
15122   function values(iterable) {
15123     if (iterable) {
15124       var iteratorMethod = iterable[iteratorSymbol];
15125       if (iteratorMethod) {
15126         return iteratorMethod.call(iterable);
15127       }
15128
15129       if (typeof iterable.next === "function") {
15130         return iterable;
15131       }
15132
15133       if (!isNaN(iterable.length)) {
15134         var i = -1, next = function next() {
15135           while (++i < iterable.length) {
15136             if (hasOwn.call(iterable, i)) {
15137               next.value = iterable[i];
15138               next.done = false;
15139               return next;
15140             }
15141           }
15142
15143           next.value = undefined;
15144           next.done = true;
15145
15146           return next;
15147         };
15148
15149         return next.next = next;
15150       }
15151     }
15152
15153     // Return an iterator with no values.
15154     return { next: doneResult };
15155   }
15156   runtime.values = values;
15157
15158   function doneResult() {
15159     return { value: undefined, done: true };
15160   }
15161
15162   Context.prototype = {
15163     constructor: Context,
15164
15165     reset: function(skipTempReset) {
15166       this.prev = 0;
15167       this.next = 0;
15168       // Resetting context._sent for legacy support of Babel's
15169       // function.sent implementation.
15170       this.sent = this._sent = undefined;
15171       this.done = false;
15172       this.delegate = null;
15173
15174       this.method = "next";
15175       this.arg = undefined;
15176
15177       this.tryEntries.forEach(resetTryEntry);
15178
15179       if (!skipTempReset) {
15180         for (var name in this) {
15181           // Not sure about the optimal order of these conditions:
15182           if (name.charAt(0) === "t" &&
15183               hasOwn.call(this, name) &&
15184               !isNaN(+name.slice(1))) {
15185             this[name] = undefined;
15186           }
15187         }
15188       }
15189     },
15190
15191     stop: function() {
15192       this.done = true;
15193
15194       var rootEntry = this.tryEntries[0];
15195       var rootRecord = rootEntry.completion;
15196       if (rootRecord.type === "throw") {
15197         throw rootRecord.arg;
15198       }
15199
15200       return this.rval;
15201     },
15202
15203     dispatchException: function(exception) {
15204       if (this.done) {
15205         throw exception;
15206       }
15207
15208       var context = this;
15209       function handle(loc, caught) {
15210         record.type = "throw";
15211         record.arg = exception;
15212         context.next = loc;
15213
15214         if (caught) {
15215           // If the dispatched exception was caught by a catch block,
15216           // then let that catch block handle the exception normally.
15217           context.method = "next";
15218           context.arg = undefined;
15219         }
15220
15221         return !! caught;
15222       }
15223
15224       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15225         var entry = this.tryEntries[i];
15226         var record = entry.completion;
15227
15228         if (entry.tryLoc === "root") {
15229           // Exception thrown outside of any try block that could handle
15230           // it, so set the completion value of the entire function to
15231           // throw the exception.
15232           return handle("end");
15233         }
15234
15235         if (entry.tryLoc <= this.prev) {
15236           var hasCatch = hasOwn.call(entry, "catchLoc");
15237           var hasFinally = hasOwn.call(entry, "finallyLoc");
15238
15239           if (hasCatch && hasFinally) {
15240             if (this.prev < entry.catchLoc) {
15241               return handle(entry.catchLoc, true);
15242             } else if (this.prev < entry.finallyLoc) {
15243               return handle(entry.finallyLoc);
15244             }
15245
15246           } else if (hasCatch) {
15247             if (this.prev < entry.catchLoc) {
15248               return handle(entry.catchLoc, true);
15249             }
15250
15251           } else if (hasFinally) {
15252             if (this.prev < entry.finallyLoc) {
15253               return handle(entry.finallyLoc);
15254             }
15255
15256           } else {
15257             throw new Error("try statement without catch or finally");
15258           }
15259         }
15260       }
15261     },
15262
15263     abrupt: function(type, arg) {
15264       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15265         var entry = this.tryEntries[i];
15266         if (entry.tryLoc <= this.prev &&
15267             hasOwn.call(entry, "finallyLoc") &&
15268             this.prev < entry.finallyLoc) {
15269           var finallyEntry = entry;
15270           break;
15271         }
15272       }
15273
15274       if (finallyEntry &&
15275           (type === "break" ||
15276            type === "continue") &&
15277           finallyEntry.tryLoc <= arg &&
15278           arg <= finallyEntry.finallyLoc) {
15279         // Ignore the finally entry if control is not jumping to a
15280         // location outside the try/catch block.
15281         finallyEntry = null;
15282       }
15283
15284       var record = finallyEntry ? finallyEntry.completion : {};
15285       record.type = type;
15286       record.arg = arg;
15287
15288       if (finallyEntry) {
15289         this.method = "next";
15290         this.next = finallyEntry.finallyLoc;
15291         return ContinueSentinel;
15292       }
15293
15294       return this.complete(record);
15295     },
15296
15297     complete: function(record, afterLoc) {
15298       if (record.type === "throw") {
15299         throw record.arg;
15300       }
15301
15302       if (record.type === "break" ||
15303           record.type === "continue") {
15304         this.next = record.arg;
15305       } else if (record.type === "return") {
15306         this.rval = this.arg = record.arg;
15307         this.method = "return";
15308         this.next = "end";
15309       } else if (record.type === "normal" && afterLoc) {
15310         this.next = afterLoc;
15311       }
15312
15313       return ContinueSentinel;
15314     },
15315
15316     finish: function(finallyLoc) {
15317       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15318         var entry = this.tryEntries[i];
15319         if (entry.finallyLoc === finallyLoc) {
15320           this.complete(entry.completion, entry.afterLoc);
15321           resetTryEntry(entry);
15322           return ContinueSentinel;
15323         }
15324       }
15325     },
15326
15327     "catch": function(tryLoc) {
15328       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15329         var entry = this.tryEntries[i];
15330         if (entry.tryLoc === tryLoc) {
15331           var record = entry.completion;
15332           if (record.type === "throw") {
15333             var thrown = record.arg;
15334             resetTryEntry(entry);
15335           }
15336           return thrown;
15337         }
15338       }
15339
15340       // The context.catch method must only be called with a location
15341       // argument that corresponds to a known catch block.
15342       throw new Error("illegal catch attempt");
15343     },
15344
15345     delegateYield: function(iterable, resultName, nextLoc) {
15346       this.delegate = {
15347         iterator: values(iterable),
15348         resultName: resultName,
15349         nextLoc: nextLoc
15350       };
15351
15352       if (this.method === "next") {
15353         // Deliberately forget the last sent value so that we don't
15354         // accidentally pass it on to the delegate.
15355         this.arg = undefined;
15356       }
15357
15358       return ContinueSentinel;
15359     }
15360   };
15361 })(
15362   // In sloppy mode, unbound `this` refers to the global object, fallback to
15363   // Function constructor if we're in global strict mode. That is sadly a form
15364   // of indirect eval which violates Content Security Policy.
15365   (function() { return this })() || Function("return this")()
15366 );
15367
15368
15369 /***/ }),
15370 /* 156 */
15371 /***/ (function(module, exports, __webpack_require__) {
15372
15373 __webpack_require__(77);
15374 __webpack_require__(132);
15375 __webpack_require__(79);
15376 __webpack_require__(164);
15377 __webpack_require__(173);
15378 __webpack_require__(174);
15379 module.exports = __webpack_require__(8).Promise;
15380
15381
15382 /***/ }),
15383 /* 157 */
15384 /***/ (function(module, exports, __webpack_require__) {
15385
15386 var toInteger = __webpack_require__(52);
15387 var defined = __webpack_require__(51);
15388 // true  -> String#at
15389 // false -> String#codePointAt
15390 module.exports = function (TO_STRING) {
15391   return function (that, pos) {
15392     var s = String(defined(that));
15393     var i = toInteger(pos);
15394     var l = s.length;
15395     var a, b;
15396     if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
15397     a = s.charCodeAt(i);
15398     return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
15399       ? TO_STRING ? s.charAt(i) : a
15400       : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
15401   };
15402 };
15403
15404
15405 /***/ }),
15406 /* 158 */
15407 /***/ (function(module, exports, __webpack_require__) {
15408
15409 "use strict";
15410
15411 var create = __webpack_require__(133);
15412 var descriptor = __webpack_require__(48);
15413 var setToStringTag = __webpack_require__(40);
15414 var IteratorPrototype = {};
15415
15416 // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
15417 __webpack_require__(19)(IteratorPrototype, __webpack_require__(7)('iterator'), function () { return this; });
15418
15419 module.exports = function (Constructor, NAME, next) {
15420   Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
15421   setToStringTag(Constructor, NAME + ' Iterator');
15422 };
15423
15424
15425 /***/ }),
15426 /* 159 */
15427 /***/ (function(module, exports, __webpack_require__) {
15428
15429 var dP = __webpack_require__(16);
15430 var anObject = __webpack_require__(15);
15431 var getKeys = __webpack_require__(39);
15432
15433 module.exports = __webpack_require__(17) ? Object.defineProperties : function defineProperties(O, Properties) {
15434   anObject(O);
15435   var keys = getKeys(Properties);
15436   var length = keys.length;
15437   var i = 0;
15438   var P;
15439   while (length > i) dP.f(O, P = keys[i++], Properties[P]);
15440   return O;
15441 };
15442
15443
15444 /***/ }),
15445 /* 160 */
15446 /***/ (function(module, exports, __webpack_require__) {
15447
15448 // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
15449 var has = __webpack_require__(20);
15450 var toObject = __webpack_require__(54);
15451 var IE_PROTO = __webpack_require__(53)('IE_PROTO');
15452 var ObjectProto = Object.prototype;
15453
15454 module.exports = Object.getPrototypeOf || function (O) {
15455   O = toObject(O);
15456   if (has(O, IE_PROTO)) return O[IE_PROTO];
15457   if (typeof O.constructor == 'function' && O instanceof O.constructor) {
15458     return O.constructor.prototype;
15459   } return O instanceof Object ? ObjectProto : null;
15460 };
15461
15462
15463 /***/ }),
15464 /* 161 */
15465 /***/ (function(module, exports, __webpack_require__) {
15466
15467 "use strict";
15468
15469 var addToUnscopables = __webpack_require__(162);
15470 var step = __webpack_require__(163);
15471 var Iterators = __webpack_require__(28);
15472 var toIObject = __webpack_require__(25);
15473
15474 // 22.1.3.4 Array.prototype.entries()
15475 // 22.1.3.13 Array.prototype.keys()
15476 // 22.1.3.29 Array.prototype.values()
15477 // 22.1.3.30 Array.prototype[@@iterator]()
15478 module.exports = __webpack_require__(85)(Array, 'Array', function (iterated, kind) {
15479   this._t = toIObject(iterated); // target
15480   this._i = 0;                   // next index
15481   this._k = kind;                // kind
15482 // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
15483 }, function () {
15484   var O = this._t;
15485   var kind = this._k;
15486   var index = this._i++;
15487   if (!O || index >= O.length) {
15488     this._t = undefined;
15489     return step(1);
15490   }
15491   if (kind == 'keys') return step(0, index);
15492   if (kind == 'values') return step(0, O[index]);
15493   return step(0, [index, O[index]]);
15494 }, 'values');
15495
15496 // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
15497 Iterators.Arguments = Iterators.Array;
15498
15499 addToUnscopables('keys');
15500 addToUnscopables('values');
15501 addToUnscopables('entries');
15502
15503
15504 /***/ }),
15505 /* 162 */
15506 /***/ (function(module, exports) {
15507
15508 module.exports = function () { /* empty */ };
15509
15510
15511 /***/ }),
15512 /* 163 */
15513 /***/ (function(module, exports) {
15514
15515 module.exports = function (done, value) {
15516   return { value: value, done: !!done };
15517 };
15518
15519
15520 /***/ }),
15521 /* 164 */
15522 /***/ (function(module, exports, __webpack_require__) {
15523
15524 "use strict";
15525
15526 var LIBRARY = __webpack_require__(37);
15527 var global = __webpack_require__(5);
15528 var ctx = __webpack_require__(35);
15529 var classof = __webpack_require__(87);
15530 var $export = __webpack_require__(13);
15531 var isObject = __webpack_require__(12);
15532 var aFunction = __webpack_require__(38);
15533 var anInstance = __webpack_require__(134);
15534 var forOf = __webpack_require__(80);
15535 var speciesConstructor = __webpack_require__(88);
15536 var task = __webpack_require__(89).set;
15537 var microtask = __webpack_require__(169)();
15538 var newPromiseCapabilityModule = __webpack_require__(55);
15539 var perform = __webpack_require__(90);
15540 var userAgent = __webpack_require__(170);
15541 var promiseResolve = __webpack_require__(91);
15542 var PROMISE = 'Promise';
15543 var TypeError = global.TypeError;
15544 var process = global.process;
15545 var versions = process && process.versions;
15546 var v8 = versions && versions.v8 || '';
15547 var $Promise = global[PROMISE];
15548 var isNode = classof(process) == 'process';
15549 var empty = function () { /* empty */ };
15550 var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
15551 var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
15552
15553 var USE_NATIVE = !!function () {
15554   try {
15555     // correct subclassing with @@species support
15556     var promise = $Promise.resolve(1);
15557     var FakePromise = (promise.constructor = {})[__webpack_require__(7)('species')] = function (exec) {
15558       exec(empty, empty);
15559     };
15560     // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
15561     return (isNode || typeof PromiseRejectionEvent == 'function')
15562       && promise.then(empty) instanceof FakePromise
15563       // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
15564       // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
15565       // we can't detect it synchronously, so just check versions
15566       && v8.indexOf('6.6') !== 0
15567       && userAgent.indexOf('Chrome/66') === -1;
15568   } catch (e) { /* empty */ }
15569 }();
15570
15571 // helpers
15572 var isThenable = function (it) {
15573   var then;
15574   return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
15575 };
15576 var notify = function (promise, isReject) {
15577   if (promise._n) return;
15578   promise._n = true;
15579   var chain = promise._c;
15580   microtask(function () {
15581     var value = promise._v;
15582     var ok = promise._s == 1;
15583     var i = 0;
15584     var run = function (reaction) {
15585       var handler = ok ? reaction.ok : reaction.fail;
15586       var resolve = reaction.resolve;
15587       var reject = reaction.reject;
15588       var domain = reaction.domain;
15589       var result, then, exited;
15590       try {
15591         if (handler) {
15592           if (!ok) {
15593             if (promise._h == 2) onHandleUnhandled(promise);
15594             promise._h = 1;
15595           }
15596           if (handler === true) result = value;
15597           else {
15598             if (domain) domain.enter();
15599             result = handler(value); // may throw
15600             if (domain) {
15601               domain.exit();
15602               exited = true;
15603             }
15604           }
15605           if (result === reaction.promise) {
15606             reject(TypeError('Promise-chain cycle'));
15607           } else if (then = isThenable(result)) {
15608             then.call(result, resolve, reject);
15609           } else resolve(result);
15610         } else reject(value);
15611       } catch (e) {
15612         if (domain && !exited) domain.exit();
15613         reject(e);
15614       }
15615     };
15616     while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
15617     promise._c = [];
15618     promise._n = false;
15619     if (isReject && !promise._h) onUnhandled(promise);
15620   });
15621 };
15622 var onUnhandled = function (promise) {
15623   task.call(global, function () {
15624     var value = promise._v;
15625     var unhandled = isUnhandled(promise);
15626     var result, handler, console;
15627     if (unhandled) {
15628       result = perform(function () {
15629         if (isNode) {
15630           process.emit('unhandledRejection', value, promise);
15631         } else if (handler = global.onunhandledrejection) {
15632           handler({ promise: promise, reason: value });
15633         } else if ((console = global.console) && console.error) {
15634           console.error('Unhandled promise rejection', value);
15635         }
15636       });
15637       // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
15638       promise._h = isNode || isUnhandled(promise) ? 2 : 1;
15639     } promise._a = undefined;
15640     if (unhandled && result.e) throw result.v;
15641   });
15642 };
15643 var isUnhandled = function (promise) {
15644   return promise._h !== 1 && (promise._a || promise._c).length === 0;
15645 };
15646 var onHandleUnhandled = function (promise) {
15647   task.call(global, function () {
15648     var handler;
15649     if (isNode) {
15650       process.emit('rejectionHandled', promise);
15651     } else if (handler = global.onrejectionhandled) {
15652       handler({ promise: promise, reason: promise._v });
15653     }
15654   });
15655 };
15656 var $reject = function (value) {
15657   var promise = this;
15658   if (promise._d) return;
15659   promise._d = true;
15660   promise = promise._w || promise; // unwrap
15661   promise._v = value;
15662   promise._s = 2;
15663   if (!promise._a) promise._a = promise._c.slice();
15664   notify(promise, true);
15665 };
15666 var $resolve = function (value) {
15667   var promise = this;
15668   var then;
15669   if (promise._d) return;
15670   promise._d = true;
15671   promise = promise._w || promise; // unwrap
15672   try {
15673     if (promise === value) throw TypeError("Promise can't be resolved itself");
15674     if (then = isThenable(value)) {
15675       microtask(function () {
15676         var wrapper = { _w: promise, _d: false }; // wrap
15677         try {
15678           then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
15679         } catch (e) {
15680           $reject.call(wrapper, e);
15681         }
15682       });
15683     } else {
15684       promise._v = value;
15685       promise._s = 1;
15686       notify(promise, false);
15687     }
15688   } catch (e) {
15689     $reject.call({ _w: promise, _d: false }, e); // wrap
15690   }
15691 };
15692
15693 // constructor polyfill
15694 if (!USE_NATIVE) {
15695   // 25.4.3.1 Promise(executor)
15696   $Promise = function Promise(executor) {
15697     anInstance(this, $Promise, PROMISE, '_h');
15698     aFunction(executor);
15699     Internal.call(this);
15700     try {
15701       executor(ctx($resolve, this, 1), ctx($reject, this, 1));
15702     } catch (err) {
15703       $reject.call(this, err);
15704     }
15705   };
15706   // eslint-disable-next-line no-unused-vars
15707   Internal = function Promise(executor) {
15708     this._c = [];             // <- awaiting reactions
15709     this._a = undefined;      // <- checked in isUnhandled reactions
15710     this._s = 0;              // <- state
15711     this._d = false;          // <- done
15712     this._v = undefined;      // <- value
15713     this._h = 0;              // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
15714     this._n = false;          // <- notify
15715   };
15716   Internal.prototype = __webpack_require__(135)($Promise.prototype, {
15717     // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
15718     then: function then(onFulfilled, onRejected) {
15719       var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
15720       reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
15721       reaction.fail = typeof onRejected == 'function' && onRejected;
15722       reaction.domain = isNode ? process.domain : undefined;
15723       this._c.push(reaction);
15724       if (this._a) this._a.push(reaction);
15725       if (this._s) notify(this, false);
15726       return reaction.promise;
15727     },
15728     // 25.4.5.1 Promise.prototype.catch(onRejected)
15729     'catch': function (onRejected) {
15730       return this.then(undefined, onRejected);
15731     }
15732   });
15733   OwnPromiseCapability = function () {
15734     var promise = new Internal();
15735     this.promise = promise;
15736     this.resolve = ctx($resolve, promise, 1);
15737     this.reject = ctx($reject, promise, 1);
15738   };
15739   newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
15740     return C === $Promise || C === Wrapper
15741       ? new OwnPromiseCapability(C)
15742       : newGenericPromiseCapability(C);
15743   };
15744 }
15745
15746 $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
15747 __webpack_require__(40)($Promise, PROMISE);
15748 __webpack_require__(171)(PROMISE);
15749 Wrapper = __webpack_require__(8)[PROMISE];
15750
15751 // statics
15752 $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
15753   // 25.4.4.5 Promise.reject(r)
15754   reject: function reject(r) {
15755     var capability = newPromiseCapability(this);
15756     var $$reject = capability.reject;
15757     $$reject(r);
15758     return capability.promise;
15759   }
15760 });
15761 $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
15762   // 25.4.4.6 Promise.resolve(x)
15763   resolve: function resolve(x) {
15764     return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
15765   }
15766 });
15767 $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(172)(function (iter) {
15768   $Promise.all(iter)['catch'](empty);
15769 })), PROMISE, {
15770   // 25.4.4.1 Promise.all(iterable)
15771   all: function all(iterable) {
15772     var C = this;
15773     var capability = newPromiseCapability(C);
15774     var resolve = capability.resolve;
15775     var reject = capability.reject;
15776     var result = perform(function () {
15777       var values = [];
15778       var index = 0;
15779       var remaining = 1;
15780       forOf(iterable, false, function (promise) {
15781         var $index = index++;
15782         var alreadyCalled = false;
15783         values.push(undefined);
15784         remaining++;
15785         C.resolve(promise).then(function (value) {
15786           if (alreadyCalled) return;
15787           alreadyCalled = true;
15788           values[$index] = value;
15789           --remaining || resolve(values);
15790         }, reject);
15791       });
15792       --remaining || resolve(values);
15793     });
15794     if (result.e) reject(result.v);
15795     return capability.promise;
15796   },
15797   // 25.4.4.4 Promise.race(iterable)
15798   race: function race(iterable) {
15799     var C = this;
15800     var capability = newPromiseCapability(C);
15801     var reject = capability.reject;
15802     var result = perform(function () {
15803       forOf(iterable, false, function (promise) {
15804         C.resolve(promise).then(capability.resolve, reject);
15805       });
15806     });
15807     if (result.e) reject(result.v);
15808     return capability.promise;
15809   }
15810 });
15811
15812
15813 /***/ }),
15814 /* 165 */
15815 /***/ (function(module, exports, __webpack_require__) {
15816
15817 // call something on iterator step with safe closing on error
15818 var anObject = __webpack_require__(15);
15819 module.exports = function (iterator, fn, value, entries) {
15820   try {
15821     return entries ? fn(anObject(value)[0], value[1]) : fn(value);
15822   // 7.4.6 IteratorClose(iterator, completion)
15823   } catch (e) {
15824     var ret = iterator['return'];
15825     if (ret !== undefined) anObject(ret.call(iterator));
15826     throw e;
15827   }
15828 };
15829
15830
15831 /***/ }),
15832 /* 166 */
15833 /***/ (function(module, exports, __webpack_require__) {
15834
15835 // check on default Array iterator
15836 var Iterators = __webpack_require__(28);
15837 var ITERATOR = __webpack_require__(7)('iterator');
15838 var ArrayProto = Array.prototype;
15839
15840 module.exports = function (it) {
15841   return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
15842 };
15843
15844
15845 /***/ }),
15846 /* 167 */
15847 /***/ (function(module, exports, __webpack_require__) {
15848
15849 var classof = __webpack_require__(87);
15850 var ITERATOR = __webpack_require__(7)('iterator');
15851 var Iterators = __webpack_require__(28);
15852 module.exports = __webpack_require__(8).getIteratorMethod = function (it) {
15853   if (it != undefined) return it[ITERATOR]
15854     || it['@@iterator']
15855     || Iterators[classof(it)];
15856 };
15857
15858
15859 /***/ }),
15860 /* 168 */
15861 /***/ (function(module, exports) {
15862
15863 // fast apply, http://jsperf.lnkit.com/fast-apply/5
15864 module.exports = function (fn, args, that) {
15865   var un = that === undefined;
15866   switch (args.length) {
15867     case 0: return un ? fn()
15868                       : fn.call(that);
15869     case 1: return un ? fn(args[0])
15870                       : fn.call(that, args[0]);
15871     case 2: return un ? fn(args[0], args[1])
15872                       : fn.call(that, args[0], args[1]);
15873     case 3: return un ? fn(args[0], args[1], args[2])
15874                       : fn.call(that, args[0], args[1], args[2]);
15875     case 4: return un ? fn(args[0], args[1], args[2], args[3])
15876                       : fn.call(that, args[0], args[1], args[2], args[3]);
15877   } return fn.apply(that, args);
15878 };
15879
15880
15881 /***/ }),
15882 /* 169 */
15883 /***/ (function(module, exports, __webpack_require__) {
15884
15885 var global = __webpack_require__(5);
15886 var macrotask = __webpack_require__(89).set;
15887 var Observer = global.MutationObserver || global.WebKitMutationObserver;
15888 var process = global.process;
15889 var Promise = global.Promise;
15890 var isNode = __webpack_require__(27)(process) == 'process';
15891
15892 module.exports = function () {
15893   var head, last, notify;
15894
15895   var flush = function () {
15896     var parent, fn;
15897     if (isNode && (parent = process.domain)) parent.exit();
15898     while (head) {
15899       fn = head.fn;
15900       head = head.next;
15901       try {
15902         fn();
15903       } catch (e) {
15904         if (head) notify();
15905         else last = undefined;
15906         throw e;
15907       }
15908     } last = undefined;
15909     if (parent) parent.enter();
15910   };
15911
15912   // Node.js
15913   if (isNode) {
15914     notify = function () {
15915       process.nextTick(flush);
15916     };
15917   // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
15918   } else if (Observer && !(global.navigator && global.navigator.standalone)) {
15919     var toggle = true;
15920     var node = document.createTextNode('');
15921     new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
15922     notify = function () {
15923       node.data = toggle = !toggle;
15924     };
15925   // environments with maybe non-completely correct, but existent Promise
15926   } else if (Promise && Promise.resolve) {
15927     // Promise.resolve without an argument throws an error in LG WebOS 2
15928     var promise = Promise.resolve(undefined);
15929     notify = function () {
15930       promise.then(flush);
15931     };
15932   // for other environments - macrotask based on:
15933   // - setImmediate
15934   // - MessageChannel
15935   // - window.postMessag
15936   // - onreadystatechange
15937   // - setTimeout
15938   } else {
15939     notify = function () {
15940       // strange IE + webpack dev server bug - use .call(global)
15941       macrotask.call(global, flush);
15942     };
15943   }
15944
15945   return function (fn) {
15946     var task = { fn: fn, next: undefined };
15947     if (last) last.next = task;
15948     if (!head) {
15949       head = task;
15950       notify();
15951     } last = task;
15952   };
15953 };
15954
15955
15956 /***/ }),
15957 /* 170 */
15958 /***/ (function(module, exports, __webpack_require__) {
15959
15960 var global = __webpack_require__(5);
15961 var navigator = global.navigator;
15962
15963 module.exports = navigator && navigator.userAgent || '';
15964
15965
15966 /***/ }),
15967 /* 171 */
15968 /***/ (function(module, exports, __webpack_require__) {
15969
15970 "use strict";
15971
15972 var global = __webpack_require__(5);
15973 var core = __webpack_require__(8);
15974 var dP = __webpack_require__(16);
15975 var DESCRIPTORS = __webpack_require__(17);
15976 var SPECIES = __webpack_require__(7)('species');
15977
15978 module.exports = function (KEY) {
15979   var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
15980   if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
15981     configurable: true,
15982     get: function () { return this; }
15983   });
15984 };
15985
15986
15987 /***/ }),
15988 /* 172 */
15989 /***/ (function(module, exports, __webpack_require__) {
15990
15991 var ITERATOR = __webpack_require__(7)('iterator');
15992 var SAFE_CLOSING = false;
15993
15994 try {
15995   var riter = [7][ITERATOR]();
15996   riter['return'] = function () { SAFE_CLOSING = true; };
15997   // eslint-disable-next-line no-throw-literal
15998   Array.from(riter, function () { throw 2; });
15999 } catch (e) { /* empty */ }
16000
16001 module.exports = function (exec, skipClosing) {
16002   if (!skipClosing && !SAFE_CLOSING) return false;
16003   var safe = false;
16004   try {
16005     var arr = [7];
16006     var iter = arr[ITERATOR]();
16007     iter.next = function () { return { done: safe = true }; };
16008     arr[ITERATOR] = function () { return iter; };
16009     exec(arr);
16010   } catch (e) { /* empty */ }
16011   return safe;
16012 };
16013
16014
16015 /***/ }),
16016 /* 173 */
16017 /***/ (function(module, exports, __webpack_require__) {
16018
16019 "use strict";
16020 // https://github.com/tc39/proposal-promise-finally
16021
16022 var $export = __webpack_require__(13);
16023 var core = __webpack_require__(8);
16024 var global = __webpack_require__(5);
16025 var speciesConstructor = __webpack_require__(88);
16026 var promiseResolve = __webpack_require__(91);
16027
16028 $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
16029   var C = speciesConstructor(this, core.Promise || global.Promise);
16030   var isFunction = typeof onFinally == 'function';
16031   return this.then(
16032     isFunction ? function (x) {
16033       return promiseResolve(C, onFinally()).then(function () { return x; });
16034     } : onFinally,
16035     isFunction ? function (e) {
16036       return promiseResolve(C, onFinally()).then(function () { throw e; });
16037     } : onFinally
16038   );
16039 } });
16040
16041
16042 /***/ }),
16043 /* 174 */
16044 /***/ (function(module, exports, __webpack_require__) {
16045
16046 "use strict";
16047
16048 // https://github.com/tc39/proposal-promise-try
16049 var $export = __webpack_require__(13);
16050 var newPromiseCapability = __webpack_require__(55);
16051 var perform = __webpack_require__(90);
16052
16053 $export($export.S, 'Promise', { 'try': function (callbackfn) {
16054   var promiseCapability = newPromiseCapability.f(this);
16055   var result = perform(callbackfn);
16056   (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
16057   return promiseCapability.promise;
16058 } });
16059
16060
16061 /***/ }),
16062 /* 175 */
16063 /***/ (function(module, exports, __webpack_require__) {
16064
16065 "use strict";
16066
16067
16068 exports.byteLength = byteLength
16069 exports.toByteArray = toByteArray
16070 exports.fromByteArray = fromByteArray
16071
16072 var lookup = []
16073 var revLookup = []
16074 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
16075
16076 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
16077 for (var i = 0, len = code.length; i < len; ++i) {
16078   lookup[i] = code[i]
16079   revLookup[code.charCodeAt(i)] = i
16080 }
16081
16082 // Support decoding URL-safe base64 strings, as Node.js does.
16083 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
16084 revLookup['-'.charCodeAt(0)] = 62
16085 revLookup['_'.charCodeAt(0)] = 63
16086
16087 function getLens (b64) {
16088   var len = b64.length
16089
16090   if (len % 4 > 0) {
16091     throw new Error('Invalid string. Length must be a multiple of 4')
16092   }
16093
16094   // Trim off extra bytes after placeholder bytes are found
16095   // See: https://github.com/beatgammit/base64-js/issues/42
16096   var validLen = b64.indexOf('=')
16097   if (validLen === -1) validLen = len
16098
16099   var placeHoldersLen = validLen === len
16100     ? 0
16101     : 4 - (validLen % 4)
16102
16103   return [validLen, placeHoldersLen]
16104 }
16105
16106 // base64 is 4/3 + up to two characters of the original data
16107 function byteLength (b64) {
16108   var lens = getLens(b64)
16109   var validLen = lens[0]
16110   var placeHoldersLen = lens[1]
16111   return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
16112 }
16113
16114 function _byteLength (b64, validLen, placeHoldersLen) {
16115   return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
16116 }
16117
16118 function toByteArray (b64) {
16119   var tmp
16120   var lens = getLens(b64)
16121   var validLen = lens[0]
16122   var placeHoldersLen = lens[1]
16123
16124   var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
16125
16126   var curByte = 0
16127
16128   // if there are placeholders, only get up to the last complete 4 chars
16129   var len = placeHoldersLen > 0
16130     ? validLen - 4
16131     : validLen
16132
16133   for (var i = 0; i < len; i += 4) {
16134     tmp =
16135       (revLookup[b64.charCodeAt(i)] << 18) |
16136       (revLookup[b64.charCodeAt(i + 1)] << 12) |
16137       (revLookup[b64.charCodeAt(i + 2)] << 6) |
16138       revLookup[b64.charCodeAt(i + 3)]
16139     arr[curByte++] = (tmp >> 16) & 0xFF
16140     arr[curByte++] = (tmp >> 8) & 0xFF
16141     arr[curByte++] = tmp & 0xFF
16142   }
16143
16144   if (placeHoldersLen === 2) {
16145     tmp =
16146       (revLookup[b64.charCodeAt(i)] << 2) |
16147       (revLookup[b64.charCodeAt(i + 1)] >> 4)
16148     arr[curByte++] = tmp & 0xFF
16149   }
16150
16151   if (placeHoldersLen === 1) {
16152     tmp =
16153       (revLookup[b64.charCodeAt(i)] << 10) |
16154       (revLookup[b64.charCodeAt(i + 1)] << 4) |
16155       (revLookup[b64.charCodeAt(i + 2)] >> 2)
16156     arr[curByte++] = (tmp >> 8) & 0xFF
16157     arr[curByte++] = tmp & 0xFF
16158   }
16159
16160   return arr
16161 }
16162
16163 function tripletToBase64 (num) {
16164   return lookup[num >> 18 & 0x3F] +
16165     lookup[num >> 12 & 0x3F] +
16166     lookup[num >> 6 & 0x3F] +
16167     lookup[num & 0x3F]
16168 }
16169
16170 function encodeChunk (uint8, start, end) {
16171   var tmp
16172   var output = []
16173   for (var i = start; i < end; i += 3) {
16174     tmp =
16175       ((uint8[i] << 16) & 0xFF0000) +
16176       ((uint8[i + 1] << 8) & 0xFF00) +
16177       (uint8[i + 2] & 0xFF)
16178     output.push(tripletToBase64(tmp))
16179   }
16180   return output.join('')
16181 }
16182
16183 function fromByteArray (uint8) {
16184   var tmp
16185   var len = uint8.length
16186   var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
16187   var parts = []
16188   var maxChunkLength = 16383 // must be multiple of 3
16189
16190   // go through the array every three bytes, we'll deal with trailing stuff later
16191   for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
16192     parts.push(encodeChunk(
16193       uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
16194     ))
16195   }
16196
16197   // pad the end with zeros, but make sure to not forget the extra bytes
16198   if (extraBytes === 1) {
16199     tmp = uint8[len - 1]
16200     parts.push(
16201       lookup[tmp >> 2] +
16202       lookup[(tmp << 4) & 0x3F] +
16203       '=='
16204     )
16205   } else if (extraBytes === 2) {
16206     tmp = (uint8[len - 2] << 8) + uint8[len - 1]
16207     parts.push(
16208       lookup[tmp >> 10] +
16209       lookup[(tmp >> 4) & 0x3F] +
16210       lookup[(tmp << 2) & 0x3F] +
16211       '='
16212     )
16213   }
16214
16215   return parts.join('')
16216 }
16217
16218
16219 /***/ }),
16220 /* 176 */
16221 /***/ (function(module, exports) {
16222
16223 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
16224   var e, m
16225   var eLen = (nBytes * 8) - mLen - 1
16226   var eMax = (1 << eLen) - 1
16227   var eBias = eMax >> 1
16228   var nBits = -7
16229   var i = isLE ? (nBytes - 1) : 0
16230   var d = isLE ? -1 : 1
16231   var s = buffer[offset + i]
16232
16233   i += d
16234
16235   e = s & ((1 << (-nBits)) - 1)
16236   s >>= (-nBits)
16237   nBits += eLen
16238   for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
16239
16240   m = e & ((1 << (-nBits)) - 1)
16241   e >>= (-nBits)
16242   nBits += mLen
16243   for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
16244
16245   if (e === 0) {
16246     e = 1 - eBias
16247   } else if (e === eMax) {
16248     return m ? NaN : ((s ? -1 : 1) * Infinity)
16249   } else {
16250     m = m + Math.pow(2, mLen)
16251     e = e - eBias
16252   }
16253   return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
16254 }
16255
16256 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
16257   var e, m, c
16258   var eLen = (nBytes * 8) - mLen - 1
16259   var eMax = (1 << eLen) - 1
16260   var eBias = eMax >> 1
16261   var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
16262   var i = isLE ? 0 : (nBytes - 1)
16263   var d = isLE ? 1 : -1
16264   var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
16265
16266   value = Math.abs(value)
16267
16268   if (isNaN(value) || value === Infinity) {
16269     m = isNaN(value) ? 1 : 0
16270     e = eMax
16271   } else {
16272     e = Math.floor(Math.log(value) / Math.LN2)
16273     if (value * (c = Math.pow(2, -e)) < 1) {
16274       e--
16275       c *= 2
16276     }
16277     if (e + eBias >= 1) {
16278       value += rt / c
16279     } else {
16280       value += rt * Math.pow(2, 1 - eBias)
16281     }
16282     if (value * c >= 2) {
16283       e++
16284       c /= 2
16285     }
16286
16287     if (e + eBias >= eMax) {
16288       m = 0
16289       e = eMax
16290     } else if (e + eBias >= 1) {
16291       m = ((value * c) - 1) * Math.pow(2, mLen)
16292       e = e + eBias
16293     } else {
16294       m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
16295       e = 0
16296     }
16297   }
16298
16299   for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
16300
16301   e = (e << mLen) | m
16302   eLen += mLen
16303   for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
16304
16305   buffer[offset + i - d] |= s * 128
16306 }
16307
16308
16309 /***/ }),
16310 /* 177 */,
16311 /* 178 */,
16312 /* 179 */
16313 /***/ (function(module, exports, __webpack_require__) {
16314
16315 "use strict";
16316 \r
16317 Object.defineProperty(exports, "__esModule", { value: true });\r
16318 const aes_oop_1 = __webpack_require__(180);\r
16319 class EncryptedStream {\r
16320     constructor(_eventName, _randomized) {\r
16321         this.eventName = _eventName;\r
16322         this.key = _randomized;\r
16323         this.synced = false;\r
16324         this.syncFn = null;\r
16325         this.listenForSync();\r
16326     }\r
16327     listenWith(func) {\r
16328         document.addEventListener(this.eventName, (event) => {\r
16329             if (!this.synced) return false;\r
16330             let msg = JSON.parse(event.detail);\r
16331             msg = (this.synced && typeof msg === 'string') ? aes_oop_1.default.decrypt(msg, this.key) : msg;\r
16332             func(msg);\r
16333         });\r
16334     }\r
16335     send(data, to) {\r
16336         const addSender = () => { data.from = this.eventName; };\r
16337         const encryptIfSynced = () => { data = (this.synced) ? aes_oop_1.default.encrypt(data, this.key) : data; };\r
16338         if (typeof data !== 'object')\r
16339             throw new Error("Payloads must be objects");\r
16340         addSender();\r
16341         encryptIfSynced();\r
16342         this.dispatch(JSON.stringify(data), to);\r
16343     }\r
16344     onSync(fn) {\r
16345         this.syncFn = fn;\r
16346     }\r
16347     sync(to, handshake) {\r
16348         this.send({ type: 'sync', handshake }, to);\r
16349     }\r
16350     listenForSync() {\r
16351         document.addEventListener(this.eventName, (event) => {\r
16352             let msg = JSON.parse(event.detail);\r
16353             if(!msg.hasOwnProperty('type')) return false;\r
16354             if(msg.type === 'sync') this.ackSync(msg);\r
16355             if(msg.type === 'synced') this.synced = true;\r
16356         });\r
16357     }\r
16358     ackSync(msg) {\r
16359         this.send({ type: 'synced' }, msg.from);\r
16360         this.key = msg.handshake;\r
16361         this.synced = true;\r
16362         this.syncFn();\r
16363     }\r
16364     dispatch(encryptedData, to) { document.dispatchEvent(this.getEvent(encryptedData, to)); }\r
16365     getEvent(encryptedData, to) { return new CustomEvent(to, this.getEventInit(encryptedData)); }\r
16366     getEventInit(encryptedData) { return { detail: encryptedData }; }\r
16367 }\r
16368 exports.EncryptedStream = EncryptedStream;\r
16369 exports.default = EncryptedStream;\r
16370 //# sourceMappingURL=EncryptedStream.js.map
16371
16372 /***/ }),
16373 /* 180 */
16374 /***/ (function(module, exports, __webpack_require__) {
16375
16376 "use strict";
16377 \r
16378 const sjcl = __webpack_require__(181);\r
16379 class AES {\r
16380     static encrypt(data, key) {\r
16381         if (typeof data === 'object')\r
16382             data = JSON.stringify(data);\r
16383         const { iv, salt, ct } = JSON.parse(sjcl.encrypt(key, data, { mode: 'gcm' }));\r
16384         return JSON.stringify({ iv, salt, ct });\r
16385     }\r
16386     static decrypt(encryptedData, key) {\r
16387         encryptedData = JSON.stringify(Object.assign(JSON.parse(encryptedData), { mode: 'gcm' }));\r
16388         let clear = sjcl.decrypt(key, encryptedData);\r
16389         try {\r
16390             return JSON.parse(clear);\r
16391         }\r
16392         catch (e) {\r
16393             return clear;\r
16394         }\r
16395     }\r
16396 }\r
16397 exports.AES = AES;\r
16398 Object.defineProperty(exports, "__esModule", { value: true });\r
16399 exports.default = AES;\r
16400 //# sourceMappingURL=AES.js.map
16401
16402 /***/ }),
16403 /* 181 */
16404 /***/ (function(module, exports, __webpack_require__) {
16405
16406 "use strict";
16407 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
16408 sjcl.cipher.aes=function(a){this.s[0][0][0]||this.O();var b,c,d,e,f=this.s[0][4],g=this.s[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c&
16409 255]]};
16410 sjcl.cipher.aes.prototype={encrypt:function(a){return t(this,a,0)},decrypt:function(a){return t(this,a,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var a=this.s[0],b=this.s[1],c=a[4],d=b[4],e,f,g,h=[],k=[],l,n,m,p;for(e=0;0x100>e;e++)k[(h[e]=e<<1^283*(e>>7))^e]=e;for(f=g=0;!c[f];f^=l||1,g=k[g]||1)for(m=g^g<<1^g<<2^g<<3^g<<4,m=m>>8^m&255^99,c[f]=m,d[m]=f,n=h[e=h[l=h[f]]],p=0x1010101*n^0x10001*e^0x101*l^0x1010100*f,n=0x101*h[m]^0x1010100*m,e=0;4>e;e++)a[e][f]=n=n<<24^n>>>8,b[e][m]=p=p<<24^p>>>8;for(e=
16411 0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}};
16412 function t(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid("invalid aes block size");var d=a.b[c],e=b[0]^d[0],f=b[c?3:1]^d[1],g=b[2]^d[2];b=b[c?1:3]^d[3];var h,k,l,n=d.length/4-2,m,p=4,r=[0,0,0,0];h=a.s[c];a=h[0];var q=h[1],v=h[2],w=h[3],x=h[4];for(m=0;m<n;m++)h=a[e>>>24]^q[f>>16&255]^v[g>>8&255]^w[b&255]^d[p],k=a[f>>>24]^q[g>>16&255]^v[b>>8&255]^w[e&255]^d[p+1],l=a[g>>>24]^q[b>>16&255]^v[e>>8&255]^w[f&255]^d[p+2],b=a[b>>>24]^q[e>>16&255]^v[f>>8&255]^w[g&255]^d[p+3],p+=4,e=h,f=k,g=l;for(m=
16413 0;4>m;m++)r[c?3&-m:m]=x[e>>>24]<<24^x[f>>16&255]<<16^x[g>>8&255]<<8^x[b&255]^d[p++],h=e,e=f,f=g,g=b,b=h;return r}
16414 sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.$(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<<c)-1},concat:function(a,b){if(0===a.length||0===b.length)return a.concat(b);var c=a[a.length-1],d=sjcl.bitArray.getPartial(c);return 32===d?a.concat(b):sjcl.bitArray.$(b,d,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;return 0===
16415 b?0:32*(b-1)+sjcl.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(32*a.length<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b=b&31;0<c&&b&&(a[c-1]=sjcl.bitArray.partial(b,a[c-1]&2147483648>>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return!1;var c=0,d;for(d=0;d<a.length;d++)c|=a[d]^b[d];return 0===
16416 c},$:function(a,b,c,d){var e;e=0;for(void 0===d&&(d=[]);32<=b;b-=32)d.push(c),c=0;if(0===b)return d.concat(a);for(e=0;e<a.length;e++)d.push(c|a[e]>>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32<b+a?c:d.pop(),1));return d},i:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]},byteswapM:function(a){var b,c;for(b=0;b<a.length;++b)c=a[b],a[b]=c>>>24|c>>>8&0xff00|(c&0xff00)<<8|c<<24;return a}};
16417 sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d<c/8;d++)0===(d&3)&&(e=a[d/4]),b+=String.fromCharCode(e>>>8>>>8>>>8),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c<a.length;c++)d=d<<8|a.charCodeAt(c),3===(c&3)&&(b.push(d),d=0);c&3&&b.push(sjcl.bitArray.partial(8*(c&3),d));return b}};
16418 sjcl.codec.hex={fromBits:function(a){var b="",c;for(c=0;c<a.length;c++)b+=((a[c]|0)+0xf00000000000).toString(16).substr(4);return b.substr(0,sjcl.bitArray.bitLength(a)/4)},toBits:function(a){var b,c=[],d;a=a.replace(/\s|0x/g,"");d=a.length;a=a+"00000000";for(b=0;b<a.length;b+=8)c.push(parseInt(a.substr(b,8),16)^0);return sjcl.bitArray.clamp(c,4*d)}};
16419 sjcl.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(a,b,c){var d=sjcl.codec.base32.BASE,e=sjcl.codec.base32.REMAINING,f="",g=0,h=sjcl.codec.base32.B,k=0,l=sjcl.bitArray.bitLength(a);c&&(h=sjcl.codec.base32.X);for(c=0;f.length*d<l;)f+=h.charAt((k^a[c]>>>g)>>>e),g<d?(k=a[c]<<d-g,g+=e,c++):(k<<=d,g-=d);for(;f.length&7&&!b;)f+="=";return f},toBits:function(a,b){a=a.replace(/\s|=/g,"").toUpperCase();var c=sjcl.codec.base32.BITS,
16420 d=sjcl.codec.base32.BASE,e=sjcl.codec.base32.REMAINING,f=[],g,h=0,k=sjcl.codec.base32.B,l=0,n,m="base32";b&&(k=sjcl.codec.base32.X,m="base32hex");for(g=0;g<a.length;g++){n=k.indexOf(a.charAt(g));if(0>n){if(!b)try{return sjcl.codec.base32hex.toBits(a)}catch(p){}throw new sjcl.exception.invalid("this isn't "+m+"!");}h>e?(h-=e,f.push(l^n>>>h),l=n<<c-h):(h+=d,l^=n<<c-h)}h&56&&f.push(sjcl.bitArray.partial(h&56,l,1));return f}};
16421 sjcl.codec.base32hex={fromBits:function(a,b){return sjcl.codec.base32.fromBits(a,b,1)},toBits:function(a){return sjcl.codec.base32.toBits(a,1)}};
16422 sjcl.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(a,b,c){var d="",e=0,f=sjcl.codec.base64.B,g=0,h=sjcl.bitArray.bitLength(a);c&&(f=f.substr(0,62)+"-_");for(c=0;6*d.length<h;)d+=f.charAt((g^a[c]>>>e)>>>26),6>e?(g=a[c]<<6-e,e+=26,c++):(g<<=6,e-=6);for(;d.length&3&&!b;)d+="=";return d},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],d,e=0,f=sjcl.codec.base64.B,g=0,h;b&&(f=f.substr(0,62)+"-_");for(d=0;d<a.length;d++){h=f.indexOf(a.charAt(d));
16423 if(0>h)throw new sjcl.exception.invalid("this isn't base64!");26<e?(e-=26,c.push(g^h>>>e),g=h<<32-e):(e+=6,g^=h<<32-e)}e&56&&c.push(sjcl.bitArray.partial(e&56,g,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.b[0]||this.O();a?(this.F=a.F.slice(0),this.A=a.A.slice(0),this.l=a.l):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};
16424 sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.F=this.Y.slice(0);this.A=[];this.l=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.A=sjcl.bitArray.concat(this.A,a);b=this.l;a=this.l=b+sjcl.bitArray.bitLength(a);if(0x1fffffffffffff<a)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var d=new Uint32Array(c),e=0;for(b=512+b-(512+b&0x1ff);b<=a;b+=512)u(this,d.subarray(16*e,
16425 16*(e+1))),e+=1;c.splice(0,16*e)}else for(b=512+b-(512+b&0x1ff);b<=a;b+=512)u(this,c.splice(0,16));return this},finalize:function(){var a,b=this.A,c=this.F,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.l/0x100000000));for(b.push(this.l|0);b.length;)u(this,b.splice(0,16));this.reset();return c},Y:[],b:[],O:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}for(var b=0,c=2,d,e;64>b;c++){e=!0;for(d=2;d*d<=c;d++)if(0===c%d){e=
16426 !1;break}e&&(8>b&&(this.Y[b]=a(Math.pow(c,.5))),this.b[b]=a(Math.pow(c,1/3)),b++)}}};
16427 function u(a,b){var c,d,e,f=a.F,g=a.b,h=f[0],k=f[1],l=f[2],n=f[3],m=f[4],p=f[5],r=f[6],q=f[7];for(c=0;64>c;c++)16>c?d=b[c]:(d=b[c+1&15],e=b[c+14&15],d=b[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+b[c&15]+b[c+9&15]|0),d=d+q+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(r^m&(p^r))+g[c],q=r,r=p,p=m,m=n+d|0,n=l,l=k,k=h,h=d+(k&l^n&(k^l))+(k>>>2^k>>>13^k>>>22^k<<30^k<<19^k<<10)|0;f[0]=f[0]+h|0;f[1]=f[1]+k|0;f[2]=f[2]+l|0;f[3]=f[3]+n|0;f[4]=f[4]+m|0;f[5]=f[5]+p|0;f[6]=f[6]+r|0;f[7]=
16428 f[7]+q|0}
16429 sjcl.mode.ccm={name:"ccm",G:[],listenProgress:function(a){sjcl.mode.ccm.G.push(a)},unListenProgress:function(a){a=sjcl.mode.ccm.G.indexOf(a);-1<a&&sjcl.mode.ccm.G.splice(a,1)},fa:function(a){var b=sjcl.mode.ccm.G.slice(),c;for(c=0;c<b.length;c+=1)b[c](a)},encrypt:function(a,b,c,d,e){var f,g=b.slice(0),h=sjcl.bitArray,k=h.bitLength(c)/8,l=h.bitLength(g)/8;e=e||64;d=d||[];if(7>k)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(f=2;4>f&&l>>>8*f;f++);f<15-k&&(f=15-k);c=h.clamp(c,
16430 8*(15-f));b=sjcl.mode.ccm.V(a,b,c,d,e,f);g=sjcl.mode.ccm.C(a,g,c,b,e,f);return h.concat(g.data,g.tag)},decrypt:function(a,b,c,d,e){e=e||64;d=d||[];var f=sjcl.bitArray,g=f.bitLength(c)/8,h=f.bitLength(b),k=f.clamp(b,h-e),l=f.bitSlice(b,h-e),h=(h-e)/8;if(7>g)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(b=2;4>b&&h>>>8*b;b++);b<15-g&&(b=15-g);c=f.clamp(c,8*(15-b));k=sjcl.mode.ccm.C(a,k,c,l,e,b);a=sjcl.mode.ccm.V(a,k.data,c,d,e,b);if(!f.equal(k.tag,a))throw new sjcl.exception.corrupt("ccm: tag doesn't match");
16431 return k.data},na:function(a,b,c,d,e,f){var g=[],h=sjcl.bitArray,k=h.i;d=[h.partial(8,(b.length?64:0)|d-2<<2|f-1)];d=h.concat(d,c);d[3]|=e;d=a.encrypt(d);if(b.length)for(c=h.bitLength(b)/8,65279>=c?g=[h.partial(16,c)]:0xffffffff>=c&&(g=h.concat([h.partial(16,65534)],[c])),g=h.concat(g,b),b=0;b<g.length;b+=4)d=a.encrypt(k(d,g.slice(b,b+4).concat([0,0,0])));return d},V:function(a,b,c,d,e,f){var g=sjcl.bitArray,h=g.i;e/=8;if(e%2||4>e||16<e)throw new sjcl.exception.invalid("ccm: invalid tag length");
16432 if(0xffffffff<d.length||0xffffffff<b.length)throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data");c=sjcl.mode.ccm.na(a,d,c,e,g.bitLength(b)/8,f);for(d=0;d<b.length;d+=4)c=a.encrypt(h(c,b.slice(d,d+4).concat([0,0,0])));return g.clamp(c,8*e)},C:function(a,b,c,d,e,f){var g,h=sjcl.bitArray;g=h.i;var k=b.length,l=h.bitLength(b),n=k/50,m=n;c=h.concat([h.partial(8,f-1)],c).concat([0,0,0]).slice(0,4);d=h.bitSlice(g(d,a.encrypt(c)),0,e);if(!k)return{tag:d,data:[]};for(g=0;g<k;g+=4)g>n&&(sjcl.mode.ccm.fa(g/
16433 k),n+=m),c[3]++,e=a.encrypt(c),b[g]^=e[0],b[g+1]^=e[1],b[g+2]^=e[2],b[g+3]^=e[3];return{tag:d,data:h.clamp(b,l)}}};
16434 sjcl.mode.ocb2={name:"ocb2",encrypt:function(a,b,c,d,e,f){if(128!==sjcl.bitArray.bitLength(c))throw new sjcl.exception.invalid("ocb iv must be 128 bits");var g,h=sjcl.mode.ocb2.S,k=sjcl.bitArray,l=k.i,n=[0,0,0,0];c=h(a.encrypt(c));var m,p=[];d=d||[];e=e||64;for(g=0;g+4<b.length;g+=4)m=b.slice(g,g+4),n=l(n,m),p=p.concat(l(c,a.encrypt(l(c,m)))),c=h(c);m=b.slice(g);b=k.bitLength(m);g=a.encrypt(l(c,[0,0,0,b]));m=k.clamp(l(m.concat([0,0,0]),g),b);n=l(n,l(m.concat([0,0,0]),g));n=a.encrypt(l(n,l(c,h(c))));
16435 d.length&&(n=l(n,f?d:sjcl.mode.ocb2.pmac(a,d)));return p.concat(k.concat(m,k.clamp(n,e)))},decrypt:function(a,b,c,d,e,f){if(128!==sjcl.bitArray.bitLength(c))throw new sjcl.exception.invalid("ocb iv must be 128 bits");e=e||64;var g=sjcl.mode.ocb2.S,h=sjcl.bitArray,k=h.i,l=[0,0,0,0],n=g(a.encrypt(c)),m,p,r=sjcl.bitArray.bitLength(b)-e,q=[];d=d||[];for(c=0;c+4<r/32;c+=4)m=k(n,a.decrypt(k(n,b.slice(c,c+4)))),l=k(l,m),q=q.concat(m),n=g(n);p=r-32*c;m=a.encrypt(k(n,[0,0,0,p]));m=k(m,h.clamp(b.slice(c),p).concat([0,
16436 0,0]));l=k(l,m);l=a.encrypt(k(l,k(n,g(n))));d.length&&(l=k(l,f?d:sjcl.mode.ocb2.pmac(a,d)));if(!h.equal(h.clamp(l,e),h.bitSlice(b,r)))throw new sjcl.exception.corrupt("ocb: tag doesn't match");return q.concat(h.clamp(m,p))},pmac:function(a,b){var c,d=sjcl.mode.ocb2.S,e=sjcl.bitArray,f=e.i,g=[0,0,0,0],h=a.encrypt([0,0,0,0]),h=f(h,d(d(h)));for(c=0;c+4<b.length;c+=4)h=d(h),g=f(g,a.encrypt(f(h,b.slice(c,c+4))));c=b.slice(c);128>e.bitLength(c)&&(h=f(h,d(h)),c=e.concat(c,[-2147483648,0,0,0]));g=f(g,c);
16437 return a.encrypt(f(d(f(h,d(h))),g))},S:function(a){return[a[0]<<1^a[1]>>>31,a[1]<<1^a[2]>>>31,a[2]<<1^a[3]>>>31,a[3]<<1^135*(a[0]>>>31)]}};
16438 sjcl.mode.gcm={name:"gcm",encrypt:function(a,b,c,d,e){var f=b.slice(0);b=sjcl.bitArray;d=d||[];a=sjcl.mode.gcm.C(!0,a,f,d,c,e||128);return b.concat(a.data,a.tag)},decrypt:function(a,b,c,d,e){var f=b.slice(0),g=sjcl.bitArray,h=g.bitLength(f);e=e||128;d=d||[];e<=h?(b=g.bitSlice(f,h-e),f=g.bitSlice(f,0,h-e)):(b=f,f=[]);a=sjcl.mode.gcm.C(!1,a,f,d,c,e);if(!g.equal(a.tag,b))throw new sjcl.exception.corrupt("gcm: tag doesn't match");return a.data},ka:function(a,b){var c,d,e,f,g,h=sjcl.bitArray.i;e=[0,0,
16439 0,0];f=b.slice(0);for(c=0;128>c;c++){(d=0!==(a[Math.floor(c/32)]&1<<31-c%32))&&(e=h(e,f));g=0!==(f[3]&1);for(d=3;0<d;d--)f[d]=f[d]>>>1|(f[d-1]&1)<<31;f[0]>>>=1;g&&(f[0]^=-0x1f000000)}return e},j:function(a,b,c){var d,e=c.length;b=b.slice(0);for(d=0;d<e;d+=4)b[0]^=0xffffffff&c[d],b[1]^=0xffffffff&c[d+1],b[2]^=0xffffffff&c[d+2],b[3]^=0xffffffff&c[d+3],b=sjcl.mode.gcm.ka(b,a);return b},C:function(a,b,c,d,e,f){var g,h,k,l,n,m,p,r,q=sjcl.bitArray;m=c.length;p=q.bitLength(c);r=q.bitLength(d);h=q.bitLength(e);
16440 g=b.encrypt([0,0,0,0]);96===h?(e=e.slice(0),e=q.concat(e,[1])):(e=sjcl.mode.gcm.j(g,[0,0,0,0],e),e=sjcl.mode.gcm.j(g,e,[0,0,Math.floor(h/0x100000000),h&0xffffffff]));h=sjcl.mode.gcm.j(g,[0,0,0,0],d);n=e.slice(0);d=h.slice(0);a||(d=sjcl.mode.gcm.j(g,h,c));for(l=0;l<m;l+=4)n[3]++,k=b.encrypt(n),c[l]^=k[0],c[l+1]^=k[1],c[l+2]^=k[2],c[l+3]^=k[3];c=q.clamp(c,p);a&&(d=sjcl.mode.gcm.j(g,h,c));a=[Math.floor(r/0x100000000),r&0xffffffff,Math.floor(p/0x100000000),p&0xffffffff];d=sjcl.mode.gcm.j(g,d,a);k=b.encrypt(e);
16441 d[0]^=k[0];d[1]^=k[1];d[2]^=k[2];d[3]^=k[3];return{tag:q.bitSlice(d,0,f),data:c}}};sjcl.misc.hmac=function(a,b){this.W=b=b||sjcl.hash.sha256;var c=[[],[]],d,e=b.prototype.blockSize/32;this.w=[new b,new b];a.length>e&&(a=b.hash(a));for(d=0;d<e;d++)c[0][d]=a[d]^909522486,c[1][d]=a[d]^1549556828;this.w[0].update(c[0]);this.w[1].update(c[1]);this.R=new b(this.w[0])};
16442 sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a){if(this.aa)throw new sjcl.exception.invalid("encrypt on already updated hmac called!");this.update(a);return this.digest(a)};sjcl.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]);this.aa=!1};sjcl.misc.hmac.prototype.update=function(a){this.aa=!0;this.R.update(a)};sjcl.misc.hmac.prototype.digest=function(){var a=this.R.finalize(),a=(new this.W(this.w[1])).update(a).finalize();this.reset();return a};
16443 sjcl.misc.pbkdf2=function(a,b,c,d,e){c=c||1E4;if(0>d||0>c)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,g,h,k,l=[],n=sjcl.bitArray;for(k=1;32*l.length<(d||1);k++){e=f=a.encrypt(n.concat(b,[k]));for(g=1;g<c;g++)for(f=a.encrypt(f),h=0;h<f.length;h++)e[h]^=f[h];l=l.concat(e)}d&&(l=n.clamp(l,d));return l};
16444 sjcl.prng=function(a){this.c=[new sjcl.hash.sha256];this.m=[0];this.P=0;this.H={};this.N=0;this.U={};this.Z=this.f=this.o=this.ha=0;this.b=[0,0,0,0,0,0,0,0];this.h=[0,0,0,0];this.L=void 0;this.M=a;this.D=!1;this.K={progress:{},seeded:{}};this.u=this.ga=0;this.I=1;this.J=2;this.ca=0x10000;this.T=[0,48,64,96,128,192,0x100,384,512,768,1024];this.da=3E4;this.ba=80};
16445 sjcl.prng.prototype={randomWords:function(a,b){var c=[],d;d=this.isReady(b);var e;if(d===this.u)throw new sjcl.exception.notReady("generator isn't seeded");if(d&this.J){d=!(d&this.I);e=[];var f=0,g;this.Z=e[0]=(new Date).valueOf()+this.da;for(g=0;16>g;g++)e.push(0x100000000*Math.random()|0);for(g=0;g<this.c.length&&(e=e.concat(this.c[g].finalize()),f+=this.m[g],this.m[g]=0,d||!(this.P&1<<g));g++);this.P>=1<<this.c.length&&(this.c.push(new sjcl.hash.sha256),this.m.push(0));this.f-=f;f>this.o&&(this.o=
16446 f);this.P++;this.b=sjcl.hash.sha256.hash(this.b.concat(e));this.L=new sjcl.cipher.aes(this.b);for(d=0;4>d&&(this.h[d]=this.h[d]+1|0,!this.h[d]);d++);}for(d=0;d<a;d+=4)0===(d+1)%this.ca&&y(this),e=z(this),c.push(e[0],e[1],e[2],e[3]);y(this);return c.slice(0,a)},setDefaultParanoia:function(a,b){if(0===a&&"Setting paranoia=0 will ruin your security; use it only for testing"!==b)throw new sjcl.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=a},addEntropy:function(a,
16447 b,c){c=c||"user";var d,e,f=(new Date).valueOf(),g=this.H[c],h=this.isReady(),k=0;d=this.U[c];void 0===d&&(d=this.U[c]=this.ha++);void 0===g&&(g=this.H[c]=0);this.H[c]=(this.H[c]+1)%this.c.length;switch(typeof a){case "number":void 0===b&&(b=1);this.c[g].update([d,this.N++,1,b,f,1,a|0]);break;case "object":c=Object.prototype.toString.call(a);if("[object Uint32Array]"===c){e=[];for(c=0;c<a.length;c++)e.push(a[c]);a=e}else for("[object Array]"!==c&&(k=1),c=0;c<a.length&&!k;c++)"number"!==typeof a[c]&&
16448 (k=1);if(!k){if(void 0===b)for(c=b=0;c<a.length;c++)for(e=a[c];0<e;)b++,e=e>>>1;this.c[g].update([d,this.N++,2,b,f,a.length].concat(a))}break;case "string":void 0===b&&(b=a.length);this.c[g].update([d,this.N++,3,b,f,a.length]);this.c[g].update(a);break;default:k=1}if(k)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[g]+=b;this.f+=b;h===this.u&&(this.isReady()!==this.u&&A("seeded",Math.max(this.o,this.f)),A("progress",this.getProgress()))},
16449 isReady:function(a){a=this.T[void 0!==a?a:this.M];return this.o&&this.o>=a?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=a?this.J|this.u:this.u},getProgress:function(a){a=this.T[a?a:this.M];return this.o>=a?1:this.f>a?1:this.f/a},startCollectors:function(){if(!this.D){this.a={loadTimeCollector:B(this,this.ma),mouseCollector:B(this,this.oa),keyboardCollector:B(this,this.la),accelerometerCollector:B(this,this.ea),touchCollector:B(this,this.qa)};if(window.addEventListener)window.addEventListener("load",
16450 this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new sjcl.exception.bug("can't attach event");
16451 this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",
16452 this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(a,b){this.K[a][this.ga++]=b},removeEventListener:function(a,b){var c,d,e=this.K[a],f=[];for(d in e)e.hasOwnProperty(d)&&e[d]===b&&f.push(d);for(c=0;c<f.length;c++)d=f[c],delete e[d]},la:function(){C(this,1)},oa:function(a){var b,c;try{b=a.x||a.clientX||a.offsetX||0,c=a.y||a.clientY||a.offsetY||0}catch(d){c=b=0}0!=b&&0!=c&&this.addEntropy([b,c],2,"mouse");C(this,0)},qa:function(a){a=
16453 a.touches[0]||a.changedTouches[0];this.addEntropy([a.pageX||a.clientX,a.pageY||a.clientY],1,"touch");C(this,0)},ma:function(){C(this,2)},ea:function(a){a=a.accelerationIncludingGravity.x||a.accelerationIncludingGravity.y||a.accelerationIncludingGravity.z;if(window.orientation){var b=window.orientation;"number"===typeof b&&this.addEntropy(b,1,"accelerometer")}a&&this.addEntropy(a,2,"accelerometer");C(this,0)}};
16454 function A(a,b){var c,d=sjcl.random.K[a],e=[];for(c in d)d.hasOwnProperty(c)&&e.push(d[c]);for(c=0;c<e.length;c++)e[c](b)}function C(a,b){"undefined"!==typeof window&&window.performance&&"function"===typeof window.performance.now?a.addEntropy(window.performance.now(),b,"loadtime"):a.addEntropy((new Date).valueOf(),b,"loadtime")}function y(a){a.b=z(a).concat(z(a));a.L=new sjcl.cipher.aes(a.b)}function z(a){for(var b=0;4>b&&(a.h[b]=a.h[b]+1|0,!a.h[b]);b++);return a.L.encrypt(a.h)}
16455 function B(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6);
16456 a:try{var D,E,F,G;if(G="undefined"!==typeof module&&module.exports){var H;try{H=__webpack_require__(182)}catch(a){H=null}G=E=H}if(G&&E.randomBytes)D=E.randomBytes(128),D=new Uint32Array((new Uint8Array(D)).buffer),sjcl.random.addEntropy(D,1024,"crypto['randomBytes']");else if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){F=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(F);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(F);
16457 else break a;sjcl.random.addEntropy(F,1024,"crypto['getRandomValues']")}}catch(a){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(a))}
16458 sjcl.json={defaults:{v:1,iter:1E4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json,f=e.g({iv:sjcl.random.randomWords(4,0)},e.defaults),g;e.g(f,c);c=f.adata;"string"===typeof f.salt&&(f.salt=sjcl.codec.base64.toBits(f.salt));"string"===typeof f.iv&&(f.iv=sjcl.codec.base64.toBits(f.iv));if(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||"string"===typeof a&&100>=f.iter||64!==f.ts&&96!==f.ts&&128!==f.ts||128!==f.ks&&192!==f.ks&&0x100!==f.ks||2>f.iv.length||
16459 4<f.iv.length)throw new sjcl.exception.invalid("json encrypt: invalid parameters");"string"===typeof a?(g=sjcl.misc.cachedPbkdf2(a,f),a=g.key.slice(0,f.ks/32),f.salt=g.salt):sjcl.ecc&&a instanceof sjcl.ecc.elGamal.publicKey&&(g=a.kem(),f.kemtag=g.tag,a=g.key.slice(0,f.ks/32));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));"string"===typeof c&&(f.adata=c=sjcl.codec.utf8String.toBits(c));g=new sjcl.cipher[f.cipher](a);e.g(d,f);d.key=a;f.ct="ccm"===f.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&
16460 b instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.encrypt(g,b,f.iv,c,f.ts):sjcl.mode[f.mode].encrypt(g,b,f.iv,c,f.ts);return f},encrypt:function(a,b,c,d){var e=sjcl.json,f=e.ja.apply(e,arguments);return e.encode(f)},ia:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json;b=e.g(e.g(e.g({},e.defaults),b),c,!0);var f,g;f=b.adata;"string"===typeof b.salt&&(b.salt=sjcl.codec.base64.toBits(b.salt));"string"===typeof b.iv&&(b.iv=sjcl.codec.base64.toBits(b.iv));if(!sjcl.mode[b.mode]||!sjcl.cipher[b.cipher]||"string"===
16461 typeof a&&100>=b.iter||64!==b.ts&&96!==b.ts&&128!==b.ts||128!==b.ks&&192!==b.ks&&0x100!==b.ks||!b.iv||2>b.iv.length||4<b.iv.length)throw new sjcl.exception.invalid("json decrypt: invalid parameters");"string"===typeof a?(g=sjcl.misc.cachedPbkdf2(a,b),a=g.key.slice(0,b.ks/32),b.salt=g.salt):sjcl.ecc&&a instanceof sjcl.ecc.elGamal.secretKey&&(a=a.unkem(sjcl.codec.base64.toBits(b.kemtag)).slice(0,b.ks/32));"string"===typeof f&&(f=sjcl.codec.utf8String.toBits(f));g=new sjcl.cipher[b.cipher](a);f="ccm"===
16462 b.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&b.ct instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.decrypt(g,b.ct,b.iv,b.tag,f,b.ts):sjcl.mode[b.mode].decrypt(g,b.ct,b.iv,f,b.ts);e.g(d,b);d.key=a;return 1===c.raw?f:sjcl.codec.utf8String.fromBits(f)},decrypt:function(a,b,c,d){var e=sjcl.json;return e.ia(a,e.decode(b),c,d)},encode:function(a){var b,c="{",d="";for(b in a)if(a.hasOwnProperty(b)){if(!b.match(/^[a-z0-9]+$/i))throw new sjcl.exception.invalid("json encode: invalid property name");c+=d+'"'+
16463 b+'":';d=",";switch(typeof a[b]){case "number":case "boolean":c+=a[b];break;case "string":c+='"'+escape(a[b])+'"';break;case "object":c+='"'+sjcl.codec.base64.fromBits(a[b],0)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type");}}return c+"}"},decode:function(a){a=a.replace(/\s/g,"");if(!a.match(/^\{.*\}$/))throw new sjcl.exception.invalid("json decode: this isn't json!");a=a.replace(/^\{|\}$/g,"").split(/,/);var b={},c,d;for(c=0;c<a.length;c++){if(!(d=a[c].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new sjcl.exception.invalid("json decode: this isn't json!");
16464 null!=d[3]?b[d[2]]=parseInt(d[3],10):null!=d[4]?b[d[2]]=d[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(d[4]):unescape(d[4]):null!=d[5]&&(b[d[2]]="true"===d[5])}return b},g:function(a,b,c){void 0===a&&(a={});if(void 0===b)return a;for(var d in b)if(b.hasOwnProperty(d)){if(c&&void 0!==a[d]&&a[d]!==b[d])throw new sjcl.exception.invalid("required parameter overridden");a[d]=b[d]}return a},sa:function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&&a[d]!==b[d]&&(c[d]=a[d]);return c},ra:function(a,
16465 b){var c={},d;for(d=0;d<b.length;d++)void 0!==a[b[d]]&&(c[b[d]]=a[b[d]]);return c}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.pa={};sjcl.misc.cachedPbkdf2=function(a,b){var c=sjcl.misc.pa,d;b=b||{};d=b.iter||1E3;c=c[a]=c[a]||{};d=c[d]=c[d]||{firstSalt:b.salt&&b.salt.length?b.salt.slice(0):sjcl.random.randomWords(2,0)};c=void 0===b.salt?d.firstSalt:b.salt;d[c]=d[c]||sjcl.misc.pbkdf2(a,c,b.iter);return{key:d[c].slice(0),salt:c.slice(0)}};
16466 "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"==="function"&&!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function(){return sjcl}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
16467                                 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
16468
16469
16470 /***/ }),
16471 /* 182 */
16472 /***/ (function(module, exports, __webpack_require__) {
16473
16474 "use strict";
16475
16476
16477 exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(23)
16478 exports.createHash = exports.Hash = __webpack_require__(29)
16479 exports.createHmac = exports.Hmac = __webpack_require__(101)
16480
16481 var algos = __webpack_require__(197)
16482 var algoKeys = Object.keys(algos)
16483 var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
16484 exports.getHashes = function () {
16485   return hashes
16486 }
16487
16488 var p = __webpack_require__(104)
16489 exports.pbkdf2 = p.pbkdf2
16490 exports.pbkdf2Sync = p.pbkdf2Sync
16491
16492 var aes = __webpack_require__(199)
16493
16494 exports.Cipher = aes.Cipher
16495 exports.createCipher = aes.createCipher
16496 exports.Cipheriv = aes.Cipheriv
16497 exports.createCipheriv = aes.createCipheriv
16498 exports.Decipher = aes.Decipher
16499 exports.createDecipher = aes.createDecipher
16500 exports.Decipheriv = aes.Decipheriv
16501 exports.createDecipheriv = aes.createDecipheriv
16502 exports.getCiphers = aes.getCiphers
16503 exports.listCiphers = aes.listCiphers
16504
16505 var dh = __webpack_require__(216)
16506
16507 exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
16508 exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
16509 exports.getDiffieHellman = dh.getDiffieHellman
16510 exports.createDiffieHellman = dh.createDiffieHellman
16511 exports.DiffieHellman = dh.DiffieHellman
16512
16513 var sign = __webpack_require__(221)
16514
16515 exports.createSign = sign.createSign
16516 exports.Sign = sign.Sign
16517 exports.createVerify = sign.createVerify
16518 exports.Verify = sign.Verify
16519
16520 exports.createECDH = __webpack_require__(259)
16521
16522 var publicEncrypt = __webpack_require__(260)
16523
16524 exports.publicEncrypt = publicEncrypt.publicEncrypt
16525 exports.privateEncrypt = publicEncrypt.privateEncrypt
16526 exports.publicDecrypt = publicEncrypt.publicDecrypt
16527 exports.privateDecrypt = publicEncrypt.privateDecrypt
16528
16529 // the least I can do is make error messages for the rest of the node.js/crypto api.
16530 // ;[
16531 //   'createCredentials'
16532 // ].forEach(function (name) {
16533 //   exports[name] = function () {
16534 //     throw new Error([
16535 //       'sorry, ' + name + ' is not implemented yet',
16536 //       'we accept pull requests',
16537 //       'https://github.com/crypto-browserify/crypto-browserify'
16538 //     ].join('\n'))
16539 //   }
16540 // })
16541
16542 var rf = __webpack_require__(263)
16543
16544 exports.randomFill = rf.randomFill
16545 exports.randomFillSync = rf.randomFillSync
16546
16547 exports.createCredentials = function () {
16548   throw new Error([
16549     'sorry, createCredentials is not implemented yet',
16550     'we accept pull requests',
16551     'https://github.com/crypto-browserify/crypto-browserify'
16552   ].join('\n'))
16553 }
16554
16555 exports.constants = {
16556   'DH_CHECK_P_NOT_SAFE_PRIME': 2,
16557   'DH_CHECK_P_NOT_PRIME': 1,
16558   'DH_UNABLE_TO_CHECK_GENERATOR': 4,
16559   'DH_NOT_SUITABLE_GENERATOR': 8,
16560   'NPN_ENABLED': 1,
16561   'ALPN_ENABLED': 1,
16562   'RSA_PKCS1_PADDING': 1,
16563   'RSA_SSLV23_PADDING': 2,
16564   'RSA_NO_PADDING': 3,
16565   'RSA_PKCS1_OAEP_PADDING': 4,
16566   'RSA_X931_PADDING': 5,
16567   'RSA_PKCS1_PSS_PADDING': 6,
16568   'POINT_CONVERSION_COMPRESSED': 2,
16569   'POINT_CONVERSION_UNCOMPRESSED': 4,
16570   'POINT_CONVERSION_HYBRID': 6
16571 }
16572
16573
16574 /***/ }),
16575 /* 183 */
16576 /***/ (function(module, exports) {
16577
16578 /* (ignored) */
16579
16580 /***/ }),
16581 /* 184 */
16582 /***/ (function(module, exports, __webpack_require__) {
16583
16584 "use strict";
16585
16586
16587 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16588
16589 var Buffer = __webpack_require__(2).Buffer;
16590 var util = __webpack_require__(185);
16591
16592 function copyBuffer(src, target, offset) {
16593   src.copy(target, offset);
16594 }
16595
16596 module.exports = function () {
16597   function BufferList() {
16598     _classCallCheck(this, BufferList);
16599
16600     this.head = null;
16601     this.tail = null;
16602     this.length = 0;
16603   }
16604
16605   BufferList.prototype.push = function push(v) {
16606     var entry = { data: v, next: null };
16607     if (this.length > 0) this.tail.next = entry;else this.head = entry;
16608     this.tail = entry;
16609     ++this.length;
16610   };
16611
16612   BufferList.prototype.unshift = function unshift(v) {
16613     var entry = { data: v, next: this.head };
16614     if (this.length === 0) this.tail = entry;
16615     this.head = entry;
16616     ++this.length;
16617   };
16618
16619   BufferList.prototype.shift = function shift() {
16620     if (this.length === 0) return;
16621     var ret = this.head.data;
16622     if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
16623     --this.length;
16624     return ret;
16625   };
16626
16627   BufferList.prototype.clear = function clear() {
16628     this.head = this.tail = null;
16629     this.length = 0;
16630   };
16631
16632   BufferList.prototype.join = function join(s) {
16633     if (this.length === 0) return '';
16634     var p = this.head;
16635     var ret = '' + p.data;
16636     while (p = p.next) {
16637       ret += s + p.data;
16638     }return ret;
16639   };
16640
16641   BufferList.prototype.concat = function concat(n) {
16642     if (this.length === 0) return Buffer.alloc(0);
16643     if (this.length === 1) return this.head.data;
16644     var ret = Buffer.allocUnsafe(n >>> 0);
16645     var p = this.head;
16646     var i = 0;
16647     while (p) {
16648       copyBuffer(p.data, ret, i);
16649       i += p.data.length;
16650       p = p.next;
16651     }
16652     return ret;
16653   };
16654
16655   return BufferList;
16656 }();
16657
16658 if (util && util.inspect && util.inspect.custom) {
16659   module.exports.prototype[util.inspect.custom] = function () {
16660     var obj = util.inspect({ length: this.length });
16661     return this.constructor.name + ' ' + obj;
16662   };
16663 }
16664
16665 /***/ }),
16666 /* 185 */
16667 /***/ (function(module, exports) {
16668
16669 /* (ignored) */
16670
16671 /***/ }),
16672 /* 186 */
16673 /***/ (function(module, exports, __webpack_require__) {
16674
16675 /* WEBPACK VAR INJECTION */(function(global) {
16676 /**
16677  * Module exports.
16678  */
16679
16680 module.exports = deprecate;
16681
16682 /**
16683  * Mark that a method should not be used.
16684  * Returns a modified function which warns once by default.
16685  *
16686  * If `localStorage.noDeprecation = true` is set, then it is a no-op.
16687  *
16688  * If `localStorage.throwDeprecation = true` is set, then deprecated functions
16689  * will throw an Error when invoked.
16690  *
16691  * If `localStorage.traceDeprecation = true` is set, then deprecated functions
16692  * will invoke `console.trace()` instead of `console.error()`.
16693  *
16694  * @param {Function} fn - the function to deprecate
16695  * @param {String} msg - the string to print to the console when `fn` is invoked
16696  * @returns {Function} a new "deprecated" version of `fn`
16697  * @api public
16698  */
16699
16700 function deprecate (fn, msg) {
16701   if (config('noDeprecation')) {
16702     return fn;
16703   }
16704
16705   var warned = false;
16706   function deprecated() {
16707     if (!warned) {
16708       if (config('throwDeprecation')) {
16709         throw new Error(msg);
16710       } else if (config('traceDeprecation')) {
16711         console.trace(msg);
16712       } else {
16713         console.warn(msg);
16714       }
16715       warned = true;
16716     }
16717     return fn.apply(this, arguments);
16718   }
16719
16720   return deprecated;
16721 }
16722
16723 /**
16724  * Checks `localStorage` for boolean values for the given `name`.
16725  *
16726  * @param {String} name
16727  * @returns {Boolean}
16728  * @api private
16729  */
16730
16731 function config (name) {
16732   // accessing global.localStorage can trigger a DOMException in sandboxed iframes
16733   try {
16734     if (!global.localStorage) return false;
16735   } catch (_) {
16736     return false;
16737   }
16738   var val = global.localStorage[name];
16739   if (null == val) return false;
16740   return String(val).toLowerCase() === 'true';
16741 }
16742
16743 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
16744
16745 /***/ }),
16746 /* 187 */
16747 /***/ (function(module, exports, __webpack_require__) {
16748
16749 "use strict";
16750 // Copyright Joyent, Inc. and other Node contributors.
16751 //
16752 // Permission is hereby granted, free of charge, to any person obtaining a
16753 // copy of this software and associated documentation files (the
16754 // "Software"), to deal in the Software without restriction, including
16755 // without limitation the rights to use, copy, modify, merge, publish,
16756 // distribute, sublicense, and/or sell copies of the Software, and to permit
16757 // persons to whom the Software is furnished to do so, subject to the
16758 // following conditions:
16759 //
16760 // The above copyright notice and this permission notice shall be included
16761 // in all copies or substantial portions of the Software.
16762 //
16763 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16764 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16765 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16766 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16767 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16768 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16769 // USE OR OTHER DEALINGS IN THE SOFTWARE.
16770
16771 // a passthrough stream.
16772 // basically just the most minimal sort of Transform stream.
16773 // Every written chunk gets output as-is.
16774
16775
16776
16777 module.exports = PassThrough;
16778
16779 var Transform = __webpack_require__(98);
16780
16781 /*<replacement>*/
16782 var util = __webpack_require__(30);
16783 util.inherits = __webpack_require__(1);
16784 /*</replacement>*/
16785
16786 util.inherits(PassThrough, Transform);
16787
16788 function PassThrough(options) {
16789   if (!(this instanceof PassThrough)) return new PassThrough(options);
16790
16791   Transform.call(this, options);
16792 }
16793
16794 PassThrough.prototype._transform = function (chunk, encoding, cb) {
16795   cb(null, chunk);
16796 };
16797
16798 /***/ }),
16799 /* 188 */
16800 /***/ (function(module, exports, __webpack_require__) {
16801
16802 module.exports = __webpack_require__(60);
16803
16804
16805 /***/ }),
16806 /* 189 */
16807 /***/ (function(module, exports, __webpack_require__) {
16808
16809 module.exports = __webpack_require__(21);
16810
16811
16812 /***/ }),
16813 /* 190 */
16814 /***/ (function(module, exports, __webpack_require__) {
16815
16816 module.exports = __webpack_require__(59).Transform
16817
16818
16819 /***/ }),
16820 /* 191 */
16821 /***/ (function(module, exports, __webpack_require__) {
16822
16823 module.exports = __webpack_require__(59).PassThrough
16824
16825
16826 /***/ }),
16827 /* 192 */
16828 /***/ (function(module, exports, __webpack_require__) {
16829
16830 /*
16831  * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
16832  * in FIPS PUB 180-1
16833  * This source code is derived from sha1.js of the same repository.
16834  * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
16835  * operation was added.
16836  */
16837
16838 var inherits = __webpack_require__(1)
16839 var Hash = __webpack_require__(24)
16840 var Buffer = __webpack_require__(2).Buffer
16841
16842 var K = [
16843   0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
16844 ]
16845
16846 var W = new Array(80)
16847
16848 function Sha () {
16849   this.init()
16850   this._w = W
16851
16852   Hash.call(this, 64, 56)
16853 }
16854
16855 inherits(Sha, Hash)
16856
16857 Sha.prototype.init = function () {
16858   this._a = 0x67452301
16859   this._b = 0xefcdab89
16860   this._c = 0x98badcfe
16861   this._d = 0x10325476
16862   this._e = 0xc3d2e1f0
16863
16864   return this
16865 }
16866
16867 function rotl5 (num) {
16868   return (num << 5) | (num >>> 27)
16869 }
16870
16871 function rotl30 (num) {
16872   return (num << 30) | (num >>> 2)
16873 }
16874
16875 function ft (s, b, c, d) {
16876   if (s === 0) return (b & c) | ((~b) & d)
16877   if (s === 2) return (b & c) | (b & d) | (c & d)
16878   return b ^ c ^ d
16879 }
16880
16881 Sha.prototype._update = function (M) {
16882   var W = this._w
16883
16884   var a = this._a | 0
16885   var b = this._b | 0
16886   var c = this._c | 0
16887   var d = this._d | 0
16888   var e = this._e | 0
16889
16890   for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
16891   for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
16892
16893   for (var j = 0; j < 80; ++j) {
16894     var s = ~~(j / 20)
16895     var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
16896
16897     e = d
16898     d = c
16899     c = rotl30(b)
16900     b = a
16901     a = t
16902   }
16903
16904   this._a = (a + this._a) | 0
16905   this._b = (b + this._b) | 0
16906   this._c = (c + this._c) | 0
16907   this._d = (d + this._d) | 0
16908   this._e = (e + this._e) | 0
16909 }
16910
16911 Sha.prototype._hash = function () {
16912   var H = Buffer.allocUnsafe(20)
16913
16914   H.writeInt32BE(this._a | 0, 0)
16915   H.writeInt32BE(this._b | 0, 4)
16916   H.writeInt32BE(this._c | 0, 8)
16917   H.writeInt32BE(this._d | 0, 12)
16918   H.writeInt32BE(this._e | 0, 16)
16919
16920   return H
16921 }
16922
16923 module.exports = Sha
16924
16925
16926 /***/ }),
16927 /* 193 */
16928 /***/ (function(module, exports, __webpack_require__) {
16929
16930 /*
16931  * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
16932  * in FIPS PUB 180-1
16933  * Version 2.1a Copyright Paul Johnston 2000 - 2002.
16934  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
16935  * Distributed under the BSD License
16936  * See http://pajhome.org.uk/crypt/md5 for details.
16937  */
16938
16939 var inherits = __webpack_require__(1)
16940 var Hash = __webpack_require__(24)
16941 var Buffer = __webpack_require__(2).Buffer
16942
16943 var K = [
16944   0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
16945 ]
16946
16947 var W = new Array(80)
16948
16949 function Sha1 () {
16950   this.init()
16951   this._w = W
16952
16953   Hash.call(this, 64, 56)
16954 }
16955
16956 inherits(Sha1, Hash)
16957
16958 Sha1.prototype.init = function () {
16959   this._a = 0x67452301
16960   this._b = 0xefcdab89
16961   this._c = 0x98badcfe
16962   this._d = 0x10325476
16963   this._e = 0xc3d2e1f0
16964
16965   return this
16966 }
16967
16968 function rotl1 (num) {
16969   return (num << 1) | (num >>> 31)
16970 }
16971
16972 function rotl5 (num) {
16973   return (num << 5) | (num >>> 27)
16974 }
16975
16976 function rotl30 (num) {
16977   return (num << 30) | (num >>> 2)
16978 }
16979
16980 function ft (s, b, c, d) {
16981   if (s === 0) return (b & c) | ((~b) & d)
16982   if (s === 2) return (b & c) | (b & d) | (c & d)
16983   return b ^ c ^ d
16984 }
16985
16986 Sha1.prototype._update = function (M) {
16987   var W = this._w
16988
16989   var a = this._a | 0
16990   var b = this._b | 0
16991   var c = this._c | 0
16992   var d = this._d | 0
16993   var e = this._e | 0
16994
16995   for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
16996   for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
16997
16998   for (var j = 0; j < 80; ++j) {
16999     var s = ~~(j / 20)
17000     var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
17001
17002     e = d
17003     d = c
17004     c = rotl30(b)
17005     b = a
17006     a = t
17007   }
17008
17009   this._a = (a + this._a) | 0
17010   this._b = (b + this._b) | 0
17011   this._c = (c + this._c) | 0
17012   this._d = (d + this._d) | 0
17013   this._e = (e + this._e) | 0
17014 }
17015
17016 Sha1.prototype._hash = function () {
17017   var H = Buffer.allocUnsafe(20)
17018
17019   H.writeInt32BE(this._a | 0, 0)
17020   H.writeInt32BE(this._b | 0, 4)
17021   H.writeInt32BE(this._c | 0, 8)
17022   H.writeInt32BE(this._d | 0, 12)
17023   H.writeInt32BE(this._e | 0, 16)
17024
17025   return H
17026 }
17027
17028 module.exports = Sha1
17029
17030
17031 /***/ }),
17032 /* 194 */
17033 /***/ (function(module, exports, __webpack_require__) {
17034
17035 /**
17036  * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
17037  * in FIPS 180-2
17038  * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
17039  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
17040  *
17041  */
17042
17043 var inherits = __webpack_require__(1)
17044 var Sha256 = __webpack_require__(99)
17045 var Hash = __webpack_require__(24)
17046 var Buffer = __webpack_require__(2).Buffer
17047
17048 var W = new Array(64)
17049
17050 function Sha224 () {
17051   this.init()
17052
17053   this._w = W // new Array(64)
17054
17055   Hash.call(this, 64, 56)
17056 }
17057
17058 inherits(Sha224, Sha256)
17059
17060 Sha224.prototype.init = function () {
17061   this._a = 0xc1059ed8
17062   this._b = 0x367cd507
17063   this._c = 0x3070dd17
17064   this._d = 0xf70e5939
17065   this._e = 0xffc00b31
17066   this._f = 0x68581511
17067   this._g = 0x64f98fa7
17068   this._h = 0xbefa4fa4
17069
17070   return this
17071 }
17072
17073 Sha224.prototype._hash = function () {
17074   var H = Buffer.allocUnsafe(28)
17075
17076   H.writeInt32BE(this._a, 0)
17077   H.writeInt32BE(this._b, 4)
17078   H.writeInt32BE(this._c, 8)
17079   H.writeInt32BE(this._d, 12)
17080   H.writeInt32BE(this._e, 16)
17081   H.writeInt32BE(this._f, 20)
17082   H.writeInt32BE(this._g, 24)
17083
17084   return H
17085 }
17086
17087 module.exports = Sha224
17088
17089
17090 /***/ }),
17091 /* 195 */
17092 /***/ (function(module, exports, __webpack_require__) {
17093
17094 var inherits = __webpack_require__(1)
17095 var SHA512 = __webpack_require__(100)
17096 var Hash = __webpack_require__(24)
17097 var Buffer = __webpack_require__(2).Buffer
17098
17099 var W = new Array(160)
17100
17101 function Sha384 () {
17102   this.init()
17103   this._w = W
17104
17105   Hash.call(this, 128, 112)
17106 }
17107
17108 inherits(Sha384, SHA512)
17109
17110 Sha384.prototype.init = function () {
17111   this._ah = 0xcbbb9d5d
17112   this._bh = 0x629a292a
17113   this._ch = 0x9159015a
17114   this._dh = 0x152fecd8
17115   this._eh = 0x67332667
17116   this._fh = 0x8eb44a87
17117   this._gh = 0xdb0c2e0d
17118   this._hh = 0x47b5481d
17119
17120   this._al = 0xc1059ed8
17121   this._bl = 0x367cd507
17122   this._cl = 0x3070dd17
17123   this._dl = 0xf70e5939
17124   this._el = 0xffc00b31
17125   this._fl = 0x68581511
17126   this._gl = 0x64f98fa7
17127   this._hl = 0xbefa4fa4
17128
17129   return this
17130 }
17131
17132 Sha384.prototype._hash = function () {
17133   var H = Buffer.allocUnsafe(48)
17134
17135   function writeInt64BE (h, l, offset) {
17136     H.writeInt32BE(h, offset)
17137     H.writeInt32BE(l, offset + 4)
17138   }
17139
17140   writeInt64BE(this._ah, this._al, 0)
17141   writeInt64BE(this._bh, this._bl, 8)
17142   writeInt64BE(this._ch, this._cl, 16)
17143   writeInt64BE(this._dh, this._dl, 24)
17144   writeInt64BE(this._eh, this._el, 32)
17145   writeInt64BE(this._fh, this._fl, 40)
17146
17147   return H
17148 }
17149
17150 module.exports = Sha384
17151
17152
17153 /***/ }),
17154 /* 196 */
17155 /***/ (function(module, exports, __webpack_require__) {
17156
17157 "use strict";
17158
17159 var inherits = __webpack_require__(1)
17160 var Buffer = __webpack_require__(2).Buffer
17161
17162 var Base = __webpack_require__(18)
17163
17164 var ZEROS = Buffer.alloc(128)
17165 var blocksize = 64
17166
17167 function Hmac (alg, key) {
17168   Base.call(this, 'digest')
17169   if (typeof key === 'string') {
17170     key = Buffer.from(key)
17171   }
17172
17173   this._alg = alg
17174   this._key = key
17175
17176   if (key.length > blocksize) {
17177     key = alg(key)
17178   } else if (key.length < blocksize) {
17179     key = Buffer.concat([key, ZEROS], blocksize)
17180   }
17181
17182   var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
17183   var opad = this._opad = Buffer.allocUnsafe(blocksize)
17184
17185   for (var i = 0; i < blocksize; i++) {
17186     ipad[i] = key[i] ^ 0x36
17187     opad[i] = key[i] ^ 0x5C
17188   }
17189
17190   this._hash = [ipad]
17191 }
17192
17193 inherits(Hmac, Base)
17194
17195 Hmac.prototype._update = function (data) {
17196   this._hash.push(data)
17197 }
17198
17199 Hmac.prototype._final = function () {
17200   var h = this._alg(Buffer.concat(this._hash))
17201   return this._alg(Buffer.concat([this._opad, h]))
17202 }
17203 module.exports = Hmac
17204
17205
17206 /***/ }),
17207 /* 197 */
17208 /***/ (function(module, exports, __webpack_require__) {
17209
17210 module.exports = __webpack_require__(103)
17211
17212
17213 /***/ }),
17214 /* 198 */
17215 /***/ (function(module, exports, __webpack_require__) {
17216
17217 /* WEBPACK VAR INJECTION */(function(global, process) {var checkParameters = __webpack_require__(105)
17218 var defaultEncoding = __webpack_require__(106)
17219 var sync = __webpack_require__(107)
17220 var Buffer = __webpack_require__(2).Buffer
17221
17222 var ZERO_BUF
17223 var subtle = global.crypto && global.crypto.subtle
17224 var toBrowser = {
17225   'sha': 'SHA-1',
17226   'sha-1': 'SHA-1',
17227   'sha1': 'SHA-1',
17228   'sha256': 'SHA-256',
17229   'sha-256': 'SHA-256',
17230   'sha384': 'SHA-384',
17231   'sha-384': 'SHA-384',
17232   'sha-512': 'SHA-512',
17233   'sha512': 'SHA-512'
17234 }
17235 var checks = []
17236 function checkNative (algo) {
17237   if (global.process && !global.process.browser) {
17238     return Promise.resolve(false)
17239   }
17240   if (!subtle || !subtle.importKey || !subtle.deriveBits) {
17241     return Promise.resolve(false)
17242   }
17243   if (checks[algo] !== undefined) {
17244     return checks[algo]
17245   }
17246   ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
17247   var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
17248     .then(function () {
17249       return true
17250     }).catch(function () {
17251       return false
17252     })
17253   checks[algo] = prom
17254   return prom
17255 }
17256
17257 function browserPbkdf2 (password, salt, iterations, length, algo) {
17258   return subtle.importKey(
17259     'raw', password, {name: 'PBKDF2'}, false, ['deriveBits']
17260   ).then(function (key) {
17261     return subtle.deriveBits({
17262       name: 'PBKDF2',
17263       salt: salt,
17264       iterations: iterations,
17265       hash: {
17266         name: algo
17267       }
17268     }, key, length << 3)
17269   }).then(function (res) {
17270     return Buffer.from(res)
17271   })
17272 }
17273
17274 function resolvePromise (promise, callback) {
17275   promise.then(function (out) {
17276     process.nextTick(function () {
17277       callback(null, out)
17278     })
17279   }, function (e) {
17280     process.nextTick(function () {
17281       callback(e)
17282     })
17283   })
17284 }
17285 module.exports = function (password, salt, iterations, keylen, digest, callback) {
17286   if (typeof digest === 'function') {
17287     callback = digest
17288     digest = undefined
17289   }
17290
17291   digest = digest || 'sha1'
17292   var algo = toBrowser[digest.toLowerCase()]
17293
17294   if (!algo || typeof global.Promise !== 'function') {
17295     return process.nextTick(function () {
17296       var out
17297       try {
17298         out = sync(password, salt, iterations, keylen, digest)
17299       } catch (e) {
17300         return callback(e)
17301       }
17302       callback(null, out)
17303     })
17304   }
17305
17306   checkParameters(password, salt, iterations, keylen)
17307   if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
17308   if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
17309   if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
17310
17311   resolvePromise(checkNative(algo).then(function (resp) {
17312     if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)
17313
17314     return sync(password, salt, iterations, keylen, digest)
17315   }), callback)
17316 }
17317
17318 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
17319
17320 /***/ }),
17321 /* 199 */
17322 /***/ (function(module, exports, __webpack_require__) {
17323
17324 var DES = __webpack_require__(200)
17325 var aes = __webpack_require__(65)
17326 var aesModes = __webpack_require__(66)
17327 var desModes = __webpack_require__(215)
17328 var ebtk = __webpack_require__(44)
17329
17330 function createCipher (suite, password) {
17331   suite = suite.toLowerCase()
17332
17333   var keyLen, ivLen
17334   if (aesModes[suite]) {
17335     keyLen = aesModes[suite].key
17336     ivLen = aesModes[suite].iv
17337   } else if (desModes[suite]) {
17338     keyLen = desModes[suite].key * 8
17339     ivLen = desModes[suite].iv
17340   } else {
17341     throw new TypeError('invalid suite type')
17342   }
17343
17344   var keys = ebtk(password, false, keyLen, ivLen)
17345   return createCipheriv(suite, keys.key, keys.iv)
17346 }
17347
17348 function createDecipher (suite, password) {
17349   suite = suite.toLowerCase()
17350
17351   var keyLen, ivLen
17352   if (aesModes[suite]) {
17353     keyLen = aesModes[suite].key
17354     ivLen = aesModes[suite].iv
17355   } else if (desModes[suite]) {
17356     keyLen = desModes[suite].key * 8
17357     ivLen = desModes[suite].iv
17358   } else {
17359     throw new TypeError('invalid suite type')
17360   }
17361
17362   var keys = ebtk(password, false, keyLen, ivLen)
17363   return createDecipheriv(suite, keys.key, keys.iv)
17364 }
17365
17366 function createCipheriv (suite, key, iv) {
17367   suite = suite.toLowerCase()
17368   if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)
17369   if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })
17370
17371   throw new TypeError('invalid suite type')
17372 }
17373
17374 function createDecipheriv (suite, key, iv) {
17375   suite = suite.toLowerCase()
17376   if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
17377   if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
17378
17379   throw new TypeError('invalid suite type')
17380 }
17381
17382 function getCiphers () {
17383   return Object.keys(desModes).concat(aes.getCiphers())
17384 }
17385
17386 exports.createCipher = exports.Cipher = createCipher
17387 exports.createCipheriv = exports.Cipheriv = createCipheriv
17388 exports.createDecipher = exports.Decipher = createDecipher
17389 exports.createDecipheriv = exports.Decipheriv = createDecipheriv
17390 exports.listCiphers = exports.getCiphers = getCiphers
17391
17392
17393 /***/ }),
17394 /* 200 */
17395 /***/ (function(module, exports, __webpack_require__) {
17396
17397 var CipherBase = __webpack_require__(18)
17398 var des = __webpack_require__(64)
17399 var inherits = __webpack_require__(1)
17400 var Buffer = __webpack_require__(2).Buffer
17401
17402 var modes = {
17403   'des-ede3-cbc': des.CBC.instantiate(des.EDE),
17404   'des-ede3': des.EDE,
17405   'des-ede-cbc': des.CBC.instantiate(des.EDE),
17406   'des-ede': des.EDE,
17407   'des-cbc': des.CBC.instantiate(des.DES),
17408   'des-ecb': des.DES
17409 }
17410 modes.des = modes['des-cbc']
17411 modes.des3 = modes['des-ede3-cbc']
17412 module.exports = DES
17413 inherits(DES, CipherBase)
17414 function DES (opts) {
17415   CipherBase.call(this)
17416   var modeName = opts.mode.toLowerCase()
17417   var mode = modes[modeName]
17418   var type
17419   if (opts.decrypt) {
17420     type = 'decrypt'
17421   } else {
17422     type = 'encrypt'
17423   }
17424   var key = opts.key
17425   if (!Buffer.isBuffer(key)) {
17426     key = Buffer.from(key)
17427   }
17428   if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
17429     key = Buffer.concat([key, key.slice(0, 8)])
17430   }
17431   var iv = opts.iv
17432   if (!Buffer.isBuffer(iv)) {
17433     iv = Buffer.from(iv)
17434   }
17435   this._des = mode.create({
17436     key: key,
17437     iv: iv,
17438     type: type
17439   })
17440 }
17441 DES.prototype._update = function (data) {
17442   return Buffer.from(this._des.update(data))
17443 }
17444 DES.prototype._final = function () {
17445   return Buffer.from(this._des.final())
17446 }
17447
17448
17449 /***/ }),
17450 /* 201 */
17451 /***/ (function(module, exports, __webpack_require__) {
17452
17453 "use strict";
17454
17455
17456 exports.readUInt32BE = function readUInt32BE(bytes, off) {
17457   var res =  (bytes[0 + off] << 24) |
17458              (bytes[1 + off] << 16) |
17459              (bytes[2 + off] << 8) |
17460              bytes[3 + off];
17461   return res >>> 0;
17462 };
17463
17464 exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
17465   bytes[0 + off] = value >>> 24;
17466   bytes[1 + off] = (value >>> 16) & 0xff;
17467   bytes[2 + off] = (value >>> 8) & 0xff;
17468   bytes[3 + off] = value & 0xff;
17469 };
17470
17471 exports.ip = function ip(inL, inR, out, off) {
17472   var outL = 0;
17473   var outR = 0;
17474
17475   for (var i = 6; i >= 0; i -= 2) {
17476     for (var j = 0; j <= 24; j += 8) {
17477       outL <<= 1;
17478       outL |= (inR >>> (j + i)) & 1;
17479     }
17480     for (var j = 0; j <= 24; j += 8) {
17481       outL <<= 1;
17482       outL |= (inL >>> (j + i)) & 1;
17483     }
17484   }
17485
17486   for (var i = 6; i >= 0; i -= 2) {
17487     for (var j = 1; j <= 25; j += 8) {
17488       outR <<= 1;
17489       outR |= (inR >>> (j + i)) & 1;
17490     }
17491     for (var j = 1; j <= 25; j += 8) {
17492       outR <<= 1;
17493       outR |= (inL >>> (j + i)) & 1;
17494     }
17495   }
17496
17497   out[off + 0] = outL >>> 0;
17498   out[off + 1] = outR >>> 0;
17499 };
17500
17501 exports.rip = function rip(inL, inR, out, off) {
17502   var outL = 0;
17503   var outR = 0;
17504
17505   for (var i = 0; i < 4; i++) {
17506     for (var j = 24; j >= 0; j -= 8) {
17507       outL <<= 1;
17508       outL |= (inR >>> (j + i)) & 1;
17509       outL <<= 1;
17510       outL |= (inL >>> (j + i)) & 1;
17511     }
17512   }
17513   for (var i = 4; i < 8; i++) {
17514     for (var j = 24; j >= 0; j -= 8) {
17515       outR <<= 1;
17516       outR |= (inR >>> (j + i)) & 1;
17517       outR <<= 1;
17518       outR |= (inL >>> (j + i)) & 1;
17519     }
17520   }
17521
17522   out[off + 0] = outL >>> 0;
17523   out[off + 1] = outR >>> 0;
17524 };
17525
17526 exports.pc1 = function pc1(inL, inR, out, off) {
17527   var outL = 0;
17528   var outR = 0;
17529
17530   // 7, 15, 23, 31, 39, 47, 55, 63
17531   // 6, 14, 22, 30, 39, 47, 55, 63
17532   // 5, 13, 21, 29, 39, 47, 55, 63
17533   // 4, 12, 20, 28
17534   for (var i = 7; i >= 5; i--) {
17535     for (var j = 0; j <= 24; j += 8) {
17536       outL <<= 1;
17537       outL |= (inR >> (j + i)) & 1;
17538     }
17539     for (var j = 0; j <= 24; j += 8) {
17540       outL <<= 1;
17541       outL |= (inL >> (j + i)) & 1;
17542     }
17543   }
17544   for (var j = 0; j <= 24; j += 8) {
17545     outL <<= 1;
17546     outL |= (inR >> (j + i)) & 1;
17547   }
17548
17549   // 1, 9, 17, 25, 33, 41, 49, 57
17550   // 2, 10, 18, 26, 34, 42, 50, 58
17551   // 3, 11, 19, 27, 35, 43, 51, 59
17552   // 36, 44, 52, 60
17553   for (var i = 1; i <= 3; i++) {
17554     for (var j = 0; j <= 24; j += 8) {
17555       outR <<= 1;
17556       outR |= (inR >> (j + i)) & 1;
17557     }
17558     for (var j = 0; j <= 24; j += 8) {
17559       outR <<= 1;
17560       outR |= (inL >> (j + i)) & 1;
17561     }
17562   }
17563   for (var j = 0; j <= 24; j += 8) {
17564     outR <<= 1;
17565     outR |= (inL >> (j + i)) & 1;
17566   }
17567
17568   out[off + 0] = outL >>> 0;
17569   out[off + 1] = outR >>> 0;
17570 };
17571
17572 exports.r28shl = function r28shl(num, shift) {
17573   return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
17574 };
17575
17576 var pc2table = [
17577   // inL => outL
17578   14, 11, 17, 4, 27, 23, 25, 0,
17579   13, 22, 7, 18, 5, 9, 16, 24,
17580   2, 20, 12, 21, 1, 8, 15, 26,
17581
17582   // inR => outR
17583   15, 4, 25, 19, 9, 1, 26, 16,
17584   5, 11, 23, 8, 12, 7, 17, 0,
17585   22, 3, 10, 14, 6, 20, 27, 24
17586 ];
17587
17588 exports.pc2 = function pc2(inL, inR, out, off) {
17589   var outL = 0;
17590   var outR = 0;
17591
17592   var len = pc2table.length >>> 1;
17593   for (var i = 0; i < len; i++) {
17594     outL <<= 1;
17595     outL |= (inL >>> pc2table[i]) & 0x1;
17596   }
17597   for (var i = len; i < pc2table.length; i++) {
17598     outR <<= 1;
17599     outR |= (inR >>> pc2table[i]) & 0x1;
17600   }
17601
17602   out[off + 0] = outL >>> 0;
17603   out[off + 1] = outR >>> 0;
17604 };
17605
17606 exports.expand = function expand(r, out, off) {
17607   var outL = 0;
17608   var outR = 0;
17609
17610   outL = ((r & 1) << 5) | (r >>> 27);
17611   for (var i = 23; i >= 15; i -= 4) {
17612     outL <<= 6;
17613     outL |= (r >>> i) & 0x3f;
17614   }
17615   for (var i = 11; i >= 3; i -= 4) {
17616     outR |= (r >>> i) & 0x3f;
17617     outR <<= 6;
17618   }
17619   outR |= ((r & 0x1f) << 1) | (r >>> 31);
17620
17621   out[off + 0] = outL >>> 0;
17622   out[off + 1] = outR >>> 0;
17623 };
17624
17625 var sTable = [
17626   14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
17627   3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
17628   4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
17629   15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
17630
17631   15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
17632   9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
17633   0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
17634   5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
17635
17636   10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
17637   1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
17638   13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
17639   11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
17640
17641   7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
17642   1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
17643   10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
17644   15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
17645
17646   2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
17647   8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
17648   4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
17649   15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
17650
17651   12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
17652   0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
17653   9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
17654   7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
17655
17656   4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
17657   3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
17658   1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
17659   10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
17660
17661   13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
17662   10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
17663   7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
17664   0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
17665 ];
17666
17667 exports.substitute = function substitute(inL, inR) {
17668   var out = 0;
17669   for (var i = 0; i < 4; i++) {
17670     var b = (inL >>> (18 - i * 6)) & 0x3f;
17671     var sb = sTable[i * 0x40 + b];
17672
17673     out <<= 4;
17674     out |= sb;
17675   }
17676   for (var i = 0; i < 4; i++) {
17677     var b = (inR >>> (18 - i * 6)) & 0x3f;
17678     var sb = sTable[4 * 0x40 + i * 0x40 + b];
17679
17680     out <<= 4;
17681     out |= sb;
17682   }
17683   return out >>> 0;
17684 };
17685
17686 var permuteTable = [
17687   16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
17688   30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
17689 ];
17690
17691 exports.permute = function permute(num) {
17692   var out = 0;
17693   for (var i = 0; i < permuteTable.length; i++) {
17694     out <<= 1;
17695     out |= (num >>> permuteTable[i]) & 0x1;
17696   }
17697   return out >>> 0;
17698 };
17699
17700 exports.padSplit = function padSplit(num, size, group) {
17701   var str = num.toString(2);
17702   while (str.length < size)
17703     str = '0' + str;
17704
17705   var out = [];
17706   for (var i = 0; i < size; i += group)
17707     out.push(str.slice(i, i + group));
17708   return out.join(' ');
17709 };
17710
17711
17712 /***/ }),
17713 /* 202 */
17714 /***/ (function(module, exports, __webpack_require__) {
17715
17716 "use strict";
17717
17718
17719 var assert = __webpack_require__(9);
17720
17721 function Cipher(options) {
17722   this.options = options;
17723
17724   this.type = this.options.type;
17725   this.blockSize = 8;
17726   this._init();
17727
17728   this.buffer = new Array(this.blockSize);
17729   this.bufferOff = 0;
17730 }
17731 module.exports = Cipher;
17732
17733 Cipher.prototype._init = function _init() {
17734   // Might be overrided
17735 };
17736
17737 Cipher.prototype.update = function update(data) {
17738   if (data.length === 0)
17739     return [];
17740
17741   if (this.type === 'decrypt')
17742     return this._updateDecrypt(data);
17743   else
17744     return this._updateEncrypt(data);
17745 };
17746
17747 Cipher.prototype._buffer = function _buffer(data, off) {
17748   // Append data to buffer
17749   var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
17750   for (var i = 0; i < min; i++)
17751     this.buffer[this.bufferOff + i] = data[off + i];
17752   this.bufferOff += min;
17753
17754   // Shift next
17755   return min;
17756 };
17757
17758 Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
17759   this._update(this.buffer, 0, out, off);
17760   this.bufferOff = 0;
17761   return this.blockSize;
17762 };
17763
17764 Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
17765   var inputOff = 0;
17766   var outputOff = 0;
17767
17768   var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
17769   var out = new Array(count * this.blockSize);
17770
17771   if (this.bufferOff !== 0) {
17772     inputOff += this._buffer(data, inputOff);
17773
17774     if (this.bufferOff === this.buffer.length)
17775       outputOff += this._flushBuffer(out, outputOff);
17776   }
17777
17778   // Write blocks
17779   var max = data.length - ((data.length - inputOff) % this.blockSize);
17780   for (; inputOff < max; inputOff += this.blockSize) {
17781     this._update(data, inputOff, out, outputOff);
17782     outputOff += this.blockSize;
17783   }
17784
17785   // Queue rest
17786   for (; inputOff < data.length; inputOff++, this.bufferOff++)
17787     this.buffer[this.bufferOff] = data[inputOff];
17788
17789   return out;
17790 };
17791
17792 Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
17793   var inputOff = 0;
17794   var outputOff = 0;
17795
17796   var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
17797   var out = new Array(count * this.blockSize);
17798
17799   // TODO(indutny): optimize it, this is far from optimal
17800   for (; count > 0; count--) {
17801     inputOff += this._buffer(data, inputOff);
17802     outputOff += this._flushBuffer(out, outputOff);
17803   }
17804
17805   // Buffer rest of the input
17806   inputOff += this._buffer(data, inputOff);
17807
17808   return out;
17809 };
17810
17811 Cipher.prototype.final = function final(buffer) {
17812   var first;
17813   if (buffer)
17814     first = this.update(buffer);
17815
17816   var last;
17817   if (this.type === 'encrypt')
17818     last = this._finalEncrypt();
17819   else
17820     last = this._finalDecrypt();
17821
17822   if (first)
17823     return first.concat(last);
17824   else
17825     return last;
17826 };
17827
17828 Cipher.prototype._pad = function _pad(buffer, off) {
17829   if (off === 0)
17830     return false;
17831
17832   while (off < buffer.length)
17833     buffer[off++] = 0;
17834
17835   return true;
17836 };
17837
17838 Cipher.prototype._finalEncrypt = function _finalEncrypt() {
17839   if (!this._pad(this.buffer, this.bufferOff))
17840     return [];
17841
17842   var out = new Array(this.blockSize);
17843   this._update(this.buffer, 0, out, 0);
17844   return out;
17845 };
17846
17847 Cipher.prototype._unpad = function _unpad(buffer) {
17848   return buffer;
17849 };
17850
17851 Cipher.prototype._finalDecrypt = function _finalDecrypt() {
17852   assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
17853   var out = new Array(this.blockSize);
17854   this._flushBuffer(out, 0);
17855
17856   return this._unpad(out);
17857 };
17858
17859
17860 /***/ }),
17861 /* 203 */
17862 /***/ (function(module, exports, __webpack_require__) {
17863
17864 "use strict";
17865
17866
17867 var assert = __webpack_require__(9);
17868 var inherits = __webpack_require__(1);
17869
17870 var des = __webpack_require__(64);
17871 var utils = des.utils;
17872 var Cipher = des.Cipher;
17873
17874 function DESState() {
17875   this.tmp = new Array(2);
17876   this.keys = null;
17877 }
17878
17879 function DES(options) {
17880   Cipher.call(this, options);
17881
17882   var state = new DESState();
17883   this._desState = state;
17884
17885   this.deriveKeys(state, options.key);
17886 }
17887 inherits(DES, Cipher);
17888 module.exports = DES;
17889
17890 DES.create = function create(options) {
17891   return new DES(options);
17892 };
17893
17894 var shiftTable = [
17895   1, 1, 2, 2, 2, 2, 2, 2,
17896   1, 2, 2, 2, 2, 2, 2, 1
17897 ];
17898
17899 DES.prototype.deriveKeys = function deriveKeys(state, key) {
17900   state.keys = new Array(16 * 2);
17901
17902   assert.equal(key.length, this.blockSize, 'Invalid key length');
17903
17904   var kL = utils.readUInt32BE(key, 0);
17905   var kR = utils.readUInt32BE(key, 4);
17906
17907   utils.pc1(kL, kR, state.tmp, 0);
17908   kL = state.tmp[0];
17909   kR = state.tmp[1];
17910   for (var i = 0; i < state.keys.length; i += 2) {
17911     var shift = shiftTable[i >>> 1];
17912     kL = utils.r28shl(kL, shift);
17913     kR = utils.r28shl(kR, shift);
17914     utils.pc2(kL, kR, state.keys, i);
17915   }
17916 };
17917
17918 DES.prototype._update = function _update(inp, inOff, out, outOff) {
17919   var state = this._desState;
17920
17921   var l = utils.readUInt32BE(inp, inOff);
17922   var r = utils.readUInt32BE(inp, inOff + 4);
17923
17924   // Initial Permutation
17925   utils.ip(l, r, state.tmp, 0);
17926   l = state.tmp[0];
17927   r = state.tmp[1];
17928
17929   if (this.type === 'encrypt')
17930     this._encrypt(state, l, r, state.tmp, 0);
17931   else
17932     this._decrypt(state, l, r, state.tmp, 0);
17933
17934   l = state.tmp[0];
17935   r = state.tmp[1];
17936
17937   utils.writeUInt32BE(out, l, outOff);
17938   utils.writeUInt32BE(out, r, outOff + 4);
17939 };
17940
17941 DES.prototype._pad = function _pad(buffer, off) {
17942   var value = buffer.length - off;
17943   for (var i = off; i < buffer.length; i++)
17944     buffer[i] = value;
17945
17946   return true;
17947 };
17948
17949 DES.prototype._unpad = function _unpad(buffer) {
17950   var pad = buffer[buffer.length - 1];
17951   for (var i = buffer.length - pad; i < buffer.length; i++)
17952     assert.equal(buffer[i], pad);
17953
17954   return buffer.slice(0, buffer.length - pad);
17955 };
17956
17957 DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
17958   var l = lStart;
17959   var r = rStart;
17960
17961   // Apply f() x16 times
17962   for (var i = 0; i < state.keys.length; i += 2) {
17963     var keyL = state.keys[i];
17964     var keyR = state.keys[i + 1];
17965
17966     // f(r, k)
17967     utils.expand(r, state.tmp, 0);
17968
17969     keyL ^= state.tmp[0];
17970     keyR ^= state.tmp[1];
17971     var s = utils.substitute(keyL, keyR);
17972     var f = utils.permute(s);
17973
17974     var t = r;
17975     r = (l ^ f) >>> 0;
17976     l = t;
17977   }
17978
17979   // Reverse Initial Permutation
17980   utils.rip(r, l, out, off);
17981 };
17982
17983 DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
17984   var l = rStart;
17985   var r = lStart;
17986
17987   // Apply f() x16 times
17988   for (var i = state.keys.length - 2; i >= 0; i -= 2) {
17989     var keyL = state.keys[i];
17990     var keyR = state.keys[i + 1];
17991
17992     // f(r, k)
17993     utils.expand(l, state.tmp, 0);
17994
17995     keyL ^= state.tmp[0];
17996     keyR ^= state.tmp[1];
17997     var s = utils.substitute(keyL, keyR);
17998     var f = utils.permute(s);
17999
18000     var t = l;
18001     l = (r ^ f) >>> 0;
18002     r = t;
18003   }
18004
18005   // Reverse Initial Permutation
18006   utils.rip(l, r, out, off);
18007 };
18008
18009
18010 /***/ }),
18011 /* 204 */
18012 /***/ (function(module, exports, __webpack_require__) {
18013
18014 "use strict";
18015
18016
18017 var assert = __webpack_require__(9);
18018 var inherits = __webpack_require__(1);
18019
18020 var proto = {};
18021
18022 function CBCState(iv) {
18023   assert.equal(iv.length, 8, 'Invalid IV length');
18024
18025   this.iv = new Array(8);
18026   for (var i = 0; i < this.iv.length; i++)
18027     this.iv[i] = iv[i];
18028 }
18029
18030 function instantiate(Base) {
18031   function CBC(options) {
18032     Base.call(this, options);
18033     this._cbcInit();
18034   }
18035   inherits(CBC, Base);
18036
18037   var keys = Object.keys(proto);
18038   for (var i = 0; i < keys.length; i++) {
18039     var key = keys[i];
18040     CBC.prototype[key] = proto[key];
18041   }
18042
18043   CBC.create = function create(options) {
18044     return new CBC(options);
18045   };
18046
18047   return CBC;
18048 }
18049
18050 exports.instantiate = instantiate;
18051
18052 proto._cbcInit = function _cbcInit() {
18053   var state = new CBCState(this.options.iv);
18054   this._cbcState = state;
18055 };
18056
18057 proto._update = function _update(inp, inOff, out, outOff) {
18058   var state = this._cbcState;
18059   var superProto = this.constructor.super_.prototype;
18060
18061   var iv = state.iv;
18062   if (this.type === 'encrypt') {
18063     for (var i = 0; i < this.blockSize; i++)
18064       iv[i] ^= inp[inOff + i];
18065
18066     superProto._update.call(this, iv, 0, out, outOff);
18067
18068     for (var i = 0; i < this.blockSize; i++)
18069       iv[i] = out[outOff + i];
18070   } else {
18071     superProto._update.call(this, inp, inOff, out, outOff);
18072
18073     for (var i = 0; i < this.blockSize; i++)
18074       out[outOff + i] ^= iv[i];
18075
18076     for (var i = 0; i < this.blockSize; i++)
18077       iv[i] = inp[inOff + i];
18078   }
18079 };
18080
18081
18082 /***/ }),
18083 /* 205 */
18084 /***/ (function(module, exports, __webpack_require__) {
18085
18086 "use strict";
18087
18088
18089 var assert = __webpack_require__(9);
18090 var inherits = __webpack_require__(1);
18091
18092 var des = __webpack_require__(64);
18093 var Cipher = des.Cipher;
18094 var DES = des.DES;
18095
18096 function EDEState(type, key) {
18097   assert.equal(key.length, 24, 'Invalid key length');
18098
18099   var k1 = key.slice(0, 8);
18100   var k2 = key.slice(8, 16);
18101   var k3 = key.slice(16, 24);
18102
18103   if (type === 'encrypt') {
18104     this.ciphers = [
18105       DES.create({ type: 'encrypt', key: k1 }),
18106       DES.create({ type: 'decrypt', key: k2 }),
18107       DES.create({ type: 'encrypt', key: k3 })
18108     ];
18109   } else {
18110     this.ciphers = [
18111       DES.create({ type: 'decrypt', key: k3 }),
18112       DES.create({ type: 'encrypt', key: k2 }),
18113       DES.create({ type: 'decrypt', key: k1 })
18114     ];
18115   }
18116 }
18117
18118 function EDE(options) {
18119   Cipher.call(this, options);
18120
18121   var state = new EDEState(this.type, this.options.key);
18122   this._edeState = state;
18123 }
18124 inherits(EDE, Cipher);
18125
18126 module.exports = EDE;
18127
18128 EDE.create = function create(options) {
18129   return new EDE(options);
18130 };
18131
18132 EDE.prototype._update = function _update(inp, inOff, out, outOff) {
18133   var state = this._edeState;
18134
18135   state.ciphers[0]._update(inp, inOff, out, outOff);
18136   state.ciphers[1]._update(out, outOff, out, outOff);
18137   state.ciphers[2]._update(out, outOff, out, outOff);
18138 };
18139
18140 EDE.prototype._pad = DES.prototype._pad;
18141 EDE.prototype._unpad = DES.prototype._unpad;
18142
18143
18144 /***/ }),
18145 /* 206 */
18146 /***/ (function(module, exports, __webpack_require__) {
18147
18148 var MODES = __webpack_require__(66)
18149 var AuthCipher = __webpack_require__(111)
18150 var Buffer = __webpack_require__(2).Buffer
18151 var StreamCipher = __webpack_require__(112)
18152 var Transform = __webpack_require__(18)
18153 var aes = __webpack_require__(43)
18154 var ebtk = __webpack_require__(44)
18155 var inherits = __webpack_require__(1)
18156
18157 function Cipher (mode, key, iv) {
18158   Transform.call(this)
18159
18160   this._cache = new Splitter()
18161   this._cipher = new aes.AES(key)
18162   this._prev = Buffer.from(iv)
18163   this._mode = mode
18164   this._autopadding = true
18165 }
18166
18167 inherits(Cipher, Transform)
18168
18169 Cipher.prototype._update = function (data) {
18170   this._cache.add(data)
18171   var chunk
18172   var thing
18173   var out = []
18174
18175   while ((chunk = this._cache.get())) {
18176     thing = this._mode.encrypt(this, chunk)
18177     out.push(thing)
18178   }
18179
18180   return Buffer.concat(out)
18181 }
18182
18183 var PADDING = Buffer.alloc(16, 0x10)
18184
18185 Cipher.prototype._final = function () {
18186   var chunk = this._cache.flush()
18187   if (this._autopadding) {
18188     chunk = this._mode.encrypt(this, chunk)
18189     this._cipher.scrub()
18190     return chunk
18191   }
18192
18193   if (!chunk.equals(PADDING)) {
18194     this._cipher.scrub()
18195     throw new Error('data not multiple of block length')
18196   }
18197 }
18198
18199 Cipher.prototype.setAutoPadding = function (setTo) {
18200   this._autopadding = !!setTo
18201   return this
18202 }
18203
18204 function Splitter () {
18205   this.cache = Buffer.allocUnsafe(0)
18206 }
18207
18208 Splitter.prototype.add = function (data) {
18209   this.cache = Buffer.concat([this.cache, data])
18210 }
18211
18212 Splitter.prototype.get = function () {
18213   if (this.cache.length > 15) {
18214     var out = this.cache.slice(0, 16)
18215     this.cache = this.cache.slice(16)
18216     return out
18217   }
18218   return null
18219 }
18220
18221 Splitter.prototype.flush = function () {
18222   var len = 16 - this.cache.length
18223   var padBuff = Buffer.allocUnsafe(len)
18224
18225   var i = -1
18226   while (++i < len) {
18227     padBuff.writeUInt8(len, i)
18228   }
18229
18230   return Buffer.concat([this.cache, padBuff])
18231 }
18232
18233 function createCipheriv (suite, password, iv) {
18234   var config = MODES[suite.toLowerCase()]
18235   if (!config) throw new TypeError('invalid suite type')
18236
18237   if (typeof password === 'string') password = Buffer.from(password)
18238   if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
18239
18240   if (typeof iv === 'string') iv = Buffer.from(iv)
18241   if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
18242
18243   if (config.type === 'stream') {
18244     return new StreamCipher(config.module, password, iv)
18245   } else if (config.type === 'auth') {
18246     return new AuthCipher(config.module, password, iv)
18247   }
18248
18249   return new Cipher(config.module, password, iv)
18250 }
18251
18252 function createCipher (suite, password) {
18253   var config = MODES[suite.toLowerCase()]
18254   if (!config) throw new TypeError('invalid suite type')
18255
18256   var keys = ebtk(password, false, config.key, config.iv)
18257   return createCipheriv(suite, keys.key, keys.iv)
18258 }
18259
18260 exports.createCipheriv = createCipheriv
18261 exports.createCipher = createCipher
18262
18263
18264 /***/ }),
18265 /* 207 */
18266 /***/ (function(module, exports) {
18267
18268 exports.encrypt = function (self, block) {
18269   return self._cipher.encryptBlock(block)
18270 }
18271
18272 exports.decrypt = function (self, block) {
18273   return self._cipher.decryptBlock(block)
18274 }
18275
18276
18277 /***/ }),
18278 /* 208 */
18279 /***/ (function(module, exports, __webpack_require__) {
18280
18281 var xor = __webpack_require__(31)
18282
18283 exports.encrypt = function (self, block) {
18284   var data = xor(block, self._prev)
18285
18286   self._prev = self._cipher.encryptBlock(data)
18287   return self._prev
18288 }
18289
18290 exports.decrypt = function (self, block) {
18291   var pad = self._prev
18292
18293   self._prev = block
18294   var out = self._cipher.decryptBlock(block)
18295
18296   return xor(out, pad)
18297 }
18298
18299
18300 /***/ }),
18301 /* 209 */
18302 /***/ (function(module, exports, __webpack_require__) {
18303
18304 var Buffer = __webpack_require__(2).Buffer
18305 var xor = __webpack_require__(31)
18306
18307 function encryptStart (self, data, decrypt) {
18308   var len = data.length
18309   var out = xor(data, self._cache)
18310   self._cache = self._cache.slice(len)
18311   self._prev = Buffer.concat([self._prev, decrypt ? data : out])
18312   return out
18313 }
18314
18315 exports.encrypt = function (self, data, decrypt) {
18316   var out = Buffer.allocUnsafe(0)
18317   var len
18318
18319   while (data.length) {
18320     if (self._cache.length === 0) {
18321       self._cache = self._cipher.encryptBlock(self._prev)
18322       self._prev = Buffer.allocUnsafe(0)
18323     }
18324
18325     if (self._cache.length <= data.length) {
18326       len = self._cache.length
18327       out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
18328       data = data.slice(len)
18329     } else {
18330       out = Buffer.concat([out, encryptStart(self, data, decrypt)])
18331       break
18332     }
18333   }
18334
18335   return out
18336 }
18337
18338
18339 /***/ }),
18340 /* 210 */
18341 /***/ (function(module, exports, __webpack_require__) {
18342
18343 var Buffer = __webpack_require__(2).Buffer
18344
18345 function encryptByte (self, byteParam, decrypt) {
18346   var pad = self._cipher.encryptBlock(self._prev)
18347   var out = pad[0] ^ byteParam
18348
18349   self._prev = Buffer.concat([
18350     self._prev.slice(1),
18351     Buffer.from([decrypt ? byteParam : out])
18352   ])
18353
18354   return out
18355 }
18356
18357 exports.encrypt = function (self, chunk, decrypt) {
18358   var len = chunk.length
18359   var out = Buffer.allocUnsafe(len)
18360   var i = -1
18361
18362   while (++i < len) {
18363     out[i] = encryptByte(self, chunk[i], decrypt)
18364   }
18365
18366   return out
18367 }
18368
18369
18370 /***/ }),
18371 /* 211 */
18372 /***/ (function(module, exports, __webpack_require__) {
18373
18374 var Buffer = __webpack_require__(2).Buffer
18375
18376 function encryptByte (self, byteParam, decrypt) {
18377   var pad
18378   var i = -1
18379   var len = 8
18380   var out = 0
18381   var bit, value
18382   while (++i < len) {
18383     pad = self._cipher.encryptBlock(self._prev)
18384     bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
18385     value = pad[0] ^ bit
18386     out += ((value & 0x80) >> (i % 8))
18387     self._prev = shiftIn(self._prev, decrypt ? bit : value)
18388   }
18389   return out
18390 }
18391
18392 function shiftIn (buffer, value) {
18393   var len = buffer.length
18394   var i = -1
18395   var out = Buffer.allocUnsafe(buffer.length)
18396   buffer = Buffer.concat([buffer, Buffer.from([value])])
18397
18398   while (++i < len) {
18399     out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
18400   }
18401
18402   return out
18403 }
18404
18405 exports.encrypt = function (self, chunk, decrypt) {
18406   var len = chunk.length
18407   var out = Buffer.allocUnsafe(len)
18408   var i = -1
18409
18410   while (++i < len) {
18411     out[i] = encryptByte(self, chunk[i], decrypt)
18412   }
18413
18414   return out
18415 }
18416
18417
18418 /***/ }),
18419 /* 212 */
18420 /***/ (function(module, exports, __webpack_require__) {
18421
18422 /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(31)
18423
18424 function getBlock (self) {
18425   self._prev = self._cipher.encryptBlock(self._prev)
18426   return self._prev
18427 }
18428
18429 exports.encrypt = function (self, chunk) {
18430   while (self._cache.length < chunk.length) {
18431     self._cache = Buffer.concat([self._cache, getBlock(self)])
18432   }
18433
18434   var pad = self._cache.slice(0, chunk.length)
18435   self._cache = self._cache.slice(chunk.length)
18436   return xor(chunk, pad)
18437 }
18438
18439 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
18440
18441 /***/ }),
18442 /* 213 */
18443 /***/ (function(module, exports, __webpack_require__) {
18444
18445 var Buffer = __webpack_require__(2).Buffer
18446 var ZEROES = Buffer.alloc(16, 0)
18447
18448 function toArray (buf) {
18449   return [
18450     buf.readUInt32BE(0),
18451     buf.readUInt32BE(4),
18452     buf.readUInt32BE(8),
18453     buf.readUInt32BE(12)
18454   ]
18455 }
18456
18457 function fromArray (out) {
18458   var buf = Buffer.allocUnsafe(16)
18459   buf.writeUInt32BE(out[0] >>> 0, 0)
18460   buf.writeUInt32BE(out[1] >>> 0, 4)
18461   buf.writeUInt32BE(out[2] >>> 0, 8)
18462   buf.writeUInt32BE(out[3] >>> 0, 12)
18463   return buf
18464 }
18465
18466 function GHASH (key) {
18467   this.h = key
18468   this.state = Buffer.alloc(16, 0)
18469   this.cache = Buffer.allocUnsafe(0)
18470 }
18471
18472 // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
18473 // by Juho Vähä-Herttua
18474 GHASH.prototype.ghash = function (block) {
18475   var i = -1
18476   while (++i < block.length) {
18477     this.state[i] ^= block[i]
18478   }
18479   this._multiply()
18480 }
18481
18482 GHASH.prototype._multiply = function () {
18483   var Vi = toArray(this.h)
18484   var Zi = [0, 0, 0, 0]
18485   var j, xi, lsbVi
18486   var i = -1
18487   while (++i < 128) {
18488     xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
18489     if (xi) {
18490       // Z_i+1 = Z_i ^ V_i
18491       Zi[0] ^= Vi[0]
18492       Zi[1] ^= Vi[1]
18493       Zi[2] ^= Vi[2]
18494       Zi[3] ^= Vi[3]
18495     }
18496
18497     // Store the value of LSB(V_i)
18498     lsbVi = (Vi[3] & 1) !== 0
18499
18500     // V_i+1 = V_i >> 1
18501     for (j = 3; j > 0; j--) {
18502       Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
18503     }
18504     Vi[0] = Vi[0] >>> 1
18505
18506     // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
18507     if (lsbVi) {
18508       Vi[0] = Vi[0] ^ (0xe1 << 24)
18509     }
18510   }
18511   this.state = fromArray(Zi)
18512 }
18513
18514 GHASH.prototype.update = function (buf) {
18515   this.cache = Buffer.concat([this.cache, buf])
18516   var chunk
18517   while (this.cache.length >= 16) {
18518     chunk = this.cache.slice(0, 16)
18519     this.cache = this.cache.slice(16)
18520     this.ghash(chunk)
18521   }
18522 }
18523
18524 GHASH.prototype.final = function (abl, bl) {
18525   if (this.cache.length) {
18526     this.ghash(Buffer.concat([this.cache, ZEROES], 16))
18527   }
18528
18529   this.ghash(fromArray([0, abl, 0, bl]))
18530   return this.state
18531 }
18532
18533 module.exports = GHASH
18534
18535
18536 /***/ }),
18537 /* 214 */
18538 /***/ (function(module, exports, __webpack_require__) {
18539
18540 var AuthCipher = __webpack_require__(111)
18541 var Buffer = __webpack_require__(2).Buffer
18542 var MODES = __webpack_require__(66)
18543 var StreamCipher = __webpack_require__(112)
18544 var Transform = __webpack_require__(18)
18545 var aes = __webpack_require__(43)
18546 var ebtk = __webpack_require__(44)
18547 var inherits = __webpack_require__(1)
18548
18549 function Decipher (mode, key, iv) {
18550   Transform.call(this)
18551
18552   this._cache = new Splitter()
18553   this._last = void 0
18554   this._cipher = new aes.AES(key)
18555   this._prev = Buffer.from(iv)
18556   this._mode = mode
18557   this._autopadding = true
18558 }
18559
18560 inherits(Decipher, Transform)
18561
18562 Decipher.prototype._update = function (data) {
18563   this._cache.add(data)
18564   var chunk
18565   var thing
18566   var out = []
18567   while ((chunk = this._cache.get(this._autopadding))) {
18568     thing = this._mode.decrypt(this, chunk)
18569     out.push(thing)
18570   }
18571   return Buffer.concat(out)
18572 }
18573
18574 Decipher.prototype._final = function () {
18575   var chunk = this._cache.flush()
18576   if (this._autopadding) {
18577     return unpad(this._mode.decrypt(this, chunk))
18578   } else if (chunk) {
18579     throw new Error('data not multiple of block length')
18580   }
18581 }
18582
18583 Decipher.prototype.setAutoPadding = function (setTo) {
18584   this._autopadding = !!setTo
18585   return this
18586 }
18587
18588 function Splitter () {
18589   this.cache = Buffer.allocUnsafe(0)
18590 }
18591
18592 Splitter.prototype.add = function (data) {
18593   this.cache = Buffer.concat([this.cache, data])
18594 }
18595
18596 Splitter.prototype.get = function (autoPadding) {
18597   var out
18598   if (autoPadding) {
18599     if (this.cache.length > 16) {
18600       out = this.cache.slice(0, 16)
18601       this.cache = this.cache.slice(16)
18602       return out
18603     }
18604   } else {
18605     if (this.cache.length >= 16) {
18606       out = this.cache.slice(0, 16)
18607       this.cache = this.cache.slice(16)
18608       return out
18609     }
18610   }
18611
18612   return null
18613 }
18614
18615 Splitter.prototype.flush = function () {
18616   if (this.cache.length) return this.cache
18617 }
18618
18619 function unpad (last) {
18620   var padded = last[15]
18621   if (padded < 1 || padded > 16) {
18622     throw new Error('unable to decrypt data')
18623   }
18624   var i = -1
18625   while (++i < padded) {
18626     if (last[(i + (16 - padded))] !== padded) {
18627       throw new Error('unable to decrypt data')
18628     }
18629   }
18630   if (padded === 16) return
18631
18632   return last.slice(0, 16 - padded)
18633 }
18634
18635 function createDecipheriv (suite, password, iv) {
18636   var config = MODES[suite.toLowerCase()]
18637   if (!config) throw new TypeError('invalid suite type')
18638
18639   if (typeof iv === 'string') iv = Buffer.from(iv)
18640   if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
18641
18642   if (typeof password === 'string') password = Buffer.from(password)
18643   if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
18644
18645   if (config.type === 'stream') {
18646     return new StreamCipher(config.module, password, iv, true)
18647   } else if (config.type === 'auth') {
18648     return new AuthCipher(config.module, password, iv, true)
18649   }
18650
18651   return new Decipher(config.module, password, iv)
18652 }
18653
18654 function createDecipher (suite, password) {
18655   var config = MODES[suite.toLowerCase()]
18656   if (!config) throw new TypeError('invalid suite type')
18657
18658   var keys = ebtk(password, false, config.key, config.iv)
18659   return createDecipheriv(suite, keys.key, keys.iv)
18660 }
18661
18662 exports.createDecipher = createDecipher
18663 exports.createDecipheriv = createDecipheriv
18664
18665
18666 /***/ }),
18667 /* 215 */
18668 /***/ (function(module, exports) {
18669
18670 exports['des-ecb'] = {
18671   key: 8,
18672   iv: 0
18673 }
18674 exports['des-cbc'] = exports.des = {
18675   key: 8,
18676   iv: 8
18677 }
18678 exports['des-ede3-cbc'] = exports.des3 = {
18679   key: 24,
18680   iv: 8
18681 }
18682 exports['des-ede3'] = {
18683   key: 24,
18684   iv: 0
18685 }
18686 exports['des-ede-cbc'] = {
18687   key: 16,
18688   iv: 8
18689 }
18690 exports['des-ede'] = {
18691   key: 16,
18692   iv: 0
18693 }
18694
18695
18696 /***/ }),
18697 /* 216 */
18698 /***/ (function(module, exports, __webpack_require__) {
18699
18700 /* WEBPACK VAR INJECTION */(function(Buffer) {var generatePrime = __webpack_require__(113)
18701 var primes = __webpack_require__(219)
18702
18703 var DH = __webpack_require__(220)
18704
18705 function getDiffieHellman (mod) {
18706   var prime = new Buffer(primes[mod].prime, 'hex')
18707   var gen = new Buffer(primes[mod].gen, 'hex')
18708
18709   return new DH(prime, gen)
18710 }
18711
18712 var ENCODINGS = {
18713   'binary': true, 'hex': true, 'base64': true
18714 }
18715
18716 function createDiffieHellman (prime, enc, generator, genc) {
18717   if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
18718     return createDiffieHellman(prime, 'binary', enc, generator)
18719   }
18720
18721   enc = enc || 'binary'
18722   genc = genc || 'binary'
18723   generator = generator || new Buffer([2])
18724
18725   if (!Buffer.isBuffer(generator)) {
18726     generator = new Buffer(generator, genc)
18727   }
18728
18729   if (typeof prime === 'number') {
18730     return new DH(generatePrime(prime, generator), generator, true)
18731   }
18732
18733   if (!Buffer.isBuffer(prime)) {
18734     prime = new Buffer(prime, enc)
18735   }
18736
18737   return new DH(prime, generator, true)
18738 }
18739
18740 exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
18741 exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
18742
18743 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
18744
18745 /***/ }),
18746 /* 217 */
18747 /***/ (function(module, exports) {
18748
18749 /* (ignored) */
18750
18751 /***/ }),
18752 /* 218 */
18753 /***/ (function(module, exports) {
18754
18755 /* (ignored) */
18756
18757 /***/ }),
18758 /* 219 */
18759 /***/ (function(module, exports) {
18760
18761 module.exports = {"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}
18762
18763 /***/ }),
18764 /* 220 */
18765 /***/ (function(module, exports, __webpack_require__) {
18766
18767 /* WEBPACK VAR INJECTION */(function(Buffer) {var BN = __webpack_require__(4);
18768 var MillerRabin = __webpack_require__(114);
18769 var millerRabin = new MillerRabin();
18770 var TWENTYFOUR = new BN(24);
18771 var ELEVEN = new BN(11);
18772 var TEN = new BN(10);
18773 var THREE = new BN(3);
18774 var SEVEN = new BN(7);
18775 var primes = __webpack_require__(113);
18776 var randomBytes = __webpack_require__(23);
18777 module.exports = DH;
18778
18779 function setPublicKey(pub, enc) {
18780   enc = enc || 'utf8';
18781   if (!Buffer.isBuffer(pub)) {
18782     pub = new Buffer(pub, enc);
18783   }
18784   this._pub = new BN(pub);
18785   return this;
18786 }
18787
18788 function setPrivateKey(priv, enc) {
18789   enc = enc || 'utf8';
18790   if (!Buffer.isBuffer(priv)) {
18791     priv = new Buffer(priv, enc);
18792   }
18793   this._priv = new BN(priv);
18794   return this;
18795 }
18796
18797 var primeCache = {};
18798 function checkPrime(prime, generator) {
18799   var gen = generator.toString('hex');
18800   var hex = [gen, prime.toString(16)].join('_');
18801   if (hex in primeCache) {
18802     return primeCache[hex];
18803   }
18804   var error = 0;
18805
18806   if (prime.isEven() ||
18807     !primes.simpleSieve ||
18808     !primes.fermatTest(prime) ||
18809     !millerRabin.test(prime)) {
18810     //not a prime so +1
18811     error += 1;
18812
18813     if (gen === '02' || gen === '05') {
18814       // we'd be able to check the generator
18815       // it would fail so +8
18816       error += 8;
18817     } else {
18818       //we wouldn't be able to test the generator
18819       // so +4
18820       error += 4;
18821     }
18822     primeCache[hex] = error;
18823     return error;
18824   }
18825   if (!millerRabin.test(prime.shrn(1))) {
18826     //not a safe prime
18827     error += 2;
18828   }
18829   var rem;
18830   switch (gen) {
18831     case '02':
18832       if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
18833         // unsuidable generator
18834         error += 8;
18835       }
18836       break;
18837     case '05':
18838       rem = prime.mod(TEN);
18839       if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
18840         // prime mod 10 needs to equal 3 or 7
18841         error += 8;
18842       }
18843       break;
18844     default:
18845       error += 4;
18846   }
18847   primeCache[hex] = error;
18848   return error;
18849 }
18850
18851 function DH(prime, generator, malleable) {
18852   this.setGenerator(generator);
18853   this.__prime = new BN(prime);
18854   this._prime = BN.mont(this.__prime);
18855   this._primeLen = prime.length;
18856   this._pub = undefined;
18857   this._priv = undefined;
18858   this._primeCode = undefined;
18859   if (malleable) {
18860     this.setPublicKey = setPublicKey;
18861     this.setPrivateKey = setPrivateKey;
18862   } else {
18863     this._primeCode = 8;
18864   }
18865 }
18866 Object.defineProperty(DH.prototype, 'verifyError', {
18867   enumerable: true,
18868   get: function () {
18869     if (typeof this._primeCode !== 'number') {
18870       this._primeCode = checkPrime(this.__prime, this.__gen);
18871     }
18872     return this._primeCode;
18873   }
18874 });
18875 DH.prototype.generateKeys = function () {
18876   if (!this._priv) {
18877     this._priv = new BN(randomBytes(this._primeLen));
18878   }
18879   this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
18880   return this.getPublicKey();
18881 };
18882
18883 DH.prototype.computeSecret = function (other) {
18884   other = new BN(other);
18885   other = other.toRed(this._prime);
18886   var secret = other.redPow(this._priv).fromRed();
18887   var out = new Buffer(secret.toArray());
18888   var prime = this.getPrime();
18889   if (out.length < prime.length) {
18890     var front = new Buffer(prime.length - out.length);
18891     front.fill(0);
18892     out = Buffer.concat([front, out]);
18893   }
18894   return out;
18895 };
18896
18897 DH.prototype.getPublicKey = function getPublicKey(enc) {
18898   return formatReturnValue(this._pub, enc);
18899 };
18900
18901 DH.prototype.getPrivateKey = function getPrivateKey(enc) {
18902   return formatReturnValue(this._priv, enc);
18903 };
18904
18905 DH.prototype.getPrime = function (enc) {
18906   return formatReturnValue(this.__prime, enc);
18907 };
18908
18909 DH.prototype.getGenerator = function (enc) {
18910   return formatReturnValue(this._gen, enc);
18911 };
18912
18913 DH.prototype.setGenerator = function (gen, enc) {
18914   enc = enc || 'utf8';
18915   if (!Buffer.isBuffer(gen)) {
18916     gen = new Buffer(gen, enc);
18917   }
18918   this.__gen = gen;
18919   this._gen = new BN(gen);
18920   return this;
18921 };
18922
18923 function formatReturnValue(bn, enc) {
18924   var buf = new Buffer(bn.toArray());
18925   if (!enc) {
18926     return buf;
18927   } else {
18928     return buf.toString(enc);
18929   }
18930 }
18931
18932 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
18933
18934 /***/ }),
18935 /* 221 */
18936 /***/ (function(module, exports, __webpack_require__) {
18937
18938 /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(29)
18939 var stream = __webpack_require__(57)
18940 var inherits = __webpack_require__(1)
18941 var sign = __webpack_require__(222)
18942 var verify = __webpack_require__(258)
18943
18944 var algorithms = __webpack_require__(103)
18945 Object.keys(algorithms).forEach(function (key) {
18946   algorithms[key].id = new Buffer(algorithms[key].id, 'hex')
18947   algorithms[key.toLowerCase()] = algorithms[key]
18948 })
18949
18950 function Sign (algorithm) {
18951   stream.Writable.call(this)
18952
18953   var data = algorithms[algorithm]
18954   if (!data) throw new Error('Unknown message digest')
18955
18956   this._hashType = data.hash
18957   this._hash = createHash(data.hash)
18958   this._tag = data.id
18959   this._signType = data.sign
18960 }
18961 inherits(Sign, stream.Writable)
18962
18963 Sign.prototype._write = function _write (data, _, done) {
18964   this._hash.update(data)
18965   done()
18966 }
18967
18968 Sign.prototype.update = function update (data, enc) {
18969   if (typeof data === 'string') data = new Buffer(data, enc)
18970
18971   this._hash.update(data)
18972   return this
18973 }
18974
18975 Sign.prototype.sign = function signMethod (key, enc) {
18976   this.end()
18977   var hash = this._hash.digest()
18978   var sig = sign(hash, key, this._hashType, this._signType, this._tag)
18979
18980   return enc ? sig.toString(enc) : sig
18981 }
18982
18983 function Verify (algorithm) {
18984   stream.Writable.call(this)
18985
18986   var data = algorithms[algorithm]
18987   if (!data) throw new Error('Unknown message digest')
18988
18989   this._hash = createHash(data.hash)
18990   this._tag = data.id
18991   this._signType = data.sign
18992 }
18993 inherits(Verify, stream.Writable)
18994
18995 Verify.prototype._write = function _write (data, _, done) {
18996   this._hash.update(data)
18997   done()
18998 }
18999
19000 Verify.prototype.update = function update (data, enc) {
19001   if (typeof data === 'string') data = new Buffer(data, enc)
19002
19003   this._hash.update(data)
19004   return this
19005 }
19006
19007 Verify.prototype.verify = function verifyMethod (key, sig, enc) {
19008   if (typeof sig === 'string') sig = new Buffer(sig, enc)
19009
19010   this.end()
19011   var hash = this._hash.digest()
19012   return verify(sig, hash, key, this._signType, this._tag)
19013 }
19014
19015 function createSign (algorithm) {
19016   return new Sign(algorithm)
19017 }
19018
19019 function createVerify (algorithm) {
19020   return new Verify(algorithm)
19021 }
19022
19023 module.exports = {
19024   Sign: createSign,
19025   Verify: createVerify,
19026   createSign: createSign,
19027   createVerify: createVerify
19028 }
19029
19030 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
19031
19032 /***/ }),
19033 /* 222 */
19034 /***/ (function(module, exports, __webpack_require__) {
19035
19036 /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
19037 var createHmac = __webpack_require__(101)
19038 var crt = __webpack_require__(67)
19039 var EC = __webpack_require__(6).ec
19040 var BN = __webpack_require__(4)
19041 var parseKeys = __webpack_require__(46)
19042 var curves = __webpack_require__(124)
19043
19044 function sign (hash, key, hashType, signType, tag) {
19045   var priv = parseKeys(key)
19046   if (priv.curve) {
19047     // rsa keys can be interpreted as ecdsa ones in openssl
19048     if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
19049     return ecSign(hash, priv)
19050   } else if (priv.type === 'dsa') {
19051     if (signType !== 'dsa') throw new Error('wrong private key type')
19052     return dsaSign(hash, priv, hashType)
19053   } else {
19054     if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
19055   }
19056   hash = Buffer.concat([tag, hash])
19057   var len = priv.modulus.byteLength()
19058   var pad = [ 0, 1 ]
19059   while (hash.length + pad.length + 1 < len) pad.push(0xff)
19060   pad.push(0x00)
19061   var i = -1
19062   while (++i < hash.length) pad.push(hash[i])
19063
19064   var out = crt(pad, priv)
19065   return out
19066 }
19067
19068 function ecSign (hash, priv) {
19069   var curveId = curves[priv.curve.join('.')]
19070   if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
19071
19072   var curve = new EC(curveId)
19073   var key = curve.keyFromPrivate(priv.privateKey)
19074   var out = key.sign(hash)
19075
19076   return new Buffer(out.toDER())
19077 }
19078
19079 function dsaSign (hash, priv, algo) {
19080   var x = priv.params.priv_key
19081   var p = priv.params.p
19082   var q = priv.params.q
19083   var g = priv.params.g
19084   var r = new BN(0)
19085   var k
19086   var H = bits2int(hash, q).mod(q)
19087   var s = false
19088   var kv = getKey(x, q, hash, algo)
19089   while (s === false) {
19090     k = makeKey(q, kv, algo)
19091     r = makeR(g, k, p, q)
19092     s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
19093     if (s.cmpn(0) === 0) {
19094       s = false
19095       r = new BN(0)
19096     }
19097   }
19098   return toDER(r, s)
19099 }
19100
19101 function toDER (r, s) {
19102   r = r.toArray()
19103   s = s.toArray()
19104
19105   // Pad values
19106   if (r[0] & 0x80) r = [ 0 ].concat(r)
19107   if (s[0] & 0x80) s = [ 0 ].concat(s)
19108
19109   var total = r.length + s.length + 4
19110   var res = [ 0x30, total, 0x02, r.length ]
19111   res = res.concat(r, [ 0x02, s.length ], s)
19112   return new Buffer(res)
19113 }
19114
19115 function getKey (x, q, hash, algo) {
19116   x = new Buffer(x.toArray())
19117   if (x.length < q.byteLength()) {
19118     var zeros = new Buffer(q.byteLength() - x.length)
19119     zeros.fill(0)
19120     x = Buffer.concat([ zeros, x ])
19121   }
19122   var hlen = hash.length
19123   var hbits = bits2octets(hash, q)
19124   var v = new Buffer(hlen)
19125   v.fill(1)
19126   var k = new Buffer(hlen)
19127   k.fill(0)
19128   k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest()
19129   v = createHmac(algo, k).update(v).digest()
19130   k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest()
19131   v = createHmac(algo, k).update(v).digest()
19132   return { k: k, v: v }
19133 }
19134
19135 function bits2int (obits, q) {
19136   var bits = new BN(obits)
19137   var shift = (obits.length << 3) - q.bitLength()
19138   if (shift > 0) bits.ishrn(shift)
19139   return bits
19140 }
19141
19142 function bits2octets (bits, q) {
19143   bits = bits2int(bits, q)
19144   bits = bits.mod(q)
19145   var out = new Buffer(bits.toArray())
19146   if (out.length < q.byteLength()) {
19147     var zeros = new Buffer(q.byteLength() - out.length)
19148     zeros.fill(0)
19149     out = Buffer.concat([ zeros, out ])
19150   }
19151   return out
19152 }
19153
19154 function makeKey (q, kv, algo) {
19155   var t
19156   var k
19157
19158   do {
19159     t = new Buffer(0)
19160
19161     while (t.length * 8 < q.bitLength()) {
19162       kv.v = createHmac(algo, kv.k).update(kv.v).digest()
19163       t = Buffer.concat([ t, kv.v ])
19164     }
19165
19166     k = bits2int(t, q)
19167     kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest()
19168     kv.v = createHmac(algo, kv.k).update(kv.v).digest()
19169   } while (k.cmp(q) !== -1)
19170
19171   return k
19172 }
19173
19174 function makeR (g, k, p, q) {
19175   return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
19176 }
19177
19178 module.exports = sign
19179 module.exports.getKey = getKey
19180 module.exports.makeKey = makeKey
19181
19182 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
19183
19184 /***/ }),
19185 /* 223 */
19186 /***/ (function(module, exports) {
19187
19188 module.exports = {"_args":[["elliptic@6.4.1","/Users/jnet/Documents/random/Bytom-Chrome-Extension"]],"_development":true,"_from":"elliptic@6.4.1","_id":"elliptic@6.4.1","_inBundle":false,"_integrity":"sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==","_location":"/elliptic","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"elliptic@6.4.1","name":"elliptic","escapedName":"elliptic","rawSpec":"6.4.1","saveSpec":null,"fetchSpec":"6.4.1"},"_requiredBy":["/browserify-sign","/create-ecdh"],"_resolved":"https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz","_spec":"6.4.1","_where":"/Users/jnet/Documents/random/Bytom-Chrome-Extension","author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"bugs":{"url":"https://github.com/indutny/elliptic/issues"},"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},"description":"EC cryptography","devDependencies":{"brfs":"^1.4.3","coveralls":"^2.11.3","grunt":"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2","istanbul":"^0.4.2","jscs":"^2.9.0","jshint":"^2.6.0","mocha":"^2.1.0"},"files":["lib"],"homepage":"https://github.com/indutny/elliptic","keywords":["EC","Elliptic","curve","Cryptography"],"license":"MIT","main":"lib/elliptic.js","name":"elliptic","repository":{"type":"git","url":"git+ssh://git@github.com/indutny/elliptic.git"},"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","test":"npm run lint && npm run unit","unit":"istanbul test _mocha --reporter=spec test/index.js","version":"grunt dist && git add dist/"},"version":"6.4.1"}
19189
19190 /***/ }),
19191 /* 224 */
19192 /***/ (function(module, exports, __webpack_require__) {
19193
19194 "use strict";
19195
19196
19197 var utils = exports;
19198 var BN = __webpack_require__(4);
19199 var minAssert = __webpack_require__(9);
19200 var minUtils = __webpack_require__(116);
19201
19202 utils.assert = minAssert;
19203 utils.toArray = minUtils.toArray;
19204 utils.zero2 = minUtils.zero2;
19205 utils.toHex = minUtils.toHex;
19206 utils.encode = minUtils.encode;
19207
19208 // Represent num in a w-NAF form
19209 function getNAF(num, w) {
19210   var naf = [];
19211   var ws = 1 << (w + 1);
19212   var k = num.clone();
19213   while (k.cmpn(1) >= 0) {
19214     var z;
19215     if (k.isOdd()) {
19216       var mod = k.andln(ws - 1);
19217       if (mod > (ws >> 1) - 1)
19218         z = (ws >> 1) - mod;
19219       else
19220         z = mod;
19221       k.isubn(z);
19222     } else {
19223       z = 0;
19224     }
19225     naf.push(z);
19226
19227     // Optimization, shift by word if possible
19228     var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
19229     for (var i = 1; i < shift; i++)
19230       naf.push(0);
19231     k.iushrn(shift);
19232   }
19233
19234   return naf;
19235 }
19236 utils.getNAF = getNAF;
19237
19238 // Represent k1, k2 in a Joint Sparse Form
19239 function getJSF(k1, k2) {
19240   var jsf = [
19241     [],
19242     []
19243   ];
19244
19245   k1 = k1.clone();
19246   k2 = k2.clone();
19247   var d1 = 0;
19248   var d2 = 0;
19249   while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
19250
19251     // First phase
19252     var m14 = (k1.andln(3) + d1) & 3;
19253     var m24 = (k2.andln(3) + d2) & 3;
19254     if (m14 === 3)
19255       m14 = -1;
19256     if (m24 === 3)
19257       m24 = -1;
19258     var u1;
19259     if ((m14 & 1) === 0) {
19260       u1 = 0;
19261     } else {
19262       var m8 = (k1.andln(7) + d1) & 7;
19263       if ((m8 === 3 || m8 === 5) && m24 === 2)
19264         u1 = -m14;
19265       else
19266         u1 = m14;
19267     }
19268     jsf[0].push(u1);
19269
19270     var u2;
19271     if ((m24 & 1) === 0) {
19272       u2 = 0;
19273     } else {
19274       var m8 = (k2.andln(7) + d2) & 7;
19275       if ((m8 === 3 || m8 === 5) && m14 === 2)
19276         u2 = -m24;
19277       else
19278         u2 = m24;
19279     }
19280     jsf[1].push(u2);
19281
19282     // Second phase
19283     if (2 * d1 === u1 + 1)
19284       d1 = 1 - d1;
19285     if (2 * d2 === u2 + 1)
19286       d2 = 1 - d2;
19287     k1.iushrn(1);
19288     k2.iushrn(1);
19289   }
19290
19291   return jsf;
19292 }
19293 utils.getJSF = getJSF;
19294
19295 function cachedProperty(obj, name, computer) {
19296   var key = '_' + name;
19297   obj.prototype[name] = function cachedProperty() {
19298     return this[key] !== undefined ? this[key] :
19299            this[key] = computer.call(this);
19300   };
19301 }
19302 utils.cachedProperty = cachedProperty;
19303
19304 function parseBytes(bytes) {
19305   return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
19306                                      bytes;
19307 }
19308 utils.parseBytes = parseBytes;
19309
19310 function intFromLE(bytes) {
19311   return new BN(bytes, 'hex', 'le');
19312 }
19313 utils.intFromLE = intFromLE;
19314
19315
19316
19317 /***/ }),
19318 /* 225 */
19319 /***/ (function(module, exports, __webpack_require__) {
19320
19321 "use strict";
19322
19323
19324 var BN = __webpack_require__(4);
19325 var elliptic = __webpack_require__(6);
19326 var utils = elliptic.utils;
19327 var getNAF = utils.getNAF;
19328 var getJSF = utils.getJSF;
19329 var assert = utils.assert;
19330
19331 function BaseCurve(type, conf) {
19332   this.type = type;
19333   this.p = new BN(conf.p, 16);
19334
19335   // Use Montgomery, when there is no fast reduction for the prime
19336   this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
19337
19338   // Useful for many curves
19339   this.zero = new BN(0).toRed(this.red);
19340   this.one = new BN(1).toRed(this.red);
19341   this.two = new BN(2).toRed(this.red);
19342
19343   // Curve configuration, optional
19344   this.n = conf.n && new BN(conf.n, 16);
19345   this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
19346
19347   // Temporary arrays
19348   this._wnafT1 = new Array(4);
19349   this._wnafT2 = new Array(4);
19350   this._wnafT3 = new Array(4);
19351   this._wnafT4 = new Array(4);
19352
19353   // Generalized Greg Maxwell's trick
19354   var adjustCount = this.n && this.p.div(this.n);
19355   if (!adjustCount || adjustCount.cmpn(100) > 0) {
19356     this.redN = null;
19357   } else {
19358     this._maxwellTrick = true;
19359     this.redN = this.n.toRed(this.red);
19360   }
19361 }
19362 module.exports = BaseCurve;
19363
19364 BaseCurve.prototype.point = function point() {
19365   throw new Error('Not implemented');
19366 };
19367
19368 BaseCurve.prototype.validate = function validate() {
19369   throw new Error('Not implemented');
19370 };
19371
19372 BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
19373   assert(p.precomputed);
19374   var doubles = p._getDoubles();
19375
19376   var naf = getNAF(k, 1);
19377   var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
19378   I /= 3;
19379
19380   // Translate into more windowed form
19381   var repr = [];
19382   for (var j = 0; j < naf.length; j += doubles.step) {
19383     var nafW = 0;
19384     for (var k = j + doubles.step - 1; k >= j; k--)
19385       nafW = (nafW << 1) + naf[k];
19386     repr.push(nafW);
19387   }
19388
19389   var a = this.jpoint(null, null, null);
19390   var b = this.jpoint(null, null, null);
19391   for (var i = I; i > 0; i--) {
19392     for (var j = 0; j < repr.length; j++) {
19393       var nafW = repr[j];
19394       if (nafW === i)
19395         b = b.mixedAdd(doubles.points[j]);
19396       else if (nafW === -i)
19397         b = b.mixedAdd(doubles.points[j].neg());
19398     }
19399     a = a.add(b);
19400   }
19401   return a.toP();
19402 };
19403
19404 BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
19405   var w = 4;
19406
19407   // Precompute window
19408   var nafPoints = p._getNAFPoints(w);
19409   w = nafPoints.wnd;
19410   var wnd = nafPoints.points;
19411
19412   // Get NAF form
19413   var naf = getNAF(k, w);
19414
19415   // Add `this`*(N+1) for every w-NAF index
19416   var acc = this.jpoint(null, null, null);
19417   for (var i = naf.length - 1; i >= 0; i--) {
19418     // Count zeroes
19419     for (var k = 0; i >= 0 && naf[i] === 0; i--)
19420       k++;
19421     if (i >= 0)
19422       k++;
19423     acc = acc.dblp(k);
19424
19425     if (i < 0)
19426       break;
19427     var z = naf[i];
19428     assert(z !== 0);
19429     if (p.type === 'affine') {
19430       // J +- P
19431       if (z > 0)
19432         acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
19433       else
19434         acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
19435     } else {
19436       // J +- J
19437       if (z > 0)
19438         acc = acc.add(wnd[(z - 1) >> 1]);
19439       else
19440         acc = acc.add(wnd[(-z - 1) >> 1].neg());
19441     }
19442   }
19443   return p.type === 'affine' ? acc.toP() : acc;
19444 };
19445
19446 BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
19447                                                        points,
19448                                                        coeffs,
19449                                                        len,
19450                                                        jacobianResult) {
19451   var wndWidth = this._wnafT1;
19452   var wnd = this._wnafT2;
19453   var naf = this._wnafT3;
19454
19455   // Fill all arrays
19456   var max = 0;
19457   for (var i = 0; i < len; i++) {
19458     var p = points[i];
19459     var nafPoints = p._getNAFPoints(defW);
19460     wndWidth[i] = nafPoints.wnd;
19461     wnd[i] = nafPoints.points;
19462   }
19463
19464   // Comb small window NAFs
19465   for (var i = len - 1; i >= 1; i -= 2) {
19466     var a = i - 1;
19467     var b = i;
19468     if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
19469       naf[a] = getNAF(coeffs[a], wndWidth[a]);
19470       naf[b] = getNAF(coeffs[b], wndWidth[b]);
19471       max = Math.max(naf[a].length, max);
19472       max = Math.max(naf[b].length, max);
19473       continue;
19474     }
19475
19476     var comb = [
19477       points[a], /* 1 */
19478       null, /* 3 */
19479       null, /* 5 */
19480       points[b] /* 7 */
19481     ];
19482
19483     // Try to avoid Projective points, if possible
19484     if (points[a].y.cmp(points[b].y) === 0) {
19485       comb[1] = points[a].add(points[b]);
19486       comb[2] = points[a].toJ().mixedAdd(points[b].neg());
19487     } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
19488       comb[1] = points[a].toJ().mixedAdd(points[b]);
19489       comb[2] = points[a].add(points[b].neg());
19490     } else {
19491       comb[1] = points[a].toJ().mixedAdd(points[b]);
19492       comb[2] = points[a].toJ().mixedAdd(points[b].neg());
19493     }
19494
19495     var index = [
19496       -3, /* -1 -1 */
19497       -1, /* -1 0 */
19498       -5, /* -1 1 */
19499       -7, /* 0 -1 */
19500       0, /* 0 0 */
19501       7, /* 0 1 */
19502       5, /* 1 -1 */
19503       1, /* 1 0 */
19504       3  /* 1 1 */
19505     ];
19506
19507     var jsf = getJSF(coeffs[a], coeffs[b]);
19508     max = Math.max(jsf[0].length, max);
19509     naf[a] = new Array(max);
19510     naf[b] = new Array(max);
19511     for (var j = 0; j < max; j++) {
19512       var ja = jsf[0][j] | 0;
19513       var jb = jsf[1][j] | 0;
19514
19515       naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
19516       naf[b][j] = 0;
19517       wnd[a] = comb;
19518     }
19519   }
19520
19521   var acc = this.jpoint(null, null, null);
19522   var tmp = this._wnafT4;
19523   for (var i = max; i >= 0; i--) {
19524     var k = 0;
19525
19526     while (i >= 0) {
19527       var zero = true;
19528       for (var j = 0; j < len; j++) {
19529         tmp[j] = naf[j][i] | 0;
19530         if (tmp[j] !== 0)
19531           zero = false;
19532       }
19533       if (!zero)
19534         break;
19535       k++;
19536       i--;
19537     }
19538     if (i >= 0)
19539       k++;
19540     acc = acc.dblp(k);
19541     if (i < 0)
19542       break;
19543
19544     for (var j = 0; j < len; j++) {
19545       var z = tmp[j];
19546       var p;
19547       if (z === 0)
19548         continue;
19549       else if (z > 0)
19550         p = wnd[j][(z - 1) >> 1];
19551       else if (z < 0)
19552         p = wnd[j][(-z - 1) >> 1].neg();
19553
19554       if (p.type === 'affine')
19555         acc = acc.mixedAdd(p);
19556       else
19557         acc = acc.add(p);
19558     }
19559   }
19560   // Zeroify references
19561   for (var i = 0; i < len; i++)
19562     wnd[i] = null;
19563
19564   if (jacobianResult)
19565     return acc;
19566   else
19567     return acc.toP();
19568 };
19569
19570 function BasePoint(curve, type) {
19571   this.curve = curve;
19572   this.type = type;
19573   this.precomputed = null;
19574 }
19575 BaseCurve.BasePoint = BasePoint;
19576
19577 BasePoint.prototype.eq = function eq(/*other*/) {
19578   throw new Error('Not implemented');
19579 };
19580
19581 BasePoint.prototype.validate = function validate() {
19582   return this.curve.validate(this);
19583 };
19584
19585 BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
19586   bytes = utils.toArray(bytes, enc);
19587
19588   var len = this.p.byteLength();
19589
19590   // uncompressed, hybrid-odd, hybrid-even
19591   if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
19592       bytes.length - 1 === 2 * len) {
19593     if (bytes[0] === 0x06)
19594       assert(bytes[bytes.length - 1] % 2 === 0);
19595     else if (bytes[0] === 0x07)
19596       assert(bytes[bytes.length - 1] % 2 === 1);
19597
19598     var res =  this.point(bytes.slice(1, 1 + len),
19599                           bytes.slice(1 + len, 1 + 2 * len));
19600
19601     return res;
19602   } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
19603               bytes.length - 1 === len) {
19604     return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
19605   }
19606   throw new Error('Unknown point format');
19607 };
19608
19609 BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
19610   return this.encode(enc, true);
19611 };
19612
19613 BasePoint.prototype._encode = function _encode(compact) {
19614   var len = this.curve.p.byteLength();
19615   var x = this.getX().toArray('be', len);
19616
19617   if (compact)
19618     return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
19619
19620   return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
19621 };
19622
19623 BasePoint.prototype.encode = function encode(enc, compact) {
19624   return utils.encode(this._encode(compact), enc);
19625 };
19626
19627 BasePoint.prototype.precompute = function precompute(power) {
19628   if (this.precomputed)
19629     return this;
19630
19631   var precomputed = {
19632     doubles: null,
19633     naf: null,
19634     beta: null
19635   };
19636   precomputed.naf = this._getNAFPoints(8);
19637   precomputed.doubles = this._getDoubles(4, power);
19638   precomputed.beta = this._getBeta();
19639   this.precomputed = precomputed;
19640
19641   return this;
19642 };
19643
19644 BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
19645   if (!this.precomputed)
19646     return false;
19647
19648   var doubles = this.precomputed.doubles;
19649   if (!doubles)
19650     return false;
19651
19652   return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
19653 };
19654
19655 BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
19656   if (this.precomputed && this.precomputed.doubles)
19657     return this.precomputed.doubles;
19658
19659   var doubles = [ this ];
19660   var acc = this;
19661   for (var i = 0; i < power; i += step) {
19662     for (var j = 0; j < step; j++)
19663       acc = acc.dbl();
19664     doubles.push(acc);
19665   }
19666   return {
19667     step: step,
19668     points: doubles
19669   };
19670 };
19671
19672 BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
19673   if (this.precomputed && this.precomputed.naf)
19674     return this.precomputed.naf;
19675
19676   var res = [ this ];
19677   var max = (1 << wnd) - 1;
19678   var dbl = max === 1 ? null : this.dbl();
19679   for (var i = 1; i < max; i++)
19680     res[i] = res[i - 1].add(dbl);
19681   return {
19682     wnd: wnd,
19683     points: res
19684   };
19685 };
19686
19687 BasePoint.prototype._getBeta = function _getBeta() {
19688   return null;
19689 };
19690
19691 BasePoint.prototype.dblp = function dblp(k) {
19692   var r = this;
19693   for (var i = 0; i < k; i++)
19694     r = r.dbl();
19695   return r;
19696 };
19697
19698
19699 /***/ }),
19700 /* 226 */
19701 /***/ (function(module, exports, __webpack_require__) {
19702
19703 "use strict";
19704
19705
19706 var curve = __webpack_require__(45);
19707 var elliptic = __webpack_require__(6);
19708 var BN = __webpack_require__(4);
19709 var inherits = __webpack_require__(1);
19710 var Base = curve.base;
19711
19712 var assert = elliptic.utils.assert;
19713
19714 function ShortCurve(conf) {
19715   Base.call(this, 'short', conf);
19716
19717   this.a = new BN(conf.a, 16).toRed(this.red);
19718   this.b = new BN(conf.b, 16).toRed(this.red);
19719   this.tinv = this.two.redInvm();
19720
19721   this.zeroA = this.a.fromRed().cmpn(0) === 0;
19722   this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
19723
19724   // If the curve is endomorphic, precalculate beta and lambda
19725   this.endo = this._getEndomorphism(conf);
19726   this._endoWnafT1 = new Array(4);
19727   this._endoWnafT2 = new Array(4);
19728 }
19729 inherits(ShortCurve, Base);
19730 module.exports = ShortCurve;
19731
19732 ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
19733   // No efficient endomorphism
19734   if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
19735     return;
19736
19737   // Compute beta and lambda, that lambda * P = (beta * Px; Py)
19738   var beta;
19739   var lambda;
19740   if (conf.beta) {
19741     beta = new BN(conf.beta, 16).toRed(this.red);
19742   } else {
19743     var betas = this._getEndoRoots(this.p);
19744     // Choose the smallest beta
19745     beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
19746     beta = beta.toRed(this.red);
19747   }
19748   if (conf.lambda) {
19749     lambda = new BN(conf.lambda, 16);
19750   } else {
19751     // Choose the lambda that is matching selected beta
19752     var lambdas = this._getEndoRoots(this.n);
19753     if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
19754       lambda = lambdas[0];
19755     } else {
19756       lambda = lambdas[1];
19757       assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
19758     }
19759   }
19760
19761   // Get basis vectors, used for balanced length-two representation
19762   var basis;
19763   if (conf.basis) {
19764     basis = conf.basis.map(function(vec) {
19765       return {
19766         a: new BN(vec.a, 16),
19767         b: new BN(vec.b, 16)
19768       };
19769     });
19770   } else {
19771     basis = this._getEndoBasis(lambda);
19772   }
19773
19774   return {
19775     beta: beta,
19776     lambda: lambda,
19777     basis: basis
19778   };
19779 };
19780
19781 ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
19782   // Find roots of for x^2 + x + 1 in F
19783   // Root = (-1 +- Sqrt(-3)) / 2
19784   //
19785   var red = num === this.p ? this.red : BN.mont(num);
19786   var tinv = new BN(2).toRed(red).redInvm();
19787   var ntinv = tinv.redNeg();
19788
19789   var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
19790
19791   var l1 = ntinv.redAdd(s).fromRed();
19792   var l2 = ntinv.redSub(s).fromRed();
19793   return [ l1, l2 ];
19794 };
19795
19796 ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
19797   // aprxSqrt >= sqrt(this.n)
19798   var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
19799
19800   // 3.74
19801   // Run EGCD, until r(L + 1) < aprxSqrt
19802   var u = lambda;
19803   var v = this.n.clone();
19804   var x1 = new BN(1);
19805   var y1 = new BN(0);
19806   var x2 = new BN(0);
19807   var y2 = new BN(1);
19808
19809   // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
19810   var a0;
19811   var b0;
19812   // First vector
19813   var a1;
19814   var b1;
19815   // Second vector
19816   var a2;
19817   var b2;
19818
19819   var prevR;
19820   var i = 0;
19821   var r;
19822   var x;
19823   while (u.cmpn(0) !== 0) {
19824     var q = v.div(u);
19825     r = v.sub(q.mul(u));
19826     x = x2.sub(q.mul(x1));
19827     var y = y2.sub(q.mul(y1));
19828
19829     if (!a1 && r.cmp(aprxSqrt) < 0) {
19830       a0 = prevR.neg();
19831       b0 = x1;
19832       a1 = r.neg();
19833       b1 = x;
19834     } else if (a1 && ++i === 2) {
19835       break;
19836     }
19837     prevR = r;
19838
19839     v = u;
19840     u = r;
19841     x2 = x1;
19842     x1 = x;
19843     y2 = y1;
19844     y1 = y;
19845   }
19846   a2 = r.neg();
19847   b2 = x;
19848
19849   var len1 = a1.sqr().add(b1.sqr());
19850   var len2 = a2.sqr().add(b2.sqr());
19851   if (len2.cmp(len1) >= 0) {
19852     a2 = a0;
19853     b2 = b0;
19854   }
19855
19856   // Normalize signs
19857   if (a1.negative) {
19858     a1 = a1.neg();
19859     b1 = b1.neg();
19860   }
19861   if (a2.negative) {
19862     a2 = a2.neg();
19863     b2 = b2.neg();
19864   }
19865
19866   return [
19867     { a: a1, b: b1 },
19868     { a: a2, b: b2 }
19869   ];
19870 };
19871
19872 ShortCurve.prototype._endoSplit = function _endoSplit(k) {
19873   var basis = this.endo.basis;
19874   var v1 = basis[0];
19875   var v2 = basis[1];
19876
19877   var c1 = v2.b.mul(k).divRound(this.n);
19878   var c2 = v1.b.neg().mul(k).divRound(this.n);
19879
19880   var p1 = c1.mul(v1.a);
19881   var p2 = c2.mul(v2.a);
19882   var q1 = c1.mul(v1.b);
19883   var q2 = c2.mul(v2.b);
19884
19885   // Calculate answer
19886   var k1 = k.sub(p1).sub(p2);
19887   var k2 = q1.add(q2).neg();
19888   return { k1: k1, k2: k2 };
19889 };
19890
19891 ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
19892   x = new BN(x, 16);
19893   if (!x.red)
19894     x = x.toRed(this.red);
19895
19896   var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
19897   var y = y2.redSqrt();
19898   if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
19899     throw new Error('invalid point');
19900
19901   // XXX Is there any way to tell if the number is odd without converting it
19902   // to non-red form?
19903   var isOdd = y.fromRed().isOdd();
19904   if (odd && !isOdd || !odd && isOdd)
19905     y = y.redNeg();
19906
19907   return this.point(x, y);
19908 };
19909
19910 ShortCurve.prototype.validate = function validate(point) {
19911   if (point.inf)
19912     return true;
19913
19914   var x = point.x;
19915   var y = point.y;
19916
19917   var ax = this.a.redMul(x);
19918   var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
19919   return y.redSqr().redISub(rhs).cmpn(0) === 0;
19920 };
19921
19922 ShortCurve.prototype._endoWnafMulAdd =
19923     function _endoWnafMulAdd(points, coeffs, jacobianResult) {
19924   var npoints = this._endoWnafT1;
19925   var ncoeffs = this._endoWnafT2;
19926   for (var i = 0; i < points.length; i++) {
19927     var split = this._endoSplit(coeffs[i]);
19928     var p = points[i];
19929     var beta = p._getBeta();
19930
19931     if (split.k1.negative) {
19932       split.k1.ineg();
19933       p = p.neg(true);
19934     }
19935     if (split.k2.negative) {
19936       split.k2.ineg();
19937       beta = beta.neg(true);
19938     }
19939
19940     npoints[i * 2] = p;
19941     npoints[i * 2 + 1] = beta;
19942     ncoeffs[i * 2] = split.k1;
19943     ncoeffs[i * 2 + 1] = split.k2;
19944   }
19945   var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
19946
19947   // Clean-up references to points and coefficients
19948   for (var j = 0; j < i * 2; j++) {
19949     npoints[j] = null;
19950     ncoeffs[j] = null;
19951   }
19952   return res;
19953 };
19954
19955 function Point(curve, x, y, isRed) {
19956   Base.BasePoint.call(this, curve, 'affine');
19957   if (x === null && y === null) {
19958     this.x = null;
19959     this.y = null;
19960     this.inf = true;
19961   } else {
19962     this.x = new BN(x, 16);
19963     this.y = new BN(y, 16);
19964     // Force redgomery representation when loading from JSON
19965     if (isRed) {
19966       this.x.forceRed(this.curve.red);
19967       this.y.forceRed(this.curve.red);
19968     }
19969     if (!this.x.red)
19970       this.x = this.x.toRed(this.curve.red);
19971     if (!this.y.red)
19972       this.y = this.y.toRed(this.curve.red);
19973     this.inf = false;
19974   }
19975 }
19976 inherits(Point, Base.BasePoint);
19977
19978 ShortCurve.prototype.point = function point(x, y, isRed) {
19979   return new Point(this, x, y, isRed);
19980 };
19981
19982 ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
19983   return Point.fromJSON(this, obj, red);
19984 };
19985
19986 Point.prototype._getBeta = function _getBeta() {
19987   if (!this.curve.endo)
19988     return;
19989
19990   var pre = this.precomputed;
19991   if (pre && pre.beta)
19992     return pre.beta;
19993
19994   var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
19995   if (pre) {
19996     var curve = this.curve;
19997     var endoMul = function(p) {
19998       return curve.point(p.x.redMul(curve.endo.beta), p.y);
19999     };
20000     pre.beta = beta;
20001     beta.precomputed = {
20002       beta: null,
20003       naf: pre.naf && {
20004         wnd: pre.naf.wnd,
20005         points: pre.naf.points.map(endoMul)
20006       },
20007       doubles: pre.doubles && {
20008         step: pre.doubles.step,
20009         points: pre.doubles.points.map(endoMul)
20010       }
20011     };
20012   }
20013   return beta;
20014 };
20015
20016 Point.prototype.toJSON = function toJSON() {
20017   if (!this.precomputed)
20018     return [ this.x, this.y ];
20019
20020   return [ this.x, this.y, this.precomputed && {
20021     doubles: this.precomputed.doubles && {
20022       step: this.precomputed.doubles.step,
20023       points: this.precomputed.doubles.points.slice(1)
20024     },
20025     naf: this.precomputed.naf && {
20026       wnd: this.precomputed.naf.wnd,
20027       points: this.precomputed.naf.points.slice(1)
20028     }
20029   } ];
20030 };
20031
20032 Point.fromJSON = function fromJSON(curve, obj, red) {
20033   if (typeof obj === 'string')
20034     obj = JSON.parse(obj);
20035   var res = curve.point(obj[0], obj[1], red);
20036   if (!obj[2])
20037     return res;
20038
20039   function obj2point(obj) {
20040     return curve.point(obj[0], obj[1], red);
20041   }
20042
20043   var pre = obj[2];
20044   res.precomputed = {
20045     beta: null,
20046     doubles: pre.doubles && {
20047       step: pre.doubles.step,
20048       points: [ res ].concat(pre.doubles.points.map(obj2point))
20049     },
20050     naf: pre.naf && {
20051       wnd: pre.naf.wnd,
20052       points: [ res ].concat(pre.naf.points.map(obj2point))
20053     }
20054   };
20055   return res;
20056 };
20057
20058 Point.prototype.inspect = function inspect() {
20059   if (this.isInfinity())
20060     return '<EC Point Infinity>';
20061   return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
20062       ' y: ' + this.y.fromRed().toString(16, 2) + '>';
20063 };
20064
20065 Point.prototype.isInfinity = function isInfinity() {
20066   return this.inf;
20067 };
20068
20069 Point.prototype.add = function add(p) {
20070   // O + P = P
20071   if (this.inf)
20072     return p;
20073
20074   // P + O = P
20075   if (p.inf)
20076     return this;
20077
20078   // P + P = 2P
20079   if (this.eq(p))
20080     return this.dbl();
20081
20082   // P + (-P) = O
20083   if (this.neg().eq(p))
20084     return this.curve.point(null, null);
20085
20086   // P + Q = O
20087   if (this.x.cmp(p.x) === 0)
20088     return this.curve.point(null, null);
20089
20090   var c = this.y.redSub(p.y);
20091   if (c.cmpn(0) !== 0)
20092     c = c.redMul(this.x.redSub(p.x).redInvm());
20093   var nx = c.redSqr().redISub(this.x).redISub(p.x);
20094   var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
20095   return this.curve.point(nx, ny);
20096 };
20097
20098 Point.prototype.dbl = function dbl() {
20099   if (this.inf)
20100     return this;
20101
20102   // 2P = O
20103   var ys1 = this.y.redAdd(this.y);
20104   if (ys1.cmpn(0) === 0)
20105     return this.curve.point(null, null);
20106
20107   var a = this.curve.a;
20108
20109   var x2 = this.x.redSqr();
20110   var dyinv = ys1.redInvm();
20111   var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
20112
20113   var nx = c.redSqr().redISub(this.x.redAdd(this.x));
20114   var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
20115   return this.curve.point(nx, ny);
20116 };
20117
20118 Point.prototype.getX = function getX() {
20119   return this.x.fromRed();
20120 };
20121
20122 Point.prototype.getY = function getY() {
20123   return this.y.fromRed();
20124 };
20125
20126 Point.prototype.mul = function mul(k) {
20127   k = new BN(k, 16);
20128
20129   if (this._hasDoubles(k))
20130     return this.curve._fixedNafMul(this, k);
20131   else if (this.curve.endo)
20132     return this.curve._endoWnafMulAdd([ this ], [ k ]);
20133   else
20134     return this.curve._wnafMul(this, k);
20135 };
20136
20137 Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
20138   var points = [ this, p2 ];
20139   var coeffs = [ k1, k2 ];
20140   if (this.curve.endo)
20141     return this.curve._endoWnafMulAdd(points, coeffs);
20142   else
20143     return this.curve._wnafMulAdd(1, points, coeffs, 2);
20144 };
20145
20146 Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
20147   var points = [ this, p2 ];
20148   var coeffs = [ k1, k2 ];
20149   if (this.curve.endo)
20150     return this.curve._endoWnafMulAdd(points, coeffs, true);
20151   else
20152     return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
20153 };
20154
20155 Point.prototype.eq = function eq(p) {
20156   return this === p ||
20157          this.inf === p.inf &&
20158              (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
20159 };
20160
20161 Point.prototype.neg = function neg(_precompute) {
20162   if (this.inf)
20163     return this;
20164
20165   var res = this.curve.point(this.x, this.y.redNeg());
20166   if (_precompute && this.precomputed) {
20167     var pre = this.precomputed;
20168     var negate = function(p) {
20169       return p.neg();
20170     };
20171     res.precomputed = {
20172       naf: pre.naf && {
20173         wnd: pre.naf.wnd,
20174         points: pre.naf.points.map(negate)
20175       },
20176       doubles: pre.doubles && {
20177         step: pre.doubles.step,
20178         points: pre.doubles.points.map(negate)
20179       }
20180     };
20181   }
20182   return res;
20183 };
20184
20185 Point.prototype.toJ = function toJ() {
20186   if (this.inf)
20187     return this.curve.jpoint(null, null, null);
20188
20189   var res = this.curve.jpoint(this.x, this.y, this.curve.one);
20190   return res;
20191 };
20192
20193 function JPoint(curve, x, y, z) {
20194   Base.BasePoint.call(this, curve, 'jacobian');
20195   if (x === null && y === null && z === null) {
20196     this.x = this.curve.one;
20197     this.y = this.curve.one;
20198     this.z = new BN(0);
20199   } else {
20200     this.x = new BN(x, 16);
20201     this.y = new BN(y, 16);
20202     this.z = new BN(z, 16);
20203   }
20204   if (!this.x.red)
20205     this.x = this.x.toRed(this.curve.red);
20206   if (!this.y.red)
20207     this.y = this.y.toRed(this.curve.red);
20208   if (!this.z.red)
20209     this.z = this.z.toRed(this.curve.red);
20210
20211   this.zOne = this.z === this.curve.one;
20212 }
20213 inherits(JPoint, Base.BasePoint);
20214
20215 ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
20216   return new JPoint(this, x, y, z);
20217 };
20218
20219 JPoint.prototype.toP = function toP() {
20220   if (this.isInfinity())
20221     return this.curve.point(null, null);
20222
20223   var zinv = this.z.redInvm();
20224   var zinv2 = zinv.redSqr();
20225   var ax = this.x.redMul(zinv2);
20226   var ay = this.y.redMul(zinv2).redMul(zinv);
20227
20228   return this.curve.point(ax, ay);
20229 };
20230
20231 JPoint.prototype.neg = function neg() {
20232   return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
20233 };
20234
20235 JPoint.prototype.add = function add(p) {
20236   // O + P = P
20237   if (this.isInfinity())
20238     return p;
20239
20240   // P + O = P
20241   if (p.isInfinity())
20242     return this;
20243
20244   // 12M + 4S + 7A
20245   var pz2 = p.z.redSqr();
20246   var z2 = this.z.redSqr();
20247   var u1 = this.x.redMul(pz2);
20248   var u2 = p.x.redMul(z2);
20249   var s1 = this.y.redMul(pz2.redMul(p.z));
20250   var s2 = p.y.redMul(z2.redMul(this.z));
20251
20252   var h = u1.redSub(u2);
20253   var r = s1.redSub(s2);
20254   if (h.cmpn(0) === 0) {
20255     if (r.cmpn(0) !== 0)
20256       return this.curve.jpoint(null, null, null);
20257     else
20258       return this.dbl();
20259   }
20260
20261   var h2 = h.redSqr();
20262   var h3 = h2.redMul(h);
20263   var v = u1.redMul(h2);
20264
20265   var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
20266   var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
20267   var nz = this.z.redMul(p.z).redMul(h);
20268
20269   return this.curve.jpoint(nx, ny, nz);
20270 };
20271
20272 JPoint.prototype.mixedAdd = function mixedAdd(p) {
20273   // O + P = P
20274   if (this.isInfinity())
20275     return p.toJ();
20276
20277   // P + O = P
20278   if (p.isInfinity())
20279     return this;
20280
20281   // 8M + 3S + 7A
20282   var z2 = this.z.redSqr();
20283   var u1 = this.x;
20284   var u2 = p.x.redMul(z2);
20285   var s1 = this.y;
20286   var s2 = p.y.redMul(z2).redMul(this.z);
20287
20288   var h = u1.redSub(u2);
20289   var r = s1.redSub(s2);
20290   if (h.cmpn(0) === 0) {
20291     if (r.cmpn(0) !== 0)
20292       return this.curve.jpoint(null, null, null);
20293     else
20294       return this.dbl();
20295   }
20296
20297   var h2 = h.redSqr();
20298   var h3 = h2.redMul(h);
20299   var v = u1.redMul(h2);
20300
20301   var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
20302   var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
20303   var nz = this.z.redMul(h);
20304
20305   return this.curve.jpoint(nx, ny, nz);
20306 };
20307
20308 JPoint.prototype.dblp = function dblp(pow) {
20309   if (pow === 0)
20310     return this;
20311   if (this.isInfinity())
20312     return this;
20313   if (!pow)
20314     return this.dbl();
20315
20316   if (this.curve.zeroA || this.curve.threeA) {
20317     var r = this;
20318     for (var i = 0; i < pow; i++)
20319       r = r.dbl();
20320     return r;
20321   }
20322
20323   // 1M + 2S + 1A + N * (4S + 5M + 8A)
20324   // N = 1 => 6M + 6S + 9A
20325   var a = this.curve.a;
20326   var tinv = this.curve.tinv;
20327
20328   var jx = this.x;
20329   var jy = this.y;
20330   var jz = this.z;
20331   var jz4 = jz.redSqr().redSqr();
20332
20333   // Reuse results
20334   var jyd = jy.redAdd(jy);
20335   for (var i = 0; i < pow; i++) {
20336     var jx2 = jx.redSqr();
20337     var jyd2 = jyd.redSqr();
20338     var jyd4 = jyd2.redSqr();
20339     var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
20340
20341     var t1 = jx.redMul(jyd2);
20342     var nx = c.redSqr().redISub(t1.redAdd(t1));
20343     var t2 = t1.redISub(nx);
20344     var dny = c.redMul(t2);
20345     dny = dny.redIAdd(dny).redISub(jyd4);
20346     var nz = jyd.redMul(jz);
20347     if (i + 1 < pow)
20348       jz4 = jz4.redMul(jyd4);
20349
20350     jx = nx;
20351     jz = nz;
20352     jyd = dny;
20353   }
20354
20355   return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
20356 };
20357
20358 JPoint.prototype.dbl = function dbl() {
20359   if (this.isInfinity())
20360     return this;
20361
20362   if (this.curve.zeroA)
20363     return this._zeroDbl();
20364   else if (this.curve.threeA)
20365     return this._threeDbl();
20366   else
20367     return this._dbl();
20368 };
20369
20370 JPoint.prototype._zeroDbl = function _zeroDbl() {
20371   var nx;
20372   var ny;
20373   var nz;
20374   // Z = 1
20375   if (this.zOne) {
20376     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
20377     //     #doubling-mdbl-2007-bl
20378     // 1M + 5S + 14A
20379
20380     // XX = X1^2
20381     var xx = this.x.redSqr();
20382     // YY = Y1^2
20383     var yy = this.y.redSqr();
20384     // YYYY = YY^2
20385     var yyyy = yy.redSqr();
20386     // S = 2 * ((X1 + YY)^2 - XX - YYYY)
20387     var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
20388     s = s.redIAdd(s);
20389     // M = 3 * XX + a; a = 0
20390     var m = xx.redAdd(xx).redIAdd(xx);
20391     // T = M ^ 2 - 2*S
20392     var t = m.redSqr().redISub(s).redISub(s);
20393
20394     // 8 * YYYY
20395     var yyyy8 = yyyy.redIAdd(yyyy);
20396     yyyy8 = yyyy8.redIAdd(yyyy8);
20397     yyyy8 = yyyy8.redIAdd(yyyy8);
20398
20399     // X3 = T
20400     nx = t;
20401     // Y3 = M * (S - T) - 8 * YYYY
20402     ny = m.redMul(s.redISub(t)).redISub(yyyy8);
20403     // Z3 = 2*Y1
20404     nz = this.y.redAdd(this.y);
20405   } else {
20406     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
20407     //     #doubling-dbl-2009-l
20408     // 2M + 5S + 13A
20409
20410     // A = X1^2
20411     var a = this.x.redSqr();
20412     // B = Y1^2
20413     var b = this.y.redSqr();
20414     // C = B^2
20415     var c = b.redSqr();
20416     // D = 2 * ((X1 + B)^2 - A - C)
20417     var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
20418     d = d.redIAdd(d);
20419     // E = 3 * A
20420     var e = a.redAdd(a).redIAdd(a);
20421     // F = E^2
20422     var f = e.redSqr();
20423
20424     // 8 * C
20425     var c8 = c.redIAdd(c);
20426     c8 = c8.redIAdd(c8);
20427     c8 = c8.redIAdd(c8);
20428
20429     // X3 = F - 2 * D
20430     nx = f.redISub(d).redISub(d);
20431     // Y3 = E * (D - X3) - 8 * C
20432     ny = e.redMul(d.redISub(nx)).redISub(c8);
20433     // Z3 = 2 * Y1 * Z1
20434     nz = this.y.redMul(this.z);
20435     nz = nz.redIAdd(nz);
20436   }
20437
20438   return this.curve.jpoint(nx, ny, nz);
20439 };
20440
20441 JPoint.prototype._threeDbl = function _threeDbl() {
20442   var nx;
20443   var ny;
20444   var nz;
20445   // Z = 1
20446   if (this.zOne) {
20447     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
20448     //     #doubling-mdbl-2007-bl
20449     // 1M + 5S + 15A
20450
20451     // XX = X1^2
20452     var xx = this.x.redSqr();
20453     // YY = Y1^2
20454     var yy = this.y.redSqr();
20455     // YYYY = YY^2
20456     var yyyy = yy.redSqr();
20457     // S = 2 * ((X1 + YY)^2 - XX - YYYY)
20458     var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
20459     s = s.redIAdd(s);
20460     // M = 3 * XX + a
20461     var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
20462     // T = M^2 - 2 * S
20463     var t = m.redSqr().redISub(s).redISub(s);
20464     // X3 = T
20465     nx = t;
20466     // Y3 = M * (S - T) - 8 * YYYY
20467     var yyyy8 = yyyy.redIAdd(yyyy);
20468     yyyy8 = yyyy8.redIAdd(yyyy8);
20469     yyyy8 = yyyy8.redIAdd(yyyy8);
20470     ny = m.redMul(s.redISub(t)).redISub(yyyy8);
20471     // Z3 = 2 * Y1
20472     nz = this.y.redAdd(this.y);
20473   } else {
20474     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
20475     // 3M + 5S
20476
20477     // delta = Z1^2
20478     var delta = this.z.redSqr();
20479     // gamma = Y1^2
20480     var gamma = this.y.redSqr();
20481     // beta = X1 * gamma
20482     var beta = this.x.redMul(gamma);
20483     // alpha = 3 * (X1 - delta) * (X1 + delta)
20484     var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
20485     alpha = alpha.redAdd(alpha).redIAdd(alpha);
20486     // X3 = alpha^2 - 8 * beta
20487     var beta4 = beta.redIAdd(beta);
20488     beta4 = beta4.redIAdd(beta4);
20489     var beta8 = beta4.redAdd(beta4);
20490     nx = alpha.redSqr().redISub(beta8);
20491     // Z3 = (Y1 + Z1)^2 - gamma - delta
20492     nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
20493     // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
20494     var ggamma8 = gamma.redSqr();
20495     ggamma8 = ggamma8.redIAdd(ggamma8);
20496     ggamma8 = ggamma8.redIAdd(ggamma8);
20497     ggamma8 = ggamma8.redIAdd(ggamma8);
20498     ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
20499   }
20500
20501   return this.curve.jpoint(nx, ny, nz);
20502 };
20503
20504 JPoint.prototype._dbl = function _dbl() {
20505   var a = this.curve.a;
20506
20507   // 4M + 6S + 10A
20508   var jx = this.x;
20509   var jy = this.y;
20510   var jz = this.z;
20511   var jz4 = jz.redSqr().redSqr();
20512
20513   var jx2 = jx.redSqr();
20514   var jy2 = jy.redSqr();
20515
20516   var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
20517
20518   var jxd4 = jx.redAdd(jx);
20519   jxd4 = jxd4.redIAdd(jxd4);
20520   var t1 = jxd4.redMul(jy2);
20521   var nx = c.redSqr().redISub(t1.redAdd(t1));
20522   var t2 = t1.redISub(nx);
20523
20524   var jyd8 = jy2.redSqr();
20525   jyd8 = jyd8.redIAdd(jyd8);
20526   jyd8 = jyd8.redIAdd(jyd8);
20527   jyd8 = jyd8.redIAdd(jyd8);
20528   var ny = c.redMul(t2).redISub(jyd8);
20529   var nz = jy.redAdd(jy).redMul(jz);
20530
20531   return this.curve.jpoint(nx, ny, nz);
20532 };
20533
20534 JPoint.prototype.trpl = function trpl() {
20535   if (!this.curve.zeroA)
20536     return this.dbl().add(this);
20537
20538   // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
20539   // 5M + 10S + ...
20540
20541   // XX = X1^2
20542   var xx = this.x.redSqr();
20543   // YY = Y1^2
20544   var yy = this.y.redSqr();
20545   // ZZ = Z1^2
20546   var zz = this.z.redSqr();
20547   // YYYY = YY^2
20548   var yyyy = yy.redSqr();
20549   // M = 3 * XX + a * ZZ2; a = 0
20550   var m = xx.redAdd(xx).redIAdd(xx);
20551   // MM = M^2
20552   var mm = m.redSqr();
20553   // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
20554   var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
20555   e = e.redIAdd(e);
20556   e = e.redAdd(e).redIAdd(e);
20557   e = e.redISub(mm);
20558   // EE = E^2
20559   var ee = e.redSqr();
20560   // T = 16*YYYY
20561   var t = yyyy.redIAdd(yyyy);
20562   t = t.redIAdd(t);
20563   t = t.redIAdd(t);
20564   t = t.redIAdd(t);
20565   // U = (M + E)^2 - MM - EE - T
20566   var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
20567   // X3 = 4 * (X1 * EE - 4 * YY * U)
20568   var yyu4 = yy.redMul(u);
20569   yyu4 = yyu4.redIAdd(yyu4);
20570   yyu4 = yyu4.redIAdd(yyu4);
20571   var nx = this.x.redMul(ee).redISub(yyu4);
20572   nx = nx.redIAdd(nx);
20573   nx = nx.redIAdd(nx);
20574   // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
20575   var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
20576   ny = ny.redIAdd(ny);
20577   ny = ny.redIAdd(ny);
20578   ny = ny.redIAdd(ny);
20579   // Z3 = (Z1 + E)^2 - ZZ - EE
20580   var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
20581
20582   return this.curve.jpoint(nx, ny, nz);
20583 };
20584
20585 JPoint.prototype.mul = function mul(k, kbase) {
20586   k = new BN(k, kbase);
20587
20588   return this.curve._wnafMul(this, k);
20589 };
20590
20591 JPoint.prototype.eq = function eq(p) {
20592   if (p.type === 'affine')
20593     return this.eq(p.toJ());
20594
20595   if (this === p)
20596     return true;
20597
20598   // x1 * z2^2 == x2 * z1^2
20599   var z2 = this.z.redSqr();
20600   var pz2 = p.z.redSqr();
20601   if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
20602     return false;
20603
20604   // y1 * z2^3 == y2 * z1^3
20605   var z3 = z2.redMul(this.z);
20606   var pz3 = pz2.redMul(p.z);
20607   return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
20608 };
20609
20610 JPoint.prototype.eqXToP = function eqXToP(x) {
20611   var zs = this.z.redSqr();
20612   var rx = x.toRed(this.curve.red).redMul(zs);
20613   if (this.x.cmp(rx) === 0)
20614     return true;
20615
20616   var xc = x.clone();
20617   var t = this.curve.redN.redMul(zs);
20618   for (;;) {
20619     xc.iadd(this.curve.n);
20620     if (xc.cmp(this.curve.p) >= 0)
20621       return false;
20622
20623     rx.redIAdd(t);
20624     if (this.x.cmp(rx) === 0)
20625       return true;
20626   }
20627 };
20628
20629 JPoint.prototype.inspect = function inspect() {
20630   if (this.isInfinity())
20631     return '<EC JPoint Infinity>';
20632   return '<EC JPoint x: ' + this.x.toString(16, 2) +
20633       ' y: ' + this.y.toString(16, 2) +
20634       ' z: ' + this.z.toString(16, 2) + '>';
20635 };
20636
20637 JPoint.prototype.isInfinity = function isInfinity() {
20638   // XXX This code assumes that zero is always zero in red
20639   return this.z.cmpn(0) === 0;
20640 };
20641
20642
20643 /***/ }),
20644 /* 227 */
20645 /***/ (function(module, exports, __webpack_require__) {
20646
20647 "use strict";
20648
20649
20650 var curve = __webpack_require__(45);
20651 var BN = __webpack_require__(4);
20652 var inherits = __webpack_require__(1);
20653 var Base = curve.base;
20654
20655 var elliptic = __webpack_require__(6);
20656 var utils = elliptic.utils;
20657
20658 function MontCurve(conf) {
20659   Base.call(this, 'mont', conf);
20660
20661   this.a = new BN(conf.a, 16).toRed(this.red);
20662   this.b = new BN(conf.b, 16).toRed(this.red);
20663   this.i4 = new BN(4).toRed(this.red).redInvm();
20664   this.two = new BN(2).toRed(this.red);
20665   this.a24 = this.i4.redMul(this.a.redAdd(this.two));
20666 }
20667 inherits(MontCurve, Base);
20668 module.exports = MontCurve;
20669
20670 MontCurve.prototype.validate = function validate(point) {
20671   var x = point.normalize().x;
20672   var x2 = x.redSqr();
20673   var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
20674   var y = rhs.redSqrt();
20675
20676   return y.redSqr().cmp(rhs) === 0;
20677 };
20678
20679 function Point(curve, x, z) {
20680   Base.BasePoint.call(this, curve, 'projective');
20681   if (x === null && z === null) {
20682     this.x = this.curve.one;
20683     this.z = this.curve.zero;
20684   } else {
20685     this.x = new BN(x, 16);
20686     this.z = new BN(z, 16);
20687     if (!this.x.red)
20688       this.x = this.x.toRed(this.curve.red);
20689     if (!this.z.red)
20690       this.z = this.z.toRed(this.curve.red);
20691   }
20692 }
20693 inherits(Point, Base.BasePoint);
20694
20695 MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
20696   return this.point(utils.toArray(bytes, enc), 1);
20697 };
20698
20699 MontCurve.prototype.point = function point(x, z) {
20700   return new Point(this, x, z);
20701 };
20702
20703 MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
20704   return Point.fromJSON(this, obj);
20705 };
20706
20707 Point.prototype.precompute = function precompute() {
20708   // No-op
20709 };
20710
20711 Point.prototype._encode = function _encode() {
20712   return this.getX().toArray('be', this.curve.p.byteLength());
20713 };
20714
20715 Point.fromJSON = function fromJSON(curve, obj) {
20716   return new Point(curve, obj[0], obj[1] || curve.one);
20717 };
20718
20719 Point.prototype.inspect = function inspect() {
20720   if (this.isInfinity())
20721     return '<EC Point Infinity>';
20722   return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
20723       ' z: ' + this.z.fromRed().toString(16, 2) + '>';
20724 };
20725
20726 Point.prototype.isInfinity = function isInfinity() {
20727   // XXX This code assumes that zero is always zero in red
20728   return this.z.cmpn(0) === 0;
20729 };
20730
20731 Point.prototype.dbl = function dbl() {
20732   // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
20733   // 2M + 2S + 4A
20734
20735   // A = X1 + Z1
20736   var a = this.x.redAdd(this.z);
20737   // AA = A^2
20738   var aa = a.redSqr();
20739   // B = X1 - Z1
20740   var b = this.x.redSub(this.z);
20741   // BB = B^2
20742   var bb = b.redSqr();
20743   // C = AA - BB
20744   var c = aa.redSub(bb);
20745   // X3 = AA * BB
20746   var nx = aa.redMul(bb);
20747   // Z3 = C * (BB + A24 * C)
20748   var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
20749   return this.curve.point(nx, nz);
20750 };
20751
20752 Point.prototype.add = function add() {
20753   throw new Error('Not supported on Montgomery curve');
20754 };
20755
20756 Point.prototype.diffAdd = function diffAdd(p, diff) {
20757   // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
20758   // 4M + 2S + 6A
20759
20760   // A = X2 + Z2
20761   var a = this.x.redAdd(this.z);
20762   // B = X2 - Z2
20763   var b = this.x.redSub(this.z);
20764   // C = X3 + Z3
20765   var c = p.x.redAdd(p.z);
20766   // D = X3 - Z3
20767   var d = p.x.redSub(p.z);
20768   // DA = D * A
20769   var da = d.redMul(a);
20770   // CB = C * B
20771   var cb = c.redMul(b);
20772   // X5 = Z1 * (DA + CB)^2
20773   var nx = diff.z.redMul(da.redAdd(cb).redSqr());
20774   // Z5 = X1 * (DA - CB)^2
20775   var nz = diff.x.redMul(da.redISub(cb).redSqr());
20776   return this.curve.point(nx, nz);
20777 };
20778
20779 Point.prototype.mul = function mul(k) {
20780   var t = k.clone();
20781   var a = this; // (N / 2) * Q + Q
20782   var b = this.curve.point(null, null); // (N / 2) * Q
20783   var c = this; // Q
20784
20785   for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
20786     bits.push(t.andln(1));
20787
20788   for (var i = bits.length - 1; i >= 0; i--) {
20789     if (bits[i] === 0) {
20790       // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
20791       a = a.diffAdd(b, c);
20792       // N * Q = 2 * ((N / 2) * Q + Q))
20793       b = b.dbl();
20794     } else {
20795       // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
20796       b = a.diffAdd(b, c);
20797       // N * Q + Q = 2 * ((N / 2) * Q + Q)
20798       a = a.dbl();
20799     }
20800   }
20801   return b;
20802 };
20803
20804 Point.prototype.mulAdd = function mulAdd() {
20805   throw new Error('Not supported on Montgomery curve');
20806 };
20807
20808 Point.prototype.jumlAdd = function jumlAdd() {
20809   throw new Error('Not supported on Montgomery curve');
20810 };
20811
20812 Point.prototype.eq = function eq(other) {
20813   return this.getX().cmp(other.getX()) === 0;
20814 };
20815
20816 Point.prototype.normalize = function normalize() {
20817   this.x = this.x.redMul(this.z.redInvm());
20818   this.z = this.curve.one;
20819   return this;
20820 };
20821
20822 Point.prototype.getX = function getX() {
20823   // Normalize coordinates
20824   this.normalize();
20825
20826   return this.x.fromRed();
20827 };
20828
20829
20830 /***/ }),
20831 /* 228 */
20832 /***/ (function(module, exports, __webpack_require__) {
20833
20834 "use strict";
20835
20836
20837 var curve = __webpack_require__(45);
20838 var elliptic = __webpack_require__(6);
20839 var BN = __webpack_require__(4);
20840 var inherits = __webpack_require__(1);
20841 var Base = curve.base;
20842
20843 var assert = elliptic.utils.assert;
20844
20845 function EdwardsCurve(conf) {
20846   // NOTE: Important as we are creating point in Base.call()
20847   this.twisted = (conf.a | 0) !== 1;
20848   this.mOneA = this.twisted && (conf.a | 0) === -1;
20849   this.extended = this.mOneA;
20850
20851   Base.call(this, 'edwards', conf);
20852
20853   this.a = new BN(conf.a, 16).umod(this.red.m);
20854   this.a = this.a.toRed(this.red);
20855   this.c = new BN(conf.c, 16).toRed(this.red);
20856   this.c2 = this.c.redSqr();
20857   this.d = new BN(conf.d, 16).toRed(this.red);
20858   this.dd = this.d.redAdd(this.d);
20859
20860   assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
20861   this.oneC = (conf.c | 0) === 1;
20862 }
20863 inherits(EdwardsCurve, Base);
20864 module.exports = EdwardsCurve;
20865
20866 EdwardsCurve.prototype._mulA = function _mulA(num) {
20867   if (this.mOneA)
20868     return num.redNeg();
20869   else
20870     return this.a.redMul(num);
20871 };
20872
20873 EdwardsCurve.prototype._mulC = function _mulC(num) {
20874   if (this.oneC)
20875     return num;
20876   else
20877     return this.c.redMul(num);
20878 };
20879
20880 // Just for compatibility with Short curve
20881 EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
20882   return this.point(x, y, z, t);
20883 };
20884
20885 EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
20886   x = new BN(x, 16);
20887   if (!x.red)
20888     x = x.toRed(this.red);
20889
20890   var x2 = x.redSqr();
20891   var rhs = this.c2.redSub(this.a.redMul(x2));
20892   var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
20893
20894   var y2 = rhs.redMul(lhs.redInvm());
20895   var y = y2.redSqrt();
20896   if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
20897     throw new Error('invalid point');
20898
20899   var isOdd = y.fromRed().isOdd();
20900   if (odd && !isOdd || !odd && isOdd)
20901     y = y.redNeg();
20902
20903   return this.point(x, y);
20904 };
20905
20906 EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
20907   y = new BN(y, 16);
20908   if (!y.red)
20909     y = y.toRed(this.red);
20910
20911   // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
20912   var y2 = y.redSqr();
20913   var lhs = y2.redSub(this.c2);
20914   var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
20915   var x2 = lhs.redMul(rhs.redInvm());
20916
20917   if (x2.cmp(this.zero) === 0) {
20918     if (odd)
20919       throw new Error('invalid point');
20920     else
20921       return this.point(this.zero, y);
20922   }
20923
20924   var x = x2.redSqrt();
20925   if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
20926     throw new Error('invalid point');
20927
20928   if (x.fromRed().isOdd() !== odd)
20929     x = x.redNeg();
20930
20931   return this.point(x, y);
20932 };
20933
20934 EdwardsCurve.prototype.validate = function validate(point) {
20935   if (point.isInfinity())
20936     return true;
20937
20938   // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
20939   point.normalize();
20940
20941   var x2 = point.x.redSqr();
20942   var y2 = point.y.redSqr();
20943   var lhs = x2.redMul(this.a).redAdd(y2);
20944   var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
20945
20946   return lhs.cmp(rhs) === 0;
20947 };
20948
20949 function Point(curve, x, y, z, t) {
20950   Base.BasePoint.call(this, curve, 'projective');
20951   if (x === null && y === null && z === null) {
20952     this.x = this.curve.zero;
20953     this.y = this.curve.one;
20954     this.z = this.curve.one;
20955     this.t = this.curve.zero;
20956     this.zOne = true;
20957   } else {
20958     this.x = new BN(x, 16);
20959     this.y = new BN(y, 16);
20960     this.z = z ? new BN(z, 16) : this.curve.one;
20961     this.t = t && new BN(t, 16);
20962     if (!this.x.red)
20963       this.x = this.x.toRed(this.curve.red);
20964     if (!this.y.red)
20965       this.y = this.y.toRed(this.curve.red);
20966     if (!this.z.red)
20967       this.z = this.z.toRed(this.curve.red);
20968     if (this.t && !this.t.red)
20969       this.t = this.t.toRed(this.curve.red);
20970     this.zOne = this.z === this.curve.one;
20971
20972     // Use extended coordinates
20973     if (this.curve.extended && !this.t) {
20974       this.t = this.x.redMul(this.y);
20975       if (!this.zOne)
20976         this.t = this.t.redMul(this.z.redInvm());
20977     }
20978   }
20979 }
20980 inherits(Point, Base.BasePoint);
20981
20982 EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
20983   return Point.fromJSON(this, obj);
20984 };
20985
20986 EdwardsCurve.prototype.point = function point(x, y, z, t) {
20987   return new Point(this, x, y, z, t);
20988 };
20989
20990 Point.fromJSON = function fromJSON(curve, obj) {
20991   return new Point(curve, obj[0], obj[1], obj[2]);
20992 };
20993
20994 Point.prototype.inspect = function inspect() {
20995   if (this.isInfinity())
20996     return '<EC Point Infinity>';
20997   return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
20998       ' y: ' + this.y.fromRed().toString(16, 2) +
20999       ' z: ' + this.z.fromRed().toString(16, 2) + '>';
21000 };
21001
21002 Point.prototype.isInfinity = function isInfinity() {
21003   // XXX This code assumes that zero is always zero in red
21004   return this.x.cmpn(0) === 0 &&
21005     (this.y.cmp(this.z) === 0 ||
21006     (this.zOne && this.y.cmp(this.curve.c) === 0));
21007 };
21008
21009 Point.prototype._extDbl = function _extDbl() {
21010   // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
21011   //     #doubling-dbl-2008-hwcd
21012   // 4M + 4S
21013
21014   // A = X1^2
21015   var a = this.x.redSqr();
21016   // B = Y1^2
21017   var b = this.y.redSqr();
21018   // C = 2 * Z1^2
21019   var c = this.z.redSqr();
21020   c = c.redIAdd(c);
21021   // D = a * A
21022   var d = this.curve._mulA(a);
21023   // E = (X1 + Y1)^2 - A - B
21024   var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
21025   // G = D + B
21026   var g = d.redAdd(b);
21027   // F = G - C
21028   var f = g.redSub(c);
21029   // H = D - B
21030   var h = d.redSub(b);
21031   // X3 = E * F
21032   var nx = e.redMul(f);
21033   // Y3 = G * H
21034   var ny = g.redMul(h);
21035   // T3 = E * H
21036   var nt = e.redMul(h);
21037   // Z3 = F * G
21038   var nz = f.redMul(g);
21039   return this.curve.point(nx, ny, nz, nt);
21040 };
21041
21042 Point.prototype._projDbl = function _projDbl() {
21043   // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
21044   //     #doubling-dbl-2008-bbjlp
21045   //     #doubling-dbl-2007-bl
21046   // and others
21047   // Generally 3M + 4S or 2M + 4S
21048
21049   // B = (X1 + Y1)^2
21050   var b = this.x.redAdd(this.y).redSqr();
21051   // C = X1^2
21052   var c = this.x.redSqr();
21053   // D = Y1^2
21054   var d = this.y.redSqr();
21055
21056   var nx;
21057   var ny;
21058   var nz;
21059   if (this.curve.twisted) {
21060     // E = a * C
21061     var e = this.curve._mulA(c);
21062     // F = E + D
21063     var f = e.redAdd(d);
21064     if (this.zOne) {
21065       // X3 = (B - C - D) * (F - 2)
21066       nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
21067       // Y3 = F * (E - D)
21068       ny = f.redMul(e.redSub(d));
21069       // Z3 = F^2 - 2 * F
21070       nz = f.redSqr().redSub(f).redSub(f);
21071     } else {
21072       // H = Z1^2
21073       var h = this.z.redSqr();
21074       // J = F - 2 * H
21075       var j = f.redSub(h).redISub(h);
21076       // X3 = (B-C-D)*J
21077       nx = b.redSub(c).redISub(d).redMul(j);
21078       // Y3 = F * (E - D)
21079       ny = f.redMul(e.redSub(d));
21080       // Z3 = F * J
21081       nz = f.redMul(j);
21082     }
21083   } else {
21084     // E = C + D
21085     var e = c.redAdd(d);
21086     // H = (c * Z1)^2
21087     var h = this.curve._mulC(this.z).redSqr();
21088     // J = E - 2 * H
21089     var j = e.redSub(h).redSub(h);
21090     // X3 = c * (B - E) * J
21091     nx = this.curve._mulC(b.redISub(e)).redMul(j);
21092     // Y3 = c * E * (C - D)
21093     ny = this.curve._mulC(e).redMul(c.redISub(d));
21094     // Z3 = E * J
21095     nz = e.redMul(j);
21096   }
21097   return this.curve.point(nx, ny, nz);
21098 };
21099
21100 Point.prototype.dbl = function dbl() {
21101   if (this.isInfinity())
21102     return this;
21103
21104   // Double in extended coordinates
21105   if (this.curve.extended)
21106     return this._extDbl();
21107   else
21108     return this._projDbl();
21109 };
21110
21111 Point.prototype._extAdd = function _extAdd(p) {
21112   // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
21113   //     #addition-add-2008-hwcd-3
21114   // 8M
21115
21116   // A = (Y1 - X1) * (Y2 - X2)
21117   var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
21118   // B = (Y1 + X1) * (Y2 + X2)
21119   var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
21120   // C = T1 * k * T2
21121   var c = this.t.redMul(this.curve.dd).redMul(p.t);
21122   // D = Z1 * 2 * Z2
21123   var d = this.z.redMul(p.z.redAdd(p.z));
21124   // E = B - A
21125   var e = b.redSub(a);
21126   // F = D - C
21127   var f = d.redSub(c);
21128   // G = D + C
21129   var g = d.redAdd(c);
21130   // H = B + A
21131   var h = b.redAdd(a);
21132   // X3 = E * F
21133   var nx = e.redMul(f);
21134   // Y3 = G * H
21135   var ny = g.redMul(h);
21136   // T3 = E * H
21137   var nt = e.redMul(h);
21138   // Z3 = F * G
21139   var nz = f.redMul(g);
21140   return this.curve.point(nx, ny, nz, nt);
21141 };
21142
21143 Point.prototype._projAdd = function _projAdd(p) {
21144   // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
21145   //     #addition-add-2008-bbjlp
21146   //     #addition-add-2007-bl
21147   // 10M + 1S
21148
21149   // A = Z1 * Z2
21150   var a = this.z.redMul(p.z);
21151   // B = A^2
21152   var b = a.redSqr();
21153   // C = X1 * X2
21154   var c = this.x.redMul(p.x);
21155   // D = Y1 * Y2
21156   var d = this.y.redMul(p.y);
21157   // E = d * C * D
21158   var e = this.curve.d.redMul(c).redMul(d);
21159   // F = B - E
21160   var f = b.redSub(e);
21161   // G = B + E
21162   var g = b.redAdd(e);
21163   // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
21164   var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
21165   var nx = a.redMul(f).redMul(tmp);
21166   var ny;
21167   var nz;
21168   if (this.curve.twisted) {
21169     // Y3 = A * G * (D - a * C)
21170     ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
21171     // Z3 = F * G
21172     nz = f.redMul(g);
21173   } else {
21174     // Y3 = A * G * (D - C)
21175     ny = a.redMul(g).redMul(d.redSub(c));
21176     // Z3 = c * F * G
21177     nz = this.curve._mulC(f).redMul(g);
21178   }
21179   return this.curve.point(nx, ny, nz);
21180 };
21181
21182 Point.prototype.add = function add(p) {
21183   if (this.isInfinity())
21184     return p;
21185   if (p.isInfinity())
21186     return this;
21187
21188   if (this.curve.extended)
21189     return this._extAdd(p);
21190   else
21191     return this._projAdd(p);
21192 };
21193
21194 Point.prototype.mul = function mul(k) {
21195   if (this._hasDoubles(k))
21196     return this.curve._fixedNafMul(this, k);
21197   else
21198     return this.curve._wnafMul(this, k);
21199 };
21200
21201 Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
21202   return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
21203 };
21204
21205 Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
21206   return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
21207 };
21208
21209 Point.prototype.normalize = function normalize() {
21210   if (this.zOne)
21211     return this;
21212
21213   // Normalize coordinates
21214   var zi = this.z.redInvm();
21215   this.x = this.x.redMul(zi);
21216   this.y = this.y.redMul(zi);
21217   if (this.t)
21218     this.t = this.t.redMul(zi);
21219   this.z = this.curve.one;
21220   this.zOne = true;
21221   return this;
21222 };
21223
21224 Point.prototype.neg = function neg() {
21225   return this.curve.point(this.x.redNeg(),
21226                           this.y,
21227                           this.z,
21228                           this.t && this.t.redNeg());
21229 };
21230
21231 Point.prototype.getX = function getX() {
21232   this.normalize();
21233   return this.x.fromRed();
21234 };
21235
21236 Point.prototype.getY = function getY() {
21237   this.normalize();
21238   return this.y.fromRed();
21239 };
21240
21241 Point.prototype.eq = function eq(other) {
21242   return this === other ||
21243          this.getX().cmp(other.getX()) === 0 &&
21244          this.getY().cmp(other.getY()) === 0;
21245 };
21246
21247 Point.prototype.eqXToP = function eqXToP(x) {
21248   var rx = x.toRed(this.curve.red).redMul(this.z);
21249   if (this.x.cmp(rx) === 0)
21250     return true;
21251
21252   var xc = x.clone();
21253   var t = this.curve.redN.redMul(this.z);
21254   for (;;) {
21255     xc.iadd(this.curve.n);
21256     if (xc.cmp(this.curve.p) >= 0)
21257       return false;
21258
21259     rx.redIAdd(t);
21260     if (this.x.cmp(rx) === 0)
21261       return true;
21262   }
21263 };
21264
21265 // Compatibility with BaseCurve
21266 Point.prototype.toP = Point.prototype.normalize;
21267 Point.prototype.mixedAdd = Point.prototype.add;
21268
21269
21270 /***/ }),
21271 /* 229 */
21272 /***/ (function(module, exports, __webpack_require__) {
21273
21274 "use strict";
21275
21276
21277 var curves = exports;
21278
21279 var hash = __webpack_require__(68);
21280 var elliptic = __webpack_require__(6);
21281
21282 var assert = elliptic.utils.assert;
21283
21284 function PresetCurve(options) {
21285   if (options.type === 'short')
21286     this.curve = new elliptic.curve.short(options);
21287   else if (options.type === 'edwards')
21288     this.curve = new elliptic.curve.edwards(options);
21289   else
21290     this.curve = new elliptic.curve.mont(options);
21291   this.g = this.curve.g;
21292   this.n = this.curve.n;
21293   this.hash = options.hash;
21294
21295   assert(this.g.validate(), 'Invalid curve');
21296   assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
21297 }
21298 curves.PresetCurve = PresetCurve;
21299
21300 function defineCurve(name, options) {
21301   Object.defineProperty(curves, name, {
21302     configurable: true,
21303     enumerable: true,
21304     get: function() {
21305       var curve = new PresetCurve(options);
21306       Object.defineProperty(curves, name, {
21307         configurable: true,
21308         enumerable: true,
21309         value: curve
21310       });
21311       return curve;
21312     }
21313   });
21314 }
21315
21316 defineCurve('p192', {
21317   type: 'short',
21318   prime: 'p192',
21319   p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
21320   a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
21321   b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
21322   n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
21323   hash: hash.sha256,
21324   gRed: false,
21325   g: [
21326     '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
21327     '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
21328   ]
21329 });
21330
21331 defineCurve('p224', {
21332   type: 'short',
21333   prime: 'p224',
21334   p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
21335   a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
21336   b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
21337   n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
21338   hash: hash.sha256,
21339   gRed: false,
21340   g: [
21341     'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
21342     'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
21343   ]
21344 });
21345
21346 defineCurve('p256', {
21347   type: 'short',
21348   prime: null,
21349   p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
21350   a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
21351   b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
21352   n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
21353   hash: hash.sha256,
21354   gRed: false,
21355   g: [
21356     '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
21357     '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
21358   ]
21359 });
21360
21361 defineCurve('p384', {
21362   type: 'short',
21363   prime: null,
21364   p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21365      'fffffffe ffffffff 00000000 00000000 ffffffff',
21366   a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21367      'fffffffe ffffffff 00000000 00000000 fffffffc',
21368   b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
21369      '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
21370   n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
21371      'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
21372   hash: hash.sha384,
21373   gRed: false,
21374   g: [
21375     'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
21376     '5502f25d bf55296c 3a545e38 72760ab7',
21377     '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
21378     '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
21379   ]
21380 });
21381
21382 defineCurve('p521', {
21383   type: 'short',
21384   prime: null,
21385   p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21386      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21387      'ffffffff ffffffff ffffffff ffffffff ffffffff',
21388   a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21389      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21390      'ffffffff ffffffff ffffffff ffffffff fffffffc',
21391   b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
21392      '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
21393      '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
21394   n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21395      'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
21396      'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
21397   hash: hash.sha512,
21398   gRed: false,
21399   g: [
21400     '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
21401     '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
21402     'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
21403     '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
21404     '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
21405     '3fad0761 353c7086 a272c240 88be9476 9fd16650'
21406   ]
21407 });
21408
21409 defineCurve('curve25519', {
21410   type: 'mont',
21411   prime: 'p25519',
21412   p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
21413   a: '76d06',
21414   b: '1',
21415   n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
21416   hash: hash.sha256,
21417   gRed: false,
21418   g: [
21419     '9'
21420   ]
21421 });
21422
21423 defineCurve('ed25519', {
21424   type: 'edwards',
21425   prime: 'p25519',
21426   p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
21427   a: '-1',
21428   c: '1',
21429   // -121665 * (121666^(-1)) (mod P)
21430   d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
21431   n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
21432   hash: hash.sha256,
21433   gRed: false,
21434   g: [
21435     '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
21436
21437     // 4/5
21438     '6666666666666666666666666666666666666666666666666666666666666658'
21439   ]
21440 });
21441
21442 var pre;
21443 try {
21444   pre = __webpack_require__(236);
21445 } catch (e) {
21446   pre = undefined;
21447 }
21448
21449 defineCurve('secp256k1', {
21450   type: 'short',
21451   prime: 'k256',
21452   p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
21453   a: '0',
21454   b: '7',
21455   n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
21456   h: '1',
21457   hash: hash.sha256,
21458
21459   // Precomputed endomorphism
21460   beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
21461   lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
21462   basis: [
21463     {
21464       a: '3086d221a7d46bcde86c90e49284eb15',
21465       b: '-e4437ed6010e88286f547fa90abfe4c3'
21466     },
21467     {
21468       a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
21469       b: '3086d221a7d46bcde86c90e49284eb15'
21470     }
21471   ],
21472
21473   gRed: false,
21474   g: [
21475     '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
21476     '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
21477     pre
21478   ]
21479 });
21480
21481
21482 /***/ }),
21483 /* 230 */
21484 /***/ (function(module, exports, __webpack_require__) {
21485
21486 "use strict";
21487
21488
21489 exports.sha1 = __webpack_require__(231);
21490 exports.sha224 = __webpack_require__(232);
21491 exports.sha256 = __webpack_require__(118);
21492 exports.sha384 = __webpack_require__(233);
21493 exports.sha512 = __webpack_require__(119);
21494
21495
21496 /***/ }),
21497 /* 231 */
21498 /***/ (function(module, exports, __webpack_require__) {
21499
21500 "use strict";
21501
21502
21503 var utils = __webpack_require__(11);
21504 var common = __webpack_require__(32);
21505 var shaCommon = __webpack_require__(117);
21506
21507 var rotl32 = utils.rotl32;
21508 var sum32 = utils.sum32;
21509 var sum32_5 = utils.sum32_5;
21510 var ft_1 = shaCommon.ft_1;
21511 var BlockHash = common.BlockHash;
21512
21513 var sha1_K = [
21514   0x5A827999, 0x6ED9EBA1,
21515   0x8F1BBCDC, 0xCA62C1D6
21516 ];
21517
21518 function SHA1() {
21519   if (!(this instanceof SHA1))
21520     return new SHA1();
21521
21522   BlockHash.call(this);
21523   this.h = [
21524     0x67452301, 0xefcdab89, 0x98badcfe,
21525     0x10325476, 0xc3d2e1f0 ];
21526   this.W = new Array(80);
21527 }
21528
21529 utils.inherits(SHA1, BlockHash);
21530 module.exports = SHA1;
21531
21532 SHA1.blockSize = 512;
21533 SHA1.outSize = 160;
21534 SHA1.hmacStrength = 80;
21535 SHA1.padLength = 64;
21536
21537 SHA1.prototype._update = function _update(msg, start) {
21538   var W = this.W;
21539
21540   for (var i = 0; i < 16; i++)
21541     W[i] = msg[start + i];
21542
21543   for(; i < W.length; i++)
21544     W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
21545
21546   var a = this.h[0];
21547   var b = this.h[1];
21548   var c = this.h[2];
21549   var d = this.h[3];
21550   var e = this.h[4];
21551
21552   for (i = 0; i < W.length; i++) {
21553     var s = ~~(i / 20);
21554     var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
21555     e = d;
21556     d = c;
21557     c = rotl32(b, 30);
21558     b = a;
21559     a = t;
21560   }
21561
21562   this.h[0] = sum32(this.h[0], a);
21563   this.h[1] = sum32(this.h[1], b);
21564   this.h[2] = sum32(this.h[2], c);
21565   this.h[3] = sum32(this.h[3], d);
21566   this.h[4] = sum32(this.h[4], e);
21567 };
21568
21569 SHA1.prototype._digest = function digest(enc) {
21570   if (enc === 'hex')
21571     return utils.toHex32(this.h, 'big');
21572   else
21573     return utils.split32(this.h, 'big');
21574 };
21575
21576
21577 /***/ }),
21578 /* 232 */
21579 /***/ (function(module, exports, __webpack_require__) {
21580
21581 "use strict";
21582
21583
21584 var utils = __webpack_require__(11);
21585 var SHA256 = __webpack_require__(118);
21586
21587 function SHA224() {
21588   if (!(this instanceof SHA224))
21589     return new SHA224();
21590
21591   SHA256.call(this);
21592   this.h = [
21593     0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
21594     0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
21595 }
21596 utils.inherits(SHA224, SHA256);
21597 module.exports = SHA224;
21598
21599 SHA224.blockSize = 512;
21600 SHA224.outSize = 224;
21601 SHA224.hmacStrength = 192;
21602 SHA224.padLength = 64;
21603
21604 SHA224.prototype._digest = function digest(enc) {
21605   // Just truncate output
21606   if (enc === 'hex')
21607     return utils.toHex32(this.h.slice(0, 7), 'big');
21608   else
21609     return utils.split32(this.h.slice(0, 7), 'big');
21610 };
21611
21612
21613
21614 /***/ }),
21615 /* 233 */
21616 /***/ (function(module, exports, __webpack_require__) {
21617
21618 "use strict";
21619
21620
21621 var utils = __webpack_require__(11);
21622
21623 var SHA512 = __webpack_require__(119);
21624
21625 function SHA384() {
21626   if (!(this instanceof SHA384))
21627     return new SHA384();
21628
21629   SHA512.call(this);
21630   this.h = [
21631     0xcbbb9d5d, 0xc1059ed8,
21632     0x629a292a, 0x367cd507,
21633     0x9159015a, 0x3070dd17,
21634     0x152fecd8, 0xf70e5939,
21635     0x67332667, 0xffc00b31,
21636     0x8eb44a87, 0x68581511,
21637     0xdb0c2e0d, 0x64f98fa7,
21638     0x47b5481d, 0xbefa4fa4 ];
21639 }
21640 utils.inherits(SHA384, SHA512);
21641 module.exports = SHA384;
21642
21643 SHA384.blockSize = 1024;
21644 SHA384.outSize = 384;
21645 SHA384.hmacStrength = 192;
21646 SHA384.padLength = 128;
21647
21648 SHA384.prototype._digest = function digest(enc) {
21649   if (enc === 'hex')
21650     return utils.toHex32(this.h.slice(0, 12), 'big');
21651   else
21652     return utils.split32(this.h.slice(0, 12), 'big');
21653 };
21654
21655
21656 /***/ }),
21657 /* 234 */
21658 /***/ (function(module, exports, __webpack_require__) {
21659
21660 "use strict";
21661
21662
21663 var utils = __webpack_require__(11);
21664 var common = __webpack_require__(32);
21665
21666 var rotl32 = utils.rotl32;
21667 var sum32 = utils.sum32;
21668 var sum32_3 = utils.sum32_3;
21669 var sum32_4 = utils.sum32_4;
21670 var BlockHash = common.BlockHash;
21671
21672 function RIPEMD160() {
21673   if (!(this instanceof RIPEMD160))
21674     return new RIPEMD160();
21675
21676   BlockHash.call(this);
21677
21678   this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
21679   this.endian = 'little';
21680 }
21681 utils.inherits(RIPEMD160, BlockHash);
21682 exports.ripemd160 = RIPEMD160;
21683
21684 RIPEMD160.blockSize = 512;
21685 RIPEMD160.outSize = 160;
21686 RIPEMD160.hmacStrength = 192;
21687 RIPEMD160.padLength = 64;
21688
21689 RIPEMD160.prototype._update = function update(msg, start) {
21690   var A = this.h[0];
21691   var B = this.h[1];
21692   var C = this.h[2];
21693   var D = this.h[3];
21694   var E = this.h[4];
21695   var Ah = A;
21696   var Bh = B;
21697   var Ch = C;
21698   var Dh = D;
21699   var Eh = E;
21700   for (var j = 0; j < 80; j++) {
21701     var T = sum32(
21702       rotl32(
21703         sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
21704         s[j]),
21705       E);
21706     A = E;
21707     E = D;
21708     D = rotl32(C, 10);
21709     C = B;
21710     B = T;
21711     T = sum32(
21712       rotl32(
21713         sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
21714         sh[j]),
21715       Eh);
21716     Ah = Eh;
21717     Eh = Dh;
21718     Dh = rotl32(Ch, 10);
21719     Ch = Bh;
21720     Bh = T;
21721   }
21722   T = sum32_3(this.h[1], C, Dh);
21723   this.h[1] = sum32_3(this.h[2], D, Eh);
21724   this.h[2] = sum32_3(this.h[3], E, Ah);
21725   this.h[3] = sum32_3(this.h[4], A, Bh);
21726   this.h[4] = sum32_3(this.h[0], B, Ch);
21727   this.h[0] = T;
21728 };
21729
21730 RIPEMD160.prototype._digest = function digest(enc) {
21731   if (enc === 'hex')
21732     return utils.toHex32(this.h, 'little');
21733   else
21734     return utils.split32(this.h, 'little');
21735 };
21736
21737 function f(j, x, y, z) {
21738   if (j <= 15)
21739     return x ^ y ^ z;
21740   else if (j <= 31)
21741     return (x & y) | ((~x) & z);
21742   else if (j <= 47)
21743     return (x | (~y)) ^ z;
21744   else if (j <= 63)
21745     return (x & z) | (y & (~z));
21746   else
21747     return x ^ (y | (~z));
21748 }
21749
21750 function K(j) {
21751   if (j <= 15)
21752     return 0x00000000;
21753   else if (j <= 31)
21754     return 0x5a827999;
21755   else if (j <= 47)
21756     return 0x6ed9eba1;
21757   else if (j <= 63)
21758     return 0x8f1bbcdc;
21759   else
21760     return 0xa953fd4e;
21761 }
21762
21763 function Kh(j) {
21764   if (j <= 15)
21765     return 0x50a28be6;
21766   else if (j <= 31)
21767     return 0x5c4dd124;
21768   else if (j <= 47)
21769     return 0x6d703ef3;
21770   else if (j <= 63)
21771     return 0x7a6d76e9;
21772   else
21773     return 0x00000000;
21774 }
21775
21776 var r = [
21777   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
21778   7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
21779   3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
21780   1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
21781   4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
21782 ];
21783
21784 var rh = [
21785   5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
21786   6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
21787   15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
21788   8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
21789   12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
21790 ];
21791
21792 var s = [
21793   11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
21794   7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
21795   11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
21796   11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
21797   9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
21798 ];
21799
21800 var sh = [
21801   8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
21802   9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
21803   9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
21804   15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
21805   8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
21806 ];
21807
21808
21809 /***/ }),
21810 /* 235 */
21811 /***/ (function(module, exports, __webpack_require__) {
21812
21813 "use strict";
21814
21815
21816 var utils = __webpack_require__(11);
21817 var assert = __webpack_require__(9);
21818
21819 function Hmac(hash, key, enc) {
21820   if (!(this instanceof Hmac))
21821     return new Hmac(hash, key, enc);
21822   this.Hash = hash;
21823   this.blockSize = hash.blockSize / 8;
21824   this.outSize = hash.outSize / 8;
21825   this.inner = null;
21826   this.outer = null;
21827
21828   this._init(utils.toArray(key, enc));
21829 }
21830 module.exports = Hmac;
21831
21832 Hmac.prototype._init = function init(key) {
21833   // Shorten key, if needed
21834   if (key.length > this.blockSize)
21835     key = new this.Hash().update(key).digest();
21836   assert(key.length <= this.blockSize);
21837
21838   // Add padding to key
21839   for (var i = key.length; i < this.blockSize; i++)
21840     key.push(0);
21841
21842   for (i = 0; i < key.length; i++)
21843     key[i] ^= 0x36;
21844   this.inner = new this.Hash().update(key);
21845
21846   // 0x36 ^ 0x5c = 0x6a
21847   for (i = 0; i < key.length; i++)
21848     key[i] ^= 0x6a;
21849   this.outer = new this.Hash().update(key);
21850 };
21851
21852 Hmac.prototype.update = function update(msg, enc) {
21853   this.inner.update(msg, enc);
21854   return this;
21855 };
21856
21857 Hmac.prototype.digest = function digest(enc) {
21858   this.outer.update(this.inner.digest());
21859   return this.outer.digest(enc);
21860 };
21861
21862
21863 /***/ }),
21864 /* 236 */
21865 /***/ (function(module, exports) {
21866
21867 module.exports = {
21868   doubles: {
21869     step: 4,
21870     points: [
21871       [
21872         'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
21873         'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
21874       ],
21875       [
21876         '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
21877         '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
21878       ],
21879       [
21880         '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
21881         'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
21882       ],
21883       [
21884         '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
21885         '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
21886       ],
21887       [
21888         '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
21889         '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
21890       ],
21891       [
21892         '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
21893         '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
21894       ],
21895       [
21896         'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
21897         '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
21898       ],
21899       [
21900         '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
21901         'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
21902       ],
21903       [
21904         'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
21905         '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
21906       ],
21907       [
21908         'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
21909         'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
21910       ],
21911       [
21912         'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
21913         '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
21914       ],
21915       [
21916         '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
21917         '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
21918       ],
21919       [
21920         '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
21921         '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
21922       ],
21923       [
21924         '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
21925         '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
21926       ],
21927       [
21928         '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
21929         '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
21930       ],
21931       [
21932         '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
21933         '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
21934       ],
21935       [
21936         '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
21937         '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
21938       ],
21939       [
21940         '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
21941         '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
21942       ],
21943       [
21944         '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
21945         'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
21946       ],
21947       [
21948         'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
21949         '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
21950       ],
21951       [
21952         'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
21953         '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
21954       ],
21955       [
21956         '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
21957         '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
21958       ],
21959       [
21960         '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
21961         '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
21962       ],
21963       [
21964         'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
21965         '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
21966       ],
21967       [
21968         '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
21969         'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
21970       ],
21971       [
21972         'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
21973         '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
21974       ],
21975       [
21976         'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
21977         'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
21978       ],
21979       [
21980         'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
21981         '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
21982       ],
21983       [
21984         'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
21985         'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
21986       ],
21987       [
21988         'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
21989         '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
21990       ],
21991       [
21992         '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
21993         'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
21994       ],
21995       [
21996         '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
21997         '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
21998       ],
21999       [
22000         'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
22001         '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
22002       ],
22003       [
22004         '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
22005         'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
22006       ],
22007       [
22008         'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
22009         '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
22010       ],
22011       [
22012         'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
22013         '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
22014       ],
22015       [
22016         'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
22017         'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
22018       ],
22019       [
22020         '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
22021         '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
22022       ],
22023       [
22024         '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
22025         '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
22026       ],
22027       [
22028         '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
22029         'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
22030       ],
22031       [
22032         '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
22033         '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
22034       ],
22035       [
22036         'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
22037         '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
22038       ],
22039       [
22040         '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
22041         '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
22042       ],
22043       [
22044         '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
22045         'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
22046       ],
22047       [
22048         '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
22049         '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
22050       ],
22051       [
22052         'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
22053         '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
22054       ],
22055       [
22056         '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
22057         'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
22058       ],
22059       [
22060         'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
22061         'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
22062       ],
22063       [
22064         'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
22065         '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
22066       ],
22067       [
22068         '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
22069         'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
22070       ],
22071       [
22072         '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
22073         'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
22074       ],
22075       [
22076         'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
22077         '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
22078       ],
22079       [
22080         'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
22081         '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
22082       ],
22083       [
22084         'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
22085         '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
22086       ],
22087       [
22088         '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
22089         'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
22090       ],
22091       [
22092         '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
22093         '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
22094       ],
22095       [
22096         'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
22097         'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
22098       ],
22099       [
22100         '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
22101         'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
22102       ],
22103       [
22104         '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
22105         '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
22106       ],
22107       [
22108         '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
22109         '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
22110       ],
22111       [
22112         'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
22113         'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
22114       ],
22115       [
22116         '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
22117         '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
22118       ],
22119       [
22120         '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
22121         '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
22122       ],
22123       [
22124         'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
22125         '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
22126       ],
22127       [
22128         'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
22129         'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
22130       ]
22131     ]
22132   },
22133   naf: {
22134     wnd: 7,
22135     points: [
22136       [
22137         'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
22138         '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
22139       ],
22140       [
22141         '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
22142         'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
22143       ],
22144       [
22145         '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
22146         '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
22147       ],
22148       [
22149         'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
22150         'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
22151       ],
22152       [
22153         '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
22154         'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
22155       ],
22156       [
22157         'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
22158         'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
22159       ],
22160       [
22161         'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
22162         '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
22163       ],
22164       [
22165         'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
22166         '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
22167       ],
22168       [
22169         '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
22170         '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
22171       ],
22172       [
22173         '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
22174         '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
22175       ],
22176       [
22177         '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
22178         '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
22179       ],
22180       [
22181         '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
22182         '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
22183       ],
22184       [
22185         'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
22186         'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
22187       ],
22188       [
22189         'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
22190         '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
22191       ],
22192       [
22193         '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
22194         'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
22195       ],
22196       [
22197         '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
22198         'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
22199       ],
22200       [
22201         '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
22202         '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
22203       ],
22204       [
22205         '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
22206         '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
22207       ],
22208       [
22209         '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
22210         '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
22211       ],
22212       [
22213         '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
22214         'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
22215       ],
22216       [
22217         'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
22218         'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
22219       ],
22220       [
22221         '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
22222         '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
22223       ],
22224       [
22225         '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
22226         '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
22227       ],
22228       [
22229         'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
22230         'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
22231       ],
22232       [
22233         '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
22234         '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
22235       ],
22236       [
22237         'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
22238         'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
22239       ],
22240       [
22241         'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
22242         'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
22243       ],
22244       [
22245         '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
22246         '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
22247       ],
22248       [
22249         '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
22250         '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
22251       ],
22252       [
22253         '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
22254         '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
22255       ],
22256       [
22257         'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
22258         '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
22259       ],
22260       [
22261         '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
22262         '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
22263       ],
22264       [
22265         'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
22266         '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
22267       ],
22268       [
22269         '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
22270         'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
22271       ],
22272       [
22273         '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
22274         'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
22275       ],
22276       [
22277         'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
22278         'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
22279       ],
22280       [
22281         '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
22282         '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
22283       ],
22284       [
22285         '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
22286         'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
22287       ],
22288       [
22289         'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
22290         'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
22291       ],
22292       [
22293         '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
22294         '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
22295       ],
22296       [
22297         '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
22298         'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
22299       ],
22300       [
22301         '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
22302         '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
22303       ],
22304       [
22305         '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
22306         'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
22307       ],
22308       [
22309         'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
22310         '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
22311       ],
22312       [
22313         '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
22314         '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
22315       ],
22316       [
22317         '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
22318         'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
22319       ],
22320       [
22321         '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
22322         'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
22323       ],
22324       [
22325         'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
22326         'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
22327       ],
22328       [
22329         'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
22330         'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
22331       ],
22332       [
22333         '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
22334         '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
22335       ],
22336       [
22337         '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
22338         '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
22339       ],
22340       [
22341         'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
22342         '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
22343       ],
22344       [
22345         'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
22346         'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
22347       ],
22348       [
22349         '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
22350         '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
22351       ],
22352       [
22353         '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
22354         '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
22355       ],
22356       [
22357         'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
22358         '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
22359       ],
22360       [
22361         '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
22362         '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
22363       ],
22364       [
22365         'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
22366         'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
22367       ],
22368       [
22369         '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
22370         'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
22371       ],
22372       [
22373         '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
22374         '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
22375       ],
22376       [
22377         'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
22378         '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
22379       ],
22380       [
22381         'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
22382         '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
22383       ],
22384       [
22385         '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
22386         '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
22387       ],
22388       [
22389         '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
22390         '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
22391       ],
22392       [
22393         '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
22394         'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
22395       ],
22396       [
22397         '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
22398         'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
22399       ],
22400       [
22401         '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
22402         '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
22403       ],
22404       [
22405         '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
22406         '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
22407       ],
22408       [
22409         '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
22410         '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
22411       ],
22412       [
22413         '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
22414         'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
22415       ],
22416       [
22417         'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
22418         'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
22419       ],
22420       [
22421         '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
22422         'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
22423       ],
22424       [
22425         'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
22426         '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
22427       ],
22428       [
22429         'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
22430         '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
22431       ],
22432       [
22433         'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
22434         '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
22435       ],
22436       [
22437         'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
22438         '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
22439       ],
22440       [
22441         '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
22442         'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
22443       ],
22444       [
22445         '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
22446         '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
22447       ],
22448       [
22449         '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
22450         'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
22451       ],
22452       [
22453         'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
22454         'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
22455       ],
22456       [
22457         'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
22458         '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
22459       ],
22460       [
22461         'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
22462         'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
22463       ],
22464       [
22465         'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
22466         '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
22467       ],
22468       [
22469         '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
22470         '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
22471       ],
22472       [
22473         'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
22474         '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
22475       ],
22476       [
22477         'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
22478         '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
22479       ],
22480       [
22481         '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
22482         '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
22483       ],
22484       [
22485         '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
22486         'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
22487       ],
22488       [
22489         'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
22490         '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
22491       ],
22492       [
22493         'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
22494         '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
22495       ],
22496       [
22497         'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
22498         '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
22499       ],
22500       [
22501         '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
22502         '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
22503       ],
22504       [
22505         'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
22506         'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
22507       ],
22508       [
22509         '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
22510         'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
22511       ],
22512       [
22513         'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
22514         'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
22515       ],
22516       [
22517         'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
22518         '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
22519       ],
22520       [
22521         '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
22522         'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
22523       ],
22524       [
22525         'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
22526         '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
22527       ],
22528       [
22529         'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
22530         '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
22531       ],
22532       [
22533         'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
22534         '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
22535       ],
22536       [
22537         '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
22538         'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
22539       ],
22540       [
22541         '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
22542         'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
22543       ],
22544       [
22545         'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
22546         '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
22547       ],
22548       [
22549         '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
22550         'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
22551       ],
22552       [
22553         '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
22554         '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
22555       ],
22556       [
22557         '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
22558         'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
22559       ],
22560       [
22561         'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
22562         'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
22563       ],
22564       [
22565         '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
22566         'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
22567       ],
22568       [
22569         '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
22570         '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
22571       ],
22572       [
22573         '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
22574         'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
22575       ],
22576       [
22577         '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
22578         '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
22579       ],
22580       [
22581         'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
22582         'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
22583       ],
22584       [
22585         '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
22586         '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
22587       ],
22588       [
22589         'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
22590         '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
22591       ],
22592       [
22593         '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
22594         '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
22595       ],
22596       [
22597         'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
22598         'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
22599       ],
22600       [
22601         'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
22602         '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
22603       ],
22604       [
22605         'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
22606         'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
22607       ],
22608       [
22609         '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
22610         'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
22611       ],
22612       [
22613         '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
22614         '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
22615       ],
22616       [
22617         '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
22618         'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
22619       ],
22620       [
22621         '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
22622         '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
22623       ],
22624       [
22625         '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
22626         '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
22627       ],
22628       [
22629         '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
22630         'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
22631       ],
22632       [
22633         '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
22634         '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
22635       ],
22636       [
22637         '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
22638         '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
22639       ],
22640       [
22641         '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
22642         '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
22643       ]
22644     ]
22645   }
22646 };
22647
22648
22649 /***/ }),
22650 /* 237 */
22651 /***/ (function(module, exports, __webpack_require__) {
22652
22653 "use strict";
22654
22655
22656 var BN = __webpack_require__(4);
22657 var HmacDRBG = __webpack_require__(238);
22658 var elliptic = __webpack_require__(6);
22659 var utils = elliptic.utils;
22660 var assert = utils.assert;
22661
22662 var KeyPair = __webpack_require__(239);
22663 var Signature = __webpack_require__(240);
22664
22665 function EC(options) {
22666   if (!(this instanceof EC))
22667     return new EC(options);
22668
22669   // Shortcut `elliptic.ec(curve-name)`
22670   if (typeof options === 'string') {
22671     assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
22672
22673     options = elliptic.curves[options];
22674   }
22675
22676   // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
22677   if (options instanceof elliptic.curves.PresetCurve)
22678     options = { curve: options };
22679
22680   this.curve = options.curve.curve;
22681   this.n = this.curve.n;
22682   this.nh = this.n.ushrn(1);
22683   this.g = this.curve.g;
22684
22685   // Point on curve
22686   this.g = options.curve.g;
22687   this.g.precompute(options.curve.n.bitLength() + 1);
22688
22689   // Hash for function for DRBG
22690   this.hash = options.hash || options.curve.hash;
22691 }
22692 module.exports = EC;
22693
22694 EC.prototype.keyPair = function keyPair(options) {
22695   return new KeyPair(this, options);
22696 };
22697
22698 EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
22699   return KeyPair.fromPrivate(this, priv, enc);
22700 };
22701
22702 EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
22703   return KeyPair.fromPublic(this, pub, enc);
22704 };
22705
22706 EC.prototype.genKeyPair = function genKeyPair(options) {
22707   if (!options)
22708     options = {};
22709
22710   // Instantiate Hmac_DRBG
22711   var drbg = new HmacDRBG({
22712     hash: this.hash,
22713     pers: options.pers,
22714     persEnc: options.persEnc || 'utf8',
22715     entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
22716     entropyEnc: options.entropy && options.entropyEnc || 'utf8',
22717     nonce: this.n.toArray()
22718   });
22719
22720   var bytes = this.n.byteLength();
22721   var ns2 = this.n.sub(new BN(2));
22722   do {
22723     var priv = new BN(drbg.generate(bytes));
22724     if (priv.cmp(ns2) > 0)
22725       continue;
22726
22727     priv.iaddn(1);
22728     return this.keyFromPrivate(priv);
22729   } while (true);
22730 };
22731
22732 EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
22733   var delta = msg.byteLength() * 8 - this.n.bitLength();
22734   if (delta > 0)
22735     msg = msg.ushrn(delta);
22736   if (!truncOnly && msg.cmp(this.n) >= 0)
22737     return msg.sub(this.n);
22738   else
22739     return msg;
22740 };
22741
22742 EC.prototype.sign = function sign(msg, key, enc, options) {
22743   if (typeof enc === 'object') {
22744     options = enc;
22745     enc = null;
22746   }
22747   if (!options)
22748     options = {};
22749
22750   key = this.keyFromPrivate(key, enc);
22751   msg = this._truncateToN(new BN(msg, 16));
22752
22753   // Zero-extend key to provide enough entropy
22754   var bytes = this.n.byteLength();
22755   var bkey = key.getPrivate().toArray('be', bytes);
22756
22757   // Zero-extend nonce to have the same byte size as N
22758   var nonce = msg.toArray('be', bytes);
22759
22760   // Instantiate Hmac_DRBG
22761   var drbg = new HmacDRBG({
22762     hash: this.hash,
22763     entropy: bkey,
22764     nonce: nonce,
22765     pers: options.pers,
22766     persEnc: options.persEnc || 'utf8'
22767   });
22768
22769   // Number of bytes to generate
22770   var ns1 = this.n.sub(new BN(1));
22771
22772   for (var iter = 0; true; iter++) {
22773     var k = options.k ?
22774         options.k(iter) :
22775         new BN(drbg.generate(this.n.byteLength()));
22776     k = this._truncateToN(k, true);
22777     if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
22778       continue;
22779
22780     var kp = this.g.mul(k);
22781     if (kp.isInfinity())
22782       continue;
22783
22784     var kpX = kp.getX();
22785     var r = kpX.umod(this.n);
22786     if (r.cmpn(0) === 0)
22787       continue;
22788
22789     var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
22790     s = s.umod(this.n);
22791     if (s.cmpn(0) === 0)
22792       continue;
22793
22794     var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
22795                         (kpX.cmp(r) !== 0 ? 2 : 0);
22796
22797     // Use complement of `s`, if it is > `n / 2`
22798     if (options.canonical && s.cmp(this.nh) > 0) {
22799       s = this.n.sub(s);
22800       recoveryParam ^= 1;
22801     }
22802
22803     return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
22804   }
22805 };
22806
22807 EC.prototype.verify = function verify(msg, signature, key, enc) {
22808   msg = this._truncateToN(new BN(msg, 16));
22809   key = this.keyFromPublic(key, enc);
22810   signature = new Signature(signature, 'hex');
22811
22812   // Perform primitive values validation
22813   var r = signature.r;
22814   var s = signature.s;
22815   if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
22816     return false;
22817   if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
22818     return false;
22819
22820   // Validate signature
22821   var sinv = s.invm(this.n);
22822   var u1 = sinv.mul(msg).umod(this.n);
22823   var u2 = sinv.mul(r).umod(this.n);
22824
22825   if (!this.curve._maxwellTrick) {
22826     var p = this.g.mulAdd(u1, key.getPublic(), u2);
22827     if (p.isInfinity())
22828       return false;
22829
22830     return p.getX().umod(this.n).cmp(r) === 0;
22831   }
22832
22833   // NOTE: Greg Maxwell's trick, inspired by:
22834   // https://git.io/vad3K
22835
22836   var p = this.g.jmulAdd(u1, key.getPublic(), u2);
22837   if (p.isInfinity())
22838     return false;
22839
22840   // Compare `p.x` of Jacobian point with `r`,
22841   // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
22842   // inverse of `p.z^2`
22843   return p.eqXToP(r);
22844 };
22845
22846 EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
22847   assert((3 & j) === j, 'The recovery param is more than two bits');
22848   signature = new Signature(signature, enc);
22849
22850   var n = this.n;
22851   var e = new BN(msg);
22852   var r = signature.r;
22853   var s = signature.s;
22854
22855   // A set LSB signifies that the y-coordinate is odd
22856   var isYOdd = j & 1;
22857   var isSecondKey = j >> 1;
22858   if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
22859     throw new Error('Unable to find sencond key candinate');
22860
22861   // 1.1. Let x = r + jn.
22862   if (isSecondKey)
22863     r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
22864   else
22865     r = this.curve.pointFromX(r, isYOdd);
22866
22867   var rInv = signature.r.invm(n);
22868   var s1 = n.sub(e).mul(rInv).umod(n);
22869   var s2 = s.mul(rInv).umod(n);
22870
22871   // 1.6.1 Compute Q = r^-1 (sR -  eG)
22872   //               Q = r^-1 (sR + -eG)
22873   return this.g.mulAdd(s1, r, s2);
22874 };
22875
22876 EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
22877   signature = new Signature(signature, enc);
22878   if (signature.recoveryParam !== null)
22879     return signature.recoveryParam;
22880
22881   for (var i = 0; i < 4; i++) {
22882     var Qprime;
22883     try {
22884       Qprime = this.recoverPubKey(e, signature, i);
22885     } catch (e) {
22886       continue;
22887     }
22888
22889     if (Qprime.eq(Q))
22890       return i;
22891   }
22892   throw new Error('Unable to find valid recovery factor');
22893 };
22894
22895
22896 /***/ }),
22897 /* 238 */
22898 /***/ (function(module, exports, __webpack_require__) {
22899
22900 "use strict";
22901
22902
22903 var hash = __webpack_require__(68);
22904 var utils = __webpack_require__(116);
22905 var assert = __webpack_require__(9);
22906
22907 function HmacDRBG(options) {
22908   if (!(this instanceof HmacDRBG))
22909     return new HmacDRBG(options);
22910   this.hash = options.hash;
22911   this.predResist = !!options.predResist;
22912
22913   this.outLen = this.hash.outSize;
22914   this.minEntropy = options.minEntropy || this.hash.hmacStrength;
22915
22916   this._reseed = null;
22917   this.reseedInterval = null;
22918   this.K = null;
22919   this.V = null;
22920
22921   var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
22922   var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
22923   var pers = utils.toArray(options.pers, options.persEnc || 'hex');
22924   assert(entropy.length >= (this.minEntropy / 8),
22925          'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
22926   this._init(entropy, nonce, pers);
22927 }
22928 module.exports = HmacDRBG;
22929
22930 HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
22931   var seed = entropy.concat(nonce).concat(pers);
22932
22933   this.K = new Array(this.outLen / 8);
22934   this.V = new Array(this.outLen / 8);
22935   for (var i = 0; i < this.V.length; i++) {
22936     this.K[i] = 0x00;
22937     this.V[i] = 0x01;
22938   }
22939
22940   this._update(seed);
22941   this._reseed = 1;
22942   this.reseedInterval = 0x1000000000000;  // 2^48
22943 };
22944
22945 HmacDRBG.prototype._hmac = function hmac() {
22946   return new hash.hmac(this.hash, this.K);
22947 };
22948
22949 HmacDRBG.prototype._update = function update(seed) {
22950   var kmac = this._hmac()
22951                  .update(this.V)
22952                  .update([ 0x00 ]);
22953   if (seed)
22954     kmac = kmac.update(seed);
22955   this.K = kmac.digest();
22956   this.V = this._hmac().update(this.V).digest();
22957   if (!seed)
22958     return;
22959
22960   this.K = this._hmac()
22961                .update(this.V)
22962                .update([ 0x01 ])
22963                .update(seed)
22964                .digest();
22965   this.V = this._hmac().update(this.V).digest();
22966 };
22967
22968 HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
22969   // Optional entropy enc
22970   if (typeof entropyEnc !== 'string') {
22971     addEnc = add;
22972     add = entropyEnc;
22973     entropyEnc = null;
22974   }
22975
22976   entropy = utils.toArray(entropy, entropyEnc);
22977   add = utils.toArray(add, addEnc);
22978
22979   assert(entropy.length >= (this.minEntropy / 8),
22980          'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
22981
22982   this._update(entropy.concat(add || []));
22983   this._reseed = 1;
22984 };
22985
22986 HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
22987   if (this._reseed > this.reseedInterval)
22988     throw new Error('Reseed is required');
22989
22990   // Optional encoding
22991   if (typeof enc !== 'string') {
22992     addEnc = add;
22993     add = enc;
22994     enc = null;
22995   }
22996
22997   // Optional additional data
22998   if (add) {
22999     add = utils.toArray(add, addEnc || 'hex');
23000     this._update(add);
23001   }
23002
23003   var temp = [];
23004   while (temp.length < len) {
23005     this.V = this._hmac().update(this.V).digest();
23006     temp = temp.concat(this.V);
23007   }
23008
23009   var res = temp.slice(0, len);
23010   this._update(add);
23011   this._reseed++;
23012   return utils.encode(res, enc);
23013 };
23014
23015
23016 /***/ }),
23017 /* 239 */
23018 /***/ (function(module, exports, __webpack_require__) {
23019
23020 "use strict";
23021
23022
23023 var BN = __webpack_require__(4);
23024 var elliptic = __webpack_require__(6);
23025 var utils = elliptic.utils;
23026 var assert = utils.assert;
23027
23028 function KeyPair(ec, options) {
23029   this.ec = ec;
23030   this.priv = null;
23031   this.pub = null;
23032
23033   // KeyPair(ec, { priv: ..., pub: ... })
23034   if (options.priv)
23035     this._importPrivate(options.priv, options.privEnc);
23036   if (options.pub)
23037     this._importPublic(options.pub, options.pubEnc);
23038 }
23039 module.exports = KeyPair;
23040
23041 KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
23042   if (pub instanceof KeyPair)
23043     return pub;
23044
23045   return new KeyPair(ec, {
23046     pub: pub,
23047     pubEnc: enc
23048   });
23049 };
23050
23051 KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
23052   if (priv instanceof KeyPair)
23053     return priv;
23054
23055   return new KeyPair(ec, {
23056     priv: priv,
23057     privEnc: enc
23058   });
23059 };
23060
23061 KeyPair.prototype.validate = function validate() {
23062   var pub = this.getPublic();
23063
23064   if (pub.isInfinity())
23065     return { result: false, reason: 'Invalid public key' };
23066   if (!pub.validate())
23067     return { result: false, reason: 'Public key is not a point' };
23068   if (!pub.mul(this.ec.curve.n).isInfinity())
23069     return { result: false, reason: 'Public key * N != O' };
23070
23071   return { result: true, reason: null };
23072 };
23073
23074 KeyPair.prototype.getPublic = function getPublic(compact, enc) {
23075   // compact is optional argument
23076   if (typeof compact === 'string') {
23077     enc = compact;
23078     compact = null;
23079   }
23080
23081   if (!this.pub)
23082     this.pub = this.ec.g.mul(this.priv);
23083
23084   if (!enc)
23085     return this.pub;
23086
23087   return this.pub.encode(enc, compact);
23088 };
23089
23090 KeyPair.prototype.getPrivate = function getPrivate(enc) {
23091   if (enc === 'hex')
23092     return this.priv.toString(16, 2);
23093   else
23094     return this.priv;
23095 };
23096
23097 KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
23098   this.priv = new BN(key, enc || 16);
23099
23100   // Ensure that the priv won't be bigger than n, otherwise we may fail
23101   // in fixed multiplication method
23102   this.priv = this.priv.umod(this.ec.curve.n);
23103 };
23104
23105 KeyPair.prototype._importPublic = function _importPublic(key, enc) {
23106   if (key.x || key.y) {
23107     // Montgomery points only have an `x` coordinate.
23108     // Weierstrass/Edwards points on the other hand have both `x` and
23109     // `y` coordinates.
23110     if (this.ec.curve.type === 'mont') {
23111       assert(key.x, 'Need x coordinate');
23112     } else if (this.ec.curve.type === 'short' ||
23113                this.ec.curve.type === 'edwards') {
23114       assert(key.x && key.y, 'Need both x and y coordinate');
23115     }
23116     this.pub = this.ec.curve.point(key.x, key.y);
23117     return;
23118   }
23119   this.pub = this.ec.curve.decodePoint(key, enc);
23120 };
23121
23122 // ECDH
23123 KeyPair.prototype.derive = function derive(pub) {
23124   return pub.mul(this.priv).getX();
23125 };
23126
23127 // ECDSA
23128 KeyPair.prototype.sign = function sign(msg, enc, options) {
23129   return this.ec.sign(msg, this, enc, options);
23130 };
23131
23132 KeyPair.prototype.verify = function verify(msg, signature) {
23133   return this.ec.verify(msg, signature, this);
23134 };
23135
23136 KeyPair.prototype.inspect = function inspect() {
23137   return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
23138          ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
23139 };
23140
23141
23142 /***/ }),
23143 /* 240 */
23144 /***/ (function(module, exports, __webpack_require__) {
23145
23146 "use strict";
23147
23148
23149 var BN = __webpack_require__(4);
23150
23151 var elliptic = __webpack_require__(6);
23152 var utils = elliptic.utils;
23153 var assert = utils.assert;
23154
23155 function Signature(options, enc) {
23156   if (options instanceof Signature)
23157     return options;
23158
23159   if (this._importDER(options, enc))
23160     return;
23161
23162   assert(options.r && options.s, 'Signature without r or s');
23163   this.r = new BN(options.r, 16);
23164   this.s = new BN(options.s, 16);
23165   if (options.recoveryParam === undefined)
23166     this.recoveryParam = null;
23167   else
23168     this.recoveryParam = options.recoveryParam;
23169 }
23170 module.exports = Signature;
23171
23172 function Position() {
23173   this.place = 0;
23174 }
23175
23176 function getLength(buf, p) {
23177   var initial = buf[p.place++];
23178   if (!(initial & 0x80)) {
23179     return initial;
23180   }
23181   var octetLen = initial & 0xf;
23182   var val = 0;
23183   for (var i = 0, off = p.place; i < octetLen; i++, off++) {
23184     val <<= 8;
23185     val |= buf[off];
23186   }
23187   p.place = off;
23188   return val;
23189 }
23190
23191 function rmPadding(buf) {
23192   var i = 0;
23193   var len = buf.length - 1;
23194   while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
23195     i++;
23196   }
23197   if (i === 0) {
23198     return buf;
23199   }
23200   return buf.slice(i);
23201 }
23202
23203 Signature.prototype._importDER = function _importDER(data, enc) {
23204   data = utils.toArray(data, enc);
23205   var p = new Position();
23206   if (data[p.place++] !== 0x30) {
23207     return false;
23208   }
23209   var len = getLength(data, p);
23210   if ((len + p.place) !== data.length) {
23211     return false;
23212   }
23213   if (data[p.place++] !== 0x02) {
23214     return false;
23215   }
23216   var rlen = getLength(data, p);
23217   var r = data.slice(p.place, rlen + p.place);
23218   p.place += rlen;
23219   if (data[p.place++] !== 0x02) {
23220     return false;
23221   }
23222   var slen = getLength(data, p);
23223   if (data.length !== slen + p.place) {
23224     return false;
23225   }
23226   var s = data.slice(p.place, slen + p.place);
23227   if (r[0] === 0 && (r[1] & 0x80)) {
23228     r = r.slice(1);
23229   }
23230   if (s[0] === 0 && (s[1] & 0x80)) {
23231     s = s.slice(1);
23232   }
23233
23234   this.r = new BN(r);
23235   this.s = new BN(s);
23236   this.recoveryParam = null;
23237
23238   return true;
23239 };
23240
23241 function constructLength(arr, len) {
23242   if (len < 0x80) {
23243     arr.push(len);
23244     return;
23245   }
23246   var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
23247   arr.push(octets | 0x80);
23248   while (--octets) {
23249     arr.push((len >>> (octets << 3)) & 0xff);
23250   }
23251   arr.push(len);
23252 }
23253
23254 Signature.prototype.toDER = function toDER(enc) {
23255   var r = this.r.toArray();
23256   var s = this.s.toArray();
23257
23258   // Pad values
23259   if (r[0] & 0x80)
23260     r = [ 0 ].concat(r);
23261   // Pad values
23262   if (s[0] & 0x80)
23263     s = [ 0 ].concat(s);
23264
23265   r = rmPadding(r);
23266   s = rmPadding(s);
23267
23268   while (!s[0] && !(s[1] & 0x80)) {
23269     s = s.slice(1);
23270   }
23271   var arr = [ 0x02 ];
23272   constructLength(arr, r.length);
23273   arr = arr.concat(r);
23274   arr.push(0x02);
23275   constructLength(arr, s.length);
23276   var backHalf = arr.concat(s);
23277   var res = [ 0x30 ];
23278   constructLength(res, backHalf.length);
23279   res = res.concat(backHalf);
23280   return utils.encode(res, enc);
23281 };
23282
23283
23284 /***/ }),
23285 /* 241 */
23286 /***/ (function(module, exports, __webpack_require__) {
23287
23288 "use strict";
23289
23290
23291 var hash = __webpack_require__(68);
23292 var elliptic = __webpack_require__(6);
23293 var utils = elliptic.utils;
23294 var assert = utils.assert;
23295 var parseBytes = utils.parseBytes;
23296 var KeyPair = __webpack_require__(242);
23297 var Signature = __webpack_require__(243);
23298
23299 function EDDSA(curve) {
23300   assert(curve === 'ed25519', 'only tested with ed25519 so far');
23301
23302   if (!(this instanceof EDDSA))
23303     return new EDDSA(curve);
23304
23305   var curve = elliptic.curves[curve].curve;
23306   this.curve = curve;
23307   this.g = curve.g;
23308   this.g.precompute(curve.n.bitLength() + 1);
23309
23310   this.pointClass = curve.point().constructor;
23311   this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
23312   this.hash = hash.sha512;
23313 }
23314
23315 module.exports = EDDSA;
23316
23317 /**
23318 * @param {Array|String} message - message bytes
23319 * @param {Array|String|KeyPair} secret - secret bytes or a keypair
23320 * @returns {Signature} - signature
23321 */
23322 EDDSA.prototype.sign = function sign(message, secret) {
23323   message = parseBytes(message);
23324   var key = this.keyFromSecret(secret);
23325   var r = this.hashInt(key.messagePrefix(), message);
23326   var R = this.g.mul(r);
23327   var Rencoded = this.encodePoint(R);
23328   var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
23329                .mul(key.priv());
23330   var S = r.add(s_).umod(this.curve.n);
23331   return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
23332 };
23333
23334 /**
23335 * @param {Array} message - message bytes
23336 * @param {Array|String|Signature} sig - sig bytes
23337 * @param {Array|String|Point|KeyPair} pub - public key
23338 * @returns {Boolean} - true if public key matches sig of message
23339 */
23340 EDDSA.prototype.verify = function verify(message, sig, pub) {
23341   message = parseBytes(message);
23342   sig = this.makeSignature(sig);
23343   var key = this.keyFromPublic(pub);
23344   var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
23345   var SG = this.g.mul(sig.S());
23346   var RplusAh = sig.R().add(key.pub().mul(h));
23347   return RplusAh.eq(SG);
23348 };
23349
23350 EDDSA.prototype.hashInt = function hashInt() {
23351   var hash = this.hash();
23352   for (var i = 0; i < arguments.length; i++)
23353     hash.update(arguments[i]);
23354   return utils.intFromLE(hash.digest()).umod(this.curve.n);
23355 };
23356
23357 EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
23358   return KeyPair.fromPublic(this, pub);
23359 };
23360
23361 EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
23362   return KeyPair.fromSecret(this, secret);
23363 };
23364
23365 EDDSA.prototype.makeSignature = function makeSignature(sig) {
23366   if (sig instanceof Signature)
23367     return sig;
23368   return new Signature(this, sig);
23369 };
23370
23371 /**
23372 * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
23373 *
23374 * EDDSA defines methods for encoding and decoding points and integers. These are
23375 * helper convenience methods, that pass along to utility functions implied
23376 * parameters.
23377 *
23378 */
23379 EDDSA.prototype.encodePoint = function encodePoint(point) {
23380   var enc = point.getY().toArray('le', this.encodingLength);
23381   enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
23382   return enc;
23383 };
23384
23385 EDDSA.prototype.decodePoint = function decodePoint(bytes) {
23386   bytes = utils.parseBytes(bytes);
23387
23388   var lastIx = bytes.length - 1;
23389   var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
23390   var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
23391
23392   var y = utils.intFromLE(normed);
23393   return this.curve.pointFromY(y, xIsOdd);
23394 };
23395
23396 EDDSA.prototype.encodeInt = function encodeInt(num) {
23397   return num.toArray('le', this.encodingLength);
23398 };
23399
23400 EDDSA.prototype.decodeInt = function decodeInt(bytes) {
23401   return utils.intFromLE(bytes);
23402 };
23403
23404 EDDSA.prototype.isPoint = function isPoint(val) {
23405   return val instanceof this.pointClass;
23406 };
23407
23408
23409 /***/ }),
23410 /* 242 */
23411 /***/ (function(module, exports, __webpack_require__) {
23412
23413 "use strict";
23414
23415
23416 var elliptic = __webpack_require__(6);
23417 var utils = elliptic.utils;
23418 var assert = utils.assert;
23419 var parseBytes = utils.parseBytes;
23420 var cachedProperty = utils.cachedProperty;
23421
23422 /**
23423 * @param {EDDSA} eddsa - instance
23424 * @param {Object} params - public/private key parameters
23425 *
23426 * @param {Array<Byte>} [params.secret] - secret seed bytes
23427 * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
23428 * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
23429 *
23430 */
23431 function KeyPair(eddsa, params) {
23432   this.eddsa = eddsa;
23433   this._secret = parseBytes(params.secret);
23434   if (eddsa.isPoint(params.pub))
23435     this._pub = params.pub;
23436   else
23437     this._pubBytes = parseBytes(params.pub);
23438 }
23439
23440 KeyPair.fromPublic = function fromPublic(eddsa, pub) {
23441   if (pub instanceof KeyPair)
23442     return pub;
23443   return new KeyPair(eddsa, { pub: pub });
23444 };
23445
23446 KeyPair.fromSecret = function fromSecret(eddsa, secret) {
23447   if (secret instanceof KeyPair)
23448     return secret;
23449   return new KeyPair(eddsa, { secret: secret });
23450 };
23451
23452 KeyPair.prototype.secret = function secret() {
23453   return this._secret;
23454 };
23455
23456 cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
23457   return this.eddsa.encodePoint(this.pub());
23458 });
23459
23460 cachedProperty(KeyPair, 'pub', function pub() {
23461   if (this._pubBytes)
23462     return this.eddsa.decodePoint(this._pubBytes);
23463   return this.eddsa.g.mul(this.priv());
23464 });
23465
23466 cachedProperty(KeyPair, 'privBytes', function privBytes() {
23467   var eddsa = this.eddsa;
23468   var hash = this.hash();
23469   var lastIx = eddsa.encodingLength - 1;
23470
23471   var a = hash.slice(0, eddsa.encodingLength);
23472   a[0] &= 248;
23473   a[lastIx] &= 127;
23474   a[lastIx] |= 64;
23475
23476   return a;
23477 });
23478
23479 cachedProperty(KeyPair, 'priv', function priv() {
23480   return this.eddsa.decodeInt(this.privBytes());
23481 });
23482
23483 cachedProperty(KeyPair, 'hash', function hash() {
23484   return this.eddsa.hash().update(this.secret()).digest();
23485 });
23486
23487 cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
23488   return this.hash().slice(this.eddsa.encodingLength);
23489 });
23490
23491 KeyPair.prototype.sign = function sign(message) {
23492   assert(this._secret, 'KeyPair can only verify');
23493   return this.eddsa.sign(message, this);
23494 };
23495
23496 KeyPair.prototype.verify = function verify(message, sig) {
23497   return this.eddsa.verify(message, sig, this);
23498 };
23499
23500 KeyPair.prototype.getSecret = function getSecret(enc) {
23501   assert(this._secret, 'KeyPair is public only');
23502   return utils.encode(this.secret(), enc);
23503 };
23504
23505 KeyPair.prototype.getPublic = function getPublic(enc) {
23506   return utils.encode(this.pubBytes(), enc);
23507 };
23508
23509 module.exports = KeyPair;
23510
23511
23512 /***/ }),
23513 /* 243 */
23514 /***/ (function(module, exports, __webpack_require__) {
23515
23516 "use strict";
23517
23518
23519 var BN = __webpack_require__(4);
23520 var elliptic = __webpack_require__(6);
23521 var utils = elliptic.utils;
23522 var assert = utils.assert;
23523 var cachedProperty = utils.cachedProperty;
23524 var parseBytes = utils.parseBytes;
23525
23526 /**
23527 * @param {EDDSA} eddsa - eddsa instance
23528 * @param {Array<Bytes>|Object} sig -
23529 * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
23530 * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
23531 * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
23532 * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
23533 */
23534 function Signature(eddsa, sig) {
23535   this.eddsa = eddsa;
23536
23537   if (typeof sig !== 'object')
23538     sig = parseBytes(sig);
23539
23540   if (Array.isArray(sig)) {
23541     sig = {
23542       R: sig.slice(0, eddsa.encodingLength),
23543       S: sig.slice(eddsa.encodingLength)
23544     };
23545   }
23546
23547   assert(sig.R && sig.S, 'Signature without R or S');
23548
23549   if (eddsa.isPoint(sig.R))
23550     this._R = sig.R;
23551   if (sig.S instanceof BN)
23552     this._S = sig.S;
23553
23554   this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
23555   this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
23556 }
23557
23558 cachedProperty(Signature, 'S', function S() {
23559   return this.eddsa.decodeInt(this.Sencoded());
23560 });
23561
23562 cachedProperty(Signature, 'R', function R() {
23563   return this.eddsa.decodePoint(this.Rencoded());
23564 });
23565
23566 cachedProperty(Signature, 'Rencoded', function Rencoded() {
23567   return this.eddsa.encodePoint(this.R());
23568 });
23569
23570 cachedProperty(Signature, 'Sencoded', function Sencoded() {
23571   return this.eddsa.encodeInt(this.S());
23572 });
23573
23574 Signature.prototype.toBytes = function toBytes() {
23575   return this.Rencoded().concat(this.Sencoded());
23576 };
23577
23578 Signature.prototype.toHex = function toHex() {
23579   return utils.encode(this.toBytes(), 'hex').toUpperCase();
23580 };
23581
23582 module.exports = Signature;
23583
23584
23585 /***/ }),
23586 /* 244 */
23587 /***/ (function(module, exports, __webpack_require__) {
23588
23589 "use strict";
23590 // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
23591 // Fedor, you are amazing.
23592
23593
23594 var asn1 = __webpack_require__(33)
23595
23596 exports.certificate = __webpack_require__(255)
23597
23598 var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
23599   this.seq().obj(
23600     this.key('version').int(),
23601     this.key('modulus').int(),
23602     this.key('publicExponent').int(),
23603     this.key('privateExponent').int(),
23604     this.key('prime1').int(),
23605     this.key('prime2').int(),
23606     this.key('exponent1').int(),
23607     this.key('exponent2').int(),
23608     this.key('coefficient').int()
23609   )
23610 })
23611 exports.RSAPrivateKey = RSAPrivateKey
23612
23613 var RSAPublicKey = asn1.define('RSAPublicKey', function () {
23614   this.seq().obj(
23615     this.key('modulus').int(),
23616     this.key('publicExponent').int()
23617   )
23618 })
23619 exports.RSAPublicKey = RSAPublicKey
23620
23621 var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
23622   this.seq().obj(
23623     this.key('algorithm').use(AlgorithmIdentifier),
23624     this.key('subjectPublicKey').bitstr()
23625   )
23626 })
23627 exports.PublicKey = PublicKey
23628
23629 var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
23630   this.seq().obj(
23631     this.key('algorithm').objid(),
23632     this.key('none').null_().optional(),
23633     this.key('curve').objid().optional(),
23634     this.key('params').seq().obj(
23635       this.key('p').int(),
23636       this.key('q').int(),
23637       this.key('g').int()
23638     ).optional()
23639   )
23640 })
23641
23642 var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
23643   this.seq().obj(
23644     this.key('version').int(),
23645     this.key('algorithm').use(AlgorithmIdentifier),
23646     this.key('subjectPrivateKey').octstr()
23647   )
23648 })
23649 exports.PrivateKey = PrivateKeyInfo
23650 var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
23651   this.seq().obj(
23652     this.key('algorithm').seq().obj(
23653       this.key('id').objid(),
23654       this.key('decrypt').seq().obj(
23655         this.key('kde').seq().obj(
23656           this.key('id').objid(),
23657           this.key('kdeparams').seq().obj(
23658             this.key('salt').octstr(),
23659             this.key('iters').int()
23660           )
23661         ),
23662         this.key('cipher').seq().obj(
23663           this.key('algo').objid(),
23664           this.key('iv').octstr()
23665         )
23666       )
23667     ),
23668     this.key('subjectPrivateKey').octstr()
23669   )
23670 })
23671
23672 exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
23673
23674 var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
23675   this.seq().obj(
23676     this.key('version').int(),
23677     this.key('p').int(),
23678     this.key('q').int(),
23679     this.key('g').int(),
23680     this.key('pub_key').int(),
23681     this.key('priv_key').int()
23682   )
23683 })
23684 exports.DSAPrivateKey = DSAPrivateKey
23685
23686 exports.DSAparam = asn1.define('DSAparam', function () {
23687   this.int()
23688 })
23689
23690 var ECPrivateKey = asn1.define('ECPrivateKey', function () {
23691   this.seq().obj(
23692     this.key('version').int(),
23693     this.key('privateKey').octstr(),
23694     this.key('parameters').optional().explicit(0).use(ECParameters),
23695     this.key('publicKey').optional().explicit(1).bitstr()
23696   )
23697 })
23698 exports.ECPrivateKey = ECPrivateKey
23699
23700 var ECParameters = asn1.define('ECParameters', function () {
23701   this.choice({
23702     namedCurve: this.objid()
23703   })
23704 })
23705
23706 exports.signature = asn1.define('signature', function () {
23707   this.seq().obj(
23708     this.key('r').int(),
23709     this.key('s').int()
23710   )
23711 })
23712
23713
23714 /***/ }),
23715 /* 245 */
23716 /***/ (function(module, exports, __webpack_require__) {
23717
23718 var asn1 = __webpack_require__(33);
23719 var inherits = __webpack_require__(1);
23720
23721 var api = exports;
23722
23723 api.define = function define(name, body) {
23724   return new Entity(name, body);
23725 };
23726
23727 function Entity(name, body) {
23728   this.name = name;
23729   this.body = body;
23730
23731   this.decoders = {};
23732   this.encoders = {};
23733 };
23734
23735 Entity.prototype._createNamed = function createNamed(base) {
23736   var named;
23737   try {
23738     named = __webpack_require__(246).runInThisContext(
23739       '(function ' + this.name + '(entity) {\n' +
23740       '  this._initNamed(entity);\n' +
23741       '})'
23742     );
23743   } catch (e) {
23744     named = function (entity) {
23745       this._initNamed(entity);
23746     };
23747   }
23748   inherits(named, base);
23749   named.prototype._initNamed = function initnamed(entity) {
23750     base.call(this, entity);
23751   };
23752
23753   return new named(this);
23754 };
23755
23756 Entity.prototype._getDecoder = function _getDecoder(enc) {
23757   enc = enc || 'der';
23758   // Lazily create decoder
23759   if (!this.decoders.hasOwnProperty(enc))
23760     this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
23761   return this.decoders[enc];
23762 };
23763
23764 Entity.prototype.decode = function decode(data, enc, options) {
23765   return this._getDecoder(enc).decode(data, options);
23766 };
23767
23768 Entity.prototype._getEncoder = function _getEncoder(enc) {
23769   enc = enc || 'der';
23770   // Lazily create encoder
23771   if (!this.encoders.hasOwnProperty(enc))
23772     this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
23773   return this.encoders[enc];
23774 };
23775
23776 Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
23777   return this._getEncoder(enc).encode(data, reporter);
23778 };
23779
23780
23781 /***/ }),
23782 /* 246 */
23783 /***/ (function(module, exports, __webpack_require__) {
23784
23785 var indexOf = __webpack_require__(247);
23786
23787 var Object_keys = function (obj) {
23788     if (Object.keys) return Object.keys(obj)
23789     else {
23790         var res = [];
23791         for (var key in obj) res.push(key)
23792         return res;
23793     }
23794 };
23795
23796 var forEach = function (xs, fn) {
23797     if (xs.forEach) return xs.forEach(fn)
23798     else for (var i = 0; i < xs.length; i++) {
23799         fn(xs[i], i, xs);
23800     }
23801 };
23802
23803 var defineProp = (function() {
23804     try {
23805         Object.defineProperty({}, '_', {});
23806         return function(obj, name, value) {
23807             Object.defineProperty(obj, name, {
23808                 writable: true,
23809                 enumerable: false,
23810                 configurable: true,
23811                 value: value
23812             })
23813         };
23814     } catch(e) {
23815         return function(obj, name, value) {
23816             obj[name] = value;
23817         };
23818     }
23819 }());
23820
23821 var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
23822 'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
23823 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
23824 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
23825 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
23826
23827 function Context() {}
23828 Context.prototype = {};
23829
23830 var Script = exports.Script = function NodeScript (code) {
23831     if (!(this instanceof Script)) return new Script(code);
23832     this.code = code;
23833 };
23834
23835 Script.prototype.runInContext = function (context) {
23836     if (!(context instanceof Context)) {
23837         throw new TypeError("needs a 'context' argument.");
23838     }
23839     
23840     var iframe = document.createElement('iframe');
23841     if (!iframe.style) iframe.style = {};
23842     iframe.style.display = 'none';
23843     
23844     document.body.appendChild(iframe);
23845     
23846     var win = iframe.contentWindow;
23847     var wEval = win.eval, wExecScript = win.execScript;
23848
23849     if (!wEval && wExecScript) {
23850         // win.eval() magically appears when this is called in IE:
23851         wExecScript.call(win, 'null');
23852         wEval = win.eval;
23853     }
23854     
23855     forEach(Object_keys(context), function (key) {
23856         win[key] = context[key];
23857     });
23858     forEach(globals, function (key) {
23859         if (context[key]) {
23860             win[key] = context[key];
23861         }
23862     });
23863     
23864     var winKeys = Object_keys(win);
23865
23866     var res = wEval.call(win, this.code);
23867     
23868     forEach(Object_keys(win), function (key) {
23869         // Avoid copying circular objects like `top` and `window` by only
23870         // updating existing context properties or new properties in the `win`
23871         // that was only introduced after the eval.
23872         if (key in context || indexOf(winKeys, key) === -1) {
23873             context[key] = win[key];
23874         }
23875     });
23876
23877     forEach(globals, function (key) {
23878         if (!(key in context)) {
23879             defineProp(context, key, win[key]);
23880         }
23881     });
23882     
23883     document.body.removeChild(iframe);
23884     
23885     return res;
23886 };
23887
23888 Script.prototype.runInThisContext = function () {
23889     return eval(this.code); // maybe...
23890 };
23891
23892 Script.prototype.runInNewContext = function (context) {
23893     var ctx = Script.createContext(context);
23894     var res = this.runInContext(ctx);
23895
23896     forEach(Object_keys(ctx), function (key) {
23897         context[key] = ctx[key];
23898     });
23899
23900     return res;
23901 };
23902
23903 forEach(Object_keys(Script.prototype), function (name) {
23904     exports[name] = Script[name] = function (code) {
23905         var s = Script(code);
23906         return s[name].apply(s, [].slice.call(arguments, 1));
23907     };
23908 });
23909
23910 exports.createScript = function (code) {
23911     return exports.Script(code);
23912 };
23913
23914 exports.createContext = Script.createContext = function (context) {
23915     var copy = new Context();
23916     if(typeof context === 'object') {
23917         forEach(Object_keys(context), function (key) {
23918             copy[key] = context[key];
23919         });
23920     }
23921     return copy;
23922 };
23923
23924
23925 /***/ }),
23926 /* 247 */
23927 /***/ (function(module, exports) {
23928
23929
23930 var indexOf = [].indexOf;
23931
23932 module.exports = function(arr, obj){
23933   if (indexOf) return arr.indexOf(obj);
23934   for (var i = 0; i < arr.length; ++i) {
23935     if (arr[i] === obj) return i;
23936   }
23937   return -1;
23938 };
23939
23940 /***/ }),
23941 /* 248 */
23942 /***/ (function(module, exports, __webpack_require__) {
23943
23944 var inherits = __webpack_require__(1);
23945
23946 function Reporter(options) {
23947   this._reporterState = {
23948     obj: null,
23949     path: [],
23950     options: options || {},
23951     errors: []
23952   };
23953 }
23954 exports.Reporter = Reporter;
23955
23956 Reporter.prototype.isError = function isError(obj) {
23957   return obj instanceof ReporterError;
23958 };
23959
23960 Reporter.prototype.save = function save() {
23961   var state = this._reporterState;
23962
23963   return { obj: state.obj, pathLen: state.path.length };
23964 };
23965
23966 Reporter.prototype.restore = function restore(data) {
23967   var state = this._reporterState;
23968
23969   state.obj = data.obj;
23970   state.path = state.path.slice(0, data.pathLen);
23971 };
23972
23973 Reporter.prototype.enterKey = function enterKey(key) {
23974   return this._reporterState.path.push(key);
23975 };
23976
23977 Reporter.prototype.exitKey = function exitKey(index) {
23978   var state = this._reporterState;
23979
23980   state.path = state.path.slice(0, index - 1);
23981 };
23982
23983 Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
23984   var state = this._reporterState;
23985
23986   this.exitKey(index);
23987   if (state.obj !== null)
23988     state.obj[key] = value;
23989 };
23990
23991 Reporter.prototype.path = function path() {
23992   return this._reporterState.path.join('/');
23993 };
23994
23995 Reporter.prototype.enterObject = function enterObject() {
23996   var state = this._reporterState;
23997
23998   var prev = state.obj;
23999   state.obj = {};
24000   return prev;
24001 };
24002
24003 Reporter.prototype.leaveObject = function leaveObject(prev) {
24004   var state = this._reporterState;
24005
24006   var now = state.obj;
24007   state.obj = prev;
24008   return now;
24009 };
24010
24011 Reporter.prototype.error = function error(msg) {
24012   var err;
24013   var state = this._reporterState;
24014
24015   var inherited = msg instanceof ReporterError;
24016   if (inherited) {
24017     err = msg;
24018   } else {
24019     err = new ReporterError(state.path.map(function(elem) {
24020       return '[' + JSON.stringify(elem) + ']';
24021     }).join(''), msg.message || msg, msg.stack);
24022   }
24023
24024   if (!state.options.partial)
24025     throw err;
24026
24027   if (!inherited)
24028     state.errors.push(err);
24029
24030   return err;
24031 };
24032
24033 Reporter.prototype.wrapResult = function wrapResult(result) {
24034   var state = this._reporterState;
24035   if (!state.options.partial)
24036     return result;
24037
24038   return {
24039     result: this.isError(result) ? null : result,
24040     errors: state.errors
24041   };
24042 };
24043
24044 function ReporterError(path, msg) {
24045   this.path = path;
24046   this.rethrow(msg);
24047 };
24048 inherits(ReporterError, Error);
24049
24050 ReporterError.prototype.rethrow = function rethrow(msg) {
24051   this.message = msg + ' at: ' + (this.path || '(shallow)');
24052   if (Error.captureStackTrace)
24053     Error.captureStackTrace(this, ReporterError);
24054
24055   if (!this.stack) {
24056     try {
24057       // IE only adds stack when thrown
24058       throw new Error(this.message);
24059     } catch (e) {
24060       this.stack = e.stack;
24061     }
24062   }
24063   return this;
24064 };
24065
24066
24067 /***/ }),
24068 /* 249 */
24069 /***/ (function(module, exports, __webpack_require__) {
24070
24071 var Reporter = __webpack_require__(34).Reporter;
24072 var EncoderBuffer = __webpack_require__(34).EncoderBuffer;
24073 var DecoderBuffer = __webpack_require__(34).DecoderBuffer;
24074 var assert = __webpack_require__(9);
24075
24076 // Supported tags
24077 var tags = [
24078   'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
24079   'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
24080   'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
24081   'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
24082 ];
24083
24084 // Public methods list
24085 var methods = [
24086   'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
24087   'any', 'contains'
24088 ].concat(tags);
24089
24090 // Overrided methods list
24091 var overrided = [
24092   '_peekTag', '_decodeTag', '_use',
24093   '_decodeStr', '_decodeObjid', '_decodeTime',
24094   '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
24095
24096   '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
24097   '_encodeNull', '_encodeInt', '_encodeBool'
24098 ];
24099
24100 function Node(enc, parent) {
24101   var state = {};
24102   this._baseState = state;
24103
24104   state.enc = enc;
24105
24106   state.parent = parent || null;
24107   state.children = null;
24108
24109   // State
24110   state.tag = null;
24111   state.args = null;
24112   state.reverseArgs = null;
24113   state.choice = null;
24114   state.optional = false;
24115   state.any = false;
24116   state.obj = false;
24117   state.use = null;
24118   state.useDecoder = null;
24119   state.key = null;
24120   state['default'] = null;
24121   state.explicit = null;
24122   state.implicit = null;
24123   state.contains = null;
24124
24125   // Should create new instance on each method
24126   if (!state.parent) {
24127     state.children = [];
24128     this._wrap();
24129   }
24130 }
24131 module.exports = Node;
24132
24133 var stateProps = [
24134   'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
24135   'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
24136   'implicit', 'contains'
24137 ];
24138
24139 Node.prototype.clone = function clone() {
24140   var state = this._baseState;
24141   var cstate = {};
24142   stateProps.forEach(function(prop) {
24143     cstate[prop] = state[prop];
24144   });
24145   var res = new this.constructor(cstate.parent);
24146   res._baseState = cstate;
24147   return res;
24148 };
24149
24150 Node.prototype._wrap = function wrap() {
24151   var state = this._baseState;
24152   methods.forEach(function(method) {
24153     this[method] = function _wrappedMethod() {
24154       var clone = new this.constructor(this);
24155       state.children.push(clone);
24156       return clone[method].apply(clone, arguments);
24157     };
24158   }, this);
24159 };
24160
24161 Node.prototype._init = function init(body) {
24162   var state = this._baseState;
24163
24164   assert(state.parent === null);
24165   body.call(this);
24166
24167   // Filter children
24168   state.children = state.children.filter(function(child) {
24169     return child._baseState.parent === this;
24170   }, this);
24171   assert.equal(state.children.length, 1, 'Root node can have only one child');
24172 };
24173
24174 Node.prototype._useArgs = function useArgs(args) {
24175   var state = this._baseState;
24176
24177   // Filter children and args
24178   var children = args.filter(function(arg) {
24179     return arg instanceof this.constructor;
24180   }, this);
24181   args = args.filter(function(arg) {
24182     return !(arg instanceof this.constructor);
24183   }, this);
24184
24185   if (children.length !== 0) {
24186     assert(state.children === null);
24187     state.children = children;
24188
24189     // Replace parent to maintain backward link
24190     children.forEach(function(child) {
24191       child._baseState.parent = this;
24192     }, this);
24193   }
24194   if (args.length !== 0) {
24195     assert(state.args === null);
24196     state.args = args;
24197     state.reverseArgs = args.map(function(arg) {
24198       if (typeof arg !== 'object' || arg.constructor !== Object)
24199         return arg;
24200
24201       var res = {};
24202       Object.keys(arg).forEach(function(key) {
24203         if (key == (key | 0))
24204           key |= 0;
24205         var value = arg[key];
24206         res[value] = key;
24207       });
24208       return res;
24209     });
24210   }
24211 };
24212
24213 //
24214 // Overrided methods
24215 //
24216
24217 overrided.forEach(function(method) {
24218   Node.prototype[method] = function _overrided() {
24219     var state = this._baseState;
24220     throw new Error(method + ' not implemented for encoding: ' + state.enc);
24221   };
24222 });
24223
24224 //
24225 // Public methods
24226 //
24227
24228 tags.forEach(function(tag) {
24229   Node.prototype[tag] = function _tagMethod() {
24230     var state = this._baseState;
24231     var args = Array.prototype.slice.call(arguments);
24232
24233     assert(state.tag === null);
24234     state.tag = tag;
24235
24236     this._useArgs(args);
24237
24238     return this;
24239   };
24240 });
24241
24242 Node.prototype.use = function use(item) {
24243   assert(item);
24244   var state = this._baseState;
24245
24246   assert(state.use === null);
24247   state.use = item;
24248
24249   return this;
24250 };
24251
24252 Node.prototype.optional = function optional() {
24253   var state = this._baseState;
24254
24255   state.optional = true;
24256
24257   return this;
24258 };
24259
24260 Node.prototype.def = function def(val) {
24261   var state = this._baseState;
24262
24263   assert(state['default'] === null);
24264   state['default'] = val;
24265   state.optional = true;
24266
24267   return this;
24268 };
24269
24270 Node.prototype.explicit = function explicit(num) {
24271   var state = this._baseState;
24272
24273   assert(state.explicit === null && state.implicit === null);
24274   state.explicit = num;
24275
24276   return this;
24277 };
24278
24279 Node.prototype.implicit = function implicit(num) {
24280   var state = this._baseState;
24281
24282   assert(state.explicit === null && state.implicit === null);
24283   state.implicit = num;
24284
24285   return this;
24286 };
24287
24288 Node.prototype.obj = function obj() {
24289   var state = this._baseState;
24290   var args = Array.prototype.slice.call(arguments);
24291
24292   state.obj = true;
24293
24294   if (args.length !== 0)
24295     this._useArgs(args);
24296
24297   return this;
24298 };
24299
24300 Node.prototype.key = function key(newKey) {
24301   var state = this._baseState;
24302
24303   assert(state.key === null);
24304   state.key = newKey;
24305
24306   return this;
24307 };
24308
24309 Node.prototype.any = function any() {
24310   var state = this._baseState;
24311
24312   state.any = true;
24313
24314   return this;
24315 };
24316
24317 Node.prototype.choice = function choice(obj) {
24318   var state = this._baseState;
24319
24320   assert(state.choice === null);
24321   state.choice = obj;
24322   this._useArgs(Object.keys(obj).map(function(key) {
24323     return obj[key];
24324   }));
24325
24326   return this;
24327 };
24328
24329 Node.prototype.contains = function contains(item) {
24330   var state = this._baseState;
24331
24332   assert(state.use === null);
24333   state.contains = item;
24334
24335   return this;
24336 };
24337
24338 //
24339 // Decoding
24340 //
24341
24342 Node.prototype._decode = function decode(input, options) {
24343   var state = this._baseState;
24344
24345   // Decode root node
24346   if (state.parent === null)
24347     return input.wrapResult(state.children[0]._decode(input, options));
24348
24349   var result = state['default'];
24350   var present = true;
24351
24352   var prevKey = null;
24353   if (state.key !== null)
24354     prevKey = input.enterKey(state.key);
24355
24356   // Check if tag is there
24357   if (state.optional) {
24358     var tag = null;
24359     if (state.explicit !== null)
24360       tag = state.explicit;
24361     else if (state.implicit !== null)
24362       tag = state.implicit;
24363     else if (state.tag !== null)
24364       tag = state.tag;
24365
24366     if (tag === null && !state.any) {
24367       // Trial and Error
24368       var save = input.save();
24369       try {
24370         if (state.choice === null)
24371           this._decodeGeneric(state.tag, input, options);
24372         else
24373           this._decodeChoice(input, options);
24374         present = true;
24375       } catch (e) {
24376         present = false;
24377       }
24378       input.restore(save);
24379     } else {
24380       present = this._peekTag(input, tag, state.any);
24381
24382       if (input.isError(present))
24383         return present;
24384     }
24385   }
24386
24387   // Push object on stack
24388   var prevObj;
24389   if (state.obj && present)
24390     prevObj = input.enterObject();
24391
24392   if (present) {
24393     // Unwrap explicit values
24394     if (state.explicit !== null) {
24395       var explicit = this._decodeTag(input, state.explicit);
24396       if (input.isError(explicit))
24397         return explicit;
24398       input = explicit;
24399     }
24400
24401     var start = input.offset;
24402
24403     // Unwrap implicit and normal values
24404     if (state.use === null && state.choice === null) {
24405       if (state.any)
24406         var save = input.save();
24407       var body = this._decodeTag(
24408         input,
24409         state.implicit !== null ? state.implicit : state.tag,
24410         state.any
24411       );
24412       if (input.isError(body))
24413         return body;
24414
24415       if (state.any)
24416         result = input.raw(save);
24417       else
24418         input = body;
24419     }
24420
24421     if (options && options.track && state.tag !== null)
24422       options.track(input.path(), start, input.length, 'tagged');
24423
24424     if (options && options.track && state.tag !== null)
24425       options.track(input.path(), input.offset, input.length, 'content');
24426
24427     // Select proper method for tag
24428     if (state.any)
24429       result = result;
24430     else if (state.choice === null)
24431       result = this._decodeGeneric(state.tag, input, options);
24432     else
24433       result = this._decodeChoice(input, options);
24434
24435     if (input.isError(result))
24436       return result;
24437
24438     // Decode children
24439     if (!state.any && state.choice === null && state.children !== null) {
24440       state.children.forEach(function decodeChildren(child) {
24441         // NOTE: We are ignoring errors here, to let parser continue with other
24442         // parts of encoded data
24443         child._decode(input, options);
24444       });
24445     }
24446
24447     // Decode contained/encoded by schema, only in bit or octet strings
24448     if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
24449       var data = new DecoderBuffer(result);
24450       result = this._getUse(state.contains, input._reporterState.obj)
24451           ._decode(data, options);
24452     }
24453   }
24454
24455   // Pop object
24456   if (state.obj && present)
24457     result = input.leaveObject(prevObj);
24458
24459   // Set key
24460   if (state.key !== null && (result !== null || present === true))
24461     input.leaveKey(prevKey, state.key, result);
24462   else if (prevKey !== null)
24463     input.exitKey(prevKey);
24464
24465   return result;
24466 };
24467
24468 Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
24469   var state = this._baseState;
24470
24471   if (tag === 'seq' || tag === 'set')
24472     return null;
24473   if (tag === 'seqof' || tag === 'setof')
24474     return this._decodeList(input, tag, state.args[0], options);
24475   else if (/str$/.test(tag))
24476     return this._decodeStr(input, tag, options);
24477   else if (tag === 'objid' && state.args)
24478     return this._decodeObjid(input, state.args[0], state.args[1], options);
24479   else if (tag === 'objid')
24480     return this._decodeObjid(input, null, null, options);
24481   else if (tag === 'gentime' || tag === 'utctime')
24482     return this._decodeTime(input, tag, options);
24483   else if (tag === 'null_')
24484     return this._decodeNull(input, options);
24485   else if (tag === 'bool')
24486     return this._decodeBool(input, options);
24487   else if (tag === 'objDesc')
24488     return this._decodeStr(input, tag, options);
24489   else if (tag === 'int' || tag === 'enum')
24490     return this._decodeInt(input, state.args && state.args[0], options);
24491
24492   if (state.use !== null) {
24493     return this._getUse(state.use, input._reporterState.obj)
24494         ._decode(input, options);
24495   } else {
24496     return input.error('unknown tag: ' + tag);
24497   }
24498 };
24499
24500 Node.prototype._getUse = function _getUse(entity, obj) {
24501
24502   var state = this._baseState;
24503   // Create altered use decoder if implicit is set
24504   state.useDecoder = this._use(entity, obj);
24505   assert(state.useDecoder._baseState.parent === null);
24506   state.useDecoder = state.useDecoder._baseState.children[0];
24507   if (state.implicit !== state.useDecoder._baseState.implicit) {
24508     state.useDecoder = state.useDecoder.clone();
24509     state.useDecoder._baseState.implicit = state.implicit;
24510   }
24511   return state.useDecoder;
24512 };
24513
24514 Node.prototype._decodeChoice = function decodeChoice(input, options) {
24515   var state = this._baseState;
24516   var result = null;
24517   var match = false;
24518
24519   Object.keys(state.choice).some(function(key) {
24520     var save = input.save();
24521     var node = state.choice[key];
24522     try {
24523       var value = node._decode(input, options);
24524       if (input.isError(value))
24525         return false;
24526
24527       result = { type: key, value: value };
24528       match = true;
24529     } catch (e) {
24530       input.restore(save);
24531       return false;
24532     }
24533     return true;
24534   }, this);
24535
24536   if (!match)
24537     return input.error('Choice not matched');
24538
24539   return result;
24540 };
24541
24542 //
24543 // Encoding
24544 //
24545
24546 Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
24547   return new EncoderBuffer(data, this.reporter);
24548 };
24549
24550 Node.prototype._encode = function encode(data, reporter, parent) {
24551   var state = this._baseState;
24552   if (state['default'] !== null && state['default'] === data)
24553     return;
24554
24555   var result = this._encodeValue(data, reporter, parent);
24556   if (result === undefined)
24557     return;
24558
24559   if (this._skipDefault(result, reporter, parent))
24560     return;
24561
24562   return result;
24563 };
24564
24565 Node.prototype._encodeValue = function encode(data, reporter, parent) {
24566   var state = this._baseState;
24567
24568   // Decode root node
24569   if (state.parent === null)
24570     return state.children[0]._encode(data, reporter || new Reporter());
24571
24572   var result = null;
24573
24574   // Set reporter to share it with a child class
24575   this.reporter = reporter;
24576
24577   // Check if data is there
24578   if (state.optional && data === undefined) {
24579     if (state['default'] !== null)
24580       data = state['default']
24581     else
24582       return;
24583   }
24584
24585   // Encode children first
24586   var content = null;
24587   var primitive = false;
24588   if (state.any) {
24589     // Anything that was given is translated to buffer
24590     result = this._createEncoderBuffer(data);
24591   } else if (state.choice) {
24592     result = this._encodeChoice(data, reporter);
24593   } else if (state.contains) {
24594     content = this._getUse(state.contains, parent)._encode(data, reporter);
24595     primitive = true;
24596   } else if (state.children) {
24597     content = state.children.map(function(child) {
24598       if (child._baseState.tag === 'null_')
24599         return child._encode(null, reporter, data);
24600
24601       if (child._baseState.key === null)
24602         return reporter.error('Child should have a key');
24603       var prevKey = reporter.enterKey(child._baseState.key);
24604
24605       if (typeof data !== 'object')
24606         return reporter.error('Child expected, but input is not object');
24607
24608       var res = child._encode(data[child._baseState.key], reporter, data);
24609       reporter.leaveKey(prevKey);
24610
24611       return res;
24612     }, this).filter(function(child) {
24613       return child;
24614     });
24615     content = this._createEncoderBuffer(content);
24616   } else {
24617     if (state.tag === 'seqof' || state.tag === 'setof') {
24618       // TODO(indutny): this should be thrown on DSL level
24619       if (!(state.args && state.args.length === 1))
24620         return reporter.error('Too many args for : ' + state.tag);
24621
24622       if (!Array.isArray(data))
24623         return reporter.error('seqof/setof, but data is not Array');
24624
24625       var child = this.clone();
24626       child._baseState.implicit = null;
24627       content = this._createEncoderBuffer(data.map(function(item) {
24628         var state = this._baseState;
24629
24630         return this._getUse(state.args[0], data)._encode(item, reporter);
24631       }, child));
24632     } else if (state.use !== null) {
24633       result = this._getUse(state.use, parent)._encode(data, reporter);
24634     } else {
24635       content = this._encodePrimitive(state.tag, data);
24636       primitive = true;
24637     }
24638   }
24639
24640   // Encode data itself
24641   var result;
24642   if (!state.any && state.choice === null) {
24643     var tag = state.implicit !== null ? state.implicit : state.tag;
24644     var cls = state.implicit === null ? 'universal' : 'context';
24645
24646     if (tag === null) {
24647       if (state.use === null)
24648         reporter.error('Tag could be omitted only for .use()');
24649     } else {
24650       if (state.use === null)
24651         result = this._encodeComposite(tag, primitive, cls, content);
24652     }
24653   }
24654
24655   // Wrap in explicit
24656   if (state.explicit !== null)
24657     result = this._encodeComposite(state.explicit, false, 'context', result);
24658
24659   return result;
24660 };
24661
24662 Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
24663   var state = this._baseState;
24664
24665   var node = state.choice[data.type];
24666   if (!node) {
24667     assert(
24668         false,
24669         data.type + ' not found in ' +
24670             JSON.stringify(Object.keys(state.choice)));
24671   }
24672   return node._encode(data.value, reporter);
24673 };
24674
24675 Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
24676   var state = this._baseState;
24677
24678   if (/str$/.test(tag))
24679     return this._encodeStr(data, tag);
24680   else if (tag === 'objid' && state.args)
24681     return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
24682   else if (tag === 'objid')
24683     return this._encodeObjid(data, null, null);
24684   else if (tag === 'gentime' || tag === 'utctime')
24685     return this._encodeTime(data, tag);
24686   else if (tag === 'null_')
24687     return this._encodeNull();
24688   else if (tag === 'int' || tag === 'enum')
24689     return this._encodeInt(data, state.args && state.reverseArgs[0]);
24690   else if (tag === 'bool')
24691     return this._encodeBool(data);
24692   else if (tag === 'objDesc')
24693     return this._encodeStr(data, tag);
24694   else
24695     throw new Error('Unsupported tag: ' + tag);
24696 };
24697
24698 Node.prototype._isNumstr = function isNumstr(str) {
24699   return /^[0-9 ]*$/.test(str);
24700 };
24701
24702 Node.prototype._isPrintstr = function isPrintstr(str) {
24703   return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
24704 };
24705
24706
24707 /***/ }),
24708 /* 250 */
24709 /***/ (function(module, exports, __webpack_require__) {
24710
24711 var constants = __webpack_require__(121);
24712
24713 exports.tagClass = {
24714   0: 'universal',
24715   1: 'application',
24716   2: 'context',
24717   3: 'private'
24718 };
24719 exports.tagClassByName = constants._reverse(exports.tagClass);
24720
24721 exports.tag = {
24722   0x00: 'end',
24723   0x01: 'bool',
24724   0x02: 'int',
24725   0x03: 'bitstr',
24726   0x04: 'octstr',
24727   0x05: 'null_',
24728   0x06: 'objid',
24729   0x07: 'objDesc',
24730   0x08: 'external',
24731   0x09: 'real',
24732   0x0a: 'enum',
24733   0x0b: 'embed',
24734   0x0c: 'utf8str',
24735   0x0d: 'relativeOid',
24736   0x10: 'seq',
24737   0x11: 'set',
24738   0x12: 'numstr',
24739   0x13: 'printstr',
24740   0x14: 't61str',
24741   0x15: 'videostr',
24742   0x16: 'ia5str',
24743   0x17: 'utctime',
24744   0x18: 'gentime',
24745   0x19: 'graphstr',
24746   0x1a: 'iso646str',
24747   0x1b: 'genstr',
24748   0x1c: 'unistr',
24749   0x1d: 'charstr',
24750   0x1e: 'bmpstr'
24751 };
24752 exports.tagByName = constants._reverse(exports.tag);
24753
24754
24755 /***/ }),
24756 /* 251 */
24757 /***/ (function(module, exports, __webpack_require__) {
24758
24759 var decoders = exports;
24760
24761 decoders.der = __webpack_require__(122);
24762 decoders.pem = __webpack_require__(252);
24763
24764
24765 /***/ }),
24766 /* 252 */
24767 /***/ (function(module, exports, __webpack_require__) {
24768
24769 var inherits = __webpack_require__(1);
24770 var Buffer = __webpack_require__(3).Buffer;
24771
24772 var DERDecoder = __webpack_require__(122);
24773
24774 function PEMDecoder(entity) {
24775   DERDecoder.call(this, entity);
24776   this.enc = 'pem';
24777 };
24778 inherits(PEMDecoder, DERDecoder);
24779 module.exports = PEMDecoder;
24780
24781 PEMDecoder.prototype.decode = function decode(data, options) {
24782   var lines = data.toString().split(/[\r\n]+/g);
24783
24784   var label = options.label.toUpperCase();
24785
24786   var re = /^-----(BEGIN|END) ([^-]+)-----$/;
24787   var start = -1;
24788   var end = -1;
24789   for (var i = 0; i < lines.length; i++) {
24790     var match = lines[i].match(re);
24791     if (match === null)
24792       continue;
24793
24794     if (match[2] !== label)
24795       continue;
24796
24797     if (start === -1) {
24798       if (match[1] !== 'BEGIN')
24799         break;
24800       start = i;
24801     } else {
24802       if (match[1] !== 'END')
24803         break;
24804       end = i;
24805       break;
24806     }
24807   }
24808   if (start === -1 || end === -1)
24809     throw new Error('PEM section not found for: ' + label);
24810
24811   var base64 = lines.slice(start + 1, end).join('');
24812   // Remove excessive symbols
24813   base64.replace(/[^a-z0-9\+\/=]+/gi, '');
24814
24815   var input = new Buffer(base64, 'base64');
24816   return DERDecoder.prototype.decode.call(this, input, options);
24817 };
24818
24819
24820 /***/ }),
24821 /* 253 */
24822 /***/ (function(module, exports, __webpack_require__) {
24823
24824 var encoders = exports;
24825
24826 encoders.der = __webpack_require__(123);
24827 encoders.pem = __webpack_require__(254);
24828
24829
24830 /***/ }),
24831 /* 254 */
24832 /***/ (function(module, exports, __webpack_require__) {
24833
24834 var inherits = __webpack_require__(1);
24835
24836 var DEREncoder = __webpack_require__(123);
24837
24838 function PEMEncoder(entity) {
24839   DEREncoder.call(this, entity);
24840   this.enc = 'pem';
24841 };
24842 inherits(PEMEncoder, DEREncoder);
24843 module.exports = PEMEncoder;
24844
24845 PEMEncoder.prototype.encode = function encode(data, options) {
24846   var buf = DEREncoder.prototype.encode.call(this, data);
24847
24848   var p = buf.toString('base64');
24849   var out = [ '-----BEGIN ' + options.label + '-----' ];
24850   for (var i = 0; i < p.length; i += 64)
24851     out.push(p.slice(i, i + 64));
24852   out.push('-----END ' + options.label + '-----');
24853   return out.join('\n');
24854 };
24855
24856
24857 /***/ }),
24858 /* 255 */
24859 /***/ (function(module, exports, __webpack_require__) {
24860
24861 "use strict";
24862 // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
24863 // thanks to @Rantanen
24864
24865
24866
24867 var asn = __webpack_require__(33)
24868
24869 var Time = asn.define('Time', function () {
24870   this.choice({
24871     utcTime: this.utctime(),
24872     generalTime: this.gentime()
24873   })
24874 })
24875
24876 var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
24877   this.seq().obj(
24878     this.key('type').objid(),
24879     this.key('value').any()
24880   )
24881 })
24882
24883 var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
24884   this.seq().obj(
24885     this.key('algorithm').objid(),
24886     this.key('parameters').optional()
24887   )
24888 })
24889
24890 var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
24891   this.seq().obj(
24892     this.key('algorithm').use(AlgorithmIdentifier),
24893     this.key('subjectPublicKey').bitstr()
24894   )
24895 })
24896
24897 var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
24898   this.setof(AttributeTypeValue)
24899 })
24900
24901 var RDNSequence = asn.define('RDNSequence', function () {
24902   this.seqof(RelativeDistinguishedName)
24903 })
24904
24905 var Name = asn.define('Name', function () {
24906   this.choice({
24907     rdnSequence: this.use(RDNSequence)
24908   })
24909 })
24910
24911 var Validity = asn.define('Validity', function () {
24912   this.seq().obj(
24913     this.key('notBefore').use(Time),
24914     this.key('notAfter').use(Time)
24915   )
24916 })
24917
24918 var Extension = asn.define('Extension', function () {
24919   this.seq().obj(
24920     this.key('extnID').objid(),
24921     this.key('critical').bool().def(false),
24922     this.key('extnValue').octstr()
24923   )
24924 })
24925
24926 var TBSCertificate = asn.define('TBSCertificate', function () {
24927   this.seq().obj(
24928     this.key('version').explicit(0).int(),
24929     this.key('serialNumber').int(),
24930     this.key('signature').use(AlgorithmIdentifier),
24931     this.key('issuer').use(Name),
24932     this.key('validity').use(Validity),
24933     this.key('subject').use(Name),
24934     this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
24935     this.key('issuerUniqueID').implicit(1).bitstr().optional(),
24936     this.key('subjectUniqueID').implicit(2).bitstr().optional(),
24937     this.key('extensions').explicit(3).seqof(Extension).optional()
24938   )
24939 })
24940
24941 var X509Certificate = asn.define('X509Certificate', function () {
24942   this.seq().obj(
24943     this.key('tbsCertificate').use(TBSCertificate),
24944     this.key('signatureAlgorithm').use(AlgorithmIdentifier),
24945     this.key('signatureValue').bitstr()
24946   )
24947 })
24948
24949 module.exports = X509Certificate
24950
24951
24952 /***/ }),
24953 /* 256 */
24954 /***/ (function(module, exports) {
24955
24956 module.exports = {"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}
24957
24958 /***/ }),
24959 /* 257 */
24960 /***/ (function(module, exports, __webpack_require__) {
24961
24962 /* WEBPACK VAR INJECTION */(function(Buffer) {// adapted from https://github.com/apatil/pemstrip
24963 var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m
24964 var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m
24965 var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m
24966 var evp = __webpack_require__(44)
24967 var ciphers = __webpack_require__(65)
24968 module.exports = function (okey, password) {
24969   var key = okey.toString()
24970   var match = key.match(findProc)
24971   var decrypted
24972   if (!match) {
24973     var match2 = key.match(fullRegex)
24974     decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64')
24975   } else {
24976     var suite = 'aes' + match[1]
24977     var iv = new Buffer(match[2], 'hex')
24978     var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64')
24979     var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
24980     var out = []
24981     var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
24982     out.push(cipher.update(cipherText))
24983     out.push(cipher.final())
24984     decrypted = Buffer.concat(out)
24985   }
24986   var tag = key.match(startRegex)[1]
24987   return {
24988     tag: tag,
24989     data: decrypted
24990   }
24991 }
24992
24993 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
24994
24995 /***/ }),
24996 /* 258 */
24997 /***/ (function(module, exports, __webpack_require__) {
24998
24999 /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
25000 var BN = __webpack_require__(4)
25001 var EC = __webpack_require__(6).ec
25002 var parseKeys = __webpack_require__(46)
25003 var curves = __webpack_require__(124)
25004
25005 function verify (sig, hash, key, signType, tag) {
25006   var pub = parseKeys(key)
25007   if (pub.type === 'ec') {
25008     // rsa keys can be interpreted as ecdsa ones in openssl
25009     if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
25010     return ecVerify(sig, hash, pub)
25011   } else if (pub.type === 'dsa') {
25012     if (signType !== 'dsa') throw new Error('wrong public key type')
25013     return dsaVerify(sig, hash, pub)
25014   } else {
25015     if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
25016   }
25017   hash = Buffer.concat([tag, hash])
25018   var len = pub.modulus.byteLength()
25019   var pad = [ 1 ]
25020   var padNum = 0
25021   while (hash.length + pad.length + 2 < len) {
25022     pad.push(0xff)
25023     padNum++
25024   }
25025   pad.push(0x00)
25026   var i = -1
25027   while (++i < hash.length) {
25028     pad.push(hash[i])
25029   }
25030   pad = new Buffer(pad)
25031   var red = BN.mont(pub.modulus)
25032   sig = new BN(sig).toRed(red)
25033
25034   sig = sig.redPow(new BN(pub.publicExponent))
25035   sig = new Buffer(sig.fromRed().toArray())
25036   var out = padNum < 8 ? 1 : 0
25037   len = Math.min(sig.length, pad.length)
25038   if (sig.length !== pad.length) out = 1
25039
25040   i = -1
25041   while (++i < len) out |= sig[i] ^ pad[i]
25042   return out === 0
25043 }
25044
25045 function ecVerify (sig, hash, pub) {
25046   var curveId = curves[pub.data.algorithm.curve.join('.')]
25047   if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
25048
25049   var curve = new EC(curveId)
25050   var pubkey = pub.data.subjectPrivateKey.data
25051
25052   return curve.verify(hash, sig, pubkey)
25053 }
25054
25055 function dsaVerify (sig, hash, pub) {
25056   var p = pub.data.p
25057   var q = pub.data.q
25058   var g = pub.data.g
25059   var y = pub.data.pub_key
25060   var unpacked = parseKeys.signature.decode(sig, 'der')
25061   var s = unpacked.s
25062   var r = unpacked.r
25063   checkValue(s, q)
25064   checkValue(r, q)
25065   var montp = BN.mont(p)
25066   var w = s.invm(q)
25067   var v = g.toRed(montp)
25068     .redPow(new BN(hash).mul(w).mod(q))
25069     .fromRed()
25070     .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
25071     .mod(p)
25072     .mod(q)
25073   return v.cmp(r) === 0
25074 }
25075
25076 function checkValue (b, q) {
25077   if (b.cmpn(0) <= 0) throw new Error('invalid sig')
25078   if (b.cmp(q) >= q) throw new Error('invalid sig')
25079 }
25080
25081 module.exports = verify
25082
25083 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25084
25085 /***/ }),
25086 /* 259 */
25087 /***/ (function(module, exports, __webpack_require__) {
25088
25089 /* WEBPACK VAR INJECTION */(function(Buffer) {var elliptic = __webpack_require__(6)
25090 var BN = __webpack_require__(4)
25091
25092 module.exports = function createECDH (curve) {
25093   return new ECDH(curve)
25094 }
25095
25096 var aliases = {
25097   secp256k1: {
25098     name: 'secp256k1',
25099     byteLength: 32
25100   },
25101   secp224r1: {
25102     name: 'p224',
25103     byteLength: 28
25104   },
25105   prime256v1: {
25106     name: 'p256',
25107     byteLength: 32
25108   },
25109   prime192v1: {
25110     name: 'p192',
25111     byteLength: 24
25112   },
25113   ed25519: {
25114     name: 'ed25519',
25115     byteLength: 32
25116   },
25117   secp384r1: {
25118     name: 'p384',
25119     byteLength: 48
25120   },
25121   secp521r1: {
25122     name: 'p521',
25123     byteLength: 66
25124   }
25125 }
25126
25127 aliases.p224 = aliases.secp224r1
25128 aliases.p256 = aliases.secp256r1 = aliases.prime256v1
25129 aliases.p192 = aliases.secp192r1 = aliases.prime192v1
25130 aliases.p384 = aliases.secp384r1
25131 aliases.p521 = aliases.secp521r1
25132
25133 function ECDH (curve) {
25134   this.curveType = aliases[curve]
25135   if (!this.curveType) {
25136     this.curveType = {
25137       name: curve
25138     }
25139   }
25140   this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
25141   this.keys = void 0
25142 }
25143
25144 ECDH.prototype.generateKeys = function (enc, format) {
25145   this.keys = this.curve.genKeyPair()
25146   return this.getPublicKey(enc, format)
25147 }
25148
25149 ECDH.prototype.computeSecret = function (other, inenc, enc) {
25150   inenc = inenc || 'utf8'
25151   if (!Buffer.isBuffer(other)) {
25152     other = new Buffer(other, inenc)
25153   }
25154   var otherPub = this.curve.keyFromPublic(other).getPublic()
25155   var out = otherPub.mul(this.keys.getPrivate()).getX()
25156   return formatReturnValue(out, enc, this.curveType.byteLength)
25157 }
25158
25159 ECDH.prototype.getPublicKey = function (enc, format) {
25160   var key = this.keys.getPublic(format === 'compressed', true)
25161   if (format === 'hybrid') {
25162     if (key[key.length - 1] % 2) {
25163       key[0] = 7
25164     } else {
25165       key[0] = 6
25166     }
25167   }
25168   return formatReturnValue(key, enc)
25169 }
25170
25171 ECDH.prototype.getPrivateKey = function (enc) {
25172   return formatReturnValue(this.keys.getPrivate(), enc)
25173 }
25174
25175 ECDH.prototype.setPublicKey = function (pub, enc) {
25176   enc = enc || 'utf8'
25177   if (!Buffer.isBuffer(pub)) {
25178     pub = new Buffer(pub, enc)
25179   }
25180   this.keys._importPublic(pub)
25181   return this
25182 }
25183
25184 ECDH.prototype.setPrivateKey = function (priv, enc) {
25185   enc = enc || 'utf8'
25186   if (!Buffer.isBuffer(priv)) {
25187     priv = new Buffer(priv, enc)
25188   }
25189
25190   var _priv = new BN(priv)
25191   _priv = _priv.toString(16)
25192   this.keys = this.curve.genKeyPair()
25193   this.keys._importPrivate(_priv)
25194   return this
25195 }
25196
25197 function formatReturnValue (bn, enc, len) {
25198   if (!Array.isArray(bn)) {
25199     bn = bn.toArray()
25200   }
25201   var buf = new Buffer(bn)
25202   if (len && buf.length < len) {
25203     var zeros = new Buffer(len - buf.length)
25204     zeros.fill(0)
25205     buf = Buffer.concat([zeros, buf])
25206   }
25207   if (!enc) {
25208     return buf
25209   } else {
25210     return buf.toString(enc)
25211   }
25212 }
25213
25214 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25215
25216 /***/ }),
25217 /* 260 */
25218 /***/ (function(module, exports, __webpack_require__) {
25219
25220 exports.publicEncrypt = __webpack_require__(261);
25221 exports.privateDecrypt = __webpack_require__(262);
25222
25223 exports.privateEncrypt = function privateEncrypt(key, buf) {
25224   return exports.publicEncrypt(key, buf, true);
25225 };
25226
25227 exports.publicDecrypt = function publicDecrypt(key, buf) {
25228   return exports.privateDecrypt(key, buf, true);
25229 };
25230
25231 /***/ }),
25232 /* 261 */
25233 /***/ (function(module, exports, __webpack_require__) {
25234
25235 /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(46);
25236 var randomBytes = __webpack_require__(23);
25237 var createHash = __webpack_require__(29);
25238 var mgf = __webpack_require__(125);
25239 var xor = __webpack_require__(126);
25240 var bn = __webpack_require__(4);
25241 var withPublic = __webpack_require__(127);
25242 var crt = __webpack_require__(67);
25243
25244 var constants = {
25245   RSA_PKCS1_OAEP_PADDING: 4,
25246   RSA_PKCS1_PADDIN: 1,
25247   RSA_NO_PADDING: 3
25248 };
25249
25250 module.exports = function publicEncrypt(public_key, msg, reverse) {
25251   var padding;
25252   if (public_key.padding) {
25253     padding = public_key.padding;
25254   } else if (reverse) {
25255     padding = 1;
25256   } else {
25257     padding = 4;
25258   }
25259   var key = parseKeys(public_key);
25260   var paddedMsg;
25261   if (padding === 4) {
25262     paddedMsg = oaep(key, msg);
25263   } else if (padding === 1) {
25264     paddedMsg = pkcs1(key, msg, reverse);
25265   } else if (padding === 3) {
25266     paddedMsg = new bn(msg);
25267     if (paddedMsg.cmp(key.modulus) >= 0) {
25268       throw new Error('data too long for modulus');
25269     }
25270   } else {
25271     throw new Error('unknown padding');
25272   }
25273   if (reverse) {
25274     return crt(paddedMsg, key);
25275   } else {
25276     return withPublic(paddedMsg, key);
25277   }
25278 };
25279
25280 function oaep(key, msg){
25281   var k = key.modulus.byteLength();
25282   var mLen = msg.length;
25283   var iHash = createHash('sha1').update(new Buffer('')).digest();
25284   var hLen = iHash.length;
25285   var hLen2 = 2 * hLen;
25286   if (mLen > k - hLen2 - 2) {
25287     throw new Error('message too long');
25288   }
25289   var ps = new Buffer(k - mLen - hLen2 - 2);
25290   ps.fill(0);
25291   var dblen = k - hLen - 1;
25292   var seed = randomBytes(hLen);
25293   var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen));
25294   var maskedSeed = xor(seed, mgf(maskedDb, hLen));
25295   return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k));
25296 }
25297 function pkcs1(key, msg, reverse){
25298   var mLen = msg.length;
25299   var k = key.modulus.byteLength();
25300   if (mLen > k - 11) {
25301     throw new Error('message too long');
25302   }
25303   var ps;
25304   if (reverse) {
25305     ps = new Buffer(k - mLen - 3);
25306     ps.fill(0xff);
25307   } else {
25308     ps = nonZero(k - mLen - 3);
25309   }
25310   return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k));
25311 }
25312 function nonZero(len, crypto) {
25313   var out = new Buffer(len);
25314   var i = 0;
25315   var cache = randomBytes(len*2);
25316   var cur = 0;
25317   var num;
25318   while (i < len) {
25319     if (cur === cache.length) {
25320       cache = randomBytes(len*2);
25321       cur = 0;
25322     }
25323     num = cache[cur++];
25324     if (num) {
25325       out[i++] = num;
25326     }
25327   }
25328   return out;
25329 }
25330 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25331
25332 /***/ }),
25333 /* 262 */
25334 /***/ (function(module, exports, __webpack_require__) {
25335
25336 /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(46);
25337 var mgf = __webpack_require__(125);
25338 var xor = __webpack_require__(126);
25339 var bn = __webpack_require__(4);
25340 var crt = __webpack_require__(67);
25341 var createHash = __webpack_require__(29);
25342 var withPublic = __webpack_require__(127);
25343 module.exports = function privateDecrypt(private_key, enc, reverse) {
25344   var padding;
25345   if (private_key.padding) {
25346     padding = private_key.padding;
25347   } else if (reverse) {
25348     padding = 1;
25349   } else {
25350     padding = 4;
25351   }
25352   
25353   var key = parseKeys(private_key);
25354   var k = key.modulus.byteLength();
25355   if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
25356     throw new Error('decryption error');
25357   }
25358   var msg;
25359   if (reverse) {
25360     msg = withPublic(new bn(enc), key);
25361   } else {
25362     msg = crt(enc, key);
25363   }
25364   var zBuffer = new Buffer(k - msg.length);
25365   zBuffer.fill(0);
25366   msg = Buffer.concat([zBuffer, msg], k);
25367   if (padding === 4) {
25368     return oaep(key, msg);
25369   } else if (padding === 1) {
25370     return pkcs1(key, msg, reverse);
25371   } else if (padding === 3) {
25372     return msg;
25373   } else {
25374     throw new Error('unknown padding');
25375   }
25376 };
25377
25378 function oaep(key, msg){
25379   var n = key.modulus;
25380   var k = key.modulus.byteLength();
25381   var mLen = msg.length;
25382   var iHash = createHash('sha1').update(new Buffer('')).digest();
25383   var hLen = iHash.length;
25384   var hLen2 = 2 * hLen;
25385   if (msg[0] !== 0) {
25386     throw new Error('decryption error');
25387   }
25388   var maskedSeed = msg.slice(1, hLen + 1);
25389   var maskedDb =  msg.slice(hLen + 1);
25390   var seed = xor(maskedSeed, mgf(maskedDb, hLen));
25391   var db = xor(maskedDb, mgf(seed, k - hLen - 1));
25392   if (compare(iHash, db.slice(0, hLen))) {
25393     throw new Error('decryption error');
25394   }
25395   var i = hLen;
25396   while (db[i] === 0) {
25397     i++;
25398   }
25399   if (db[i++] !== 1) {
25400     throw new Error('decryption error');
25401   }
25402   return db.slice(i);
25403 }
25404
25405 function pkcs1(key, msg, reverse){
25406   var p1 = msg.slice(0, 2);
25407   var i = 2;
25408   var status = 0;
25409   while (msg[i++] !== 0) {
25410     if (i >= msg.length) {
25411       status++;
25412       break;
25413     }
25414   }
25415   var ps = msg.slice(2, i - 1);
25416   var p2 = msg.slice(i - 1, i);
25417
25418   if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){
25419     status++;
25420   }
25421   if (ps.length < 8) {
25422     status++;
25423   }
25424   if (status) {
25425     throw new Error('decryption error');
25426   }
25427   return  msg.slice(i);
25428 }
25429 function compare(a, b){
25430   a = new Buffer(a);
25431   b = new Buffer(b);
25432   var dif = 0;
25433   var len = a.length;
25434   if (a.length !== b.length) {
25435     dif++;
25436     len = Math.min(a.length, b.length);
25437   }
25438   var i = -1;
25439   while (++i < len) {
25440     dif += (a[i] ^ b[i]);
25441   }
25442   return dif;
25443 }
25444 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25445
25446 /***/ }),
25447 /* 263 */
25448 /***/ (function(module, exports, __webpack_require__) {
25449
25450 "use strict";
25451 /* WEBPACK VAR INJECTION */(function(global, process) {
25452
25453 function oldBrowser () {
25454   throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
25455 }
25456 var safeBuffer = __webpack_require__(2)
25457 var randombytes = __webpack_require__(23)
25458 var Buffer = safeBuffer.Buffer
25459 var kBufferMaxLength = safeBuffer.kMaxLength
25460 var crypto = global.crypto || global.msCrypto
25461 var kMaxUint32 = Math.pow(2, 32) - 1
25462 function assertOffset (offset, length) {
25463   if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
25464     throw new TypeError('offset must be a number')
25465   }
25466
25467   if (offset > kMaxUint32 || offset < 0) {
25468     throw new TypeError('offset must be a uint32')
25469   }
25470
25471   if (offset > kBufferMaxLength || offset > length) {
25472     throw new RangeError('offset out of range')
25473   }
25474 }
25475
25476 function assertSize (size, offset, length) {
25477   if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
25478     throw new TypeError('size must be a number')
25479   }
25480
25481   if (size > kMaxUint32 || size < 0) {
25482     throw new TypeError('size must be a uint32')
25483   }
25484
25485   if (size + offset > length || size > kBufferMaxLength) {
25486     throw new RangeError('buffer too small')
25487   }
25488 }
25489 if ((crypto && crypto.getRandomValues) || !process.browser) {
25490   exports.randomFill = randomFill
25491   exports.randomFillSync = randomFillSync
25492 } else {
25493   exports.randomFill = oldBrowser
25494   exports.randomFillSync = oldBrowser
25495 }
25496 function randomFill (buf, offset, size, cb) {
25497   if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
25498     throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25499   }
25500
25501   if (typeof offset === 'function') {
25502     cb = offset
25503     offset = 0
25504     size = buf.length
25505   } else if (typeof size === 'function') {
25506     cb = size
25507     size = buf.length - offset
25508   } else if (typeof cb !== 'function') {
25509     throw new TypeError('"cb" argument must be a function')
25510   }
25511   assertOffset(offset, buf.length)
25512   assertSize(size, offset, buf.length)
25513   return actualFill(buf, offset, size, cb)
25514 }
25515
25516 function actualFill (buf, offset, size, cb) {
25517   if (process.browser) {
25518     var ourBuf = buf.buffer
25519     var uint = new Uint8Array(ourBuf, offset, size)
25520     crypto.getRandomValues(uint)
25521     if (cb) {
25522       process.nextTick(function () {
25523         cb(null, buf)
25524       })
25525       return
25526     }
25527     return buf
25528   }
25529   if (cb) {
25530     randombytes(size, function (err, bytes) {
25531       if (err) {
25532         return cb(err)
25533       }
25534       bytes.copy(buf, offset)
25535       cb(null, buf)
25536     })
25537     return
25538   }
25539   var bytes = randombytes(size)
25540   bytes.copy(buf, offset)
25541   return buf
25542 }
25543 function randomFillSync (buf, offset, size) {
25544   if (typeof offset === 'undefined') {
25545     offset = 0
25546   }
25547   if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
25548     throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25549   }
25550
25551   assertOffset(offset, buf.length)
25552
25553   if (size === undefined) size = buf.length - offset
25554
25555   assertSize(size, offset, buf.length)
25556
25557   return actualFill(buf, offset, size)
25558 }
25559
25560 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
25561
25562 /***/ }),
25563 /* 264 */
25564 /***/ (function(module, exports, __webpack_require__) {
25565
25566 "use strict";
25567 \r
25568 Object.defineProperty(exports, "__esModule", { value: true });\r
25569 class LocalStream {\r
25570     static send(msg) {\r
25571         return new Promise((resolve, reject) => {\r
25572             chrome.runtime.sendMessage(msg, (response) => resolve(response));\r
25573         });\r
25574     }\r
25575     static watch(callback) {\r
25576         chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {\r
25577             if (sender.id !== chrome.runtime.id)\r
25578                 return;\r
25579             callback(request, sendResponse);\r
25580             return true;\r
25581         });\r
25582     }\r
25583 }\r
25584 exports.LocalStream = LocalStream;\r
25585 exports.default = LocalStream;\r
25586 //# sourceMappingURL=LocalStream.js.map
25587
25588 /***/ }),
25589 /* 265 */,
25590 /* 266 */,
25591 /* 267 */
25592 /***/ (function(module, __webpack_exports__, __webpack_require__) {
25593
25594 "use strict";
25595 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__ = __webpack_require__(69);
25596 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__);
25597 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
25598 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
25599 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__ = __webpack_require__(36);
25600 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__);
25601 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_extension_streams__ = __webpack_require__(137);
25602 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_extension_streams___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_extension_streams__);
25603
25604
25605
25606
25607
25608 var InternalMessage = function () {
25609   function InternalMessage() {
25610     __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, InternalMessage);
25611
25612     this.type = '';
25613     this.payload = '';
25614   }
25615
25616   __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(InternalMessage, [{
25617     key: 'send',
25618     value: function send() {
25619       return __WEBPACK_IMPORTED_MODULE_3_extension_streams__["LocalStream"].send(this);
25620     }
25621   }], [{
25622     key: 'initMessage',
25623     value: function initMessage() {
25624       return new InternalMessage();
25625     }
25626   }, {
25627     key: 'fromJson',
25628     value: function fromJson(json) {
25629       return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default()(this.initMessage(), json);
25630     }
25631   }, {
25632     key: 'payload',
25633     value: function payload(type, _payload) {
25634       var p = this.initMessage();
25635       p.type = type;
25636       p.payload = _payload;
25637       return p;
25638     }
25639   }, {
25640     key: 'signal',
25641     value: function signal(type) {
25642       var p = this.initMessage();
25643       p.type = type;
25644       return p;
25645     }
25646   }]);
25647
25648   return InternalMessage;
25649 }();
25650
25651 /* harmony default export */ __webpack_exports__["a"] = (InternalMessage);
25652
25653 /***/ }),
25654 /* 268 */,
25655 /* 269 */,
25656 /* 270 */,
25657 /* 271 */,
25658 /* 272 */,
25659 /* 273 */,
25660 /* 274 */,
25661 /* 275 */,
25662 /* 276 */,
25663 /* 277 */,
25664 /* 278 */,
25665 /* 279 */,
25666 /* 280 */,
25667 /* 281 */,
25668 /* 282 */
25669 /***/ (function(module, exports, __webpack_require__) {
25670
25671 // 0 -> Array#forEach
25672 // 1 -> Array#map
25673 // 2 -> Array#filter
25674 // 3 -> Array#some
25675 // 4 -> Array#every
25676 // 5 -> Array#find
25677 // 6 -> Array#findIndex
25678 var ctx = __webpack_require__(35);
25679 var IObject = __webpack_require__(74);
25680 var toObject = __webpack_require__(54);
25681 var toLength = __webpack_require__(75);
25682 var asc = __webpack_require__(520);
25683 module.exports = function (TYPE, $create) {
25684   var IS_MAP = TYPE == 1;
25685   var IS_FILTER = TYPE == 2;
25686   var IS_SOME = TYPE == 3;
25687   var IS_EVERY = TYPE == 4;
25688   var IS_FIND_INDEX = TYPE == 6;
25689   var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
25690   var create = $create || asc;
25691   return function ($this, callbackfn, that) {
25692     var O = toObject($this);
25693     var self = IObject(O);
25694     var f = ctx(callbackfn, that, 3);
25695     var length = toLength(self.length);
25696     var index = 0;
25697     var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
25698     var val, res;
25699     for (;length > index; index++) if (NO_HOLES || index in self) {
25700       val = self[index];
25701       res = f(val, index, O);
25702       if (TYPE) {
25703         if (IS_MAP) result[index] = res;   // map
25704         else if (res) switch (TYPE) {
25705           case 3: return true;             // some
25706           case 5: return val;              // find
25707           case 6: return index;            // findIndex
25708           case 2: result.push(val);        // filter
25709         } else if (IS_EVERY) return false; // every
25710       }
25711     }
25712     return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
25713   };
25714 };
25715
25716
25717 /***/ }),
25718 /* 283 */,
25719 /* 284 */,
25720 /* 285 */,
25721 /* 286 */,
25722 /* 287 */,
25723 /* 288 */,
25724 /* 289 */,
25725 /* 290 */,
25726 /* 291 */,
25727 /* 292 */,
25728 /* 293 */,
25729 /* 294 */,
25730 /* 295 */,
25731 /* 296 */,
25732 /* 297 */,
25733 /* 298 */,
25734 /* 299 */,
25735 /* 300 */,
25736 /* 301 */,
25737 /* 302 */,
25738 /* 303 */,
25739 /* 304 */,
25740 /* 305 */,
25741 /* 306 */,
25742 /* 307 */,
25743 /* 308 */,
25744 /* 309 */,
25745 /* 310 */,
25746 /* 311 */,
25747 /* 312 */,
25748 /* 313 */,
25749 /* 314 */,
25750 /* 315 */,
25751 /* 316 */,
25752 /* 317 */,
25753 /* 318 */,
25754 /* 319 */,
25755 /* 320 */,
25756 /* 321 */,
25757 /* 322 */,
25758 /* 323 */,
25759 /* 324 */,
25760 /* 325 */,
25761 /* 326 */,
25762 /* 327 */,
25763 /* 328 */,
25764 /* 329 */,
25765 /* 330 */,
25766 /* 331 */,
25767 /* 332 */,
25768 /* 333 */,
25769 /* 334 */,
25770 /* 335 */,
25771 /* 336 */,
25772 /* 337 */,
25773 /* 338 */,
25774 /* 339 */,
25775 /* 340 */,
25776 /* 341 */,
25777 /* 342 */,
25778 /* 343 */,
25779 /* 344 */,
25780 /* 345 */,
25781 /* 346 */,
25782 /* 347 */,
25783 /* 348 */,
25784 /* 349 */,
25785 /* 350 */,
25786 /* 351 */,
25787 /* 352 */,
25788 /* 353 */,
25789 /* 354 */,
25790 /* 355 */,
25791 /* 356 */,
25792 /* 357 */,
25793 /* 358 */,
25794 /* 359 */,
25795 /* 360 */,
25796 /* 361 */,
25797 /* 362 */,
25798 /* 363 */,
25799 /* 364 */,
25800 /* 365 */,
25801 /* 366 */,
25802 /* 367 */,
25803 /* 368 */,
25804 /* 369 */,
25805 /* 370 */,
25806 /* 371 */,
25807 /* 372 */,
25808 /* 373 */,
25809 /* 374 */,
25810 /* 375 */,
25811 /* 376 */,
25812 /* 377 */,
25813 /* 378 */,
25814 /* 379 */,
25815 /* 380 */,
25816 /* 381 */,
25817 /* 382 */,
25818 /* 383 */,
25819 /* 384 */,
25820 /* 385 */,
25821 /* 386 */,
25822 /* 387 */,
25823 /* 388 */,
25824 /* 389 */,
25825 /* 390 */,
25826 /* 391 */,
25827 /* 392 */,
25828 /* 393 */,
25829 /* 394 */,
25830 /* 395 */,
25831 /* 396 */,
25832 /* 397 */,
25833 /* 398 */,
25834 /* 399 */,
25835 /* 400 */,
25836 /* 401 */,
25837 /* 402 */,
25838 /* 403 */,
25839 /* 404 */,
25840 /* 405 */,
25841 /* 406 */,
25842 /* 407 */,
25843 /* 408 */,
25844 /* 409 */,
25845 /* 410 */,
25846 /* 411 */,
25847 /* 412 */,
25848 /* 413 */,
25849 /* 414 */,
25850 /* 415 */,
25851 /* 416 */,
25852 /* 417 */,
25853 /* 418 */,
25854 /* 419 */,
25855 /* 420 */,
25856 /* 421 */,
25857 /* 422 */,
25858 /* 423 */,
25859 /* 424 */,
25860 /* 425 */,
25861 /* 426 */,
25862 /* 427 */,
25863 /* 428 */,
25864 /* 429 */,
25865 /* 430 */
25866 /***/ (function(module, exports, __webpack_require__) {
25867
25868 var isObject = __webpack_require__(12);
25869 module.exports = function (it, TYPE) {
25870   if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
25871   return it;
25872 };
25873
25874
25875 /***/ }),
25876 /* 431 */
25877 /***/ (function(module, __webpack_exports__, __webpack_require__) {
25878
25879 "use strict";
25880 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
25881 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
25882 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(36);
25883 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
25884
25885
25886
25887 var IdGenerator = function () {
25888   function IdGenerator() {
25889     __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, IdGenerator);
25890   }
25891
25892   __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(IdGenerator, null, [{
25893     key: 'rand',
25894     value: function rand() {
25895       var arr = new Uint32Array(1);
25896       window.crypto.getRandomValues(arr);
25897       return arr[0] / (0xffffffff + 1);
25898     }
25899
25900     /***
25901      * Generates a random string of specified size
25902      * @param size - The length of the string to generate
25903      * @returns {string} - The generated random string
25904      */
25905
25906   }, {
25907     key: 'text',
25908     value: function text(size) {
25909       var text = '';
25910       var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
25911       for (var i = 0; i < size; i++) {
25912         text += possible.charAt(Math.floor(IdGenerator.rand() * possible.length));
25913       }return text;
25914     }
25915
25916     /***
25917      * Generates a random number of specified size
25918      * @param size - The length of the number to generate
25919      * @returns {string} - The generated random number ( as a string )
25920      */
25921
25922   }, {
25923     key: 'numeric',
25924     value: function numeric(size) {
25925       var add = 1;
25926       var max = 12 - add;
25927
25928       if (size > max) return IdGenerator.numeric(max) + IdGenerator.numeric(size - max);
25929
25930       max = Math.pow(10, size + add);
25931       var min = max / 10,
25932           number = Math.floor(IdGenerator.rand() * (max - min + 1)) + min;
25933
25934       return ('' + number).substring(add);
25935     }
25936   }]);
25937
25938   return IdGenerator;
25939 }();
25940
25941 /* harmony default export */ __webpack_exports__["a"] = (IdGenerator);
25942
25943 /***/ }),
25944 /* 432 */
25945 /***/ (function(module, __webpack_exports__, __webpack_require__) {
25946
25947 "use strict";
25948 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return INJECT; });
25949 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return BYTOM; });
25950 var INJECT = 'bytom-inject-js';
25951 var BYTOM = 'bytom-content-js';
25952
25953 /***/ }),
25954 /* 433 */,
25955 /* 434 */
25956 /***/ (function(module, exports, __webpack_require__) {
25957
25958 /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
25959  * @license
25960  * Lodash <https://lodash.com/>
25961  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
25962  * Released under MIT license <https://lodash.com/license>
25963  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
25964  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
25965  */
25966 ;(function() {
25967
25968   /** Used as a safe reference for `undefined` in pre-ES5 environments. */
25969   var undefined;
25970
25971   /** Used as the semantic version number. */
25972   var VERSION = '4.17.15';
25973
25974   /** Used as the size to enable large array optimizations. */
25975   var LARGE_ARRAY_SIZE = 200;
25976
25977   /** Error message constants. */
25978   var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
25979       FUNC_ERROR_TEXT = 'Expected a function';
25980
25981   /** Used to stand-in for `undefined` hash values. */
25982   var HASH_UNDEFINED = '__lodash_hash_undefined__';
25983
25984   /** Used as the maximum memoize cache size. */
25985   var MAX_MEMOIZE_SIZE = 500;
25986
25987   /** Used as the internal argument placeholder. */
25988   var PLACEHOLDER = '__lodash_placeholder__';
25989
25990   /** Used to compose bitmasks for cloning. */
25991   var CLONE_DEEP_FLAG = 1,
25992       CLONE_FLAT_FLAG = 2,
25993       CLONE_SYMBOLS_FLAG = 4;
25994
25995   /** Used to compose bitmasks for value comparisons. */
25996   var COMPARE_PARTIAL_FLAG = 1,
25997       COMPARE_UNORDERED_FLAG = 2;
25998
25999   /** Used to compose bitmasks for function metadata. */
26000   var WRAP_BIND_FLAG = 1,
26001       WRAP_BIND_KEY_FLAG = 2,
26002       WRAP_CURRY_BOUND_FLAG = 4,
26003       WRAP_CURRY_FLAG = 8,
26004       WRAP_CURRY_RIGHT_FLAG = 16,
26005       WRAP_PARTIAL_FLAG = 32,
26006       WRAP_PARTIAL_RIGHT_FLAG = 64,
26007       WRAP_ARY_FLAG = 128,
26008       WRAP_REARG_FLAG = 256,
26009       WRAP_FLIP_FLAG = 512;
26010
26011   /** Used as default options for `_.truncate`. */
26012   var DEFAULT_TRUNC_LENGTH = 30,
26013       DEFAULT_TRUNC_OMISSION = '...';
26014
26015   /** Used to detect hot functions by number of calls within a span of milliseconds. */
26016   var HOT_COUNT = 800,
26017       HOT_SPAN = 16;
26018
26019   /** Used to indicate the type of lazy iteratees. */
26020   var LAZY_FILTER_FLAG = 1,
26021       LAZY_MAP_FLAG = 2,
26022       LAZY_WHILE_FLAG = 3;
26023
26024   /** Used as references for various `Number` constants. */
26025   var INFINITY = 1 / 0,
26026       MAX_SAFE_INTEGER = 9007199254740991,
26027       MAX_INTEGER = 1.7976931348623157e+308,
26028       NAN = 0 / 0;
26029
26030   /** Used as references for the maximum length and index of an array. */
26031   var MAX_ARRAY_LENGTH = 4294967295,
26032       MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
26033       HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
26034
26035   /** Used to associate wrap methods with their bit flags. */
26036   var wrapFlags = [
26037     ['ary', WRAP_ARY_FLAG],
26038     ['bind', WRAP_BIND_FLAG],
26039     ['bindKey', WRAP_BIND_KEY_FLAG],
26040     ['curry', WRAP_CURRY_FLAG],
26041     ['curryRight', WRAP_CURRY_RIGHT_FLAG],
26042     ['flip', WRAP_FLIP_FLAG],
26043     ['partial', WRAP_PARTIAL_FLAG],
26044     ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
26045     ['rearg', WRAP_REARG_FLAG]
26046   ];
26047
26048   /** `Object#toString` result references. */
26049   var argsTag = '[object Arguments]',
26050       arrayTag = '[object Array]',
26051       asyncTag = '[object AsyncFunction]',
26052       boolTag = '[object Boolean]',
26053       dateTag = '[object Date]',
26054       domExcTag = '[object DOMException]',
26055       errorTag = '[object Error]',
26056       funcTag = '[object Function]',
26057       genTag = '[object GeneratorFunction]',
26058       mapTag = '[object Map]',
26059       numberTag = '[object Number]',
26060       nullTag = '[object Null]',
26061       objectTag = '[object Object]',
26062       promiseTag = '[object Promise]',
26063       proxyTag = '[object Proxy]',
26064       regexpTag = '[object RegExp]',
26065       setTag = '[object Set]',
26066       stringTag = '[object String]',
26067       symbolTag = '[object Symbol]',
26068       undefinedTag = '[object Undefined]',
26069       weakMapTag = '[object WeakMap]',
26070       weakSetTag = '[object WeakSet]';
26071
26072   var arrayBufferTag = '[object ArrayBuffer]',
26073       dataViewTag = '[object DataView]',
26074       float32Tag = '[object Float32Array]',
26075       float64Tag = '[object Float64Array]',
26076       int8Tag = '[object Int8Array]',
26077       int16Tag = '[object Int16Array]',
26078       int32Tag = '[object Int32Array]',
26079       uint8Tag = '[object Uint8Array]',
26080       uint8ClampedTag = '[object Uint8ClampedArray]',
26081       uint16Tag = '[object Uint16Array]',
26082       uint32Tag = '[object Uint32Array]';
26083
26084   /** Used to match empty string literals in compiled template source. */
26085   var reEmptyStringLeading = /\b__p \+= '';/g,
26086       reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
26087       reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
26088
26089   /** Used to match HTML entities and HTML characters. */
26090   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
26091       reUnescapedHtml = /[&<>"']/g,
26092       reHasEscapedHtml = RegExp(reEscapedHtml.source),
26093       reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
26094
26095   /** Used to match template delimiters. */
26096   var reEscape = /<%-([\s\S]+?)%>/g,
26097       reEvaluate = /<%([\s\S]+?)%>/g,
26098       reInterpolate = /<%=([\s\S]+?)%>/g;
26099
26100   /** Used to match property names within property paths. */
26101   var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
26102       reIsPlainProp = /^\w*$/,
26103       rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
26104
26105   /**
26106    * Used to match `RegExp`
26107    * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
26108    */
26109   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
26110       reHasRegExpChar = RegExp(reRegExpChar.source);
26111
26112   /** Used to match leading and trailing whitespace. */
26113   var reTrim = /^\s+|\s+$/g,
26114       reTrimStart = /^\s+/,
26115       reTrimEnd = /\s+$/;
26116
26117   /** Used to match wrap detail comments. */
26118   var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
26119       reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
26120       reSplitDetails = /,? & /;
26121
26122   /** Used to match words composed of alphanumeric characters. */
26123   var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
26124
26125   /** Used to match backslashes in property paths. */
26126   var reEscapeChar = /\\(\\)?/g;
26127
26128   /**
26129    * Used to match
26130    * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
26131    */
26132   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
26133
26134   /** Used to match `RegExp` flags from their coerced string values. */
26135   var reFlags = /\w*$/;
26136
26137   /** Used to detect bad signed hexadecimal string values. */
26138   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
26139
26140   /** Used to detect binary string values. */
26141   var reIsBinary = /^0b[01]+$/i;
26142
26143   /** Used to detect host constructors (Safari). */
26144   var reIsHostCtor = /^\[object .+?Constructor\]$/;
26145
26146   /** Used to detect octal string values. */
26147   var reIsOctal = /^0o[0-7]+$/i;
26148
26149   /** Used to detect unsigned integer values. */
26150   var reIsUint = /^(?:0|[1-9]\d*)$/;
26151
26152   /** Used to match Latin Unicode letters (excluding mathematical operators). */
26153   var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
26154
26155   /** Used to ensure capturing order of template delimiters. */
26156   var reNoMatch = /($^)/;
26157
26158   /** Used to match unescaped characters in compiled string literals. */
26159   var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
26160
26161   /** Used to compose unicode character classes. */
26162   var rsAstralRange = '\\ud800-\\udfff',
26163       rsComboMarksRange = '\\u0300-\\u036f',
26164       reComboHalfMarksRange = '\\ufe20-\\ufe2f',
26165       rsComboSymbolsRange = '\\u20d0-\\u20ff',
26166       rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
26167       rsDingbatRange = '\\u2700-\\u27bf',
26168       rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
26169       rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
26170       rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
26171       rsPunctuationRange = '\\u2000-\\u206f',
26172       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',
26173       rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
26174       rsVarRange = '\\ufe0e\\ufe0f',
26175       rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
26176
26177   /** Used to compose unicode capture groups. */
26178   var rsApos = "['\u2019]",
26179       rsAstral = '[' + rsAstralRange + ']',
26180       rsBreak = '[' + rsBreakRange + ']',
26181       rsCombo = '[' + rsComboRange + ']',
26182       rsDigits = '\\d+',
26183       rsDingbat = '[' + rsDingbatRange + ']',
26184       rsLower = '[' + rsLowerRange + ']',
26185       rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
26186       rsFitz = '\\ud83c[\\udffb-\\udfff]',
26187       rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
26188       rsNonAstral = '[^' + rsAstralRange + ']',
26189       rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
26190       rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
26191       rsUpper = '[' + rsUpperRange + ']',
26192       rsZWJ = '\\u200d';
26193
26194   /** Used to compose unicode regexes. */
26195   var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
26196       rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
26197       rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
26198       rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
26199       reOptMod = rsModifier + '?',
26200       rsOptVar = '[' + rsVarRange + ']?',
26201       rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
26202       rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
26203       rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
26204       rsSeq = rsOptVar + reOptMod + rsOptJoin,
26205       rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
26206       rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
26207
26208   /** Used to match apostrophes. */
26209   var reApos = RegExp(rsApos, 'g');
26210
26211   /**
26212    * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
26213    * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
26214    */
26215   var reComboMark = RegExp(rsCombo, 'g');
26216
26217   /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
26218   var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
26219
26220   /** Used to match complex or compound words. */
26221   var reUnicodeWord = RegExp([
26222     rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
26223     rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
26224     rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
26225     rsUpper + '+' + rsOptContrUpper,
26226     rsOrdUpper,
26227     rsOrdLower,
26228     rsDigits,
26229     rsEmoji
26230   ].join('|'), 'g');
26231
26232   /** 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/). */
26233   var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange  + rsComboRange + rsVarRange + ']');
26234
26235   /** Used to detect strings that need a more robust regexp to match words. */
26236   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 ]/;
26237
26238   /** Used to assign default `context` object properties. */
26239   var contextProps = [
26240     'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
26241     'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
26242     'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
26243     'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
26244     '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
26245   ];
26246
26247   /** Used to make template sourceURLs easier to identify. */
26248   var templateCounter = -1;
26249
26250   /** Used to identify `toStringTag` values of typed arrays. */
26251   var typedArrayTags = {};
26252   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
26253   typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
26254   typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
26255   typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
26256   typedArrayTags[uint32Tag] = true;
26257   typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
26258   typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
26259   typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
26260   typedArrayTags[errorTag] = typedArrayTags[funcTag] =
26261   typedArrayTags[mapTag] = typedArrayTags[numberTag] =
26262   typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
26263   typedArrayTags[setTag] = typedArrayTags[stringTag] =
26264   typedArrayTags[weakMapTag] = false;
26265
26266   /** Used to identify `toStringTag` values supported by `_.clone`. */
26267   var cloneableTags = {};
26268   cloneableTags[argsTag] = cloneableTags[arrayTag] =
26269   cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
26270   cloneableTags[boolTag] = cloneableTags[dateTag] =
26271   cloneableTags[float32Tag] = cloneableTags[float64Tag] =
26272   cloneableTags[int8Tag] = cloneableTags[int16Tag] =
26273   cloneableTags[int32Tag] = cloneableTags[mapTag] =
26274   cloneableTags[numberTag] = cloneableTags[objectTag] =
26275   cloneableTags[regexpTag] = cloneableTags[setTag] =
26276   cloneableTags[stringTag] = cloneableTags[symbolTag] =
26277   cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
26278   cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
26279   cloneableTags[errorTag] = cloneableTags[funcTag] =
26280   cloneableTags[weakMapTag] = false;
26281
26282   /** Used to map Latin Unicode letters to basic Latin letters. */
26283   var deburredLetters = {
26284     // Latin-1 Supplement block.
26285     '\xc0': 'A',  '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
26286     '\xe0': 'a',  '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
26287     '\xc7': 'C',  '\xe7': 'c',
26288     '\xd0': 'D',  '\xf0': 'd',
26289     '\xc8': 'E',  '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
26290     '\xe8': 'e',  '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
26291     '\xcc': 'I',  '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
26292     '\xec': 'i',  '\xed': 'i', '\xee': 'i', '\xef': 'i',
26293     '\xd1': 'N',  '\xf1': 'n',
26294     '\xd2': 'O',  '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
26295     '\xf2': 'o',  '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
26296     '\xd9': 'U',  '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
26297     '\xf9': 'u',  '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
26298     '\xdd': 'Y',  '\xfd': 'y', '\xff': 'y',
26299     '\xc6': 'Ae', '\xe6': 'ae',
26300     '\xde': 'Th', '\xfe': 'th',
26301     '\xdf': 'ss',
26302     // Latin Extended-A block.
26303     '\u0100': 'A',  '\u0102': 'A', '\u0104': 'A',
26304     '\u0101': 'a',  '\u0103': 'a', '\u0105': 'a',
26305     '\u0106': 'C',  '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
26306     '\u0107': 'c',  '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
26307     '\u010e': 'D',  '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
26308     '\u0112': 'E',  '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
26309     '\u0113': 'e',  '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
26310     '\u011c': 'G',  '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
26311     '\u011d': 'g',  '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
26312     '\u0124': 'H',  '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
26313     '\u0128': 'I',  '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
26314     '\u0129': 'i',  '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
26315     '\u0134': 'J',  '\u0135': 'j',
26316     '\u0136': 'K',  '\u0137': 'k', '\u0138': 'k',
26317     '\u0139': 'L',  '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
26318     '\u013a': 'l',  '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
26319     '\u0143': 'N',  '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
26320     '\u0144': 'n',  '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
26321     '\u014c': 'O',  '\u014e': 'O', '\u0150': 'O',
26322     '\u014d': 'o',  '\u014f': 'o', '\u0151': 'o',
26323     '\u0154': 'R',  '\u0156': 'R', '\u0158': 'R',
26324     '\u0155': 'r',  '\u0157': 'r', '\u0159': 'r',
26325     '\u015a': 'S',  '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
26326     '\u015b': 's',  '\u015d': 's', '\u015f': 's', '\u0161': 's',
26327     '\u0162': 'T',  '\u0164': 'T', '\u0166': 'T',
26328     '\u0163': 't',  '\u0165': 't', '\u0167': 't',
26329     '\u0168': 'U',  '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
26330     '\u0169': 'u',  '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
26331     '\u0174': 'W',  '\u0175': 'w',
26332     '\u0176': 'Y',  '\u0177': 'y', '\u0178': 'Y',
26333     '\u0179': 'Z',  '\u017b': 'Z', '\u017d': 'Z',
26334     '\u017a': 'z',  '\u017c': 'z', '\u017e': 'z',
26335     '\u0132': 'IJ', '\u0133': 'ij',
26336     '\u0152': 'Oe', '\u0153': 'oe',
26337     '\u0149': "'n", '\u017f': 's'
26338   };
26339
26340   /** Used to map characters to HTML entities. */
26341   var htmlEscapes = {
26342     '&': '&amp;',
26343     '<': '&lt;',
26344     '>': '&gt;',
26345     '"': '&quot;',
26346     "'": '&#39;'
26347   };
26348
26349   /** Used to map HTML entities to characters. */
26350   var htmlUnescapes = {
26351     '&amp;': '&',
26352     '&lt;': '<',
26353     '&gt;': '>',
26354     '&quot;': '"',
26355     '&#39;': "'"
26356   };
26357
26358   /** Used to escape characters for inclusion in compiled string literals. */
26359   var stringEscapes = {
26360     '\\': '\\',
26361     "'": "'",
26362     '\n': 'n',
26363     '\r': 'r',
26364     '\u2028': 'u2028',
26365     '\u2029': 'u2029'
26366   };
26367
26368   /** Built-in method references without a dependency on `root`. */
26369   var freeParseFloat = parseFloat,
26370       freeParseInt = parseInt;
26371
26372   /** Detect free variable `global` from Node.js. */
26373   var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
26374
26375   /** Detect free variable `self`. */
26376   var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
26377
26378   /** Used as a reference to the global object. */
26379   var root = freeGlobal || freeSelf || Function('return this')();
26380
26381   /** Detect free variable `exports`. */
26382   var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
26383
26384   /** Detect free variable `module`. */
26385   var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
26386
26387   /** Detect the popular CommonJS extension `module.exports`. */
26388   var moduleExports = freeModule && freeModule.exports === freeExports;
26389
26390   /** Detect free variable `process` from Node.js. */
26391   var freeProcess = moduleExports && freeGlobal.process;
26392
26393   /** Used to access faster Node.js helpers. */
26394   var nodeUtil = (function() {
26395     try {
26396       // Use `util.types` for Node.js 10+.
26397       var types = freeModule && freeModule.require && freeModule.require('util').types;
26398
26399       if (types) {
26400         return types;
26401       }
26402
26403       // Legacy `process.binding('util')` for Node.js < 10.
26404       return freeProcess && freeProcess.binding && freeProcess.binding('util');
26405     } catch (e) {}
26406   }());
26407
26408   /* Node.js helper references. */
26409   var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
26410       nodeIsDate = nodeUtil && nodeUtil.isDate,
26411       nodeIsMap = nodeUtil && nodeUtil.isMap,
26412       nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
26413       nodeIsSet = nodeUtil && nodeUtil.isSet,
26414       nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
26415
26416   /*--------------------------------------------------------------------------*/
26417
26418   /**
26419    * A faster alternative to `Function#apply`, this function invokes `func`
26420    * with the `this` binding of `thisArg` and the arguments of `args`.
26421    *
26422    * @private
26423    * @param {Function} func The function to invoke.
26424    * @param {*} thisArg The `this` binding of `func`.
26425    * @param {Array} args The arguments to invoke `func` with.
26426    * @returns {*} Returns the result of `func`.
26427    */
26428   function apply(func, thisArg, args) {
26429     switch (args.length) {
26430       case 0: return func.call(thisArg);
26431       case 1: return func.call(thisArg, args[0]);
26432       case 2: return func.call(thisArg, args[0], args[1]);
26433       case 3: return func.call(thisArg, args[0], args[1], args[2]);
26434     }
26435     return func.apply(thisArg, args);
26436   }
26437
26438   /**
26439    * A specialized version of `baseAggregator` for arrays.
26440    *
26441    * @private
26442    * @param {Array} [array] The array to iterate over.
26443    * @param {Function} setter The function to set `accumulator` values.
26444    * @param {Function} iteratee The iteratee to transform keys.
26445    * @param {Object} accumulator The initial aggregated object.
26446    * @returns {Function} Returns `accumulator`.
26447    */
26448   function arrayAggregator(array, setter, iteratee, accumulator) {
26449     var index = -1,
26450         length = array == null ? 0 : array.length;
26451
26452     while (++index < length) {
26453       var value = array[index];
26454       setter(accumulator, value, iteratee(value), array);
26455     }
26456     return accumulator;
26457   }
26458
26459   /**
26460    * A specialized version of `_.forEach` for arrays without support for
26461    * iteratee shorthands.
26462    *
26463    * @private
26464    * @param {Array} [array] The array to iterate over.
26465    * @param {Function} iteratee The function invoked per iteration.
26466    * @returns {Array} Returns `array`.
26467    */
26468   function arrayEach(array, iteratee) {
26469     var index = -1,
26470         length = array == null ? 0 : array.length;
26471
26472     while (++index < length) {
26473       if (iteratee(array[index], index, array) === false) {
26474         break;
26475       }
26476     }
26477     return array;
26478   }
26479
26480   /**
26481    * A specialized version of `_.forEachRight` for arrays without support for
26482    * iteratee shorthands.
26483    *
26484    * @private
26485    * @param {Array} [array] The array to iterate over.
26486    * @param {Function} iteratee The function invoked per iteration.
26487    * @returns {Array} Returns `array`.
26488    */
26489   function arrayEachRight(array, iteratee) {
26490     var length = array == null ? 0 : array.length;
26491
26492     while (length--) {
26493       if (iteratee(array[length], length, array) === false) {
26494         break;
26495       }
26496     }
26497     return array;
26498   }
26499
26500   /**
26501    * A specialized version of `_.every` for arrays without support for
26502    * iteratee shorthands.
26503    *
26504    * @private
26505    * @param {Array} [array] The array to iterate over.
26506    * @param {Function} predicate The function invoked per iteration.
26507    * @returns {boolean} Returns `true` if all elements pass the predicate check,
26508    *  else `false`.
26509    */
26510   function arrayEvery(array, predicate) {
26511     var index = -1,
26512         length = array == null ? 0 : array.length;
26513
26514     while (++index < length) {
26515       if (!predicate(array[index], index, array)) {
26516         return false;
26517       }
26518     }
26519     return true;
26520   }
26521
26522   /**
26523    * A specialized version of `_.filter` for arrays without support for
26524    * iteratee shorthands.
26525    *
26526    * @private
26527    * @param {Array} [array] The array to iterate over.
26528    * @param {Function} predicate The function invoked per iteration.
26529    * @returns {Array} Returns the new filtered array.
26530    */
26531   function arrayFilter(array, predicate) {
26532     var index = -1,
26533         length = array == null ? 0 : array.length,
26534         resIndex = 0,
26535         result = [];
26536
26537     while (++index < length) {
26538       var value = array[index];
26539       if (predicate(value, index, array)) {
26540         result[resIndex++] = value;
26541       }
26542     }
26543     return result;
26544   }
26545
26546   /**
26547    * A specialized version of `_.includes` for arrays without support for
26548    * specifying an index to search from.
26549    *
26550    * @private
26551    * @param {Array} [array] The array to inspect.
26552    * @param {*} target The value to search for.
26553    * @returns {boolean} Returns `true` if `target` is found, else `false`.
26554    */
26555   function arrayIncludes(array, value) {
26556     var length = array == null ? 0 : array.length;
26557     return !!length && baseIndexOf(array, value, 0) > -1;
26558   }
26559
26560   /**
26561    * This function is like `arrayIncludes` except that it accepts a comparator.
26562    *
26563    * @private
26564    * @param {Array} [array] The array to inspect.
26565    * @param {*} target The value to search for.
26566    * @param {Function} comparator The comparator invoked per element.
26567    * @returns {boolean} Returns `true` if `target` is found, else `false`.
26568    */
26569   function arrayIncludesWith(array, value, comparator) {
26570     var index = -1,
26571         length = array == null ? 0 : array.length;
26572
26573     while (++index < length) {
26574       if (comparator(value, array[index])) {
26575         return true;
26576       }
26577     }
26578     return false;
26579   }
26580
26581   /**
26582    * A specialized version of `_.map` for arrays without support for iteratee
26583    * shorthands.
26584    *
26585    * @private
26586    * @param {Array} [array] The array to iterate over.
26587    * @param {Function} iteratee The function invoked per iteration.
26588    * @returns {Array} Returns the new mapped array.
26589    */
26590   function arrayMap(array, iteratee) {
26591     var index = -1,
26592         length = array == null ? 0 : array.length,
26593         result = Array(length);
26594
26595     while (++index < length) {
26596       result[index] = iteratee(array[index], index, array);
26597     }
26598     return result;
26599   }
26600
26601   /**
26602    * Appends the elements of `values` to `array`.
26603    *
26604    * @private
26605    * @param {Array} array The array to modify.
26606    * @param {Array} values The values to append.
26607    * @returns {Array} Returns `array`.
26608    */
26609   function arrayPush(array, values) {
26610     var index = -1,
26611         length = values.length,
26612         offset = array.length;
26613
26614     while (++index < length) {
26615       array[offset + index] = values[index];
26616     }
26617     return array;
26618   }
26619
26620   /**
26621    * A specialized version of `_.reduce` for arrays without support for
26622    * iteratee shorthands.
26623    *
26624    * @private
26625    * @param {Array} [array] The array to iterate over.
26626    * @param {Function} iteratee The function invoked per iteration.
26627    * @param {*} [accumulator] The initial value.
26628    * @param {boolean} [initAccum] Specify using the first element of `array` as
26629    *  the initial value.
26630    * @returns {*} Returns the accumulated value.
26631    */
26632   function arrayReduce(array, iteratee, accumulator, initAccum) {
26633     var index = -1,
26634         length = array == null ? 0 : array.length;
26635
26636     if (initAccum && length) {
26637       accumulator = array[++index];
26638     }
26639     while (++index < length) {
26640       accumulator = iteratee(accumulator, array[index], index, array);
26641     }
26642     return accumulator;
26643   }
26644
26645   /**
26646    * A specialized version of `_.reduceRight` for arrays without support for
26647    * iteratee shorthands.
26648    *
26649    * @private
26650    * @param {Array} [array] The array to iterate over.
26651    * @param {Function} iteratee The function invoked per iteration.
26652    * @param {*} [accumulator] The initial value.
26653    * @param {boolean} [initAccum] Specify using the last element of `array` as
26654    *  the initial value.
26655    * @returns {*} Returns the accumulated value.
26656    */
26657   function arrayReduceRight(array, iteratee, accumulator, initAccum) {
26658     var length = array == null ? 0 : array.length;
26659     if (initAccum && length) {
26660       accumulator = array[--length];
26661     }
26662     while (length--) {
26663       accumulator = iteratee(accumulator, array[length], length, array);
26664     }
26665     return accumulator;
26666   }
26667
26668   /**
26669    * A specialized version of `_.some` for arrays without support for iteratee
26670    * shorthands.
26671    *
26672    * @private
26673    * @param {Array} [array] The array to iterate over.
26674    * @param {Function} predicate The function invoked per iteration.
26675    * @returns {boolean} Returns `true` if any element passes the predicate check,
26676    *  else `false`.
26677    */
26678   function arraySome(array, predicate) {
26679     var index = -1,
26680         length = array == null ? 0 : array.length;
26681
26682     while (++index < length) {
26683       if (predicate(array[index], index, array)) {
26684         return true;
26685       }
26686     }
26687     return false;
26688   }
26689
26690   /**
26691    * Gets the size of an ASCII `string`.
26692    *
26693    * @private
26694    * @param {string} string The string inspect.
26695    * @returns {number} Returns the string size.
26696    */
26697   var asciiSize = baseProperty('length');
26698
26699   /**
26700    * Converts an ASCII `string` to an array.
26701    *
26702    * @private
26703    * @param {string} string The string to convert.
26704    * @returns {Array} Returns the converted array.
26705    */
26706   function asciiToArray(string) {
26707     return string.split('');
26708   }
26709
26710   /**
26711    * Splits an ASCII `string` into an array of its words.
26712    *
26713    * @private
26714    * @param {string} The string to inspect.
26715    * @returns {Array} Returns the words of `string`.
26716    */
26717   function asciiWords(string) {
26718     return string.match(reAsciiWord) || [];
26719   }
26720
26721   /**
26722    * The base implementation of methods like `_.findKey` and `_.findLastKey`,
26723    * without support for iteratee shorthands, which iterates over `collection`
26724    * using `eachFunc`.
26725    *
26726    * @private
26727    * @param {Array|Object} collection The collection to inspect.
26728    * @param {Function} predicate The function invoked per iteration.
26729    * @param {Function} eachFunc The function to iterate over `collection`.
26730    * @returns {*} Returns the found element or its key, else `undefined`.
26731    */
26732   function baseFindKey(collection, predicate, eachFunc) {
26733     var result;
26734     eachFunc(collection, function(value, key, collection) {
26735       if (predicate(value, key, collection)) {
26736         result = key;
26737         return false;
26738       }
26739     });
26740     return result;
26741   }
26742
26743   /**
26744    * The base implementation of `_.findIndex` and `_.findLastIndex` without
26745    * support for iteratee shorthands.
26746    *
26747    * @private
26748    * @param {Array} array The array to inspect.
26749    * @param {Function} predicate The function invoked per iteration.
26750    * @param {number} fromIndex The index to search from.
26751    * @param {boolean} [fromRight] Specify iterating from right to left.
26752    * @returns {number} Returns the index of the matched value, else `-1`.
26753    */
26754   function baseFindIndex(array, predicate, fromIndex, fromRight) {
26755     var length = array.length,
26756         index = fromIndex + (fromRight ? 1 : -1);
26757
26758     while ((fromRight ? index-- : ++index < length)) {
26759       if (predicate(array[index], index, array)) {
26760         return index;
26761       }
26762     }
26763     return -1;
26764   }
26765
26766   /**
26767    * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
26768    *
26769    * @private
26770    * @param {Array} array The array to inspect.
26771    * @param {*} value The value to search for.
26772    * @param {number} fromIndex The index to search from.
26773    * @returns {number} Returns the index of the matched value, else `-1`.
26774    */
26775   function baseIndexOf(array, value, fromIndex) {
26776     return value === value
26777       ? strictIndexOf(array, value, fromIndex)
26778       : baseFindIndex(array, baseIsNaN, fromIndex);
26779   }
26780
26781   /**
26782    * This function is like `baseIndexOf` except that it accepts a comparator.
26783    *
26784    * @private
26785    * @param {Array} array The array to inspect.
26786    * @param {*} value The value to search for.
26787    * @param {number} fromIndex The index to search from.
26788    * @param {Function} comparator The comparator invoked per element.
26789    * @returns {number} Returns the index of the matched value, else `-1`.
26790    */
26791   function baseIndexOfWith(array, value, fromIndex, comparator) {
26792     var index = fromIndex - 1,
26793         length = array.length;
26794
26795     while (++index < length) {
26796       if (comparator(array[index], value)) {
26797         return index;
26798       }
26799     }
26800     return -1;
26801   }
26802
26803   /**
26804    * The base implementation of `_.isNaN` without support for number objects.
26805    *
26806    * @private
26807    * @param {*} value The value to check.
26808    * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
26809    */
26810   function baseIsNaN(value) {
26811     return value !== value;
26812   }
26813
26814   /**
26815    * The base implementation of `_.mean` and `_.meanBy` without support for
26816    * iteratee shorthands.
26817    *
26818    * @private
26819    * @param {Array} array The array to iterate over.
26820    * @param {Function} iteratee The function invoked per iteration.
26821    * @returns {number} Returns the mean.
26822    */
26823   function baseMean(array, iteratee) {
26824     var length = array == null ? 0 : array.length;
26825     return length ? (baseSum(array, iteratee) / length) : NAN;
26826   }
26827
26828   /**
26829    * The base implementation of `_.property` without support for deep paths.
26830    *
26831    * @private
26832    * @param {string} key The key of the property to get.
26833    * @returns {Function} Returns the new accessor function.
26834    */
26835   function baseProperty(key) {
26836     return function(object) {
26837       return object == null ? undefined : object[key];
26838     };
26839   }
26840
26841   /**
26842    * The base implementation of `_.propertyOf` without support for deep paths.
26843    *
26844    * @private
26845    * @param {Object} object The object to query.
26846    * @returns {Function} Returns the new accessor function.
26847    */
26848   function basePropertyOf(object) {
26849     return function(key) {
26850       return object == null ? undefined : object[key];
26851     };
26852   }
26853
26854   /**
26855    * The base implementation of `_.reduce` and `_.reduceRight`, without support
26856    * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
26857    *
26858    * @private
26859    * @param {Array|Object} collection The collection to iterate over.
26860    * @param {Function} iteratee The function invoked per iteration.
26861    * @param {*} accumulator The initial value.
26862    * @param {boolean} initAccum Specify using the first or last element of
26863    *  `collection` as the initial value.
26864    * @param {Function} eachFunc The function to iterate over `collection`.
26865    * @returns {*} Returns the accumulated value.
26866    */
26867   function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
26868     eachFunc(collection, function(value, index, collection) {
26869       accumulator = initAccum
26870         ? (initAccum = false, value)
26871         : iteratee(accumulator, value, index, collection);
26872     });
26873     return accumulator;
26874   }
26875
26876   /**
26877    * The base implementation of `_.sortBy` which uses `comparer` to define the
26878    * sort order of `array` and replaces criteria objects with their corresponding
26879    * values.
26880    *
26881    * @private
26882    * @param {Array} array The array to sort.
26883    * @param {Function} comparer The function to define sort order.
26884    * @returns {Array} Returns `array`.
26885    */
26886   function baseSortBy(array, comparer) {
26887     var length = array.length;
26888
26889     array.sort(comparer);
26890     while (length--) {
26891       array[length] = array[length].value;
26892     }
26893     return array;
26894   }
26895
26896   /**
26897    * The base implementation of `_.sum` and `_.sumBy` without support for
26898    * iteratee shorthands.
26899    *
26900    * @private
26901    * @param {Array} array The array to iterate over.
26902    * @param {Function} iteratee The function invoked per iteration.
26903    * @returns {number} Returns the sum.
26904    */
26905   function baseSum(array, iteratee) {
26906     var result,
26907         index = -1,
26908         length = array.length;
26909
26910     while (++index < length) {
26911       var current = iteratee(array[index]);
26912       if (current !== undefined) {
26913         result = result === undefined ? current : (result + current);
26914       }
26915     }
26916     return result;
26917   }
26918
26919   /**
26920    * The base implementation of `_.times` without support for iteratee shorthands
26921    * or max array length checks.
26922    *
26923    * @private
26924    * @param {number} n The number of times to invoke `iteratee`.
26925    * @param {Function} iteratee The function invoked per iteration.
26926    * @returns {Array} Returns the array of results.
26927    */
26928   function baseTimes(n, iteratee) {
26929     var index = -1,
26930         result = Array(n);
26931
26932     while (++index < n) {
26933       result[index] = iteratee(index);
26934     }
26935     return result;
26936   }
26937
26938   /**
26939    * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
26940    * of key-value pairs for `object` corresponding to the property names of `props`.
26941    *
26942    * @private
26943    * @param {Object} object The object to query.
26944    * @param {Array} props The property names to get values for.
26945    * @returns {Object} Returns the key-value pairs.
26946    */
26947   function baseToPairs(object, props) {
26948     return arrayMap(props, function(key) {
26949       return [key, object[key]];
26950     });
26951   }
26952
26953   /**
26954    * The base implementation of `_.unary` without support for storing metadata.
26955    *
26956    * @private
26957    * @param {Function} func The function to cap arguments for.
26958    * @returns {Function} Returns the new capped function.
26959    */
26960   function baseUnary(func) {
26961     return function(value) {
26962       return func(value);
26963     };
26964   }
26965
26966   /**
26967    * The base implementation of `_.values` and `_.valuesIn` which creates an
26968    * array of `object` property values corresponding to the property names
26969    * of `props`.
26970    *
26971    * @private
26972    * @param {Object} object The object to query.
26973    * @param {Array} props The property names to get values for.
26974    * @returns {Object} Returns the array of property values.
26975    */
26976   function baseValues(object, props) {
26977     return arrayMap(props, function(key) {
26978       return object[key];
26979     });
26980   }
26981
26982   /**
26983    * Checks if a `cache` value for `key` exists.
26984    *
26985    * @private
26986    * @param {Object} cache The cache to query.
26987    * @param {string} key The key of the entry to check.
26988    * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26989    */
26990   function cacheHas(cache, key) {
26991     return cache.has(key);
26992   }
26993
26994   /**
26995    * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
26996    * that is not found in the character symbols.
26997    *
26998    * @private
26999    * @param {Array} strSymbols The string symbols to inspect.
27000    * @param {Array} chrSymbols The character symbols to find.
27001    * @returns {number} Returns the index of the first unmatched string symbol.
27002    */
27003   function charsStartIndex(strSymbols, chrSymbols) {
27004     var index = -1,
27005         length = strSymbols.length;
27006
27007     while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
27008     return index;
27009   }
27010
27011   /**
27012    * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
27013    * that is not found in the character symbols.
27014    *
27015    * @private
27016    * @param {Array} strSymbols The string symbols to inspect.
27017    * @param {Array} chrSymbols The character symbols to find.
27018    * @returns {number} Returns the index of the last unmatched string symbol.
27019    */
27020   function charsEndIndex(strSymbols, chrSymbols) {
27021     var index = strSymbols.length;
27022
27023     while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
27024     return index;
27025   }
27026
27027   /**
27028    * Gets the number of `placeholder` occurrences in `array`.
27029    *
27030    * @private
27031    * @param {Array} array The array to inspect.
27032    * @param {*} placeholder The placeholder to search for.
27033    * @returns {number} Returns the placeholder count.
27034    */
27035   function countHolders(array, placeholder) {
27036     var length = array.length,
27037         result = 0;
27038
27039     while (length--) {
27040       if (array[length] === placeholder) {
27041         ++result;
27042       }
27043     }
27044     return result;
27045   }
27046
27047   /**
27048    * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
27049    * letters to basic Latin letters.
27050    *
27051    * @private
27052    * @param {string} letter The matched letter to deburr.
27053    * @returns {string} Returns the deburred letter.
27054    */
27055   var deburrLetter = basePropertyOf(deburredLetters);
27056
27057   /**
27058    * Used by `_.escape` to convert characters to HTML entities.
27059    *
27060    * @private
27061    * @param {string} chr The matched character to escape.
27062    * @returns {string} Returns the escaped character.
27063    */
27064   var escapeHtmlChar = basePropertyOf(htmlEscapes);
27065
27066   /**
27067    * Used by `_.template` to escape characters for inclusion in compiled string literals.
27068    *
27069    * @private
27070    * @param {string} chr The matched character to escape.
27071    * @returns {string} Returns the escaped character.
27072    */
27073   function escapeStringChar(chr) {
27074     return '\\' + stringEscapes[chr];
27075   }
27076
27077   /**
27078    * Gets the value at `key` of `object`.
27079    *
27080    * @private
27081    * @param {Object} [object] The object to query.
27082    * @param {string} key The key of the property to get.
27083    * @returns {*} Returns the property value.
27084    */
27085   function getValue(object, key) {
27086     return object == null ? undefined : object[key];
27087   }
27088
27089   /**
27090    * Checks if `string` contains Unicode symbols.
27091    *
27092    * @private
27093    * @param {string} string The string to inspect.
27094    * @returns {boolean} Returns `true` if a symbol is found, else `false`.
27095    */
27096   function hasUnicode(string) {
27097     return reHasUnicode.test(string);
27098   }
27099
27100   /**
27101    * Checks if `string` contains a word composed of Unicode symbols.
27102    *
27103    * @private
27104    * @param {string} string The string to inspect.
27105    * @returns {boolean} Returns `true` if a word is found, else `false`.
27106    */
27107   function hasUnicodeWord(string) {
27108     return reHasUnicodeWord.test(string);
27109   }
27110
27111   /**
27112    * Converts `iterator` to an array.
27113    *
27114    * @private
27115    * @param {Object} iterator The iterator to convert.
27116    * @returns {Array} Returns the converted array.
27117    */
27118   function iteratorToArray(iterator) {
27119     var data,
27120         result = [];
27121
27122     while (!(data = iterator.next()).done) {
27123       result.push(data.value);
27124     }
27125     return result;
27126   }
27127
27128   /**
27129    * Converts `map` to its key-value pairs.
27130    *
27131    * @private
27132    * @param {Object} map The map to convert.
27133    * @returns {Array} Returns the key-value pairs.
27134    */
27135   function mapToArray(map) {
27136     var index = -1,
27137         result = Array(map.size);
27138
27139     map.forEach(function(value, key) {
27140       result[++index] = [key, value];
27141     });
27142     return result;
27143   }
27144
27145   /**
27146    * Creates a unary function that invokes `func` with its argument transformed.
27147    *
27148    * @private
27149    * @param {Function} func The function to wrap.
27150    * @param {Function} transform The argument transform.
27151    * @returns {Function} Returns the new function.
27152    */
27153   function overArg(func, transform) {
27154     return function(arg) {
27155       return func(transform(arg));
27156     };
27157   }
27158
27159   /**
27160    * Replaces all `placeholder` elements in `array` with an internal placeholder
27161    * and returns an array of their indexes.
27162    *
27163    * @private
27164    * @param {Array} array The array to modify.
27165    * @param {*} placeholder The placeholder to replace.
27166    * @returns {Array} Returns the new array of placeholder indexes.
27167    */
27168   function replaceHolders(array, placeholder) {
27169     var index = -1,
27170         length = array.length,
27171         resIndex = 0,
27172         result = [];
27173
27174     while (++index < length) {
27175       var value = array[index];
27176       if (value === placeholder || value === PLACEHOLDER) {
27177         array[index] = PLACEHOLDER;
27178         result[resIndex++] = index;
27179       }
27180     }
27181     return result;
27182   }
27183
27184   /**
27185    * Converts `set` to an array of its values.
27186    *
27187    * @private
27188    * @param {Object} set The set to convert.
27189    * @returns {Array} Returns the values.
27190    */
27191   function setToArray(set) {
27192     var index = -1,
27193         result = Array(set.size);
27194
27195     set.forEach(function(value) {
27196       result[++index] = value;
27197     });
27198     return result;
27199   }
27200
27201   /**
27202    * Converts `set` to its value-value pairs.
27203    *
27204    * @private
27205    * @param {Object} set The set to convert.
27206    * @returns {Array} Returns the value-value pairs.
27207    */
27208   function setToPairs(set) {
27209     var index = -1,
27210         result = Array(set.size);
27211
27212     set.forEach(function(value) {
27213       result[++index] = [value, value];
27214     });
27215     return result;
27216   }
27217
27218   /**
27219    * A specialized version of `_.indexOf` which performs strict equality
27220    * comparisons of values, i.e. `===`.
27221    *
27222    * @private
27223    * @param {Array} array The array to inspect.
27224    * @param {*} value The value to search for.
27225    * @param {number} fromIndex The index to search from.
27226    * @returns {number} Returns the index of the matched value, else `-1`.
27227    */
27228   function strictIndexOf(array, value, fromIndex) {
27229     var index = fromIndex - 1,
27230         length = array.length;
27231
27232     while (++index < length) {
27233       if (array[index] === value) {
27234         return index;
27235       }
27236     }
27237     return -1;
27238   }
27239
27240   /**
27241    * A specialized version of `_.lastIndexOf` which performs strict equality
27242    * comparisons of values, i.e. `===`.
27243    *
27244    * @private
27245    * @param {Array} array The array to inspect.
27246    * @param {*} value The value to search for.
27247    * @param {number} fromIndex The index to search from.
27248    * @returns {number} Returns the index of the matched value, else `-1`.
27249    */
27250   function strictLastIndexOf(array, value, fromIndex) {
27251     var index = fromIndex + 1;
27252     while (index--) {
27253       if (array[index] === value) {
27254         return index;
27255       }
27256     }
27257     return index;
27258   }
27259
27260   /**
27261    * Gets the number of symbols in `string`.
27262    *
27263    * @private
27264    * @param {string} string The string to inspect.
27265    * @returns {number} Returns the string size.
27266    */
27267   function stringSize(string) {
27268     return hasUnicode(string)
27269       ? unicodeSize(string)
27270       : asciiSize(string);
27271   }
27272
27273   /**
27274    * Converts `string` to an array.
27275    *
27276    * @private
27277    * @param {string} string The string to convert.
27278    * @returns {Array} Returns the converted array.
27279    */
27280   function stringToArray(string) {
27281     return hasUnicode(string)
27282       ? unicodeToArray(string)
27283       : asciiToArray(string);
27284   }
27285
27286   /**
27287    * Used by `_.unescape` to convert HTML entities to characters.
27288    *
27289    * @private
27290    * @param {string} chr The matched character to unescape.
27291    * @returns {string} Returns the unescaped character.
27292    */
27293   var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
27294
27295   /**
27296    * Gets the size of a Unicode `string`.
27297    *
27298    * @private
27299    * @param {string} string The string inspect.
27300    * @returns {number} Returns the string size.
27301    */
27302   function unicodeSize(string) {
27303     var result = reUnicode.lastIndex = 0;
27304     while (reUnicode.test(string)) {
27305       ++result;
27306     }
27307     return result;
27308   }
27309
27310   /**
27311    * Converts a Unicode `string` to an array.
27312    *
27313    * @private
27314    * @param {string} string The string to convert.
27315    * @returns {Array} Returns the converted array.
27316    */
27317   function unicodeToArray(string) {
27318     return string.match(reUnicode) || [];
27319   }
27320
27321   /**
27322    * Splits a Unicode `string` into an array of its words.
27323    *
27324    * @private
27325    * @param {string} The string to inspect.
27326    * @returns {Array} Returns the words of `string`.
27327    */
27328   function unicodeWords(string) {
27329     return string.match(reUnicodeWord) || [];
27330   }
27331
27332   /*--------------------------------------------------------------------------*/
27333
27334   /**
27335    * Create a new pristine `lodash` function using the `context` object.
27336    *
27337    * @static
27338    * @memberOf _
27339    * @since 1.1.0
27340    * @category Util
27341    * @param {Object} [context=root] The context object.
27342    * @returns {Function} Returns a new `lodash` function.
27343    * @example
27344    *
27345    * _.mixin({ 'foo': _.constant('foo') });
27346    *
27347    * var lodash = _.runInContext();
27348    * lodash.mixin({ 'bar': lodash.constant('bar') });
27349    *
27350    * _.isFunction(_.foo);
27351    * // => true
27352    * _.isFunction(_.bar);
27353    * // => false
27354    *
27355    * lodash.isFunction(lodash.foo);
27356    * // => false
27357    * lodash.isFunction(lodash.bar);
27358    * // => true
27359    *
27360    * // Create a suped-up `defer` in Node.js.
27361    * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
27362    */
27363   var runInContext = (function runInContext(context) {
27364     context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
27365
27366     /** Built-in constructor references. */
27367     var Array = context.Array,
27368         Date = context.Date,
27369         Error = context.Error,
27370         Function = context.Function,
27371         Math = context.Math,
27372         Object = context.Object,
27373         RegExp = context.RegExp,
27374         String = context.String,
27375         TypeError = context.TypeError;
27376
27377     /** Used for built-in method references. */
27378     var arrayProto = Array.prototype,
27379         funcProto = Function.prototype,
27380         objectProto = Object.prototype;
27381
27382     /** Used to detect overreaching core-js shims. */
27383     var coreJsData = context['__core-js_shared__'];
27384
27385     /** Used to resolve the decompiled source of functions. */
27386     var funcToString = funcProto.toString;
27387
27388     /** Used to check objects for own properties. */
27389     var hasOwnProperty = objectProto.hasOwnProperty;
27390
27391     /** Used to generate unique IDs. */
27392     var idCounter = 0;
27393
27394     /** Used to detect methods masquerading as native. */
27395     var maskSrcKey = (function() {
27396       var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
27397       return uid ? ('Symbol(src)_1.' + uid) : '';
27398     }());
27399
27400     /**
27401      * Used to resolve the
27402      * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
27403      * of values.
27404      */
27405     var nativeObjectToString = objectProto.toString;
27406
27407     /** Used to infer the `Object` constructor. */
27408     var objectCtorString = funcToString.call(Object);
27409
27410     /** Used to restore the original `_` reference in `_.noConflict`. */
27411     var oldDash = root._;
27412
27413     /** Used to detect if a method is native. */
27414     var reIsNative = RegExp('^' +
27415       funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
27416       .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
27417     );
27418
27419     /** Built-in value references. */
27420     var Buffer = moduleExports ? context.Buffer : undefined,
27421         Symbol = context.Symbol,
27422         Uint8Array = context.Uint8Array,
27423         allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
27424         getPrototype = overArg(Object.getPrototypeOf, Object),
27425         objectCreate = Object.create,
27426         propertyIsEnumerable = objectProto.propertyIsEnumerable,
27427         splice = arrayProto.splice,
27428         spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
27429         symIterator = Symbol ? Symbol.iterator : undefined,
27430         symToStringTag = Symbol ? Symbol.toStringTag : undefined;
27431
27432     var defineProperty = (function() {
27433       try {
27434         var func = getNative(Object, 'defineProperty');
27435         func({}, '', {});
27436         return func;
27437       } catch (e) {}
27438     }());
27439
27440     /** Mocked built-ins. */
27441     var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
27442         ctxNow = Date && Date.now !== root.Date.now && Date.now,
27443         ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
27444
27445     /* Built-in method references for those with the same name as other `lodash` methods. */
27446     var nativeCeil = Math.ceil,
27447         nativeFloor = Math.floor,
27448         nativeGetSymbols = Object.getOwnPropertySymbols,
27449         nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
27450         nativeIsFinite = context.isFinite,
27451         nativeJoin = arrayProto.join,
27452         nativeKeys = overArg(Object.keys, Object),
27453         nativeMax = Math.max,
27454         nativeMin = Math.min,
27455         nativeNow = Date.now,
27456         nativeParseInt = context.parseInt,
27457         nativeRandom = Math.random,
27458         nativeReverse = arrayProto.reverse;
27459
27460     /* Built-in method references that are verified to be native. */
27461     var DataView = getNative(context, 'DataView'),
27462         Map = getNative(context, 'Map'),
27463         Promise = getNative(context, 'Promise'),
27464         Set = getNative(context, 'Set'),
27465         WeakMap = getNative(context, 'WeakMap'),
27466         nativeCreate = getNative(Object, 'create');
27467
27468     /** Used to store function metadata. */
27469     var metaMap = WeakMap && new WeakMap;
27470
27471     /** Used to lookup unminified function names. */
27472     var realNames = {};
27473
27474     /** Used to detect maps, sets, and weakmaps. */
27475     var dataViewCtorString = toSource(DataView),
27476         mapCtorString = toSource(Map),
27477         promiseCtorString = toSource(Promise),
27478         setCtorString = toSource(Set),
27479         weakMapCtorString = toSource(WeakMap);
27480
27481     /** Used to convert symbols to primitives and strings. */
27482     var symbolProto = Symbol ? Symbol.prototype : undefined,
27483         symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
27484         symbolToString = symbolProto ? symbolProto.toString : undefined;
27485
27486     /*------------------------------------------------------------------------*/
27487
27488     /**
27489      * Creates a `lodash` object which wraps `value` to enable implicit method
27490      * chain sequences. Methods that operate on and return arrays, collections,
27491      * and functions can be chained together. Methods that retrieve a single value
27492      * or may return a primitive value will automatically end the chain sequence
27493      * and return the unwrapped value. Otherwise, the value must be unwrapped
27494      * with `_#value`.
27495      *
27496      * Explicit chain sequences, which must be unwrapped with `_#value`, may be
27497      * enabled using `_.chain`.
27498      *
27499      * The execution of chained methods is lazy, that is, it's deferred until
27500      * `_#value` is implicitly or explicitly called.
27501      *
27502      * Lazy evaluation allows several methods to support shortcut fusion.
27503      * Shortcut fusion is an optimization to merge iteratee calls; this avoids
27504      * the creation of intermediate arrays and can greatly reduce the number of
27505      * iteratee executions. Sections of a chain sequence qualify for shortcut
27506      * fusion if the section is applied to an array and iteratees accept only
27507      * one argument. The heuristic for whether a section qualifies for shortcut
27508      * fusion is subject to change.
27509      *
27510      * Chaining is supported in custom builds as long as the `_#value` method is
27511      * directly or indirectly included in the build.
27512      *
27513      * In addition to lodash methods, wrappers have `Array` and `String` methods.
27514      *
27515      * The wrapper `Array` methods are:
27516      * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
27517      *
27518      * The wrapper `String` methods are:
27519      * `replace` and `split`
27520      *
27521      * The wrapper methods that support shortcut fusion are:
27522      * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
27523      * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
27524      * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
27525      *
27526      * The chainable wrapper methods are:
27527      * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
27528      * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
27529      * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
27530      * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
27531      * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
27532      * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
27533      * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
27534      * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
27535      * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
27536      * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
27537      * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
27538      * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
27539      * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
27540      * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
27541      * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
27542      * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
27543      * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
27544      * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
27545      * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
27546      * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
27547      * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
27548      * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
27549      * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
27550      * `zipObject`, `zipObjectDeep`, and `zipWith`
27551      *
27552      * The wrapper methods that are **not** chainable by default are:
27553      * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
27554      * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
27555      * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
27556      * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
27557      * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
27558      * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
27559      * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
27560      * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
27561      * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
27562      * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
27563      * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
27564      * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
27565      * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
27566      * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
27567      * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
27568      * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
27569      * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
27570      * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
27571      * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
27572      * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
27573      * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
27574      * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
27575      * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
27576      * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
27577      * `upperFirst`, `value`, and `words`
27578      *
27579      * @name _
27580      * @constructor
27581      * @category Seq
27582      * @param {*} value The value to wrap in a `lodash` instance.
27583      * @returns {Object} Returns the new `lodash` wrapper instance.
27584      * @example
27585      *
27586      * function square(n) {
27587      *   return n * n;
27588      * }
27589      *
27590      * var wrapped = _([1, 2, 3]);
27591      *
27592      * // Returns an unwrapped value.
27593      * wrapped.reduce(_.add);
27594      * // => 6
27595      *
27596      * // Returns a wrapped value.
27597      * var squares = wrapped.map(square);
27598      *
27599      * _.isArray(squares);
27600      * // => false
27601      *
27602      * _.isArray(squares.value());
27603      * // => true
27604      */
27605     function lodash(value) {
27606       if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
27607         if (value instanceof LodashWrapper) {
27608           return value;
27609         }
27610         if (hasOwnProperty.call(value, '__wrapped__')) {
27611           return wrapperClone(value);
27612         }
27613       }
27614       return new LodashWrapper(value);
27615     }
27616
27617     /**
27618      * The base implementation of `_.create` without support for assigning
27619      * properties to the created object.
27620      *
27621      * @private
27622      * @param {Object} proto The object to inherit from.
27623      * @returns {Object} Returns the new object.
27624      */
27625     var baseCreate = (function() {
27626       function object() {}
27627       return function(proto) {
27628         if (!isObject(proto)) {
27629           return {};
27630         }
27631         if (objectCreate) {
27632           return objectCreate(proto);
27633         }
27634         object.prototype = proto;
27635         var result = new object;
27636         object.prototype = undefined;
27637         return result;
27638       };
27639     }());
27640
27641     /**
27642      * The function whose prototype chain sequence wrappers inherit from.
27643      *
27644      * @private
27645      */
27646     function baseLodash() {
27647       // No operation performed.
27648     }
27649
27650     /**
27651      * The base constructor for creating `lodash` wrapper objects.
27652      *
27653      * @private
27654      * @param {*} value The value to wrap.
27655      * @param {boolean} [chainAll] Enable explicit method chain sequences.
27656      */
27657     function LodashWrapper(value, chainAll) {
27658       this.__wrapped__ = value;
27659       this.__actions__ = [];
27660       this.__chain__ = !!chainAll;
27661       this.__index__ = 0;
27662       this.__values__ = undefined;
27663     }
27664
27665     /**
27666      * By default, the template delimiters used by lodash are like those in
27667      * embedded Ruby (ERB) as well as ES2015 template strings. Change the
27668      * following template settings to use alternative delimiters.
27669      *
27670      * @static
27671      * @memberOf _
27672      * @type {Object}
27673      */
27674     lodash.templateSettings = {
27675
27676       /**
27677        * Used to detect `data` property values to be HTML-escaped.
27678        *
27679        * @memberOf _.templateSettings
27680        * @type {RegExp}
27681        */
27682       'escape': reEscape,
27683
27684       /**
27685        * Used to detect code to be evaluated.
27686        *
27687        * @memberOf _.templateSettings
27688        * @type {RegExp}
27689        */
27690       'evaluate': reEvaluate,
27691
27692       /**
27693        * Used to detect `data` property values to inject.
27694        *
27695        * @memberOf _.templateSettings
27696        * @type {RegExp}
27697        */
27698       'interpolate': reInterpolate,
27699
27700       /**
27701        * Used to reference the data object in the template text.
27702        *
27703        * @memberOf _.templateSettings
27704        * @type {string}
27705        */
27706       'variable': '',
27707
27708       /**
27709        * Used to import variables into the compiled template.
27710        *
27711        * @memberOf _.templateSettings
27712        * @type {Object}
27713        */
27714       'imports': {
27715
27716         /**
27717          * A reference to the `lodash` function.
27718          *
27719          * @memberOf _.templateSettings.imports
27720          * @type {Function}
27721          */
27722         '_': lodash
27723       }
27724     };
27725
27726     // Ensure wrappers are instances of `baseLodash`.
27727     lodash.prototype = baseLodash.prototype;
27728     lodash.prototype.constructor = lodash;
27729
27730     LodashWrapper.prototype = baseCreate(baseLodash.prototype);
27731     LodashWrapper.prototype.constructor = LodashWrapper;
27732
27733     /*------------------------------------------------------------------------*/
27734
27735     /**
27736      * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
27737      *
27738      * @private
27739      * @constructor
27740      * @param {*} value The value to wrap.
27741      */
27742     function LazyWrapper(value) {
27743       this.__wrapped__ = value;
27744       this.__actions__ = [];
27745       this.__dir__ = 1;
27746       this.__filtered__ = false;
27747       this.__iteratees__ = [];
27748       this.__takeCount__ = MAX_ARRAY_LENGTH;
27749       this.__views__ = [];
27750     }
27751
27752     /**
27753      * Creates a clone of the lazy wrapper object.
27754      *
27755      * @private
27756      * @name clone
27757      * @memberOf LazyWrapper
27758      * @returns {Object} Returns the cloned `LazyWrapper` object.
27759      */
27760     function lazyClone() {
27761       var result = new LazyWrapper(this.__wrapped__);
27762       result.__actions__ = copyArray(this.__actions__);
27763       result.__dir__ = this.__dir__;
27764       result.__filtered__ = this.__filtered__;
27765       result.__iteratees__ = copyArray(this.__iteratees__);
27766       result.__takeCount__ = this.__takeCount__;
27767       result.__views__ = copyArray(this.__views__);
27768       return result;
27769     }
27770
27771     /**
27772      * Reverses the direction of lazy iteration.
27773      *
27774      * @private
27775      * @name reverse
27776      * @memberOf LazyWrapper
27777      * @returns {Object} Returns the new reversed `LazyWrapper` object.
27778      */
27779     function lazyReverse() {
27780       if (this.__filtered__) {
27781         var result = new LazyWrapper(this);
27782         result.__dir__ = -1;
27783         result.__filtered__ = true;
27784       } else {
27785         result = this.clone();
27786         result.__dir__ *= -1;
27787       }
27788       return result;
27789     }
27790
27791     /**
27792      * Extracts the unwrapped value from its lazy wrapper.
27793      *
27794      * @private
27795      * @name value
27796      * @memberOf LazyWrapper
27797      * @returns {*} Returns the unwrapped value.
27798      */
27799     function lazyValue() {
27800       var array = this.__wrapped__.value(),
27801           dir = this.__dir__,
27802           isArr = isArray(array),
27803           isRight = dir < 0,
27804           arrLength = isArr ? array.length : 0,
27805           view = getView(0, arrLength, this.__views__),
27806           start = view.start,
27807           end = view.end,
27808           length = end - start,
27809           index = isRight ? end : (start - 1),
27810           iteratees = this.__iteratees__,
27811           iterLength = iteratees.length,
27812           resIndex = 0,
27813           takeCount = nativeMin(length, this.__takeCount__);
27814
27815       if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
27816         return baseWrapperValue(array, this.__actions__);
27817       }
27818       var result = [];
27819
27820       outer:
27821       while (length-- && resIndex < takeCount) {
27822         index += dir;
27823
27824         var iterIndex = -1,
27825             value = array[index];
27826
27827         while (++iterIndex < iterLength) {
27828           var data = iteratees[iterIndex],
27829               iteratee = data.iteratee,
27830               type = data.type,
27831               computed = iteratee(value);
27832
27833           if (type == LAZY_MAP_FLAG) {
27834             value = computed;
27835           } else if (!computed) {
27836             if (type == LAZY_FILTER_FLAG) {
27837               continue outer;
27838             } else {
27839               break outer;
27840             }
27841           }
27842         }
27843         result[resIndex++] = value;
27844       }
27845       return result;
27846     }
27847
27848     // Ensure `LazyWrapper` is an instance of `baseLodash`.
27849     LazyWrapper.prototype = baseCreate(baseLodash.prototype);
27850     LazyWrapper.prototype.constructor = LazyWrapper;
27851
27852     /*------------------------------------------------------------------------*/
27853
27854     /**
27855      * Creates a hash object.
27856      *
27857      * @private
27858      * @constructor
27859      * @param {Array} [entries] The key-value pairs to cache.
27860      */
27861     function Hash(entries) {
27862       var index = -1,
27863           length = entries == null ? 0 : entries.length;
27864
27865       this.clear();
27866       while (++index < length) {
27867         var entry = entries[index];
27868         this.set(entry[0], entry[1]);
27869       }
27870     }
27871
27872     /**
27873      * Removes all key-value entries from the hash.
27874      *
27875      * @private
27876      * @name clear
27877      * @memberOf Hash
27878      */
27879     function hashClear() {
27880       this.__data__ = nativeCreate ? nativeCreate(null) : {};
27881       this.size = 0;
27882     }
27883
27884     /**
27885      * Removes `key` and its value from the hash.
27886      *
27887      * @private
27888      * @name delete
27889      * @memberOf Hash
27890      * @param {Object} hash The hash to modify.
27891      * @param {string} key The key of the value to remove.
27892      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
27893      */
27894     function hashDelete(key) {
27895       var result = this.has(key) && delete this.__data__[key];
27896       this.size -= result ? 1 : 0;
27897       return result;
27898     }
27899
27900     /**
27901      * Gets the hash value for `key`.
27902      *
27903      * @private
27904      * @name get
27905      * @memberOf Hash
27906      * @param {string} key The key of the value to get.
27907      * @returns {*} Returns the entry value.
27908      */
27909     function hashGet(key) {
27910       var data = this.__data__;
27911       if (nativeCreate) {
27912         var result = data[key];
27913         return result === HASH_UNDEFINED ? undefined : result;
27914       }
27915       return hasOwnProperty.call(data, key) ? data[key] : undefined;
27916     }
27917
27918     /**
27919      * Checks if a hash value for `key` exists.
27920      *
27921      * @private
27922      * @name has
27923      * @memberOf Hash
27924      * @param {string} key The key of the entry to check.
27925      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
27926      */
27927     function hashHas(key) {
27928       var data = this.__data__;
27929       return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
27930     }
27931
27932     /**
27933      * Sets the hash `key` to `value`.
27934      *
27935      * @private
27936      * @name set
27937      * @memberOf Hash
27938      * @param {string} key The key of the value to set.
27939      * @param {*} value The value to set.
27940      * @returns {Object} Returns the hash instance.
27941      */
27942     function hashSet(key, value) {
27943       var data = this.__data__;
27944       this.size += this.has(key) ? 0 : 1;
27945       data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
27946       return this;
27947     }
27948
27949     // Add methods to `Hash`.
27950     Hash.prototype.clear = hashClear;
27951     Hash.prototype['delete'] = hashDelete;
27952     Hash.prototype.get = hashGet;
27953     Hash.prototype.has = hashHas;
27954     Hash.prototype.set = hashSet;
27955
27956     /*------------------------------------------------------------------------*/
27957
27958     /**
27959      * Creates an list cache object.
27960      *
27961      * @private
27962      * @constructor
27963      * @param {Array} [entries] The key-value pairs to cache.
27964      */
27965     function ListCache(entries) {
27966       var index = -1,
27967           length = entries == null ? 0 : entries.length;
27968
27969       this.clear();
27970       while (++index < length) {
27971         var entry = entries[index];
27972         this.set(entry[0], entry[1]);
27973       }
27974     }
27975
27976     /**
27977      * Removes all key-value entries from the list cache.
27978      *
27979      * @private
27980      * @name clear
27981      * @memberOf ListCache
27982      */
27983     function listCacheClear() {
27984       this.__data__ = [];
27985       this.size = 0;
27986     }
27987
27988     /**
27989      * Removes `key` and its value from the list cache.
27990      *
27991      * @private
27992      * @name delete
27993      * @memberOf ListCache
27994      * @param {string} key The key of the value to remove.
27995      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
27996      */
27997     function listCacheDelete(key) {
27998       var data = this.__data__,
27999           index = assocIndexOf(data, key);
28000
28001       if (index < 0) {
28002         return false;
28003       }
28004       var lastIndex = data.length - 1;
28005       if (index == lastIndex) {
28006         data.pop();
28007       } else {
28008         splice.call(data, index, 1);
28009       }
28010       --this.size;
28011       return true;
28012     }
28013
28014     /**
28015      * Gets the list cache value for `key`.
28016      *
28017      * @private
28018      * @name get
28019      * @memberOf ListCache
28020      * @param {string} key The key of the value to get.
28021      * @returns {*} Returns the entry value.
28022      */
28023     function listCacheGet(key) {
28024       var data = this.__data__,
28025           index = assocIndexOf(data, key);
28026
28027       return index < 0 ? undefined : data[index][1];
28028     }
28029
28030     /**
28031      * Checks if a list cache value for `key` exists.
28032      *
28033      * @private
28034      * @name has
28035      * @memberOf ListCache
28036      * @param {string} key The key of the entry to check.
28037      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28038      */
28039     function listCacheHas(key) {
28040       return assocIndexOf(this.__data__, key) > -1;
28041     }
28042
28043     /**
28044      * Sets the list cache `key` to `value`.
28045      *
28046      * @private
28047      * @name set
28048      * @memberOf ListCache
28049      * @param {string} key The key of the value to set.
28050      * @param {*} value The value to set.
28051      * @returns {Object} Returns the list cache instance.
28052      */
28053     function listCacheSet(key, value) {
28054       var data = this.__data__,
28055           index = assocIndexOf(data, key);
28056
28057       if (index < 0) {
28058         ++this.size;
28059         data.push([key, value]);
28060       } else {
28061         data[index][1] = value;
28062       }
28063       return this;
28064     }
28065
28066     // Add methods to `ListCache`.
28067     ListCache.prototype.clear = listCacheClear;
28068     ListCache.prototype['delete'] = listCacheDelete;
28069     ListCache.prototype.get = listCacheGet;
28070     ListCache.prototype.has = listCacheHas;
28071     ListCache.prototype.set = listCacheSet;
28072
28073     /*------------------------------------------------------------------------*/
28074
28075     /**
28076      * Creates a map cache object to store key-value pairs.
28077      *
28078      * @private
28079      * @constructor
28080      * @param {Array} [entries] The key-value pairs to cache.
28081      */
28082     function MapCache(entries) {
28083       var index = -1,
28084           length = entries == null ? 0 : entries.length;
28085
28086       this.clear();
28087       while (++index < length) {
28088         var entry = entries[index];
28089         this.set(entry[0], entry[1]);
28090       }
28091     }
28092
28093     /**
28094      * Removes all key-value entries from the map.
28095      *
28096      * @private
28097      * @name clear
28098      * @memberOf MapCache
28099      */
28100     function mapCacheClear() {
28101       this.size = 0;
28102       this.__data__ = {
28103         'hash': new Hash,
28104         'map': new (Map || ListCache),
28105         'string': new Hash
28106       };
28107     }
28108
28109     /**
28110      * Removes `key` and its value from the map.
28111      *
28112      * @private
28113      * @name delete
28114      * @memberOf MapCache
28115      * @param {string} key The key of the value to remove.
28116      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
28117      */
28118     function mapCacheDelete(key) {
28119       var result = getMapData(this, key)['delete'](key);
28120       this.size -= result ? 1 : 0;
28121       return result;
28122     }
28123
28124     /**
28125      * Gets the map value for `key`.
28126      *
28127      * @private
28128      * @name get
28129      * @memberOf MapCache
28130      * @param {string} key The key of the value to get.
28131      * @returns {*} Returns the entry value.
28132      */
28133     function mapCacheGet(key) {
28134       return getMapData(this, key).get(key);
28135     }
28136
28137     /**
28138      * Checks if a map value for `key` exists.
28139      *
28140      * @private
28141      * @name has
28142      * @memberOf MapCache
28143      * @param {string} key The key of the entry to check.
28144      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28145      */
28146     function mapCacheHas(key) {
28147       return getMapData(this, key).has(key);
28148     }
28149
28150     /**
28151      * Sets the map `key` to `value`.
28152      *
28153      * @private
28154      * @name set
28155      * @memberOf MapCache
28156      * @param {string} key The key of the value to set.
28157      * @param {*} value The value to set.
28158      * @returns {Object} Returns the map cache instance.
28159      */
28160     function mapCacheSet(key, value) {
28161       var data = getMapData(this, key),
28162           size = data.size;
28163
28164       data.set(key, value);
28165       this.size += data.size == size ? 0 : 1;
28166       return this;
28167     }
28168
28169     // Add methods to `MapCache`.
28170     MapCache.prototype.clear = mapCacheClear;
28171     MapCache.prototype['delete'] = mapCacheDelete;
28172     MapCache.prototype.get = mapCacheGet;
28173     MapCache.prototype.has = mapCacheHas;
28174     MapCache.prototype.set = mapCacheSet;
28175
28176     /*------------------------------------------------------------------------*/
28177
28178     /**
28179      *
28180      * Creates an array cache object to store unique values.
28181      *
28182      * @private
28183      * @constructor
28184      * @param {Array} [values] The values to cache.
28185      */
28186     function SetCache(values) {
28187       var index = -1,
28188           length = values == null ? 0 : values.length;
28189
28190       this.__data__ = new MapCache;
28191       while (++index < length) {
28192         this.add(values[index]);
28193       }
28194     }
28195
28196     /**
28197      * Adds `value` to the array cache.
28198      *
28199      * @private
28200      * @name add
28201      * @memberOf SetCache
28202      * @alias push
28203      * @param {*} value The value to cache.
28204      * @returns {Object} Returns the cache instance.
28205      */
28206     function setCacheAdd(value) {
28207       this.__data__.set(value, HASH_UNDEFINED);
28208       return this;
28209     }
28210
28211     /**
28212      * Checks if `value` is in the array cache.
28213      *
28214      * @private
28215      * @name has
28216      * @memberOf SetCache
28217      * @param {*} value The value to search for.
28218      * @returns {number} Returns `true` if `value` is found, else `false`.
28219      */
28220     function setCacheHas(value) {
28221       return this.__data__.has(value);
28222     }
28223
28224     // Add methods to `SetCache`.
28225     SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
28226     SetCache.prototype.has = setCacheHas;
28227
28228     /*------------------------------------------------------------------------*/
28229
28230     /**
28231      * Creates a stack cache object to store key-value pairs.
28232      *
28233      * @private
28234      * @constructor
28235      * @param {Array} [entries] The key-value pairs to cache.
28236      */
28237     function Stack(entries) {
28238       var data = this.__data__ = new ListCache(entries);
28239       this.size = data.size;
28240     }
28241
28242     /**
28243      * Removes all key-value entries from the stack.
28244      *
28245      * @private
28246      * @name clear
28247      * @memberOf Stack
28248      */
28249     function stackClear() {
28250       this.__data__ = new ListCache;
28251       this.size = 0;
28252     }
28253
28254     /**
28255      * Removes `key` and its value from the stack.
28256      *
28257      * @private
28258      * @name delete
28259      * @memberOf Stack
28260      * @param {string} key The key of the value to remove.
28261      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
28262      */
28263     function stackDelete(key) {
28264       var data = this.__data__,
28265           result = data['delete'](key);
28266
28267       this.size = data.size;
28268       return result;
28269     }
28270
28271     /**
28272      * Gets the stack value for `key`.
28273      *
28274      * @private
28275      * @name get
28276      * @memberOf Stack
28277      * @param {string} key The key of the value to get.
28278      * @returns {*} Returns the entry value.
28279      */
28280     function stackGet(key) {
28281       return this.__data__.get(key);
28282     }
28283
28284     /**
28285      * Checks if a stack value for `key` exists.
28286      *
28287      * @private
28288      * @name has
28289      * @memberOf Stack
28290      * @param {string} key The key of the entry to check.
28291      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28292      */
28293     function stackHas(key) {
28294       return this.__data__.has(key);
28295     }
28296
28297     /**
28298      * Sets the stack `key` to `value`.
28299      *
28300      * @private
28301      * @name set
28302      * @memberOf Stack
28303      * @param {string} key The key of the value to set.
28304      * @param {*} value The value to set.
28305      * @returns {Object} Returns the stack cache instance.
28306      */
28307     function stackSet(key, value) {
28308       var data = this.__data__;
28309       if (data instanceof ListCache) {
28310         var pairs = data.__data__;
28311         if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
28312           pairs.push([key, value]);
28313           this.size = ++data.size;
28314           return this;
28315         }
28316         data = this.__data__ = new MapCache(pairs);
28317       }
28318       data.set(key, value);
28319       this.size = data.size;
28320       return this;
28321     }
28322
28323     // Add methods to `Stack`.
28324     Stack.prototype.clear = stackClear;
28325     Stack.prototype['delete'] = stackDelete;
28326     Stack.prototype.get = stackGet;
28327     Stack.prototype.has = stackHas;
28328     Stack.prototype.set = stackSet;
28329
28330     /*------------------------------------------------------------------------*/
28331
28332     /**
28333      * Creates an array of the enumerable property names of the array-like `value`.
28334      *
28335      * @private
28336      * @param {*} value The value to query.
28337      * @param {boolean} inherited Specify returning inherited property names.
28338      * @returns {Array} Returns the array of property names.
28339      */
28340     function arrayLikeKeys(value, inherited) {
28341       var isArr = isArray(value),
28342           isArg = !isArr && isArguments(value),
28343           isBuff = !isArr && !isArg && isBuffer(value),
28344           isType = !isArr && !isArg && !isBuff && isTypedArray(value),
28345           skipIndexes = isArr || isArg || isBuff || isType,
28346           result = skipIndexes ? baseTimes(value.length, String) : [],
28347           length = result.length;
28348
28349       for (var key in value) {
28350         if ((inherited || hasOwnProperty.call(value, key)) &&
28351             !(skipIndexes && (
28352                // Safari 9 has enumerable `arguments.length` in strict mode.
28353                key == 'length' ||
28354                // Node.js 0.10 has enumerable non-index properties on buffers.
28355                (isBuff && (key == 'offset' || key == 'parent')) ||
28356                // PhantomJS 2 has enumerable non-index properties on typed arrays.
28357                (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
28358                // Skip index properties.
28359                isIndex(key, length)
28360             ))) {
28361           result.push(key);
28362         }
28363       }
28364       return result;
28365     }
28366
28367     /**
28368      * A specialized version of `_.sample` for arrays.
28369      *
28370      * @private
28371      * @param {Array} array The array to sample.
28372      * @returns {*} Returns the random element.
28373      */
28374     function arraySample(array) {
28375       var length = array.length;
28376       return length ? array[baseRandom(0, length - 1)] : undefined;
28377     }
28378
28379     /**
28380      * A specialized version of `_.sampleSize` for arrays.
28381      *
28382      * @private
28383      * @param {Array} array The array to sample.
28384      * @param {number} n The number of elements to sample.
28385      * @returns {Array} Returns the random elements.
28386      */
28387     function arraySampleSize(array, n) {
28388       return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
28389     }
28390
28391     /**
28392      * A specialized version of `_.shuffle` for arrays.
28393      *
28394      * @private
28395      * @param {Array} array The array to shuffle.
28396      * @returns {Array} Returns the new shuffled array.
28397      */
28398     function arrayShuffle(array) {
28399       return shuffleSelf(copyArray(array));
28400     }
28401
28402     /**
28403      * This function is like `assignValue` except that it doesn't assign
28404      * `undefined` values.
28405      *
28406      * @private
28407      * @param {Object} object The object to modify.
28408      * @param {string} key The key of the property to assign.
28409      * @param {*} value The value to assign.
28410      */
28411     function assignMergeValue(object, key, value) {
28412       if ((value !== undefined && !eq(object[key], value)) ||
28413           (value === undefined && !(key in object))) {
28414         baseAssignValue(object, key, value);
28415       }
28416     }
28417
28418     /**
28419      * Assigns `value` to `key` of `object` if the existing value is not equivalent
28420      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
28421      * for equality comparisons.
28422      *
28423      * @private
28424      * @param {Object} object The object to modify.
28425      * @param {string} key The key of the property to assign.
28426      * @param {*} value The value to assign.
28427      */
28428     function assignValue(object, key, value) {
28429       var objValue = object[key];
28430       if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
28431           (value === undefined && !(key in object))) {
28432         baseAssignValue(object, key, value);
28433       }
28434     }
28435
28436     /**
28437      * Gets the index at which the `key` is found in `array` of key-value pairs.
28438      *
28439      * @private
28440      * @param {Array} array The array to inspect.
28441      * @param {*} key The key to search for.
28442      * @returns {number} Returns the index of the matched value, else `-1`.
28443      */
28444     function assocIndexOf(array, key) {
28445       var length = array.length;
28446       while (length--) {
28447         if (eq(array[length][0], key)) {
28448           return length;
28449         }
28450       }
28451       return -1;
28452     }
28453
28454     /**
28455      * Aggregates elements of `collection` on `accumulator` with keys transformed
28456      * by `iteratee` and values set by `setter`.
28457      *
28458      * @private
28459      * @param {Array|Object} collection The collection to iterate over.
28460      * @param {Function} setter The function to set `accumulator` values.
28461      * @param {Function} iteratee The iteratee to transform keys.
28462      * @param {Object} accumulator The initial aggregated object.
28463      * @returns {Function} Returns `accumulator`.
28464      */
28465     function baseAggregator(collection, setter, iteratee, accumulator) {
28466       baseEach(collection, function(value, key, collection) {
28467         setter(accumulator, value, iteratee(value), collection);
28468       });
28469       return accumulator;
28470     }
28471
28472     /**
28473      * The base implementation of `_.assign` without support for multiple sources
28474      * or `customizer` functions.
28475      *
28476      * @private
28477      * @param {Object} object The destination object.
28478      * @param {Object} source The source object.
28479      * @returns {Object} Returns `object`.
28480      */
28481     function baseAssign(object, source) {
28482       return object && copyObject(source, keys(source), object);
28483     }
28484
28485     /**
28486      * The base implementation of `_.assignIn` without support for multiple sources
28487      * or `customizer` functions.
28488      *
28489      * @private
28490      * @param {Object} object The destination object.
28491      * @param {Object} source The source object.
28492      * @returns {Object} Returns `object`.
28493      */
28494     function baseAssignIn(object, source) {
28495       return object && copyObject(source, keysIn(source), object);
28496     }
28497
28498     /**
28499      * The base implementation of `assignValue` and `assignMergeValue` without
28500      * value checks.
28501      *
28502      * @private
28503      * @param {Object} object The object to modify.
28504      * @param {string} key The key of the property to assign.
28505      * @param {*} value The value to assign.
28506      */
28507     function baseAssignValue(object, key, value) {
28508       if (key == '__proto__' && defineProperty) {
28509         defineProperty(object, key, {
28510           'configurable': true,
28511           'enumerable': true,
28512           'value': value,
28513           'writable': true
28514         });
28515       } else {
28516         object[key] = value;
28517       }
28518     }
28519
28520     /**
28521      * The base implementation of `_.at` without support for individual paths.
28522      *
28523      * @private
28524      * @param {Object} object The object to iterate over.
28525      * @param {string[]} paths The property paths to pick.
28526      * @returns {Array} Returns the picked elements.
28527      */
28528     function baseAt(object, paths) {
28529       var index = -1,
28530           length = paths.length,
28531           result = Array(length),
28532           skip = object == null;
28533
28534       while (++index < length) {
28535         result[index] = skip ? undefined : get(object, paths[index]);
28536       }
28537       return result;
28538     }
28539
28540     /**
28541      * The base implementation of `_.clamp` which doesn't coerce arguments.
28542      *
28543      * @private
28544      * @param {number} number The number to clamp.
28545      * @param {number} [lower] The lower bound.
28546      * @param {number} upper The upper bound.
28547      * @returns {number} Returns the clamped number.
28548      */
28549     function baseClamp(number, lower, upper) {
28550       if (number === number) {
28551         if (upper !== undefined) {
28552           number = number <= upper ? number : upper;
28553         }
28554         if (lower !== undefined) {
28555           number = number >= lower ? number : lower;
28556         }
28557       }
28558       return number;
28559     }
28560
28561     /**
28562      * The base implementation of `_.clone` and `_.cloneDeep` which tracks
28563      * traversed objects.
28564      *
28565      * @private
28566      * @param {*} value The value to clone.
28567      * @param {boolean} bitmask The bitmask flags.
28568      *  1 - Deep clone
28569      *  2 - Flatten inherited properties
28570      *  4 - Clone symbols
28571      * @param {Function} [customizer] The function to customize cloning.
28572      * @param {string} [key] The key of `value`.
28573      * @param {Object} [object] The parent object of `value`.
28574      * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
28575      * @returns {*} Returns the cloned value.
28576      */
28577     function baseClone(value, bitmask, customizer, key, object, stack) {
28578       var result,
28579           isDeep = bitmask & CLONE_DEEP_FLAG,
28580           isFlat = bitmask & CLONE_FLAT_FLAG,
28581           isFull = bitmask & CLONE_SYMBOLS_FLAG;
28582
28583       if (customizer) {
28584         result = object ? customizer(value, key, object, stack) : customizer(value);
28585       }
28586       if (result !== undefined) {
28587         return result;
28588       }
28589       if (!isObject(value)) {
28590         return value;
28591       }
28592       var isArr = isArray(value);
28593       if (isArr) {
28594         result = initCloneArray(value);
28595         if (!isDeep) {
28596           return copyArray(value, result);
28597         }
28598       } else {
28599         var tag = getTag(value),
28600             isFunc = tag == funcTag || tag == genTag;
28601
28602         if (isBuffer(value)) {
28603           return cloneBuffer(value, isDeep);
28604         }
28605         if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
28606           result = (isFlat || isFunc) ? {} : initCloneObject(value);
28607           if (!isDeep) {
28608             return isFlat
28609               ? copySymbolsIn(value, baseAssignIn(result, value))
28610               : copySymbols(value, baseAssign(result, value));
28611           }
28612         } else {
28613           if (!cloneableTags[tag]) {
28614             return object ? value : {};
28615           }
28616           result = initCloneByTag(value, tag, isDeep);
28617         }
28618       }
28619       // Check for circular references and return its corresponding clone.
28620       stack || (stack = new Stack);
28621       var stacked = stack.get(value);
28622       if (stacked) {
28623         return stacked;
28624       }
28625       stack.set(value, result);
28626
28627       if (isSet(value)) {
28628         value.forEach(function(subValue) {
28629           result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
28630         });
28631       } else if (isMap(value)) {
28632         value.forEach(function(subValue, key) {
28633           result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
28634         });
28635       }
28636
28637       var keysFunc = isFull
28638         ? (isFlat ? getAllKeysIn : getAllKeys)
28639         : (isFlat ? keysIn : keys);
28640
28641       var props = isArr ? undefined : keysFunc(value);
28642       arrayEach(props || value, function(subValue, key) {
28643         if (props) {
28644           key = subValue;
28645           subValue = value[key];
28646         }
28647         // Recursively populate clone (susceptible to call stack limits).
28648         assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
28649       });
28650       return result;
28651     }
28652
28653     /**
28654      * The base implementation of `_.conforms` which doesn't clone `source`.
28655      *
28656      * @private
28657      * @param {Object} source The object of property predicates to conform to.
28658      * @returns {Function} Returns the new spec function.
28659      */
28660     function baseConforms(source) {
28661       var props = keys(source);
28662       return function(object) {
28663         return baseConformsTo(object, source, props);
28664       };
28665     }
28666
28667     /**
28668      * The base implementation of `_.conformsTo` which accepts `props` to check.
28669      *
28670      * @private
28671      * @param {Object} object The object to inspect.
28672      * @param {Object} source The object of property predicates to conform to.
28673      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
28674      */
28675     function baseConformsTo(object, source, props) {
28676       var length = props.length;
28677       if (object == null) {
28678         return !length;
28679       }
28680       object = Object(object);
28681       while (length--) {
28682         var key = props[length],
28683             predicate = source[key],
28684             value = object[key];
28685
28686         if ((value === undefined && !(key in object)) || !predicate(value)) {
28687           return false;
28688         }
28689       }
28690       return true;
28691     }
28692
28693     /**
28694      * The base implementation of `_.delay` and `_.defer` which accepts `args`
28695      * to provide to `func`.
28696      *
28697      * @private
28698      * @param {Function} func The function to delay.
28699      * @param {number} wait The number of milliseconds to delay invocation.
28700      * @param {Array} args The arguments to provide to `func`.
28701      * @returns {number|Object} Returns the timer id or timeout object.
28702      */
28703     function baseDelay(func, wait, args) {
28704       if (typeof func != 'function') {
28705         throw new TypeError(FUNC_ERROR_TEXT);
28706       }
28707       return setTimeout(function() { func.apply(undefined, args); }, wait);
28708     }
28709
28710     /**
28711      * The base implementation of methods like `_.difference` without support
28712      * for excluding multiple arrays or iteratee shorthands.
28713      *
28714      * @private
28715      * @param {Array} array The array to inspect.
28716      * @param {Array} values The values to exclude.
28717      * @param {Function} [iteratee] The iteratee invoked per element.
28718      * @param {Function} [comparator] The comparator invoked per element.
28719      * @returns {Array} Returns the new array of filtered values.
28720      */
28721     function baseDifference(array, values, iteratee, comparator) {
28722       var index = -1,
28723           includes = arrayIncludes,
28724           isCommon = true,
28725           length = array.length,
28726           result = [],
28727           valuesLength = values.length;
28728
28729       if (!length) {
28730         return result;
28731       }
28732       if (iteratee) {
28733         values = arrayMap(values, baseUnary(iteratee));
28734       }
28735       if (comparator) {
28736         includes = arrayIncludesWith;
28737         isCommon = false;
28738       }
28739       else if (values.length >= LARGE_ARRAY_SIZE) {
28740         includes = cacheHas;
28741         isCommon = false;
28742         values = new SetCache(values);
28743       }
28744       outer:
28745       while (++index < length) {
28746         var value = array[index],
28747             computed = iteratee == null ? value : iteratee(value);
28748
28749         value = (comparator || value !== 0) ? value : 0;
28750         if (isCommon && computed === computed) {
28751           var valuesIndex = valuesLength;
28752           while (valuesIndex--) {
28753             if (values[valuesIndex] === computed) {
28754               continue outer;
28755             }
28756           }
28757           result.push(value);
28758         }
28759         else if (!includes(values, computed, comparator)) {
28760           result.push(value);
28761         }
28762       }
28763       return result;
28764     }
28765
28766     /**
28767      * The base implementation of `_.forEach` without support for iteratee shorthands.
28768      *
28769      * @private
28770      * @param {Array|Object} collection The collection to iterate over.
28771      * @param {Function} iteratee The function invoked per iteration.
28772      * @returns {Array|Object} Returns `collection`.
28773      */
28774     var baseEach = createBaseEach(baseForOwn);
28775
28776     /**
28777      * The base implementation of `_.forEachRight` without support for iteratee shorthands.
28778      *
28779      * @private
28780      * @param {Array|Object} collection The collection to iterate over.
28781      * @param {Function} iteratee The function invoked per iteration.
28782      * @returns {Array|Object} Returns `collection`.
28783      */
28784     var baseEachRight = createBaseEach(baseForOwnRight, true);
28785
28786     /**
28787      * The base implementation of `_.every` without support for iteratee shorthands.
28788      *
28789      * @private
28790      * @param {Array|Object} collection The collection to iterate over.
28791      * @param {Function} predicate The function invoked per iteration.
28792      * @returns {boolean} Returns `true` if all elements pass the predicate check,
28793      *  else `false`
28794      */
28795     function baseEvery(collection, predicate) {
28796       var result = true;
28797       baseEach(collection, function(value, index, collection) {
28798         result = !!predicate(value, index, collection);
28799         return result;
28800       });
28801       return result;
28802     }
28803
28804     /**
28805      * The base implementation of methods like `_.max` and `_.min` which accepts a
28806      * `comparator` to determine the extremum value.
28807      *
28808      * @private
28809      * @param {Array} array The array to iterate over.
28810      * @param {Function} iteratee The iteratee invoked per iteration.
28811      * @param {Function} comparator The comparator used to compare values.
28812      * @returns {*} Returns the extremum value.
28813      */
28814     function baseExtremum(array, iteratee, comparator) {
28815       var index = -1,
28816           length = array.length;
28817
28818       while (++index < length) {
28819         var value = array[index],
28820             current = iteratee(value);
28821
28822         if (current != null && (computed === undefined
28823               ? (current === current && !isSymbol(current))
28824               : comparator(current, computed)
28825             )) {
28826           var computed = current,
28827               result = value;
28828         }
28829       }
28830       return result;
28831     }
28832
28833     /**
28834      * The base implementation of `_.fill` without an iteratee call guard.
28835      *
28836      * @private
28837      * @param {Array} array The array to fill.
28838      * @param {*} value The value to fill `array` with.
28839      * @param {number} [start=0] The start position.
28840      * @param {number} [end=array.length] The end position.
28841      * @returns {Array} Returns `array`.
28842      */
28843     function baseFill(array, value, start, end) {
28844       var length = array.length;
28845
28846       start = toInteger(start);
28847       if (start < 0) {
28848         start = -start > length ? 0 : (length + start);
28849       }
28850       end = (end === undefined || end > length) ? length : toInteger(end);
28851       if (end < 0) {
28852         end += length;
28853       }
28854       end = start > end ? 0 : toLength(end);
28855       while (start < end) {
28856         array[start++] = value;
28857       }
28858       return array;
28859     }
28860
28861     /**
28862      * The base implementation of `_.filter` without support for iteratee shorthands.
28863      *
28864      * @private
28865      * @param {Array|Object} collection The collection to iterate over.
28866      * @param {Function} predicate The function invoked per iteration.
28867      * @returns {Array} Returns the new filtered array.
28868      */
28869     function baseFilter(collection, predicate) {
28870       var result = [];
28871       baseEach(collection, function(value, index, collection) {
28872         if (predicate(value, index, collection)) {
28873           result.push(value);
28874         }
28875       });
28876       return result;
28877     }
28878
28879     /**
28880      * The base implementation of `_.flatten` with support for restricting flattening.
28881      *
28882      * @private
28883      * @param {Array} array The array to flatten.
28884      * @param {number} depth The maximum recursion depth.
28885      * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
28886      * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
28887      * @param {Array} [result=[]] The initial result value.
28888      * @returns {Array} Returns the new flattened array.
28889      */
28890     function baseFlatten(array, depth, predicate, isStrict, result) {
28891       var index = -1,
28892           length = array.length;
28893
28894       predicate || (predicate = isFlattenable);
28895       result || (result = []);
28896
28897       while (++index < length) {
28898         var value = array[index];
28899         if (depth > 0 && predicate(value)) {
28900           if (depth > 1) {
28901             // Recursively flatten arrays (susceptible to call stack limits).
28902             baseFlatten(value, depth - 1, predicate, isStrict, result);
28903           } else {
28904             arrayPush(result, value);
28905           }
28906         } else if (!isStrict) {
28907           result[result.length] = value;
28908         }
28909       }
28910       return result;
28911     }
28912
28913     /**
28914      * The base implementation of `baseForOwn` which iterates over `object`
28915      * properties returned by `keysFunc` and invokes `iteratee` for each property.
28916      * Iteratee functions may exit iteration early by explicitly returning `false`.
28917      *
28918      * @private
28919      * @param {Object} object The object to iterate over.
28920      * @param {Function} iteratee The function invoked per iteration.
28921      * @param {Function} keysFunc The function to get the keys of `object`.
28922      * @returns {Object} Returns `object`.
28923      */
28924     var baseFor = createBaseFor();
28925
28926     /**
28927      * This function is like `baseFor` except that it iterates over properties
28928      * in the opposite order.
28929      *
28930      * @private
28931      * @param {Object} object The object to iterate over.
28932      * @param {Function} iteratee The function invoked per iteration.
28933      * @param {Function} keysFunc The function to get the keys of `object`.
28934      * @returns {Object} Returns `object`.
28935      */
28936     var baseForRight = createBaseFor(true);
28937
28938     /**
28939      * The base implementation of `_.forOwn` without support for iteratee shorthands.
28940      *
28941      * @private
28942      * @param {Object} object The object to iterate over.
28943      * @param {Function} iteratee The function invoked per iteration.
28944      * @returns {Object} Returns `object`.
28945      */
28946     function baseForOwn(object, iteratee) {
28947       return object && baseFor(object, iteratee, keys);
28948     }
28949
28950     /**
28951      * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
28952      *
28953      * @private
28954      * @param {Object} object The object to iterate over.
28955      * @param {Function} iteratee The function invoked per iteration.
28956      * @returns {Object} Returns `object`.
28957      */
28958     function baseForOwnRight(object, iteratee) {
28959       return object && baseForRight(object, iteratee, keys);
28960     }
28961
28962     /**
28963      * The base implementation of `_.functions` which creates an array of
28964      * `object` function property names filtered from `props`.
28965      *
28966      * @private
28967      * @param {Object} object The object to inspect.
28968      * @param {Array} props The property names to filter.
28969      * @returns {Array} Returns the function names.
28970      */
28971     function baseFunctions(object, props) {
28972       return arrayFilter(props, function(key) {
28973         return isFunction(object[key]);
28974       });
28975     }
28976
28977     /**
28978      * The base implementation of `_.get` without support for default values.
28979      *
28980      * @private
28981      * @param {Object} object The object to query.
28982      * @param {Array|string} path The path of the property to get.
28983      * @returns {*} Returns the resolved value.
28984      */
28985     function baseGet(object, path) {
28986       path = castPath(path, object);
28987
28988       var index = 0,
28989           length = path.length;
28990
28991       while (object != null && index < length) {
28992         object = object[toKey(path[index++])];
28993       }
28994       return (index && index == length) ? object : undefined;
28995     }
28996
28997     /**
28998      * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
28999      * `keysFunc` and `symbolsFunc` to get the enumerable property names and
29000      * symbols of `object`.
29001      *
29002      * @private
29003      * @param {Object} object The object to query.
29004      * @param {Function} keysFunc The function to get the keys of `object`.
29005      * @param {Function} symbolsFunc The function to get the symbols of `object`.
29006      * @returns {Array} Returns the array of property names and symbols.
29007      */
29008     function baseGetAllKeys(object, keysFunc, symbolsFunc) {
29009       var result = keysFunc(object);
29010       return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
29011     }
29012
29013     /**
29014      * The base implementation of `getTag` without fallbacks for buggy environments.
29015      *
29016      * @private
29017      * @param {*} value The value to query.
29018      * @returns {string} Returns the `toStringTag`.
29019      */
29020     function baseGetTag(value) {
29021       if (value == null) {
29022         return value === undefined ? undefinedTag : nullTag;
29023       }
29024       return (symToStringTag && symToStringTag in Object(value))
29025         ? getRawTag(value)
29026         : objectToString(value);
29027     }
29028
29029     /**
29030      * The base implementation of `_.gt` which doesn't coerce arguments.
29031      *
29032      * @private
29033      * @param {*} value The value to compare.
29034      * @param {*} other The other value to compare.
29035      * @returns {boolean} Returns `true` if `value` is greater than `other`,
29036      *  else `false`.
29037      */
29038     function baseGt(value, other) {
29039       return value > other;
29040     }
29041
29042     /**
29043      * The base implementation of `_.has` without support for deep paths.
29044      *
29045      * @private
29046      * @param {Object} [object] The object to query.
29047      * @param {Array|string} key The key to check.
29048      * @returns {boolean} Returns `true` if `key` exists, else `false`.
29049      */
29050     function baseHas(object, key) {
29051       return object != null && hasOwnProperty.call(object, key);
29052     }
29053
29054     /**
29055      * The base implementation of `_.hasIn` without support for deep paths.
29056      *
29057      * @private
29058      * @param {Object} [object] The object to query.
29059      * @param {Array|string} key The key to check.
29060      * @returns {boolean} Returns `true` if `key` exists, else `false`.
29061      */
29062     function baseHasIn(object, key) {
29063       return object != null && key in Object(object);
29064     }
29065
29066     /**
29067      * The base implementation of `_.inRange` which doesn't coerce arguments.
29068      *
29069      * @private
29070      * @param {number} number The number to check.
29071      * @param {number} start The start of the range.
29072      * @param {number} end The end of the range.
29073      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
29074      */
29075     function baseInRange(number, start, end) {
29076       return number >= nativeMin(start, end) && number < nativeMax(start, end);
29077     }
29078
29079     /**
29080      * The base implementation of methods like `_.intersection`, without support
29081      * for iteratee shorthands, that accepts an array of arrays to inspect.
29082      *
29083      * @private
29084      * @param {Array} arrays The arrays to inspect.
29085      * @param {Function} [iteratee] The iteratee invoked per element.
29086      * @param {Function} [comparator] The comparator invoked per element.
29087      * @returns {Array} Returns the new array of shared values.
29088      */
29089     function baseIntersection(arrays, iteratee, comparator) {
29090       var includes = comparator ? arrayIncludesWith : arrayIncludes,
29091           length = arrays[0].length,
29092           othLength = arrays.length,
29093           othIndex = othLength,
29094           caches = Array(othLength),
29095           maxLength = Infinity,
29096           result = [];
29097
29098       while (othIndex--) {
29099         var array = arrays[othIndex];
29100         if (othIndex && iteratee) {
29101           array = arrayMap(array, baseUnary(iteratee));
29102         }
29103         maxLength = nativeMin(array.length, maxLength);
29104         caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
29105           ? new SetCache(othIndex && array)
29106           : undefined;
29107       }
29108       array = arrays[0];
29109
29110       var index = -1,
29111           seen = caches[0];
29112
29113       outer:
29114       while (++index < length && result.length < maxLength) {
29115         var value = array[index],
29116             computed = iteratee ? iteratee(value) : value;
29117
29118         value = (comparator || value !== 0) ? value : 0;
29119         if (!(seen
29120               ? cacheHas(seen, computed)
29121               : includes(result, computed, comparator)
29122             )) {
29123           othIndex = othLength;
29124           while (--othIndex) {
29125             var cache = caches[othIndex];
29126             if (!(cache
29127                   ? cacheHas(cache, computed)
29128                   : includes(arrays[othIndex], computed, comparator))
29129                 ) {
29130               continue outer;
29131             }
29132           }
29133           if (seen) {
29134             seen.push(computed);
29135           }
29136           result.push(value);
29137         }
29138       }
29139       return result;
29140     }
29141
29142     /**
29143      * The base implementation of `_.invert` and `_.invertBy` which inverts
29144      * `object` with values transformed by `iteratee` and set by `setter`.
29145      *
29146      * @private
29147      * @param {Object} object The object to iterate over.
29148      * @param {Function} setter The function to set `accumulator` values.
29149      * @param {Function} iteratee The iteratee to transform values.
29150      * @param {Object} accumulator The initial inverted object.
29151      * @returns {Function} Returns `accumulator`.
29152      */
29153     function baseInverter(object, setter, iteratee, accumulator) {
29154       baseForOwn(object, function(value, key, object) {
29155         setter(accumulator, iteratee(value), key, object);
29156       });
29157       return accumulator;
29158     }
29159
29160     /**
29161      * The base implementation of `_.invoke` without support for individual
29162      * method arguments.
29163      *
29164      * @private
29165      * @param {Object} object The object to query.
29166      * @param {Array|string} path The path of the method to invoke.
29167      * @param {Array} args The arguments to invoke the method with.
29168      * @returns {*} Returns the result of the invoked method.
29169      */
29170     function baseInvoke(object, path, args) {
29171       path = castPath(path, object);
29172       object = parent(object, path);
29173       var func = object == null ? object : object[toKey(last(path))];
29174       return func == null ? undefined : apply(func, object, args);
29175     }
29176
29177     /**
29178      * The base implementation of `_.isArguments`.
29179      *
29180      * @private
29181      * @param {*} value The value to check.
29182      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
29183      */
29184     function baseIsArguments(value) {
29185       return isObjectLike(value) && baseGetTag(value) == argsTag;
29186     }
29187
29188     /**
29189      * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
29190      *
29191      * @private
29192      * @param {*} value The value to check.
29193      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
29194      */
29195     function baseIsArrayBuffer(value) {
29196       return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
29197     }
29198
29199     /**
29200      * The base implementation of `_.isDate` without Node.js optimizations.
29201      *
29202      * @private
29203      * @param {*} value The value to check.
29204      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
29205      */
29206     function baseIsDate(value) {
29207       return isObjectLike(value) && baseGetTag(value) == dateTag;
29208     }
29209
29210     /**
29211      * The base implementation of `_.isEqual` which supports partial comparisons
29212      * and tracks traversed objects.
29213      *
29214      * @private
29215      * @param {*} value The value to compare.
29216      * @param {*} other The other value to compare.
29217      * @param {boolean} bitmask The bitmask flags.
29218      *  1 - Unordered comparison
29219      *  2 - Partial comparison
29220      * @param {Function} [customizer] The function to customize comparisons.
29221      * @param {Object} [stack] Tracks traversed `value` and `other` objects.
29222      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
29223      */
29224     function baseIsEqual(value, other, bitmask, customizer, stack) {
29225       if (value === other) {
29226         return true;
29227       }
29228       if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
29229         return value !== value && other !== other;
29230       }
29231       return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
29232     }
29233
29234     /**
29235      * A specialized version of `baseIsEqual` for arrays and objects which performs
29236      * deep comparisons and tracks traversed objects enabling objects with circular
29237      * references to be compared.
29238      *
29239      * @private
29240      * @param {Object} object The object to compare.
29241      * @param {Object} other The other object to compare.
29242      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
29243      * @param {Function} customizer The function to customize comparisons.
29244      * @param {Function} equalFunc The function to determine equivalents of values.
29245      * @param {Object} [stack] Tracks traversed `object` and `other` objects.
29246      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
29247      */
29248     function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
29249       var objIsArr = isArray(object),
29250           othIsArr = isArray(other),
29251           objTag = objIsArr ? arrayTag : getTag(object),
29252           othTag = othIsArr ? arrayTag : getTag(other);
29253
29254       objTag = objTag == argsTag ? objectTag : objTag;
29255       othTag = othTag == argsTag ? objectTag : othTag;
29256
29257       var objIsObj = objTag == objectTag,
29258           othIsObj = othTag == objectTag,
29259           isSameTag = objTag == othTag;
29260
29261       if (isSameTag && isBuffer(object)) {
29262         if (!isBuffer(other)) {
29263           return false;
29264         }
29265         objIsArr = true;
29266         objIsObj = false;
29267       }
29268       if (isSameTag && !objIsObj) {
29269         stack || (stack = new Stack);
29270         return (objIsArr || isTypedArray(object))
29271           ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
29272           : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
29273       }
29274       if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
29275         var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
29276             othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
29277
29278         if (objIsWrapped || othIsWrapped) {
29279           var objUnwrapped = objIsWrapped ? object.value() : object,
29280               othUnwrapped = othIsWrapped ? other.value() : other;
29281
29282           stack || (stack = new Stack);
29283           return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
29284         }
29285       }
29286       if (!isSameTag) {
29287         return false;
29288       }
29289       stack || (stack = new Stack);
29290       return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
29291     }
29292
29293     /**
29294      * The base implementation of `_.isMap` without Node.js optimizations.
29295      *
29296      * @private
29297      * @param {*} value The value to check.
29298      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
29299      */
29300     function baseIsMap(value) {
29301       return isObjectLike(value) && getTag(value) == mapTag;
29302     }
29303
29304     /**
29305      * The base implementation of `_.isMatch` without support for iteratee shorthands.
29306      *
29307      * @private
29308      * @param {Object} object The object to inspect.
29309      * @param {Object} source The object of property values to match.
29310      * @param {Array} matchData The property names, values, and compare flags to match.
29311      * @param {Function} [customizer] The function to customize comparisons.
29312      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
29313      */
29314     function baseIsMatch(object, source, matchData, customizer) {
29315       var index = matchData.length,
29316           length = index,
29317           noCustomizer = !customizer;
29318
29319       if (object == null) {
29320         return !length;
29321       }
29322       object = Object(object);
29323       while (index--) {
29324         var data = matchData[index];
29325         if ((noCustomizer && data[2])
29326               ? data[1] !== object[data[0]]
29327               : !(data[0] in object)
29328             ) {
29329           return false;
29330         }
29331       }
29332       while (++index < length) {
29333         data = matchData[index];
29334         var key = data[0],
29335             objValue = object[key],
29336             srcValue = data[1];
29337
29338         if (noCustomizer && data[2]) {
29339           if (objValue === undefined && !(key in object)) {
29340             return false;
29341           }
29342         } else {
29343           var stack = new Stack;
29344           if (customizer) {
29345             var result = customizer(objValue, srcValue, key, object, source, stack);
29346           }
29347           if (!(result === undefined
29348                 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
29349                 : result
29350               )) {
29351             return false;
29352           }
29353         }
29354       }
29355       return true;
29356     }
29357
29358     /**
29359      * The base implementation of `_.isNative` without bad shim checks.
29360      *
29361      * @private
29362      * @param {*} value The value to check.
29363      * @returns {boolean} Returns `true` if `value` is a native function,
29364      *  else `false`.
29365      */
29366     function baseIsNative(value) {
29367       if (!isObject(value) || isMasked(value)) {
29368         return false;
29369       }
29370       var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
29371       return pattern.test(toSource(value));
29372     }
29373
29374     /**
29375      * The base implementation of `_.isRegExp` without Node.js optimizations.
29376      *
29377      * @private
29378      * @param {*} value The value to check.
29379      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
29380      */
29381     function baseIsRegExp(value) {
29382       return isObjectLike(value) && baseGetTag(value) == regexpTag;
29383     }
29384
29385     /**
29386      * The base implementation of `_.isSet` without Node.js optimizations.
29387      *
29388      * @private
29389      * @param {*} value The value to check.
29390      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
29391      */
29392     function baseIsSet(value) {
29393       return isObjectLike(value) && getTag(value) == setTag;
29394     }
29395
29396     /**
29397      * The base implementation of `_.isTypedArray` without Node.js optimizations.
29398      *
29399      * @private
29400      * @param {*} value The value to check.
29401      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
29402      */
29403     function baseIsTypedArray(value) {
29404       return isObjectLike(value) &&
29405         isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
29406     }
29407
29408     /**
29409      * The base implementation of `_.iteratee`.
29410      *
29411      * @private
29412      * @param {*} [value=_.identity] The value to convert to an iteratee.
29413      * @returns {Function} Returns the iteratee.
29414      */
29415     function baseIteratee(value) {
29416       // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
29417       // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
29418       if (typeof value == 'function') {
29419         return value;
29420       }
29421       if (value == null) {
29422         return identity;
29423       }
29424       if (typeof value == 'object') {
29425         return isArray(value)
29426           ? baseMatchesProperty(value[0], value[1])
29427           : baseMatches(value);
29428       }
29429       return property(value);
29430     }
29431
29432     /**
29433      * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
29434      *
29435      * @private
29436      * @param {Object} object The object to query.
29437      * @returns {Array} Returns the array of property names.
29438      */
29439     function baseKeys(object) {
29440       if (!isPrototype(object)) {
29441         return nativeKeys(object);
29442       }
29443       var result = [];
29444       for (var key in Object(object)) {
29445         if (hasOwnProperty.call(object, key) && key != 'constructor') {
29446           result.push(key);
29447         }
29448       }
29449       return result;
29450     }
29451
29452     /**
29453      * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
29454      *
29455      * @private
29456      * @param {Object} object The object to query.
29457      * @returns {Array} Returns the array of property names.
29458      */
29459     function baseKeysIn(object) {
29460       if (!isObject(object)) {
29461         return nativeKeysIn(object);
29462       }
29463       var isProto = isPrototype(object),
29464           result = [];
29465
29466       for (var key in object) {
29467         if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
29468           result.push(key);
29469         }
29470       }
29471       return result;
29472     }
29473
29474     /**
29475      * The base implementation of `_.lt` which doesn't coerce arguments.
29476      *
29477      * @private
29478      * @param {*} value The value to compare.
29479      * @param {*} other The other value to compare.
29480      * @returns {boolean} Returns `true` if `value` is less than `other`,
29481      *  else `false`.
29482      */
29483     function baseLt(value, other) {
29484       return value < other;
29485     }
29486
29487     /**
29488      * The base implementation of `_.map` without support for iteratee shorthands.
29489      *
29490      * @private
29491      * @param {Array|Object} collection The collection to iterate over.
29492      * @param {Function} iteratee The function invoked per iteration.
29493      * @returns {Array} Returns the new mapped array.
29494      */
29495     function baseMap(collection, iteratee) {
29496       var index = -1,
29497           result = isArrayLike(collection) ? Array(collection.length) : [];
29498
29499       baseEach(collection, function(value, key, collection) {
29500         result[++index] = iteratee(value, key, collection);
29501       });
29502       return result;
29503     }
29504
29505     /**
29506      * The base implementation of `_.matches` which doesn't clone `source`.
29507      *
29508      * @private
29509      * @param {Object} source The object of property values to match.
29510      * @returns {Function} Returns the new spec function.
29511      */
29512     function baseMatches(source) {
29513       var matchData = getMatchData(source);
29514       if (matchData.length == 1 && matchData[0][2]) {
29515         return matchesStrictComparable(matchData[0][0], matchData[0][1]);
29516       }
29517       return function(object) {
29518         return object === source || baseIsMatch(object, source, matchData);
29519       };
29520     }
29521
29522     /**
29523      * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
29524      *
29525      * @private
29526      * @param {string} path The path of the property to get.
29527      * @param {*} srcValue The value to match.
29528      * @returns {Function} Returns the new spec function.
29529      */
29530     function baseMatchesProperty(path, srcValue) {
29531       if (isKey(path) && isStrictComparable(srcValue)) {
29532         return matchesStrictComparable(toKey(path), srcValue);
29533       }
29534       return function(object) {
29535         var objValue = get(object, path);
29536         return (objValue === undefined && objValue === srcValue)
29537           ? hasIn(object, path)
29538           : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
29539       };
29540     }
29541
29542     /**
29543      * The base implementation of `_.merge` without support for multiple sources.
29544      *
29545      * @private
29546      * @param {Object} object The destination object.
29547      * @param {Object} source The source object.
29548      * @param {number} srcIndex The index of `source`.
29549      * @param {Function} [customizer] The function to customize merged values.
29550      * @param {Object} [stack] Tracks traversed source values and their merged
29551      *  counterparts.
29552      */
29553     function baseMerge(object, source, srcIndex, customizer, stack) {
29554       if (object === source) {
29555         return;
29556       }
29557       baseFor(source, function(srcValue, key) {
29558         stack || (stack = new Stack);
29559         if (isObject(srcValue)) {
29560           baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
29561         }
29562         else {
29563           var newValue = customizer
29564             ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
29565             : undefined;
29566
29567           if (newValue === undefined) {
29568             newValue = srcValue;
29569           }
29570           assignMergeValue(object, key, newValue);
29571         }
29572       }, keysIn);
29573     }
29574
29575     /**
29576      * A specialized version of `baseMerge` for arrays and objects which performs
29577      * deep merges and tracks traversed objects enabling objects with circular
29578      * references to be merged.
29579      *
29580      * @private
29581      * @param {Object} object The destination object.
29582      * @param {Object} source The source object.
29583      * @param {string} key The key of the value to merge.
29584      * @param {number} srcIndex The index of `source`.
29585      * @param {Function} mergeFunc The function to merge values.
29586      * @param {Function} [customizer] The function to customize assigned values.
29587      * @param {Object} [stack] Tracks traversed source values and their merged
29588      *  counterparts.
29589      */
29590     function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
29591       var objValue = safeGet(object, key),
29592           srcValue = safeGet(source, key),
29593           stacked = stack.get(srcValue);
29594
29595       if (stacked) {
29596         assignMergeValue(object, key, stacked);
29597         return;
29598       }
29599       var newValue = customizer
29600         ? customizer(objValue, srcValue, (key + ''), object, source, stack)
29601         : undefined;
29602
29603       var isCommon = newValue === undefined;
29604
29605       if (isCommon) {
29606         var isArr = isArray(srcValue),
29607             isBuff = !isArr && isBuffer(srcValue),
29608             isTyped = !isArr && !isBuff && isTypedArray(srcValue);
29609
29610         newValue = srcValue;
29611         if (isArr || isBuff || isTyped) {
29612           if (isArray(objValue)) {
29613             newValue = objValue;
29614           }
29615           else if (isArrayLikeObject(objValue)) {
29616             newValue = copyArray(objValue);
29617           }
29618           else if (isBuff) {
29619             isCommon = false;
29620             newValue = cloneBuffer(srcValue, true);
29621           }
29622           else if (isTyped) {
29623             isCommon = false;
29624             newValue = cloneTypedArray(srcValue, true);
29625           }
29626           else {
29627             newValue = [];
29628           }
29629         }
29630         else if (isPlainObject(srcValue) || isArguments(srcValue)) {
29631           newValue = objValue;
29632           if (isArguments(objValue)) {
29633             newValue = toPlainObject(objValue);
29634           }
29635           else if (!isObject(objValue) || isFunction(objValue)) {
29636             newValue = initCloneObject(srcValue);
29637           }
29638         }
29639         else {
29640           isCommon = false;
29641         }
29642       }
29643       if (isCommon) {
29644         // Recursively merge objects and arrays (susceptible to call stack limits).
29645         stack.set(srcValue, newValue);
29646         mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
29647         stack['delete'](srcValue);
29648       }
29649       assignMergeValue(object, key, newValue);
29650     }
29651
29652     /**
29653      * The base implementation of `_.nth` which doesn't coerce arguments.
29654      *
29655      * @private
29656      * @param {Array} array The array to query.
29657      * @param {number} n The index of the element to return.
29658      * @returns {*} Returns the nth element of `array`.
29659      */
29660     function baseNth(array, n) {
29661       var length = array.length;
29662       if (!length) {
29663         return;
29664       }
29665       n += n < 0 ? length : 0;
29666       return isIndex(n, length) ? array[n] : undefined;
29667     }
29668
29669     /**
29670      * The base implementation of `_.orderBy` without param guards.
29671      *
29672      * @private
29673      * @param {Array|Object} collection The collection to iterate over.
29674      * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
29675      * @param {string[]} orders The sort orders of `iteratees`.
29676      * @returns {Array} Returns the new sorted array.
29677      */
29678     function baseOrderBy(collection, iteratees, orders) {
29679       var index = -1;
29680       iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
29681
29682       var result = baseMap(collection, function(value, key, collection) {
29683         var criteria = arrayMap(iteratees, function(iteratee) {
29684           return iteratee(value);
29685         });
29686         return { 'criteria': criteria, 'index': ++index, 'value': value };
29687       });
29688
29689       return baseSortBy(result, function(object, other) {
29690         return compareMultiple(object, other, orders);
29691       });
29692     }
29693
29694     /**
29695      * The base implementation of `_.pick` without support for individual
29696      * property identifiers.
29697      *
29698      * @private
29699      * @param {Object} object The source object.
29700      * @param {string[]} paths The property paths to pick.
29701      * @returns {Object} Returns the new object.
29702      */
29703     function basePick(object, paths) {
29704       return basePickBy(object, paths, function(value, path) {
29705         return hasIn(object, path);
29706       });
29707     }
29708
29709     /**
29710      * The base implementation of  `_.pickBy` without support for iteratee shorthands.
29711      *
29712      * @private
29713      * @param {Object} object The source object.
29714      * @param {string[]} paths The property paths to pick.
29715      * @param {Function} predicate The function invoked per property.
29716      * @returns {Object} Returns the new object.
29717      */
29718     function basePickBy(object, paths, predicate) {
29719       var index = -1,
29720           length = paths.length,
29721           result = {};
29722
29723       while (++index < length) {
29724         var path = paths[index],
29725             value = baseGet(object, path);
29726
29727         if (predicate(value, path)) {
29728           baseSet(result, castPath(path, object), value);
29729         }
29730       }
29731       return result;
29732     }
29733
29734     /**
29735      * A specialized version of `baseProperty` which supports deep paths.
29736      *
29737      * @private
29738      * @param {Array|string} path The path of the property to get.
29739      * @returns {Function} Returns the new accessor function.
29740      */
29741     function basePropertyDeep(path) {
29742       return function(object) {
29743         return baseGet(object, path);
29744       };
29745     }
29746
29747     /**
29748      * The base implementation of `_.pullAllBy` without support for iteratee
29749      * shorthands.
29750      *
29751      * @private
29752      * @param {Array} array The array to modify.
29753      * @param {Array} values The values to remove.
29754      * @param {Function} [iteratee] The iteratee invoked per element.
29755      * @param {Function} [comparator] The comparator invoked per element.
29756      * @returns {Array} Returns `array`.
29757      */
29758     function basePullAll(array, values, iteratee, comparator) {
29759       var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
29760           index = -1,
29761           length = values.length,
29762           seen = array;
29763
29764       if (array === values) {
29765         values = copyArray(values);
29766       }
29767       if (iteratee) {
29768         seen = arrayMap(array, baseUnary(iteratee));
29769       }
29770       while (++index < length) {
29771         var fromIndex = 0,
29772             value = values[index],
29773             computed = iteratee ? iteratee(value) : value;
29774
29775         while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
29776           if (seen !== array) {
29777             splice.call(seen, fromIndex, 1);
29778           }
29779           splice.call(array, fromIndex, 1);
29780         }
29781       }
29782       return array;
29783     }
29784
29785     /**
29786      * The base implementation of `_.pullAt` without support for individual
29787      * indexes or capturing the removed elements.
29788      *
29789      * @private
29790      * @param {Array} array The array to modify.
29791      * @param {number[]} indexes The indexes of elements to remove.
29792      * @returns {Array} Returns `array`.
29793      */
29794     function basePullAt(array, indexes) {
29795       var length = array ? indexes.length : 0,
29796           lastIndex = length - 1;
29797
29798       while (length--) {
29799         var index = indexes[length];
29800         if (length == lastIndex || index !== previous) {
29801           var previous = index;
29802           if (isIndex(index)) {
29803             splice.call(array, index, 1);
29804           } else {
29805             baseUnset(array, index);
29806           }
29807         }
29808       }
29809       return array;
29810     }
29811
29812     /**
29813      * The base implementation of `_.random` without support for returning
29814      * floating-point numbers.
29815      *
29816      * @private
29817      * @param {number} lower The lower bound.
29818      * @param {number} upper The upper bound.
29819      * @returns {number} Returns the random number.
29820      */
29821     function baseRandom(lower, upper) {
29822       return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
29823     }
29824
29825     /**
29826      * The base implementation of `_.range` and `_.rangeRight` which doesn't
29827      * coerce arguments.
29828      *
29829      * @private
29830      * @param {number} start The start of the range.
29831      * @param {number} end The end of the range.
29832      * @param {number} step The value to increment or decrement by.
29833      * @param {boolean} [fromRight] Specify iterating from right to left.
29834      * @returns {Array} Returns the range of numbers.
29835      */
29836     function baseRange(start, end, step, fromRight) {
29837       var index = -1,
29838           length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
29839           result = Array(length);
29840
29841       while (length--) {
29842         result[fromRight ? length : ++index] = start;
29843         start += step;
29844       }
29845       return result;
29846     }
29847
29848     /**
29849      * The base implementation of `_.repeat` which doesn't coerce arguments.
29850      *
29851      * @private
29852      * @param {string} string The string to repeat.
29853      * @param {number} n The number of times to repeat the string.
29854      * @returns {string} Returns the repeated string.
29855      */
29856     function baseRepeat(string, n) {
29857       var result = '';
29858       if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
29859         return result;
29860       }
29861       // Leverage the exponentiation by squaring algorithm for a faster repeat.
29862       // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
29863       do {
29864         if (n % 2) {
29865           result += string;
29866         }
29867         n = nativeFloor(n / 2);
29868         if (n) {
29869           string += string;
29870         }
29871       } while (n);
29872
29873       return result;
29874     }
29875
29876     /**
29877      * The base implementation of `_.rest` which doesn't validate or coerce arguments.
29878      *
29879      * @private
29880      * @param {Function} func The function to apply a rest parameter to.
29881      * @param {number} [start=func.length-1] The start position of the rest parameter.
29882      * @returns {Function} Returns the new function.
29883      */
29884     function baseRest(func, start) {
29885       return setToString(overRest(func, start, identity), func + '');
29886     }
29887
29888     /**
29889      * The base implementation of `_.sample`.
29890      *
29891      * @private
29892      * @param {Array|Object} collection The collection to sample.
29893      * @returns {*} Returns the random element.
29894      */
29895     function baseSample(collection) {
29896       return arraySample(values(collection));
29897     }
29898
29899     /**
29900      * The base implementation of `_.sampleSize` without param guards.
29901      *
29902      * @private
29903      * @param {Array|Object} collection The collection to sample.
29904      * @param {number} n The number of elements to sample.
29905      * @returns {Array} Returns the random elements.
29906      */
29907     function baseSampleSize(collection, n) {
29908       var array = values(collection);
29909       return shuffleSelf(array, baseClamp(n, 0, array.length));
29910     }
29911
29912     /**
29913      * The base implementation of `_.set`.
29914      *
29915      * @private
29916      * @param {Object} object The object to modify.
29917      * @param {Array|string} path The path of the property to set.
29918      * @param {*} value The value to set.
29919      * @param {Function} [customizer] The function to customize path creation.
29920      * @returns {Object} Returns `object`.
29921      */
29922     function baseSet(object, path, value, customizer) {
29923       if (!isObject(object)) {
29924         return object;
29925       }
29926       path = castPath(path, object);
29927
29928       var index = -1,
29929           length = path.length,
29930           lastIndex = length - 1,
29931           nested = object;
29932
29933       while (nested != null && ++index < length) {
29934         var key = toKey(path[index]),
29935             newValue = value;
29936
29937         if (index != lastIndex) {
29938           var objValue = nested[key];
29939           newValue = customizer ? customizer(objValue, key, nested) : undefined;
29940           if (newValue === undefined) {
29941             newValue = isObject(objValue)
29942               ? objValue
29943               : (isIndex(path[index + 1]) ? [] : {});
29944           }
29945         }
29946         assignValue(nested, key, newValue);
29947         nested = nested[key];
29948       }
29949       return object;
29950     }
29951
29952     /**
29953      * The base implementation of `setData` without support for hot loop shorting.
29954      *
29955      * @private
29956      * @param {Function} func The function to associate metadata with.
29957      * @param {*} data The metadata.
29958      * @returns {Function} Returns `func`.
29959      */
29960     var baseSetData = !metaMap ? identity : function(func, data) {
29961       metaMap.set(func, data);
29962       return func;
29963     };
29964
29965     /**
29966      * The base implementation of `setToString` without support for hot loop shorting.
29967      *
29968      * @private
29969      * @param {Function} func The function to modify.
29970      * @param {Function} string The `toString` result.
29971      * @returns {Function} Returns `func`.
29972      */
29973     var baseSetToString = !defineProperty ? identity : function(func, string) {
29974       return defineProperty(func, 'toString', {
29975         'configurable': true,
29976         'enumerable': false,
29977         'value': constant(string),
29978         'writable': true
29979       });
29980     };
29981
29982     /**
29983      * The base implementation of `_.shuffle`.
29984      *
29985      * @private
29986      * @param {Array|Object} collection The collection to shuffle.
29987      * @returns {Array} Returns the new shuffled array.
29988      */
29989     function baseShuffle(collection) {
29990       return shuffleSelf(values(collection));
29991     }
29992
29993     /**
29994      * The base implementation of `_.slice` without an iteratee call guard.
29995      *
29996      * @private
29997      * @param {Array} array The array to slice.
29998      * @param {number} [start=0] The start position.
29999      * @param {number} [end=array.length] The end position.
30000      * @returns {Array} Returns the slice of `array`.
30001      */
30002     function baseSlice(array, start, end) {
30003       var index = -1,
30004           length = array.length;
30005
30006       if (start < 0) {
30007         start = -start > length ? 0 : (length + start);
30008       }
30009       end = end > length ? length : end;
30010       if (end < 0) {
30011         end += length;
30012       }
30013       length = start > end ? 0 : ((end - start) >>> 0);
30014       start >>>= 0;
30015
30016       var result = Array(length);
30017       while (++index < length) {
30018         result[index] = array[index + start];
30019       }
30020       return result;
30021     }
30022
30023     /**
30024      * The base implementation of `_.some` without support for iteratee shorthands.
30025      *
30026      * @private
30027      * @param {Array|Object} collection The collection to iterate over.
30028      * @param {Function} predicate The function invoked per iteration.
30029      * @returns {boolean} Returns `true` if any element passes the predicate check,
30030      *  else `false`.
30031      */
30032     function baseSome(collection, predicate) {
30033       var result;
30034
30035       baseEach(collection, function(value, index, collection) {
30036         result = predicate(value, index, collection);
30037         return !result;
30038       });
30039       return !!result;
30040     }
30041
30042     /**
30043      * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
30044      * performs a binary search of `array` to determine the index at which `value`
30045      * should be inserted into `array` in order to maintain its sort order.
30046      *
30047      * @private
30048      * @param {Array} array The sorted array to inspect.
30049      * @param {*} value The value to evaluate.
30050      * @param {boolean} [retHighest] Specify returning the highest qualified index.
30051      * @returns {number} Returns the index at which `value` should be inserted
30052      *  into `array`.
30053      */
30054     function baseSortedIndex(array, value, retHighest) {
30055       var low = 0,
30056           high = array == null ? low : array.length;
30057
30058       if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
30059         while (low < high) {
30060           var mid = (low + high) >>> 1,
30061               computed = array[mid];
30062
30063           if (computed !== null && !isSymbol(computed) &&
30064               (retHighest ? (computed <= value) : (computed < value))) {
30065             low = mid + 1;
30066           } else {
30067             high = mid;
30068           }
30069         }
30070         return high;
30071       }
30072       return baseSortedIndexBy(array, value, identity, retHighest);
30073     }
30074
30075     /**
30076      * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
30077      * which invokes `iteratee` for `value` and each element of `array` to compute
30078      * their sort ranking. The iteratee is invoked with one argument; (value).
30079      *
30080      * @private
30081      * @param {Array} array The sorted array to inspect.
30082      * @param {*} value The value to evaluate.
30083      * @param {Function} iteratee The iteratee invoked per element.
30084      * @param {boolean} [retHighest] Specify returning the highest qualified index.
30085      * @returns {number} Returns the index at which `value` should be inserted
30086      *  into `array`.
30087      */
30088     function baseSortedIndexBy(array, value, iteratee, retHighest) {
30089       value = iteratee(value);
30090
30091       var low = 0,
30092           high = array == null ? 0 : array.length,
30093           valIsNaN = value !== value,
30094           valIsNull = value === null,
30095           valIsSymbol = isSymbol(value),
30096           valIsUndefined = value === undefined;
30097
30098       while (low < high) {
30099         var mid = nativeFloor((low + high) / 2),
30100             computed = iteratee(array[mid]),
30101             othIsDefined = computed !== undefined,
30102             othIsNull = computed === null,
30103             othIsReflexive = computed === computed,
30104             othIsSymbol = isSymbol(computed);
30105
30106         if (valIsNaN) {
30107           var setLow = retHighest || othIsReflexive;
30108         } else if (valIsUndefined) {
30109           setLow = othIsReflexive && (retHighest || othIsDefined);
30110         } else if (valIsNull) {
30111           setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
30112         } else if (valIsSymbol) {
30113           setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
30114         } else if (othIsNull || othIsSymbol) {
30115           setLow = false;
30116         } else {
30117           setLow = retHighest ? (computed <= value) : (computed < value);
30118         }
30119         if (setLow) {
30120           low = mid + 1;
30121         } else {
30122           high = mid;
30123         }
30124       }
30125       return nativeMin(high, MAX_ARRAY_INDEX);
30126     }
30127
30128     /**
30129      * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
30130      * support for iteratee shorthands.
30131      *
30132      * @private
30133      * @param {Array} array The array to inspect.
30134      * @param {Function} [iteratee] The iteratee invoked per element.
30135      * @returns {Array} Returns the new duplicate free array.
30136      */
30137     function baseSortedUniq(array, iteratee) {
30138       var index = -1,
30139           length = array.length,
30140           resIndex = 0,
30141           result = [];
30142
30143       while (++index < length) {
30144         var value = array[index],
30145             computed = iteratee ? iteratee(value) : value;
30146
30147         if (!index || !eq(computed, seen)) {
30148           var seen = computed;
30149           result[resIndex++] = value === 0 ? 0 : value;
30150         }
30151       }
30152       return result;
30153     }
30154
30155     /**
30156      * The base implementation of `_.toNumber` which doesn't ensure correct
30157      * conversions of binary, hexadecimal, or octal string values.
30158      *
30159      * @private
30160      * @param {*} value The value to process.
30161      * @returns {number} Returns the number.
30162      */
30163     function baseToNumber(value) {
30164       if (typeof value == 'number') {
30165         return value;
30166       }
30167       if (isSymbol(value)) {
30168         return NAN;
30169       }
30170       return +value;
30171     }
30172
30173     /**
30174      * The base implementation of `_.toString` which doesn't convert nullish
30175      * values to empty strings.
30176      *
30177      * @private
30178      * @param {*} value The value to process.
30179      * @returns {string} Returns the string.
30180      */
30181     function baseToString(value) {
30182       // Exit early for strings to avoid a performance hit in some environments.
30183       if (typeof value == 'string') {
30184         return value;
30185       }
30186       if (isArray(value)) {
30187         // Recursively convert values (susceptible to call stack limits).
30188         return arrayMap(value, baseToString) + '';
30189       }
30190       if (isSymbol(value)) {
30191         return symbolToString ? symbolToString.call(value) : '';
30192       }
30193       var result = (value + '');
30194       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
30195     }
30196
30197     /**
30198      * The base implementation of `_.uniqBy` without support for iteratee shorthands.
30199      *
30200      * @private
30201      * @param {Array} array The array to inspect.
30202      * @param {Function} [iteratee] The iteratee invoked per element.
30203      * @param {Function} [comparator] The comparator invoked per element.
30204      * @returns {Array} Returns the new duplicate free array.
30205      */
30206     function baseUniq(array, iteratee, comparator) {
30207       var index = -1,
30208           includes = arrayIncludes,
30209           length = array.length,
30210           isCommon = true,
30211           result = [],
30212           seen = result;
30213
30214       if (comparator) {
30215         isCommon = false;
30216         includes = arrayIncludesWith;
30217       }
30218       else if (length >= LARGE_ARRAY_SIZE) {
30219         var set = iteratee ? null : createSet(array);
30220         if (set) {
30221           return setToArray(set);
30222         }
30223         isCommon = false;
30224         includes = cacheHas;
30225         seen = new SetCache;
30226       }
30227       else {
30228         seen = iteratee ? [] : result;
30229       }
30230       outer:
30231       while (++index < length) {
30232         var value = array[index],
30233             computed = iteratee ? iteratee(value) : value;
30234
30235         value = (comparator || value !== 0) ? value : 0;
30236         if (isCommon && computed === computed) {
30237           var seenIndex = seen.length;
30238           while (seenIndex--) {
30239             if (seen[seenIndex] === computed) {
30240               continue outer;
30241             }
30242           }
30243           if (iteratee) {
30244             seen.push(computed);
30245           }
30246           result.push(value);
30247         }
30248         else if (!includes(seen, computed, comparator)) {
30249           if (seen !== result) {
30250             seen.push(computed);
30251           }
30252           result.push(value);
30253         }
30254       }
30255       return result;
30256     }
30257
30258     /**
30259      * The base implementation of `_.unset`.
30260      *
30261      * @private
30262      * @param {Object} object The object to modify.
30263      * @param {Array|string} path The property path to unset.
30264      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
30265      */
30266     function baseUnset(object, path) {
30267       path = castPath(path, object);
30268       object = parent(object, path);
30269       return object == null || delete object[toKey(last(path))];
30270     }
30271
30272     /**
30273      * The base implementation of `_.update`.
30274      *
30275      * @private
30276      * @param {Object} object The object to modify.
30277      * @param {Array|string} path The path of the property to update.
30278      * @param {Function} updater The function to produce the updated value.
30279      * @param {Function} [customizer] The function to customize path creation.
30280      * @returns {Object} Returns `object`.
30281      */
30282     function baseUpdate(object, path, updater, customizer) {
30283       return baseSet(object, path, updater(baseGet(object, path)), customizer);
30284     }
30285
30286     /**
30287      * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
30288      * without support for iteratee shorthands.
30289      *
30290      * @private
30291      * @param {Array} array The array to query.
30292      * @param {Function} predicate The function invoked per iteration.
30293      * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
30294      * @param {boolean} [fromRight] Specify iterating from right to left.
30295      * @returns {Array} Returns the slice of `array`.
30296      */
30297     function baseWhile(array, predicate, isDrop, fromRight) {
30298       var length = array.length,
30299           index = fromRight ? length : -1;
30300
30301       while ((fromRight ? index-- : ++index < length) &&
30302         predicate(array[index], index, array)) {}
30303
30304       return isDrop
30305         ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
30306         : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
30307     }
30308
30309     /**
30310      * The base implementation of `wrapperValue` which returns the result of
30311      * performing a sequence of actions on the unwrapped `value`, where each
30312      * successive action is supplied the return value of the previous.
30313      *
30314      * @private
30315      * @param {*} value The unwrapped value.
30316      * @param {Array} actions Actions to perform to resolve the unwrapped value.
30317      * @returns {*} Returns the resolved value.
30318      */
30319     function baseWrapperValue(value, actions) {
30320       var result = value;
30321       if (result instanceof LazyWrapper) {
30322         result = result.value();
30323       }
30324       return arrayReduce(actions, function(result, action) {
30325         return action.func.apply(action.thisArg, arrayPush([result], action.args));
30326       }, result);
30327     }
30328
30329     /**
30330      * The base implementation of methods like `_.xor`, without support for
30331      * iteratee shorthands, that accepts an array of arrays to inspect.
30332      *
30333      * @private
30334      * @param {Array} arrays The arrays to inspect.
30335      * @param {Function} [iteratee] The iteratee invoked per element.
30336      * @param {Function} [comparator] The comparator invoked per element.
30337      * @returns {Array} Returns the new array of values.
30338      */
30339     function baseXor(arrays, iteratee, comparator) {
30340       var length = arrays.length;
30341       if (length < 2) {
30342         return length ? baseUniq(arrays[0]) : [];
30343       }
30344       var index = -1,
30345           result = Array(length);
30346
30347       while (++index < length) {
30348         var array = arrays[index],
30349             othIndex = -1;
30350
30351         while (++othIndex < length) {
30352           if (othIndex != index) {
30353             result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
30354           }
30355         }
30356       }
30357       return baseUniq(baseFlatten(result, 1), iteratee, comparator);
30358     }
30359
30360     /**
30361      * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
30362      *
30363      * @private
30364      * @param {Array} props The property identifiers.
30365      * @param {Array} values The property values.
30366      * @param {Function} assignFunc The function to assign values.
30367      * @returns {Object} Returns the new object.
30368      */
30369     function baseZipObject(props, values, assignFunc) {
30370       var index = -1,
30371           length = props.length,
30372           valsLength = values.length,
30373           result = {};
30374
30375       while (++index < length) {
30376         var value = index < valsLength ? values[index] : undefined;
30377         assignFunc(result, props[index], value);
30378       }
30379       return result;
30380     }
30381
30382     /**
30383      * Casts `value` to an empty array if it's not an array like object.
30384      *
30385      * @private
30386      * @param {*} value The value to inspect.
30387      * @returns {Array|Object} Returns the cast array-like object.
30388      */
30389     function castArrayLikeObject(value) {
30390       return isArrayLikeObject(value) ? value : [];
30391     }
30392
30393     /**
30394      * Casts `value` to `identity` if it's not a function.
30395      *
30396      * @private
30397      * @param {*} value The value to inspect.
30398      * @returns {Function} Returns cast function.
30399      */
30400     function castFunction(value) {
30401       return typeof value == 'function' ? value : identity;
30402     }
30403
30404     /**
30405      * Casts `value` to a path array if it's not one.
30406      *
30407      * @private
30408      * @param {*} value The value to inspect.
30409      * @param {Object} [object] The object to query keys on.
30410      * @returns {Array} Returns the cast property path array.
30411      */
30412     function castPath(value, object) {
30413       if (isArray(value)) {
30414         return value;
30415       }
30416       return isKey(value, object) ? [value] : stringToPath(toString(value));
30417     }
30418
30419     /**
30420      * A `baseRest` alias which can be replaced with `identity` by module
30421      * replacement plugins.
30422      *
30423      * @private
30424      * @type {Function}
30425      * @param {Function} func The function to apply a rest parameter to.
30426      * @returns {Function} Returns the new function.
30427      */
30428     var castRest = baseRest;
30429
30430     /**
30431      * Casts `array` to a slice if it's needed.
30432      *
30433      * @private
30434      * @param {Array} array The array to inspect.
30435      * @param {number} start The start position.
30436      * @param {number} [end=array.length] The end position.
30437      * @returns {Array} Returns the cast slice.
30438      */
30439     function castSlice(array, start, end) {
30440       var length = array.length;
30441       end = end === undefined ? length : end;
30442       return (!start && end >= length) ? array : baseSlice(array, start, end);
30443     }
30444
30445     /**
30446      * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
30447      *
30448      * @private
30449      * @param {number|Object} id The timer id or timeout object of the timer to clear.
30450      */
30451     var clearTimeout = ctxClearTimeout || function(id) {
30452       return root.clearTimeout(id);
30453     };
30454
30455     /**
30456      * Creates a clone of  `buffer`.
30457      *
30458      * @private
30459      * @param {Buffer} buffer The buffer to clone.
30460      * @param {boolean} [isDeep] Specify a deep clone.
30461      * @returns {Buffer} Returns the cloned buffer.
30462      */
30463     function cloneBuffer(buffer, isDeep) {
30464       if (isDeep) {
30465         return buffer.slice();
30466       }
30467       var length = buffer.length,
30468           result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
30469
30470       buffer.copy(result);
30471       return result;
30472     }
30473
30474     /**
30475      * Creates a clone of `arrayBuffer`.
30476      *
30477      * @private
30478      * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
30479      * @returns {ArrayBuffer} Returns the cloned array buffer.
30480      */
30481     function cloneArrayBuffer(arrayBuffer) {
30482       var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
30483       new Uint8Array(result).set(new Uint8Array(arrayBuffer));
30484       return result;
30485     }
30486
30487     /**
30488      * Creates a clone of `dataView`.
30489      *
30490      * @private
30491      * @param {Object} dataView The data view to clone.
30492      * @param {boolean} [isDeep] Specify a deep clone.
30493      * @returns {Object} Returns the cloned data view.
30494      */
30495     function cloneDataView(dataView, isDeep) {
30496       var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
30497       return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
30498     }
30499
30500     /**
30501      * Creates a clone of `regexp`.
30502      *
30503      * @private
30504      * @param {Object} regexp The regexp to clone.
30505      * @returns {Object} Returns the cloned regexp.
30506      */
30507     function cloneRegExp(regexp) {
30508       var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
30509       result.lastIndex = regexp.lastIndex;
30510       return result;
30511     }
30512
30513     /**
30514      * Creates a clone of the `symbol` object.
30515      *
30516      * @private
30517      * @param {Object} symbol The symbol object to clone.
30518      * @returns {Object} Returns the cloned symbol object.
30519      */
30520     function cloneSymbol(symbol) {
30521       return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
30522     }
30523
30524     /**
30525      * Creates a clone of `typedArray`.
30526      *
30527      * @private
30528      * @param {Object} typedArray The typed array to clone.
30529      * @param {boolean} [isDeep] Specify a deep clone.
30530      * @returns {Object} Returns the cloned typed array.
30531      */
30532     function cloneTypedArray(typedArray, isDeep) {
30533       var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
30534       return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
30535     }
30536
30537     /**
30538      * Compares values to sort them in ascending order.
30539      *
30540      * @private
30541      * @param {*} value The value to compare.
30542      * @param {*} other The other value to compare.
30543      * @returns {number} Returns the sort order indicator for `value`.
30544      */
30545     function compareAscending(value, other) {
30546       if (value !== other) {
30547         var valIsDefined = value !== undefined,
30548             valIsNull = value === null,
30549             valIsReflexive = value === value,
30550             valIsSymbol = isSymbol(value);
30551
30552         var othIsDefined = other !== undefined,
30553             othIsNull = other === null,
30554             othIsReflexive = other === other,
30555             othIsSymbol = isSymbol(other);
30556
30557         if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
30558             (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
30559             (valIsNull && othIsDefined && othIsReflexive) ||
30560             (!valIsDefined && othIsReflexive) ||
30561             !valIsReflexive) {
30562           return 1;
30563         }
30564         if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
30565             (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
30566             (othIsNull && valIsDefined && valIsReflexive) ||
30567             (!othIsDefined && valIsReflexive) ||
30568             !othIsReflexive) {
30569           return -1;
30570         }
30571       }
30572       return 0;
30573     }
30574
30575     /**
30576      * Used by `_.orderBy` to compare multiple properties of a value to another
30577      * and stable sort them.
30578      *
30579      * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
30580      * specify an order of "desc" for descending or "asc" for ascending sort order
30581      * of corresponding values.
30582      *
30583      * @private
30584      * @param {Object} object The object to compare.
30585      * @param {Object} other The other object to compare.
30586      * @param {boolean[]|string[]} orders The order to sort by for each property.
30587      * @returns {number} Returns the sort order indicator for `object`.
30588      */
30589     function compareMultiple(object, other, orders) {
30590       var index = -1,
30591           objCriteria = object.criteria,
30592           othCriteria = other.criteria,
30593           length = objCriteria.length,
30594           ordersLength = orders.length;
30595
30596       while (++index < length) {
30597         var result = compareAscending(objCriteria[index], othCriteria[index]);
30598         if (result) {
30599           if (index >= ordersLength) {
30600             return result;
30601           }
30602           var order = orders[index];
30603           return result * (order == 'desc' ? -1 : 1);
30604         }
30605       }
30606       // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
30607       // that causes it, under certain circumstances, to provide the same value for
30608       // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
30609       // for more details.
30610       //
30611       // This also ensures a stable sort in V8 and other engines.
30612       // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
30613       return object.index - other.index;
30614     }
30615
30616     /**
30617      * Creates an array that is the composition of partially applied arguments,
30618      * placeholders, and provided arguments into a single array of arguments.
30619      *
30620      * @private
30621      * @param {Array} args The provided arguments.
30622      * @param {Array} partials The arguments to prepend to those provided.
30623      * @param {Array} holders The `partials` placeholder indexes.
30624      * @params {boolean} [isCurried] Specify composing for a curried function.
30625      * @returns {Array} Returns the new array of composed arguments.
30626      */
30627     function composeArgs(args, partials, holders, isCurried) {
30628       var argsIndex = -1,
30629           argsLength = args.length,
30630           holdersLength = holders.length,
30631           leftIndex = -1,
30632           leftLength = partials.length,
30633           rangeLength = nativeMax(argsLength - holdersLength, 0),
30634           result = Array(leftLength + rangeLength),
30635           isUncurried = !isCurried;
30636
30637       while (++leftIndex < leftLength) {
30638         result[leftIndex] = partials[leftIndex];
30639       }
30640       while (++argsIndex < holdersLength) {
30641         if (isUncurried || argsIndex < argsLength) {
30642           result[holders[argsIndex]] = args[argsIndex];
30643         }
30644       }
30645       while (rangeLength--) {
30646         result[leftIndex++] = args[argsIndex++];
30647       }
30648       return result;
30649     }
30650
30651     /**
30652      * This function is like `composeArgs` except that the arguments composition
30653      * is tailored for `_.partialRight`.
30654      *
30655      * @private
30656      * @param {Array} args The provided arguments.
30657      * @param {Array} partials The arguments to append to those provided.
30658      * @param {Array} holders The `partials` placeholder indexes.
30659      * @params {boolean} [isCurried] Specify composing for a curried function.
30660      * @returns {Array} Returns the new array of composed arguments.
30661      */
30662     function composeArgsRight(args, partials, holders, isCurried) {
30663       var argsIndex = -1,
30664           argsLength = args.length,
30665           holdersIndex = -1,
30666           holdersLength = holders.length,
30667           rightIndex = -1,
30668           rightLength = partials.length,
30669           rangeLength = nativeMax(argsLength - holdersLength, 0),
30670           result = Array(rangeLength + rightLength),
30671           isUncurried = !isCurried;
30672
30673       while (++argsIndex < rangeLength) {
30674         result[argsIndex] = args[argsIndex];
30675       }
30676       var offset = argsIndex;
30677       while (++rightIndex < rightLength) {
30678         result[offset + rightIndex] = partials[rightIndex];
30679       }
30680       while (++holdersIndex < holdersLength) {
30681         if (isUncurried || argsIndex < argsLength) {
30682           result[offset + holders[holdersIndex]] = args[argsIndex++];
30683         }
30684       }
30685       return result;
30686     }
30687
30688     /**
30689      * Copies the values of `source` to `array`.
30690      *
30691      * @private
30692      * @param {Array} source The array to copy values from.
30693      * @param {Array} [array=[]] The array to copy values to.
30694      * @returns {Array} Returns `array`.
30695      */
30696     function copyArray(source, array) {
30697       var index = -1,
30698           length = source.length;
30699
30700       array || (array = Array(length));
30701       while (++index < length) {
30702         array[index] = source[index];
30703       }
30704       return array;
30705     }
30706
30707     /**
30708      * Copies properties of `source` to `object`.
30709      *
30710      * @private
30711      * @param {Object} source The object to copy properties from.
30712      * @param {Array} props The property identifiers to copy.
30713      * @param {Object} [object={}] The object to copy properties to.
30714      * @param {Function} [customizer] The function to customize copied values.
30715      * @returns {Object} Returns `object`.
30716      */
30717     function copyObject(source, props, object, customizer) {
30718       var isNew = !object;
30719       object || (object = {});
30720
30721       var index = -1,
30722           length = props.length;
30723
30724       while (++index < length) {
30725         var key = props[index];
30726
30727         var newValue = customizer
30728           ? customizer(object[key], source[key], key, object, source)
30729           : undefined;
30730
30731         if (newValue === undefined) {
30732           newValue = source[key];
30733         }
30734         if (isNew) {
30735           baseAssignValue(object, key, newValue);
30736         } else {
30737           assignValue(object, key, newValue);
30738         }
30739       }
30740       return object;
30741     }
30742
30743     /**
30744      * Copies own symbols of `source` to `object`.
30745      *
30746      * @private
30747      * @param {Object} source The object to copy symbols from.
30748      * @param {Object} [object={}] The object to copy symbols to.
30749      * @returns {Object} Returns `object`.
30750      */
30751     function copySymbols(source, object) {
30752       return copyObject(source, getSymbols(source), object);
30753     }
30754
30755     /**
30756      * Copies own and inherited symbols of `source` to `object`.
30757      *
30758      * @private
30759      * @param {Object} source The object to copy symbols from.
30760      * @param {Object} [object={}] The object to copy symbols to.
30761      * @returns {Object} Returns `object`.
30762      */
30763     function copySymbolsIn(source, object) {
30764       return copyObject(source, getSymbolsIn(source), object);
30765     }
30766
30767     /**
30768      * Creates a function like `_.groupBy`.
30769      *
30770      * @private
30771      * @param {Function} setter The function to set accumulator values.
30772      * @param {Function} [initializer] The accumulator object initializer.
30773      * @returns {Function} Returns the new aggregator function.
30774      */
30775     function createAggregator(setter, initializer) {
30776       return function(collection, iteratee) {
30777         var func = isArray(collection) ? arrayAggregator : baseAggregator,
30778             accumulator = initializer ? initializer() : {};
30779
30780         return func(collection, setter, getIteratee(iteratee, 2), accumulator);
30781       };
30782     }
30783
30784     /**
30785      * Creates a function like `_.assign`.
30786      *
30787      * @private
30788      * @param {Function} assigner The function to assign values.
30789      * @returns {Function} Returns the new assigner function.
30790      */
30791     function createAssigner(assigner) {
30792       return baseRest(function(object, sources) {
30793         var index = -1,
30794             length = sources.length,
30795             customizer = length > 1 ? sources[length - 1] : undefined,
30796             guard = length > 2 ? sources[2] : undefined;
30797
30798         customizer = (assigner.length > 3 && typeof customizer == 'function')
30799           ? (length--, customizer)
30800           : undefined;
30801
30802         if (guard && isIterateeCall(sources[0], sources[1], guard)) {
30803           customizer = length < 3 ? undefined : customizer;
30804           length = 1;
30805         }
30806         object = Object(object);
30807         while (++index < length) {
30808           var source = sources[index];
30809           if (source) {
30810             assigner(object, source, index, customizer);
30811           }
30812         }
30813         return object;
30814       });
30815     }
30816
30817     /**
30818      * Creates a `baseEach` or `baseEachRight` function.
30819      *
30820      * @private
30821      * @param {Function} eachFunc The function to iterate over a collection.
30822      * @param {boolean} [fromRight] Specify iterating from right to left.
30823      * @returns {Function} Returns the new base function.
30824      */
30825     function createBaseEach(eachFunc, fromRight) {
30826       return function(collection, iteratee) {
30827         if (collection == null) {
30828           return collection;
30829         }
30830         if (!isArrayLike(collection)) {
30831           return eachFunc(collection, iteratee);
30832         }
30833         var length = collection.length,
30834             index = fromRight ? length : -1,
30835             iterable = Object(collection);
30836
30837         while ((fromRight ? index-- : ++index < length)) {
30838           if (iteratee(iterable[index], index, iterable) === false) {
30839             break;
30840           }
30841         }
30842         return collection;
30843       };
30844     }
30845
30846     /**
30847      * Creates a base function for methods like `_.forIn` and `_.forOwn`.
30848      *
30849      * @private
30850      * @param {boolean} [fromRight] Specify iterating from right to left.
30851      * @returns {Function} Returns the new base function.
30852      */
30853     function createBaseFor(fromRight) {
30854       return function(object, iteratee, keysFunc) {
30855         var index = -1,
30856             iterable = Object(object),
30857             props = keysFunc(object),
30858             length = props.length;
30859
30860         while (length--) {
30861           var key = props[fromRight ? length : ++index];
30862           if (iteratee(iterable[key], key, iterable) === false) {
30863             break;
30864           }
30865         }
30866         return object;
30867       };
30868     }
30869
30870     /**
30871      * Creates a function that wraps `func` to invoke it with the optional `this`
30872      * binding of `thisArg`.
30873      *
30874      * @private
30875      * @param {Function} func The function to wrap.
30876      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
30877      * @param {*} [thisArg] The `this` binding of `func`.
30878      * @returns {Function} Returns the new wrapped function.
30879      */
30880     function createBind(func, bitmask, thisArg) {
30881       var isBind = bitmask & WRAP_BIND_FLAG,
30882           Ctor = createCtor(func);
30883
30884       function wrapper() {
30885         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
30886         return fn.apply(isBind ? thisArg : this, arguments);
30887       }
30888       return wrapper;
30889     }
30890
30891     /**
30892      * Creates a function like `_.lowerFirst`.
30893      *
30894      * @private
30895      * @param {string} methodName The name of the `String` case method to use.
30896      * @returns {Function} Returns the new case function.
30897      */
30898     function createCaseFirst(methodName) {
30899       return function(string) {
30900         string = toString(string);
30901
30902         var strSymbols = hasUnicode(string)
30903           ? stringToArray(string)
30904           : undefined;
30905
30906         var chr = strSymbols
30907           ? strSymbols[0]
30908           : string.charAt(0);
30909
30910         var trailing = strSymbols
30911           ? castSlice(strSymbols, 1).join('')
30912           : string.slice(1);
30913
30914         return chr[methodName]() + trailing;
30915       };
30916     }
30917
30918     /**
30919      * Creates a function like `_.camelCase`.
30920      *
30921      * @private
30922      * @param {Function} callback The function to combine each word.
30923      * @returns {Function} Returns the new compounder function.
30924      */
30925     function createCompounder(callback) {
30926       return function(string) {
30927         return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
30928       };
30929     }
30930
30931     /**
30932      * Creates a function that produces an instance of `Ctor` regardless of
30933      * whether it was invoked as part of a `new` expression or by `call` or `apply`.
30934      *
30935      * @private
30936      * @param {Function} Ctor The constructor to wrap.
30937      * @returns {Function} Returns the new wrapped function.
30938      */
30939     function createCtor(Ctor) {
30940       return function() {
30941         // Use a `switch` statement to work with class constructors. See
30942         // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
30943         // for more details.
30944         var args = arguments;
30945         switch (args.length) {
30946           case 0: return new Ctor;
30947           case 1: return new Ctor(args[0]);
30948           case 2: return new Ctor(args[0], args[1]);
30949           case 3: return new Ctor(args[0], args[1], args[2]);
30950           case 4: return new Ctor(args[0], args[1], args[2], args[3]);
30951           case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
30952           case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
30953           case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
30954         }
30955         var thisBinding = baseCreate(Ctor.prototype),
30956             result = Ctor.apply(thisBinding, args);
30957
30958         // Mimic the constructor's `return` behavior.
30959         // See https://es5.github.io/#x13.2.2 for more details.
30960         return isObject(result) ? result : thisBinding;
30961       };
30962     }
30963
30964     /**
30965      * Creates a function that wraps `func` to enable currying.
30966      *
30967      * @private
30968      * @param {Function} func The function to wrap.
30969      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
30970      * @param {number} arity The arity of `func`.
30971      * @returns {Function} Returns the new wrapped function.
30972      */
30973     function createCurry(func, bitmask, arity) {
30974       var Ctor = createCtor(func);
30975
30976       function wrapper() {
30977         var length = arguments.length,
30978             args = Array(length),
30979             index = length,
30980             placeholder = getHolder(wrapper);
30981
30982         while (index--) {
30983           args[index] = arguments[index];
30984         }
30985         var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
30986           ? []
30987           : replaceHolders(args, placeholder);
30988
30989         length -= holders.length;
30990         if (length < arity) {
30991           return createRecurry(
30992             func, bitmask, createHybrid, wrapper.placeholder, undefined,
30993             args, holders, undefined, undefined, arity - length);
30994         }
30995         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
30996         return apply(fn, this, args);
30997       }
30998       return wrapper;
30999     }
31000
31001     /**
31002      * Creates a `_.find` or `_.findLast` function.
31003      *
31004      * @private
31005      * @param {Function} findIndexFunc The function to find the collection index.
31006      * @returns {Function} Returns the new find function.
31007      */
31008     function createFind(findIndexFunc) {
31009       return function(collection, predicate, fromIndex) {
31010         var iterable = Object(collection);
31011         if (!isArrayLike(collection)) {
31012           var iteratee = getIteratee(predicate, 3);
31013           collection = keys(collection);
31014           predicate = function(key) { return iteratee(iterable[key], key, iterable); };
31015         }
31016         var index = findIndexFunc(collection, predicate, fromIndex);
31017         return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
31018       };
31019     }
31020
31021     /**
31022      * Creates a `_.flow` or `_.flowRight` function.
31023      *
31024      * @private
31025      * @param {boolean} [fromRight] Specify iterating from right to left.
31026      * @returns {Function} Returns the new flow function.
31027      */
31028     function createFlow(fromRight) {
31029       return flatRest(function(funcs) {
31030         var length = funcs.length,
31031             index = length,
31032             prereq = LodashWrapper.prototype.thru;
31033
31034         if (fromRight) {
31035           funcs.reverse();
31036         }
31037         while (index--) {
31038           var func = funcs[index];
31039           if (typeof func != 'function') {
31040             throw new TypeError(FUNC_ERROR_TEXT);
31041           }
31042           if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
31043             var wrapper = new LodashWrapper([], true);
31044           }
31045         }
31046         index = wrapper ? index : length;
31047         while (++index < length) {
31048           func = funcs[index];
31049
31050           var funcName = getFuncName(func),
31051               data = funcName == 'wrapper' ? getData(func) : undefined;
31052
31053           if (data && isLaziable(data[0]) &&
31054                 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
31055                 !data[4].length && data[9] == 1
31056               ) {
31057             wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
31058           } else {
31059             wrapper = (func.length == 1 && isLaziable(func))
31060               ? wrapper[funcName]()
31061               : wrapper.thru(func);
31062           }
31063         }
31064         return function() {
31065           var args = arguments,
31066               value = args[0];
31067
31068           if (wrapper && args.length == 1 && isArray(value)) {
31069             return wrapper.plant(value).value();
31070           }
31071           var index = 0,
31072               result = length ? funcs[index].apply(this, args) : value;
31073
31074           while (++index < length) {
31075             result = funcs[index].call(this, result);
31076           }
31077           return result;
31078         };
31079       });
31080     }
31081
31082     /**
31083      * Creates a function that wraps `func` to invoke it with optional `this`
31084      * binding of `thisArg`, partial application, and currying.
31085      *
31086      * @private
31087      * @param {Function|string} func The function or method name to wrap.
31088      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31089      * @param {*} [thisArg] The `this` binding of `func`.
31090      * @param {Array} [partials] The arguments to prepend to those provided to
31091      *  the new function.
31092      * @param {Array} [holders] The `partials` placeholder indexes.
31093      * @param {Array} [partialsRight] The arguments to append to those provided
31094      *  to the new function.
31095      * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
31096      * @param {Array} [argPos] The argument positions of the new function.
31097      * @param {number} [ary] The arity cap of `func`.
31098      * @param {number} [arity] The arity of `func`.
31099      * @returns {Function} Returns the new wrapped function.
31100      */
31101     function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
31102       var isAry = bitmask & WRAP_ARY_FLAG,
31103           isBind = bitmask & WRAP_BIND_FLAG,
31104           isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
31105           isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
31106           isFlip = bitmask & WRAP_FLIP_FLAG,
31107           Ctor = isBindKey ? undefined : createCtor(func);
31108
31109       function wrapper() {
31110         var length = arguments.length,
31111             args = Array(length),
31112             index = length;
31113
31114         while (index--) {
31115           args[index] = arguments[index];
31116         }
31117         if (isCurried) {
31118           var placeholder = getHolder(wrapper),
31119               holdersCount = countHolders(args, placeholder);
31120         }
31121         if (partials) {
31122           args = composeArgs(args, partials, holders, isCurried);
31123         }
31124         if (partialsRight) {
31125           args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
31126         }
31127         length -= holdersCount;
31128         if (isCurried && length < arity) {
31129           var newHolders = replaceHolders(args, placeholder);
31130           return createRecurry(
31131             func, bitmask, createHybrid, wrapper.placeholder, thisArg,
31132             args, newHolders, argPos, ary, arity - length
31133           );
31134         }
31135         var thisBinding = isBind ? thisArg : this,
31136             fn = isBindKey ? thisBinding[func] : func;
31137
31138         length = args.length;
31139         if (argPos) {
31140           args = reorder(args, argPos);
31141         } else if (isFlip && length > 1) {
31142           args.reverse();
31143         }
31144         if (isAry && ary < length) {
31145           args.length = ary;
31146         }
31147         if (this && this !== root && this instanceof wrapper) {
31148           fn = Ctor || createCtor(fn);
31149         }
31150         return fn.apply(thisBinding, args);
31151       }
31152       return wrapper;
31153     }
31154
31155     /**
31156      * Creates a function like `_.invertBy`.
31157      *
31158      * @private
31159      * @param {Function} setter The function to set accumulator values.
31160      * @param {Function} toIteratee The function to resolve iteratees.
31161      * @returns {Function} Returns the new inverter function.
31162      */
31163     function createInverter(setter, toIteratee) {
31164       return function(object, iteratee) {
31165         return baseInverter(object, setter, toIteratee(iteratee), {});
31166       };
31167     }
31168
31169     /**
31170      * Creates a function that performs a mathematical operation on two values.
31171      *
31172      * @private
31173      * @param {Function} operator The function to perform the operation.
31174      * @param {number} [defaultValue] The value used for `undefined` arguments.
31175      * @returns {Function} Returns the new mathematical operation function.
31176      */
31177     function createMathOperation(operator, defaultValue) {
31178       return function(value, other) {
31179         var result;
31180         if (value === undefined && other === undefined) {
31181           return defaultValue;
31182         }
31183         if (value !== undefined) {
31184           result = value;
31185         }
31186         if (other !== undefined) {
31187           if (result === undefined) {
31188             return other;
31189           }
31190           if (typeof value == 'string' || typeof other == 'string') {
31191             value = baseToString(value);
31192             other = baseToString(other);
31193           } else {
31194             value = baseToNumber(value);
31195             other = baseToNumber(other);
31196           }
31197           result = operator(value, other);
31198         }
31199         return result;
31200       };
31201     }
31202
31203     /**
31204      * Creates a function like `_.over`.
31205      *
31206      * @private
31207      * @param {Function} arrayFunc The function to iterate over iteratees.
31208      * @returns {Function} Returns the new over function.
31209      */
31210     function createOver(arrayFunc) {
31211       return flatRest(function(iteratees) {
31212         iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
31213         return baseRest(function(args) {
31214           var thisArg = this;
31215           return arrayFunc(iteratees, function(iteratee) {
31216             return apply(iteratee, thisArg, args);
31217           });
31218         });
31219       });
31220     }
31221
31222     /**
31223      * Creates the padding for `string` based on `length`. The `chars` string
31224      * is truncated if the number of characters exceeds `length`.
31225      *
31226      * @private
31227      * @param {number} length The padding length.
31228      * @param {string} [chars=' '] The string used as padding.
31229      * @returns {string} Returns the padding for `string`.
31230      */
31231     function createPadding(length, chars) {
31232       chars = chars === undefined ? ' ' : baseToString(chars);
31233
31234       var charsLength = chars.length;
31235       if (charsLength < 2) {
31236         return charsLength ? baseRepeat(chars, length) : chars;
31237       }
31238       var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
31239       return hasUnicode(chars)
31240         ? castSlice(stringToArray(result), 0, length).join('')
31241         : result.slice(0, length);
31242     }
31243
31244     /**
31245      * Creates a function that wraps `func` to invoke it with the `this` binding
31246      * of `thisArg` and `partials` prepended to the arguments it receives.
31247      *
31248      * @private
31249      * @param {Function} func The function to wrap.
31250      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31251      * @param {*} thisArg The `this` binding of `func`.
31252      * @param {Array} partials The arguments to prepend to those provided to
31253      *  the new function.
31254      * @returns {Function} Returns the new wrapped function.
31255      */
31256     function createPartial(func, bitmask, thisArg, partials) {
31257       var isBind = bitmask & WRAP_BIND_FLAG,
31258           Ctor = createCtor(func);
31259
31260       function wrapper() {
31261         var argsIndex = -1,
31262             argsLength = arguments.length,
31263             leftIndex = -1,
31264             leftLength = partials.length,
31265             args = Array(leftLength + argsLength),
31266             fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
31267
31268         while (++leftIndex < leftLength) {
31269           args[leftIndex] = partials[leftIndex];
31270         }
31271         while (argsLength--) {
31272           args[leftIndex++] = arguments[++argsIndex];
31273         }
31274         return apply(fn, isBind ? thisArg : this, args);
31275       }
31276       return wrapper;
31277     }
31278
31279     /**
31280      * Creates a `_.range` or `_.rangeRight` function.
31281      *
31282      * @private
31283      * @param {boolean} [fromRight] Specify iterating from right to left.
31284      * @returns {Function} Returns the new range function.
31285      */
31286     function createRange(fromRight) {
31287       return function(start, end, step) {
31288         if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
31289           end = step = undefined;
31290         }
31291         // Ensure the sign of `-0` is preserved.
31292         start = toFinite(start);
31293         if (end === undefined) {
31294           end = start;
31295           start = 0;
31296         } else {
31297           end = toFinite(end);
31298         }
31299         step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
31300         return baseRange(start, end, step, fromRight);
31301       };
31302     }
31303
31304     /**
31305      * Creates a function that performs a relational operation on two values.
31306      *
31307      * @private
31308      * @param {Function} operator The function to perform the operation.
31309      * @returns {Function} Returns the new relational operation function.
31310      */
31311     function createRelationalOperation(operator) {
31312       return function(value, other) {
31313         if (!(typeof value == 'string' && typeof other == 'string')) {
31314           value = toNumber(value);
31315           other = toNumber(other);
31316         }
31317         return operator(value, other);
31318       };
31319     }
31320
31321     /**
31322      * Creates a function that wraps `func` to continue currying.
31323      *
31324      * @private
31325      * @param {Function} func The function to wrap.
31326      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31327      * @param {Function} wrapFunc The function to create the `func` wrapper.
31328      * @param {*} placeholder The placeholder value.
31329      * @param {*} [thisArg] The `this` binding of `func`.
31330      * @param {Array} [partials] The arguments to prepend to those provided to
31331      *  the new function.
31332      * @param {Array} [holders] The `partials` placeholder indexes.
31333      * @param {Array} [argPos] The argument positions of the new function.
31334      * @param {number} [ary] The arity cap of `func`.
31335      * @param {number} [arity] The arity of `func`.
31336      * @returns {Function} Returns the new wrapped function.
31337      */
31338     function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
31339       var isCurry = bitmask & WRAP_CURRY_FLAG,
31340           newHolders = isCurry ? holders : undefined,
31341           newHoldersRight = isCurry ? undefined : holders,
31342           newPartials = isCurry ? partials : undefined,
31343           newPartialsRight = isCurry ? undefined : partials;
31344
31345       bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
31346       bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
31347
31348       if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
31349         bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
31350       }
31351       var newData = [
31352         func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
31353         newHoldersRight, argPos, ary, arity
31354       ];
31355
31356       var result = wrapFunc.apply(undefined, newData);
31357       if (isLaziable(func)) {
31358         setData(result, newData);
31359       }
31360       result.placeholder = placeholder;
31361       return setWrapToString(result, func, bitmask);
31362     }
31363
31364     /**
31365      * Creates a function like `_.round`.
31366      *
31367      * @private
31368      * @param {string} methodName The name of the `Math` method to use when rounding.
31369      * @returns {Function} Returns the new round function.
31370      */
31371     function createRound(methodName) {
31372       var func = Math[methodName];
31373       return function(number, precision) {
31374         number = toNumber(number);
31375         precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
31376         if (precision && nativeIsFinite(number)) {
31377           // Shift with exponential notation to avoid floating-point issues.
31378           // See [MDN](https://mdn.io/round#Examples) for more details.
31379           var pair = (toString(number) + 'e').split('e'),
31380               value = func(pair[0] + 'e' + (+pair[1] + precision));
31381
31382           pair = (toString(value) + 'e').split('e');
31383           return +(pair[0] + 'e' + (+pair[1] - precision));
31384         }
31385         return func(number);
31386       };
31387     }
31388
31389     /**
31390      * Creates a set object of `values`.
31391      *
31392      * @private
31393      * @param {Array} values The values to add to the set.
31394      * @returns {Object} Returns the new set.
31395      */
31396     var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
31397       return new Set(values);
31398     };
31399
31400     /**
31401      * Creates a `_.toPairs` or `_.toPairsIn` function.
31402      *
31403      * @private
31404      * @param {Function} keysFunc The function to get the keys of a given object.
31405      * @returns {Function} Returns the new pairs function.
31406      */
31407     function createToPairs(keysFunc) {
31408       return function(object) {
31409         var tag = getTag(object);
31410         if (tag == mapTag) {
31411           return mapToArray(object);
31412         }
31413         if (tag == setTag) {
31414           return setToPairs(object);
31415         }
31416         return baseToPairs(object, keysFunc(object));
31417       };
31418     }
31419
31420     /**
31421      * Creates a function that either curries or invokes `func` with optional
31422      * `this` binding and partially applied arguments.
31423      *
31424      * @private
31425      * @param {Function|string} func The function or method name to wrap.
31426      * @param {number} bitmask The bitmask flags.
31427      *    1 - `_.bind`
31428      *    2 - `_.bindKey`
31429      *    4 - `_.curry` or `_.curryRight` of a bound function
31430      *    8 - `_.curry`
31431      *   16 - `_.curryRight`
31432      *   32 - `_.partial`
31433      *   64 - `_.partialRight`
31434      *  128 - `_.rearg`
31435      *  256 - `_.ary`
31436      *  512 - `_.flip`
31437      * @param {*} [thisArg] The `this` binding of `func`.
31438      * @param {Array} [partials] The arguments to be partially applied.
31439      * @param {Array} [holders] The `partials` placeholder indexes.
31440      * @param {Array} [argPos] The argument positions of the new function.
31441      * @param {number} [ary] The arity cap of `func`.
31442      * @param {number} [arity] The arity of `func`.
31443      * @returns {Function} Returns the new wrapped function.
31444      */
31445     function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
31446       var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
31447       if (!isBindKey && typeof func != 'function') {
31448         throw new TypeError(FUNC_ERROR_TEXT);
31449       }
31450       var length = partials ? partials.length : 0;
31451       if (!length) {
31452         bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
31453         partials = holders = undefined;
31454       }
31455       ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
31456       arity = arity === undefined ? arity : toInteger(arity);
31457       length -= holders ? holders.length : 0;
31458
31459       if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
31460         var partialsRight = partials,
31461             holdersRight = holders;
31462
31463         partials = holders = undefined;
31464       }
31465       var data = isBindKey ? undefined : getData(func);
31466
31467       var newData = [
31468         func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
31469         argPos, ary, arity
31470       ];
31471
31472       if (data) {
31473         mergeData(newData, data);
31474       }
31475       func = newData[0];
31476       bitmask = newData[1];
31477       thisArg = newData[2];
31478       partials = newData[3];
31479       holders = newData[4];
31480       arity = newData[9] = newData[9] === undefined
31481         ? (isBindKey ? 0 : func.length)
31482         : nativeMax(newData[9] - length, 0);
31483
31484       if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
31485         bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
31486       }
31487       if (!bitmask || bitmask == WRAP_BIND_FLAG) {
31488         var result = createBind(func, bitmask, thisArg);
31489       } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
31490         result = createCurry(func, bitmask, arity);
31491       } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
31492         result = createPartial(func, bitmask, thisArg, partials);
31493       } else {
31494         result = createHybrid.apply(undefined, newData);
31495       }
31496       var setter = data ? baseSetData : setData;
31497       return setWrapToString(setter(result, newData), func, bitmask);
31498     }
31499
31500     /**
31501      * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
31502      * of source objects to the destination object for all destination properties
31503      * that resolve to `undefined`.
31504      *
31505      * @private
31506      * @param {*} objValue The destination value.
31507      * @param {*} srcValue The source value.
31508      * @param {string} key The key of the property to assign.
31509      * @param {Object} object The parent object of `objValue`.
31510      * @returns {*} Returns the value to assign.
31511      */
31512     function customDefaultsAssignIn(objValue, srcValue, key, object) {
31513       if (objValue === undefined ||
31514           (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
31515         return srcValue;
31516       }
31517       return objValue;
31518     }
31519
31520     /**
31521      * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
31522      * objects into destination objects that are passed thru.
31523      *
31524      * @private
31525      * @param {*} objValue The destination value.
31526      * @param {*} srcValue The source value.
31527      * @param {string} key The key of the property to merge.
31528      * @param {Object} object The parent object of `objValue`.
31529      * @param {Object} source The parent object of `srcValue`.
31530      * @param {Object} [stack] Tracks traversed source values and their merged
31531      *  counterparts.
31532      * @returns {*} Returns the value to assign.
31533      */
31534     function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
31535       if (isObject(objValue) && isObject(srcValue)) {
31536         // Recursively merge objects and arrays (susceptible to call stack limits).
31537         stack.set(srcValue, objValue);
31538         baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
31539         stack['delete'](srcValue);
31540       }
31541       return objValue;
31542     }
31543
31544     /**
31545      * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
31546      * objects.
31547      *
31548      * @private
31549      * @param {*} value The value to inspect.
31550      * @param {string} key The key of the property to inspect.
31551      * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
31552      */
31553     function customOmitClone(value) {
31554       return isPlainObject(value) ? undefined : value;
31555     }
31556
31557     /**
31558      * A specialized version of `baseIsEqualDeep` for arrays with support for
31559      * partial deep comparisons.
31560      *
31561      * @private
31562      * @param {Array} array The array to compare.
31563      * @param {Array} other The other array to compare.
31564      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
31565      * @param {Function} customizer The function to customize comparisons.
31566      * @param {Function} equalFunc The function to determine equivalents of values.
31567      * @param {Object} stack Tracks traversed `array` and `other` objects.
31568      * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
31569      */
31570     function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
31571       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
31572           arrLength = array.length,
31573           othLength = other.length;
31574
31575       if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
31576         return false;
31577       }
31578       // Assume cyclic values are equal.
31579       var stacked = stack.get(array);
31580       if (stacked && stack.get(other)) {
31581         return stacked == other;
31582       }
31583       var index = -1,
31584           result = true,
31585           seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
31586
31587       stack.set(array, other);
31588       stack.set(other, array);
31589
31590       // Ignore non-index properties.
31591       while (++index < arrLength) {
31592         var arrValue = array[index],
31593             othValue = other[index];
31594
31595         if (customizer) {
31596           var compared = isPartial
31597             ? customizer(othValue, arrValue, index, other, array, stack)
31598             : customizer(arrValue, othValue, index, array, other, stack);
31599         }
31600         if (compared !== undefined) {
31601           if (compared) {
31602             continue;
31603           }
31604           result = false;
31605           break;
31606         }
31607         // Recursively compare arrays (susceptible to call stack limits).
31608         if (seen) {
31609           if (!arraySome(other, function(othValue, othIndex) {
31610                 if (!cacheHas(seen, othIndex) &&
31611                     (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
31612                   return seen.push(othIndex);
31613                 }
31614               })) {
31615             result = false;
31616             break;
31617           }
31618         } else if (!(
31619               arrValue === othValue ||
31620                 equalFunc(arrValue, othValue, bitmask, customizer, stack)
31621             )) {
31622           result = false;
31623           break;
31624         }
31625       }
31626       stack['delete'](array);
31627       stack['delete'](other);
31628       return result;
31629     }
31630
31631     /**
31632      * A specialized version of `baseIsEqualDeep` for comparing objects of
31633      * the same `toStringTag`.
31634      *
31635      * **Note:** This function only supports comparing values with tags of
31636      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
31637      *
31638      * @private
31639      * @param {Object} object The object to compare.
31640      * @param {Object} other The other object to compare.
31641      * @param {string} tag The `toStringTag` of the objects to compare.
31642      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
31643      * @param {Function} customizer The function to customize comparisons.
31644      * @param {Function} equalFunc The function to determine equivalents of values.
31645      * @param {Object} stack Tracks traversed `object` and `other` objects.
31646      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
31647      */
31648     function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
31649       switch (tag) {
31650         case dataViewTag:
31651           if ((object.byteLength != other.byteLength) ||
31652               (object.byteOffset != other.byteOffset)) {
31653             return false;
31654           }
31655           object = object.buffer;
31656           other = other.buffer;
31657
31658         case arrayBufferTag:
31659           if ((object.byteLength != other.byteLength) ||
31660               !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
31661             return false;
31662           }
31663           return true;
31664
31665         case boolTag:
31666         case dateTag:
31667         case numberTag:
31668           // Coerce booleans to `1` or `0` and dates to milliseconds.
31669           // Invalid dates are coerced to `NaN`.
31670           return eq(+object, +other);
31671
31672         case errorTag:
31673           return object.name == other.name && object.message == other.message;
31674
31675         case regexpTag:
31676         case stringTag:
31677           // Coerce regexes to strings and treat strings, primitives and objects,
31678           // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
31679           // for more details.
31680           return object == (other + '');
31681
31682         case mapTag:
31683           var convert = mapToArray;
31684
31685         case setTag:
31686           var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
31687           convert || (convert = setToArray);
31688
31689           if (object.size != other.size && !isPartial) {
31690             return false;
31691           }
31692           // Assume cyclic values are equal.
31693           var stacked = stack.get(object);
31694           if (stacked) {
31695             return stacked == other;
31696           }
31697           bitmask |= COMPARE_UNORDERED_FLAG;
31698
31699           // Recursively compare objects (susceptible to call stack limits).
31700           stack.set(object, other);
31701           var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
31702           stack['delete'](object);
31703           return result;
31704
31705         case symbolTag:
31706           if (symbolValueOf) {
31707             return symbolValueOf.call(object) == symbolValueOf.call(other);
31708           }
31709       }
31710       return false;
31711     }
31712
31713     /**
31714      * A specialized version of `baseIsEqualDeep` for objects with support for
31715      * partial deep comparisons.
31716      *
31717      * @private
31718      * @param {Object} object The object to compare.
31719      * @param {Object} other The other object to compare.
31720      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
31721      * @param {Function} customizer The function to customize comparisons.
31722      * @param {Function} equalFunc The function to determine equivalents of values.
31723      * @param {Object} stack Tracks traversed `object` and `other` objects.
31724      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
31725      */
31726     function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
31727       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
31728           objProps = getAllKeys(object),
31729           objLength = objProps.length,
31730           othProps = getAllKeys(other),
31731           othLength = othProps.length;
31732
31733       if (objLength != othLength && !isPartial) {
31734         return false;
31735       }
31736       var index = objLength;
31737       while (index--) {
31738         var key = objProps[index];
31739         if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
31740           return false;
31741         }
31742       }
31743       // Assume cyclic values are equal.
31744       var stacked = stack.get(object);
31745       if (stacked && stack.get(other)) {
31746         return stacked == other;
31747       }
31748       var result = true;
31749       stack.set(object, other);
31750       stack.set(other, object);
31751
31752       var skipCtor = isPartial;
31753       while (++index < objLength) {
31754         key = objProps[index];
31755         var objValue = object[key],
31756             othValue = other[key];
31757
31758         if (customizer) {
31759           var compared = isPartial
31760             ? customizer(othValue, objValue, key, other, object, stack)
31761             : customizer(objValue, othValue, key, object, other, stack);
31762         }
31763         // Recursively compare objects (susceptible to call stack limits).
31764         if (!(compared === undefined
31765               ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
31766               : compared
31767             )) {
31768           result = false;
31769           break;
31770         }
31771         skipCtor || (skipCtor = key == 'constructor');
31772       }
31773       if (result && !skipCtor) {
31774         var objCtor = object.constructor,
31775             othCtor = other.constructor;
31776
31777         // Non `Object` object instances with different constructors are not equal.
31778         if (objCtor != othCtor &&
31779             ('constructor' in object && 'constructor' in other) &&
31780             !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
31781               typeof othCtor == 'function' && othCtor instanceof othCtor)) {
31782           result = false;
31783         }
31784       }
31785       stack['delete'](object);
31786       stack['delete'](other);
31787       return result;
31788     }
31789
31790     /**
31791      * A specialized version of `baseRest` which flattens the rest array.
31792      *
31793      * @private
31794      * @param {Function} func The function to apply a rest parameter to.
31795      * @returns {Function} Returns the new function.
31796      */
31797     function flatRest(func) {
31798       return setToString(overRest(func, undefined, flatten), func + '');
31799     }
31800
31801     /**
31802      * Creates an array of own enumerable property names and symbols of `object`.
31803      *
31804      * @private
31805      * @param {Object} object The object to query.
31806      * @returns {Array} Returns the array of property names and symbols.
31807      */
31808     function getAllKeys(object) {
31809       return baseGetAllKeys(object, keys, getSymbols);
31810     }
31811
31812     /**
31813      * Creates an array of own and inherited enumerable property names and
31814      * symbols of `object`.
31815      *
31816      * @private
31817      * @param {Object} object The object to query.
31818      * @returns {Array} Returns the array of property names and symbols.
31819      */
31820     function getAllKeysIn(object) {
31821       return baseGetAllKeys(object, keysIn, getSymbolsIn);
31822     }
31823
31824     /**
31825      * Gets metadata for `func`.
31826      *
31827      * @private
31828      * @param {Function} func The function to query.
31829      * @returns {*} Returns the metadata for `func`.
31830      */
31831     var getData = !metaMap ? noop : function(func) {
31832       return metaMap.get(func);
31833     };
31834
31835     /**
31836      * Gets the name of `func`.
31837      *
31838      * @private
31839      * @param {Function} func The function to query.
31840      * @returns {string} Returns the function name.
31841      */
31842     function getFuncName(func) {
31843       var result = (func.name + ''),
31844           array = realNames[result],
31845           length = hasOwnProperty.call(realNames, result) ? array.length : 0;
31846
31847       while (length--) {
31848         var data = array[length],
31849             otherFunc = data.func;
31850         if (otherFunc == null || otherFunc == func) {
31851           return data.name;
31852         }
31853       }
31854       return result;
31855     }
31856
31857     /**
31858      * Gets the argument placeholder value for `func`.
31859      *
31860      * @private
31861      * @param {Function} func The function to inspect.
31862      * @returns {*} Returns the placeholder value.
31863      */
31864     function getHolder(func) {
31865       var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
31866       return object.placeholder;
31867     }
31868
31869     /**
31870      * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
31871      * this function returns the custom method, otherwise it returns `baseIteratee`.
31872      * If arguments are provided, the chosen function is invoked with them and
31873      * its result is returned.
31874      *
31875      * @private
31876      * @param {*} [value] The value to convert to an iteratee.
31877      * @param {number} [arity] The arity of the created iteratee.
31878      * @returns {Function} Returns the chosen function or its result.
31879      */
31880     function getIteratee() {
31881       var result = lodash.iteratee || iteratee;
31882       result = result === iteratee ? baseIteratee : result;
31883       return arguments.length ? result(arguments[0], arguments[1]) : result;
31884     }
31885
31886     /**
31887      * Gets the data for `map`.
31888      *
31889      * @private
31890      * @param {Object} map The map to query.
31891      * @param {string} key The reference key.
31892      * @returns {*} Returns the map data.
31893      */
31894     function getMapData(map, key) {
31895       var data = map.__data__;
31896       return isKeyable(key)
31897         ? data[typeof key == 'string' ? 'string' : 'hash']
31898         : data.map;
31899     }
31900
31901     /**
31902      * Gets the property names, values, and compare flags of `object`.
31903      *
31904      * @private
31905      * @param {Object} object The object to query.
31906      * @returns {Array} Returns the match data of `object`.
31907      */
31908     function getMatchData(object) {
31909       var result = keys(object),
31910           length = result.length;
31911
31912       while (length--) {
31913         var key = result[length],
31914             value = object[key];
31915
31916         result[length] = [key, value, isStrictComparable(value)];
31917       }
31918       return result;
31919     }
31920
31921     /**
31922      * Gets the native function at `key` of `object`.
31923      *
31924      * @private
31925      * @param {Object} object The object to query.
31926      * @param {string} key The key of the method to get.
31927      * @returns {*} Returns the function if it's native, else `undefined`.
31928      */
31929     function getNative(object, key) {
31930       var value = getValue(object, key);
31931       return baseIsNative(value) ? value : undefined;
31932     }
31933
31934     /**
31935      * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
31936      *
31937      * @private
31938      * @param {*} value The value to query.
31939      * @returns {string} Returns the raw `toStringTag`.
31940      */
31941     function getRawTag(value) {
31942       var isOwn = hasOwnProperty.call(value, symToStringTag),
31943           tag = value[symToStringTag];
31944
31945       try {
31946         value[symToStringTag] = undefined;
31947         var unmasked = true;
31948       } catch (e) {}
31949
31950       var result = nativeObjectToString.call(value);
31951       if (unmasked) {
31952         if (isOwn) {
31953           value[symToStringTag] = tag;
31954         } else {
31955           delete value[symToStringTag];
31956         }
31957       }
31958       return result;
31959     }
31960
31961     /**
31962      * Creates an array of the own enumerable symbols of `object`.
31963      *
31964      * @private
31965      * @param {Object} object The object to query.
31966      * @returns {Array} Returns the array of symbols.
31967      */
31968     var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
31969       if (object == null) {
31970         return [];
31971       }
31972       object = Object(object);
31973       return arrayFilter(nativeGetSymbols(object), function(symbol) {
31974         return propertyIsEnumerable.call(object, symbol);
31975       });
31976     };
31977
31978     /**
31979      * Creates an array of the own and inherited enumerable symbols of `object`.
31980      *
31981      * @private
31982      * @param {Object} object The object to query.
31983      * @returns {Array} Returns the array of symbols.
31984      */
31985     var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
31986       var result = [];
31987       while (object) {
31988         arrayPush(result, getSymbols(object));
31989         object = getPrototype(object);
31990       }
31991       return result;
31992     };
31993
31994     /**
31995      * Gets the `toStringTag` of `value`.
31996      *
31997      * @private
31998      * @param {*} value The value to query.
31999      * @returns {string} Returns the `toStringTag`.
32000      */
32001     var getTag = baseGetTag;
32002
32003     // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
32004     if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
32005         (Map && getTag(new Map) != mapTag) ||
32006         (Promise && getTag(Promise.resolve()) != promiseTag) ||
32007         (Set && getTag(new Set) != setTag) ||
32008         (WeakMap && getTag(new WeakMap) != weakMapTag)) {
32009       getTag = function(value) {
32010         var result = baseGetTag(value),
32011             Ctor = result == objectTag ? value.constructor : undefined,
32012             ctorString = Ctor ? toSource(Ctor) : '';
32013
32014         if (ctorString) {
32015           switch (ctorString) {
32016             case dataViewCtorString: return dataViewTag;
32017             case mapCtorString: return mapTag;
32018             case promiseCtorString: return promiseTag;
32019             case setCtorString: return setTag;
32020             case weakMapCtorString: return weakMapTag;
32021           }
32022         }
32023         return result;
32024       };
32025     }
32026
32027     /**
32028      * Gets the view, applying any `transforms` to the `start` and `end` positions.
32029      *
32030      * @private
32031      * @param {number} start The start of the view.
32032      * @param {number} end The end of the view.
32033      * @param {Array} transforms The transformations to apply to the view.
32034      * @returns {Object} Returns an object containing the `start` and `end`
32035      *  positions of the view.
32036      */
32037     function getView(start, end, transforms) {
32038       var index = -1,
32039           length = transforms.length;
32040
32041       while (++index < length) {
32042         var data = transforms[index],
32043             size = data.size;
32044
32045         switch (data.type) {
32046           case 'drop':      start += size; break;
32047           case 'dropRight': end -= size; break;
32048           case 'take':      end = nativeMin(end, start + size); break;
32049           case 'takeRight': start = nativeMax(start, end - size); break;
32050         }
32051       }
32052       return { 'start': start, 'end': end };
32053     }
32054
32055     /**
32056      * Extracts wrapper details from the `source` body comment.
32057      *
32058      * @private
32059      * @param {string} source The source to inspect.
32060      * @returns {Array} Returns the wrapper details.
32061      */
32062     function getWrapDetails(source) {
32063       var match = source.match(reWrapDetails);
32064       return match ? match[1].split(reSplitDetails) : [];
32065     }
32066
32067     /**
32068      * Checks if `path` exists on `object`.
32069      *
32070      * @private
32071      * @param {Object} object The object to query.
32072      * @param {Array|string} path The path to check.
32073      * @param {Function} hasFunc The function to check properties.
32074      * @returns {boolean} Returns `true` if `path` exists, else `false`.
32075      */
32076     function hasPath(object, path, hasFunc) {
32077       path = castPath(path, object);
32078
32079       var index = -1,
32080           length = path.length,
32081           result = false;
32082
32083       while (++index < length) {
32084         var key = toKey(path[index]);
32085         if (!(result = object != null && hasFunc(object, key))) {
32086           break;
32087         }
32088         object = object[key];
32089       }
32090       if (result || ++index != length) {
32091         return result;
32092       }
32093       length = object == null ? 0 : object.length;
32094       return !!length && isLength(length) && isIndex(key, length) &&
32095         (isArray(object) || isArguments(object));
32096     }
32097
32098     /**
32099      * Initializes an array clone.
32100      *
32101      * @private
32102      * @param {Array} array The array to clone.
32103      * @returns {Array} Returns the initialized clone.
32104      */
32105     function initCloneArray(array) {
32106       var length = array.length,
32107           result = new array.constructor(length);
32108
32109       // Add properties assigned by `RegExp#exec`.
32110       if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
32111         result.index = array.index;
32112         result.input = array.input;
32113       }
32114       return result;
32115     }
32116
32117     /**
32118      * Initializes an object clone.
32119      *
32120      * @private
32121      * @param {Object} object The object to clone.
32122      * @returns {Object} Returns the initialized clone.
32123      */
32124     function initCloneObject(object) {
32125       return (typeof object.constructor == 'function' && !isPrototype(object))
32126         ? baseCreate(getPrototype(object))
32127         : {};
32128     }
32129
32130     /**
32131      * Initializes an object clone based on its `toStringTag`.
32132      *
32133      * **Note:** This function only supports cloning values with tags of
32134      * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
32135      *
32136      * @private
32137      * @param {Object} object The object to clone.
32138      * @param {string} tag The `toStringTag` of the object to clone.
32139      * @param {boolean} [isDeep] Specify a deep clone.
32140      * @returns {Object} Returns the initialized clone.
32141      */
32142     function initCloneByTag(object, tag, isDeep) {
32143       var Ctor = object.constructor;
32144       switch (tag) {
32145         case arrayBufferTag:
32146           return cloneArrayBuffer(object);
32147
32148         case boolTag:
32149         case dateTag:
32150           return new Ctor(+object);
32151
32152         case dataViewTag:
32153           return cloneDataView(object, isDeep);
32154
32155         case float32Tag: case float64Tag:
32156         case int8Tag: case int16Tag: case int32Tag:
32157         case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
32158           return cloneTypedArray(object, isDeep);
32159
32160         case mapTag:
32161           return new Ctor;
32162
32163         case numberTag:
32164         case stringTag:
32165           return new Ctor(object);
32166
32167         case regexpTag:
32168           return cloneRegExp(object);
32169
32170         case setTag:
32171           return new Ctor;
32172
32173         case symbolTag:
32174           return cloneSymbol(object);
32175       }
32176     }
32177
32178     /**
32179      * Inserts wrapper `details` in a comment at the top of the `source` body.
32180      *
32181      * @private
32182      * @param {string} source The source to modify.
32183      * @returns {Array} details The details to insert.
32184      * @returns {string} Returns the modified source.
32185      */
32186     function insertWrapDetails(source, details) {
32187       var length = details.length;
32188       if (!length) {
32189         return source;
32190       }
32191       var lastIndex = length - 1;
32192       details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
32193       details = details.join(length > 2 ? ', ' : ' ');
32194       return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
32195     }
32196
32197     /**
32198      * Checks if `value` is a flattenable `arguments` object or array.
32199      *
32200      * @private
32201      * @param {*} value The value to check.
32202      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
32203      */
32204     function isFlattenable(value) {
32205       return isArray(value) || isArguments(value) ||
32206         !!(spreadableSymbol && value && value[spreadableSymbol]);
32207     }
32208
32209     /**
32210      * Checks if `value` is a valid array-like index.
32211      *
32212      * @private
32213      * @param {*} value The value to check.
32214      * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
32215      * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
32216      */
32217     function isIndex(value, length) {
32218       var type = typeof value;
32219       length = length == null ? MAX_SAFE_INTEGER : length;
32220
32221       return !!length &&
32222         (type == 'number' ||
32223           (type != 'symbol' && reIsUint.test(value))) &&
32224             (value > -1 && value % 1 == 0 && value < length);
32225     }
32226
32227     /**
32228      * Checks if the given arguments are from an iteratee call.
32229      *
32230      * @private
32231      * @param {*} value The potential iteratee value argument.
32232      * @param {*} index The potential iteratee index or key argument.
32233      * @param {*} object The potential iteratee object argument.
32234      * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
32235      *  else `false`.
32236      */
32237     function isIterateeCall(value, index, object) {
32238       if (!isObject(object)) {
32239         return false;
32240       }
32241       var type = typeof index;
32242       if (type == 'number'
32243             ? (isArrayLike(object) && isIndex(index, object.length))
32244             : (type == 'string' && index in object)
32245           ) {
32246         return eq(object[index], value);
32247       }
32248       return false;
32249     }
32250
32251     /**
32252      * Checks if `value` is a property name and not a property path.
32253      *
32254      * @private
32255      * @param {*} value The value to check.
32256      * @param {Object} [object] The object to query keys on.
32257      * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
32258      */
32259     function isKey(value, object) {
32260       if (isArray(value)) {
32261         return false;
32262       }
32263       var type = typeof value;
32264       if (type == 'number' || type == 'symbol' || type == 'boolean' ||
32265           value == null || isSymbol(value)) {
32266         return true;
32267       }
32268       return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
32269         (object != null && value in Object(object));
32270     }
32271
32272     /**
32273      * Checks if `value` is suitable for use as unique object key.
32274      *
32275      * @private
32276      * @param {*} value The value to check.
32277      * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
32278      */
32279     function isKeyable(value) {
32280       var type = typeof value;
32281       return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
32282         ? (value !== '__proto__')
32283         : (value === null);
32284     }
32285
32286     /**
32287      * Checks if `func` has a lazy counterpart.
32288      *
32289      * @private
32290      * @param {Function} func The function to check.
32291      * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
32292      *  else `false`.
32293      */
32294     function isLaziable(func) {
32295       var funcName = getFuncName(func),
32296           other = lodash[funcName];
32297
32298       if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
32299         return false;
32300       }
32301       if (func === other) {
32302         return true;
32303       }
32304       var data = getData(other);
32305       return !!data && func === data[0];
32306     }
32307
32308     /**
32309      * Checks if `func` has its source masked.
32310      *
32311      * @private
32312      * @param {Function} func The function to check.
32313      * @returns {boolean} Returns `true` if `func` is masked, else `false`.
32314      */
32315     function isMasked(func) {
32316       return !!maskSrcKey && (maskSrcKey in func);
32317     }
32318
32319     /**
32320      * Checks if `func` is capable of being masked.
32321      *
32322      * @private
32323      * @param {*} value The value to check.
32324      * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
32325      */
32326     var isMaskable = coreJsData ? isFunction : stubFalse;
32327
32328     /**
32329      * Checks if `value` is likely a prototype object.
32330      *
32331      * @private
32332      * @param {*} value The value to check.
32333      * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
32334      */
32335     function isPrototype(value) {
32336       var Ctor = value && value.constructor,
32337           proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
32338
32339       return value === proto;
32340     }
32341
32342     /**
32343      * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
32344      *
32345      * @private
32346      * @param {*} value The value to check.
32347      * @returns {boolean} Returns `true` if `value` if suitable for strict
32348      *  equality comparisons, else `false`.
32349      */
32350     function isStrictComparable(value) {
32351       return value === value && !isObject(value);
32352     }
32353
32354     /**
32355      * A specialized version of `matchesProperty` for source values suitable
32356      * for strict equality comparisons, i.e. `===`.
32357      *
32358      * @private
32359      * @param {string} key The key of the property to get.
32360      * @param {*} srcValue The value to match.
32361      * @returns {Function} Returns the new spec function.
32362      */
32363     function matchesStrictComparable(key, srcValue) {
32364       return function(object) {
32365         if (object == null) {
32366           return false;
32367         }
32368         return object[key] === srcValue &&
32369           (srcValue !== undefined || (key in Object(object)));
32370       };
32371     }
32372
32373     /**
32374      * A specialized version of `_.memoize` which clears the memoized function's
32375      * cache when it exceeds `MAX_MEMOIZE_SIZE`.
32376      *
32377      * @private
32378      * @param {Function} func The function to have its output memoized.
32379      * @returns {Function} Returns the new memoized function.
32380      */
32381     function memoizeCapped(func) {
32382       var result = memoize(func, function(key) {
32383         if (cache.size === MAX_MEMOIZE_SIZE) {
32384           cache.clear();
32385         }
32386         return key;
32387       });
32388
32389       var cache = result.cache;
32390       return result;
32391     }
32392
32393     /**
32394      * Merges the function metadata of `source` into `data`.
32395      *
32396      * Merging metadata reduces the number of wrappers used to invoke a function.
32397      * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
32398      * may be applied regardless of execution order. Methods like `_.ary` and
32399      * `_.rearg` modify function arguments, making the order in which they are
32400      * executed important, preventing the merging of metadata. However, we make
32401      * an exception for a safe combined case where curried functions have `_.ary`
32402      * and or `_.rearg` applied.
32403      *
32404      * @private
32405      * @param {Array} data The destination metadata.
32406      * @param {Array} source The source metadata.
32407      * @returns {Array} Returns `data`.
32408      */
32409     function mergeData(data, source) {
32410       var bitmask = data[1],
32411           srcBitmask = source[1],
32412           newBitmask = bitmask | srcBitmask,
32413           isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
32414
32415       var isCombo =
32416         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
32417         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
32418         ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
32419
32420       // Exit early if metadata can't be merged.
32421       if (!(isCommon || isCombo)) {
32422         return data;
32423       }
32424       // Use source `thisArg` if available.
32425       if (srcBitmask & WRAP_BIND_FLAG) {
32426         data[2] = source[2];
32427         // Set when currying a bound function.
32428         newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
32429       }
32430       // Compose partial arguments.
32431       var value = source[3];
32432       if (value) {
32433         var partials = data[3];
32434         data[3] = partials ? composeArgs(partials, value, source[4]) : value;
32435         data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
32436       }
32437       // Compose partial right arguments.
32438       value = source[5];
32439       if (value) {
32440         partials = data[5];
32441         data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
32442         data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
32443       }
32444       // Use source `argPos` if available.
32445       value = source[7];
32446       if (value) {
32447         data[7] = value;
32448       }
32449       // Use source `ary` if it's smaller.
32450       if (srcBitmask & WRAP_ARY_FLAG) {
32451         data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
32452       }
32453       // Use source `arity` if one is not provided.
32454       if (data[9] == null) {
32455         data[9] = source[9];
32456       }
32457       // Use source `func` and merge bitmasks.
32458       data[0] = source[0];
32459       data[1] = newBitmask;
32460
32461       return data;
32462     }
32463
32464     /**
32465      * This function is like
32466      * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
32467      * except that it includes inherited enumerable properties.
32468      *
32469      * @private
32470      * @param {Object} object The object to query.
32471      * @returns {Array} Returns the array of property names.
32472      */
32473     function nativeKeysIn(object) {
32474       var result = [];
32475       if (object != null) {
32476         for (var key in Object(object)) {
32477           result.push(key);
32478         }
32479       }
32480       return result;
32481     }
32482
32483     /**
32484      * Converts `value` to a string using `Object.prototype.toString`.
32485      *
32486      * @private
32487      * @param {*} value The value to convert.
32488      * @returns {string} Returns the converted string.
32489      */
32490     function objectToString(value) {
32491       return nativeObjectToString.call(value);
32492     }
32493
32494     /**
32495      * A specialized version of `baseRest` which transforms the rest array.
32496      *
32497      * @private
32498      * @param {Function} func The function to apply a rest parameter to.
32499      * @param {number} [start=func.length-1] The start position of the rest parameter.
32500      * @param {Function} transform The rest array transform.
32501      * @returns {Function} Returns the new function.
32502      */
32503     function overRest(func, start, transform) {
32504       start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
32505       return function() {
32506         var args = arguments,
32507             index = -1,
32508             length = nativeMax(args.length - start, 0),
32509             array = Array(length);
32510
32511         while (++index < length) {
32512           array[index] = args[start + index];
32513         }
32514         index = -1;
32515         var otherArgs = Array(start + 1);
32516         while (++index < start) {
32517           otherArgs[index] = args[index];
32518         }
32519         otherArgs[start] = transform(array);
32520         return apply(func, this, otherArgs);
32521       };
32522     }
32523
32524     /**
32525      * Gets the parent value at `path` of `object`.
32526      *
32527      * @private
32528      * @param {Object} object The object to query.
32529      * @param {Array} path The path to get the parent value of.
32530      * @returns {*} Returns the parent value.
32531      */
32532     function parent(object, path) {
32533       return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
32534     }
32535
32536     /**
32537      * Reorder `array` according to the specified indexes where the element at
32538      * the first index is assigned as the first element, the element at
32539      * the second index is assigned as the second element, and so on.
32540      *
32541      * @private
32542      * @param {Array} array The array to reorder.
32543      * @param {Array} indexes The arranged array indexes.
32544      * @returns {Array} Returns `array`.
32545      */
32546     function reorder(array, indexes) {
32547       var arrLength = array.length,
32548           length = nativeMin(indexes.length, arrLength),
32549           oldArray = copyArray(array);
32550
32551       while (length--) {
32552         var index = indexes[length];
32553         array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
32554       }
32555       return array;
32556     }
32557
32558     /**
32559      * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
32560      *
32561      * @private
32562      * @param {Object} object The object to query.
32563      * @param {string} key The key of the property to get.
32564      * @returns {*} Returns the property value.
32565      */
32566     function safeGet(object, key) {
32567       if (key === 'constructor' && typeof object[key] === 'function') {
32568         return;
32569       }
32570
32571       if (key == '__proto__') {
32572         return;
32573       }
32574
32575       return object[key];
32576     }
32577
32578     /**
32579      * Sets metadata for `func`.
32580      *
32581      * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
32582      * period of time, it will trip its breaker and transition to an identity
32583      * function to avoid garbage collection pauses in V8. See
32584      * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
32585      * for more details.
32586      *
32587      * @private
32588      * @param {Function} func The function to associate metadata with.
32589      * @param {*} data The metadata.
32590      * @returns {Function} Returns `func`.
32591      */
32592     var setData = shortOut(baseSetData);
32593
32594     /**
32595      * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
32596      *
32597      * @private
32598      * @param {Function} func The function to delay.
32599      * @param {number} wait The number of milliseconds to delay invocation.
32600      * @returns {number|Object} Returns the timer id or timeout object.
32601      */
32602     var setTimeout = ctxSetTimeout || function(func, wait) {
32603       return root.setTimeout(func, wait);
32604     };
32605
32606     /**
32607      * Sets the `toString` method of `func` to return `string`.
32608      *
32609      * @private
32610      * @param {Function} func The function to modify.
32611      * @param {Function} string The `toString` result.
32612      * @returns {Function} Returns `func`.
32613      */
32614     var setToString = shortOut(baseSetToString);
32615
32616     /**
32617      * Sets the `toString` method of `wrapper` to mimic the source of `reference`
32618      * with wrapper details in a comment at the top of the source body.
32619      *
32620      * @private
32621      * @param {Function} wrapper The function to modify.
32622      * @param {Function} reference The reference function.
32623      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
32624      * @returns {Function} Returns `wrapper`.
32625      */
32626     function setWrapToString(wrapper, reference, bitmask) {
32627       var source = (reference + '');
32628       return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
32629     }
32630
32631     /**
32632      * Creates a function that'll short out and invoke `identity` instead
32633      * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
32634      * milliseconds.
32635      *
32636      * @private
32637      * @param {Function} func The function to restrict.
32638      * @returns {Function} Returns the new shortable function.
32639      */
32640     function shortOut(func) {
32641       var count = 0,
32642           lastCalled = 0;
32643
32644       return function() {
32645         var stamp = nativeNow(),
32646             remaining = HOT_SPAN - (stamp - lastCalled);
32647
32648         lastCalled = stamp;
32649         if (remaining > 0) {
32650           if (++count >= HOT_COUNT) {
32651             return arguments[0];
32652           }
32653         } else {
32654           count = 0;
32655         }
32656         return func.apply(undefined, arguments);
32657       };
32658     }
32659
32660     /**
32661      * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
32662      *
32663      * @private
32664      * @param {Array} array The array to shuffle.
32665      * @param {number} [size=array.length] The size of `array`.
32666      * @returns {Array} Returns `array`.
32667      */
32668     function shuffleSelf(array, size) {
32669       var index = -1,
32670           length = array.length,
32671           lastIndex = length - 1;
32672
32673       size = size === undefined ? length : size;
32674       while (++index < size) {
32675         var rand = baseRandom(index, lastIndex),
32676             value = array[rand];
32677
32678         array[rand] = array[index];
32679         array[index] = value;
32680       }
32681       array.length = size;
32682       return array;
32683     }
32684
32685     /**
32686      * Converts `string` to a property path array.
32687      *
32688      * @private
32689      * @param {string} string The string to convert.
32690      * @returns {Array} Returns the property path array.
32691      */
32692     var stringToPath = memoizeCapped(function(string) {
32693       var result = [];
32694       if (string.charCodeAt(0) === 46 /* . */) {
32695         result.push('');
32696       }
32697       string.replace(rePropName, function(match, number, quote, subString) {
32698         result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
32699       });
32700       return result;
32701     });
32702
32703     /**
32704      * Converts `value` to a string key if it's not a string or symbol.
32705      *
32706      * @private
32707      * @param {*} value The value to inspect.
32708      * @returns {string|symbol} Returns the key.
32709      */
32710     function toKey(value) {
32711       if (typeof value == 'string' || isSymbol(value)) {
32712         return value;
32713       }
32714       var result = (value + '');
32715       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
32716     }
32717
32718     /**
32719      * Converts `func` to its source code.
32720      *
32721      * @private
32722      * @param {Function} func The function to convert.
32723      * @returns {string} Returns the source code.
32724      */
32725     function toSource(func) {
32726       if (func != null) {
32727         try {
32728           return funcToString.call(func);
32729         } catch (e) {}
32730         try {
32731           return (func + '');
32732         } catch (e) {}
32733       }
32734       return '';
32735     }
32736
32737     /**
32738      * Updates wrapper `details` based on `bitmask` flags.
32739      *
32740      * @private
32741      * @returns {Array} details The details to modify.
32742      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
32743      * @returns {Array} Returns `details`.
32744      */
32745     function updateWrapDetails(details, bitmask) {
32746       arrayEach(wrapFlags, function(pair) {
32747         var value = '_.' + pair[0];
32748         if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
32749           details.push(value);
32750         }
32751       });
32752       return details.sort();
32753     }
32754
32755     /**
32756      * Creates a clone of `wrapper`.
32757      *
32758      * @private
32759      * @param {Object} wrapper The wrapper to clone.
32760      * @returns {Object} Returns the cloned wrapper.
32761      */
32762     function wrapperClone(wrapper) {
32763       if (wrapper instanceof LazyWrapper) {
32764         return wrapper.clone();
32765       }
32766       var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
32767       result.__actions__ = copyArray(wrapper.__actions__);
32768       result.__index__  = wrapper.__index__;
32769       result.__values__ = wrapper.__values__;
32770       return result;
32771     }
32772
32773     /*------------------------------------------------------------------------*/
32774
32775     /**
32776      * Creates an array of elements split into groups the length of `size`.
32777      * If `array` can't be split evenly, the final chunk will be the remaining
32778      * elements.
32779      *
32780      * @static
32781      * @memberOf _
32782      * @since 3.0.0
32783      * @category Array
32784      * @param {Array} array The array to process.
32785      * @param {number} [size=1] The length of each chunk
32786      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
32787      * @returns {Array} Returns the new array of chunks.
32788      * @example
32789      *
32790      * _.chunk(['a', 'b', 'c', 'd'], 2);
32791      * // => [['a', 'b'], ['c', 'd']]
32792      *
32793      * _.chunk(['a', 'b', 'c', 'd'], 3);
32794      * // => [['a', 'b', 'c'], ['d']]
32795      */
32796     function chunk(array, size, guard) {
32797       if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
32798         size = 1;
32799       } else {
32800         size = nativeMax(toInteger(size), 0);
32801       }
32802       var length = array == null ? 0 : array.length;
32803       if (!length || size < 1) {
32804         return [];
32805       }
32806       var index = 0,
32807           resIndex = 0,
32808           result = Array(nativeCeil(length / size));
32809
32810       while (index < length) {
32811         result[resIndex++] = baseSlice(array, index, (index += size));
32812       }
32813       return result;
32814     }
32815
32816     /**
32817      * Creates an array with all falsey values removed. The values `false`, `null`,
32818      * `0`, `""`, `undefined`, and `NaN` are falsey.
32819      *
32820      * @static
32821      * @memberOf _
32822      * @since 0.1.0
32823      * @category Array
32824      * @param {Array} array The array to compact.
32825      * @returns {Array} Returns the new array of filtered values.
32826      * @example
32827      *
32828      * _.compact([0, 1, false, 2, '', 3]);
32829      * // => [1, 2, 3]
32830      */
32831     function compact(array) {
32832       var index = -1,
32833           length = array == null ? 0 : array.length,
32834           resIndex = 0,
32835           result = [];
32836
32837       while (++index < length) {
32838         var value = array[index];
32839         if (value) {
32840           result[resIndex++] = value;
32841         }
32842       }
32843       return result;
32844     }
32845
32846     /**
32847      * Creates a new array concatenating `array` with any additional arrays
32848      * and/or values.
32849      *
32850      * @static
32851      * @memberOf _
32852      * @since 4.0.0
32853      * @category Array
32854      * @param {Array} array The array to concatenate.
32855      * @param {...*} [values] The values to concatenate.
32856      * @returns {Array} Returns the new concatenated array.
32857      * @example
32858      *
32859      * var array = [1];
32860      * var other = _.concat(array, 2, [3], [[4]]);
32861      *
32862      * console.log(other);
32863      * // => [1, 2, 3, [4]]
32864      *
32865      * console.log(array);
32866      * // => [1]
32867      */
32868     function concat() {
32869       var length = arguments.length;
32870       if (!length) {
32871         return [];
32872       }
32873       var args = Array(length - 1),
32874           array = arguments[0],
32875           index = length;
32876
32877       while (index--) {
32878         args[index - 1] = arguments[index];
32879       }
32880       return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
32881     }
32882
32883     /**
32884      * Creates an array of `array` values not included in the other given arrays
32885      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
32886      * for equality comparisons. The order and references of result values are
32887      * determined by the first array.
32888      *
32889      * **Note:** Unlike `_.pullAll`, this method returns a new array.
32890      *
32891      * @static
32892      * @memberOf _
32893      * @since 0.1.0
32894      * @category Array
32895      * @param {Array} array The array to inspect.
32896      * @param {...Array} [values] The values to exclude.
32897      * @returns {Array} Returns the new array of filtered values.
32898      * @see _.without, _.xor
32899      * @example
32900      *
32901      * _.difference([2, 1], [2, 3]);
32902      * // => [1]
32903      */
32904     var difference = baseRest(function(array, values) {
32905       return isArrayLikeObject(array)
32906         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
32907         : [];
32908     });
32909
32910     /**
32911      * This method is like `_.difference` except that it accepts `iteratee` which
32912      * is invoked for each element of `array` and `values` to generate the criterion
32913      * by which they're compared. The order and references of result values are
32914      * determined by the first array. The iteratee is invoked with one argument:
32915      * (value).
32916      *
32917      * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
32918      *
32919      * @static
32920      * @memberOf _
32921      * @since 4.0.0
32922      * @category Array
32923      * @param {Array} array The array to inspect.
32924      * @param {...Array} [values] The values to exclude.
32925      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
32926      * @returns {Array} Returns the new array of filtered values.
32927      * @example
32928      *
32929      * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
32930      * // => [1.2]
32931      *
32932      * // The `_.property` iteratee shorthand.
32933      * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
32934      * // => [{ 'x': 2 }]
32935      */
32936     var differenceBy = baseRest(function(array, values) {
32937       var iteratee = last(values);
32938       if (isArrayLikeObject(iteratee)) {
32939         iteratee = undefined;
32940       }
32941       return isArrayLikeObject(array)
32942         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
32943         : [];
32944     });
32945
32946     /**
32947      * This method is like `_.difference` except that it accepts `comparator`
32948      * which is invoked to compare elements of `array` to `values`. The order and
32949      * references of result values are determined by the first array. The comparator
32950      * is invoked with two arguments: (arrVal, othVal).
32951      *
32952      * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
32953      *
32954      * @static
32955      * @memberOf _
32956      * @since 4.0.0
32957      * @category Array
32958      * @param {Array} array The array to inspect.
32959      * @param {...Array} [values] The values to exclude.
32960      * @param {Function} [comparator] The comparator invoked per element.
32961      * @returns {Array} Returns the new array of filtered values.
32962      * @example
32963      *
32964      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
32965      *
32966      * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
32967      * // => [{ 'x': 2, 'y': 1 }]
32968      */
32969     var differenceWith = baseRest(function(array, values) {
32970       var comparator = last(values);
32971       if (isArrayLikeObject(comparator)) {
32972         comparator = undefined;
32973       }
32974       return isArrayLikeObject(array)
32975         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
32976         : [];
32977     });
32978
32979     /**
32980      * Creates a slice of `array` with `n` elements dropped from the beginning.
32981      *
32982      * @static
32983      * @memberOf _
32984      * @since 0.5.0
32985      * @category Array
32986      * @param {Array} array The array to query.
32987      * @param {number} [n=1] The number of elements to drop.
32988      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
32989      * @returns {Array} Returns the slice of `array`.
32990      * @example
32991      *
32992      * _.drop([1, 2, 3]);
32993      * // => [2, 3]
32994      *
32995      * _.drop([1, 2, 3], 2);
32996      * // => [3]
32997      *
32998      * _.drop([1, 2, 3], 5);
32999      * // => []
33000      *
33001      * _.drop([1, 2, 3], 0);
33002      * // => [1, 2, 3]
33003      */
33004     function drop(array, n, guard) {
33005       var length = array == null ? 0 : array.length;
33006       if (!length) {
33007         return [];
33008       }
33009       n = (guard || n === undefined) ? 1 : toInteger(n);
33010       return baseSlice(array, n < 0 ? 0 : n, length);
33011     }
33012
33013     /**
33014      * Creates a slice of `array` with `n` elements dropped from the end.
33015      *
33016      * @static
33017      * @memberOf _
33018      * @since 3.0.0
33019      * @category Array
33020      * @param {Array} array The array to query.
33021      * @param {number} [n=1] The number of elements to drop.
33022      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
33023      * @returns {Array} Returns the slice of `array`.
33024      * @example
33025      *
33026      * _.dropRight([1, 2, 3]);
33027      * // => [1, 2]
33028      *
33029      * _.dropRight([1, 2, 3], 2);
33030      * // => [1]
33031      *
33032      * _.dropRight([1, 2, 3], 5);
33033      * // => []
33034      *
33035      * _.dropRight([1, 2, 3], 0);
33036      * // => [1, 2, 3]
33037      */
33038     function dropRight(array, n, guard) {
33039       var length = array == null ? 0 : array.length;
33040       if (!length) {
33041         return [];
33042       }
33043       n = (guard || n === undefined) ? 1 : toInteger(n);
33044       n = length - n;
33045       return baseSlice(array, 0, n < 0 ? 0 : n);
33046     }
33047
33048     /**
33049      * Creates a slice of `array` excluding elements dropped from the end.
33050      * Elements are dropped until `predicate` returns falsey. The predicate is
33051      * invoked with three arguments: (value, index, array).
33052      *
33053      * @static
33054      * @memberOf _
33055      * @since 3.0.0
33056      * @category Array
33057      * @param {Array} array The array to query.
33058      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33059      * @returns {Array} Returns the slice of `array`.
33060      * @example
33061      *
33062      * var users = [
33063      *   { 'user': 'barney',  'active': true },
33064      *   { 'user': 'fred',    'active': false },
33065      *   { 'user': 'pebbles', 'active': false }
33066      * ];
33067      *
33068      * _.dropRightWhile(users, function(o) { return !o.active; });
33069      * // => objects for ['barney']
33070      *
33071      * // The `_.matches` iteratee shorthand.
33072      * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
33073      * // => objects for ['barney', 'fred']
33074      *
33075      * // The `_.matchesProperty` iteratee shorthand.
33076      * _.dropRightWhile(users, ['active', false]);
33077      * // => objects for ['barney']
33078      *
33079      * // The `_.property` iteratee shorthand.
33080      * _.dropRightWhile(users, 'active');
33081      * // => objects for ['barney', 'fred', 'pebbles']
33082      */
33083     function dropRightWhile(array, predicate) {
33084       return (array && array.length)
33085         ? baseWhile(array, getIteratee(predicate, 3), true, true)
33086         : [];
33087     }
33088
33089     /**
33090      * Creates a slice of `array` excluding elements dropped from the beginning.
33091      * Elements are dropped until `predicate` returns falsey. The predicate is
33092      * invoked with three arguments: (value, index, array).
33093      *
33094      * @static
33095      * @memberOf _
33096      * @since 3.0.0
33097      * @category Array
33098      * @param {Array} array The array to query.
33099      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33100      * @returns {Array} Returns the slice of `array`.
33101      * @example
33102      *
33103      * var users = [
33104      *   { 'user': 'barney',  'active': false },
33105      *   { 'user': 'fred',    'active': false },
33106      *   { 'user': 'pebbles', 'active': true }
33107      * ];
33108      *
33109      * _.dropWhile(users, function(o) { return !o.active; });
33110      * // => objects for ['pebbles']
33111      *
33112      * // The `_.matches` iteratee shorthand.
33113      * _.dropWhile(users, { 'user': 'barney', 'active': false });
33114      * // => objects for ['fred', 'pebbles']
33115      *
33116      * // The `_.matchesProperty` iteratee shorthand.
33117      * _.dropWhile(users, ['active', false]);
33118      * // => objects for ['pebbles']
33119      *
33120      * // The `_.property` iteratee shorthand.
33121      * _.dropWhile(users, 'active');
33122      * // => objects for ['barney', 'fred', 'pebbles']
33123      */
33124     function dropWhile(array, predicate) {
33125       return (array && array.length)
33126         ? baseWhile(array, getIteratee(predicate, 3), true)
33127         : [];
33128     }
33129
33130     /**
33131      * Fills elements of `array` with `value` from `start` up to, but not
33132      * including, `end`.
33133      *
33134      * **Note:** This method mutates `array`.
33135      *
33136      * @static
33137      * @memberOf _
33138      * @since 3.2.0
33139      * @category Array
33140      * @param {Array} array The array to fill.
33141      * @param {*} value The value to fill `array` with.
33142      * @param {number} [start=0] The start position.
33143      * @param {number} [end=array.length] The end position.
33144      * @returns {Array} Returns `array`.
33145      * @example
33146      *
33147      * var array = [1, 2, 3];
33148      *
33149      * _.fill(array, 'a');
33150      * console.log(array);
33151      * // => ['a', 'a', 'a']
33152      *
33153      * _.fill(Array(3), 2);
33154      * // => [2, 2, 2]
33155      *
33156      * _.fill([4, 6, 8, 10], '*', 1, 3);
33157      * // => [4, '*', '*', 10]
33158      */
33159     function fill(array, value, start, end) {
33160       var length = array == null ? 0 : array.length;
33161       if (!length) {
33162         return [];
33163       }
33164       if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
33165         start = 0;
33166         end = length;
33167       }
33168       return baseFill(array, value, start, end);
33169     }
33170
33171     /**
33172      * This method is like `_.find` except that it returns the index of the first
33173      * element `predicate` returns truthy for instead of the element itself.
33174      *
33175      * @static
33176      * @memberOf _
33177      * @since 1.1.0
33178      * @category Array
33179      * @param {Array} array The array to inspect.
33180      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33181      * @param {number} [fromIndex=0] The index to search from.
33182      * @returns {number} Returns the index of the found element, else `-1`.
33183      * @example
33184      *
33185      * var users = [
33186      *   { 'user': 'barney',  'active': false },
33187      *   { 'user': 'fred',    'active': false },
33188      *   { 'user': 'pebbles', 'active': true }
33189      * ];
33190      *
33191      * _.findIndex(users, function(o) { return o.user == 'barney'; });
33192      * // => 0
33193      *
33194      * // The `_.matches` iteratee shorthand.
33195      * _.findIndex(users, { 'user': 'fred', 'active': false });
33196      * // => 1
33197      *
33198      * // The `_.matchesProperty` iteratee shorthand.
33199      * _.findIndex(users, ['active', false]);
33200      * // => 0
33201      *
33202      * // The `_.property` iteratee shorthand.
33203      * _.findIndex(users, 'active');
33204      * // => 2
33205      */
33206     function findIndex(array, predicate, fromIndex) {
33207       var length = array == null ? 0 : array.length;
33208       if (!length) {
33209         return -1;
33210       }
33211       var index = fromIndex == null ? 0 : toInteger(fromIndex);
33212       if (index < 0) {
33213         index = nativeMax(length + index, 0);
33214       }
33215       return baseFindIndex(array, getIteratee(predicate, 3), index);
33216     }
33217
33218     /**
33219      * This method is like `_.findIndex` except that it iterates over elements
33220      * of `collection` from right to left.
33221      *
33222      * @static
33223      * @memberOf _
33224      * @since 2.0.0
33225      * @category Array
33226      * @param {Array} array The array to inspect.
33227      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33228      * @param {number} [fromIndex=array.length-1] The index to search from.
33229      * @returns {number} Returns the index of the found element, else `-1`.
33230      * @example
33231      *
33232      * var users = [
33233      *   { 'user': 'barney',  'active': true },
33234      *   { 'user': 'fred',    'active': false },
33235      *   { 'user': 'pebbles', 'active': false }
33236      * ];
33237      *
33238      * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
33239      * // => 2
33240      *
33241      * // The `_.matches` iteratee shorthand.
33242      * _.findLastIndex(users, { 'user': 'barney', 'active': true });
33243      * // => 0
33244      *
33245      * // The `_.matchesProperty` iteratee shorthand.
33246      * _.findLastIndex(users, ['active', false]);
33247      * // => 2
33248      *
33249      * // The `_.property` iteratee shorthand.
33250      * _.findLastIndex(users, 'active');
33251      * // => 0
33252      */
33253     function findLastIndex(array, predicate, fromIndex) {
33254       var length = array == null ? 0 : array.length;
33255       if (!length) {
33256         return -1;
33257       }
33258       var index = length - 1;
33259       if (fromIndex !== undefined) {
33260         index = toInteger(fromIndex);
33261         index = fromIndex < 0
33262           ? nativeMax(length + index, 0)
33263           : nativeMin(index, length - 1);
33264       }
33265       return baseFindIndex(array, getIteratee(predicate, 3), index, true);
33266     }
33267
33268     /**
33269      * Flattens `array` a single level deep.
33270      *
33271      * @static
33272      * @memberOf _
33273      * @since 0.1.0
33274      * @category Array
33275      * @param {Array} array The array to flatten.
33276      * @returns {Array} Returns the new flattened array.
33277      * @example
33278      *
33279      * _.flatten([1, [2, [3, [4]], 5]]);
33280      * // => [1, 2, [3, [4]], 5]
33281      */
33282     function flatten(array) {
33283       var length = array == null ? 0 : array.length;
33284       return length ? baseFlatten(array, 1) : [];
33285     }
33286
33287     /**
33288      * Recursively flattens `array`.
33289      *
33290      * @static
33291      * @memberOf _
33292      * @since 3.0.0
33293      * @category Array
33294      * @param {Array} array The array to flatten.
33295      * @returns {Array} Returns the new flattened array.
33296      * @example
33297      *
33298      * _.flattenDeep([1, [2, [3, [4]], 5]]);
33299      * // => [1, 2, 3, 4, 5]
33300      */
33301     function flattenDeep(array) {
33302       var length = array == null ? 0 : array.length;
33303       return length ? baseFlatten(array, INFINITY) : [];
33304     }
33305
33306     /**
33307      * Recursively flatten `array` up to `depth` times.
33308      *
33309      * @static
33310      * @memberOf _
33311      * @since 4.4.0
33312      * @category Array
33313      * @param {Array} array The array to flatten.
33314      * @param {number} [depth=1] The maximum recursion depth.
33315      * @returns {Array} Returns the new flattened array.
33316      * @example
33317      *
33318      * var array = [1, [2, [3, [4]], 5]];
33319      *
33320      * _.flattenDepth(array, 1);
33321      * // => [1, 2, [3, [4]], 5]
33322      *
33323      * _.flattenDepth(array, 2);
33324      * // => [1, 2, 3, [4], 5]
33325      */
33326     function flattenDepth(array, depth) {
33327       var length = array == null ? 0 : array.length;
33328       if (!length) {
33329         return [];
33330       }
33331       depth = depth === undefined ? 1 : toInteger(depth);
33332       return baseFlatten(array, depth);
33333     }
33334
33335     /**
33336      * The inverse of `_.toPairs`; this method returns an object composed
33337      * from key-value `pairs`.
33338      *
33339      * @static
33340      * @memberOf _
33341      * @since 4.0.0
33342      * @category Array
33343      * @param {Array} pairs The key-value pairs.
33344      * @returns {Object} Returns the new object.
33345      * @example
33346      *
33347      * _.fromPairs([['a', 1], ['b', 2]]);
33348      * // => { 'a': 1, 'b': 2 }
33349      */
33350     function fromPairs(pairs) {
33351       var index = -1,
33352           length = pairs == null ? 0 : pairs.length,
33353           result = {};
33354
33355       while (++index < length) {
33356         var pair = pairs[index];
33357         result[pair[0]] = pair[1];
33358       }
33359       return result;
33360     }
33361
33362     /**
33363      * Gets the first element of `array`.
33364      *
33365      * @static
33366      * @memberOf _
33367      * @since 0.1.0
33368      * @alias first
33369      * @category Array
33370      * @param {Array} array The array to query.
33371      * @returns {*} Returns the first element of `array`.
33372      * @example
33373      *
33374      * _.head([1, 2, 3]);
33375      * // => 1
33376      *
33377      * _.head([]);
33378      * // => undefined
33379      */
33380     function head(array) {
33381       return (array && array.length) ? array[0] : undefined;
33382     }
33383
33384     /**
33385      * Gets the index at which the first occurrence of `value` is found in `array`
33386      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33387      * for equality comparisons. If `fromIndex` is negative, it's used as the
33388      * offset from the end of `array`.
33389      *
33390      * @static
33391      * @memberOf _
33392      * @since 0.1.0
33393      * @category Array
33394      * @param {Array} array The array to inspect.
33395      * @param {*} value The value to search for.
33396      * @param {number} [fromIndex=0] The index to search from.
33397      * @returns {number} Returns the index of the matched value, else `-1`.
33398      * @example
33399      *
33400      * _.indexOf([1, 2, 1, 2], 2);
33401      * // => 1
33402      *
33403      * // Search from the `fromIndex`.
33404      * _.indexOf([1, 2, 1, 2], 2, 2);
33405      * // => 3
33406      */
33407     function indexOf(array, value, fromIndex) {
33408       var length = array == null ? 0 : array.length;
33409       if (!length) {
33410         return -1;
33411       }
33412       var index = fromIndex == null ? 0 : toInteger(fromIndex);
33413       if (index < 0) {
33414         index = nativeMax(length + index, 0);
33415       }
33416       return baseIndexOf(array, value, index);
33417     }
33418
33419     /**
33420      * Gets all but the last element of `array`.
33421      *
33422      * @static
33423      * @memberOf _
33424      * @since 0.1.0
33425      * @category Array
33426      * @param {Array} array The array to query.
33427      * @returns {Array} Returns the slice of `array`.
33428      * @example
33429      *
33430      * _.initial([1, 2, 3]);
33431      * // => [1, 2]
33432      */
33433     function initial(array) {
33434       var length = array == null ? 0 : array.length;
33435       return length ? baseSlice(array, 0, -1) : [];
33436     }
33437
33438     /**
33439      * Creates an array of unique values that are included in all given arrays
33440      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33441      * for equality comparisons. The order and references of result values are
33442      * determined by the first array.
33443      *
33444      * @static
33445      * @memberOf _
33446      * @since 0.1.0
33447      * @category Array
33448      * @param {...Array} [arrays] The arrays to inspect.
33449      * @returns {Array} Returns the new array of intersecting values.
33450      * @example
33451      *
33452      * _.intersection([2, 1], [2, 3]);
33453      * // => [2]
33454      */
33455     var intersection = baseRest(function(arrays) {
33456       var mapped = arrayMap(arrays, castArrayLikeObject);
33457       return (mapped.length && mapped[0] === arrays[0])
33458         ? baseIntersection(mapped)
33459         : [];
33460     });
33461
33462     /**
33463      * This method is like `_.intersection` except that it accepts `iteratee`
33464      * which is invoked for each element of each `arrays` to generate the criterion
33465      * by which they're compared. The order and references of result values are
33466      * determined by the first array. The iteratee is invoked with one argument:
33467      * (value).
33468      *
33469      * @static
33470      * @memberOf _
33471      * @since 4.0.0
33472      * @category Array
33473      * @param {...Array} [arrays] The arrays to inspect.
33474      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
33475      * @returns {Array} Returns the new array of intersecting values.
33476      * @example
33477      *
33478      * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
33479      * // => [2.1]
33480      *
33481      * // The `_.property` iteratee shorthand.
33482      * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
33483      * // => [{ 'x': 1 }]
33484      */
33485     var intersectionBy = baseRest(function(arrays) {
33486       var iteratee = last(arrays),
33487           mapped = arrayMap(arrays, castArrayLikeObject);
33488
33489       if (iteratee === last(mapped)) {
33490         iteratee = undefined;
33491       } else {
33492         mapped.pop();
33493       }
33494       return (mapped.length && mapped[0] === arrays[0])
33495         ? baseIntersection(mapped, getIteratee(iteratee, 2))
33496         : [];
33497     });
33498
33499     /**
33500      * This method is like `_.intersection` except that it accepts `comparator`
33501      * which is invoked to compare elements of `arrays`. The order and references
33502      * of result values are determined by the first array. The comparator is
33503      * invoked with two arguments: (arrVal, othVal).
33504      *
33505      * @static
33506      * @memberOf _
33507      * @since 4.0.0
33508      * @category Array
33509      * @param {...Array} [arrays] The arrays to inspect.
33510      * @param {Function} [comparator] The comparator invoked per element.
33511      * @returns {Array} Returns the new array of intersecting values.
33512      * @example
33513      *
33514      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
33515      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
33516      *
33517      * _.intersectionWith(objects, others, _.isEqual);
33518      * // => [{ 'x': 1, 'y': 2 }]
33519      */
33520     var intersectionWith = baseRest(function(arrays) {
33521       var comparator = last(arrays),
33522           mapped = arrayMap(arrays, castArrayLikeObject);
33523
33524       comparator = typeof comparator == 'function' ? comparator : undefined;
33525       if (comparator) {
33526         mapped.pop();
33527       }
33528       return (mapped.length && mapped[0] === arrays[0])
33529         ? baseIntersection(mapped, undefined, comparator)
33530         : [];
33531     });
33532
33533     /**
33534      * Converts all elements in `array` into a string separated by `separator`.
33535      *
33536      * @static
33537      * @memberOf _
33538      * @since 4.0.0
33539      * @category Array
33540      * @param {Array} array The array to convert.
33541      * @param {string} [separator=','] The element separator.
33542      * @returns {string} Returns the joined string.
33543      * @example
33544      *
33545      * _.join(['a', 'b', 'c'], '~');
33546      * // => 'a~b~c'
33547      */
33548     function join(array, separator) {
33549       return array == null ? '' : nativeJoin.call(array, separator);
33550     }
33551
33552     /**
33553      * Gets the last element of `array`.
33554      *
33555      * @static
33556      * @memberOf _
33557      * @since 0.1.0
33558      * @category Array
33559      * @param {Array} array The array to query.
33560      * @returns {*} Returns the last element of `array`.
33561      * @example
33562      *
33563      * _.last([1, 2, 3]);
33564      * // => 3
33565      */
33566     function last(array) {
33567       var length = array == null ? 0 : array.length;
33568       return length ? array[length - 1] : undefined;
33569     }
33570
33571     /**
33572      * This method is like `_.indexOf` except that it iterates over elements of
33573      * `array` from right to left.
33574      *
33575      * @static
33576      * @memberOf _
33577      * @since 0.1.0
33578      * @category Array
33579      * @param {Array} array The array to inspect.
33580      * @param {*} value The value to search for.
33581      * @param {number} [fromIndex=array.length-1] The index to search from.
33582      * @returns {number} Returns the index of the matched value, else `-1`.
33583      * @example
33584      *
33585      * _.lastIndexOf([1, 2, 1, 2], 2);
33586      * // => 3
33587      *
33588      * // Search from the `fromIndex`.
33589      * _.lastIndexOf([1, 2, 1, 2], 2, 2);
33590      * // => 1
33591      */
33592     function lastIndexOf(array, value, fromIndex) {
33593       var length = array == null ? 0 : array.length;
33594       if (!length) {
33595         return -1;
33596       }
33597       var index = length;
33598       if (fromIndex !== undefined) {
33599         index = toInteger(fromIndex);
33600         index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
33601       }
33602       return value === value
33603         ? strictLastIndexOf(array, value, index)
33604         : baseFindIndex(array, baseIsNaN, index, true);
33605     }
33606
33607     /**
33608      * Gets the element at index `n` of `array`. If `n` is negative, the nth
33609      * element from the end is returned.
33610      *
33611      * @static
33612      * @memberOf _
33613      * @since 4.11.0
33614      * @category Array
33615      * @param {Array} array The array to query.
33616      * @param {number} [n=0] The index of the element to return.
33617      * @returns {*} Returns the nth element of `array`.
33618      * @example
33619      *
33620      * var array = ['a', 'b', 'c', 'd'];
33621      *
33622      * _.nth(array, 1);
33623      * // => 'b'
33624      *
33625      * _.nth(array, -2);
33626      * // => 'c';
33627      */
33628     function nth(array, n) {
33629       return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
33630     }
33631
33632     /**
33633      * Removes all given values from `array` using
33634      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33635      * for equality comparisons.
33636      *
33637      * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
33638      * to remove elements from an array by predicate.
33639      *
33640      * @static
33641      * @memberOf _
33642      * @since 2.0.0
33643      * @category Array
33644      * @param {Array} array The array to modify.
33645      * @param {...*} [values] The values to remove.
33646      * @returns {Array} Returns `array`.
33647      * @example
33648      *
33649      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
33650      *
33651      * _.pull(array, 'a', 'c');
33652      * console.log(array);
33653      * // => ['b', 'b']
33654      */
33655     var pull = baseRest(pullAll);
33656
33657     /**
33658      * This method is like `_.pull` except that it accepts an array of values to remove.
33659      *
33660      * **Note:** Unlike `_.difference`, this method mutates `array`.
33661      *
33662      * @static
33663      * @memberOf _
33664      * @since 4.0.0
33665      * @category Array
33666      * @param {Array} array The array to modify.
33667      * @param {Array} values The values to remove.
33668      * @returns {Array} Returns `array`.
33669      * @example
33670      *
33671      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
33672      *
33673      * _.pullAll(array, ['a', 'c']);
33674      * console.log(array);
33675      * // => ['b', 'b']
33676      */
33677     function pullAll(array, values) {
33678       return (array && array.length && values && values.length)
33679         ? basePullAll(array, values)
33680         : array;
33681     }
33682
33683     /**
33684      * This method is like `_.pullAll` except that it accepts `iteratee` which is
33685      * invoked for each element of `array` and `values` to generate the criterion
33686      * by which they're compared. The iteratee is invoked with one argument: (value).
33687      *
33688      * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
33689      *
33690      * @static
33691      * @memberOf _
33692      * @since 4.0.0
33693      * @category Array
33694      * @param {Array} array The array to modify.
33695      * @param {Array} values The values to remove.
33696      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
33697      * @returns {Array} Returns `array`.
33698      * @example
33699      *
33700      * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
33701      *
33702      * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
33703      * console.log(array);
33704      * // => [{ 'x': 2 }]
33705      */
33706     function pullAllBy(array, values, iteratee) {
33707       return (array && array.length && values && values.length)
33708         ? basePullAll(array, values, getIteratee(iteratee, 2))
33709         : array;
33710     }
33711
33712     /**
33713      * This method is like `_.pullAll` except that it accepts `comparator` which
33714      * is invoked to compare elements of `array` to `values`. The comparator is
33715      * invoked with two arguments: (arrVal, othVal).
33716      *
33717      * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
33718      *
33719      * @static
33720      * @memberOf _
33721      * @since 4.6.0
33722      * @category Array
33723      * @param {Array} array The array to modify.
33724      * @param {Array} values The values to remove.
33725      * @param {Function} [comparator] The comparator invoked per element.
33726      * @returns {Array} Returns `array`.
33727      * @example
33728      *
33729      * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
33730      *
33731      * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
33732      * console.log(array);
33733      * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
33734      */
33735     function pullAllWith(array, values, comparator) {
33736       return (array && array.length && values && values.length)
33737         ? basePullAll(array, values, undefined, comparator)
33738         : array;
33739     }
33740
33741     /**
33742      * Removes elements from `array` corresponding to `indexes` and returns an
33743      * array of removed elements.
33744      *
33745      * **Note:** Unlike `_.at`, this method mutates `array`.
33746      *
33747      * @static
33748      * @memberOf _
33749      * @since 3.0.0
33750      * @category Array
33751      * @param {Array} array The array to modify.
33752      * @param {...(number|number[])} [indexes] The indexes of elements to remove.
33753      * @returns {Array} Returns the new array of removed elements.
33754      * @example
33755      *
33756      * var array = ['a', 'b', 'c', 'd'];
33757      * var pulled = _.pullAt(array, [1, 3]);
33758      *
33759      * console.log(array);
33760      * // => ['a', 'c']
33761      *
33762      * console.log(pulled);
33763      * // => ['b', 'd']
33764      */
33765     var pullAt = flatRest(function(array, indexes) {
33766       var length = array == null ? 0 : array.length,
33767           result = baseAt(array, indexes);
33768
33769       basePullAt(array, arrayMap(indexes, function(index) {
33770         return isIndex(index, length) ? +index : index;
33771       }).sort(compareAscending));
33772
33773       return result;
33774     });
33775
33776     /**
33777      * Removes all elements from `array` that `predicate` returns truthy for
33778      * and returns an array of the removed elements. The predicate is invoked
33779      * with three arguments: (value, index, array).
33780      *
33781      * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
33782      * to pull elements from an array by value.
33783      *
33784      * @static
33785      * @memberOf _
33786      * @since 2.0.0
33787      * @category Array
33788      * @param {Array} array The array to modify.
33789      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33790      * @returns {Array} Returns the new array of removed elements.
33791      * @example
33792      *
33793      * var array = [1, 2, 3, 4];
33794      * var evens = _.remove(array, function(n) {
33795      *   return n % 2 == 0;
33796      * });
33797      *
33798      * console.log(array);
33799      * // => [1, 3]
33800      *
33801      * console.log(evens);
33802      * // => [2, 4]
33803      */
33804     function remove(array, predicate) {
33805       var result = [];
33806       if (!(array && array.length)) {
33807         return result;
33808       }
33809       var index = -1,
33810           indexes = [],
33811           length = array.length;
33812
33813       predicate = getIteratee(predicate, 3);
33814       while (++index < length) {
33815         var value = array[index];
33816         if (predicate(value, index, array)) {
33817           result.push(value);
33818           indexes.push(index);
33819         }
33820       }
33821       basePullAt(array, indexes);
33822       return result;
33823     }
33824
33825     /**
33826      * Reverses `array` so that the first element becomes the last, the second
33827      * element becomes the second to last, and so on.
33828      *
33829      * **Note:** This method mutates `array` and is based on
33830      * [`Array#reverse`](https://mdn.io/Array/reverse).
33831      *
33832      * @static
33833      * @memberOf _
33834      * @since 4.0.0
33835      * @category Array
33836      * @param {Array} array The array to modify.
33837      * @returns {Array} Returns `array`.
33838      * @example
33839      *
33840      * var array = [1, 2, 3];
33841      *
33842      * _.reverse(array);
33843      * // => [3, 2, 1]
33844      *
33845      * console.log(array);
33846      * // => [3, 2, 1]
33847      */
33848     function reverse(array) {
33849       return array == null ? array : nativeReverse.call(array);
33850     }
33851
33852     /**
33853      * Creates a slice of `array` from `start` up to, but not including, `end`.
33854      *
33855      * **Note:** This method is used instead of
33856      * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
33857      * returned.
33858      *
33859      * @static
33860      * @memberOf _
33861      * @since 3.0.0
33862      * @category Array
33863      * @param {Array} array The array to slice.
33864      * @param {number} [start=0] The start position.
33865      * @param {number} [end=array.length] The end position.
33866      * @returns {Array} Returns the slice of `array`.
33867      */
33868     function slice(array, start, end) {
33869       var length = array == null ? 0 : array.length;
33870       if (!length) {
33871         return [];
33872       }
33873       if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
33874         start = 0;
33875         end = length;
33876       }
33877       else {
33878         start = start == null ? 0 : toInteger(start);
33879         end = end === undefined ? length : toInteger(end);
33880       }
33881       return baseSlice(array, start, end);
33882     }
33883
33884     /**
33885      * Uses a binary search to determine the lowest index at which `value`
33886      * should be inserted into `array` in order to maintain its sort order.
33887      *
33888      * @static
33889      * @memberOf _
33890      * @since 0.1.0
33891      * @category Array
33892      * @param {Array} array The sorted array to inspect.
33893      * @param {*} value The value to evaluate.
33894      * @returns {number} Returns the index at which `value` should be inserted
33895      *  into `array`.
33896      * @example
33897      *
33898      * _.sortedIndex([30, 50], 40);
33899      * // => 1
33900      */
33901     function sortedIndex(array, value) {
33902       return baseSortedIndex(array, value);
33903     }
33904
33905     /**
33906      * This method is like `_.sortedIndex` except that it accepts `iteratee`
33907      * which is invoked for `value` and each element of `array` to compute their
33908      * sort ranking. The iteratee is invoked with one argument: (value).
33909      *
33910      * @static
33911      * @memberOf _
33912      * @since 4.0.0
33913      * @category Array
33914      * @param {Array} array The sorted array to inspect.
33915      * @param {*} value The value to evaluate.
33916      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
33917      * @returns {number} Returns the index at which `value` should be inserted
33918      *  into `array`.
33919      * @example
33920      *
33921      * var objects = [{ 'x': 4 }, { 'x': 5 }];
33922      *
33923      * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
33924      * // => 0
33925      *
33926      * // The `_.property` iteratee shorthand.
33927      * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
33928      * // => 0
33929      */
33930     function sortedIndexBy(array, value, iteratee) {
33931       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
33932     }
33933
33934     /**
33935      * This method is like `_.indexOf` except that it performs a binary
33936      * search on a sorted `array`.
33937      *
33938      * @static
33939      * @memberOf _
33940      * @since 4.0.0
33941      * @category Array
33942      * @param {Array} array The array to inspect.
33943      * @param {*} value The value to search for.
33944      * @returns {number} Returns the index of the matched value, else `-1`.
33945      * @example
33946      *
33947      * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
33948      * // => 1
33949      */
33950     function sortedIndexOf(array, value) {
33951       var length = array == null ? 0 : array.length;
33952       if (length) {
33953         var index = baseSortedIndex(array, value);
33954         if (index < length && eq(array[index], value)) {
33955           return index;
33956         }
33957       }
33958       return -1;
33959     }
33960
33961     /**
33962      * This method is like `_.sortedIndex` except that it returns the highest
33963      * index at which `value` should be inserted into `array` in order to
33964      * maintain its sort order.
33965      *
33966      * @static
33967      * @memberOf _
33968      * @since 3.0.0
33969      * @category Array
33970      * @param {Array} array The sorted array to inspect.
33971      * @param {*} value The value to evaluate.
33972      * @returns {number} Returns the index at which `value` should be inserted
33973      *  into `array`.
33974      * @example
33975      *
33976      * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
33977      * // => 4
33978      */
33979     function sortedLastIndex(array, value) {
33980       return baseSortedIndex(array, value, true);
33981     }
33982
33983     /**
33984      * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
33985      * which is invoked for `value` and each element of `array` to compute their
33986      * sort ranking. The iteratee is invoked with one argument: (value).
33987      *
33988      * @static
33989      * @memberOf _
33990      * @since 4.0.0
33991      * @category Array
33992      * @param {Array} array The sorted array to inspect.
33993      * @param {*} value The value to evaluate.
33994      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
33995      * @returns {number} Returns the index at which `value` should be inserted
33996      *  into `array`.
33997      * @example
33998      *
33999      * var objects = [{ 'x': 4 }, { 'x': 5 }];
34000      *
34001      * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
34002      * // => 1
34003      *
34004      * // The `_.property` iteratee shorthand.
34005      * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
34006      * // => 1
34007      */
34008     function sortedLastIndexBy(array, value, iteratee) {
34009       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
34010     }
34011
34012     /**
34013      * This method is like `_.lastIndexOf` except that it performs a binary
34014      * search on a sorted `array`.
34015      *
34016      * @static
34017      * @memberOf _
34018      * @since 4.0.0
34019      * @category Array
34020      * @param {Array} array The array to inspect.
34021      * @param {*} value The value to search for.
34022      * @returns {number} Returns the index of the matched value, else `-1`.
34023      * @example
34024      *
34025      * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
34026      * // => 3
34027      */
34028     function sortedLastIndexOf(array, value) {
34029       var length = array == null ? 0 : array.length;
34030       if (length) {
34031         var index = baseSortedIndex(array, value, true) - 1;
34032         if (eq(array[index], value)) {
34033           return index;
34034         }
34035       }
34036       return -1;
34037     }
34038
34039     /**
34040      * This method is like `_.uniq` except that it's designed and optimized
34041      * for sorted arrays.
34042      *
34043      * @static
34044      * @memberOf _
34045      * @since 4.0.0
34046      * @category Array
34047      * @param {Array} array The array to inspect.
34048      * @returns {Array} Returns the new duplicate free array.
34049      * @example
34050      *
34051      * _.sortedUniq([1, 1, 2]);
34052      * // => [1, 2]
34053      */
34054     function sortedUniq(array) {
34055       return (array && array.length)
34056         ? baseSortedUniq(array)
34057         : [];
34058     }
34059
34060     /**
34061      * This method is like `_.uniqBy` except that it's designed and optimized
34062      * for sorted arrays.
34063      *
34064      * @static
34065      * @memberOf _
34066      * @since 4.0.0
34067      * @category Array
34068      * @param {Array} array The array to inspect.
34069      * @param {Function} [iteratee] The iteratee invoked per element.
34070      * @returns {Array} Returns the new duplicate free array.
34071      * @example
34072      *
34073      * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
34074      * // => [1.1, 2.3]
34075      */
34076     function sortedUniqBy(array, iteratee) {
34077       return (array && array.length)
34078         ? baseSortedUniq(array, getIteratee(iteratee, 2))
34079         : [];
34080     }
34081
34082     /**
34083      * Gets all but the first element of `array`.
34084      *
34085      * @static
34086      * @memberOf _
34087      * @since 4.0.0
34088      * @category Array
34089      * @param {Array} array The array to query.
34090      * @returns {Array} Returns the slice of `array`.
34091      * @example
34092      *
34093      * _.tail([1, 2, 3]);
34094      * // => [2, 3]
34095      */
34096     function tail(array) {
34097       var length = array == null ? 0 : array.length;
34098       return length ? baseSlice(array, 1, length) : [];
34099     }
34100
34101     /**
34102      * Creates a slice of `array` with `n` elements taken from the beginning.
34103      *
34104      * @static
34105      * @memberOf _
34106      * @since 0.1.0
34107      * @category Array
34108      * @param {Array} array The array to query.
34109      * @param {number} [n=1] The number of elements to take.
34110      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
34111      * @returns {Array} Returns the slice of `array`.
34112      * @example
34113      *
34114      * _.take([1, 2, 3]);
34115      * // => [1]
34116      *
34117      * _.take([1, 2, 3], 2);
34118      * // => [1, 2]
34119      *
34120      * _.take([1, 2, 3], 5);
34121      * // => [1, 2, 3]
34122      *
34123      * _.take([1, 2, 3], 0);
34124      * // => []
34125      */
34126     function take(array, n, guard) {
34127       if (!(array && array.length)) {
34128         return [];
34129       }
34130       n = (guard || n === undefined) ? 1 : toInteger(n);
34131       return baseSlice(array, 0, n < 0 ? 0 : n);
34132     }
34133
34134     /**
34135      * Creates a slice of `array` with `n` elements taken from the end.
34136      *
34137      * @static
34138      * @memberOf _
34139      * @since 3.0.0
34140      * @category Array
34141      * @param {Array} array The array to query.
34142      * @param {number} [n=1] The number of elements to take.
34143      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
34144      * @returns {Array} Returns the slice of `array`.
34145      * @example
34146      *
34147      * _.takeRight([1, 2, 3]);
34148      * // => [3]
34149      *
34150      * _.takeRight([1, 2, 3], 2);
34151      * // => [2, 3]
34152      *
34153      * _.takeRight([1, 2, 3], 5);
34154      * // => [1, 2, 3]
34155      *
34156      * _.takeRight([1, 2, 3], 0);
34157      * // => []
34158      */
34159     function takeRight(array, n, guard) {
34160       var length = array == null ? 0 : array.length;
34161       if (!length) {
34162         return [];
34163       }
34164       n = (guard || n === undefined) ? 1 : toInteger(n);
34165       n = length - n;
34166       return baseSlice(array, n < 0 ? 0 : n, length);
34167     }
34168
34169     /**
34170      * Creates a slice of `array` with elements taken from the end. Elements are
34171      * taken until `predicate` returns falsey. The predicate is invoked with
34172      * three arguments: (value, index, array).
34173      *
34174      * @static
34175      * @memberOf _
34176      * @since 3.0.0
34177      * @category Array
34178      * @param {Array} array The array to query.
34179      * @param {Function} [predicate=_.identity] The function invoked per iteration.
34180      * @returns {Array} Returns the slice of `array`.
34181      * @example
34182      *
34183      * var users = [
34184      *   { 'user': 'barney',  'active': true },
34185      *   { 'user': 'fred',    'active': false },
34186      *   { 'user': 'pebbles', 'active': false }
34187      * ];
34188      *
34189      * _.takeRightWhile(users, function(o) { return !o.active; });
34190      * // => objects for ['fred', 'pebbles']
34191      *
34192      * // The `_.matches` iteratee shorthand.
34193      * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
34194      * // => objects for ['pebbles']
34195      *
34196      * // The `_.matchesProperty` iteratee shorthand.
34197      * _.takeRightWhile(users, ['active', false]);
34198      * // => objects for ['fred', 'pebbles']
34199      *
34200      * // The `_.property` iteratee shorthand.
34201      * _.takeRightWhile(users, 'active');
34202      * // => []
34203      */
34204     function takeRightWhile(array, predicate) {
34205       return (array && array.length)
34206         ? baseWhile(array, getIteratee(predicate, 3), false, true)
34207         : [];
34208     }
34209
34210     /**
34211      * Creates a slice of `array` with elements taken from the beginning. Elements
34212      * are taken until `predicate` returns falsey. The predicate is invoked with
34213      * three arguments: (value, index, array).
34214      *
34215      * @static
34216      * @memberOf _
34217      * @since 3.0.0
34218      * @category Array
34219      * @param {Array} array The array to query.
34220      * @param {Function} [predicate=_.identity] The function invoked per iteration.
34221      * @returns {Array} Returns the slice of `array`.
34222      * @example
34223      *
34224      * var users = [
34225      *   { 'user': 'barney',  'active': false },
34226      *   { 'user': 'fred',    'active': false },
34227      *   { 'user': 'pebbles', 'active': true }
34228      * ];
34229      *
34230      * _.takeWhile(users, function(o) { return !o.active; });
34231      * // => objects for ['barney', 'fred']
34232      *
34233      * // The `_.matches` iteratee shorthand.
34234      * _.takeWhile(users, { 'user': 'barney', 'active': false });
34235      * // => objects for ['barney']
34236      *
34237      * // The `_.matchesProperty` iteratee shorthand.
34238      * _.takeWhile(users, ['active', false]);
34239      * // => objects for ['barney', 'fred']
34240      *
34241      * // The `_.property` iteratee shorthand.
34242      * _.takeWhile(users, 'active');
34243      * // => []
34244      */
34245     function takeWhile(array, predicate) {
34246       return (array && array.length)
34247         ? baseWhile(array, getIteratee(predicate, 3))
34248         : [];
34249     }
34250
34251     /**
34252      * Creates an array of unique values, in order, from all given arrays using
34253      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34254      * for equality comparisons.
34255      *
34256      * @static
34257      * @memberOf _
34258      * @since 0.1.0
34259      * @category Array
34260      * @param {...Array} [arrays] The arrays to inspect.
34261      * @returns {Array} Returns the new array of combined values.
34262      * @example
34263      *
34264      * _.union([2], [1, 2]);
34265      * // => [2, 1]
34266      */
34267     var union = baseRest(function(arrays) {
34268       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
34269     });
34270
34271     /**
34272      * This method is like `_.union` except that it accepts `iteratee` which is
34273      * invoked for each element of each `arrays` to generate the criterion by
34274      * which uniqueness is computed. Result values are chosen from the first
34275      * array in which the value occurs. The iteratee is invoked with one argument:
34276      * (value).
34277      *
34278      * @static
34279      * @memberOf _
34280      * @since 4.0.0
34281      * @category Array
34282      * @param {...Array} [arrays] The arrays to inspect.
34283      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34284      * @returns {Array} Returns the new array of combined values.
34285      * @example
34286      *
34287      * _.unionBy([2.1], [1.2, 2.3], Math.floor);
34288      * // => [2.1, 1.2]
34289      *
34290      * // The `_.property` iteratee shorthand.
34291      * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
34292      * // => [{ 'x': 1 }, { 'x': 2 }]
34293      */
34294     var unionBy = baseRest(function(arrays) {
34295       var iteratee = last(arrays);
34296       if (isArrayLikeObject(iteratee)) {
34297         iteratee = undefined;
34298       }
34299       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
34300     });
34301
34302     /**
34303      * This method is like `_.union` except that it accepts `comparator` which
34304      * is invoked to compare elements of `arrays`. Result values are chosen from
34305      * the first array in which the value occurs. The comparator is invoked
34306      * with two arguments: (arrVal, othVal).
34307      *
34308      * @static
34309      * @memberOf _
34310      * @since 4.0.0
34311      * @category Array
34312      * @param {...Array} [arrays] The arrays to inspect.
34313      * @param {Function} [comparator] The comparator invoked per element.
34314      * @returns {Array} Returns the new array of combined values.
34315      * @example
34316      *
34317      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
34318      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
34319      *
34320      * _.unionWith(objects, others, _.isEqual);
34321      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
34322      */
34323     var unionWith = baseRest(function(arrays) {
34324       var comparator = last(arrays);
34325       comparator = typeof comparator == 'function' ? comparator : undefined;
34326       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
34327     });
34328
34329     /**
34330      * Creates a duplicate-free version of an array, using
34331      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34332      * for equality comparisons, in which only the first occurrence of each element
34333      * is kept. The order of result values is determined by the order they occur
34334      * in the array.
34335      *
34336      * @static
34337      * @memberOf _
34338      * @since 0.1.0
34339      * @category Array
34340      * @param {Array} array The array to inspect.
34341      * @returns {Array} Returns the new duplicate free array.
34342      * @example
34343      *
34344      * _.uniq([2, 1, 2]);
34345      * // => [2, 1]
34346      */
34347     function uniq(array) {
34348       return (array && array.length) ? baseUniq(array) : [];
34349     }
34350
34351     /**
34352      * This method is like `_.uniq` except that it accepts `iteratee` which is
34353      * invoked for each element in `array` to generate the criterion by which
34354      * uniqueness is computed. The order of result values is determined by the
34355      * order they occur in the array. The iteratee is invoked with one argument:
34356      * (value).
34357      *
34358      * @static
34359      * @memberOf _
34360      * @since 4.0.0
34361      * @category Array
34362      * @param {Array} array The array to inspect.
34363      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34364      * @returns {Array} Returns the new duplicate free array.
34365      * @example
34366      *
34367      * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
34368      * // => [2.1, 1.2]
34369      *
34370      * // The `_.property` iteratee shorthand.
34371      * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
34372      * // => [{ 'x': 1 }, { 'x': 2 }]
34373      */
34374     function uniqBy(array, iteratee) {
34375       return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
34376     }
34377
34378     /**
34379      * This method is like `_.uniq` except that it accepts `comparator` which
34380      * is invoked to compare elements of `array`. The order of result values is
34381      * determined by the order they occur in the array.The comparator is invoked
34382      * with two arguments: (arrVal, othVal).
34383      *
34384      * @static
34385      * @memberOf _
34386      * @since 4.0.0
34387      * @category Array
34388      * @param {Array} array The array to inspect.
34389      * @param {Function} [comparator] The comparator invoked per element.
34390      * @returns {Array} Returns the new duplicate free array.
34391      * @example
34392      *
34393      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
34394      *
34395      * _.uniqWith(objects, _.isEqual);
34396      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
34397      */
34398     function uniqWith(array, comparator) {
34399       comparator = typeof comparator == 'function' ? comparator : undefined;
34400       return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
34401     }
34402
34403     /**
34404      * This method is like `_.zip` except that it accepts an array of grouped
34405      * elements and creates an array regrouping the elements to their pre-zip
34406      * configuration.
34407      *
34408      * @static
34409      * @memberOf _
34410      * @since 1.2.0
34411      * @category Array
34412      * @param {Array} array The array of grouped elements to process.
34413      * @returns {Array} Returns the new array of regrouped elements.
34414      * @example
34415      *
34416      * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
34417      * // => [['a', 1, true], ['b', 2, false]]
34418      *
34419      * _.unzip(zipped);
34420      * // => [['a', 'b'], [1, 2], [true, false]]
34421      */
34422     function unzip(array) {
34423       if (!(array && array.length)) {
34424         return [];
34425       }
34426       var length = 0;
34427       array = arrayFilter(array, function(group) {
34428         if (isArrayLikeObject(group)) {
34429           length = nativeMax(group.length, length);
34430           return true;
34431         }
34432       });
34433       return baseTimes(length, function(index) {
34434         return arrayMap(array, baseProperty(index));
34435       });
34436     }
34437
34438     /**
34439      * This method is like `_.unzip` except that it accepts `iteratee` to specify
34440      * how regrouped values should be combined. The iteratee is invoked with the
34441      * elements of each group: (...group).
34442      *
34443      * @static
34444      * @memberOf _
34445      * @since 3.8.0
34446      * @category Array
34447      * @param {Array} array The array of grouped elements to process.
34448      * @param {Function} [iteratee=_.identity] The function to combine
34449      *  regrouped values.
34450      * @returns {Array} Returns the new array of regrouped elements.
34451      * @example
34452      *
34453      * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
34454      * // => [[1, 10, 100], [2, 20, 200]]
34455      *
34456      * _.unzipWith(zipped, _.add);
34457      * // => [3, 30, 300]
34458      */
34459     function unzipWith(array, iteratee) {
34460       if (!(array && array.length)) {
34461         return [];
34462       }
34463       var result = unzip(array);
34464       if (iteratee == null) {
34465         return result;
34466       }
34467       return arrayMap(result, function(group) {
34468         return apply(iteratee, undefined, group);
34469       });
34470     }
34471
34472     /**
34473      * Creates an array excluding all given values using
34474      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34475      * for equality comparisons.
34476      *
34477      * **Note:** Unlike `_.pull`, this method returns a new array.
34478      *
34479      * @static
34480      * @memberOf _
34481      * @since 0.1.0
34482      * @category Array
34483      * @param {Array} array The array to inspect.
34484      * @param {...*} [values] The values to exclude.
34485      * @returns {Array} Returns the new array of filtered values.
34486      * @see _.difference, _.xor
34487      * @example
34488      *
34489      * _.without([2, 1, 2, 3], 1, 2);
34490      * // => [3]
34491      */
34492     var without = baseRest(function(array, values) {
34493       return isArrayLikeObject(array)
34494         ? baseDifference(array, values)
34495         : [];
34496     });
34497
34498     /**
34499      * Creates an array of unique values that is the
34500      * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
34501      * of the given arrays. The order of result values is determined by the order
34502      * they occur in the arrays.
34503      *
34504      * @static
34505      * @memberOf _
34506      * @since 2.4.0
34507      * @category Array
34508      * @param {...Array} [arrays] The arrays to inspect.
34509      * @returns {Array} Returns the new array of filtered values.
34510      * @see _.difference, _.without
34511      * @example
34512      *
34513      * _.xor([2, 1], [2, 3]);
34514      * // => [1, 3]
34515      */
34516     var xor = baseRest(function(arrays) {
34517       return baseXor(arrayFilter(arrays, isArrayLikeObject));
34518     });
34519
34520     /**
34521      * This method is like `_.xor` except that it accepts `iteratee` which is
34522      * invoked for each element of each `arrays` to generate the criterion by
34523      * which by which they're compared. The order of result values is determined
34524      * by the order they occur in the arrays. The iteratee is invoked with one
34525      * argument: (value).
34526      *
34527      * @static
34528      * @memberOf _
34529      * @since 4.0.0
34530      * @category Array
34531      * @param {...Array} [arrays] The arrays to inspect.
34532      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34533      * @returns {Array} Returns the new array of filtered values.
34534      * @example
34535      *
34536      * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
34537      * // => [1.2, 3.4]
34538      *
34539      * // The `_.property` iteratee shorthand.
34540      * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
34541      * // => [{ 'x': 2 }]
34542      */
34543     var xorBy = baseRest(function(arrays) {
34544       var iteratee = last(arrays);
34545       if (isArrayLikeObject(iteratee)) {
34546         iteratee = undefined;
34547       }
34548       return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
34549     });
34550
34551     /**
34552      * This method is like `_.xor` except that it accepts `comparator` which is
34553      * invoked to compare elements of `arrays`. The order of result values is
34554      * determined by the order they occur in the arrays. The comparator is invoked
34555      * with two arguments: (arrVal, othVal).
34556      *
34557      * @static
34558      * @memberOf _
34559      * @since 4.0.0
34560      * @category Array
34561      * @param {...Array} [arrays] The arrays to inspect.
34562      * @param {Function} [comparator] The comparator invoked per element.
34563      * @returns {Array} Returns the new array of filtered values.
34564      * @example
34565      *
34566      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
34567      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
34568      *
34569      * _.xorWith(objects, others, _.isEqual);
34570      * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
34571      */
34572     var xorWith = baseRest(function(arrays) {
34573       var comparator = last(arrays);
34574       comparator = typeof comparator == 'function' ? comparator : undefined;
34575       return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
34576     });
34577
34578     /**
34579      * Creates an array of grouped elements, the first of which contains the
34580      * first elements of the given arrays, the second of which contains the
34581      * second elements of the given arrays, and so on.
34582      *
34583      * @static
34584      * @memberOf _
34585      * @since 0.1.0
34586      * @category Array
34587      * @param {...Array} [arrays] The arrays to process.
34588      * @returns {Array} Returns the new array of grouped elements.
34589      * @example
34590      *
34591      * _.zip(['a', 'b'], [1, 2], [true, false]);
34592      * // => [['a', 1, true], ['b', 2, false]]
34593      */
34594     var zip = baseRest(unzip);
34595
34596     /**
34597      * This method is like `_.fromPairs` except that it accepts two arrays,
34598      * one of property identifiers and one of corresponding values.
34599      *
34600      * @static
34601      * @memberOf _
34602      * @since 0.4.0
34603      * @category Array
34604      * @param {Array} [props=[]] The property identifiers.
34605      * @param {Array} [values=[]] The property values.
34606      * @returns {Object} Returns the new object.
34607      * @example
34608      *
34609      * _.zipObject(['a', 'b'], [1, 2]);
34610      * // => { 'a': 1, 'b': 2 }
34611      */
34612     function zipObject(props, values) {
34613       return baseZipObject(props || [], values || [], assignValue);
34614     }
34615
34616     /**
34617      * This method is like `_.zipObject` except that it supports property paths.
34618      *
34619      * @static
34620      * @memberOf _
34621      * @since 4.1.0
34622      * @category Array
34623      * @param {Array} [props=[]] The property identifiers.
34624      * @param {Array} [values=[]] The property values.
34625      * @returns {Object} Returns the new object.
34626      * @example
34627      *
34628      * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
34629      * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
34630      */
34631     function zipObjectDeep(props, values) {
34632       return baseZipObject(props || [], values || [], baseSet);
34633     }
34634
34635     /**
34636      * This method is like `_.zip` except that it accepts `iteratee` to specify
34637      * how grouped values should be combined. The iteratee is invoked with the
34638      * elements of each group: (...group).
34639      *
34640      * @static
34641      * @memberOf _
34642      * @since 3.8.0
34643      * @category Array
34644      * @param {...Array} [arrays] The arrays to process.
34645      * @param {Function} [iteratee=_.identity] The function to combine
34646      *  grouped values.
34647      * @returns {Array} Returns the new array of grouped elements.
34648      * @example
34649      *
34650      * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
34651      *   return a + b + c;
34652      * });
34653      * // => [111, 222]
34654      */
34655     var zipWith = baseRest(function(arrays) {
34656       var length = arrays.length,
34657           iteratee = length > 1 ? arrays[length - 1] : undefined;
34658
34659       iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
34660       return unzipWith(arrays, iteratee);
34661     });
34662
34663     /*------------------------------------------------------------------------*/
34664
34665     /**
34666      * Creates a `lodash` wrapper instance that wraps `value` with explicit method
34667      * chain sequences enabled. The result of such sequences must be unwrapped
34668      * with `_#value`.
34669      *
34670      * @static
34671      * @memberOf _
34672      * @since 1.3.0
34673      * @category Seq
34674      * @param {*} value The value to wrap.
34675      * @returns {Object} Returns the new `lodash` wrapper instance.
34676      * @example
34677      *
34678      * var users = [
34679      *   { 'user': 'barney',  'age': 36 },
34680      *   { 'user': 'fred',    'age': 40 },
34681      *   { 'user': 'pebbles', 'age': 1 }
34682      * ];
34683      *
34684      * var youngest = _
34685      *   .chain(users)
34686      *   .sortBy('age')
34687      *   .map(function(o) {
34688      *     return o.user + ' is ' + o.age;
34689      *   })
34690      *   .head()
34691      *   .value();
34692      * // => 'pebbles is 1'
34693      */
34694     function chain(value) {
34695       var result = lodash(value);
34696       result.__chain__ = true;
34697       return result;
34698     }
34699
34700     /**
34701      * This method invokes `interceptor` and returns `value`. The interceptor
34702      * is invoked with one argument; (value). The purpose of this method is to
34703      * "tap into" a method chain sequence in order to modify intermediate results.
34704      *
34705      * @static
34706      * @memberOf _
34707      * @since 0.1.0
34708      * @category Seq
34709      * @param {*} value The value to provide to `interceptor`.
34710      * @param {Function} interceptor The function to invoke.
34711      * @returns {*} Returns `value`.
34712      * @example
34713      *
34714      * _([1, 2, 3])
34715      *  .tap(function(array) {
34716      *    // Mutate input array.
34717      *    array.pop();
34718      *  })
34719      *  .reverse()
34720      *  .value();
34721      * // => [2, 1]
34722      */
34723     function tap(value, interceptor) {
34724       interceptor(value);
34725       return value;
34726     }
34727
34728     /**
34729      * This method is like `_.tap` except that it returns the result of `interceptor`.
34730      * The purpose of this method is to "pass thru" values replacing intermediate
34731      * results in a method chain sequence.
34732      *
34733      * @static
34734      * @memberOf _
34735      * @since 3.0.0
34736      * @category Seq
34737      * @param {*} value The value to provide to `interceptor`.
34738      * @param {Function} interceptor The function to invoke.
34739      * @returns {*} Returns the result of `interceptor`.
34740      * @example
34741      *
34742      * _('  abc  ')
34743      *  .chain()
34744      *  .trim()
34745      *  .thru(function(value) {
34746      *    return [value];
34747      *  })
34748      *  .value();
34749      * // => ['abc']
34750      */
34751     function thru(value, interceptor) {
34752       return interceptor(value);
34753     }
34754
34755     /**
34756      * This method is the wrapper version of `_.at`.
34757      *
34758      * @name at
34759      * @memberOf _
34760      * @since 1.0.0
34761      * @category Seq
34762      * @param {...(string|string[])} [paths] The property paths to pick.
34763      * @returns {Object} Returns the new `lodash` wrapper instance.
34764      * @example
34765      *
34766      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
34767      *
34768      * _(object).at(['a[0].b.c', 'a[1]']).value();
34769      * // => [3, 4]
34770      */
34771     var wrapperAt = flatRest(function(paths) {
34772       var length = paths.length,
34773           start = length ? paths[0] : 0,
34774           value = this.__wrapped__,
34775           interceptor = function(object) { return baseAt(object, paths); };
34776
34777       if (length > 1 || this.__actions__.length ||
34778           !(value instanceof LazyWrapper) || !isIndex(start)) {
34779         return this.thru(interceptor);
34780       }
34781       value = value.slice(start, +start + (length ? 1 : 0));
34782       value.__actions__.push({
34783         'func': thru,
34784         'args': [interceptor],
34785         'thisArg': undefined
34786       });
34787       return new LodashWrapper(value, this.__chain__).thru(function(array) {
34788         if (length && !array.length) {
34789           array.push(undefined);
34790         }
34791         return array;
34792       });
34793     });
34794
34795     /**
34796      * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
34797      *
34798      * @name chain
34799      * @memberOf _
34800      * @since 0.1.0
34801      * @category Seq
34802      * @returns {Object} Returns the new `lodash` wrapper instance.
34803      * @example
34804      *
34805      * var users = [
34806      *   { 'user': 'barney', 'age': 36 },
34807      *   { 'user': 'fred',   'age': 40 }
34808      * ];
34809      *
34810      * // A sequence without explicit chaining.
34811      * _(users).head();
34812      * // => { 'user': 'barney', 'age': 36 }
34813      *
34814      * // A sequence with explicit chaining.
34815      * _(users)
34816      *   .chain()
34817      *   .head()
34818      *   .pick('user')
34819      *   .value();
34820      * // => { 'user': 'barney' }
34821      */
34822     function wrapperChain() {
34823       return chain(this);
34824     }
34825
34826     /**
34827      * Executes the chain sequence and returns the wrapped result.
34828      *
34829      * @name commit
34830      * @memberOf _
34831      * @since 3.2.0
34832      * @category Seq
34833      * @returns {Object} Returns the new `lodash` wrapper instance.
34834      * @example
34835      *
34836      * var array = [1, 2];
34837      * var wrapped = _(array).push(3);
34838      *
34839      * console.log(array);
34840      * // => [1, 2]
34841      *
34842      * wrapped = wrapped.commit();
34843      * console.log(array);
34844      * // => [1, 2, 3]
34845      *
34846      * wrapped.last();
34847      * // => 3
34848      *
34849      * console.log(array);
34850      * // => [1, 2, 3]
34851      */
34852     function wrapperCommit() {
34853       return new LodashWrapper(this.value(), this.__chain__);
34854     }
34855
34856     /**
34857      * Gets the next value on a wrapped object following the
34858      * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
34859      *
34860      * @name next
34861      * @memberOf _
34862      * @since 4.0.0
34863      * @category Seq
34864      * @returns {Object} Returns the next iterator value.
34865      * @example
34866      *
34867      * var wrapped = _([1, 2]);
34868      *
34869      * wrapped.next();
34870      * // => { 'done': false, 'value': 1 }
34871      *
34872      * wrapped.next();
34873      * // => { 'done': false, 'value': 2 }
34874      *
34875      * wrapped.next();
34876      * // => { 'done': true, 'value': undefined }
34877      */
34878     function wrapperNext() {
34879       if (this.__values__ === undefined) {
34880         this.__values__ = toArray(this.value());
34881       }
34882       var done = this.__index__ >= this.__values__.length,
34883           value = done ? undefined : this.__values__[this.__index__++];
34884
34885       return { 'done': done, 'value': value };
34886     }
34887
34888     /**
34889      * Enables the wrapper to be iterable.
34890      *
34891      * @name Symbol.iterator
34892      * @memberOf _
34893      * @since 4.0.0
34894      * @category Seq
34895      * @returns {Object} Returns the wrapper object.
34896      * @example
34897      *
34898      * var wrapped = _([1, 2]);
34899      *
34900      * wrapped[Symbol.iterator]() === wrapped;
34901      * // => true
34902      *
34903      * Array.from(wrapped);
34904      * // => [1, 2]
34905      */
34906     function wrapperToIterator() {
34907       return this;
34908     }
34909
34910     /**
34911      * Creates a clone of the chain sequence planting `value` as the wrapped value.
34912      *
34913      * @name plant
34914      * @memberOf _
34915      * @since 3.2.0
34916      * @category Seq
34917      * @param {*} value The value to plant.
34918      * @returns {Object} Returns the new `lodash` wrapper instance.
34919      * @example
34920      *
34921      * function square(n) {
34922      *   return n * n;
34923      * }
34924      *
34925      * var wrapped = _([1, 2]).map(square);
34926      * var other = wrapped.plant([3, 4]);
34927      *
34928      * other.value();
34929      * // => [9, 16]
34930      *
34931      * wrapped.value();
34932      * // => [1, 4]
34933      */
34934     function wrapperPlant(value) {
34935       var result,
34936           parent = this;
34937
34938       while (parent instanceof baseLodash) {
34939         var clone = wrapperClone(parent);
34940         clone.__index__ = 0;
34941         clone.__values__ = undefined;
34942         if (result) {
34943           previous.__wrapped__ = clone;
34944         } else {
34945           result = clone;
34946         }
34947         var previous = clone;
34948         parent = parent.__wrapped__;
34949       }
34950       previous.__wrapped__ = value;
34951       return result;
34952     }
34953
34954     /**
34955      * This method is the wrapper version of `_.reverse`.
34956      *
34957      * **Note:** This method mutates the wrapped array.
34958      *
34959      * @name reverse
34960      * @memberOf _
34961      * @since 0.1.0
34962      * @category Seq
34963      * @returns {Object} Returns the new `lodash` wrapper instance.
34964      * @example
34965      *
34966      * var array = [1, 2, 3];
34967      *
34968      * _(array).reverse().value()
34969      * // => [3, 2, 1]
34970      *
34971      * console.log(array);
34972      * // => [3, 2, 1]
34973      */
34974     function wrapperReverse() {
34975       var value = this.__wrapped__;
34976       if (value instanceof LazyWrapper) {
34977         var wrapped = value;
34978         if (this.__actions__.length) {
34979           wrapped = new LazyWrapper(this);
34980         }
34981         wrapped = wrapped.reverse();
34982         wrapped.__actions__.push({
34983           'func': thru,
34984           'args': [reverse],
34985           'thisArg': undefined
34986         });
34987         return new LodashWrapper(wrapped, this.__chain__);
34988       }
34989       return this.thru(reverse);
34990     }
34991
34992     /**
34993      * Executes the chain sequence to resolve the unwrapped value.
34994      *
34995      * @name value
34996      * @memberOf _
34997      * @since 0.1.0
34998      * @alias toJSON, valueOf
34999      * @category Seq
35000      * @returns {*} Returns the resolved unwrapped value.
35001      * @example
35002      *
35003      * _([1, 2, 3]).value();
35004      * // => [1, 2, 3]
35005      */
35006     function wrapperValue() {
35007       return baseWrapperValue(this.__wrapped__, this.__actions__);
35008     }
35009
35010     /*------------------------------------------------------------------------*/
35011
35012     /**
35013      * Creates an object composed of keys generated from the results of running
35014      * each element of `collection` thru `iteratee`. The corresponding value of
35015      * each key is the number of times the key was returned by `iteratee`. The
35016      * iteratee is invoked with one argument: (value).
35017      *
35018      * @static
35019      * @memberOf _
35020      * @since 0.5.0
35021      * @category Collection
35022      * @param {Array|Object} collection The collection to iterate over.
35023      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
35024      * @returns {Object} Returns the composed aggregate object.
35025      * @example
35026      *
35027      * _.countBy([6.1, 4.2, 6.3], Math.floor);
35028      * // => { '4': 1, '6': 2 }
35029      *
35030      * // The `_.property` iteratee shorthand.
35031      * _.countBy(['one', 'two', 'three'], 'length');
35032      * // => { '3': 2, '5': 1 }
35033      */
35034     var countBy = createAggregator(function(result, value, key) {
35035       if (hasOwnProperty.call(result, key)) {
35036         ++result[key];
35037       } else {
35038         baseAssignValue(result, key, 1);
35039       }
35040     });
35041
35042     /**
35043      * Checks if `predicate` returns truthy for **all** elements of `collection`.
35044      * Iteration is stopped once `predicate` returns falsey. The predicate is
35045      * invoked with three arguments: (value, index|key, collection).
35046      *
35047      * **Note:** This method returns `true` for
35048      * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
35049      * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
35050      * elements of empty collections.
35051      *
35052      * @static
35053      * @memberOf _
35054      * @since 0.1.0
35055      * @category Collection
35056      * @param {Array|Object} collection The collection to iterate over.
35057      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35058      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35059      * @returns {boolean} Returns `true` if all elements pass the predicate check,
35060      *  else `false`.
35061      * @example
35062      *
35063      * _.every([true, 1, null, 'yes'], Boolean);
35064      * // => false
35065      *
35066      * var users = [
35067      *   { 'user': 'barney', 'age': 36, 'active': false },
35068      *   { 'user': 'fred',   'age': 40, 'active': false }
35069      * ];
35070      *
35071      * // The `_.matches` iteratee shorthand.
35072      * _.every(users, { 'user': 'barney', 'active': false });
35073      * // => false
35074      *
35075      * // The `_.matchesProperty` iteratee shorthand.
35076      * _.every(users, ['active', false]);
35077      * // => true
35078      *
35079      * // The `_.property` iteratee shorthand.
35080      * _.every(users, 'active');
35081      * // => false
35082      */
35083     function every(collection, predicate, guard) {
35084       var func = isArray(collection) ? arrayEvery : baseEvery;
35085       if (guard && isIterateeCall(collection, predicate, guard)) {
35086         predicate = undefined;
35087       }
35088       return func(collection, getIteratee(predicate, 3));
35089     }
35090
35091     /**
35092      * Iterates over elements of `collection`, returning an array of all elements
35093      * `predicate` returns truthy for. The predicate is invoked with three
35094      * arguments: (value, index|key, collection).
35095      *
35096      * **Note:** Unlike `_.remove`, this method returns a new array.
35097      *
35098      * @static
35099      * @memberOf _
35100      * @since 0.1.0
35101      * @category Collection
35102      * @param {Array|Object} collection The collection to iterate over.
35103      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35104      * @returns {Array} Returns the new filtered array.
35105      * @see _.reject
35106      * @example
35107      *
35108      * var users = [
35109      *   { 'user': 'barney', 'age': 36, 'active': true },
35110      *   { 'user': 'fred',   'age': 40, 'active': false }
35111      * ];
35112      *
35113      * _.filter(users, function(o) { return !o.active; });
35114      * // => objects for ['fred']
35115      *
35116      * // The `_.matches` iteratee shorthand.
35117      * _.filter(users, { 'age': 36, 'active': true });
35118      * // => objects for ['barney']
35119      *
35120      * // The `_.matchesProperty` iteratee shorthand.
35121      * _.filter(users, ['active', false]);
35122      * // => objects for ['fred']
35123      *
35124      * // The `_.property` iteratee shorthand.
35125      * _.filter(users, 'active');
35126      * // => objects for ['barney']
35127      */
35128     function filter(collection, predicate) {
35129       var func = isArray(collection) ? arrayFilter : baseFilter;
35130       return func(collection, getIteratee(predicate, 3));
35131     }
35132
35133     /**
35134      * Iterates over elements of `collection`, returning the first element
35135      * `predicate` returns truthy for. The predicate is invoked with three
35136      * arguments: (value, index|key, collection).
35137      *
35138      * @static
35139      * @memberOf _
35140      * @since 0.1.0
35141      * @category Collection
35142      * @param {Array|Object} collection The collection to inspect.
35143      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35144      * @param {number} [fromIndex=0] The index to search from.
35145      * @returns {*} Returns the matched element, else `undefined`.
35146      * @example
35147      *
35148      * var users = [
35149      *   { 'user': 'barney',  'age': 36, 'active': true },
35150      *   { 'user': 'fred',    'age': 40, 'active': false },
35151      *   { 'user': 'pebbles', 'age': 1,  'active': true }
35152      * ];
35153      *
35154      * _.find(users, function(o) { return o.age < 40; });
35155      * // => object for 'barney'
35156      *
35157      * // The `_.matches` iteratee shorthand.
35158      * _.find(users, { 'age': 1, 'active': true });
35159      * // => object for 'pebbles'
35160      *
35161      * // The `_.matchesProperty` iteratee shorthand.
35162      * _.find(users, ['active', false]);
35163      * // => object for 'fred'
35164      *
35165      * // The `_.property` iteratee shorthand.
35166      * _.find(users, 'active');
35167      * // => object for 'barney'
35168      */
35169     var find = createFind(findIndex);
35170
35171     /**
35172      * This method is like `_.find` except that it iterates over elements of
35173      * `collection` from right to left.
35174      *
35175      * @static
35176      * @memberOf _
35177      * @since 2.0.0
35178      * @category Collection
35179      * @param {Array|Object} collection The collection to inspect.
35180      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35181      * @param {number} [fromIndex=collection.length-1] The index to search from.
35182      * @returns {*} Returns the matched element, else `undefined`.
35183      * @example
35184      *
35185      * _.findLast([1, 2, 3, 4], function(n) {
35186      *   return n % 2 == 1;
35187      * });
35188      * // => 3
35189      */
35190     var findLast = createFind(findLastIndex);
35191
35192     /**
35193      * Creates a flattened array of values by running each element in `collection`
35194      * thru `iteratee` and flattening the mapped results. The iteratee is invoked
35195      * with three arguments: (value, index|key, collection).
35196      *
35197      * @static
35198      * @memberOf _
35199      * @since 4.0.0
35200      * @category Collection
35201      * @param {Array|Object} collection The collection to iterate over.
35202      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35203      * @returns {Array} Returns the new flattened array.
35204      * @example
35205      *
35206      * function duplicate(n) {
35207      *   return [n, n];
35208      * }
35209      *
35210      * _.flatMap([1, 2], duplicate);
35211      * // => [1, 1, 2, 2]
35212      */
35213     function flatMap(collection, iteratee) {
35214       return baseFlatten(map(collection, iteratee), 1);
35215     }
35216
35217     /**
35218      * This method is like `_.flatMap` except that it recursively flattens the
35219      * mapped results.
35220      *
35221      * @static
35222      * @memberOf _
35223      * @since 4.7.0
35224      * @category Collection
35225      * @param {Array|Object} collection The collection to iterate over.
35226      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35227      * @returns {Array} Returns the new flattened array.
35228      * @example
35229      *
35230      * function duplicate(n) {
35231      *   return [[[n, n]]];
35232      * }
35233      *
35234      * _.flatMapDeep([1, 2], duplicate);
35235      * // => [1, 1, 2, 2]
35236      */
35237     function flatMapDeep(collection, iteratee) {
35238       return baseFlatten(map(collection, iteratee), INFINITY);
35239     }
35240
35241     /**
35242      * This method is like `_.flatMap` except that it recursively flattens the
35243      * mapped results up to `depth` times.
35244      *
35245      * @static
35246      * @memberOf _
35247      * @since 4.7.0
35248      * @category Collection
35249      * @param {Array|Object} collection The collection to iterate over.
35250      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35251      * @param {number} [depth=1] The maximum recursion depth.
35252      * @returns {Array} Returns the new flattened array.
35253      * @example
35254      *
35255      * function duplicate(n) {
35256      *   return [[[n, n]]];
35257      * }
35258      *
35259      * _.flatMapDepth([1, 2], duplicate, 2);
35260      * // => [[1, 1], [2, 2]]
35261      */
35262     function flatMapDepth(collection, iteratee, depth) {
35263       depth = depth === undefined ? 1 : toInteger(depth);
35264       return baseFlatten(map(collection, iteratee), depth);
35265     }
35266
35267     /**
35268      * Iterates over elements of `collection` and invokes `iteratee` for each element.
35269      * The iteratee is invoked with three arguments: (value, index|key, collection).
35270      * Iteratee functions may exit iteration early by explicitly returning `false`.
35271      *
35272      * **Note:** As with other "Collections" methods, objects with a "length"
35273      * property are iterated like arrays. To avoid this behavior use `_.forIn`
35274      * or `_.forOwn` for object iteration.
35275      *
35276      * @static
35277      * @memberOf _
35278      * @since 0.1.0
35279      * @alias each
35280      * @category Collection
35281      * @param {Array|Object} collection The collection to iterate over.
35282      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35283      * @returns {Array|Object} Returns `collection`.
35284      * @see _.forEachRight
35285      * @example
35286      *
35287      * _.forEach([1, 2], function(value) {
35288      *   console.log(value);
35289      * });
35290      * // => Logs `1` then `2`.
35291      *
35292      * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
35293      *   console.log(key);
35294      * });
35295      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
35296      */
35297     function forEach(collection, iteratee) {
35298       var func = isArray(collection) ? arrayEach : baseEach;
35299       return func(collection, getIteratee(iteratee, 3));
35300     }
35301
35302     /**
35303      * This method is like `_.forEach` except that it iterates over elements of
35304      * `collection` from right to left.
35305      *
35306      * @static
35307      * @memberOf _
35308      * @since 2.0.0
35309      * @alias eachRight
35310      * @category Collection
35311      * @param {Array|Object} collection The collection to iterate over.
35312      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35313      * @returns {Array|Object} Returns `collection`.
35314      * @see _.forEach
35315      * @example
35316      *
35317      * _.forEachRight([1, 2], function(value) {
35318      *   console.log(value);
35319      * });
35320      * // => Logs `2` then `1`.
35321      */
35322     function forEachRight(collection, iteratee) {
35323       var func = isArray(collection) ? arrayEachRight : baseEachRight;
35324       return func(collection, getIteratee(iteratee, 3));
35325     }
35326
35327     /**
35328      * Creates an object composed of keys generated from the results of running
35329      * each element of `collection` thru `iteratee`. The order of grouped values
35330      * is determined by the order they occur in `collection`. The corresponding
35331      * value of each key is an array of elements responsible for generating the
35332      * key. The iteratee is invoked with one argument: (value).
35333      *
35334      * @static
35335      * @memberOf _
35336      * @since 0.1.0
35337      * @category Collection
35338      * @param {Array|Object} collection The collection to iterate over.
35339      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
35340      * @returns {Object} Returns the composed aggregate object.
35341      * @example
35342      *
35343      * _.groupBy([6.1, 4.2, 6.3], Math.floor);
35344      * // => { '4': [4.2], '6': [6.1, 6.3] }
35345      *
35346      * // The `_.property` iteratee shorthand.
35347      * _.groupBy(['one', 'two', 'three'], 'length');
35348      * // => { '3': ['one', 'two'], '5': ['three'] }
35349      */
35350     var groupBy = createAggregator(function(result, value, key) {
35351       if (hasOwnProperty.call(result, key)) {
35352         result[key].push(value);
35353       } else {
35354         baseAssignValue(result, key, [value]);
35355       }
35356     });
35357
35358     /**
35359      * Checks if `value` is in `collection`. If `collection` is a string, it's
35360      * checked for a substring of `value`, otherwise
35361      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
35362      * is used for equality comparisons. If `fromIndex` is negative, it's used as
35363      * the offset from the end of `collection`.
35364      *
35365      * @static
35366      * @memberOf _
35367      * @since 0.1.0
35368      * @category Collection
35369      * @param {Array|Object|string} collection The collection to inspect.
35370      * @param {*} value The value to search for.
35371      * @param {number} [fromIndex=0] The index to search from.
35372      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
35373      * @returns {boolean} Returns `true` if `value` is found, else `false`.
35374      * @example
35375      *
35376      * _.includes([1, 2, 3], 1);
35377      * // => true
35378      *
35379      * _.includes([1, 2, 3], 1, 2);
35380      * // => false
35381      *
35382      * _.includes({ 'a': 1, 'b': 2 }, 1);
35383      * // => true
35384      *
35385      * _.includes('abcd', 'bc');
35386      * // => true
35387      */
35388     function includes(collection, value, fromIndex, guard) {
35389       collection = isArrayLike(collection) ? collection : values(collection);
35390       fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
35391
35392       var length = collection.length;
35393       if (fromIndex < 0) {
35394         fromIndex = nativeMax(length + fromIndex, 0);
35395       }
35396       return isString(collection)
35397         ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
35398         : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
35399     }
35400
35401     /**
35402      * Invokes the method at `path` of each element in `collection`, returning
35403      * an array of the results of each invoked method. Any additional arguments
35404      * are provided to each invoked method. If `path` is a function, it's invoked
35405      * for, and `this` bound to, each element in `collection`.
35406      *
35407      * @static
35408      * @memberOf _
35409      * @since 4.0.0
35410      * @category Collection
35411      * @param {Array|Object} collection The collection to iterate over.
35412      * @param {Array|Function|string} path The path of the method to invoke or
35413      *  the function invoked per iteration.
35414      * @param {...*} [args] The arguments to invoke each method with.
35415      * @returns {Array} Returns the array of results.
35416      * @example
35417      *
35418      * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
35419      * // => [[1, 5, 7], [1, 2, 3]]
35420      *
35421      * _.invokeMap([123, 456], String.prototype.split, '');
35422      * // => [['1', '2', '3'], ['4', '5', '6']]
35423      */
35424     var invokeMap = baseRest(function(collection, path, args) {
35425       var index = -1,
35426           isFunc = typeof path == 'function',
35427           result = isArrayLike(collection) ? Array(collection.length) : [];
35428
35429       baseEach(collection, function(value) {
35430         result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
35431       });
35432       return result;
35433     });
35434
35435     /**
35436      * Creates an object composed of keys generated from the results of running
35437      * each element of `collection` thru `iteratee`. The corresponding value of
35438      * each key is the last element responsible for generating the key. The
35439      * iteratee is invoked with one argument: (value).
35440      *
35441      * @static
35442      * @memberOf _
35443      * @since 4.0.0
35444      * @category Collection
35445      * @param {Array|Object} collection The collection to iterate over.
35446      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
35447      * @returns {Object} Returns the composed aggregate object.
35448      * @example
35449      *
35450      * var array = [
35451      *   { 'dir': 'left', 'code': 97 },
35452      *   { 'dir': 'right', 'code': 100 }
35453      * ];
35454      *
35455      * _.keyBy(array, function(o) {
35456      *   return String.fromCharCode(o.code);
35457      * });
35458      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
35459      *
35460      * _.keyBy(array, 'dir');
35461      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
35462      */
35463     var keyBy = createAggregator(function(result, value, key) {
35464       baseAssignValue(result, key, value);
35465     });
35466
35467     /**
35468      * Creates an array of values by running each element in `collection` thru
35469      * `iteratee`. The iteratee is invoked with three arguments:
35470      * (value, index|key, collection).
35471      *
35472      * Many lodash methods are guarded to work as iteratees for methods like
35473      * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
35474      *
35475      * The guarded methods are:
35476      * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
35477      * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
35478      * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
35479      * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
35480      *
35481      * @static
35482      * @memberOf _
35483      * @since 0.1.0
35484      * @category Collection
35485      * @param {Array|Object} collection The collection to iterate over.
35486      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35487      * @returns {Array} Returns the new mapped array.
35488      * @example
35489      *
35490      * function square(n) {
35491      *   return n * n;
35492      * }
35493      *
35494      * _.map([4, 8], square);
35495      * // => [16, 64]
35496      *
35497      * _.map({ 'a': 4, 'b': 8 }, square);
35498      * // => [16, 64] (iteration order is not guaranteed)
35499      *
35500      * var users = [
35501      *   { 'user': 'barney' },
35502      *   { 'user': 'fred' }
35503      * ];
35504      *
35505      * // The `_.property` iteratee shorthand.
35506      * _.map(users, 'user');
35507      * // => ['barney', 'fred']
35508      */
35509     function map(collection, iteratee) {
35510       var func = isArray(collection) ? arrayMap : baseMap;
35511       return func(collection, getIteratee(iteratee, 3));
35512     }
35513
35514     /**
35515      * This method is like `_.sortBy` except that it allows specifying the sort
35516      * orders of the iteratees to sort by. If `orders` is unspecified, all values
35517      * are sorted in ascending order. Otherwise, specify an order of "desc" for
35518      * descending or "asc" for ascending sort order of corresponding values.
35519      *
35520      * @static
35521      * @memberOf _
35522      * @since 4.0.0
35523      * @category Collection
35524      * @param {Array|Object} collection The collection to iterate over.
35525      * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
35526      *  The iteratees to sort by.
35527      * @param {string[]} [orders] The sort orders of `iteratees`.
35528      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
35529      * @returns {Array} Returns the new sorted array.
35530      * @example
35531      *
35532      * var users = [
35533      *   { 'user': 'fred',   'age': 48 },
35534      *   { 'user': 'barney', 'age': 34 },
35535      *   { 'user': 'fred',   'age': 40 },
35536      *   { 'user': 'barney', 'age': 36 }
35537      * ];
35538      *
35539      * // Sort by `user` in ascending order and by `age` in descending order.
35540      * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
35541      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
35542      */
35543     function orderBy(collection, iteratees, orders, guard) {
35544       if (collection == null) {
35545         return [];
35546       }
35547       if (!isArray(iteratees)) {
35548         iteratees = iteratees == null ? [] : [iteratees];
35549       }
35550       orders = guard ? undefined : orders;
35551       if (!isArray(orders)) {
35552         orders = orders == null ? [] : [orders];
35553       }
35554       return baseOrderBy(collection, iteratees, orders);
35555     }
35556
35557     /**
35558      * Creates an array of elements split into two groups, the first of which
35559      * contains elements `predicate` returns truthy for, the second of which
35560      * contains elements `predicate` returns falsey for. The predicate is
35561      * invoked with one argument: (value).
35562      *
35563      * @static
35564      * @memberOf _
35565      * @since 3.0.0
35566      * @category Collection
35567      * @param {Array|Object} collection The collection to iterate over.
35568      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35569      * @returns {Array} Returns the array of grouped elements.
35570      * @example
35571      *
35572      * var users = [
35573      *   { 'user': 'barney',  'age': 36, 'active': false },
35574      *   { 'user': 'fred',    'age': 40, 'active': true },
35575      *   { 'user': 'pebbles', 'age': 1,  'active': false }
35576      * ];
35577      *
35578      * _.partition(users, function(o) { return o.active; });
35579      * // => objects for [['fred'], ['barney', 'pebbles']]
35580      *
35581      * // The `_.matches` iteratee shorthand.
35582      * _.partition(users, { 'age': 1, 'active': false });
35583      * // => objects for [['pebbles'], ['barney', 'fred']]
35584      *
35585      * // The `_.matchesProperty` iteratee shorthand.
35586      * _.partition(users, ['active', false]);
35587      * // => objects for [['barney', 'pebbles'], ['fred']]
35588      *
35589      * // The `_.property` iteratee shorthand.
35590      * _.partition(users, 'active');
35591      * // => objects for [['fred'], ['barney', 'pebbles']]
35592      */
35593     var partition = createAggregator(function(result, value, key) {
35594       result[key ? 0 : 1].push(value);
35595     }, function() { return [[], []]; });
35596
35597     /**
35598      * Reduces `collection` to a value which is the accumulated result of running
35599      * each element in `collection` thru `iteratee`, where each successive
35600      * invocation is supplied the return value of the previous. If `accumulator`
35601      * is not given, the first element of `collection` is used as the initial
35602      * value. The iteratee is invoked with four arguments:
35603      * (accumulator, value, index|key, collection).
35604      *
35605      * Many lodash methods are guarded to work as iteratees for methods like
35606      * `_.reduce`, `_.reduceRight`, and `_.transform`.
35607      *
35608      * The guarded methods are:
35609      * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
35610      * and `sortBy`
35611      *
35612      * @static
35613      * @memberOf _
35614      * @since 0.1.0
35615      * @category Collection
35616      * @param {Array|Object} collection The collection to iterate over.
35617      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35618      * @param {*} [accumulator] The initial value.
35619      * @returns {*} Returns the accumulated value.
35620      * @see _.reduceRight
35621      * @example
35622      *
35623      * _.reduce([1, 2], function(sum, n) {
35624      *   return sum + n;
35625      * }, 0);
35626      * // => 3
35627      *
35628      * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
35629      *   (result[value] || (result[value] = [])).push(key);
35630      *   return result;
35631      * }, {});
35632      * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
35633      */
35634     function reduce(collection, iteratee, accumulator) {
35635       var func = isArray(collection) ? arrayReduce : baseReduce,
35636           initAccum = arguments.length < 3;
35637
35638       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
35639     }
35640
35641     /**
35642      * This method is like `_.reduce` except that it iterates over elements of
35643      * `collection` from right to left.
35644      *
35645      * @static
35646      * @memberOf _
35647      * @since 0.1.0
35648      * @category Collection
35649      * @param {Array|Object} collection The collection to iterate over.
35650      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35651      * @param {*} [accumulator] The initial value.
35652      * @returns {*} Returns the accumulated value.
35653      * @see _.reduce
35654      * @example
35655      *
35656      * var array = [[0, 1], [2, 3], [4, 5]];
35657      *
35658      * _.reduceRight(array, function(flattened, other) {
35659      *   return flattened.concat(other);
35660      * }, []);
35661      * // => [4, 5, 2, 3, 0, 1]
35662      */
35663     function reduceRight(collection, iteratee, accumulator) {
35664       var func = isArray(collection) ? arrayReduceRight : baseReduce,
35665           initAccum = arguments.length < 3;
35666
35667       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
35668     }
35669
35670     /**
35671      * The opposite of `_.filter`; this method returns the elements of `collection`
35672      * that `predicate` does **not** return truthy for.
35673      *
35674      * @static
35675      * @memberOf _
35676      * @since 0.1.0
35677      * @category Collection
35678      * @param {Array|Object} collection The collection to iterate over.
35679      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35680      * @returns {Array} Returns the new filtered array.
35681      * @see _.filter
35682      * @example
35683      *
35684      * var users = [
35685      *   { 'user': 'barney', 'age': 36, 'active': false },
35686      *   { 'user': 'fred',   'age': 40, 'active': true }
35687      * ];
35688      *
35689      * _.reject(users, function(o) { return !o.active; });
35690      * // => objects for ['fred']
35691      *
35692      * // The `_.matches` iteratee shorthand.
35693      * _.reject(users, { 'age': 40, 'active': true });
35694      * // => objects for ['barney']
35695      *
35696      * // The `_.matchesProperty` iteratee shorthand.
35697      * _.reject(users, ['active', false]);
35698      * // => objects for ['fred']
35699      *
35700      * // The `_.property` iteratee shorthand.
35701      * _.reject(users, 'active');
35702      * // => objects for ['barney']
35703      */
35704     function reject(collection, predicate) {
35705       var func = isArray(collection) ? arrayFilter : baseFilter;
35706       return func(collection, negate(getIteratee(predicate, 3)));
35707     }
35708
35709     /**
35710      * Gets a random element from `collection`.
35711      *
35712      * @static
35713      * @memberOf _
35714      * @since 2.0.0
35715      * @category Collection
35716      * @param {Array|Object} collection The collection to sample.
35717      * @returns {*} Returns the random element.
35718      * @example
35719      *
35720      * _.sample([1, 2, 3, 4]);
35721      * // => 2
35722      */
35723     function sample(collection) {
35724       var func = isArray(collection) ? arraySample : baseSample;
35725       return func(collection);
35726     }
35727
35728     /**
35729      * Gets `n` random elements at unique keys from `collection` up to the
35730      * size of `collection`.
35731      *
35732      * @static
35733      * @memberOf _
35734      * @since 4.0.0
35735      * @category Collection
35736      * @param {Array|Object} collection The collection to sample.
35737      * @param {number} [n=1] The number of elements to sample.
35738      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35739      * @returns {Array} Returns the random elements.
35740      * @example
35741      *
35742      * _.sampleSize([1, 2, 3], 2);
35743      * // => [3, 1]
35744      *
35745      * _.sampleSize([1, 2, 3], 4);
35746      * // => [2, 3, 1]
35747      */
35748     function sampleSize(collection, n, guard) {
35749       if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
35750         n = 1;
35751       } else {
35752         n = toInteger(n);
35753       }
35754       var func = isArray(collection) ? arraySampleSize : baseSampleSize;
35755       return func(collection, n);
35756     }
35757
35758     /**
35759      * Creates an array of shuffled values, using a version of the
35760      * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
35761      *
35762      * @static
35763      * @memberOf _
35764      * @since 0.1.0
35765      * @category Collection
35766      * @param {Array|Object} collection The collection to shuffle.
35767      * @returns {Array} Returns the new shuffled array.
35768      * @example
35769      *
35770      * _.shuffle([1, 2, 3, 4]);
35771      * // => [4, 1, 3, 2]
35772      */
35773     function shuffle(collection) {
35774       var func = isArray(collection) ? arrayShuffle : baseShuffle;
35775       return func(collection);
35776     }
35777
35778     /**
35779      * Gets the size of `collection` by returning its length for array-like
35780      * values or the number of own enumerable string keyed properties for objects.
35781      *
35782      * @static
35783      * @memberOf _
35784      * @since 0.1.0
35785      * @category Collection
35786      * @param {Array|Object|string} collection The collection to inspect.
35787      * @returns {number} Returns the collection size.
35788      * @example
35789      *
35790      * _.size([1, 2, 3]);
35791      * // => 3
35792      *
35793      * _.size({ 'a': 1, 'b': 2 });
35794      * // => 2
35795      *
35796      * _.size('pebbles');
35797      * // => 7
35798      */
35799     function size(collection) {
35800       if (collection == null) {
35801         return 0;
35802       }
35803       if (isArrayLike(collection)) {
35804         return isString(collection) ? stringSize(collection) : collection.length;
35805       }
35806       var tag = getTag(collection);
35807       if (tag == mapTag || tag == setTag) {
35808         return collection.size;
35809       }
35810       return baseKeys(collection).length;
35811     }
35812
35813     /**
35814      * Checks if `predicate` returns truthy for **any** element of `collection`.
35815      * Iteration is stopped once `predicate` returns truthy. The predicate is
35816      * invoked with three arguments: (value, index|key, collection).
35817      *
35818      * @static
35819      * @memberOf _
35820      * @since 0.1.0
35821      * @category Collection
35822      * @param {Array|Object} collection The collection to iterate over.
35823      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35824      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35825      * @returns {boolean} Returns `true` if any element passes the predicate check,
35826      *  else `false`.
35827      * @example
35828      *
35829      * _.some([null, 0, 'yes', false], Boolean);
35830      * // => true
35831      *
35832      * var users = [
35833      *   { 'user': 'barney', 'active': true },
35834      *   { 'user': 'fred',   'active': false }
35835      * ];
35836      *
35837      * // The `_.matches` iteratee shorthand.
35838      * _.some(users, { 'user': 'barney', 'active': false });
35839      * // => false
35840      *
35841      * // The `_.matchesProperty` iteratee shorthand.
35842      * _.some(users, ['active', false]);
35843      * // => true
35844      *
35845      * // The `_.property` iteratee shorthand.
35846      * _.some(users, 'active');
35847      * // => true
35848      */
35849     function some(collection, predicate, guard) {
35850       var func = isArray(collection) ? arraySome : baseSome;
35851       if (guard && isIterateeCall(collection, predicate, guard)) {
35852         predicate = undefined;
35853       }
35854       return func(collection, getIteratee(predicate, 3));
35855     }
35856
35857     /**
35858      * Creates an array of elements, sorted in ascending order by the results of
35859      * running each element in a collection thru each iteratee. This method
35860      * performs a stable sort, that is, it preserves the original sort order of
35861      * equal elements. The iteratees are invoked with one argument: (value).
35862      *
35863      * @static
35864      * @memberOf _
35865      * @since 0.1.0
35866      * @category Collection
35867      * @param {Array|Object} collection The collection to iterate over.
35868      * @param {...(Function|Function[])} [iteratees=[_.identity]]
35869      *  The iteratees to sort by.
35870      * @returns {Array} Returns the new sorted array.
35871      * @example
35872      *
35873      * var users = [
35874      *   { 'user': 'fred',   'age': 48 },
35875      *   { 'user': 'barney', 'age': 36 },
35876      *   { 'user': 'fred',   'age': 40 },
35877      *   { 'user': 'barney', 'age': 34 }
35878      * ];
35879      *
35880      * _.sortBy(users, [function(o) { return o.user; }]);
35881      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
35882      *
35883      * _.sortBy(users, ['user', 'age']);
35884      * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
35885      */
35886     var sortBy = baseRest(function(collection, iteratees) {
35887       if (collection == null) {
35888         return [];
35889       }
35890       var length = iteratees.length;
35891       if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
35892         iteratees = [];
35893       } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
35894         iteratees = [iteratees[0]];
35895       }
35896       return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
35897     });
35898
35899     /*------------------------------------------------------------------------*/
35900
35901     /**
35902      * Gets the timestamp of the number of milliseconds that have elapsed since
35903      * the Unix epoch (1 January 1970 00:00:00 UTC).
35904      *
35905      * @static
35906      * @memberOf _
35907      * @since 2.4.0
35908      * @category Date
35909      * @returns {number} Returns the timestamp.
35910      * @example
35911      *
35912      * _.defer(function(stamp) {
35913      *   console.log(_.now() - stamp);
35914      * }, _.now());
35915      * // => Logs the number of milliseconds it took for the deferred invocation.
35916      */
35917     var now = ctxNow || function() {
35918       return root.Date.now();
35919     };
35920
35921     /*------------------------------------------------------------------------*/
35922
35923     /**
35924      * The opposite of `_.before`; this method creates a function that invokes
35925      * `func` once it's called `n` or more times.
35926      *
35927      * @static
35928      * @memberOf _
35929      * @since 0.1.0
35930      * @category Function
35931      * @param {number} n The number of calls before `func` is invoked.
35932      * @param {Function} func The function to restrict.
35933      * @returns {Function} Returns the new restricted function.
35934      * @example
35935      *
35936      * var saves = ['profile', 'settings'];
35937      *
35938      * var done = _.after(saves.length, function() {
35939      *   console.log('done saving!');
35940      * });
35941      *
35942      * _.forEach(saves, function(type) {
35943      *   asyncSave({ 'type': type, 'complete': done });
35944      * });
35945      * // => Logs 'done saving!' after the two async saves have completed.
35946      */
35947     function after(n, func) {
35948       if (typeof func != 'function') {
35949         throw new TypeError(FUNC_ERROR_TEXT);
35950       }
35951       n = toInteger(n);
35952       return function() {
35953         if (--n < 1) {
35954           return func.apply(this, arguments);
35955         }
35956       };
35957     }
35958
35959     /**
35960      * Creates a function that invokes `func`, with up to `n` arguments,
35961      * ignoring any additional arguments.
35962      *
35963      * @static
35964      * @memberOf _
35965      * @since 3.0.0
35966      * @category Function
35967      * @param {Function} func The function to cap arguments for.
35968      * @param {number} [n=func.length] The arity cap.
35969      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35970      * @returns {Function} Returns the new capped function.
35971      * @example
35972      *
35973      * _.map(['6', '8', '10'], _.ary(parseInt, 1));
35974      * // => [6, 8, 10]
35975      */
35976     function ary(func, n, guard) {
35977       n = guard ? undefined : n;
35978       n = (func && n == null) ? func.length : n;
35979       return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
35980     }
35981
35982     /**
35983      * Creates a function that invokes `func`, with the `this` binding and arguments
35984      * of the created function, while it's called less than `n` times. Subsequent
35985      * calls to the created function return the result of the last `func` invocation.
35986      *
35987      * @static
35988      * @memberOf _
35989      * @since 3.0.0
35990      * @category Function
35991      * @param {number} n The number of calls at which `func` is no longer invoked.
35992      * @param {Function} func The function to restrict.
35993      * @returns {Function} Returns the new restricted function.
35994      * @example
35995      *
35996      * jQuery(element).on('click', _.before(5, addContactToList));
35997      * // => Allows adding up to 4 contacts to the list.
35998      */
35999     function before(n, func) {
36000       var result;
36001       if (typeof func != 'function') {
36002         throw new TypeError(FUNC_ERROR_TEXT);
36003       }
36004       n = toInteger(n);
36005       return function() {
36006         if (--n > 0) {
36007           result = func.apply(this, arguments);
36008         }
36009         if (n <= 1) {
36010           func = undefined;
36011         }
36012         return result;
36013       };
36014     }
36015
36016     /**
36017      * Creates a function that invokes `func` with the `this` binding of `thisArg`
36018      * and `partials` prepended to the arguments it receives.
36019      *
36020      * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
36021      * may be used as a placeholder for partially applied arguments.
36022      *
36023      * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
36024      * property of bound functions.
36025      *
36026      * @static
36027      * @memberOf _
36028      * @since 0.1.0
36029      * @category Function
36030      * @param {Function} func The function to bind.
36031      * @param {*} thisArg The `this` binding of `func`.
36032      * @param {...*} [partials] The arguments to be partially applied.
36033      * @returns {Function} Returns the new bound function.
36034      * @example
36035      *
36036      * function greet(greeting, punctuation) {
36037      *   return greeting + ' ' + this.user + punctuation;
36038      * }
36039      *
36040      * var object = { 'user': 'fred' };
36041      *
36042      * var bound = _.bind(greet, object, 'hi');
36043      * bound('!');
36044      * // => 'hi fred!'
36045      *
36046      * // Bound with placeholders.
36047      * var bound = _.bind(greet, object, _, '!');
36048      * bound('hi');
36049      * // => 'hi fred!'
36050      */
36051     var bind = baseRest(function(func, thisArg, partials) {
36052       var bitmask = WRAP_BIND_FLAG;
36053       if (partials.length) {
36054         var holders = replaceHolders(partials, getHolder(bind));
36055         bitmask |= WRAP_PARTIAL_FLAG;
36056       }
36057       return createWrap(func, bitmask, thisArg, partials, holders);
36058     });
36059
36060     /**
36061      * Creates a function that invokes the method at `object[key]` with `partials`
36062      * prepended to the arguments it receives.
36063      *
36064      * This method differs from `_.bind` by allowing bound functions to reference
36065      * methods that may be redefined or don't yet exist. See
36066      * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
36067      * for more details.
36068      *
36069      * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
36070      * builds, may be used as a placeholder for partially applied arguments.
36071      *
36072      * @static
36073      * @memberOf _
36074      * @since 0.10.0
36075      * @category Function
36076      * @param {Object} object The object to invoke the method on.
36077      * @param {string} key The key of the method.
36078      * @param {...*} [partials] The arguments to be partially applied.
36079      * @returns {Function} Returns the new bound function.
36080      * @example
36081      *
36082      * var object = {
36083      *   'user': 'fred',
36084      *   'greet': function(greeting, punctuation) {
36085      *     return greeting + ' ' + this.user + punctuation;
36086      *   }
36087      * };
36088      *
36089      * var bound = _.bindKey(object, 'greet', 'hi');
36090      * bound('!');
36091      * // => 'hi fred!'
36092      *
36093      * object.greet = function(greeting, punctuation) {
36094      *   return greeting + 'ya ' + this.user + punctuation;
36095      * };
36096      *
36097      * bound('!');
36098      * // => 'hiya fred!'
36099      *
36100      * // Bound with placeholders.
36101      * var bound = _.bindKey(object, 'greet', _, '!');
36102      * bound('hi');
36103      * // => 'hiya fred!'
36104      */
36105     var bindKey = baseRest(function(object, key, partials) {
36106       var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
36107       if (partials.length) {
36108         var holders = replaceHolders(partials, getHolder(bindKey));
36109         bitmask |= WRAP_PARTIAL_FLAG;
36110       }
36111       return createWrap(key, bitmask, object, partials, holders);
36112     });
36113
36114     /**
36115      * Creates a function that accepts arguments of `func` and either invokes
36116      * `func` returning its result, if at least `arity` number of arguments have
36117      * been provided, or returns a function that accepts the remaining `func`
36118      * arguments, and so on. The arity of `func` may be specified if `func.length`
36119      * is not sufficient.
36120      *
36121      * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
36122      * may be used as a placeholder for provided arguments.
36123      *
36124      * **Note:** This method doesn't set the "length" property of curried functions.
36125      *
36126      * @static
36127      * @memberOf _
36128      * @since 2.0.0
36129      * @category Function
36130      * @param {Function} func The function to curry.
36131      * @param {number} [arity=func.length] The arity of `func`.
36132      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36133      * @returns {Function} Returns the new curried function.
36134      * @example
36135      *
36136      * var abc = function(a, b, c) {
36137      *   return [a, b, c];
36138      * };
36139      *
36140      * var curried = _.curry(abc);
36141      *
36142      * curried(1)(2)(3);
36143      * // => [1, 2, 3]
36144      *
36145      * curried(1, 2)(3);
36146      * // => [1, 2, 3]
36147      *
36148      * curried(1, 2, 3);
36149      * // => [1, 2, 3]
36150      *
36151      * // Curried with placeholders.
36152      * curried(1)(_, 3)(2);
36153      * // => [1, 2, 3]
36154      */
36155     function curry(func, arity, guard) {
36156       arity = guard ? undefined : arity;
36157       var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
36158       result.placeholder = curry.placeholder;
36159       return result;
36160     }
36161
36162     /**
36163      * This method is like `_.curry` except that arguments are applied to `func`
36164      * in the manner of `_.partialRight` instead of `_.partial`.
36165      *
36166      * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
36167      * builds, may be used as a placeholder for provided arguments.
36168      *
36169      * **Note:** This method doesn't set the "length" property of curried functions.
36170      *
36171      * @static
36172      * @memberOf _
36173      * @since 3.0.0
36174      * @category Function
36175      * @param {Function} func The function to curry.
36176      * @param {number} [arity=func.length] The arity of `func`.
36177      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36178      * @returns {Function} Returns the new curried function.
36179      * @example
36180      *
36181      * var abc = function(a, b, c) {
36182      *   return [a, b, c];
36183      * };
36184      *
36185      * var curried = _.curryRight(abc);
36186      *
36187      * curried(3)(2)(1);
36188      * // => [1, 2, 3]
36189      *
36190      * curried(2, 3)(1);
36191      * // => [1, 2, 3]
36192      *
36193      * curried(1, 2, 3);
36194      * // => [1, 2, 3]
36195      *
36196      * // Curried with placeholders.
36197      * curried(3)(1, _)(2);
36198      * // => [1, 2, 3]
36199      */
36200     function curryRight(func, arity, guard) {
36201       arity = guard ? undefined : arity;
36202       var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
36203       result.placeholder = curryRight.placeholder;
36204       return result;
36205     }
36206
36207     /**
36208      * Creates a debounced function that delays invoking `func` until after `wait`
36209      * milliseconds have elapsed since the last time the debounced function was
36210      * invoked. The debounced function comes with a `cancel` method to cancel
36211      * delayed `func` invocations and a `flush` method to immediately invoke them.
36212      * Provide `options` to indicate whether `func` should be invoked on the
36213      * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
36214      * with the last arguments provided to the debounced function. Subsequent
36215      * calls to the debounced function return the result of the last `func`
36216      * invocation.
36217      *
36218      * **Note:** If `leading` and `trailing` options are `true`, `func` is
36219      * invoked on the trailing edge of the timeout only if the debounced function
36220      * is invoked more than once during the `wait` timeout.
36221      *
36222      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
36223      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
36224      *
36225      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
36226      * for details over the differences between `_.debounce` and `_.throttle`.
36227      *
36228      * @static
36229      * @memberOf _
36230      * @since 0.1.0
36231      * @category Function
36232      * @param {Function} func The function to debounce.
36233      * @param {number} [wait=0] The number of milliseconds to delay.
36234      * @param {Object} [options={}] The options object.
36235      * @param {boolean} [options.leading=false]
36236      *  Specify invoking on the leading edge of the timeout.
36237      * @param {number} [options.maxWait]
36238      *  The maximum time `func` is allowed to be delayed before it's invoked.
36239      * @param {boolean} [options.trailing=true]
36240      *  Specify invoking on the trailing edge of the timeout.
36241      * @returns {Function} Returns the new debounced function.
36242      * @example
36243      *
36244      * // Avoid costly calculations while the window size is in flux.
36245      * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
36246      *
36247      * // Invoke `sendMail` when clicked, debouncing subsequent calls.
36248      * jQuery(element).on('click', _.debounce(sendMail, 300, {
36249      *   'leading': true,
36250      *   'trailing': false
36251      * }));
36252      *
36253      * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
36254      * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
36255      * var source = new EventSource('/stream');
36256      * jQuery(source).on('message', debounced);
36257      *
36258      * // Cancel the trailing debounced invocation.
36259      * jQuery(window).on('popstate', debounced.cancel);
36260      */
36261     function debounce(func, wait, options) {
36262       var lastArgs,
36263           lastThis,
36264           maxWait,
36265           result,
36266           timerId,
36267           lastCallTime,
36268           lastInvokeTime = 0,
36269           leading = false,
36270           maxing = false,
36271           trailing = true;
36272
36273       if (typeof func != 'function') {
36274         throw new TypeError(FUNC_ERROR_TEXT);
36275       }
36276       wait = toNumber(wait) || 0;
36277       if (isObject(options)) {
36278         leading = !!options.leading;
36279         maxing = 'maxWait' in options;
36280         maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
36281         trailing = 'trailing' in options ? !!options.trailing : trailing;
36282       }
36283
36284       function invokeFunc(time) {
36285         var args = lastArgs,
36286             thisArg = lastThis;
36287
36288         lastArgs = lastThis = undefined;
36289         lastInvokeTime = time;
36290         result = func.apply(thisArg, args);
36291         return result;
36292       }
36293
36294       function leadingEdge(time) {
36295         // Reset any `maxWait` timer.
36296         lastInvokeTime = time;
36297         // Start the timer for the trailing edge.
36298         timerId = setTimeout(timerExpired, wait);
36299         // Invoke the leading edge.
36300         return leading ? invokeFunc(time) : result;
36301       }
36302
36303       function remainingWait(time) {
36304         var timeSinceLastCall = time - lastCallTime,
36305             timeSinceLastInvoke = time - lastInvokeTime,
36306             timeWaiting = wait - timeSinceLastCall;
36307
36308         return maxing
36309           ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
36310           : timeWaiting;
36311       }
36312
36313       function shouldInvoke(time) {
36314         var timeSinceLastCall = time - lastCallTime,
36315             timeSinceLastInvoke = time - lastInvokeTime;
36316
36317         // Either this is the first call, activity has stopped and we're at the
36318         // trailing edge, the system time has gone backwards and we're treating
36319         // it as the trailing edge, or we've hit the `maxWait` limit.
36320         return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
36321           (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
36322       }
36323
36324       function timerExpired() {
36325         var time = now();
36326         if (shouldInvoke(time)) {
36327           return trailingEdge(time);
36328         }
36329         // Restart the timer.
36330         timerId = setTimeout(timerExpired, remainingWait(time));
36331       }
36332
36333       function trailingEdge(time) {
36334         timerId = undefined;
36335
36336         // Only invoke if we have `lastArgs` which means `func` has been
36337         // debounced at least once.
36338         if (trailing && lastArgs) {
36339           return invokeFunc(time);
36340         }
36341         lastArgs = lastThis = undefined;
36342         return result;
36343       }
36344
36345       function cancel() {
36346         if (timerId !== undefined) {
36347           clearTimeout(timerId);
36348         }
36349         lastInvokeTime = 0;
36350         lastArgs = lastCallTime = lastThis = timerId = undefined;
36351       }
36352
36353       function flush() {
36354         return timerId === undefined ? result : trailingEdge(now());
36355       }
36356
36357       function debounced() {
36358         var time = now(),
36359             isInvoking = shouldInvoke(time);
36360
36361         lastArgs = arguments;
36362         lastThis = this;
36363         lastCallTime = time;
36364
36365         if (isInvoking) {
36366           if (timerId === undefined) {
36367             return leadingEdge(lastCallTime);
36368           }
36369           if (maxing) {
36370             // Handle invocations in a tight loop.
36371             clearTimeout(timerId);
36372             timerId = setTimeout(timerExpired, wait);
36373             return invokeFunc(lastCallTime);
36374           }
36375         }
36376         if (timerId === undefined) {
36377           timerId = setTimeout(timerExpired, wait);
36378         }
36379         return result;
36380       }
36381       debounced.cancel = cancel;
36382       debounced.flush = flush;
36383       return debounced;
36384     }
36385
36386     /**
36387      * Defers invoking the `func` until the current call stack has cleared. Any
36388      * additional arguments are provided to `func` when it's invoked.
36389      *
36390      * @static
36391      * @memberOf _
36392      * @since 0.1.0
36393      * @category Function
36394      * @param {Function} func The function to defer.
36395      * @param {...*} [args] The arguments to invoke `func` with.
36396      * @returns {number} Returns the timer id.
36397      * @example
36398      *
36399      * _.defer(function(text) {
36400      *   console.log(text);
36401      * }, 'deferred');
36402      * // => Logs 'deferred' after one millisecond.
36403      */
36404     var defer = baseRest(function(func, args) {
36405       return baseDelay(func, 1, args);
36406     });
36407
36408     /**
36409      * Invokes `func` after `wait` milliseconds. Any additional arguments are
36410      * provided to `func` when it's invoked.
36411      *
36412      * @static
36413      * @memberOf _
36414      * @since 0.1.0
36415      * @category Function
36416      * @param {Function} func The function to delay.
36417      * @param {number} wait The number of milliseconds to delay invocation.
36418      * @param {...*} [args] The arguments to invoke `func` with.
36419      * @returns {number} Returns the timer id.
36420      * @example
36421      *
36422      * _.delay(function(text) {
36423      *   console.log(text);
36424      * }, 1000, 'later');
36425      * // => Logs 'later' after one second.
36426      */
36427     var delay = baseRest(function(func, wait, args) {
36428       return baseDelay(func, toNumber(wait) || 0, args);
36429     });
36430
36431     /**
36432      * Creates a function that invokes `func` with arguments reversed.
36433      *
36434      * @static
36435      * @memberOf _
36436      * @since 4.0.0
36437      * @category Function
36438      * @param {Function} func The function to flip arguments for.
36439      * @returns {Function} Returns the new flipped function.
36440      * @example
36441      *
36442      * var flipped = _.flip(function() {
36443      *   return _.toArray(arguments);
36444      * });
36445      *
36446      * flipped('a', 'b', 'c', 'd');
36447      * // => ['d', 'c', 'b', 'a']
36448      */
36449     function flip(func) {
36450       return createWrap(func, WRAP_FLIP_FLAG);
36451     }
36452
36453     /**
36454      * Creates a function that memoizes the result of `func`. If `resolver` is
36455      * provided, it determines the cache key for storing the result based on the
36456      * arguments provided to the memoized function. By default, the first argument
36457      * provided to the memoized function is used as the map cache key. The `func`
36458      * is invoked with the `this` binding of the memoized function.
36459      *
36460      * **Note:** The cache is exposed as the `cache` property on the memoized
36461      * function. Its creation may be customized by replacing the `_.memoize.Cache`
36462      * constructor with one whose instances implement the
36463      * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
36464      * method interface of `clear`, `delete`, `get`, `has`, and `set`.
36465      *
36466      * @static
36467      * @memberOf _
36468      * @since 0.1.0
36469      * @category Function
36470      * @param {Function} func The function to have its output memoized.
36471      * @param {Function} [resolver] The function to resolve the cache key.
36472      * @returns {Function} Returns the new memoized function.
36473      * @example
36474      *
36475      * var object = { 'a': 1, 'b': 2 };
36476      * var other = { 'c': 3, 'd': 4 };
36477      *
36478      * var values = _.memoize(_.values);
36479      * values(object);
36480      * // => [1, 2]
36481      *
36482      * values(other);
36483      * // => [3, 4]
36484      *
36485      * object.a = 2;
36486      * values(object);
36487      * // => [1, 2]
36488      *
36489      * // Modify the result cache.
36490      * values.cache.set(object, ['a', 'b']);
36491      * values(object);
36492      * // => ['a', 'b']
36493      *
36494      * // Replace `_.memoize.Cache`.
36495      * _.memoize.Cache = WeakMap;
36496      */
36497     function memoize(func, resolver) {
36498       if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
36499         throw new TypeError(FUNC_ERROR_TEXT);
36500       }
36501       var memoized = function() {
36502         var args = arguments,
36503             key = resolver ? resolver.apply(this, args) : args[0],
36504             cache = memoized.cache;
36505
36506         if (cache.has(key)) {
36507           return cache.get(key);
36508         }
36509         var result = func.apply(this, args);
36510         memoized.cache = cache.set(key, result) || cache;
36511         return result;
36512       };
36513       memoized.cache = new (memoize.Cache || MapCache);
36514       return memoized;
36515     }
36516
36517     // Expose `MapCache`.
36518     memoize.Cache = MapCache;
36519
36520     /**
36521      * Creates a function that negates the result of the predicate `func`. The
36522      * `func` predicate is invoked with the `this` binding and arguments of the
36523      * created function.
36524      *
36525      * @static
36526      * @memberOf _
36527      * @since 3.0.0
36528      * @category Function
36529      * @param {Function} predicate The predicate to negate.
36530      * @returns {Function} Returns the new negated function.
36531      * @example
36532      *
36533      * function isEven(n) {
36534      *   return n % 2 == 0;
36535      * }
36536      *
36537      * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
36538      * // => [1, 3, 5]
36539      */
36540     function negate(predicate) {
36541       if (typeof predicate != 'function') {
36542         throw new TypeError(FUNC_ERROR_TEXT);
36543       }
36544       return function() {
36545         var args = arguments;
36546         switch (args.length) {
36547           case 0: return !predicate.call(this);
36548           case 1: return !predicate.call(this, args[0]);
36549           case 2: return !predicate.call(this, args[0], args[1]);
36550           case 3: return !predicate.call(this, args[0], args[1], args[2]);
36551         }
36552         return !predicate.apply(this, args);
36553       };
36554     }
36555
36556     /**
36557      * Creates a function that is restricted to invoking `func` once. Repeat calls
36558      * to the function return the value of the first invocation. The `func` is
36559      * invoked with the `this` binding and arguments of the created function.
36560      *
36561      * @static
36562      * @memberOf _
36563      * @since 0.1.0
36564      * @category Function
36565      * @param {Function} func The function to restrict.
36566      * @returns {Function} Returns the new restricted function.
36567      * @example
36568      *
36569      * var initialize = _.once(createApplication);
36570      * initialize();
36571      * initialize();
36572      * // => `createApplication` is invoked once
36573      */
36574     function once(func) {
36575       return before(2, func);
36576     }
36577
36578     /**
36579      * Creates a function that invokes `func` with its arguments transformed.
36580      *
36581      * @static
36582      * @since 4.0.0
36583      * @memberOf _
36584      * @category Function
36585      * @param {Function} func The function to wrap.
36586      * @param {...(Function|Function[])} [transforms=[_.identity]]
36587      *  The argument transforms.
36588      * @returns {Function} Returns the new function.
36589      * @example
36590      *
36591      * function doubled(n) {
36592      *   return n * 2;
36593      * }
36594      *
36595      * function square(n) {
36596      *   return n * n;
36597      * }
36598      *
36599      * var func = _.overArgs(function(x, y) {
36600      *   return [x, y];
36601      * }, [square, doubled]);
36602      *
36603      * func(9, 3);
36604      * // => [81, 6]
36605      *
36606      * func(10, 5);
36607      * // => [100, 10]
36608      */
36609     var overArgs = castRest(function(func, transforms) {
36610       transforms = (transforms.length == 1 && isArray(transforms[0]))
36611         ? arrayMap(transforms[0], baseUnary(getIteratee()))
36612         : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
36613
36614       var funcsLength = transforms.length;
36615       return baseRest(function(args) {
36616         var index = -1,
36617             length = nativeMin(args.length, funcsLength);
36618
36619         while (++index < length) {
36620           args[index] = transforms[index].call(this, args[index]);
36621         }
36622         return apply(func, this, args);
36623       });
36624     });
36625
36626     /**
36627      * Creates a function that invokes `func` with `partials` prepended to the
36628      * arguments it receives. This method is like `_.bind` except it does **not**
36629      * alter the `this` binding.
36630      *
36631      * The `_.partial.placeholder` value, which defaults to `_` in monolithic
36632      * builds, may be used as a placeholder for partially applied arguments.
36633      *
36634      * **Note:** This method doesn't set the "length" property of partially
36635      * applied functions.
36636      *
36637      * @static
36638      * @memberOf _
36639      * @since 0.2.0
36640      * @category Function
36641      * @param {Function} func The function to partially apply arguments to.
36642      * @param {...*} [partials] The arguments to be partially applied.
36643      * @returns {Function} Returns the new partially applied function.
36644      * @example
36645      *
36646      * function greet(greeting, name) {
36647      *   return greeting + ' ' + name;
36648      * }
36649      *
36650      * var sayHelloTo = _.partial(greet, 'hello');
36651      * sayHelloTo('fred');
36652      * // => 'hello fred'
36653      *
36654      * // Partially applied with placeholders.
36655      * var greetFred = _.partial(greet, _, 'fred');
36656      * greetFred('hi');
36657      * // => 'hi fred'
36658      */
36659     var partial = baseRest(function(func, partials) {
36660       var holders = replaceHolders(partials, getHolder(partial));
36661       return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
36662     });
36663
36664     /**
36665      * This method is like `_.partial` except that partially applied arguments
36666      * are appended to the arguments it receives.
36667      *
36668      * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
36669      * builds, may be used as a placeholder for partially applied arguments.
36670      *
36671      * **Note:** This method doesn't set the "length" property of partially
36672      * applied functions.
36673      *
36674      * @static
36675      * @memberOf _
36676      * @since 1.0.0
36677      * @category Function
36678      * @param {Function} func The function to partially apply arguments to.
36679      * @param {...*} [partials] The arguments to be partially applied.
36680      * @returns {Function} Returns the new partially applied function.
36681      * @example
36682      *
36683      * function greet(greeting, name) {
36684      *   return greeting + ' ' + name;
36685      * }
36686      *
36687      * var greetFred = _.partialRight(greet, 'fred');
36688      * greetFred('hi');
36689      * // => 'hi fred'
36690      *
36691      * // Partially applied with placeholders.
36692      * var sayHelloTo = _.partialRight(greet, 'hello', _);
36693      * sayHelloTo('fred');
36694      * // => 'hello fred'
36695      */
36696     var partialRight = baseRest(function(func, partials) {
36697       var holders = replaceHolders(partials, getHolder(partialRight));
36698       return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
36699     });
36700
36701     /**
36702      * Creates a function that invokes `func` with arguments arranged according
36703      * to the specified `indexes` where the argument value at the first index is
36704      * provided as the first argument, the argument value at the second index is
36705      * provided as the second argument, and so on.
36706      *
36707      * @static
36708      * @memberOf _
36709      * @since 3.0.0
36710      * @category Function
36711      * @param {Function} func The function to rearrange arguments for.
36712      * @param {...(number|number[])} indexes The arranged argument indexes.
36713      * @returns {Function} Returns the new function.
36714      * @example
36715      *
36716      * var rearged = _.rearg(function(a, b, c) {
36717      *   return [a, b, c];
36718      * }, [2, 0, 1]);
36719      *
36720      * rearged('b', 'c', 'a')
36721      * // => ['a', 'b', 'c']
36722      */
36723     var rearg = flatRest(function(func, indexes) {
36724       return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
36725     });
36726
36727     /**
36728      * Creates a function that invokes `func` with the `this` binding of the
36729      * created function and arguments from `start` and beyond provided as
36730      * an array.
36731      *
36732      * **Note:** This method is based on the
36733      * [rest parameter](https://mdn.io/rest_parameters).
36734      *
36735      * @static
36736      * @memberOf _
36737      * @since 4.0.0
36738      * @category Function
36739      * @param {Function} func The function to apply a rest parameter to.
36740      * @param {number} [start=func.length-1] The start position of the rest parameter.
36741      * @returns {Function} Returns the new function.
36742      * @example
36743      *
36744      * var say = _.rest(function(what, names) {
36745      *   return what + ' ' + _.initial(names).join(', ') +
36746      *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
36747      * });
36748      *
36749      * say('hello', 'fred', 'barney', 'pebbles');
36750      * // => 'hello fred, barney, & pebbles'
36751      */
36752     function rest(func, start) {
36753       if (typeof func != 'function') {
36754         throw new TypeError(FUNC_ERROR_TEXT);
36755       }
36756       start = start === undefined ? start : toInteger(start);
36757       return baseRest(func, start);
36758     }
36759
36760     /**
36761      * Creates a function that invokes `func` with the `this` binding of the
36762      * create function and an array of arguments much like
36763      * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
36764      *
36765      * **Note:** This method is based on the
36766      * [spread operator](https://mdn.io/spread_operator).
36767      *
36768      * @static
36769      * @memberOf _
36770      * @since 3.2.0
36771      * @category Function
36772      * @param {Function} func The function to spread arguments over.
36773      * @param {number} [start=0] The start position of the spread.
36774      * @returns {Function} Returns the new function.
36775      * @example
36776      *
36777      * var say = _.spread(function(who, what) {
36778      *   return who + ' says ' + what;
36779      * });
36780      *
36781      * say(['fred', 'hello']);
36782      * // => 'fred says hello'
36783      *
36784      * var numbers = Promise.all([
36785      *   Promise.resolve(40),
36786      *   Promise.resolve(36)
36787      * ]);
36788      *
36789      * numbers.then(_.spread(function(x, y) {
36790      *   return x + y;
36791      * }));
36792      * // => a Promise of 76
36793      */
36794     function spread(func, start) {
36795       if (typeof func != 'function') {
36796         throw new TypeError(FUNC_ERROR_TEXT);
36797       }
36798       start = start == null ? 0 : nativeMax(toInteger(start), 0);
36799       return baseRest(function(args) {
36800         var array = args[start],
36801             otherArgs = castSlice(args, 0, start);
36802
36803         if (array) {
36804           arrayPush(otherArgs, array);
36805         }
36806         return apply(func, this, otherArgs);
36807       });
36808     }
36809
36810     /**
36811      * Creates a throttled function that only invokes `func` at most once per
36812      * every `wait` milliseconds. The throttled function comes with a `cancel`
36813      * method to cancel delayed `func` invocations and a `flush` method to
36814      * immediately invoke them. Provide `options` to indicate whether `func`
36815      * should be invoked on the leading and/or trailing edge of the `wait`
36816      * timeout. The `func` is invoked with the last arguments provided to the
36817      * throttled function. Subsequent calls to the throttled function return the
36818      * result of the last `func` invocation.
36819      *
36820      * **Note:** If `leading` and `trailing` options are `true`, `func` is
36821      * invoked on the trailing edge of the timeout only if the throttled function
36822      * is invoked more than once during the `wait` timeout.
36823      *
36824      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
36825      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
36826      *
36827      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
36828      * for details over the differences between `_.throttle` and `_.debounce`.
36829      *
36830      * @static
36831      * @memberOf _
36832      * @since 0.1.0
36833      * @category Function
36834      * @param {Function} func The function to throttle.
36835      * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
36836      * @param {Object} [options={}] The options object.
36837      * @param {boolean} [options.leading=true]
36838      *  Specify invoking on the leading edge of the timeout.
36839      * @param {boolean} [options.trailing=true]
36840      *  Specify invoking on the trailing edge of the timeout.
36841      * @returns {Function} Returns the new throttled function.
36842      * @example
36843      *
36844      * // Avoid excessively updating the position while scrolling.
36845      * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
36846      *
36847      * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
36848      * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
36849      * jQuery(element).on('click', throttled);
36850      *
36851      * // Cancel the trailing throttled invocation.
36852      * jQuery(window).on('popstate', throttled.cancel);
36853      */
36854     function throttle(func, wait, options) {
36855       var leading = true,
36856           trailing = true;
36857
36858       if (typeof func != 'function') {
36859         throw new TypeError(FUNC_ERROR_TEXT);
36860       }
36861       if (isObject(options)) {
36862         leading = 'leading' in options ? !!options.leading : leading;
36863         trailing = 'trailing' in options ? !!options.trailing : trailing;
36864       }
36865       return debounce(func, wait, {
36866         'leading': leading,
36867         'maxWait': wait,
36868         'trailing': trailing
36869       });
36870     }
36871
36872     /**
36873      * Creates a function that accepts up to one argument, ignoring any
36874      * additional arguments.
36875      *
36876      * @static
36877      * @memberOf _
36878      * @since 4.0.0
36879      * @category Function
36880      * @param {Function} func The function to cap arguments for.
36881      * @returns {Function} Returns the new capped function.
36882      * @example
36883      *
36884      * _.map(['6', '8', '10'], _.unary(parseInt));
36885      * // => [6, 8, 10]
36886      */
36887     function unary(func) {
36888       return ary(func, 1);
36889     }
36890
36891     /**
36892      * Creates a function that provides `value` to `wrapper` as its first
36893      * argument. Any additional arguments provided to the function are appended
36894      * to those provided to the `wrapper`. The wrapper is invoked with the `this`
36895      * binding of the created function.
36896      *
36897      * @static
36898      * @memberOf _
36899      * @since 0.1.0
36900      * @category Function
36901      * @param {*} value The value to wrap.
36902      * @param {Function} [wrapper=identity] The wrapper function.
36903      * @returns {Function} Returns the new function.
36904      * @example
36905      *
36906      * var p = _.wrap(_.escape, function(func, text) {
36907      *   return '<p>' + func(text) + '</p>';
36908      * });
36909      *
36910      * p('fred, barney, & pebbles');
36911      * // => '<p>fred, barney, &amp; pebbles</p>'
36912      */
36913     function wrap(value, wrapper) {
36914       return partial(castFunction(wrapper), value);
36915     }
36916
36917     /*------------------------------------------------------------------------*/
36918
36919     /**
36920      * Casts `value` as an array if it's not one.
36921      *
36922      * @static
36923      * @memberOf _
36924      * @since 4.4.0
36925      * @category Lang
36926      * @param {*} value The value to inspect.
36927      * @returns {Array} Returns the cast array.
36928      * @example
36929      *
36930      * _.castArray(1);
36931      * // => [1]
36932      *
36933      * _.castArray({ 'a': 1 });
36934      * // => [{ 'a': 1 }]
36935      *
36936      * _.castArray('abc');
36937      * // => ['abc']
36938      *
36939      * _.castArray(null);
36940      * // => [null]
36941      *
36942      * _.castArray(undefined);
36943      * // => [undefined]
36944      *
36945      * _.castArray();
36946      * // => []
36947      *
36948      * var array = [1, 2, 3];
36949      * console.log(_.castArray(array) === array);
36950      * // => true
36951      */
36952     function castArray() {
36953       if (!arguments.length) {
36954         return [];
36955       }
36956       var value = arguments[0];
36957       return isArray(value) ? value : [value];
36958     }
36959
36960     /**
36961      * Creates a shallow clone of `value`.
36962      *
36963      * **Note:** This method is loosely based on the
36964      * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
36965      * and supports cloning arrays, array buffers, booleans, date objects, maps,
36966      * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
36967      * arrays. The own enumerable properties of `arguments` objects are cloned
36968      * as plain objects. An empty object is returned for uncloneable values such
36969      * as error objects, functions, DOM nodes, and WeakMaps.
36970      *
36971      * @static
36972      * @memberOf _
36973      * @since 0.1.0
36974      * @category Lang
36975      * @param {*} value The value to clone.
36976      * @returns {*} Returns the cloned value.
36977      * @see _.cloneDeep
36978      * @example
36979      *
36980      * var objects = [{ 'a': 1 }, { 'b': 2 }];
36981      *
36982      * var shallow = _.clone(objects);
36983      * console.log(shallow[0] === objects[0]);
36984      * // => true
36985      */
36986     function clone(value) {
36987       return baseClone(value, CLONE_SYMBOLS_FLAG);
36988     }
36989
36990     /**
36991      * This method is like `_.clone` except that it accepts `customizer` which
36992      * is invoked to produce the cloned value. If `customizer` returns `undefined`,
36993      * cloning is handled by the method instead. The `customizer` is invoked with
36994      * up to four arguments; (value [, index|key, object, stack]).
36995      *
36996      * @static
36997      * @memberOf _
36998      * @since 4.0.0
36999      * @category Lang
37000      * @param {*} value The value to clone.
37001      * @param {Function} [customizer] The function to customize cloning.
37002      * @returns {*} Returns the cloned value.
37003      * @see _.cloneDeepWith
37004      * @example
37005      *
37006      * function customizer(value) {
37007      *   if (_.isElement(value)) {
37008      *     return value.cloneNode(false);
37009      *   }
37010      * }
37011      *
37012      * var el = _.cloneWith(document.body, customizer);
37013      *
37014      * console.log(el === document.body);
37015      * // => false
37016      * console.log(el.nodeName);
37017      * // => 'BODY'
37018      * console.log(el.childNodes.length);
37019      * // => 0
37020      */
37021     function cloneWith(value, customizer) {
37022       customizer = typeof customizer == 'function' ? customizer : undefined;
37023       return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
37024     }
37025
37026     /**
37027      * This method is like `_.clone` except that it recursively clones `value`.
37028      *
37029      * @static
37030      * @memberOf _
37031      * @since 1.0.0
37032      * @category Lang
37033      * @param {*} value The value to recursively clone.
37034      * @returns {*} Returns the deep cloned value.
37035      * @see _.clone
37036      * @example
37037      *
37038      * var objects = [{ 'a': 1 }, { 'b': 2 }];
37039      *
37040      * var deep = _.cloneDeep(objects);
37041      * console.log(deep[0] === objects[0]);
37042      * // => false
37043      */
37044     function cloneDeep(value) {
37045       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
37046     }
37047
37048     /**
37049      * This method is like `_.cloneWith` except that it recursively clones `value`.
37050      *
37051      * @static
37052      * @memberOf _
37053      * @since 4.0.0
37054      * @category Lang
37055      * @param {*} value The value to recursively clone.
37056      * @param {Function} [customizer] The function to customize cloning.
37057      * @returns {*} Returns the deep cloned value.
37058      * @see _.cloneWith
37059      * @example
37060      *
37061      * function customizer(value) {
37062      *   if (_.isElement(value)) {
37063      *     return value.cloneNode(true);
37064      *   }
37065      * }
37066      *
37067      * var el = _.cloneDeepWith(document.body, customizer);
37068      *
37069      * console.log(el === document.body);
37070      * // => false
37071      * console.log(el.nodeName);
37072      * // => 'BODY'
37073      * console.log(el.childNodes.length);
37074      * // => 20
37075      */
37076     function cloneDeepWith(value, customizer) {
37077       customizer = typeof customizer == 'function' ? customizer : undefined;
37078       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
37079     }
37080
37081     /**
37082      * Checks if `object` conforms to `source` by invoking the predicate
37083      * properties of `source` with the corresponding property values of `object`.
37084      *
37085      * **Note:** This method is equivalent to `_.conforms` when `source` is
37086      * partially applied.
37087      *
37088      * @static
37089      * @memberOf _
37090      * @since 4.14.0
37091      * @category Lang
37092      * @param {Object} object The object to inspect.
37093      * @param {Object} source The object of property predicates to conform to.
37094      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
37095      * @example
37096      *
37097      * var object = { 'a': 1, 'b': 2 };
37098      *
37099      * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
37100      * // => true
37101      *
37102      * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
37103      * // => false
37104      */
37105     function conformsTo(object, source) {
37106       return source == null || baseConformsTo(object, source, keys(source));
37107     }
37108
37109     /**
37110      * Performs a
37111      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
37112      * comparison between two values to determine if they are equivalent.
37113      *
37114      * @static
37115      * @memberOf _
37116      * @since 4.0.0
37117      * @category Lang
37118      * @param {*} value The value to compare.
37119      * @param {*} other The other value to compare.
37120      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
37121      * @example
37122      *
37123      * var object = { 'a': 1 };
37124      * var other = { 'a': 1 };
37125      *
37126      * _.eq(object, object);
37127      * // => true
37128      *
37129      * _.eq(object, other);
37130      * // => false
37131      *
37132      * _.eq('a', 'a');
37133      * // => true
37134      *
37135      * _.eq('a', Object('a'));
37136      * // => false
37137      *
37138      * _.eq(NaN, NaN);
37139      * // => true
37140      */
37141     function eq(value, other) {
37142       return value === other || (value !== value && other !== other);
37143     }
37144
37145     /**
37146      * Checks if `value` is greater than `other`.
37147      *
37148      * @static
37149      * @memberOf _
37150      * @since 3.9.0
37151      * @category Lang
37152      * @param {*} value The value to compare.
37153      * @param {*} other The other value to compare.
37154      * @returns {boolean} Returns `true` if `value` is greater than `other`,
37155      *  else `false`.
37156      * @see _.lt
37157      * @example
37158      *
37159      * _.gt(3, 1);
37160      * // => true
37161      *
37162      * _.gt(3, 3);
37163      * // => false
37164      *
37165      * _.gt(1, 3);
37166      * // => false
37167      */
37168     var gt = createRelationalOperation(baseGt);
37169
37170     /**
37171      * Checks if `value` is greater than or equal to `other`.
37172      *
37173      * @static
37174      * @memberOf _
37175      * @since 3.9.0
37176      * @category Lang
37177      * @param {*} value The value to compare.
37178      * @param {*} other The other value to compare.
37179      * @returns {boolean} Returns `true` if `value` is greater than or equal to
37180      *  `other`, else `false`.
37181      * @see _.lte
37182      * @example
37183      *
37184      * _.gte(3, 1);
37185      * // => true
37186      *
37187      * _.gte(3, 3);
37188      * // => true
37189      *
37190      * _.gte(1, 3);
37191      * // => false
37192      */
37193     var gte = createRelationalOperation(function(value, other) {
37194       return value >= other;
37195     });
37196
37197     /**
37198      * Checks if `value` is likely an `arguments` object.
37199      *
37200      * @static
37201      * @memberOf _
37202      * @since 0.1.0
37203      * @category Lang
37204      * @param {*} value The value to check.
37205      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
37206      *  else `false`.
37207      * @example
37208      *
37209      * _.isArguments(function() { return arguments; }());
37210      * // => true
37211      *
37212      * _.isArguments([1, 2, 3]);
37213      * // => false
37214      */
37215     var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
37216       return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
37217         !propertyIsEnumerable.call(value, 'callee');
37218     };
37219
37220     /**
37221      * Checks if `value` is classified as an `Array` object.
37222      *
37223      * @static
37224      * @memberOf _
37225      * @since 0.1.0
37226      * @category Lang
37227      * @param {*} value The value to check.
37228      * @returns {boolean} Returns `true` if `value` is an array, else `false`.
37229      * @example
37230      *
37231      * _.isArray([1, 2, 3]);
37232      * // => true
37233      *
37234      * _.isArray(document.body.children);
37235      * // => false
37236      *
37237      * _.isArray('abc');
37238      * // => false
37239      *
37240      * _.isArray(_.noop);
37241      * // => false
37242      */
37243     var isArray = Array.isArray;
37244
37245     /**
37246      * Checks if `value` is classified as an `ArrayBuffer` object.
37247      *
37248      * @static
37249      * @memberOf _
37250      * @since 4.3.0
37251      * @category Lang
37252      * @param {*} value The value to check.
37253      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
37254      * @example
37255      *
37256      * _.isArrayBuffer(new ArrayBuffer(2));
37257      * // => true
37258      *
37259      * _.isArrayBuffer(new Array(2));
37260      * // => false
37261      */
37262     var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
37263
37264     /**
37265      * Checks if `value` is array-like. A value is considered array-like if it's
37266      * not a function and has a `value.length` that's an integer greater than or
37267      * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
37268      *
37269      * @static
37270      * @memberOf _
37271      * @since 4.0.0
37272      * @category Lang
37273      * @param {*} value The value to check.
37274      * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
37275      * @example
37276      *
37277      * _.isArrayLike([1, 2, 3]);
37278      * // => true
37279      *
37280      * _.isArrayLike(document.body.children);
37281      * // => true
37282      *
37283      * _.isArrayLike('abc');
37284      * // => true
37285      *
37286      * _.isArrayLike(_.noop);
37287      * // => false
37288      */
37289     function isArrayLike(value) {
37290       return value != null && isLength(value.length) && !isFunction(value);
37291     }
37292
37293     /**
37294      * This method is like `_.isArrayLike` except that it also checks if `value`
37295      * is an object.
37296      *
37297      * @static
37298      * @memberOf _
37299      * @since 4.0.0
37300      * @category Lang
37301      * @param {*} value The value to check.
37302      * @returns {boolean} Returns `true` if `value` is an array-like object,
37303      *  else `false`.
37304      * @example
37305      *
37306      * _.isArrayLikeObject([1, 2, 3]);
37307      * // => true
37308      *
37309      * _.isArrayLikeObject(document.body.children);
37310      * // => true
37311      *
37312      * _.isArrayLikeObject('abc');
37313      * // => false
37314      *
37315      * _.isArrayLikeObject(_.noop);
37316      * // => false
37317      */
37318     function isArrayLikeObject(value) {
37319       return isObjectLike(value) && isArrayLike(value);
37320     }
37321
37322     /**
37323      * Checks if `value` is classified as a boolean primitive or object.
37324      *
37325      * @static
37326      * @memberOf _
37327      * @since 0.1.0
37328      * @category Lang
37329      * @param {*} value The value to check.
37330      * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
37331      * @example
37332      *
37333      * _.isBoolean(false);
37334      * // => true
37335      *
37336      * _.isBoolean(null);
37337      * // => false
37338      */
37339     function isBoolean(value) {
37340       return value === true || value === false ||
37341         (isObjectLike(value) && baseGetTag(value) == boolTag);
37342     }
37343
37344     /**
37345      * Checks if `value` is a buffer.
37346      *
37347      * @static
37348      * @memberOf _
37349      * @since 4.3.0
37350      * @category Lang
37351      * @param {*} value The value to check.
37352      * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
37353      * @example
37354      *
37355      * _.isBuffer(new Buffer(2));
37356      * // => true
37357      *
37358      * _.isBuffer(new Uint8Array(2));
37359      * // => false
37360      */
37361     var isBuffer = nativeIsBuffer || stubFalse;
37362
37363     /**
37364      * Checks if `value` is classified as a `Date` object.
37365      *
37366      * @static
37367      * @memberOf _
37368      * @since 0.1.0
37369      * @category Lang
37370      * @param {*} value The value to check.
37371      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
37372      * @example
37373      *
37374      * _.isDate(new Date);
37375      * // => true
37376      *
37377      * _.isDate('Mon April 23 2012');
37378      * // => false
37379      */
37380     var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
37381
37382     /**
37383      * Checks if `value` is likely a DOM element.
37384      *
37385      * @static
37386      * @memberOf _
37387      * @since 0.1.0
37388      * @category Lang
37389      * @param {*} value The value to check.
37390      * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
37391      * @example
37392      *
37393      * _.isElement(document.body);
37394      * // => true
37395      *
37396      * _.isElement('<body>');
37397      * // => false
37398      */
37399     function isElement(value) {
37400       return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
37401     }
37402
37403     /**
37404      * Checks if `value` is an empty object, collection, map, or set.
37405      *
37406      * Objects are considered empty if they have no own enumerable string keyed
37407      * properties.
37408      *
37409      * Array-like values such as `arguments` objects, arrays, buffers, strings, or
37410      * jQuery-like collections are considered empty if they have a `length` of `0`.
37411      * Similarly, maps and sets are considered empty if they have a `size` of `0`.
37412      *
37413      * @static
37414      * @memberOf _
37415      * @since 0.1.0
37416      * @category Lang
37417      * @param {*} value The value to check.
37418      * @returns {boolean} Returns `true` if `value` is empty, else `false`.
37419      * @example
37420      *
37421      * _.isEmpty(null);
37422      * // => true
37423      *
37424      * _.isEmpty(true);
37425      * // => true
37426      *
37427      * _.isEmpty(1);
37428      * // => true
37429      *
37430      * _.isEmpty([1, 2, 3]);
37431      * // => false
37432      *
37433      * _.isEmpty({ 'a': 1 });
37434      * // => false
37435      */
37436     function isEmpty(value) {
37437       if (value == null) {
37438         return true;
37439       }
37440       if (isArrayLike(value) &&
37441           (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
37442             isBuffer(value) || isTypedArray(value) || isArguments(value))) {
37443         return !value.length;
37444       }
37445       var tag = getTag(value);
37446       if (tag == mapTag || tag == setTag) {
37447         return !value.size;
37448       }
37449       if (isPrototype(value)) {
37450         return !baseKeys(value).length;
37451       }
37452       for (var key in value) {
37453         if (hasOwnProperty.call(value, key)) {
37454           return false;
37455         }
37456       }
37457       return true;
37458     }
37459
37460     /**
37461      * Performs a deep comparison between two values to determine if they are
37462      * equivalent.
37463      *
37464      * **Note:** This method supports comparing arrays, array buffers, booleans,
37465      * date objects, error objects, maps, numbers, `Object` objects, regexes,
37466      * sets, strings, symbols, and typed arrays. `Object` objects are compared
37467      * by their own, not inherited, enumerable properties. Functions and DOM
37468      * nodes are compared by strict equality, i.e. `===`.
37469      *
37470      * @static
37471      * @memberOf _
37472      * @since 0.1.0
37473      * @category Lang
37474      * @param {*} value The value to compare.
37475      * @param {*} other The other value to compare.
37476      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
37477      * @example
37478      *
37479      * var object = { 'a': 1 };
37480      * var other = { 'a': 1 };
37481      *
37482      * _.isEqual(object, other);
37483      * // => true
37484      *
37485      * object === other;
37486      * // => false
37487      */
37488     function isEqual(value, other) {
37489       return baseIsEqual(value, other);
37490     }
37491
37492     /**
37493      * This method is like `_.isEqual` except that it accepts `customizer` which
37494      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
37495      * are handled by the method instead. The `customizer` is invoked with up to
37496      * six arguments: (objValue, othValue [, index|key, object, other, stack]).
37497      *
37498      * @static
37499      * @memberOf _
37500      * @since 4.0.0
37501      * @category Lang
37502      * @param {*} value The value to compare.
37503      * @param {*} other The other value to compare.
37504      * @param {Function} [customizer] The function to customize comparisons.
37505      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
37506      * @example
37507      *
37508      * function isGreeting(value) {
37509      *   return /^h(?:i|ello)$/.test(value);
37510      * }
37511      *
37512      * function customizer(objValue, othValue) {
37513      *   if (isGreeting(objValue) && isGreeting(othValue)) {
37514      *     return true;
37515      *   }
37516      * }
37517      *
37518      * var array = ['hello', 'goodbye'];
37519      * var other = ['hi', 'goodbye'];
37520      *
37521      * _.isEqualWith(array, other, customizer);
37522      * // => true
37523      */
37524     function isEqualWith(value, other, customizer) {
37525       customizer = typeof customizer == 'function' ? customizer : undefined;
37526       var result = customizer ? customizer(value, other) : undefined;
37527       return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
37528     }
37529
37530     /**
37531      * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
37532      * `SyntaxError`, `TypeError`, or `URIError` object.
37533      *
37534      * @static
37535      * @memberOf _
37536      * @since 3.0.0
37537      * @category Lang
37538      * @param {*} value The value to check.
37539      * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
37540      * @example
37541      *
37542      * _.isError(new Error);
37543      * // => true
37544      *
37545      * _.isError(Error);
37546      * // => false
37547      */
37548     function isError(value) {
37549       if (!isObjectLike(value)) {
37550         return false;
37551       }
37552       var tag = baseGetTag(value);
37553       return tag == errorTag || tag == domExcTag ||
37554         (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
37555     }
37556
37557     /**
37558      * Checks if `value` is a finite primitive number.
37559      *
37560      * **Note:** This method is based on
37561      * [`Number.isFinite`](https://mdn.io/Number/isFinite).
37562      *
37563      * @static
37564      * @memberOf _
37565      * @since 0.1.0
37566      * @category Lang
37567      * @param {*} value The value to check.
37568      * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
37569      * @example
37570      *
37571      * _.isFinite(3);
37572      * // => true
37573      *
37574      * _.isFinite(Number.MIN_VALUE);
37575      * // => true
37576      *
37577      * _.isFinite(Infinity);
37578      * // => false
37579      *
37580      * _.isFinite('3');
37581      * // => false
37582      */
37583     function isFinite(value) {
37584       return typeof value == 'number' && nativeIsFinite(value);
37585     }
37586
37587     /**
37588      * Checks if `value` is classified as a `Function` object.
37589      *
37590      * @static
37591      * @memberOf _
37592      * @since 0.1.0
37593      * @category Lang
37594      * @param {*} value The value to check.
37595      * @returns {boolean} Returns `true` if `value` is a function, else `false`.
37596      * @example
37597      *
37598      * _.isFunction(_);
37599      * // => true
37600      *
37601      * _.isFunction(/abc/);
37602      * // => false
37603      */
37604     function isFunction(value) {
37605       if (!isObject(value)) {
37606         return false;
37607       }
37608       // The use of `Object#toString` avoids issues with the `typeof` operator
37609       // in Safari 9 which returns 'object' for typed arrays and other constructors.
37610       var tag = baseGetTag(value);
37611       return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
37612     }
37613
37614     /**
37615      * Checks if `value` is an integer.
37616      *
37617      * **Note:** This method is based on
37618      * [`Number.isInteger`](https://mdn.io/Number/isInteger).
37619      *
37620      * @static
37621      * @memberOf _
37622      * @since 4.0.0
37623      * @category Lang
37624      * @param {*} value The value to check.
37625      * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
37626      * @example
37627      *
37628      * _.isInteger(3);
37629      * // => true
37630      *
37631      * _.isInteger(Number.MIN_VALUE);
37632      * // => false
37633      *
37634      * _.isInteger(Infinity);
37635      * // => false
37636      *
37637      * _.isInteger('3');
37638      * // => false
37639      */
37640     function isInteger(value) {
37641       return typeof value == 'number' && value == toInteger(value);
37642     }
37643
37644     /**
37645      * Checks if `value` is a valid array-like length.
37646      *
37647      * **Note:** This method is loosely based on
37648      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
37649      *
37650      * @static
37651      * @memberOf _
37652      * @since 4.0.0
37653      * @category Lang
37654      * @param {*} value The value to check.
37655      * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
37656      * @example
37657      *
37658      * _.isLength(3);
37659      * // => true
37660      *
37661      * _.isLength(Number.MIN_VALUE);
37662      * // => false
37663      *
37664      * _.isLength(Infinity);
37665      * // => false
37666      *
37667      * _.isLength('3');
37668      * // => false
37669      */
37670     function isLength(value) {
37671       return typeof value == 'number' &&
37672         value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
37673     }
37674
37675     /**
37676      * Checks if `value` is the
37677      * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
37678      * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
37679      *
37680      * @static
37681      * @memberOf _
37682      * @since 0.1.0
37683      * @category Lang
37684      * @param {*} value The value to check.
37685      * @returns {boolean} Returns `true` if `value` is an object, else `false`.
37686      * @example
37687      *
37688      * _.isObject({});
37689      * // => true
37690      *
37691      * _.isObject([1, 2, 3]);
37692      * // => true
37693      *
37694      * _.isObject(_.noop);
37695      * // => true
37696      *
37697      * _.isObject(null);
37698      * // => false
37699      */
37700     function isObject(value) {
37701       var type = typeof value;
37702       return value != null && (type == 'object' || type == 'function');
37703     }
37704
37705     /**
37706      * Checks if `value` is object-like. A value is object-like if it's not `null`
37707      * and has a `typeof` result of "object".
37708      *
37709      * @static
37710      * @memberOf _
37711      * @since 4.0.0
37712      * @category Lang
37713      * @param {*} value The value to check.
37714      * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
37715      * @example
37716      *
37717      * _.isObjectLike({});
37718      * // => true
37719      *
37720      * _.isObjectLike([1, 2, 3]);
37721      * // => true
37722      *
37723      * _.isObjectLike(_.noop);
37724      * // => false
37725      *
37726      * _.isObjectLike(null);
37727      * // => false
37728      */
37729     function isObjectLike(value) {
37730       return value != null && typeof value == 'object';
37731     }
37732
37733     /**
37734      * Checks if `value` is classified as a `Map` object.
37735      *
37736      * @static
37737      * @memberOf _
37738      * @since 4.3.0
37739      * @category Lang
37740      * @param {*} value The value to check.
37741      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
37742      * @example
37743      *
37744      * _.isMap(new Map);
37745      * // => true
37746      *
37747      * _.isMap(new WeakMap);
37748      * // => false
37749      */
37750     var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
37751
37752     /**
37753      * Performs a partial deep comparison between `object` and `source` to
37754      * determine if `object` contains equivalent property values.
37755      *
37756      * **Note:** This method is equivalent to `_.matches` when `source` is
37757      * partially applied.
37758      *
37759      * Partial comparisons will match empty array and empty object `source`
37760      * values against any array or object value, respectively. See `_.isEqual`
37761      * for a list of supported value comparisons.
37762      *
37763      * @static
37764      * @memberOf _
37765      * @since 3.0.0
37766      * @category Lang
37767      * @param {Object} object The object to inspect.
37768      * @param {Object} source The object of property values to match.
37769      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
37770      * @example
37771      *
37772      * var object = { 'a': 1, 'b': 2 };
37773      *
37774      * _.isMatch(object, { 'b': 2 });
37775      * // => true
37776      *
37777      * _.isMatch(object, { 'b': 1 });
37778      * // => false
37779      */
37780     function isMatch(object, source) {
37781       return object === source || baseIsMatch(object, source, getMatchData(source));
37782     }
37783
37784     /**
37785      * This method is like `_.isMatch` except that it accepts `customizer` which
37786      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
37787      * are handled by the method instead. The `customizer` is invoked with five
37788      * arguments: (objValue, srcValue, index|key, object, source).
37789      *
37790      * @static
37791      * @memberOf _
37792      * @since 4.0.0
37793      * @category Lang
37794      * @param {Object} object The object to inspect.
37795      * @param {Object} source The object of property values to match.
37796      * @param {Function} [customizer] The function to customize comparisons.
37797      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
37798      * @example
37799      *
37800      * function isGreeting(value) {
37801      *   return /^h(?:i|ello)$/.test(value);
37802      * }
37803      *
37804      * function customizer(objValue, srcValue) {
37805      *   if (isGreeting(objValue) && isGreeting(srcValue)) {
37806      *     return true;
37807      *   }
37808      * }
37809      *
37810      * var object = { 'greeting': 'hello' };
37811      * var source = { 'greeting': 'hi' };
37812      *
37813      * _.isMatchWith(object, source, customizer);
37814      * // => true
37815      */
37816     function isMatchWith(object, source, customizer) {
37817       customizer = typeof customizer == 'function' ? customizer : undefined;
37818       return baseIsMatch(object, source, getMatchData(source), customizer);
37819     }
37820
37821     /**
37822      * Checks if `value` is `NaN`.
37823      *
37824      * **Note:** This method is based on
37825      * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
37826      * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
37827      * `undefined` and other non-number values.
37828      *
37829      * @static
37830      * @memberOf _
37831      * @since 0.1.0
37832      * @category Lang
37833      * @param {*} value The value to check.
37834      * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
37835      * @example
37836      *
37837      * _.isNaN(NaN);
37838      * // => true
37839      *
37840      * _.isNaN(new Number(NaN));
37841      * // => true
37842      *
37843      * isNaN(undefined);
37844      * // => true
37845      *
37846      * _.isNaN(undefined);
37847      * // => false
37848      */
37849     function isNaN(value) {
37850       // An `NaN` primitive is the only value that is not equal to itself.
37851       // Perform the `toStringTag` check first to avoid errors with some
37852       // ActiveX objects in IE.
37853       return isNumber(value) && value != +value;
37854     }
37855
37856     /**
37857      * Checks if `value` is a pristine native function.
37858      *
37859      * **Note:** This method can't reliably detect native functions in the presence
37860      * of the core-js package because core-js circumvents this kind of detection.
37861      * Despite multiple requests, the core-js maintainer has made it clear: any
37862      * attempt to fix the detection will be obstructed. As a result, we're left
37863      * with little choice but to throw an error. Unfortunately, this also affects
37864      * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
37865      * which rely on core-js.
37866      *
37867      * @static
37868      * @memberOf _
37869      * @since 3.0.0
37870      * @category Lang
37871      * @param {*} value The value to check.
37872      * @returns {boolean} Returns `true` if `value` is a native function,
37873      *  else `false`.
37874      * @example
37875      *
37876      * _.isNative(Array.prototype.push);
37877      * // => true
37878      *
37879      * _.isNative(_);
37880      * // => false
37881      */
37882     function isNative(value) {
37883       if (isMaskable(value)) {
37884         throw new Error(CORE_ERROR_TEXT);
37885       }
37886       return baseIsNative(value);
37887     }
37888
37889     /**
37890      * Checks if `value` is `null`.
37891      *
37892      * @static
37893      * @memberOf _
37894      * @since 0.1.0
37895      * @category Lang
37896      * @param {*} value The value to check.
37897      * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
37898      * @example
37899      *
37900      * _.isNull(null);
37901      * // => true
37902      *
37903      * _.isNull(void 0);
37904      * // => false
37905      */
37906     function isNull(value) {
37907       return value === null;
37908     }
37909
37910     /**
37911      * Checks if `value` is `null` or `undefined`.
37912      *
37913      * @static
37914      * @memberOf _
37915      * @since 4.0.0
37916      * @category Lang
37917      * @param {*} value The value to check.
37918      * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
37919      * @example
37920      *
37921      * _.isNil(null);
37922      * // => true
37923      *
37924      * _.isNil(void 0);
37925      * // => true
37926      *
37927      * _.isNil(NaN);
37928      * // => false
37929      */
37930     function isNil(value) {
37931       return value == null;
37932     }
37933
37934     /**
37935      * Checks if `value` is classified as a `Number` primitive or object.
37936      *
37937      * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
37938      * classified as numbers, use the `_.isFinite` method.
37939      *
37940      * @static
37941      * @memberOf _
37942      * @since 0.1.0
37943      * @category Lang
37944      * @param {*} value The value to check.
37945      * @returns {boolean} Returns `true` if `value` is a number, else `false`.
37946      * @example
37947      *
37948      * _.isNumber(3);
37949      * // => true
37950      *
37951      * _.isNumber(Number.MIN_VALUE);
37952      * // => true
37953      *
37954      * _.isNumber(Infinity);
37955      * // => true
37956      *
37957      * _.isNumber('3');
37958      * // => false
37959      */
37960     function isNumber(value) {
37961       return typeof value == 'number' ||
37962         (isObjectLike(value) && baseGetTag(value) == numberTag);
37963     }
37964
37965     /**
37966      * Checks if `value` is a plain object, that is, an object created by the
37967      * `Object` constructor or one with a `[[Prototype]]` of `null`.
37968      *
37969      * @static
37970      * @memberOf _
37971      * @since 0.8.0
37972      * @category Lang
37973      * @param {*} value The value to check.
37974      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
37975      * @example
37976      *
37977      * function Foo() {
37978      *   this.a = 1;
37979      * }
37980      *
37981      * _.isPlainObject(new Foo);
37982      * // => false
37983      *
37984      * _.isPlainObject([1, 2, 3]);
37985      * // => false
37986      *
37987      * _.isPlainObject({ 'x': 0, 'y': 0 });
37988      * // => true
37989      *
37990      * _.isPlainObject(Object.create(null));
37991      * // => true
37992      */
37993     function isPlainObject(value) {
37994       if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
37995         return false;
37996       }
37997       var proto = getPrototype(value);
37998       if (proto === null) {
37999         return true;
38000       }
38001       var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
38002       return typeof Ctor == 'function' && Ctor instanceof Ctor &&
38003         funcToString.call(Ctor) == objectCtorString;
38004     }
38005
38006     /**
38007      * Checks if `value` is classified as a `RegExp` object.
38008      *
38009      * @static
38010      * @memberOf _
38011      * @since 0.1.0
38012      * @category Lang
38013      * @param {*} value The value to check.
38014      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
38015      * @example
38016      *
38017      * _.isRegExp(/abc/);
38018      * // => true
38019      *
38020      * _.isRegExp('/abc/');
38021      * // => false
38022      */
38023     var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
38024
38025     /**
38026      * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
38027      * double precision number which isn't the result of a rounded unsafe integer.
38028      *
38029      * **Note:** This method is based on
38030      * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
38031      *
38032      * @static
38033      * @memberOf _
38034      * @since 4.0.0
38035      * @category Lang
38036      * @param {*} value The value to check.
38037      * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
38038      * @example
38039      *
38040      * _.isSafeInteger(3);
38041      * // => true
38042      *
38043      * _.isSafeInteger(Number.MIN_VALUE);
38044      * // => false
38045      *
38046      * _.isSafeInteger(Infinity);
38047      * // => false
38048      *
38049      * _.isSafeInteger('3');
38050      * // => false
38051      */
38052     function isSafeInteger(value) {
38053       return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
38054     }
38055
38056     /**
38057      * Checks if `value` is classified as a `Set` object.
38058      *
38059      * @static
38060      * @memberOf _
38061      * @since 4.3.0
38062      * @category Lang
38063      * @param {*} value The value to check.
38064      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
38065      * @example
38066      *
38067      * _.isSet(new Set);
38068      * // => true
38069      *
38070      * _.isSet(new WeakSet);
38071      * // => false
38072      */
38073     var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
38074
38075     /**
38076      * Checks if `value` is classified as a `String` primitive or object.
38077      *
38078      * @static
38079      * @since 0.1.0
38080      * @memberOf _
38081      * @category Lang
38082      * @param {*} value The value to check.
38083      * @returns {boolean} Returns `true` if `value` is a string, else `false`.
38084      * @example
38085      *
38086      * _.isString('abc');
38087      * // => true
38088      *
38089      * _.isString(1);
38090      * // => false
38091      */
38092     function isString(value) {
38093       return typeof value == 'string' ||
38094         (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
38095     }
38096
38097     /**
38098      * Checks if `value` is classified as a `Symbol` primitive or object.
38099      *
38100      * @static
38101      * @memberOf _
38102      * @since 4.0.0
38103      * @category Lang
38104      * @param {*} value The value to check.
38105      * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
38106      * @example
38107      *
38108      * _.isSymbol(Symbol.iterator);
38109      * // => true
38110      *
38111      * _.isSymbol('abc');
38112      * // => false
38113      */
38114     function isSymbol(value) {
38115       return typeof value == 'symbol' ||
38116         (isObjectLike(value) && baseGetTag(value) == symbolTag);
38117     }
38118
38119     /**
38120      * Checks if `value` is classified as a typed array.
38121      *
38122      * @static
38123      * @memberOf _
38124      * @since 3.0.0
38125      * @category Lang
38126      * @param {*} value The value to check.
38127      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
38128      * @example
38129      *
38130      * _.isTypedArray(new Uint8Array);
38131      * // => true
38132      *
38133      * _.isTypedArray([]);
38134      * // => false
38135      */
38136     var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
38137
38138     /**
38139      * Checks if `value` is `undefined`.
38140      *
38141      * @static
38142      * @since 0.1.0
38143      * @memberOf _
38144      * @category Lang
38145      * @param {*} value The value to check.
38146      * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
38147      * @example
38148      *
38149      * _.isUndefined(void 0);
38150      * // => true
38151      *
38152      * _.isUndefined(null);
38153      * // => false
38154      */
38155     function isUndefined(value) {
38156       return value === undefined;
38157     }
38158
38159     /**
38160      * Checks if `value` is classified as a `WeakMap` object.
38161      *
38162      * @static
38163      * @memberOf _
38164      * @since 4.3.0
38165      * @category Lang
38166      * @param {*} value The value to check.
38167      * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
38168      * @example
38169      *
38170      * _.isWeakMap(new WeakMap);
38171      * // => true
38172      *
38173      * _.isWeakMap(new Map);
38174      * // => false
38175      */
38176     function isWeakMap(value) {
38177       return isObjectLike(value) && getTag(value) == weakMapTag;
38178     }
38179
38180     /**
38181      * Checks if `value` is classified as a `WeakSet` object.
38182      *
38183      * @static
38184      * @memberOf _
38185      * @since 4.3.0
38186      * @category Lang
38187      * @param {*} value The value to check.
38188      * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
38189      * @example
38190      *
38191      * _.isWeakSet(new WeakSet);
38192      * // => true
38193      *
38194      * _.isWeakSet(new Set);
38195      * // => false
38196      */
38197     function isWeakSet(value) {
38198       return isObjectLike(value) && baseGetTag(value) == weakSetTag;
38199     }
38200
38201     /**
38202      * Checks if `value` is less than `other`.
38203      *
38204      * @static
38205      * @memberOf _
38206      * @since 3.9.0
38207      * @category Lang
38208      * @param {*} value The value to compare.
38209      * @param {*} other The other value to compare.
38210      * @returns {boolean} Returns `true` if `value` is less than `other`,
38211      *  else `false`.
38212      * @see _.gt
38213      * @example
38214      *
38215      * _.lt(1, 3);
38216      * // => true
38217      *
38218      * _.lt(3, 3);
38219      * // => false
38220      *
38221      * _.lt(3, 1);
38222      * // => false
38223      */
38224     var lt = createRelationalOperation(baseLt);
38225
38226     /**
38227      * Checks if `value` is less than or equal to `other`.
38228      *
38229      * @static
38230      * @memberOf _
38231      * @since 3.9.0
38232      * @category Lang
38233      * @param {*} value The value to compare.
38234      * @param {*} other The other value to compare.
38235      * @returns {boolean} Returns `true` if `value` is less than or equal to
38236      *  `other`, else `false`.
38237      * @see _.gte
38238      * @example
38239      *
38240      * _.lte(1, 3);
38241      * // => true
38242      *
38243      * _.lte(3, 3);
38244      * // => true
38245      *
38246      * _.lte(3, 1);
38247      * // => false
38248      */
38249     var lte = createRelationalOperation(function(value, other) {
38250       return value <= other;
38251     });
38252
38253     /**
38254      * Converts `value` to an array.
38255      *
38256      * @static
38257      * @since 0.1.0
38258      * @memberOf _
38259      * @category Lang
38260      * @param {*} value The value to convert.
38261      * @returns {Array} Returns the converted array.
38262      * @example
38263      *
38264      * _.toArray({ 'a': 1, 'b': 2 });
38265      * // => [1, 2]
38266      *
38267      * _.toArray('abc');
38268      * // => ['a', 'b', 'c']
38269      *
38270      * _.toArray(1);
38271      * // => []
38272      *
38273      * _.toArray(null);
38274      * // => []
38275      */
38276     function toArray(value) {
38277       if (!value) {
38278         return [];
38279       }
38280       if (isArrayLike(value)) {
38281         return isString(value) ? stringToArray(value) : copyArray(value);
38282       }
38283       if (symIterator && value[symIterator]) {
38284         return iteratorToArray(value[symIterator]());
38285       }
38286       var tag = getTag(value),
38287           func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
38288
38289       return func(value);
38290     }
38291
38292     /**
38293      * Converts `value` to a finite number.
38294      *
38295      * @static
38296      * @memberOf _
38297      * @since 4.12.0
38298      * @category Lang
38299      * @param {*} value The value to convert.
38300      * @returns {number} Returns the converted number.
38301      * @example
38302      *
38303      * _.toFinite(3.2);
38304      * // => 3.2
38305      *
38306      * _.toFinite(Number.MIN_VALUE);
38307      * // => 5e-324
38308      *
38309      * _.toFinite(Infinity);
38310      * // => 1.7976931348623157e+308
38311      *
38312      * _.toFinite('3.2');
38313      * // => 3.2
38314      */
38315     function toFinite(value) {
38316       if (!value) {
38317         return value === 0 ? value : 0;
38318       }
38319       value = toNumber(value);
38320       if (value === INFINITY || value === -INFINITY) {
38321         var sign = (value < 0 ? -1 : 1);
38322         return sign * MAX_INTEGER;
38323       }
38324       return value === value ? value : 0;
38325     }
38326
38327     /**
38328      * Converts `value` to an integer.
38329      *
38330      * **Note:** This method is loosely based on
38331      * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
38332      *
38333      * @static
38334      * @memberOf _
38335      * @since 4.0.0
38336      * @category Lang
38337      * @param {*} value The value to convert.
38338      * @returns {number} Returns the converted integer.
38339      * @example
38340      *
38341      * _.toInteger(3.2);
38342      * // => 3
38343      *
38344      * _.toInteger(Number.MIN_VALUE);
38345      * // => 0
38346      *
38347      * _.toInteger(Infinity);
38348      * // => 1.7976931348623157e+308
38349      *
38350      * _.toInteger('3.2');
38351      * // => 3
38352      */
38353     function toInteger(value) {
38354       var result = toFinite(value),
38355           remainder = result % 1;
38356
38357       return result === result ? (remainder ? result - remainder : result) : 0;
38358     }
38359
38360     /**
38361      * Converts `value` to an integer suitable for use as the length of an
38362      * array-like object.
38363      *
38364      * **Note:** This method is based on
38365      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
38366      *
38367      * @static
38368      * @memberOf _
38369      * @since 4.0.0
38370      * @category Lang
38371      * @param {*} value The value to convert.
38372      * @returns {number} Returns the converted integer.
38373      * @example
38374      *
38375      * _.toLength(3.2);
38376      * // => 3
38377      *
38378      * _.toLength(Number.MIN_VALUE);
38379      * // => 0
38380      *
38381      * _.toLength(Infinity);
38382      * // => 4294967295
38383      *
38384      * _.toLength('3.2');
38385      * // => 3
38386      */
38387     function toLength(value) {
38388       return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
38389     }
38390
38391     /**
38392      * Converts `value` to a number.
38393      *
38394      * @static
38395      * @memberOf _
38396      * @since 4.0.0
38397      * @category Lang
38398      * @param {*} value The value to process.
38399      * @returns {number} Returns the number.
38400      * @example
38401      *
38402      * _.toNumber(3.2);
38403      * // => 3.2
38404      *
38405      * _.toNumber(Number.MIN_VALUE);
38406      * // => 5e-324
38407      *
38408      * _.toNumber(Infinity);
38409      * // => Infinity
38410      *
38411      * _.toNumber('3.2');
38412      * // => 3.2
38413      */
38414     function toNumber(value) {
38415       if (typeof value == 'number') {
38416         return value;
38417       }
38418       if (isSymbol(value)) {
38419         return NAN;
38420       }
38421       if (isObject(value)) {
38422         var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
38423         value = isObject(other) ? (other + '') : other;
38424       }
38425       if (typeof value != 'string') {
38426         return value === 0 ? value : +value;
38427       }
38428       value = value.replace(reTrim, '');
38429       var isBinary = reIsBinary.test(value);
38430       return (isBinary || reIsOctal.test(value))
38431         ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
38432         : (reIsBadHex.test(value) ? NAN : +value);
38433     }
38434
38435     /**
38436      * Converts `value` to a plain object flattening inherited enumerable string
38437      * keyed properties of `value` to own properties of the plain object.
38438      *
38439      * @static
38440      * @memberOf _
38441      * @since 3.0.0
38442      * @category Lang
38443      * @param {*} value The value to convert.
38444      * @returns {Object} Returns the converted plain object.
38445      * @example
38446      *
38447      * function Foo() {
38448      *   this.b = 2;
38449      * }
38450      *
38451      * Foo.prototype.c = 3;
38452      *
38453      * _.assign({ 'a': 1 }, new Foo);
38454      * // => { 'a': 1, 'b': 2 }
38455      *
38456      * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
38457      * // => { 'a': 1, 'b': 2, 'c': 3 }
38458      */
38459     function toPlainObject(value) {
38460       return copyObject(value, keysIn(value));
38461     }
38462
38463     /**
38464      * Converts `value` to a safe integer. A safe integer can be compared and
38465      * represented correctly.
38466      *
38467      * @static
38468      * @memberOf _
38469      * @since 4.0.0
38470      * @category Lang
38471      * @param {*} value The value to convert.
38472      * @returns {number} Returns the converted integer.
38473      * @example
38474      *
38475      * _.toSafeInteger(3.2);
38476      * // => 3
38477      *
38478      * _.toSafeInteger(Number.MIN_VALUE);
38479      * // => 0
38480      *
38481      * _.toSafeInteger(Infinity);
38482      * // => 9007199254740991
38483      *
38484      * _.toSafeInteger('3.2');
38485      * // => 3
38486      */
38487     function toSafeInteger(value) {
38488       return value
38489         ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
38490         : (value === 0 ? value : 0);
38491     }
38492
38493     /**
38494      * Converts `value` to a string. An empty string is returned for `null`
38495      * and `undefined` values. The sign of `-0` is preserved.
38496      *
38497      * @static
38498      * @memberOf _
38499      * @since 4.0.0
38500      * @category Lang
38501      * @param {*} value The value to convert.
38502      * @returns {string} Returns the converted string.
38503      * @example
38504      *
38505      * _.toString(null);
38506      * // => ''
38507      *
38508      * _.toString(-0);
38509      * // => '-0'
38510      *
38511      * _.toString([1, 2, 3]);
38512      * // => '1,2,3'
38513      */
38514     function toString(value) {
38515       return value == null ? '' : baseToString(value);
38516     }
38517
38518     /*------------------------------------------------------------------------*/
38519
38520     /**
38521      * Assigns own enumerable string keyed properties of source objects to the
38522      * destination object. Source objects are applied from left to right.
38523      * Subsequent sources overwrite property assignments of previous sources.
38524      *
38525      * **Note:** This method mutates `object` and is loosely based on
38526      * [`Object.assign`](https://mdn.io/Object/assign).
38527      *
38528      * @static
38529      * @memberOf _
38530      * @since 0.10.0
38531      * @category Object
38532      * @param {Object} object The destination object.
38533      * @param {...Object} [sources] The source objects.
38534      * @returns {Object} Returns `object`.
38535      * @see _.assignIn
38536      * @example
38537      *
38538      * function Foo() {
38539      *   this.a = 1;
38540      * }
38541      *
38542      * function Bar() {
38543      *   this.c = 3;
38544      * }
38545      *
38546      * Foo.prototype.b = 2;
38547      * Bar.prototype.d = 4;
38548      *
38549      * _.assign({ 'a': 0 }, new Foo, new Bar);
38550      * // => { 'a': 1, 'c': 3 }
38551      */
38552     var assign = createAssigner(function(object, source) {
38553       if (isPrototype(source) || isArrayLike(source)) {
38554         copyObject(source, keys(source), object);
38555         return;
38556       }
38557       for (var key in source) {
38558         if (hasOwnProperty.call(source, key)) {
38559           assignValue(object, key, source[key]);
38560         }
38561       }
38562     });
38563
38564     /**
38565      * This method is like `_.assign` except that it iterates over own and
38566      * inherited source properties.
38567      *
38568      * **Note:** This method mutates `object`.
38569      *
38570      * @static
38571      * @memberOf _
38572      * @since 4.0.0
38573      * @alias extend
38574      * @category Object
38575      * @param {Object} object The destination object.
38576      * @param {...Object} [sources] The source objects.
38577      * @returns {Object} Returns `object`.
38578      * @see _.assign
38579      * @example
38580      *
38581      * function Foo() {
38582      *   this.a = 1;
38583      * }
38584      *
38585      * function Bar() {
38586      *   this.c = 3;
38587      * }
38588      *
38589      * Foo.prototype.b = 2;
38590      * Bar.prototype.d = 4;
38591      *
38592      * _.assignIn({ 'a': 0 }, new Foo, new Bar);
38593      * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
38594      */
38595     var assignIn = createAssigner(function(object, source) {
38596       copyObject(source, keysIn(source), object);
38597     });
38598
38599     /**
38600      * This method is like `_.assignIn` except that it accepts `customizer`
38601      * which is invoked to produce the assigned values. If `customizer` returns
38602      * `undefined`, assignment is handled by the method instead. The `customizer`
38603      * is invoked with five arguments: (objValue, srcValue, key, object, source).
38604      *
38605      * **Note:** This method mutates `object`.
38606      *
38607      * @static
38608      * @memberOf _
38609      * @since 4.0.0
38610      * @alias extendWith
38611      * @category Object
38612      * @param {Object} object The destination object.
38613      * @param {...Object} sources The source objects.
38614      * @param {Function} [customizer] The function to customize assigned values.
38615      * @returns {Object} Returns `object`.
38616      * @see _.assignWith
38617      * @example
38618      *
38619      * function customizer(objValue, srcValue) {
38620      *   return _.isUndefined(objValue) ? srcValue : objValue;
38621      * }
38622      *
38623      * var defaults = _.partialRight(_.assignInWith, customizer);
38624      *
38625      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
38626      * // => { 'a': 1, 'b': 2 }
38627      */
38628     var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
38629       copyObject(source, keysIn(source), object, customizer);
38630     });
38631
38632     /**
38633      * This method is like `_.assign` except that it accepts `customizer`
38634      * which is invoked to produce the assigned values. If `customizer` returns
38635      * `undefined`, assignment is handled by the method instead. The `customizer`
38636      * is invoked with five arguments: (objValue, srcValue, key, object, source).
38637      *
38638      * **Note:** This method mutates `object`.
38639      *
38640      * @static
38641      * @memberOf _
38642      * @since 4.0.0
38643      * @category Object
38644      * @param {Object} object The destination object.
38645      * @param {...Object} sources The source objects.
38646      * @param {Function} [customizer] The function to customize assigned values.
38647      * @returns {Object} Returns `object`.
38648      * @see _.assignInWith
38649      * @example
38650      *
38651      * function customizer(objValue, srcValue) {
38652      *   return _.isUndefined(objValue) ? srcValue : objValue;
38653      * }
38654      *
38655      * var defaults = _.partialRight(_.assignWith, customizer);
38656      *
38657      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
38658      * // => { 'a': 1, 'b': 2 }
38659      */
38660     var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
38661       copyObject(source, keys(source), object, customizer);
38662     });
38663
38664     /**
38665      * Creates an array of values corresponding to `paths` of `object`.
38666      *
38667      * @static
38668      * @memberOf _
38669      * @since 1.0.0
38670      * @category Object
38671      * @param {Object} object The object to iterate over.
38672      * @param {...(string|string[])} [paths] The property paths to pick.
38673      * @returns {Array} Returns the picked values.
38674      * @example
38675      *
38676      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
38677      *
38678      * _.at(object, ['a[0].b.c', 'a[1]']);
38679      * // => [3, 4]
38680      */
38681     var at = flatRest(baseAt);
38682
38683     /**
38684      * Creates an object that inherits from the `prototype` object. If a
38685      * `properties` object is given, its own enumerable string keyed properties
38686      * are assigned to the created object.
38687      *
38688      * @static
38689      * @memberOf _
38690      * @since 2.3.0
38691      * @category Object
38692      * @param {Object} prototype The object to inherit from.
38693      * @param {Object} [properties] The properties to assign to the object.
38694      * @returns {Object} Returns the new object.
38695      * @example
38696      *
38697      * function Shape() {
38698      *   this.x = 0;
38699      *   this.y = 0;
38700      * }
38701      *
38702      * function Circle() {
38703      *   Shape.call(this);
38704      * }
38705      *
38706      * Circle.prototype = _.create(Shape.prototype, {
38707      *   'constructor': Circle
38708      * });
38709      *
38710      * var circle = new Circle;
38711      * circle instanceof Circle;
38712      * // => true
38713      *
38714      * circle instanceof Shape;
38715      * // => true
38716      */
38717     function create(prototype, properties) {
38718       var result = baseCreate(prototype);
38719       return properties == null ? result : baseAssign(result, properties);
38720     }
38721
38722     /**
38723      * Assigns own and inherited enumerable string keyed properties of source
38724      * objects to the destination object for all destination properties that
38725      * resolve to `undefined`. Source objects are applied from left to right.
38726      * Once a property is set, additional values of the same property are ignored.
38727      *
38728      * **Note:** This method mutates `object`.
38729      *
38730      * @static
38731      * @since 0.1.0
38732      * @memberOf _
38733      * @category Object
38734      * @param {Object} object The destination object.
38735      * @param {...Object} [sources] The source objects.
38736      * @returns {Object} Returns `object`.
38737      * @see _.defaultsDeep
38738      * @example
38739      *
38740      * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
38741      * // => { 'a': 1, 'b': 2 }
38742      */
38743     var defaults = baseRest(function(object, sources) {
38744       object = Object(object);
38745
38746       var index = -1;
38747       var length = sources.length;
38748       var guard = length > 2 ? sources[2] : undefined;
38749
38750       if (guard && isIterateeCall(sources[0], sources[1], guard)) {
38751         length = 1;
38752       }
38753
38754       while (++index < length) {
38755         var source = sources[index];
38756         var props = keysIn(source);
38757         var propsIndex = -1;
38758         var propsLength = props.length;
38759
38760         while (++propsIndex < propsLength) {
38761           var key = props[propsIndex];
38762           var value = object[key];
38763
38764           if (value === undefined ||
38765               (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
38766             object[key] = source[key];
38767           }
38768         }
38769       }
38770
38771       return object;
38772     });
38773
38774     /**
38775      * This method is like `_.defaults` except that it recursively assigns
38776      * default properties.
38777      *
38778      * **Note:** This method mutates `object`.
38779      *
38780      * @static
38781      * @memberOf _
38782      * @since 3.10.0
38783      * @category Object
38784      * @param {Object} object The destination object.
38785      * @param {...Object} [sources] The source objects.
38786      * @returns {Object} Returns `object`.
38787      * @see _.defaults
38788      * @example
38789      *
38790      * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
38791      * // => { 'a': { 'b': 2, 'c': 3 } }
38792      */
38793     var defaultsDeep = baseRest(function(args) {
38794       args.push(undefined, customDefaultsMerge);
38795       return apply(mergeWith, undefined, args);
38796     });
38797
38798     /**
38799      * This method is like `_.find` except that it returns the key of the first
38800      * element `predicate` returns truthy for instead of the element itself.
38801      *
38802      * @static
38803      * @memberOf _
38804      * @since 1.1.0
38805      * @category Object
38806      * @param {Object} object The object to inspect.
38807      * @param {Function} [predicate=_.identity] The function invoked per iteration.
38808      * @returns {string|undefined} Returns the key of the matched element,
38809      *  else `undefined`.
38810      * @example
38811      *
38812      * var users = {
38813      *   'barney':  { 'age': 36, 'active': true },
38814      *   'fred':    { 'age': 40, 'active': false },
38815      *   'pebbles': { 'age': 1,  'active': true }
38816      * };
38817      *
38818      * _.findKey(users, function(o) { return o.age < 40; });
38819      * // => 'barney' (iteration order is not guaranteed)
38820      *
38821      * // The `_.matches` iteratee shorthand.
38822      * _.findKey(users, { 'age': 1, 'active': true });
38823      * // => 'pebbles'
38824      *
38825      * // The `_.matchesProperty` iteratee shorthand.
38826      * _.findKey(users, ['active', false]);
38827      * // => 'fred'
38828      *
38829      * // The `_.property` iteratee shorthand.
38830      * _.findKey(users, 'active');
38831      * // => 'barney'
38832      */
38833     function findKey(object, predicate) {
38834       return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
38835     }
38836
38837     /**
38838      * This method is like `_.findKey` except that it iterates over elements of
38839      * a collection in the opposite order.
38840      *
38841      * @static
38842      * @memberOf _
38843      * @since 2.0.0
38844      * @category Object
38845      * @param {Object} object The object to inspect.
38846      * @param {Function} [predicate=_.identity] The function invoked per iteration.
38847      * @returns {string|undefined} Returns the key of the matched element,
38848      *  else `undefined`.
38849      * @example
38850      *
38851      * var users = {
38852      *   'barney':  { 'age': 36, 'active': true },
38853      *   'fred':    { 'age': 40, 'active': false },
38854      *   'pebbles': { 'age': 1,  'active': true }
38855      * };
38856      *
38857      * _.findLastKey(users, function(o) { return o.age < 40; });
38858      * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
38859      *
38860      * // The `_.matches` iteratee shorthand.
38861      * _.findLastKey(users, { 'age': 36, 'active': true });
38862      * // => 'barney'
38863      *
38864      * // The `_.matchesProperty` iteratee shorthand.
38865      * _.findLastKey(users, ['active', false]);
38866      * // => 'fred'
38867      *
38868      * // The `_.property` iteratee shorthand.
38869      * _.findLastKey(users, 'active');
38870      * // => 'pebbles'
38871      */
38872     function findLastKey(object, predicate) {
38873       return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
38874     }
38875
38876     /**
38877      * Iterates over own and inherited enumerable string keyed properties of an
38878      * object and invokes `iteratee` for each property. The iteratee is invoked
38879      * with three arguments: (value, key, object). Iteratee functions may exit
38880      * iteration early by explicitly returning `false`.
38881      *
38882      * @static
38883      * @memberOf _
38884      * @since 0.3.0
38885      * @category Object
38886      * @param {Object} object The object to iterate over.
38887      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38888      * @returns {Object} Returns `object`.
38889      * @see _.forInRight
38890      * @example
38891      *
38892      * function Foo() {
38893      *   this.a = 1;
38894      *   this.b = 2;
38895      * }
38896      *
38897      * Foo.prototype.c = 3;
38898      *
38899      * _.forIn(new Foo, function(value, key) {
38900      *   console.log(key);
38901      * });
38902      * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
38903      */
38904     function forIn(object, iteratee) {
38905       return object == null
38906         ? object
38907         : baseFor(object, getIteratee(iteratee, 3), keysIn);
38908     }
38909
38910     /**
38911      * This method is like `_.forIn` except that it iterates over properties of
38912      * `object` in the opposite order.
38913      *
38914      * @static
38915      * @memberOf _
38916      * @since 2.0.0
38917      * @category Object
38918      * @param {Object} object The object to iterate over.
38919      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38920      * @returns {Object} Returns `object`.
38921      * @see _.forIn
38922      * @example
38923      *
38924      * function Foo() {
38925      *   this.a = 1;
38926      *   this.b = 2;
38927      * }
38928      *
38929      * Foo.prototype.c = 3;
38930      *
38931      * _.forInRight(new Foo, function(value, key) {
38932      *   console.log(key);
38933      * });
38934      * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
38935      */
38936     function forInRight(object, iteratee) {
38937       return object == null
38938         ? object
38939         : baseForRight(object, getIteratee(iteratee, 3), keysIn);
38940     }
38941
38942     /**
38943      * Iterates over own enumerable string keyed properties of an object and
38944      * invokes `iteratee` for each property. The iteratee is invoked with three
38945      * arguments: (value, key, object). Iteratee functions may exit iteration
38946      * early by explicitly returning `false`.
38947      *
38948      * @static
38949      * @memberOf _
38950      * @since 0.3.0
38951      * @category Object
38952      * @param {Object} object The object to iterate over.
38953      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38954      * @returns {Object} Returns `object`.
38955      * @see _.forOwnRight
38956      * @example
38957      *
38958      * function Foo() {
38959      *   this.a = 1;
38960      *   this.b = 2;
38961      * }
38962      *
38963      * Foo.prototype.c = 3;
38964      *
38965      * _.forOwn(new Foo, function(value, key) {
38966      *   console.log(key);
38967      * });
38968      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
38969      */
38970     function forOwn(object, iteratee) {
38971       return object && baseForOwn(object, getIteratee(iteratee, 3));
38972     }
38973
38974     /**
38975      * This method is like `_.forOwn` except that it iterates over properties of
38976      * `object` in the opposite order.
38977      *
38978      * @static
38979      * @memberOf _
38980      * @since 2.0.0
38981      * @category Object
38982      * @param {Object} object The object to iterate over.
38983      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
38984      * @returns {Object} Returns `object`.
38985      * @see _.forOwn
38986      * @example
38987      *
38988      * function Foo() {
38989      *   this.a = 1;
38990      *   this.b = 2;
38991      * }
38992      *
38993      * Foo.prototype.c = 3;
38994      *
38995      * _.forOwnRight(new Foo, function(value, key) {
38996      *   console.log(key);
38997      * });
38998      * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
38999      */
39000     function forOwnRight(object, iteratee) {
39001       return object && baseForOwnRight(object, getIteratee(iteratee, 3));
39002     }
39003
39004     /**
39005      * Creates an array of function property names from own enumerable properties
39006      * of `object`.
39007      *
39008      * @static
39009      * @since 0.1.0
39010      * @memberOf _
39011      * @category Object
39012      * @param {Object} object The object to inspect.
39013      * @returns {Array} Returns the function names.
39014      * @see _.functionsIn
39015      * @example
39016      *
39017      * function Foo() {
39018      *   this.a = _.constant('a');
39019      *   this.b = _.constant('b');
39020      * }
39021      *
39022      * Foo.prototype.c = _.constant('c');
39023      *
39024      * _.functions(new Foo);
39025      * // => ['a', 'b']
39026      */
39027     function functions(object) {
39028       return object == null ? [] : baseFunctions(object, keys(object));
39029     }
39030
39031     /**
39032      * Creates an array of function property names from own and inherited
39033      * enumerable properties of `object`.
39034      *
39035      * @static
39036      * @memberOf _
39037      * @since 4.0.0
39038      * @category Object
39039      * @param {Object} object The object to inspect.
39040      * @returns {Array} Returns the function names.
39041      * @see _.functions
39042      * @example
39043      *
39044      * function Foo() {
39045      *   this.a = _.constant('a');
39046      *   this.b = _.constant('b');
39047      * }
39048      *
39049      * Foo.prototype.c = _.constant('c');
39050      *
39051      * _.functionsIn(new Foo);
39052      * // => ['a', 'b', 'c']
39053      */
39054     function functionsIn(object) {
39055       return object == null ? [] : baseFunctions(object, keysIn(object));
39056     }
39057
39058     /**
39059      * Gets the value at `path` of `object`. If the resolved value is
39060      * `undefined`, the `defaultValue` is returned in its place.
39061      *
39062      * @static
39063      * @memberOf _
39064      * @since 3.7.0
39065      * @category Object
39066      * @param {Object} object The object to query.
39067      * @param {Array|string} path The path of the property to get.
39068      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
39069      * @returns {*} Returns the resolved value.
39070      * @example
39071      *
39072      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
39073      *
39074      * _.get(object, 'a[0].b.c');
39075      * // => 3
39076      *
39077      * _.get(object, ['a', '0', 'b', 'c']);
39078      * // => 3
39079      *
39080      * _.get(object, 'a.b.c', 'default');
39081      * // => 'default'
39082      */
39083     function get(object, path, defaultValue) {
39084       var result = object == null ? undefined : baseGet(object, path);
39085       return result === undefined ? defaultValue : result;
39086     }
39087
39088     /**
39089      * Checks if `path` is a direct property of `object`.
39090      *
39091      * @static
39092      * @since 0.1.0
39093      * @memberOf _
39094      * @category Object
39095      * @param {Object} object The object to query.
39096      * @param {Array|string} path The path to check.
39097      * @returns {boolean} Returns `true` if `path` exists, else `false`.
39098      * @example
39099      *
39100      * var object = { 'a': { 'b': 2 } };
39101      * var other = _.create({ 'a': _.create({ 'b': 2 }) });
39102      *
39103      * _.has(object, 'a');
39104      * // => true
39105      *
39106      * _.has(object, 'a.b');
39107      * // => true
39108      *
39109      * _.has(object, ['a', 'b']);
39110      * // => true
39111      *
39112      * _.has(other, 'a');
39113      * // => false
39114      */
39115     function has(object, path) {
39116       return object != null && hasPath(object, path, baseHas);
39117     }
39118
39119     /**
39120      * Checks if `path` is a direct or inherited property of `object`.
39121      *
39122      * @static
39123      * @memberOf _
39124      * @since 4.0.0
39125      * @category Object
39126      * @param {Object} object The object to query.
39127      * @param {Array|string} path The path to check.
39128      * @returns {boolean} Returns `true` if `path` exists, else `false`.
39129      * @example
39130      *
39131      * var object = _.create({ 'a': _.create({ 'b': 2 }) });
39132      *
39133      * _.hasIn(object, 'a');
39134      * // => true
39135      *
39136      * _.hasIn(object, 'a.b');
39137      * // => true
39138      *
39139      * _.hasIn(object, ['a', 'b']);
39140      * // => true
39141      *
39142      * _.hasIn(object, 'b');
39143      * // => false
39144      */
39145     function hasIn(object, path) {
39146       return object != null && hasPath(object, path, baseHasIn);
39147     }
39148
39149     /**
39150      * Creates an object composed of the inverted keys and values of `object`.
39151      * If `object` contains duplicate values, subsequent values overwrite
39152      * property assignments of previous values.
39153      *
39154      * @static
39155      * @memberOf _
39156      * @since 0.7.0
39157      * @category Object
39158      * @param {Object} object The object to invert.
39159      * @returns {Object} Returns the new inverted object.
39160      * @example
39161      *
39162      * var object = { 'a': 1, 'b': 2, 'c': 1 };
39163      *
39164      * _.invert(object);
39165      * // => { '1': 'c', '2': 'b' }
39166      */
39167     var invert = createInverter(function(result, value, key) {
39168       if (value != null &&
39169           typeof value.toString != 'function') {
39170         value = nativeObjectToString.call(value);
39171       }
39172
39173       result[value] = key;
39174     }, constant(identity));
39175
39176     /**
39177      * This method is like `_.invert` except that the inverted object is generated
39178      * from the results of running each element of `object` thru `iteratee`. The
39179      * corresponding inverted value of each inverted key is an array of keys
39180      * responsible for generating the inverted value. The iteratee is invoked
39181      * with one argument: (value).
39182      *
39183      * @static
39184      * @memberOf _
39185      * @since 4.1.0
39186      * @category Object
39187      * @param {Object} object The object to invert.
39188      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
39189      * @returns {Object} Returns the new inverted object.
39190      * @example
39191      *
39192      * var object = { 'a': 1, 'b': 2, 'c': 1 };
39193      *
39194      * _.invertBy(object);
39195      * // => { '1': ['a', 'c'], '2': ['b'] }
39196      *
39197      * _.invertBy(object, function(value) {
39198      *   return 'group' + value;
39199      * });
39200      * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
39201      */
39202     var invertBy = createInverter(function(result, value, key) {
39203       if (value != null &&
39204           typeof value.toString != 'function') {
39205         value = nativeObjectToString.call(value);
39206       }
39207
39208       if (hasOwnProperty.call(result, value)) {
39209         result[value].push(key);
39210       } else {
39211         result[value] = [key];
39212       }
39213     }, getIteratee);
39214
39215     /**
39216      * Invokes the method at `path` of `object`.
39217      *
39218      * @static
39219      * @memberOf _
39220      * @since 4.0.0
39221      * @category Object
39222      * @param {Object} object The object to query.
39223      * @param {Array|string} path The path of the method to invoke.
39224      * @param {...*} [args] The arguments to invoke the method with.
39225      * @returns {*} Returns the result of the invoked method.
39226      * @example
39227      *
39228      * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
39229      *
39230      * _.invoke(object, 'a[0].b.c.slice', 1, 3);
39231      * // => [2, 3]
39232      */
39233     var invoke = baseRest(baseInvoke);
39234
39235     /**
39236      * Creates an array of the own enumerable property names of `object`.
39237      *
39238      * **Note:** Non-object values are coerced to objects. See the
39239      * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
39240      * for more details.
39241      *
39242      * @static
39243      * @since 0.1.0
39244      * @memberOf _
39245      * @category Object
39246      * @param {Object} object The object to query.
39247      * @returns {Array} Returns the array of property names.
39248      * @example
39249      *
39250      * function Foo() {
39251      *   this.a = 1;
39252      *   this.b = 2;
39253      * }
39254      *
39255      * Foo.prototype.c = 3;
39256      *
39257      * _.keys(new Foo);
39258      * // => ['a', 'b'] (iteration order is not guaranteed)
39259      *
39260      * _.keys('hi');
39261      * // => ['0', '1']
39262      */
39263     function keys(object) {
39264       return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
39265     }
39266
39267     /**
39268      * Creates an array of the own and inherited enumerable property names of `object`.
39269      *
39270      * **Note:** Non-object values are coerced to objects.
39271      *
39272      * @static
39273      * @memberOf _
39274      * @since 3.0.0
39275      * @category Object
39276      * @param {Object} object The object to query.
39277      * @returns {Array} Returns the array of property names.
39278      * @example
39279      *
39280      * function Foo() {
39281      *   this.a = 1;
39282      *   this.b = 2;
39283      * }
39284      *
39285      * Foo.prototype.c = 3;
39286      *
39287      * _.keysIn(new Foo);
39288      * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
39289      */
39290     function keysIn(object) {
39291       return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
39292     }
39293
39294     /**
39295      * The opposite of `_.mapValues`; this method creates an object with the
39296      * same values as `object` and keys generated by running each own enumerable
39297      * string keyed property of `object` thru `iteratee`. The iteratee is invoked
39298      * with three arguments: (value, key, object).
39299      *
39300      * @static
39301      * @memberOf _
39302      * @since 3.8.0
39303      * @category Object
39304      * @param {Object} object The object to iterate over.
39305      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39306      * @returns {Object} Returns the new mapped object.
39307      * @see _.mapValues
39308      * @example
39309      *
39310      * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
39311      *   return key + value;
39312      * });
39313      * // => { 'a1': 1, 'b2': 2 }
39314      */
39315     function mapKeys(object, iteratee) {
39316       var result = {};
39317       iteratee = getIteratee(iteratee, 3);
39318
39319       baseForOwn(object, function(value, key, object) {
39320         baseAssignValue(result, iteratee(value, key, object), value);
39321       });
39322       return result;
39323     }
39324
39325     /**
39326      * Creates an object with the same keys as `object` and values generated
39327      * by running each own enumerable string keyed property of `object` thru
39328      * `iteratee`. The iteratee is invoked with three arguments:
39329      * (value, key, object).
39330      *
39331      * @static
39332      * @memberOf _
39333      * @since 2.4.0
39334      * @category Object
39335      * @param {Object} object The object to iterate over.
39336      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39337      * @returns {Object} Returns the new mapped object.
39338      * @see _.mapKeys
39339      * @example
39340      *
39341      * var users = {
39342      *   'fred':    { 'user': 'fred',    'age': 40 },
39343      *   'pebbles': { 'user': 'pebbles', 'age': 1 }
39344      * };
39345      *
39346      * _.mapValues(users, function(o) { return o.age; });
39347      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
39348      *
39349      * // The `_.property` iteratee shorthand.
39350      * _.mapValues(users, 'age');
39351      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
39352      */
39353     function mapValues(object, iteratee) {
39354       var result = {};
39355       iteratee = getIteratee(iteratee, 3);
39356
39357       baseForOwn(object, function(value, key, object) {
39358         baseAssignValue(result, key, iteratee(value, key, object));
39359       });
39360       return result;
39361     }
39362
39363     /**
39364      * This method is like `_.assign` except that it recursively merges own and
39365      * inherited enumerable string keyed properties of source objects into the
39366      * destination object. Source properties that resolve to `undefined` are
39367      * skipped if a destination value exists. Array and plain object properties
39368      * are merged recursively. Other objects and value types are overridden by
39369      * assignment. Source objects are applied from left to right. Subsequent
39370      * sources overwrite property assignments of previous sources.
39371      *
39372      * **Note:** This method mutates `object`.
39373      *
39374      * @static
39375      * @memberOf _
39376      * @since 0.5.0
39377      * @category Object
39378      * @param {Object} object The destination object.
39379      * @param {...Object} [sources] The source objects.
39380      * @returns {Object} Returns `object`.
39381      * @example
39382      *
39383      * var object = {
39384      *   'a': [{ 'b': 2 }, { 'd': 4 }]
39385      * };
39386      *
39387      * var other = {
39388      *   'a': [{ 'c': 3 }, { 'e': 5 }]
39389      * };
39390      *
39391      * _.merge(object, other);
39392      * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
39393      */
39394     var merge = createAssigner(function(object, source, srcIndex) {
39395       baseMerge(object, source, srcIndex);
39396     });
39397
39398     /**
39399      * This method is like `_.merge` except that it accepts `customizer` which
39400      * is invoked to produce the merged values of the destination and source
39401      * properties. If `customizer` returns `undefined`, merging is handled by the
39402      * method instead. The `customizer` is invoked with six arguments:
39403      * (objValue, srcValue, key, object, source, stack).
39404      *
39405      * **Note:** This method mutates `object`.
39406      *
39407      * @static
39408      * @memberOf _
39409      * @since 4.0.0
39410      * @category Object
39411      * @param {Object} object The destination object.
39412      * @param {...Object} sources The source objects.
39413      * @param {Function} customizer The function to customize assigned values.
39414      * @returns {Object} Returns `object`.
39415      * @example
39416      *
39417      * function customizer(objValue, srcValue) {
39418      *   if (_.isArray(objValue)) {
39419      *     return objValue.concat(srcValue);
39420      *   }
39421      * }
39422      *
39423      * var object = { 'a': [1], 'b': [2] };
39424      * var other = { 'a': [3], 'b': [4] };
39425      *
39426      * _.mergeWith(object, other, customizer);
39427      * // => { 'a': [1, 3], 'b': [2, 4] }
39428      */
39429     var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
39430       baseMerge(object, source, srcIndex, customizer);
39431     });
39432
39433     /**
39434      * The opposite of `_.pick`; this method creates an object composed of the
39435      * own and inherited enumerable property paths of `object` that are not omitted.
39436      *
39437      * **Note:** This method is considerably slower than `_.pick`.
39438      *
39439      * @static
39440      * @since 0.1.0
39441      * @memberOf _
39442      * @category Object
39443      * @param {Object} object The source object.
39444      * @param {...(string|string[])} [paths] The property paths to omit.
39445      * @returns {Object} Returns the new object.
39446      * @example
39447      *
39448      * var object = { 'a': 1, 'b': '2', 'c': 3 };
39449      *
39450      * _.omit(object, ['a', 'c']);
39451      * // => { 'b': '2' }
39452      */
39453     var omit = flatRest(function(object, paths) {
39454       var result = {};
39455       if (object == null) {
39456         return result;
39457       }
39458       var isDeep = false;
39459       paths = arrayMap(paths, function(path) {
39460         path = castPath(path, object);
39461         isDeep || (isDeep = path.length > 1);
39462         return path;
39463       });
39464       copyObject(object, getAllKeysIn(object), result);
39465       if (isDeep) {
39466         result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
39467       }
39468       var length = paths.length;
39469       while (length--) {
39470         baseUnset(result, paths[length]);
39471       }
39472       return result;
39473     });
39474
39475     /**
39476      * The opposite of `_.pickBy`; this method creates an object composed of
39477      * the own and inherited enumerable string keyed properties of `object` that
39478      * `predicate` doesn't return truthy for. The predicate is invoked with two
39479      * arguments: (value, key).
39480      *
39481      * @static
39482      * @memberOf _
39483      * @since 4.0.0
39484      * @category Object
39485      * @param {Object} object The source object.
39486      * @param {Function} [predicate=_.identity] The function invoked per property.
39487      * @returns {Object} Returns the new object.
39488      * @example
39489      *
39490      * var object = { 'a': 1, 'b': '2', 'c': 3 };
39491      *
39492      * _.omitBy(object, _.isNumber);
39493      * // => { 'b': '2' }
39494      */
39495     function omitBy(object, predicate) {
39496       return pickBy(object, negate(getIteratee(predicate)));
39497     }
39498
39499     /**
39500      * Creates an object composed of the picked `object` properties.
39501      *
39502      * @static
39503      * @since 0.1.0
39504      * @memberOf _
39505      * @category Object
39506      * @param {Object} object The source object.
39507      * @param {...(string|string[])} [paths] The property paths to pick.
39508      * @returns {Object} Returns the new object.
39509      * @example
39510      *
39511      * var object = { 'a': 1, 'b': '2', 'c': 3 };
39512      *
39513      * _.pick(object, ['a', 'c']);
39514      * // => { 'a': 1, 'c': 3 }
39515      */
39516     var pick = flatRest(function(object, paths) {
39517       return object == null ? {} : basePick(object, paths);
39518     });
39519
39520     /**
39521      * Creates an object composed of the `object` properties `predicate` returns
39522      * truthy for. The predicate is invoked with two arguments: (value, key).
39523      *
39524      * @static
39525      * @memberOf _
39526      * @since 4.0.0
39527      * @category Object
39528      * @param {Object} object The source object.
39529      * @param {Function} [predicate=_.identity] The function invoked per property.
39530      * @returns {Object} Returns the new object.
39531      * @example
39532      *
39533      * var object = { 'a': 1, 'b': '2', 'c': 3 };
39534      *
39535      * _.pickBy(object, _.isNumber);
39536      * // => { 'a': 1, 'c': 3 }
39537      */
39538     function pickBy(object, predicate) {
39539       if (object == null) {
39540         return {};
39541       }
39542       var props = arrayMap(getAllKeysIn(object), function(prop) {
39543         return [prop];
39544       });
39545       predicate = getIteratee(predicate);
39546       return basePickBy(object, props, function(value, path) {
39547         return predicate(value, path[0]);
39548       });
39549     }
39550
39551     /**
39552      * This method is like `_.get` except that if the resolved value is a
39553      * function it's invoked with the `this` binding of its parent object and
39554      * its result is returned.
39555      *
39556      * @static
39557      * @since 0.1.0
39558      * @memberOf _
39559      * @category Object
39560      * @param {Object} object The object to query.
39561      * @param {Array|string} path The path of the property to resolve.
39562      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
39563      * @returns {*} Returns the resolved value.
39564      * @example
39565      *
39566      * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
39567      *
39568      * _.result(object, 'a[0].b.c1');
39569      * // => 3
39570      *
39571      * _.result(object, 'a[0].b.c2');
39572      * // => 4
39573      *
39574      * _.result(object, 'a[0].b.c3', 'default');
39575      * // => 'default'
39576      *
39577      * _.result(object, 'a[0].b.c3', _.constant('default'));
39578      * // => 'default'
39579      */
39580     function result(object, path, defaultValue) {
39581       path = castPath(path, object);
39582
39583       var index = -1,
39584           length = path.length;
39585
39586       // Ensure the loop is entered when path is empty.
39587       if (!length) {
39588         length = 1;
39589         object = undefined;
39590       }
39591       while (++index < length) {
39592         var value = object == null ? undefined : object[toKey(path[index])];
39593         if (value === undefined) {
39594           index = length;
39595           value = defaultValue;
39596         }
39597         object = isFunction(value) ? value.call(object) : value;
39598       }
39599       return object;
39600     }
39601
39602     /**
39603      * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
39604      * it's created. Arrays are created for missing index properties while objects
39605      * are created for all other missing properties. Use `_.setWith` to customize
39606      * `path` creation.
39607      *
39608      * **Note:** This method mutates `object`.
39609      *
39610      * @static
39611      * @memberOf _
39612      * @since 3.7.0
39613      * @category Object
39614      * @param {Object} object The object to modify.
39615      * @param {Array|string} path The path of the property to set.
39616      * @param {*} value The value to set.
39617      * @returns {Object} Returns `object`.
39618      * @example
39619      *
39620      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
39621      *
39622      * _.set(object, 'a[0].b.c', 4);
39623      * console.log(object.a[0].b.c);
39624      * // => 4
39625      *
39626      * _.set(object, ['x', '0', 'y', 'z'], 5);
39627      * console.log(object.x[0].y.z);
39628      * // => 5
39629      */
39630     function set(object, path, value) {
39631       return object == null ? object : baseSet(object, path, value);
39632     }
39633
39634     /**
39635      * This method is like `_.set` except that it accepts `customizer` which is
39636      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
39637      * path creation is handled by the method instead. The `customizer` is invoked
39638      * with three arguments: (nsValue, key, nsObject).
39639      *
39640      * **Note:** This method mutates `object`.
39641      *
39642      * @static
39643      * @memberOf _
39644      * @since 4.0.0
39645      * @category Object
39646      * @param {Object} object The object to modify.
39647      * @param {Array|string} path The path of the property to set.
39648      * @param {*} value The value to set.
39649      * @param {Function} [customizer] The function to customize assigned values.
39650      * @returns {Object} Returns `object`.
39651      * @example
39652      *
39653      * var object = {};
39654      *
39655      * _.setWith(object, '[0][1]', 'a', Object);
39656      * // => { '0': { '1': 'a' } }
39657      */
39658     function setWith(object, path, value, customizer) {
39659       customizer = typeof customizer == 'function' ? customizer : undefined;
39660       return object == null ? object : baseSet(object, path, value, customizer);
39661     }
39662
39663     /**
39664      * Creates an array of own enumerable string keyed-value pairs for `object`
39665      * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
39666      * entries are returned.
39667      *
39668      * @static
39669      * @memberOf _
39670      * @since 4.0.0
39671      * @alias entries
39672      * @category Object
39673      * @param {Object} object The object to query.
39674      * @returns {Array} Returns the key-value pairs.
39675      * @example
39676      *
39677      * function Foo() {
39678      *   this.a = 1;
39679      *   this.b = 2;
39680      * }
39681      *
39682      * Foo.prototype.c = 3;
39683      *
39684      * _.toPairs(new Foo);
39685      * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
39686      */
39687     var toPairs = createToPairs(keys);
39688
39689     /**
39690      * Creates an array of own and inherited enumerable string keyed-value pairs
39691      * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
39692      * or set, its entries are returned.
39693      *
39694      * @static
39695      * @memberOf _
39696      * @since 4.0.0
39697      * @alias entriesIn
39698      * @category Object
39699      * @param {Object} object The object to query.
39700      * @returns {Array} Returns the key-value pairs.
39701      * @example
39702      *
39703      * function Foo() {
39704      *   this.a = 1;
39705      *   this.b = 2;
39706      * }
39707      *
39708      * Foo.prototype.c = 3;
39709      *
39710      * _.toPairsIn(new Foo);
39711      * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
39712      */
39713     var toPairsIn = createToPairs(keysIn);
39714
39715     /**
39716      * An alternative to `_.reduce`; this method transforms `object` to a new
39717      * `accumulator` object which is the result of running each of its own
39718      * enumerable string keyed properties thru `iteratee`, with each invocation
39719      * potentially mutating the `accumulator` object. If `accumulator` is not
39720      * provided, a new object with the same `[[Prototype]]` will be used. The
39721      * iteratee is invoked with four arguments: (accumulator, value, key, object).
39722      * Iteratee functions may exit iteration early by explicitly returning `false`.
39723      *
39724      * @static
39725      * @memberOf _
39726      * @since 1.3.0
39727      * @category Object
39728      * @param {Object} object The object to iterate over.
39729      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39730      * @param {*} [accumulator] The custom accumulator value.
39731      * @returns {*} Returns the accumulated value.
39732      * @example
39733      *
39734      * _.transform([2, 3, 4], function(result, n) {
39735      *   result.push(n *= n);
39736      *   return n % 2 == 0;
39737      * }, []);
39738      * // => [4, 9]
39739      *
39740      * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
39741      *   (result[value] || (result[value] = [])).push(key);
39742      * }, {});
39743      * // => { '1': ['a', 'c'], '2': ['b'] }
39744      */
39745     function transform(object, iteratee, accumulator) {
39746       var isArr = isArray(object),
39747           isArrLike = isArr || isBuffer(object) || isTypedArray(object);
39748
39749       iteratee = getIteratee(iteratee, 4);
39750       if (accumulator == null) {
39751         var Ctor = object && object.constructor;
39752         if (isArrLike) {
39753           accumulator = isArr ? new Ctor : [];
39754         }
39755         else if (isObject(object)) {
39756           accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
39757         }
39758         else {
39759           accumulator = {};
39760         }
39761       }
39762       (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
39763         return iteratee(accumulator, value, index, object);
39764       });
39765       return accumulator;
39766     }
39767
39768     /**
39769      * Removes the property at `path` of `object`.
39770      *
39771      * **Note:** This method mutates `object`.
39772      *
39773      * @static
39774      * @memberOf _
39775      * @since 4.0.0
39776      * @category Object
39777      * @param {Object} object The object to modify.
39778      * @param {Array|string} path The path of the property to unset.
39779      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
39780      * @example
39781      *
39782      * var object = { 'a': [{ 'b': { 'c': 7 } }] };
39783      * _.unset(object, 'a[0].b.c');
39784      * // => true
39785      *
39786      * console.log(object);
39787      * // => { 'a': [{ 'b': {} }] };
39788      *
39789      * _.unset(object, ['a', '0', 'b', 'c']);
39790      * // => true
39791      *
39792      * console.log(object);
39793      * // => { 'a': [{ 'b': {} }] };
39794      */
39795     function unset(object, path) {
39796       return object == null ? true : baseUnset(object, path);
39797     }
39798
39799     /**
39800      * This method is like `_.set` except that accepts `updater` to produce the
39801      * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
39802      * is invoked with one argument: (value).
39803      *
39804      * **Note:** This method mutates `object`.
39805      *
39806      * @static
39807      * @memberOf _
39808      * @since 4.6.0
39809      * @category Object
39810      * @param {Object} object The object to modify.
39811      * @param {Array|string} path The path of the property to set.
39812      * @param {Function} updater The function to produce the updated value.
39813      * @returns {Object} Returns `object`.
39814      * @example
39815      *
39816      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
39817      *
39818      * _.update(object, 'a[0].b.c', function(n) { return n * n; });
39819      * console.log(object.a[0].b.c);
39820      * // => 9
39821      *
39822      * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
39823      * console.log(object.x[0].y.z);
39824      * // => 0
39825      */
39826     function update(object, path, updater) {
39827       return object == null ? object : baseUpdate(object, path, castFunction(updater));
39828     }
39829
39830     /**
39831      * This method is like `_.update` except that it accepts `customizer` which is
39832      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
39833      * path creation is handled by the method instead. The `customizer` is invoked
39834      * with three arguments: (nsValue, key, nsObject).
39835      *
39836      * **Note:** This method mutates `object`.
39837      *
39838      * @static
39839      * @memberOf _
39840      * @since 4.6.0
39841      * @category Object
39842      * @param {Object} object The object to modify.
39843      * @param {Array|string} path The path of the property to set.
39844      * @param {Function} updater The function to produce the updated value.
39845      * @param {Function} [customizer] The function to customize assigned values.
39846      * @returns {Object} Returns `object`.
39847      * @example
39848      *
39849      * var object = {};
39850      *
39851      * _.updateWith(object, '[0][1]', _.constant('a'), Object);
39852      * // => { '0': { '1': 'a' } }
39853      */
39854     function updateWith(object, path, updater, customizer) {
39855       customizer = typeof customizer == 'function' ? customizer : undefined;
39856       return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
39857     }
39858
39859     /**
39860      * Creates an array of the own enumerable string keyed property values of `object`.
39861      *
39862      * **Note:** Non-object values are coerced to objects.
39863      *
39864      * @static
39865      * @since 0.1.0
39866      * @memberOf _
39867      * @category Object
39868      * @param {Object} object The object to query.
39869      * @returns {Array} Returns the array of property values.
39870      * @example
39871      *
39872      * function Foo() {
39873      *   this.a = 1;
39874      *   this.b = 2;
39875      * }
39876      *
39877      * Foo.prototype.c = 3;
39878      *
39879      * _.values(new Foo);
39880      * // => [1, 2] (iteration order is not guaranteed)
39881      *
39882      * _.values('hi');
39883      * // => ['h', 'i']
39884      */
39885     function values(object) {
39886       return object == null ? [] : baseValues(object, keys(object));
39887     }
39888
39889     /**
39890      * Creates an array of the own and inherited enumerable string keyed property
39891      * values of `object`.
39892      *
39893      * **Note:** Non-object values are coerced to objects.
39894      *
39895      * @static
39896      * @memberOf _
39897      * @since 3.0.0
39898      * @category Object
39899      * @param {Object} object The object to query.
39900      * @returns {Array} Returns the array of property values.
39901      * @example
39902      *
39903      * function Foo() {
39904      *   this.a = 1;
39905      *   this.b = 2;
39906      * }
39907      *
39908      * Foo.prototype.c = 3;
39909      *
39910      * _.valuesIn(new Foo);
39911      * // => [1, 2, 3] (iteration order is not guaranteed)
39912      */
39913     function valuesIn(object) {
39914       return object == null ? [] : baseValues(object, keysIn(object));
39915     }
39916
39917     /*------------------------------------------------------------------------*/
39918
39919     /**
39920      * Clamps `number` within the inclusive `lower` and `upper` bounds.
39921      *
39922      * @static
39923      * @memberOf _
39924      * @since 4.0.0
39925      * @category Number
39926      * @param {number} number The number to clamp.
39927      * @param {number} [lower] The lower bound.
39928      * @param {number} upper The upper bound.
39929      * @returns {number} Returns the clamped number.
39930      * @example
39931      *
39932      * _.clamp(-10, -5, 5);
39933      * // => -5
39934      *
39935      * _.clamp(10, -5, 5);
39936      * // => 5
39937      */
39938     function clamp(number, lower, upper) {
39939       if (upper === undefined) {
39940         upper = lower;
39941         lower = undefined;
39942       }
39943       if (upper !== undefined) {
39944         upper = toNumber(upper);
39945         upper = upper === upper ? upper : 0;
39946       }
39947       if (lower !== undefined) {
39948         lower = toNumber(lower);
39949         lower = lower === lower ? lower : 0;
39950       }
39951       return baseClamp(toNumber(number), lower, upper);
39952     }
39953
39954     /**
39955      * Checks if `n` is between `start` and up to, but not including, `end`. If
39956      * `end` is not specified, it's set to `start` with `start` then set to `0`.
39957      * If `start` is greater than `end` the params are swapped to support
39958      * negative ranges.
39959      *
39960      * @static
39961      * @memberOf _
39962      * @since 3.3.0
39963      * @category Number
39964      * @param {number} number The number to check.
39965      * @param {number} [start=0] The start of the range.
39966      * @param {number} end The end of the range.
39967      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
39968      * @see _.range, _.rangeRight
39969      * @example
39970      *
39971      * _.inRange(3, 2, 4);
39972      * // => true
39973      *
39974      * _.inRange(4, 8);
39975      * // => true
39976      *
39977      * _.inRange(4, 2);
39978      * // => false
39979      *
39980      * _.inRange(2, 2);
39981      * // => false
39982      *
39983      * _.inRange(1.2, 2);
39984      * // => true
39985      *
39986      * _.inRange(5.2, 4);
39987      * // => false
39988      *
39989      * _.inRange(-3, -2, -6);
39990      * // => true
39991      */
39992     function inRange(number, start, end) {
39993       start = toFinite(start);
39994       if (end === undefined) {
39995         end = start;
39996         start = 0;
39997       } else {
39998         end = toFinite(end);
39999       }
40000       number = toNumber(number);
40001       return baseInRange(number, start, end);
40002     }
40003
40004     /**
40005      * Produces a random number between the inclusive `lower` and `upper` bounds.
40006      * If only one argument is provided a number between `0` and the given number
40007      * is returned. If `floating` is `true`, or either `lower` or `upper` are
40008      * floats, a floating-point number is returned instead of an integer.
40009      *
40010      * **Note:** JavaScript follows the IEEE-754 standard for resolving
40011      * floating-point values which can produce unexpected results.
40012      *
40013      * @static
40014      * @memberOf _
40015      * @since 0.7.0
40016      * @category Number
40017      * @param {number} [lower=0] The lower bound.
40018      * @param {number} [upper=1] The upper bound.
40019      * @param {boolean} [floating] Specify returning a floating-point number.
40020      * @returns {number} Returns the random number.
40021      * @example
40022      *
40023      * _.random(0, 5);
40024      * // => an integer between 0 and 5
40025      *
40026      * _.random(5);
40027      * // => also an integer between 0 and 5
40028      *
40029      * _.random(5, true);
40030      * // => a floating-point number between 0 and 5
40031      *
40032      * _.random(1.2, 5.2);
40033      * // => a floating-point number between 1.2 and 5.2
40034      */
40035     function random(lower, upper, floating) {
40036       if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
40037         upper = floating = undefined;
40038       }
40039       if (floating === undefined) {
40040         if (typeof upper == 'boolean') {
40041           floating = upper;
40042           upper = undefined;
40043         }
40044         else if (typeof lower == 'boolean') {
40045           floating = lower;
40046           lower = undefined;
40047         }
40048       }
40049       if (lower === undefined && upper === undefined) {
40050         lower = 0;
40051         upper = 1;
40052       }
40053       else {
40054         lower = toFinite(lower);
40055         if (upper === undefined) {
40056           upper = lower;
40057           lower = 0;
40058         } else {
40059           upper = toFinite(upper);
40060         }
40061       }
40062       if (lower > upper) {
40063         var temp = lower;
40064         lower = upper;
40065         upper = temp;
40066       }
40067       if (floating || lower % 1 || upper % 1) {
40068         var rand = nativeRandom();
40069         return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
40070       }
40071       return baseRandom(lower, upper);
40072     }
40073
40074     /*------------------------------------------------------------------------*/
40075
40076     /**
40077      * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
40078      *
40079      * @static
40080      * @memberOf _
40081      * @since 3.0.0
40082      * @category String
40083      * @param {string} [string=''] The string to convert.
40084      * @returns {string} Returns the camel cased string.
40085      * @example
40086      *
40087      * _.camelCase('Foo Bar');
40088      * // => 'fooBar'
40089      *
40090      * _.camelCase('--foo-bar--');
40091      * // => 'fooBar'
40092      *
40093      * _.camelCase('__FOO_BAR__');
40094      * // => 'fooBar'
40095      */
40096     var camelCase = createCompounder(function(result, word, index) {
40097       word = word.toLowerCase();
40098       return result + (index ? capitalize(word) : word);
40099     });
40100
40101     /**
40102      * Converts the first character of `string` to upper case and the remaining
40103      * to lower case.
40104      *
40105      * @static
40106      * @memberOf _
40107      * @since 3.0.0
40108      * @category String
40109      * @param {string} [string=''] The string to capitalize.
40110      * @returns {string} Returns the capitalized string.
40111      * @example
40112      *
40113      * _.capitalize('FRED');
40114      * // => 'Fred'
40115      */
40116     function capitalize(string) {
40117       return upperFirst(toString(string).toLowerCase());
40118     }
40119
40120     /**
40121      * Deburrs `string` by converting
40122      * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
40123      * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
40124      * letters to basic Latin letters and removing
40125      * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
40126      *
40127      * @static
40128      * @memberOf _
40129      * @since 3.0.0
40130      * @category String
40131      * @param {string} [string=''] The string to deburr.
40132      * @returns {string} Returns the deburred string.
40133      * @example
40134      *
40135      * _.deburr('déjà vu');
40136      * // => 'deja vu'
40137      */
40138     function deburr(string) {
40139       string = toString(string);
40140       return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
40141     }
40142
40143     /**
40144      * Checks if `string` ends with the given target string.
40145      *
40146      * @static
40147      * @memberOf _
40148      * @since 3.0.0
40149      * @category String
40150      * @param {string} [string=''] The string to inspect.
40151      * @param {string} [target] The string to search for.
40152      * @param {number} [position=string.length] The position to search up to.
40153      * @returns {boolean} Returns `true` if `string` ends with `target`,
40154      *  else `false`.
40155      * @example
40156      *
40157      * _.endsWith('abc', 'c');
40158      * // => true
40159      *
40160      * _.endsWith('abc', 'b');
40161      * // => false
40162      *
40163      * _.endsWith('abc', 'b', 2);
40164      * // => true
40165      */
40166     function endsWith(string, target, position) {
40167       string = toString(string);
40168       target = baseToString(target);
40169
40170       var length = string.length;
40171       position = position === undefined
40172         ? length
40173         : baseClamp(toInteger(position), 0, length);
40174
40175       var end = position;
40176       position -= target.length;
40177       return position >= 0 && string.slice(position, end) == target;
40178     }
40179
40180     /**
40181      * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
40182      * corresponding HTML entities.
40183      *
40184      * **Note:** No other characters are escaped. To escape additional
40185      * characters use a third-party library like [_he_](https://mths.be/he).
40186      *
40187      * Though the ">" character is escaped for symmetry, characters like
40188      * ">" and "/" don't need escaping in HTML and have no special meaning
40189      * unless they're part of a tag or unquoted attribute value. See
40190      * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
40191      * (under "semi-related fun fact") for more details.
40192      *
40193      * When working with HTML you should always
40194      * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
40195      * XSS vectors.
40196      *
40197      * @static
40198      * @since 0.1.0
40199      * @memberOf _
40200      * @category String
40201      * @param {string} [string=''] The string to escape.
40202      * @returns {string} Returns the escaped string.
40203      * @example
40204      *
40205      * _.escape('fred, barney, & pebbles');
40206      * // => 'fred, barney, &amp; pebbles'
40207      */
40208     function escape(string) {
40209       string = toString(string);
40210       return (string && reHasUnescapedHtml.test(string))
40211         ? string.replace(reUnescapedHtml, escapeHtmlChar)
40212         : string;
40213     }
40214
40215     /**
40216      * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
40217      * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
40218      *
40219      * @static
40220      * @memberOf _
40221      * @since 3.0.0
40222      * @category String
40223      * @param {string} [string=''] The string to escape.
40224      * @returns {string} Returns the escaped string.
40225      * @example
40226      *
40227      * _.escapeRegExp('[lodash](https://lodash.com/)');
40228      * // => '\[lodash\]\(https://lodash\.com/\)'
40229      */
40230     function escapeRegExp(string) {
40231       string = toString(string);
40232       return (string && reHasRegExpChar.test(string))
40233         ? string.replace(reRegExpChar, '\\$&')
40234         : string;
40235     }
40236
40237     /**
40238      * Converts `string` to
40239      * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
40240      *
40241      * @static
40242      * @memberOf _
40243      * @since 3.0.0
40244      * @category String
40245      * @param {string} [string=''] The string to convert.
40246      * @returns {string} Returns the kebab cased string.
40247      * @example
40248      *
40249      * _.kebabCase('Foo Bar');
40250      * // => 'foo-bar'
40251      *
40252      * _.kebabCase('fooBar');
40253      * // => 'foo-bar'
40254      *
40255      * _.kebabCase('__FOO_BAR__');
40256      * // => 'foo-bar'
40257      */
40258     var kebabCase = createCompounder(function(result, word, index) {
40259       return result + (index ? '-' : '') + word.toLowerCase();
40260     });
40261
40262     /**
40263      * Converts `string`, as space separated words, to lower case.
40264      *
40265      * @static
40266      * @memberOf _
40267      * @since 4.0.0
40268      * @category String
40269      * @param {string} [string=''] The string to convert.
40270      * @returns {string} Returns the lower cased string.
40271      * @example
40272      *
40273      * _.lowerCase('--Foo-Bar--');
40274      * // => 'foo bar'
40275      *
40276      * _.lowerCase('fooBar');
40277      * // => 'foo bar'
40278      *
40279      * _.lowerCase('__FOO_BAR__');
40280      * // => 'foo bar'
40281      */
40282     var lowerCase = createCompounder(function(result, word, index) {
40283       return result + (index ? ' ' : '') + word.toLowerCase();
40284     });
40285
40286     /**
40287      * Converts the first character of `string` to lower case.
40288      *
40289      * @static
40290      * @memberOf _
40291      * @since 4.0.0
40292      * @category String
40293      * @param {string} [string=''] The string to convert.
40294      * @returns {string} Returns the converted string.
40295      * @example
40296      *
40297      * _.lowerFirst('Fred');
40298      * // => 'fred'
40299      *
40300      * _.lowerFirst('FRED');
40301      * // => 'fRED'
40302      */
40303     var lowerFirst = createCaseFirst('toLowerCase');
40304
40305     /**
40306      * Pads `string` on the left and right sides if it's shorter than `length`.
40307      * Padding characters are truncated if they can't be evenly divided by `length`.
40308      *
40309      * @static
40310      * @memberOf _
40311      * @since 3.0.0
40312      * @category String
40313      * @param {string} [string=''] The string to pad.
40314      * @param {number} [length=0] The padding length.
40315      * @param {string} [chars=' '] The string used as padding.
40316      * @returns {string} Returns the padded string.
40317      * @example
40318      *
40319      * _.pad('abc', 8);
40320      * // => '  abc   '
40321      *
40322      * _.pad('abc', 8, '_-');
40323      * // => '_-abc_-_'
40324      *
40325      * _.pad('abc', 3);
40326      * // => 'abc'
40327      */
40328     function pad(string, length, chars) {
40329       string = toString(string);
40330       length = toInteger(length);
40331
40332       var strLength = length ? stringSize(string) : 0;
40333       if (!length || strLength >= length) {
40334         return string;
40335       }
40336       var mid = (length - strLength) / 2;
40337       return (
40338         createPadding(nativeFloor(mid), chars) +
40339         string +
40340         createPadding(nativeCeil(mid), chars)
40341       );
40342     }
40343
40344     /**
40345      * Pads `string` on the right side if it's shorter than `length`. Padding
40346      * characters are truncated if they exceed `length`.
40347      *
40348      * @static
40349      * @memberOf _
40350      * @since 4.0.0
40351      * @category String
40352      * @param {string} [string=''] The string to pad.
40353      * @param {number} [length=0] The padding length.
40354      * @param {string} [chars=' '] The string used as padding.
40355      * @returns {string} Returns the padded string.
40356      * @example
40357      *
40358      * _.padEnd('abc', 6);
40359      * // => 'abc   '
40360      *
40361      * _.padEnd('abc', 6, '_-');
40362      * // => 'abc_-_'
40363      *
40364      * _.padEnd('abc', 3);
40365      * // => 'abc'
40366      */
40367     function padEnd(string, length, chars) {
40368       string = toString(string);
40369       length = toInteger(length);
40370
40371       var strLength = length ? stringSize(string) : 0;
40372       return (length && strLength < length)
40373         ? (string + createPadding(length - strLength, chars))
40374         : string;
40375     }
40376
40377     /**
40378      * Pads `string` on the left side if it's shorter than `length`. Padding
40379      * characters are truncated if they exceed `length`.
40380      *
40381      * @static
40382      * @memberOf _
40383      * @since 4.0.0
40384      * @category String
40385      * @param {string} [string=''] The string to pad.
40386      * @param {number} [length=0] The padding length.
40387      * @param {string} [chars=' '] The string used as padding.
40388      * @returns {string} Returns the padded string.
40389      * @example
40390      *
40391      * _.padStart('abc', 6);
40392      * // => '   abc'
40393      *
40394      * _.padStart('abc', 6, '_-');
40395      * // => '_-_abc'
40396      *
40397      * _.padStart('abc', 3);
40398      * // => 'abc'
40399      */
40400     function padStart(string, length, chars) {
40401       string = toString(string);
40402       length = toInteger(length);
40403
40404       var strLength = length ? stringSize(string) : 0;
40405       return (length && strLength < length)
40406         ? (createPadding(length - strLength, chars) + string)
40407         : string;
40408     }
40409
40410     /**
40411      * Converts `string` to an integer of the specified radix. If `radix` is
40412      * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
40413      * hexadecimal, in which case a `radix` of `16` is used.
40414      *
40415      * **Note:** This method aligns with the
40416      * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
40417      *
40418      * @static
40419      * @memberOf _
40420      * @since 1.1.0
40421      * @category String
40422      * @param {string} string The string to convert.
40423      * @param {number} [radix=10] The radix to interpret `value` by.
40424      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40425      * @returns {number} Returns the converted integer.
40426      * @example
40427      *
40428      * _.parseInt('08');
40429      * // => 8
40430      *
40431      * _.map(['6', '08', '10'], _.parseInt);
40432      * // => [6, 8, 10]
40433      */
40434     function parseInt(string, radix, guard) {
40435       if (guard || radix == null) {
40436         radix = 0;
40437       } else if (radix) {
40438         radix = +radix;
40439       }
40440       return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
40441     }
40442
40443     /**
40444      * Repeats the given string `n` times.
40445      *
40446      * @static
40447      * @memberOf _
40448      * @since 3.0.0
40449      * @category String
40450      * @param {string} [string=''] The string to repeat.
40451      * @param {number} [n=1] The number of times to repeat the string.
40452      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40453      * @returns {string} Returns the repeated string.
40454      * @example
40455      *
40456      * _.repeat('*', 3);
40457      * // => '***'
40458      *
40459      * _.repeat('abc', 2);
40460      * // => 'abcabc'
40461      *
40462      * _.repeat('abc', 0);
40463      * // => ''
40464      */
40465     function repeat(string, n, guard) {
40466       if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
40467         n = 1;
40468       } else {
40469         n = toInteger(n);
40470       }
40471       return baseRepeat(toString(string), n);
40472     }
40473
40474     /**
40475      * Replaces matches for `pattern` in `string` with `replacement`.
40476      *
40477      * **Note:** This method is based on
40478      * [`String#replace`](https://mdn.io/String/replace).
40479      *
40480      * @static
40481      * @memberOf _
40482      * @since 4.0.0
40483      * @category String
40484      * @param {string} [string=''] The string to modify.
40485      * @param {RegExp|string} pattern The pattern to replace.
40486      * @param {Function|string} replacement The match replacement.
40487      * @returns {string} Returns the modified string.
40488      * @example
40489      *
40490      * _.replace('Hi Fred', 'Fred', 'Barney');
40491      * // => 'Hi Barney'
40492      */
40493     function replace() {
40494       var args = arguments,
40495           string = toString(args[0]);
40496
40497       return args.length < 3 ? string : string.replace(args[1], args[2]);
40498     }
40499
40500     /**
40501      * Converts `string` to
40502      * [snake case](https://en.wikipedia.org/wiki/Snake_case).
40503      *
40504      * @static
40505      * @memberOf _
40506      * @since 3.0.0
40507      * @category String
40508      * @param {string} [string=''] The string to convert.
40509      * @returns {string} Returns the snake cased string.
40510      * @example
40511      *
40512      * _.snakeCase('Foo Bar');
40513      * // => 'foo_bar'
40514      *
40515      * _.snakeCase('fooBar');
40516      * // => 'foo_bar'
40517      *
40518      * _.snakeCase('--FOO-BAR--');
40519      * // => 'foo_bar'
40520      */
40521     var snakeCase = createCompounder(function(result, word, index) {
40522       return result + (index ? '_' : '') + word.toLowerCase();
40523     });
40524
40525     /**
40526      * Splits `string` by `separator`.
40527      *
40528      * **Note:** This method is based on
40529      * [`String#split`](https://mdn.io/String/split).
40530      *
40531      * @static
40532      * @memberOf _
40533      * @since 4.0.0
40534      * @category String
40535      * @param {string} [string=''] The string to split.
40536      * @param {RegExp|string} separator The separator pattern to split by.
40537      * @param {number} [limit] The length to truncate results to.
40538      * @returns {Array} Returns the string segments.
40539      * @example
40540      *
40541      * _.split('a-b-c', '-', 2);
40542      * // => ['a', 'b']
40543      */
40544     function split(string, separator, limit) {
40545       if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
40546         separator = limit = undefined;
40547       }
40548       limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
40549       if (!limit) {
40550         return [];
40551       }
40552       string = toString(string);
40553       if (string && (
40554             typeof separator == 'string' ||
40555             (separator != null && !isRegExp(separator))
40556           )) {
40557         separator = baseToString(separator);
40558         if (!separator && hasUnicode(string)) {
40559           return castSlice(stringToArray(string), 0, limit);
40560         }
40561       }
40562       return string.split(separator, limit);
40563     }
40564
40565     /**
40566      * Converts `string` to
40567      * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
40568      *
40569      * @static
40570      * @memberOf _
40571      * @since 3.1.0
40572      * @category String
40573      * @param {string} [string=''] The string to convert.
40574      * @returns {string} Returns the start cased string.
40575      * @example
40576      *
40577      * _.startCase('--foo-bar--');
40578      * // => 'Foo Bar'
40579      *
40580      * _.startCase('fooBar');
40581      * // => 'Foo Bar'
40582      *
40583      * _.startCase('__FOO_BAR__');
40584      * // => 'FOO BAR'
40585      */
40586     var startCase = createCompounder(function(result, word, index) {
40587       return result + (index ? ' ' : '') + upperFirst(word);
40588     });
40589
40590     /**
40591      * Checks if `string` starts with the given target string.
40592      *
40593      * @static
40594      * @memberOf _
40595      * @since 3.0.0
40596      * @category String
40597      * @param {string} [string=''] The string to inspect.
40598      * @param {string} [target] The string to search for.
40599      * @param {number} [position=0] The position to search from.
40600      * @returns {boolean} Returns `true` if `string` starts with `target`,
40601      *  else `false`.
40602      * @example
40603      *
40604      * _.startsWith('abc', 'a');
40605      * // => true
40606      *
40607      * _.startsWith('abc', 'b');
40608      * // => false
40609      *
40610      * _.startsWith('abc', 'b', 1);
40611      * // => true
40612      */
40613     function startsWith(string, target, position) {
40614       string = toString(string);
40615       position = position == null
40616         ? 0
40617         : baseClamp(toInteger(position), 0, string.length);
40618
40619       target = baseToString(target);
40620       return string.slice(position, position + target.length) == target;
40621     }
40622
40623     /**
40624      * Creates a compiled template function that can interpolate data properties
40625      * in "interpolate" delimiters, HTML-escape interpolated data properties in
40626      * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
40627      * properties may be accessed as free variables in the template. If a setting
40628      * object is given, it takes precedence over `_.templateSettings` values.
40629      *
40630      * **Note:** In the development build `_.template` utilizes
40631      * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
40632      * for easier debugging.
40633      *
40634      * For more information on precompiling templates see
40635      * [lodash's custom builds documentation](https://lodash.com/custom-builds).
40636      *
40637      * For more information on Chrome extension sandboxes see
40638      * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
40639      *
40640      * @static
40641      * @since 0.1.0
40642      * @memberOf _
40643      * @category String
40644      * @param {string} [string=''] The template string.
40645      * @param {Object} [options={}] The options object.
40646      * @param {RegExp} [options.escape=_.templateSettings.escape]
40647      *  The HTML "escape" delimiter.
40648      * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
40649      *  The "evaluate" delimiter.
40650      * @param {Object} [options.imports=_.templateSettings.imports]
40651      *  An object to import into the template as free variables.
40652      * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
40653      *  The "interpolate" delimiter.
40654      * @param {string} [options.sourceURL='lodash.templateSources[n]']
40655      *  The sourceURL of the compiled template.
40656      * @param {string} [options.variable='obj']
40657      *  The data object variable name.
40658      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40659      * @returns {Function} Returns the compiled template function.
40660      * @example
40661      *
40662      * // Use the "interpolate" delimiter to create a compiled template.
40663      * var compiled = _.template('hello <%= user %>!');
40664      * compiled({ 'user': 'fred' });
40665      * // => 'hello fred!'
40666      *
40667      * // Use the HTML "escape" delimiter to escape data property values.
40668      * var compiled = _.template('<b><%- value %></b>');
40669      * compiled({ 'value': '<script>' });
40670      * // => '<b>&lt;script&gt;</b>'
40671      *
40672      * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
40673      * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
40674      * compiled({ 'users': ['fred', 'barney'] });
40675      * // => '<li>fred</li><li>barney</li>'
40676      *
40677      * // Use the internal `print` function in "evaluate" delimiters.
40678      * var compiled = _.template('<% print("hello " + user); %>!');
40679      * compiled({ 'user': 'barney' });
40680      * // => 'hello barney!'
40681      *
40682      * // Use the ES template literal delimiter as an "interpolate" delimiter.
40683      * // Disable support by replacing the "interpolate" delimiter.
40684      * var compiled = _.template('hello ${ user }!');
40685      * compiled({ 'user': 'pebbles' });
40686      * // => 'hello pebbles!'
40687      *
40688      * // Use backslashes to treat delimiters as plain text.
40689      * var compiled = _.template('<%= "\\<%- value %\\>" %>');
40690      * compiled({ 'value': 'ignored' });
40691      * // => '<%- value %>'
40692      *
40693      * // Use the `imports` option to import `jQuery` as `jq`.
40694      * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
40695      * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
40696      * compiled({ 'users': ['fred', 'barney'] });
40697      * // => '<li>fred</li><li>barney</li>'
40698      *
40699      * // Use the `sourceURL` option to specify a custom sourceURL for the template.
40700      * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
40701      * compiled(data);
40702      * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
40703      *
40704      * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
40705      * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
40706      * compiled.source;
40707      * // => function(data) {
40708      * //   var __t, __p = '';
40709      * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
40710      * //   return __p;
40711      * // }
40712      *
40713      * // Use custom template delimiters.
40714      * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
40715      * var compiled = _.template('hello {{ user }}!');
40716      * compiled({ 'user': 'mustache' });
40717      * // => 'hello mustache!'
40718      *
40719      * // Use the `source` property to inline compiled templates for meaningful
40720      * // line numbers in error messages and stack traces.
40721      * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
40722      *   var JST = {\
40723      *     "main": ' + _.template(mainText).source + '\
40724      *   };\
40725      * ');
40726      */
40727     function template(string, options, guard) {
40728       // Based on John Resig's `tmpl` implementation
40729       // (http://ejohn.org/blog/javascript-micro-templating/)
40730       // and Laura Doktorova's doT.js (https://github.com/olado/doT).
40731       var settings = lodash.templateSettings;
40732
40733       if (guard && isIterateeCall(string, options, guard)) {
40734         options = undefined;
40735       }
40736       string = toString(string);
40737       options = assignInWith({}, options, settings, customDefaultsAssignIn);
40738
40739       var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
40740           importsKeys = keys(imports),
40741           importsValues = baseValues(imports, importsKeys);
40742
40743       var isEscaping,
40744           isEvaluating,
40745           index = 0,
40746           interpolate = options.interpolate || reNoMatch,
40747           source = "__p += '";
40748
40749       // Compile the regexp to match each delimiter.
40750       var reDelimiters = RegExp(
40751         (options.escape || reNoMatch).source + '|' +
40752         interpolate.source + '|' +
40753         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
40754         (options.evaluate || reNoMatch).source + '|$'
40755       , 'g');
40756
40757       // Use a sourceURL for easier debugging.
40758       // The sourceURL gets injected into the source that's eval-ed, so be careful
40759       // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
40760       // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
40761       var sourceURL = '//# sourceURL=' +
40762         (hasOwnProperty.call(options, 'sourceURL')
40763           ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
40764           : ('lodash.templateSources[' + (++templateCounter) + ']')
40765         ) + '\n';
40766
40767       string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
40768         interpolateValue || (interpolateValue = esTemplateValue);
40769
40770         // Escape characters that can't be included in string literals.
40771         source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
40772
40773         // Replace delimiters with snippets.
40774         if (escapeValue) {
40775           isEscaping = true;
40776           source += "' +\n__e(" + escapeValue + ") +\n'";
40777         }
40778         if (evaluateValue) {
40779           isEvaluating = true;
40780           source += "';\n" + evaluateValue + ";\n__p += '";
40781         }
40782         if (interpolateValue) {
40783           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
40784         }
40785         index = offset + match.length;
40786
40787         // The JS engine embedded in Adobe products needs `match` returned in
40788         // order to produce the correct `offset` value.
40789         return match;
40790       });
40791
40792       source += "';\n";
40793
40794       // If `variable` is not specified wrap a with-statement around the generated
40795       // code to add the data object to the top of the scope chain.
40796       // Like with sourceURL, we take care to not check the option's prototype,
40797       // as this configuration is a code injection vector.
40798       var variable = hasOwnProperty.call(options, 'variable') && options.variable;
40799       if (!variable) {
40800         source = 'with (obj) {\n' + source + '\n}\n';
40801       }
40802       // Cleanup code by stripping empty strings.
40803       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
40804         .replace(reEmptyStringMiddle, '$1')
40805         .replace(reEmptyStringTrailing, '$1;');
40806
40807       // Frame code as the function body.
40808       source = 'function(' + (variable || 'obj') + ') {\n' +
40809         (variable
40810           ? ''
40811           : 'obj || (obj = {});\n'
40812         ) +
40813         "var __t, __p = ''" +
40814         (isEscaping
40815            ? ', __e = _.escape'
40816            : ''
40817         ) +
40818         (isEvaluating
40819           ? ', __j = Array.prototype.join;\n' +
40820             "function print() { __p += __j.call(arguments, '') }\n"
40821           : ';\n'
40822         ) +
40823         source +
40824         'return __p\n}';
40825
40826       var result = attempt(function() {
40827         return Function(importsKeys, sourceURL + 'return ' + source)
40828           .apply(undefined, importsValues);
40829       });
40830
40831       // Provide the compiled function's source by its `toString` method or
40832       // the `source` property as a convenience for inlining compiled templates.
40833       result.source = source;
40834       if (isError(result)) {
40835         throw result;
40836       }
40837       return result;
40838     }
40839
40840     /**
40841      * Converts `string`, as a whole, to lower case just like
40842      * [String#toLowerCase](https://mdn.io/toLowerCase).
40843      *
40844      * @static
40845      * @memberOf _
40846      * @since 4.0.0
40847      * @category String
40848      * @param {string} [string=''] The string to convert.
40849      * @returns {string} Returns the lower cased string.
40850      * @example
40851      *
40852      * _.toLower('--Foo-Bar--');
40853      * // => '--foo-bar--'
40854      *
40855      * _.toLower('fooBar');
40856      * // => 'foobar'
40857      *
40858      * _.toLower('__FOO_BAR__');
40859      * // => '__foo_bar__'
40860      */
40861     function toLower(value) {
40862       return toString(value).toLowerCase();
40863     }
40864
40865     /**
40866      * Converts `string`, as a whole, to upper case just like
40867      * [String#toUpperCase](https://mdn.io/toUpperCase).
40868      *
40869      * @static
40870      * @memberOf _
40871      * @since 4.0.0
40872      * @category String
40873      * @param {string} [string=''] The string to convert.
40874      * @returns {string} Returns the upper cased string.
40875      * @example
40876      *
40877      * _.toUpper('--foo-bar--');
40878      * // => '--FOO-BAR--'
40879      *
40880      * _.toUpper('fooBar');
40881      * // => 'FOOBAR'
40882      *
40883      * _.toUpper('__foo_bar__');
40884      * // => '__FOO_BAR__'
40885      */
40886     function toUpper(value) {
40887       return toString(value).toUpperCase();
40888     }
40889
40890     /**
40891      * Removes leading and trailing whitespace or specified characters from `string`.
40892      *
40893      * @static
40894      * @memberOf _
40895      * @since 3.0.0
40896      * @category String
40897      * @param {string} [string=''] The string to trim.
40898      * @param {string} [chars=whitespace] The characters to trim.
40899      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40900      * @returns {string} Returns the trimmed string.
40901      * @example
40902      *
40903      * _.trim('  abc  ');
40904      * // => 'abc'
40905      *
40906      * _.trim('-_-abc-_-', '_-');
40907      * // => 'abc'
40908      *
40909      * _.map(['  foo  ', '  bar  '], _.trim);
40910      * // => ['foo', 'bar']
40911      */
40912     function trim(string, chars, guard) {
40913       string = toString(string);
40914       if (string && (guard || chars === undefined)) {
40915         return string.replace(reTrim, '');
40916       }
40917       if (!string || !(chars = baseToString(chars))) {
40918         return string;
40919       }
40920       var strSymbols = stringToArray(string),
40921           chrSymbols = stringToArray(chars),
40922           start = charsStartIndex(strSymbols, chrSymbols),
40923           end = charsEndIndex(strSymbols, chrSymbols) + 1;
40924
40925       return castSlice(strSymbols, start, end).join('');
40926     }
40927
40928     /**
40929      * Removes trailing whitespace or specified characters from `string`.
40930      *
40931      * @static
40932      * @memberOf _
40933      * @since 4.0.0
40934      * @category String
40935      * @param {string} [string=''] The string to trim.
40936      * @param {string} [chars=whitespace] The characters to trim.
40937      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40938      * @returns {string} Returns the trimmed string.
40939      * @example
40940      *
40941      * _.trimEnd('  abc  ');
40942      * // => '  abc'
40943      *
40944      * _.trimEnd('-_-abc-_-', '_-');
40945      * // => '-_-abc'
40946      */
40947     function trimEnd(string, chars, guard) {
40948       string = toString(string);
40949       if (string && (guard || chars === undefined)) {
40950         return string.replace(reTrimEnd, '');
40951       }
40952       if (!string || !(chars = baseToString(chars))) {
40953         return string;
40954       }
40955       var strSymbols = stringToArray(string),
40956           end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
40957
40958       return castSlice(strSymbols, 0, end).join('');
40959     }
40960
40961     /**
40962      * Removes leading whitespace or specified characters from `string`.
40963      *
40964      * @static
40965      * @memberOf _
40966      * @since 4.0.0
40967      * @category String
40968      * @param {string} [string=''] The string to trim.
40969      * @param {string} [chars=whitespace] The characters to trim.
40970      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40971      * @returns {string} Returns the trimmed string.
40972      * @example
40973      *
40974      * _.trimStart('  abc  ');
40975      * // => 'abc  '
40976      *
40977      * _.trimStart('-_-abc-_-', '_-');
40978      * // => 'abc-_-'
40979      */
40980     function trimStart(string, chars, guard) {
40981       string = toString(string);
40982       if (string && (guard || chars === undefined)) {
40983         return string.replace(reTrimStart, '');
40984       }
40985       if (!string || !(chars = baseToString(chars))) {
40986         return string;
40987       }
40988       var strSymbols = stringToArray(string),
40989           start = charsStartIndex(strSymbols, stringToArray(chars));
40990
40991       return castSlice(strSymbols, start).join('');
40992     }
40993
40994     /**
40995      * Truncates `string` if it's longer than the given maximum string length.
40996      * The last characters of the truncated string are replaced with the omission
40997      * string which defaults to "...".
40998      *
40999      * @static
41000      * @memberOf _
41001      * @since 4.0.0
41002      * @category String
41003      * @param {string} [string=''] The string to truncate.
41004      * @param {Object} [options={}] The options object.
41005      * @param {number} [options.length=30] The maximum string length.
41006      * @param {string} [options.omission='...'] The string to indicate text is omitted.
41007      * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
41008      * @returns {string} Returns the truncated string.
41009      * @example
41010      *
41011      * _.truncate('hi-diddly-ho there, neighborino');
41012      * // => 'hi-diddly-ho there, neighbo...'
41013      *
41014      * _.truncate('hi-diddly-ho there, neighborino', {
41015      *   'length': 24,
41016      *   'separator': ' '
41017      * });
41018      * // => 'hi-diddly-ho there,...'
41019      *
41020      * _.truncate('hi-diddly-ho there, neighborino', {
41021      *   'length': 24,
41022      *   'separator': /,? +/
41023      * });
41024      * // => 'hi-diddly-ho there...'
41025      *
41026      * _.truncate('hi-diddly-ho there, neighborino', {
41027      *   'omission': ' [...]'
41028      * });
41029      * // => 'hi-diddly-ho there, neig [...]'
41030      */
41031     function truncate(string, options) {
41032       var length = DEFAULT_TRUNC_LENGTH,
41033           omission = DEFAULT_TRUNC_OMISSION;
41034
41035       if (isObject(options)) {
41036         var separator = 'separator' in options ? options.separator : separator;
41037         length = 'length' in options ? toInteger(options.length) : length;
41038         omission = 'omission' in options ? baseToString(options.omission) : omission;
41039       }
41040       string = toString(string);
41041
41042       var strLength = string.length;
41043       if (hasUnicode(string)) {
41044         var strSymbols = stringToArray(string);
41045         strLength = strSymbols.length;
41046       }
41047       if (length >= strLength) {
41048         return string;
41049       }
41050       var end = length - stringSize(omission);
41051       if (end < 1) {
41052         return omission;
41053       }
41054       var result = strSymbols
41055         ? castSlice(strSymbols, 0, end).join('')
41056         : string.slice(0, end);
41057
41058       if (separator === undefined) {
41059         return result + omission;
41060       }
41061       if (strSymbols) {
41062         end += (result.length - end);
41063       }
41064       if (isRegExp(separator)) {
41065         if (string.slice(end).search(separator)) {
41066           var match,
41067               substring = result;
41068
41069           if (!separator.global) {
41070             separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
41071           }
41072           separator.lastIndex = 0;
41073           while ((match = separator.exec(substring))) {
41074             var newEnd = match.index;
41075           }
41076           result = result.slice(0, newEnd === undefined ? end : newEnd);
41077         }
41078       } else if (string.indexOf(baseToString(separator), end) != end) {
41079         var index = result.lastIndexOf(separator);
41080         if (index > -1) {
41081           result = result.slice(0, index);
41082         }
41083       }
41084       return result + omission;
41085     }
41086
41087     /**
41088      * The inverse of `_.escape`; this method converts the HTML entities
41089      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
41090      * their corresponding characters.
41091      *
41092      * **Note:** No other HTML entities are unescaped. To unescape additional
41093      * HTML entities use a third-party library like [_he_](https://mths.be/he).
41094      *
41095      * @static
41096      * @memberOf _
41097      * @since 0.6.0
41098      * @category String
41099      * @param {string} [string=''] The string to unescape.
41100      * @returns {string} Returns the unescaped string.
41101      * @example
41102      *
41103      * _.unescape('fred, barney, &amp; pebbles');
41104      * // => 'fred, barney, & pebbles'
41105      */
41106     function unescape(string) {
41107       string = toString(string);
41108       return (string && reHasEscapedHtml.test(string))
41109         ? string.replace(reEscapedHtml, unescapeHtmlChar)
41110         : string;
41111     }
41112
41113     /**
41114      * Converts `string`, as space separated words, to upper case.
41115      *
41116      * @static
41117      * @memberOf _
41118      * @since 4.0.0
41119      * @category String
41120      * @param {string} [string=''] The string to convert.
41121      * @returns {string} Returns the upper cased string.
41122      * @example
41123      *
41124      * _.upperCase('--foo-bar');
41125      * // => 'FOO BAR'
41126      *
41127      * _.upperCase('fooBar');
41128      * // => 'FOO BAR'
41129      *
41130      * _.upperCase('__foo_bar__');
41131      * // => 'FOO BAR'
41132      */
41133     var upperCase = createCompounder(function(result, word, index) {
41134       return result + (index ? ' ' : '') + word.toUpperCase();
41135     });
41136
41137     /**
41138      * Converts the first character of `string` to upper case.
41139      *
41140      * @static
41141      * @memberOf _
41142      * @since 4.0.0
41143      * @category String
41144      * @param {string} [string=''] The string to convert.
41145      * @returns {string} Returns the converted string.
41146      * @example
41147      *
41148      * _.upperFirst('fred');
41149      * // => 'Fred'
41150      *
41151      * _.upperFirst('FRED');
41152      * // => 'FRED'
41153      */
41154     var upperFirst = createCaseFirst('toUpperCase');
41155
41156     /**
41157      * Splits `string` into an array of its words.
41158      *
41159      * @static
41160      * @memberOf _
41161      * @since 3.0.0
41162      * @category String
41163      * @param {string} [string=''] The string to inspect.
41164      * @param {RegExp|string} [pattern] The pattern to match words.
41165      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
41166      * @returns {Array} Returns the words of `string`.
41167      * @example
41168      *
41169      * _.words('fred, barney, & pebbles');
41170      * // => ['fred', 'barney', 'pebbles']
41171      *
41172      * _.words('fred, barney, & pebbles', /[^, ]+/g);
41173      * // => ['fred', 'barney', '&', 'pebbles']
41174      */
41175     function words(string, pattern, guard) {
41176       string = toString(string);
41177       pattern = guard ? undefined : pattern;
41178
41179       if (pattern === undefined) {
41180         return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
41181       }
41182       return string.match(pattern) || [];
41183     }
41184
41185     /*------------------------------------------------------------------------*/
41186
41187     /**
41188      * Attempts to invoke `func`, returning either the result or the caught error
41189      * object. Any additional arguments are provided to `func` when it's invoked.
41190      *
41191      * @static
41192      * @memberOf _
41193      * @since 3.0.0
41194      * @category Util
41195      * @param {Function} func The function to attempt.
41196      * @param {...*} [args] The arguments to invoke `func` with.
41197      * @returns {*} Returns the `func` result or error object.
41198      * @example
41199      *
41200      * // Avoid throwing errors for invalid selectors.
41201      * var elements = _.attempt(function(selector) {
41202      *   return document.querySelectorAll(selector);
41203      * }, '>_>');
41204      *
41205      * if (_.isError(elements)) {
41206      *   elements = [];
41207      * }
41208      */
41209     var attempt = baseRest(function(func, args) {
41210       try {
41211         return apply(func, undefined, args);
41212       } catch (e) {
41213         return isError(e) ? e : new Error(e);
41214       }
41215     });
41216
41217     /**
41218      * Binds methods of an object to the object itself, overwriting the existing
41219      * method.
41220      *
41221      * **Note:** This method doesn't set the "length" property of bound functions.
41222      *
41223      * @static
41224      * @since 0.1.0
41225      * @memberOf _
41226      * @category Util
41227      * @param {Object} object The object to bind and assign the bound methods to.
41228      * @param {...(string|string[])} methodNames The object method names to bind.
41229      * @returns {Object} Returns `object`.
41230      * @example
41231      *
41232      * var view = {
41233      *   'label': 'docs',
41234      *   'click': function() {
41235      *     console.log('clicked ' + this.label);
41236      *   }
41237      * };
41238      *
41239      * _.bindAll(view, ['click']);
41240      * jQuery(element).on('click', view.click);
41241      * // => Logs 'clicked docs' when clicked.
41242      */
41243     var bindAll = flatRest(function(object, methodNames) {
41244       arrayEach(methodNames, function(key) {
41245         key = toKey(key);
41246         baseAssignValue(object, key, bind(object[key], object));
41247       });
41248       return object;
41249     });
41250
41251     /**
41252      * Creates a function that iterates over `pairs` and invokes the corresponding
41253      * function of the first predicate to return truthy. The predicate-function
41254      * pairs are invoked with the `this` binding and arguments of the created
41255      * function.
41256      *
41257      * @static
41258      * @memberOf _
41259      * @since 4.0.0
41260      * @category Util
41261      * @param {Array} pairs The predicate-function pairs.
41262      * @returns {Function} Returns the new composite function.
41263      * @example
41264      *
41265      * var func = _.cond([
41266      *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
41267      *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
41268      *   [_.stubTrue,                      _.constant('no match')]
41269      * ]);
41270      *
41271      * func({ 'a': 1, 'b': 2 });
41272      * // => 'matches A'
41273      *
41274      * func({ 'a': 0, 'b': 1 });
41275      * // => 'matches B'
41276      *
41277      * func({ 'a': '1', 'b': '2' });
41278      * // => 'no match'
41279      */
41280     function cond(pairs) {
41281       var length = pairs == null ? 0 : pairs.length,
41282           toIteratee = getIteratee();
41283
41284       pairs = !length ? [] : arrayMap(pairs, function(pair) {
41285         if (typeof pair[1] != 'function') {
41286           throw new TypeError(FUNC_ERROR_TEXT);
41287         }
41288         return [toIteratee(pair[0]), pair[1]];
41289       });
41290
41291       return baseRest(function(args) {
41292         var index = -1;
41293         while (++index < length) {
41294           var pair = pairs[index];
41295           if (apply(pair[0], this, args)) {
41296             return apply(pair[1], this, args);
41297           }
41298         }
41299       });
41300     }
41301
41302     /**
41303      * Creates a function that invokes the predicate properties of `source` with
41304      * the corresponding property values of a given object, returning `true` if
41305      * all predicates return truthy, else `false`.
41306      *
41307      * **Note:** The created function is equivalent to `_.conformsTo` with
41308      * `source` partially applied.
41309      *
41310      * @static
41311      * @memberOf _
41312      * @since 4.0.0
41313      * @category Util
41314      * @param {Object} source The object of property predicates to conform to.
41315      * @returns {Function} Returns the new spec function.
41316      * @example
41317      *
41318      * var objects = [
41319      *   { 'a': 2, 'b': 1 },
41320      *   { 'a': 1, 'b': 2 }
41321      * ];
41322      *
41323      * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
41324      * // => [{ 'a': 1, 'b': 2 }]
41325      */
41326     function conforms(source) {
41327       return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
41328     }
41329
41330     /**
41331      * Creates a function that returns `value`.
41332      *
41333      * @static
41334      * @memberOf _
41335      * @since 2.4.0
41336      * @category Util
41337      * @param {*} value The value to return from the new function.
41338      * @returns {Function} Returns the new constant function.
41339      * @example
41340      *
41341      * var objects = _.times(2, _.constant({ 'a': 1 }));
41342      *
41343      * console.log(objects);
41344      * // => [{ 'a': 1 }, { 'a': 1 }]
41345      *
41346      * console.log(objects[0] === objects[1]);
41347      * // => true
41348      */
41349     function constant(value) {
41350       return function() {
41351         return value;
41352       };
41353     }
41354
41355     /**
41356      * Checks `value` to determine whether a default value should be returned in
41357      * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
41358      * or `undefined`.
41359      *
41360      * @static
41361      * @memberOf _
41362      * @since 4.14.0
41363      * @category Util
41364      * @param {*} value The value to check.
41365      * @param {*} defaultValue The default value.
41366      * @returns {*} Returns the resolved value.
41367      * @example
41368      *
41369      * _.defaultTo(1, 10);
41370      * // => 1
41371      *
41372      * _.defaultTo(undefined, 10);
41373      * // => 10
41374      */
41375     function defaultTo(value, defaultValue) {
41376       return (value == null || value !== value) ? defaultValue : value;
41377     }
41378
41379     /**
41380      * Creates a function that returns the result of invoking the given functions
41381      * with the `this` binding of the created function, where each successive
41382      * invocation is supplied the return value of the previous.
41383      *
41384      * @static
41385      * @memberOf _
41386      * @since 3.0.0
41387      * @category Util
41388      * @param {...(Function|Function[])} [funcs] The functions to invoke.
41389      * @returns {Function} Returns the new composite function.
41390      * @see _.flowRight
41391      * @example
41392      *
41393      * function square(n) {
41394      *   return n * n;
41395      * }
41396      *
41397      * var addSquare = _.flow([_.add, square]);
41398      * addSquare(1, 2);
41399      * // => 9
41400      */
41401     var flow = createFlow();
41402
41403     /**
41404      * This method is like `_.flow` except that it creates a function that
41405      * invokes the given functions from right to left.
41406      *
41407      * @static
41408      * @since 3.0.0
41409      * @memberOf _
41410      * @category Util
41411      * @param {...(Function|Function[])} [funcs] The functions to invoke.
41412      * @returns {Function} Returns the new composite function.
41413      * @see _.flow
41414      * @example
41415      *
41416      * function square(n) {
41417      *   return n * n;
41418      * }
41419      *
41420      * var addSquare = _.flowRight([square, _.add]);
41421      * addSquare(1, 2);
41422      * // => 9
41423      */
41424     var flowRight = createFlow(true);
41425
41426     /**
41427      * This method returns the first argument it receives.
41428      *
41429      * @static
41430      * @since 0.1.0
41431      * @memberOf _
41432      * @category Util
41433      * @param {*} value Any value.
41434      * @returns {*} Returns `value`.
41435      * @example
41436      *
41437      * var object = { 'a': 1 };
41438      *
41439      * console.log(_.identity(object) === object);
41440      * // => true
41441      */
41442     function identity(value) {
41443       return value;
41444     }
41445
41446     /**
41447      * Creates a function that invokes `func` with the arguments of the created
41448      * function. If `func` is a property name, the created function returns the
41449      * property value for a given element. If `func` is an array or object, the
41450      * created function returns `true` for elements that contain the equivalent
41451      * source properties, otherwise it returns `false`.
41452      *
41453      * @static
41454      * @since 4.0.0
41455      * @memberOf _
41456      * @category Util
41457      * @param {*} [func=_.identity] The value to convert to a callback.
41458      * @returns {Function} Returns the callback.
41459      * @example
41460      *
41461      * var users = [
41462      *   { 'user': 'barney', 'age': 36, 'active': true },
41463      *   { 'user': 'fred',   'age': 40, 'active': false }
41464      * ];
41465      *
41466      * // The `_.matches` iteratee shorthand.
41467      * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
41468      * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
41469      *
41470      * // The `_.matchesProperty` iteratee shorthand.
41471      * _.filter(users, _.iteratee(['user', 'fred']));
41472      * // => [{ 'user': 'fred', 'age': 40 }]
41473      *
41474      * // The `_.property` iteratee shorthand.
41475      * _.map(users, _.iteratee('user'));
41476      * // => ['barney', 'fred']
41477      *
41478      * // Create custom iteratee shorthands.
41479      * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
41480      *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
41481      *     return func.test(string);
41482      *   };
41483      * });
41484      *
41485      * _.filter(['abc', 'def'], /ef/);
41486      * // => ['def']
41487      */
41488     function iteratee(func) {
41489       return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
41490     }
41491
41492     /**
41493      * Creates a function that performs a partial deep comparison between a given
41494      * object and `source`, returning `true` if the given object has equivalent
41495      * property values, else `false`.
41496      *
41497      * **Note:** The created function is equivalent to `_.isMatch` with `source`
41498      * partially applied.
41499      *
41500      * Partial comparisons will match empty array and empty object `source`
41501      * values against any array or object value, respectively. See `_.isEqual`
41502      * for a list of supported value comparisons.
41503      *
41504      * @static
41505      * @memberOf _
41506      * @since 3.0.0
41507      * @category Util
41508      * @param {Object} source The object of property values to match.
41509      * @returns {Function} Returns the new spec function.
41510      * @example
41511      *
41512      * var objects = [
41513      *   { 'a': 1, 'b': 2, 'c': 3 },
41514      *   { 'a': 4, 'b': 5, 'c': 6 }
41515      * ];
41516      *
41517      * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
41518      * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
41519      */
41520     function matches(source) {
41521       return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
41522     }
41523
41524     /**
41525      * Creates a function that performs a partial deep comparison between the
41526      * value at `path` of a given object to `srcValue`, returning `true` if the
41527      * object value is equivalent, else `false`.
41528      *
41529      * **Note:** Partial comparisons will match empty array and empty object
41530      * `srcValue` values against any array or object value, respectively. See
41531      * `_.isEqual` for a list of supported value comparisons.
41532      *
41533      * @static
41534      * @memberOf _
41535      * @since 3.2.0
41536      * @category Util
41537      * @param {Array|string} path The path of the property to get.
41538      * @param {*} srcValue The value to match.
41539      * @returns {Function} Returns the new spec function.
41540      * @example
41541      *
41542      * var objects = [
41543      *   { 'a': 1, 'b': 2, 'c': 3 },
41544      *   { 'a': 4, 'b': 5, 'c': 6 }
41545      * ];
41546      *
41547      * _.find(objects, _.matchesProperty('a', 4));
41548      * // => { 'a': 4, 'b': 5, 'c': 6 }
41549      */
41550     function matchesProperty(path, srcValue) {
41551       return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
41552     }
41553
41554     /**
41555      * Creates a function that invokes the method at `path` of a given object.
41556      * Any additional arguments are provided to the invoked method.
41557      *
41558      * @static
41559      * @memberOf _
41560      * @since 3.7.0
41561      * @category Util
41562      * @param {Array|string} path The path of the method to invoke.
41563      * @param {...*} [args] The arguments to invoke the method with.
41564      * @returns {Function} Returns the new invoker function.
41565      * @example
41566      *
41567      * var objects = [
41568      *   { 'a': { 'b': _.constant(2) } },
41569      *   { 'a': { 'b': _.constant(1) } }
41570      * ];
41571      *
41572      * _.map(objects, _.method('a.b'));
41573      * // => [2, 1]
41574      *
41575      * _.map(objects, _.method(['a', 'b']));
41576      * // => [2, 1]
41577      */
41578     var method = baseRest(function(path, args) {
41579       return function(object) {
41580         return baseInvoke(object, path, args);
41581       };
41582     });
41583
41584     /**
41585      * The opposite of `_.method`; this method creates a function that invokes
41586      * the method at a given path of `object`. Any additional arguments are
41587      * provided to the invoked method.
41588      *
41589      * @static
41590      * @memberOf _
41591      * @since 3.7.0
41592      * @category Util
41593      * @param {Object} object The object to query.
41594      * @param {...*} [args] The arguments to invoke the method with.
41595      * @returns {Function} Returns the new invoker function.
41596      * @example
41597      *
41598      * var array = _.times(3, _.constant),
41599      *     object = { 'a': array, 'b': array, 'c': array };
41600      *
41601      * _.map(['a[2]', 'c[0]'], _.methodOf(object));
41602      * // => [2, 0]
41603      *
41604      * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
41605      * // => [2, 0]
41606      */
41607     var methodOf = baseRest(function(object, args) {
41608       return function(path) {
41609         return baseInvoke(object, path, args);
41610       };
41611     });
41612
41613     /**
41614      * Adds all own enumerable string keyed function properties of a source
41615      * object to the destination object. If `object` is a function, then methods
41616      * are added to its prototype as well.
41617      *
41618      * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
41619      * avoid conflicts caused by modifying the original.
41620      *
41621      * @static
41622      * @since 0.1.0
41623      * @memberOf _
41624      * @category Util
41625      * @param {Function|Object} [object=lodash] The destination object.
41626      * @param {Object} source The object of functions to add.
41627      * @param {Object} [options={}] The options object.
41628      * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
41629      * @returns {Function|Object} Returns `object`.
41630      * @example
41631      *
41632      * function vowels(string) {
41633      *   return _.filter(string, function(v) {
41634      *     return /[aeiou]/i.test(v);
41635      *   });
41636      * }
41637      *
41638      * _.mixin({ 'vowels': vowels });
41639      * _.vowels('fred');
41640      * // => ['e']
41641      *
41642      * _('fred').vowels().value();
41643      * // => ['e']
41644      *
41645      * _.mixin({ 'vowels': vowels }, { 'chain': false });
41646      * _('fred').vowels();
41647      * // => ['e']
41648      */
41649     function mixin(object, source, options) {
41650       var props = keys(source),
41651           methodNames = baseFunctions(source, props);
41652
41653       if (options == null &&
41654           !(isObject(source) && (methodNames.length || !props.length))) {
41655         options = source;
41656         source = object;
41657         object = this;
41658         methodNames = baseFunctions(source, keys(source));
41659       }
41660       var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
41661           isFunc = isFunction(object);
41662
41663       arrayEach(methodNames, function(methodName) {
41664         var func = source[methodName];
41665         object[methodName] = func;
41666         if (isFunc) {
41667           object.prototype[methodName] = function() {
41668             var chainAll = this.__chain__;
41669             if (chain || chainAll) {
41670               var result = object(this.__wrapped__),
41671                   actions = result.__actions__ = copyArray(this.__actions__);
41672
41673               actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
41674               result.__chain__ = chainAll;
41675               return result;
41676             }
41677             return func.apply(object, arrayPush([this.value()], arguments));
41678           };
41679         }
41680       });
41681
41682       return object;
41683     }
41684
41685     /**
41686      * Reverts the `_` variable to its previous value and returns a reference to
41687      * the `lodash` function.
41688      *
41689      * @static
41690      * @since 0.1.0
41691      * @memberOf _
41692      * @category Util
41693      * @returns {Function} Returns the `lodash` function.
41694      * @example
41695      *
41696      * var lodash = _.noConflict();
41697      */
41698     function noConflict() {
41699       if (root._ === this) {
41700         root._ = oldDash;
41701       }
41702       return this;
41703     }
41704
41705     /**
41706      * This method returns `undefined`.
41707      *
41708      * @static
41709      * @memberOf _
41710      * @since 2.3.0
41711      * @category Util
41712      * @example
41713      *
41714      * _.times(2, _.noop);
41715      * // => [undefined, undefined]
41716      */
41717     function noop() {
41718       // No operation performed.
41719     }
41720
41721     /**
41722      * Creates a function that gets the argument at index `n`. If `n` is negative,
41723      * the nth argument from the end is returned.
41724      *
41725      * @static
41726      * @memberOf _
41727      * @since 4.0.0
41728      * @category Util
41729      * @param {number} [n=0] The index of the argument to return.
41730      * @returns {Function} Returns the new pass-thru function.
41731      * @example
41732      *
41733      * var func = _.nthArg(1);
41734      * func('a', 'b', 'c', 'd');
41735      * // => 'b'
41736      *
41737      * var func = _.nthArg(-2);
41738      * func('a', 'b', 'c', 'd');
41739      * // => 'c'
41740      */
41741     function nthArg(n) {
41742       n = toInteger(n);
41743       return baseRest(function(args) {
41744         return baseNth(args, n);
41745       });
41746     }
41747
41748     /**
41749      * Creates a function that invokes `iteratees` with the arguments it receives
41750      * and returns their results.
41751      *
41752      * @static
41753      * @memberOf _
41754      * @since 4.0.0
41755      * @category Util
41756      * @param {...(Function|Function[])} [iteratees=[_.identity]]
41757      *  The iteratees to invoke.
41758      * @returns {Function} Returns the new function.
41759      * @example
41760      *
41761      * var func = _.over([Math.max, Math.min]);
41762      *
41763      * func(1, 2, 3, 4);
41764      * // => [4, 1]
41765      */
41766     var over = createOver(arrayMap);
41767
41768     /**
41769      * Creates a function that checks if **all** of the `predicates` return
41770      * truthy when invoked with the arguments it receives.
41771      *
41772      * @static
41773      * @memberOf _
41774      * @since 4.0.0
41775      * @category Util
41776      * @param {...(Function|Function[])} [predicates=[_.identity]]
41777      *  The predicates to check.
41778      * @returns {Function} Returns the new function.
41779      * @example
41780      *
41781      * var func = _.overEvery([Boolean, isFinite]);
41782      *
41783      * func('1');
41784      * // => true
41785      *
41786      * func(null);
41787      * // => false
41788      *
41789      * func(NaN);
41790      * // => false
41791      */
41792     var overEvery = createOver(arrayEvery);
41793
41794     /**
41795      * Creates a function that checks if **any** of the `predicates` return
41796      * truthy when invoked with the arguments it receives.
41797      *
41798      * @static
41799      * @memberOf _
41800      * @since 4.0.0
41801      * @category Util
41802      * @param {...(Function|Function[])} [predicates=[_.identity]]
41803      *  The predicates to check.
41804      * @returns {Function} Returns the new function.
41805      * @example
41806      *
41807      * var func = _.overSome([Boolean, isFinite]);
41808      *
41809      * func('1');
41810      * // => true
41811      *
41812      * func(null);
41813      * // => true
41814      *
41815      * func(NaN);
41816      * // => false
41817      */
41818     var overSome = createOver(arraySome);
41819
41820     /**
41821      * Creates a function that returns the value at `path` of a given object.
41822      *
41823      * @static
41824      * @memberOf _
41825      * @since 2.4.0
41826      * @category Util
41827      * @param {Array|string} path The path of the property to get.
41828      * @returns {Function} Returns the new accessor function.
41829      * @example
41830      *
41831      * var objects = [
41832      *   { 'a': { 'b': 2 } },
41833      *   { 'a': { 'b': 1 } }
41834      * ];
41835      *
41836      * _.map(objects, _.property('a.b'));
41837      * // => [2, 1]
41838      *
41839      * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
41840      * // => [1, 2]
41841      */
41842     function property(path) {
41843       return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
41844     }
41845
41846     /**
41847      * The opposite of `_.property`; this method creates a function that returns
41848      * the value at a given path of `object`.
41849      *
41850      * @static
41851      * @memberOf _
41852      * @since 3.0.0
41853      * @category Util
41854      * @param {Object} object The object to query.
41855      * @returns {Function} Returns the new accessor function.
41856      * @example
41857      *
41858      * var array = [0, 1, 2],
41859      *     object = { 'a': array, 'b': array, 'c': array };
41860      *
41861      * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
41862      * // => [2, 0]
41863      *
41864      * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
41865      * // => [2, 0]
41866      */
41867     function propertyOf(object) {
41868       return function(path) {
41869         return object == null ? undefined : baseGet(object, path);
41870       };
41871     }
41872
41873     /**
41874      * Creates an array of numbers (positive and/or negative) progressing from
41875      * `start` up to, but not including, `end`. A step of `-1` is used if a negative
41876      * `start` is specified without an `end` or `step`. If `end` is not specified,
41877      * it's set to `start` with `start` then set to `0`.
41878      *
41879      * **Note:** JavaScript follows the IEEE-754 standard for resolving
41880      * floating-point values which can produce unexpected results.
41881      *
41882      * @static
41883      * @since 0.1.0
41884      * @memberOf _
41885      * @category Util
41886      * @param {number} [start=0] The start of the range.
41887      * @param {number} end The end of the range.
41888      * @param {number} [step=1] The value to increment or decrement by.
41889      * @returns {Array} Returns the range of numbers.
41890      * @see _.inRange, _.rangeRight
41891      * @example
41892      *
41893      * _.range(4);
41894      * // => [0, 1, 2, 3]
41895      *
41896      * _.range(-4);
41897      * // => [0, -1, -2, -3]
41898      *
41899      * _.range(1, 5);
41900      * // => [1, 2, 3, 4]
41901      *
41902      * _.range(0, 20, 5);
41903      * // => [0, 5, 10, 15]
41904      *
41905      * _.range(0, -4, -1);
41906      * // => [0, -1, -2, -3]
41907      *
41908      * _.range(1, 4, 0);
41909      * // => [1, 1, 1]
41910      *
41911      * _.range(0);
41912      * // => []
41913      */
41914     var range = createRange();
41915
41916     /**
41917      * This method is like `_.range` except that it populates values in
41918      * descending order.
41919      *
41920      * @static
41921      * @memberOf _
41922      * @since 4.0.0
41923      * @category Util
41924      * @param {number} [start=0] The start of the range.
41925      * @param {number} end The end of the range.
41926      * @param {number} [step=1] The value to increment or decrement by.
41927      * @returns {Array} Returns the range of numbers.
41928      * @see _.inRange, _.range
41929      * @example
41930      *
41931      * _.rangeRight(4);
41932      * // => [3, 2, 1, 0]
41933      *
41934      * _.rangeRight(-4);
41935      * // => [-3, -2, -1, 0]
41936      *
41937      * _.rangeRight(1, 5);
41938      * // => [4, 3, 2, 1]
41939      *
41940      * _.rangeRight(0, 20, 5);
41941      * // => [15, 10, 5, 0]
41942      *
41943      * _.rangeRight(0, -4, -1);
41944      * // => [-3, -2, -1, 0]
41945      *
41946      * _.rangeRight(1, 4, 0);
41947      * // => [1, 1, 1]
41948      *
41949      * _.rangeRight(0);
41950      * // => []
41951      */
41952     var rangeRight = createRange(true);
41953
41954     /**
41955      * This method returns a new empty array.
41956      *
41957      * @static
41958      * @memberOf _
41959      * @since 4.13.0
41960      * @category Util
41961      * @returns {Array} Returns the new empty array.
41962      * @example
41963      *
41964      * var arrays = _.times(2, _.stubArray);
41965      *
41966      * console.log(arrays);
41967      * // => [[], []]
41968      *
41969      * console.log(arrays[0] === arrays[1]);
41970      * // => false
41971      */
41972     function stubArray() {
41973       return [];
41974     }
41975
41976     /**
41977      * This method returns `false`.
41978      *
41979      * @static
41980      * @memberOf _
41981      * @since 4.13.0
41982      * @category Util
41983      * @returns {boolean} Returns `false`.
41984      * @example
41985      *
41986      * _.times(2, _.stubFalse);
41987      * // => [false, false]
41988      */
41989     function stubFalse() {
41990       return false;
41991     }
41992
41993     /**
41994      * This method returns a new empty object.
41995      *
41996      * @static
41997      * @memberOf _
41998      * @since 4.13.0
41999      * @category Util
42000      * @returns {Object} Returns the new empty object.
42001      * @example
42002      *
42003      * var objects = _.times(2, _.stubObject);
42004      *
42005      * console.log(objects);
42006      * // => [{}, {}]
42007      *
42008      * console.log(objects[0] === objects[1]);
42009      * // => false
42010      */
42011     function stubObject() {
42012       return {};
42013     }
42014
42015     /**
42016      * This method returns an empty string.
42017      *
42018      * @static
42019      * @memberOf _
42020      * @since 4.13.0
42021      * @category Util
42022      * @returns {string} Returns the empty string.
42023      * @example
42024      *
42025      * _.times(2, _.stubString);
42026      * // => ['', '']
42027      */
42028     function stubString() {
42029       return '';
42030     }
42031
42032     /**
42033      * This method returns `true`.
42034      *
42035      * @static
42036      * @memberOf _
42037      * @since 4.13.0
42038      * @category Util
42039      * @returns {boolean} Returns `true`.
42040      * @example
42041      *
42042      * _.times(2, _.stubTrue);
42043      * // => [true, true]
42044      */
42045     function stubTrue() {
42046       return true;
42047     }
42048
42049     /**
42050      * Invokes the iteratee `n` times, returning an array of the results of
42051      * each invocation. The iteratee is invoked with one argument; (index).
42052      *
42053      * @static
42054      * @since 0.1.0
42055      * @memberOf _
42056      * @category Util
42057      * @param {number} n The number of times to invoke `iteratee`.
42058      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
42059      * @returns {Array} Returns the array of results.
42060      * @example
42061      *
42062      * _.times(3, String);
42063      * // => ['0', '1', '2']
42064      *
42065      *  _.times(4, _.constant(0));
42066      * // => [0, 0, 0, 0]
42067      */
42068     function times(n, iteratee) {
42069       n = toInteger(n);
42070       if (n < 1 || n > MAX_SAFE_INTEGER) {
42071         return [];
42072       }
42073       var index = MAX_ARRAY_LENGTH,
42074           length = nativeMin(n, MAX_ARRAY_LENGTH);
42075
42076       iteratee = getIteratee(iteratee);
42077       n -= MAX_ARRAY_LENGTH;
42078
42079       var result = baseTimes(length, iteratee);
42080       while (++index < n) {
42081         iteratee(index);
42082       }
42083       return result;
42084     }
42085
42086     /**
42087      * Converts `value` to a property path array.
42088      *
42089      * @static
42090      * @memberOf _
42091      * @since 4.0.0
42092      * @category Util
42093      * @param {*} value The value to convert.
42094      * @returns {Array} Returns the new property path array.
42095      * @example
42096      *
42097      * _.toPath('a.b.c');
42098      * // => ['a', 'b', 'c']
42099      *
42100      * _.toPath('a[0].b.c');
42101      * // => ['a', '0', 'b', 'c']
42102      */
42103     function toPath(value) {
42104       if (isArray(value)) {
42105         return arrayMap(value, toKey);
42106       }
42107       return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
42108     }
42109
42110     /**
42111      * Generates a unique ID. If `prefix` is given, the ID is appended to it.
42112      *
42113      * @static
42114      * @since 0.1.0
42115      * @memberOf _
42116      * @category Util
42117      * @param {string} [prefix=''] The value to prefix the ID with.
42118      * @returns {string} Returns the unique ID.
42119      * @example
42120      *
42121      * _.uniqueId('contact_');
42122      * // => 'contact_104'
42123      *
42124      * _.uniqueId();
42125      * // => '105'
42126      */
42127     function uniqueId(prefix) {
42128       var id = ++idCounter;
42129       return toString(prefix) + id;
42130     }
42131
42132     /*------------------------------------------------------------------------*/
42133
42134     /**
42135      * Adds two numbers.
42136      *
42137      * @static
42138      * @memberOf _
42139      * @since 3.4.0
42140      * @category Math
42141      * @param {number} augend The first number in an addition.
42142      * @param {number} addend The second number in an addition.
42143      * @returns {number} Returns the total.
42144      * @example
42145      *
42146      * _.add(6, 4);
42147      * // => 10
42148      */
42149     var add = createMathOperation(function(augend, addend) {
42150       return augend + addend;
42151     }, 0);
42152
42153     /**
42154      * Computes `number` rounded up to `precision`.
42155      *
42156      * @static
42157      * @memberOf _
42158      * @since 3.10.0
42159      * @category Math
42160      * @param {number} number The number to round up.
42161      * @param {number} [precision=0] The precision to round up to.
42162      * @returns {number} Returns the rounded up number.
42163      * @example
42164      *
42165      * _.ceil(4.006);
42166      * // => 5
42167      *
42168      * _.ceil(6.004, 2);
42169      * // => 6.01
42170      *
42171      * _.ceil(6040, -2);
42172      * // => 6100
42173      */
42174     var ceil = createRound('ceil');
42175
42176     /**
42177      * Divide two numbers.
42178      *
42179      * @static
42180      * @memberOf _
42181      * @since 4.7.0
42182      * @category Math
42183      * @param {number} dividend The first number in a division.
42184      * @param {number} divisor The second number in a division.
42185      * @returns {number} Returns the quotient.
42186      * @example
42187      *
42188      * _.divide(6, 4);
42189      * // => 1.5
42190      */
42191     var divide = createMathOperation(function(dividend, divisor) {
42192       return dividend / divisor;
42193     }, 1);
42194
42195     /**
42196      * Computes `number` rounded down to `precision`.
42197      *
42198      * @static
42199      * @memberOf _
42200      * @since 3.10.0
42201      * @category Math
42202      * @param {number} number The number to round down.
42203      * @param {number} [precision=0] The precision to round down to.
42204      * @returns {number} Returns the rounded down number.
42205      * @example
42206      *
42207      * _.floor(4.006);
42208      * // => 4
42209      *
42210      * _.floor(0.046, 2);
42211      * // => 0.04
42212      *
42213      * _.floor(4060, -2);
42214      * // => 4000
42215      */
42216     var floor = createRound('floor');
42217
42218     /**
42219      * Computes the maximum value of `array`. If `array` is empty or falsey,
42220      * `undefined` is returned.
42221      *
42222      * @static
42223      * @since 0.1.0
42224      * @memberOf _
42225      * @category Math
42226      * @param {Array} array The array to iterate over.
42227      * @returns {*} Returns the maximum value.
42228      * @example
42229      *
42230      * _.max([4, 2, 8, 6]);
42231      * // => 8
42232      *
42233      * _.max([]);
42234      * // => undefined
42235      */
42236     function max(array) {
42237       return (array && array.length)
42238         ? baseExtremum(array, identity, baseGt)
42239         : undefined;
42240     }
42241
42242     /**
42243      * This method is like `_.max` except that it accepts `iteratee` which is
42244      * invoked for each element in `array` to generate the criterion by which
42245      * the value is ranked. The iteratee is invoked with one argument: (value).
42246      *
42247      * @static
42248      * @memberOf _
42249      * @since 4.0.0
42250      * @category Math
42251      * @param {Array} array The array to iterate over.
42252      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42253      * @returns {*} Returns the maximum value.
42254      * @example
42255      *
42256      * var objects = [{ 'n': 1 }, { 'n': 2 }];
42257      *
42258      * _.maxBy(objects, function(o) { return o.n; });
42259      * // => { 'n': 2 }
42260      *
42261      * // The `_.property` iteratee shorthand.
42262      * _.maxBy(objects, 'n');
42263      * // => { 'n': 2 }
42264      */
42265     function maxBy(array, iteratee) {
42266       return (array && array.length)
42267         ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
42268         : undefined;
42269     }
42270
42271     /**
42272      * Computes the mean of the values in `array`.
42273      *
42274      * @static
42275      * @memberOf _
42276      * @since 4.0.0
42277      * @category Math
42278      * @param {Array} array The array to iterate over.
42279      * @returns {number} Returns the mean.
42280      * @example
42281      *
42282      * _.mean([4, 2, 8, 6]);
42283      * // => 5
42284      */
42285     function mean(array) {
42286       return baseMean(array, identity);
42287     }
42288
42289     /**
42290      * This method is like `_.mean` except that it accepts `iteratee` which is
42291      * invoked for each element in `array` to generate the value to be averaged.
42292      * The iteratee is invoked with one argument: (value).
42293      *
42294      * @static
42295      * @memberOf _
42296      * @since 4.7.0
42297      * @category Math
42298      * @param {Array} array The array to iterate over.
42299      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42300      * @returns {number} Returns the mean.
42301      * @example
42302      *
42303      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
42304      *
42305      * _.meanBy(objects, function(o) { return o.n; });
42306      * // => 5
42307      *
42308      * // The `_.property` iteratee shorthand.
42309      * _.meanBy(objects, 'n');
42310      * // => 5
42311      */
42312     function meanBy(array, iteratee) {
42313       return baseMean(array, getIteratee(iteratee, 2));
42314     }
42315
42316     /**
42317      * Computes the minimum value of `array`. If `array` is empty or falsey,
42318      * `undefined` is returned.
42319      *
42320      * @static
42321      * @since 0.1.0
42322      * @memberOf _
42323      * @category Math
42324      * @param {Array} array The array to iterate over.
42325      * @returns {*} Returns the minimum value.
42326      * @example
42327      *
42328      * _.min([4, 2, 8, 6]);
42329      * // => 2
42330      *
42331      * _.min([]);
42332      * // => undefined
42333      */
42334     function min(array) {
42335       return (array && array.length)
42336         ? baseExtremum(array, identity, baseLt)
42337         : undefined;
42338     }
42339
42340     /**
42341      * This method is like `_.min` except that it accepts `iteratee` which is
42342      * invoked for each element in `array` to generate the criterion by which
42343      * the value is ranked. The iteratee is invoked with one argument: (value).
42344      *
42345      * @static
42346      * @memberOf _
42347      * @since 4.0.0
42348      * @category Math
42349      * @param {Array} array The array to iterate over.
42350      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42351      * @returns {*} Returns the minimum value.
42352      * @example
42353      *
42354      * var objects = [{ 'n': 1 }, { 'n': 2 }];
42355      *
42356      * _.minBy(objects, function(o) { return o.n; });
42357      * // => { 'n': 1 }
42358      *
42359      * // The `_.property` iteratee shorthand.
42360      * _.minBy(objects, 'n');
42361      * // => { 'n': 1 }
42362      */
42363     function minBy(array, iteratee) {
42364       return (array && array.length)
42365         ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
42366         : undefined;
42367     }
42368
42369     /**
42370      * Multiply two numbers.
42371      *
42372      * @static
42373      * @memberOf _
42374      * @since 4.7.0
42375      * @category Math
42376      * @param {number} multiplier The first number in a multiplication.
42377      * @param {number} multiplicand The second number in a multiplication.
42378      * @returns {number} Returns the product.
42379      * @example
42380      *
42381      * _.multiply(6, 4);
42382      * // => 24
42383      */
42384     var multiply = createMathOperation(function(multiplier, multiplicand) {
42385       return multiplier * multiplicand;
42386     }, 1);
42387
42388     /**
42389      * Computes `number` rounded to `precision`.
42390      *
42391      * @static
42392      * @memberOf _
42393      * @since 3.10.0
42394      * @category Math
42395      * @param {number} number The number to round.
42396      * @param {number} [precision=0] The precision to round to.
42397      * @returns {number} Returns the rounded number.
42398      * @example
42399      *
42400      * _.round(4.006);
42401      * // => 4
42402      *
42403      * _.round(4.006, 2);
42404      * // => 4.01
42405      *
42406      * _.round(4060, -2);
42407      * // => 4100
42408      */
42409     var round = createRound('round');
42410
42411     /**
42412      * Subtract two numbers.
42413      *
42414      * @static
42415      * @memberOf _
42416      * @since 4.0.0
42417      * @category Math
42418      * @param {number} minuend The first number in a subtraction.
42419      * @param {number} subtrahend The second number in a subtraction.
42420      * @returns {number} Returns the difference.
42421      * @example
42422      *
42423      * _.subtract(6, 4);
42424      * // => 2
42425      */
42426     var subtract = createMathOperation(function(minuend, subtrahend) {
42427       return minuend - subtrahend;
42428     }, 0);
42429
42430     /**
42431      * Computes the sum of the values in `array`.
42432      *
42433      * @static
42434      * @memberOf _
42435      * @since 3.4.0
42436      * @category Math
42437      * @param {Array} array The array to iterate over.
42438      * @returns {number} Returns the sum.
42439      * @example
42440      *
42441      * _.sum([4, 2, 8, 6]);
42442      * // => 20
42443      */
42444     function sum(array) {
42445       return (array && array.length)
42446         ? baseSum(array, identity)
42447         : 0;
42448     }
42449
42450     /**
42451      * This method is like `_.sum` except that it accepts `iteratee` which is
42452      * invoked for each element in `array` to generate the value to be summed.
42453      * The iteratee is invoked with one argument: (value).
42454      *
42455      * @static
42456      * @memberOf _
42457      * @since 4.0.0
42458      * @category Math
42459      * @param {Array} array The array to iterate over.
42460      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42461      * @returns {number} Returns the sum.
42462      * @example
42463      *
42464      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
42465      *
42466      * _.sumBy(objects, function(o) { return o.n; });
42467      * // => 20
42468      *
42469      * // The `_.property` iteratee shorthand.
42470      * _.sumBy(objects, 'n');
42471      * // => 20
42472      */
42473     function sumBy(array, iteratee) {
42474       return (array && array.length)
42475         ? baseSum(array, getIteratee(iteratee, 2))
42476         : 0;
42477     }
42478
42479     /*------------------------------------------------------------------------*/
42480
42481     // Add methods that return wrapped values in chain sequences.
42482     lodash.after = after;
42483     lodash.ary = ary;
42484     lodash.assign = assign;
42485     lodash.assignIn = assignIn;
42486     lodash.assignInWith = assignInWith;
42487     lodash.assignWith = assignWith;
42488     lodash.at = at;
42489     lodash.before = before;
42490     lodash.bind = bind;
42491     lodash.bindAll = bindAll;
42492     lodash.bindKey = bindKey;
42493     lodash.castArray = castArray;
42494     lodash.chain = chain;
42495     lodash.chunk = chunk;
42496     lodash.compact = compact;
42497     lodash.concat = concat;
42498     lodash.cond = cond;
42499     lodash.conforms = conforms;
42500     lodash.constant = constant;
42501     lodash.countBy = countBy;
42502     lodash.create = create;
42503     lodash.curry = curry;
42504     lodash.curryRight = curryRight;
42505     lodash.debounce = debounce;
42506     lodash.defaults = defaults;
42507     lodash.defaultsDeep = defaultsDeep;
42508     lodash.defer = defer;
42509     lodash.delay = delay;
42510     lodash.difference = difference;
42511     lodash.differenceBy = differenceBy;
42512     lodash.differenceWith = differenceWith;
42513     lodash.drop = drop;
42514     lodash.dropRight = dropRight;
42515     lodash.dropRightWhile = dropRightWhile;
42516     lodash.dropWhile = dropWhile;
42517     lodash.fill = fill;
42518     lodash.filter = filter;
42519     lodash.flatMap = flatMap;
42520     lodash.flatMapDeep = flatMapDeep;
42521     lodash.flatMapDepth = flatMapDepth;
42522     lodash.flatten = flatten;
42523     lodash.flattenDeep = flattenDeep;
42524     lodash.flattenDepth = flattenDepth;
42525     lodash.flip = flip;
42526     lodash.flow = flow;
42527     lodash.flowRight = flowRight;
42528     lodash.fromPairs = fromPairs;
42529     lodash.functions = functions;
42530     lodash.functionsIn = functionsIn;
42531     lodash.groupBy = groupBy;
42532     lodash.initial = initial;
42533     lodash.intersection = intersection;
42534     lodash.intersectionBy = intersectionBy;
42535     lodash.intersectionWith = intersectionWith;
42536     lodash.invert = invert;
42537     lodash.invertBy = invertBy;
42538     lodash.invokeMap = invokeMap;
42539     lodash.iteratee = iteratee;
42540     lodash.keyBy = keyBy;
42541     lodash.keys = keys;
42542     lodash.keysIn = keysIn;
42543     lodash.map = map;
42544     lodash.mapKeys = mapKeys;
42545     lodash.mapValues = mapValues;
42546     lodash.matches = matches;
42547     lodash.matchesProperty = matchesProperty;
42548     lodash.memoize = memoize;
42549     lodash.merge = merge;
42550     lodash.mergeWith = mergeWith;
42551     lodash.method = method;
42552     lodash.methodOf = methodOf;
42553     lodash.mixin = mixin;
42554     lodash.negate = negate;
42555     lodash.nthArg = nthArg;
42556     lodash.omit = omit;
42557     lodash.omitBy = omitBy;
42558     lodash.once = once;
42559     lodash.orderBy = orderBy;
42560     lodash.over = over;
42561     lodash.overArgs = overArgs;
42562     lodash.overEvery = overEvery;
42563     lodash.overSome = overSome;
42564     lodash.partial = partial;
42565     lodash.partialRight = partialRight;
42566     lodash.partition = partition;
42567     lodash.pick = pick;
42568     lodash.pickBy = pickBy;
42569     lodash.property = property;
42570     lodash.propertyOf = propertyOf;
42571     lodash.pull = pull;
42572     lodash.pullAll = pullAll;
42573     lodash.pullAllBy = pullAllBy;
42574     lodash.pullAllWith = pullAllWith;
42575     lodash.pullAt = pullAt;
42576     lodash.range = range;
42577     lodash.rangeRight = rangeRight;
42578     lodash.rearg = rearg;
42579     lodash.reject = reject;
42580     lodash.remove = remove;
42581     lodash.rest = rest;
42582     lodash.reverse = reverse;
42583     lodash.sampleSize = sampleSize;
42584     lodash.set = set;
42585     lodash.setWith = setWith;
42586     lodash.shuffle = shuffle;
42587     lodash.slice = slice;
42588     lodash.sortBy = sortBy;
42589     lodash.sortedUniq = sortedUniq;
42590     lodash.sortedUniqBy = sortedUniqBy;
42591     lodash.split = split;
42592     lodash.spread = spread;
42593     lodash.tail = tail;
42594     lodash.take = take;
42595     lodash.takeRight = takeRight;
42596     lodash.takeRightWhile = takeRightWhile;
42597     lodash.takeWhile = takeWhile;
42598     lodash.tap = tap;
42599     lodash.throttle = throttle;
42600     lodash.thru = thru;
42601     lodash.toArray = toArray;
42602     lodash.toPairs = toPairs;
42603     lodash.toPairsIn = toPairsIn;
42604     lodash.toPath = toPath;
42605     lodash.toPlainObject = toPlainObject;
42606     lodash.transform = transform;
42607     lodash.unary = unary;
42608     lodash.union = union;
42609     lodash.unionBy = unionBy;
42610     lodash.unionWith = unionWith;
42611     lodash.uniq = uniq;
42612     lodash.uniqBy = uniqBy;
42613     lodash.uniqWith = uniqWith;
42614     lodash.unset = unset;
42615     lodash.unzip = unzip;
42616     lodash.unzipWith = unzipWith;
42617     lodash.update = update;
42618     lodash.updateWith = updateWith;
42619     lodash.values = values;
42620     lodash.valuesIn = valuesIn;
42621     lodash.without = without;
42622     lodash.words = words;
42623     lodash.wrap = wrap;
42624     lodash.xor = xor;
42625     lodash.xorBy = xorBy;
42626     lodash.xorWith = xorWith;
42627     lodash.zip = zip;
42628     lodash.zipObject = zipObject;
42629     lodash.zipObjectDeep = zipObjectDeep;
42630     lodash.zipWith = zipWith;
42631
42632     // Add aliases.
42633     lodash.entries = toPairs;
42634     lodash.entriesIn = toPairsIn;
42635     lodash.extend = assignIn;
42636     lodash.extendWith = assignInWith;
42637
42638     // Add methods to `lodash.prototype`.
42639     mixin(lodash, lodash);
42640
42641     /*------------------------------------------------------------------------*/
42642
42643     // Add methods that return unwrapped values in chain sequences.
42644     lodash.add = add;
42645     lodash.attempt = attempt;
42646     lodash.camelCase = camelCase;
42647     lodash.capitalize = capitalize;
42648     lodash.ceil = ceil;
42649     lodash.clamp = clamp;
42650     lodash.clone = clone;
42651     lodash.cloneDeep = cloneDeep;
42652     lodash.cloneDeepWith = cloneDeepWith;
42653     lodash.cloneWith = cloneWith;
42654     lodash.conformsTo = conformsTo;
42655     lodash.deburr = deburr;
42656     lodash.defaultTo = defaultTo;
42657     lodash.divide = divide;
42658     lodash.endsWith = endsWith;
42659     lodash.eq = eq;
42660     lodash.escape = escape;
42661     lodash.escapeRegExp = escapeRegExp;
42662     lodash.every = every;
42663     lodash.find = find;
42664     lodash.findIndex = findIndex;
42665     lodash.findKey = findKey;
42666     lodash.findLast = findLast;
42667     lodash.findLastIndex = findLastIndex;
42668     lodash.findLastKey = findLastKey;
42669     lodash.floor = floor;
42670     lodash.forEach = forEach;
42671     lodash.forEachRight = forEachRight;
42672     lodash.forIn = forIn;
42673     lodash.forInRight = forInRight;
42674     lodash.forOwn = forOwn;
42675     lodash.forOwnRight = forOwnRight;
42676     lodash.get = get;
42677     lodash.gt = gt;
42678     lodash.gte = gte;
42679     lodash.has = has;
42680     lodash.hasIn = hasIn;
42681     lodash.head = head;
42682     lodash.identity = identity;
42683     lodash.includes = includes;
42684     lodash.indexOf = indexOf;
42685     lodash.inRange = inRange;
42686     lodash.invoke = invoke;
42687     lodash.isArguments = isArguments;
42688     lodash.isArray = isArray;
42689     lodash.isArrayBuffer = isArrayBuffer;
42690     lodash.isArrayLike = isArrayLike;
42691     lodash.isArrayLikeObject = isArrayLikeObject;
42692     lodash.isBoolean = isBoolean;
42693     lodash.isBuffer = isBuffer;
42694     lodash.isDate = isDate;
42695     lodash.isElement = isElement;
42696     lodash.isEmpty = isEmpty;
42697     lodash.isEqual = isEqual;
42698     lodash.isEqualWith = isEqualWith;
42699     lodash.isError = isError;
42700     lodash.isFinite = isFinite;
42701     lodash.isFunction = isFunction;
42702     lodash.isInteger = isInteger;
42703     lodash.isLength = isLength;
42704     lodash.isMap = isMap;
42705     lodash.isMatch = isMatch;
42706     lodash.isMatchWith = isMatchWith;
42707     lodash.isNaN = isNaN;
42708     lodash.isNative = isNative;
42709     lodash.isNil = isNil;
42710     lodash.isNull = isNull;
42711     lodash.isNumber = isNumber;
42712     lodash.isObject = isObject;
42713     lodash.isObjectLike = isObjectLike;
42714     lodash.isPlainObject = isPlainObject;
42715     lodash.isRegExp = isRegExp;
42716     lodash.isSafeInteger = isSafeInteger;
42717     lodash.isSet = isSet;
42718     lodash.isString = isString;
42719     lodash.isSymbol = isSymbol;
42720     lodash.isTypedArray = isTypedArray;
42721     lodash.isUndefined = isUndefined;
42722     lodash.isWeakMap = isWeakMap;
42723     lodash.isWeakSet = isWeakSet;
42724     lodash.join = join;
42725     lodash.kebabCase = kebabCase;
42726     lodash.last = last;
42727     lodash.lastIndexOf = lastIndexOf;
42728     lodash.lowerCase = lowerCase;
42729     lodash.lowerFirst = lowerFirst;
42730     lodash.lt = lt;
42731     lodash.lte = lte;
42732     lodash.max = max;
42733     lodash.maxBy = maxBy;
42734     lodash.mean = mean;
42735     lodash.meanBy = meanBy;
42736     lodash.min = min;
42737     lodash.minBy = minBy;
42738     lodash.stubArray = stubArray;
42739     lodash.stubFalse = stubFalse;
42740     lodash.stubObject = stubObject;
42741     lodash.stubString = stubString;
42742     lodash.stubTrue = stubTrue;
42743     lodash.multiply = multiply;
42744     lodash.nth = nth;
42745     lodash.noConflict = noConflict;
42746     lodash.noop = noop;
42747     lodash.now = now;
42748     lodash.pad = pad;
42749     lodash.padEnd = padEnd;
42750     lodash.padStart = padStart;
42751     lodash.parseInt = parseInt;
42752     lodash.random = random;
42753     lodash.reduce = reduce;
42754     lodash.reduceRight = reduceRight;
42755     lodash.repeat = repeat;
42756     lodash.replace = replace;
42757     lodash.result = result;
42758     lodash.round = round;
42759     lodash.runInContext = runInContext;
42760     lodash.sample = sample;
42761     lodash.size = size;
42762     lodash.snakeCase = snakeCase;
42763     lodash.some = some;
42764     lodash.sortedIndex = sortedIndex;
42765     lodash.sortedIndexBy = sortedIndexBy;
42766     lodash.sortedIndexOf = sortedIndexOf;
42767     lodash.sortedLastIndex = sortedLastIndex;
42768     lodash.sortedLastIndexBy = sortedLastIndexBy;
42769     lodash.sortedLastIndexOf = sortedLastIndexOf;
42770     lodash.startCase = startCase;
42771     lodash.startsWith = startsWith;
42772     lodash.subtract = subtract;
42773     lodash.sum = sum;
42774     lodash.sumBy = sumBy;
42775     lodash.template = template;
42776     lodash.times = times;
42777     lodash.toFinite = toFinite;
42778     lodash.toInteger = toInteger;
42779     lodash.toLength = toLength;
42780     lodash.toLower = toLower;
42781     lodash.toNumber = toNumber;
42782     lodash.toSafeInteger = toSafeInteger;
42783     lodash.toString = toString;
42784     lodash.toUpper = toUpper;
42785     lodash.trim = trim;
42786     lodash.trimEnd = trimEnd;
42787     lodash.trimStart = trimStart;
42788     lodash.truncate = truncate;
42789     lodash.unescape = unescape;
42790     lodash.uniqueId = uniqueId;
42791     lodash.upperCase = upperCase;
42792     lodash.upperFirst = upperFirst;
42793
42794     // Add aliases.
42795     lodash.each = forEach;
42796     lodash.eachRight = forEachRight;
42797     lodash.first = head;
42798
42799     mixin(lodash, (function() {
42800       var source = {};
42801       baseForOwn(lodash, function(func, methodName) {
42802         if (!hasOwnProperty.call(lodash.prototype, methodName)) {
42803           source[methodName] = func;
42804         }
42805       });
42806       return source;
42807     }()), { 'chain': false });
42808
42809     /*------------------------------------------------------------------------*/
42810
42811     /**
42812      * The semantic version number.
42813      *
42814      * @static
42815      * @memberOf _
42816      * @type {string}
42817      */
42818     lodash.VERSION = VERSION;
42819
42820     // Assign default placeholders.
42821     arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
42822       lodash[methodName].placeholder = lodash;
42823     });
42824
42825     // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
42826     arrayEach(['drop', 'take'], function(methodName, index) {
42827       LazyWrapper.prototype[methodName] = function(n) {
42828         n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
42829
42830         var result = (this.__filtered__ && !index)
42831           ? new LazyWrapper(this)
42832           : this.clone();
42833
42834         if (result.__filtered__) {
42835           result.__takeCount__ = nativeMin(n, result.__takeCount__);
42836         } else {
42837           result.__views__.push({
42838             'size': nativeMin(n, MAX_ARRAY_LENGTH),
42839             'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
42840           });
42841         }
42842         return result;
42843       };
42844
42845       LazyWrapper.prototype[methodName + 'Right'] = function(n) {
42846         return this.reverse()[methodName](n).reverse();
42847       };
42848     });
42849
42850     // Add `LazyWrapper` methods that accept an `iteratee` value.
42851     arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
42852       var type = index + 1,
42853           isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
42854
42855       LazyWrapper.prototype[methodName] = function(iteratee) {
42856         var result = this.clone();
42857         result.__iteratees__.push({
42858           'iteratee': getIteratee(iteratee, 3),
42859           'type': type
42860         });
42861         result.__filtered__ = result.__filtered__ || isFilter;
42862         return result;
42863       };
42864     });
42865
42866     // Add `LazyWrapper` methods for `_.head` and `_.last`.
42867     arrayEach(['head', 'last'], function(methodName, index) {
42868       var takeName = 'take' + (index ? 'Right' : '');
42869
42870       LazyWrapper.prototype[methodName] = function() {
42871         return this[takeName](1).value()[0];
42872       };
42873     });
42874
42875     // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
42876     arrayEach(['initial', 'tail'], function(methodName, index) {
42877       var dropName = 'drop' + (index ? '' : 'Right');
42878
42879       LazyWrapper.prototype[methodName] = function() {
42880         return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
42881       };
42882     });
42883
42884     LazyWrapper.prototype.compact = function() {
42885       return this.filter(identity);
42886     };
42887
42888     LazyWrapper.prototype.find = function(predicate) {
42889       return this.filter(predicate).head();
42890     };
42891
42892     LazyWrapper.prototype.findLast = function(predicate) {
42893       return this.reverse().find(predicate);
42894     };
42895
42896     LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
42897       if (typeof path == 'function') {
42898         return new LazyWrapper(this);
42899       }
42900       return this.map(function(value) {
42901         return baseInvoke(value, path, args);
42902       });
42903     });
42904
42905     LazyWrapper.prototype.reject = function(predicate) {
42906       return this.filter(negate(getIteratee(predicate)));
42907     };
42908
42909     LazyWrapper.prototype.slice = function(start, end) {
42910       start = toInteger(start);
42911
42912       var result = this;
42913       if (result.__filtered__ && (start > 0 || end < 0)) {
42914         return new LazyWrapper(result);
42915       }
42916       if (start < 0) {
42917         result = result.takeRight(-start);
42918       } else if (start) {
42919         result = result.drop(start);
42920       }
42921       if (end !== undefined) {
42922         end = toInteger(end);
42923         result = end < 0 ? result.dropRight(-end) : result.take(end - start);
42924       }
42925       return result;
42926     };
42927
42928     LazyWrapper.prototype.takeRightWhile = function(predicate) {
42929       return this.reverse().takeWhile(predicate).reverse();
42930     };
42931
42932     LazyWrapper.prototype.toArray = function() {
42933       return this.take(MAX_ARRAY_LENGTH);
42934     };
42935
42936     // Add `LazyWrapper` methods to `lodash.prototype`.
42937     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
42938       var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
42939           isTaker = /^(?:head|last)$/.test(methodName),
42940           lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
42941           retUnwrapped = isTaker || /^find/.test(methodName);
42942
42943       if (!lodashFunc) {
42944         return;
42945       }
42946       lodash.prototype[methodName] = function() {
42947         var value = this.__wrapped__,
42948             args = isTaker ? [1] : arguments,
42949             isLazy = value instanceof LazyWrapper,
42950             iteratee = args[0],
42951             useLazy = isLazy || isArray(value);
42952
42953         var interceptor = function(value) {
42954           var result = lodashFunc.apply(lodash, arrayPush([value], args));
42955           return (isTaker && chainAll) ? result[0] : result;
42956         };
42957
42958         if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
42959           // Avoid lazy use if the iteratee has a "length" value other than `1`.
42960           isLazy = useLazy = false;
42961         }
42962         var chainAll = this.__chain__,
42963             isHybrid = !!this.__actions__.length,
42964             isUnwrapped = retUnwrapped && !chainAll,
42965             onlyLazy = isLazy && !isHybrid;
42966
42967         if (!retUnwrapped && useLazy) {
42968           value = onlyLazy ? value : new LazyWrapper(this);
42969           var result = func.apply(value, args);
42970           result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
42971           return new LodashWrapper(result, chainAll);
42972         }
42973         if (isUnwrapped && onlyLazy) {
42974           return func.apply(this, args);
42975         }
42976         result = this.thru(interceptor);
42977         return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
42978       };
42979     });
42980
42981     // Add `Array` methods to `lodash.prototype`.
42982     arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
42983       var func = arrayProto[methodName],
42984           chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
42985           retUnwrapped = /^(?:pop|shift)$/.test(methodName);
42986
42987       lodash.prototype[methodName] = function() {
42988         var args = arguments;
42989         if (retUnwrapped && !this.__chain__) {
42990           var value = this.value();
42991           return func.apply(isArray(value) ? value : [], args);
42992         }
42993         return this[chainName](function(value) {
42994           return func.apply(isArray(value) ? value : [], args);
42995         });
42996       };
42997     });
42998
42999     // Map minified method names to their real names.
43000     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
43001       var lodashFunc = lodash[methodName];
43002       if (lodashFunc) {
43003         var key = lodashFunc.name + '';
43004         if (!hasOwnProperty.call(realNames, key)) {
43005           realNames[key] = [];
43006         }
43007         realNames[key].push({ 'name': methodName, 'func': lodashFunc });
43008       }
43009     });
43010
43011     realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
43012       'name': 'wrapper',
43013       'func': undefined
43014     }];
43015
43016     // Add methods to `LazyWrapper`.
43017     LazyWrapper.prototype.clone = lazyClone;
43018     LazyWrapper.prototype.reverse = lazyReverse;
43019     LazyWrapper.prototype.value = lazyValue;
43020
43021     // Add chain sequence methods to the `lodash` wrapper.
43022     lodash.prototype.at = wrapperAt;
43023     lodash.prototype.chain = wrapperChain;
43024     lodash.prototype.commit = wrapperCommit;
43025     lodash.prototype.next = wrapperNext;
43026     lodash.prototype.plant = wrapperPlant;
43027     lodash.prototype.reverse = wrapperReverse;
43028     lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
43029
43030     // Add lazy aliases.
43031     lodash.prototype.first = lodash.prototype.head;
43032
43033     if (symIterator) {
43034       lodash.prototype[symIterator] = wrapperToIterator;
43035     }
43036     return lodash;
43037   });
43038
43039   /*--------------------------------------------------------------------------*/
43040
43041   // Export lodash.
43042   var _ = runInContext();
43043
43044   // Some AMD build optimizers, like r.js, check for condition patterns like:
43045   if (true) {
43046     // Expose Lodash on the global object to prevent errors when Lodash is
43047     // loaded by a script tag in the presence of an AMD loader.
43048     // See http://requirejs.org/docs/errors.html#mismatch for more details.
43049     // Use `_.noConflict` to remove Lodash from the global object.
43050     root._ = _;
43051
43052     // Define as an anonymous module so, through path mapping, it can be
43053     // referenced as the "underscore" module.
43054     !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
43055       return _;
43056     }).call(exports, __webpack_require__, exports, module),
43057                                 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
43058   }
43059   // Check for `exports` after `define` in case a build optimizer adds it.
43060   else if (freeModule) {
43061     // Export for Node.js.
43062     (freeModule.exports = _)._ = _;
43063     // Export for CommonJS support.
43064     freeExports._ = _;
43065   }
43066   else {
43067     // Export to the global object.
43068     root._ = _;
43069   }
43070 }.call(this));
43071
43072 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(128)(module)))
43073
43074 /***/ }),
43075 /* 435 */,
43076 /* 436 */,
43077 /* 437 */,
43078 /* 438 */,
43079 /* 439 */,
43080 /* 440 */,
43081 /* 441 */,
43082 /* 442 */,
43083 /* 443 */,
43084 /* 444 */,
43085 /* 445 */,
43086 /* 446 */,
43087 /* 447 */,
43088 /* 448 */,
43089 /* 449 */,
43090 /* 450 */,
43091 /* 451 */,
43092 /* 452 */,
43093 /* 453 */,
43094 /* 454 */,
43095 /* 455 */,
43096 /* 456 */,
43097 /* 457 */,
43098 /* 458 */,
43099 /* 459 */,
43100 /* 460 */,
43101 /* 461 */,
43102 /* 462 */,
43103 /* 463 */,
43104 /* 464 */,
43105 /* 465 */,
43106 /* 466 */,
43107 /* 467 */,
43108 /* 468 */,
43109 /* 469 */,
43110 /* 470 */,
43111 /* 471 */,
43112 /* 472 */,
43113 /* 473 */,
43114 /* 474 */,
43115 /* 475 */,
43116 /* 476 */,
43117 /* 477 */,
43118 /* 478 */,
43119 /* 479 */,
43120 /* 480 */,
43121 /* 481 */,
43122 /* 482 */,
43123 /* 483 */,
43124 /* 484 */,
43125 /* 485 */,
43126 /* 486 */,
43127 /* 487 */,
43128 /* 488 */,
43129 /* 489 */,
43130 /* 490 */,
43131 /* 491 */,
43132 /* 492 */,
43133 /* 493 */,
43134 /* 494 */,
43135 /* 495 */,
43136 /* 496 */,
43137 /* 497 */,
43138 /* 498 */,
43139 /* 499 */,
43140 /* 500 */,
43141 /* 501 */,
43142 /* 502 */,
43143 /* 503 */,
43144 /* 504 */,
43145 /* 505 */,
43146 /* 506 */,
43147 /* 507 */,
43148 /* 508 */,
43149 /* 509 */,
43150 /* 510 */,
43151 /* 511 */,
43152 /* 512 */,
43153 /* 513 */,
43154 /* 514 */,
43155 /* 515 */,
43156 /* 516 */,
43157 /* 517 */
43158 /***/ (function(module, exports, __webpack_require__) {
43159
43160 module.exports = { "default": __webpack_require__(518), __esModule: true };
43161
43162 /***/ }),
43163 /* 518 */
43164 /***/ (function(module, exports, __webpack_require__) {
43165
43166 __webpack_require__(77);
43167 __webpack_require__(79);
43168 __webpack_require__(519);
43169 __webpack_require__(524);
43170 __webpack_require__(526);
43171 module.exports = __webpack_require__(8).WeakMap;
43172
43173
43174 /***/ }),
43175 /* 519 */
43176 /***/ (function(module, exports, __webpack_require__) {
43177
43178 "use strict";
43179
43180 var each = __webpack_require__(282)(0);
43181 var redefine = __webpack_require__(78);
43182 var meta = __webpack_require__(93);
43183 var assign = __webpack_require__(141);
43184 var weak = __webpack_require__(522);
43185 var isObject = __webpack_require__(12);
43186 var fails = __webpack_require__(22);
43187 var validate = __webpack_require__(430);
43188 var WEAK_MAP = 'WeakMap';
43189 var getWeak = meta.getWeak;
43190 var isExtensible = Object.isExtensible;
43191 var uncaughtFrozenStore = weak.ufstore;
43192 var tmp = {};
43193 var InternalMap;
43194
43195 var wrapper = function (get) {
43196   return function WeakMap() {
43197     return get(this, arguments.length > 0 ? arguments[0] : undefined);
43198   };
43199 };
43200
43201 var methods = {
43202   // 23.3.3.3 WeakMap.prototype.get(key)
43203   get: function get(key) {
43204     if (isObject(key)) {
43205       var data = getWeak(key);
43206       if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
43207       return data ? data[this._i] : undefined;
43208     }
43209   },
43210   // 23.3.3.5 WeakMap.prototype.set(key, value)
43211   set: function set(key, value) {
43212     return weak.def(validate(this, WEAK_MAP), key, value);
43213   }
43214 };
43215
43216 // 23.3 WeakMap Objects
43217 var $WeakMap = module.exports = __webpack_require__(523)(WEAK_MAP, wrapper, methods, weak, true, true);
43218
43219 // IE11 WeakMap frozen keys fix
43220 if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
43221   InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
43222   assign(InternalMap.prototype, methods);
43223   meta.NEED = true;
43224   each(['delete', 'has', 'get', 'set'], function (key) {
43225     var proto = $WeakMap.prototype;
43226     var method = proto[key];
43227     redefine(proto, key, function (a, b) {
43228       // store frozen objects on internal weakmap shim
43229       if (isObject(a) && !isExtensible(a)) {
43230         if (!this._f) this._f = new InternalMap();
43231         var result = this._f[key](a, b);
43232         return key == 'set' ? this : result;
43233       // store all the rest on native weakmap
43234       } return method.call(this, a, b);
43235     });
43236   });
43237 }
43238
43239
43240 /***/ }),
43241 /* 520 */
43242 /***/ (function(module, exports, __webpack_require__) {
43243
43244 // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
43245 var speciesConstructor = __webpack_require__(521);
43246
43247 module.exports = function (original, length) {
43248   return new (speciesConstructor(original))(length);
43249 };
43250
43251
43252 /***/ }),
43253 /* 521 */
43254 /***/ (function(module, exports, __webpack_require__) {
43255
43256 var isObject = __webpack_require__(12);
43257 var isArray = __webpack_require__(143);
43258 var SPECIES = __webpack_require__(7)('species');
43259
43260 module.exports = function (original) {
43261   var C;
43262   if (isArray(original)) {
43263     C = original.constructor;
43264     // cross-realm fallback
43265     if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
43266     if (isObject(C)) {
43267       C = C[SPECIES];
43268       if (C === null) C = undefined;
43269     }
43270   } return C === undefined ? Array : C;
43271 };
43272
43273
43274 /***/ }),
43275 /* 522 */
43276 /***/ (function(module, exports, __webpack_require__) {
43277
43278 "use strict";
43279
43280 var redefineAll = __webpack_require__(135);
43281 var getWeak = __webpack_require__(93).getWeak;
43282 var anObject = __webpack_require__(15);
43283 var isObject = __webpack_require__(12);
43284 var anInstance = __webpack_require__(134);
43285 var forOf = __webpack_require__(80);
43286 var createArrayMethod = __webpack_require__(282);
43287 var $has = __webpack_require__(20);
43288 var validate = __webpack_require__(430);
43289 var arrayFind = createArrayMethod(5);
43290 var arrayFindIndex = createArrayMethod(6);
43291 var id = 0;
43292
43293 // fallback for uncaught frozen keys
43294 var uncaughtFrozenStore = function (that) {
43295   return that._l || (that._l = new UncaughtFrozenStore());
43296 };
43297 var UncaughtFrozenStore = function () {
43298   this.a = [];
43299 };
43300 var findUncaughtFrozen = function (store, key) {
43301   return arrayFind(store.a, function (it) {
43302     return it[0] === key;
43303   });
43304 };
43305 UncaughtFrozenStore.prototype = {
43306   get: function (key) {
43307     var entry = findUncaughtFrozen(this, key);
43308     if (entry) return entry[1];
43309   },
43310   has: function (key) {
43311     return !!findUncaughtFrozen(this, key);
43312   },
43313   set: function (key, value) {
43314     var entry = findUncaughtFrozen(this, key);
43315     if (entry) entry[1] = value;
43316     else this.a.push([key, value]);
43317   },
43318   'delete': function (key) {
43319     var index = arrayFindIndex(this.a, function (it) {
43320       return it[0] === key;
43321     });
43322     if (~index) this.a.splice(index, 1);
43323     return !!~index;
43324   }
43325 };
43326
43327 module.exports = {
43328   getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
43329     var C = wrapper(function (that, iterable) {
43330       anInstance(that, C, NAME, '_i');
43331       that._t = NAME;      // collection type
43332       that._i = id++;      // collection id
43333       that._l = undefined; // leak store for uncaught frozen objects
43334       if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
43335     });
43336     redefineAll(C.prototype, {
43337       // 23.3.3.2 WeakMap.prototype.delete(key)
43338       // 23.4.3.3 WeakSet.prototype.delete(value)
43339       'delete': function (key) {
43340         if (!isObject(key)) return false;
43341         var data = getWeak(key);
43342         if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
43343         return data && $has(data, this._i) && delete data[this._i];
43344       },
43345       // 23.3.3.4 WeakMap.prototype.has(key)
43346       // 23.4.3.4 WeakSet.prototype.has(value)
43347       has: function has(key) {
43348         if (!isObject(key)) return false;
43349         var data = getWeak(key);
43350         if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
43351         return data && $has(data, this._i);
43352       }
43353     });
43354     return C;
43355   },
43356   def: function (that, key, value) {
43357     var data = getWeak(anObject(key), true);
43358     if (data === true) uncaughtFrozenStore(that).set(key, value);
43359     else data[that._i] = value;
43360     return that;
43361   },
43362   ufstore: uncaughtFrozenStore
43363 };
43364
43365
43366 /***/ }),
43367 /* 523 */
43368 /***/ (function(module, exports, __webpack_require__) {
43369
43370 "use strict";
43371
43372 var global = __webpack_require__(5);
43373 var $export = __webpack_require__(13);
43374 var meta = __webpack_require__(93);
43375 var fails = __webpack_require__(22);
43376 var hide = __webpack_require__(19);
43377 var redefineAll = __webpack_require__(135);
43378 var forOf = __webpack_require__(80);
43379 var anInstance = __webpack_require__(134);
43380 var isObject = __webpack_require__(12);
43381 var setToStringTag = __webpack_require__(40);
43382 var dP = __webpack_require__(16).f;
43383 var each = __webpack_require__(282)(0);
43384 var DESCRIPTORS = __webpack_require__(17);
43385
43386 module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
43387   var Base = global[NAME];
43388   var C = Base;
43389   var ADDER = IS_MAP ? 'set' : 'add';
43390   var proto = C && C.prototype;
43391   var O = {};
43392   if (!DESCRIPTORS || typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
43393     new C().entries().next();
43394   }))) {
43395     // create collection constructor
43396     C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
43397     redefineAll(C.prototype, methods);
43398     meta.NEED = true;
43399   } else {
43400     C = wrapper(function (target, iterable) {
43401       anInstance(target, C, NAME, '_c');
43402       target._c = new Base();
43403       if (iterable != undefined) forOf(iterable, IS_MAP, target[ADDER], target);
43404     });
43405     each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
43406       var IS_ADDER = KEY == 'add' || KEY == 'set';
43407       if (KEY in proto && !(IS_WEAK && KEY == 'clear')) hide(C.prototype, KEY, function (a, b) {
43408         anInstance(this, C, KEY);
43409         if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
43410         var result = this._c[KEY](a === 0 ? 0 : a, b);
43411         return IS_ADDER ? this : result;
43412       });
43413     });
43414     IS_WEAK || dP(C.prototype, 'size', {
43415       get: function () {
43416         return this._c.size;
43417       }
43418     });
43419   }
43420
43421   setToStringTag(C, NAME);
43422
43423   O[NAME] = C;
43424   $export($export.G + $export.W + $export.F, O);
43425
43426   if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
43427
43428   return C;
43429 };
43430
43431
43432 /***/ }),
43433 /* 524 */
43434 /***/ (function(module, exports, __webpack_require__) {
43435
43436 // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of
43437 __webpack_require__(525)('WeakMap');
43438
43439
43440 /***/ }),
43441 /* 525 */
43442 /***/ (function(module, exports, __webpack_require__) {
43443
43444 "use strict";
43445
43446 // https://tc39.github.io/proposal-setmap-offrom/
43447 var $export = __webpack_require__(13);
43448
43449 module.exports = function (COLLECTION) {
43450   $export($export.S, COLLECTION, { of: function of() {
43451     var length = arguments.length;
43452     var A = new Array(length);
43453     while (length--) A[length] = arguments[length];
43454     return new this(A);
43455   } });
43456 };
43457
43458
43459 /***/ }),
43460 /* 526 */
43461 /***/ (function(module, exports, __webpack_require__) {
43462
43463 // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from
43464 __webpack_require__(527)('WeakMap');
43465
43466
43467 /***/ }),
43468 /* 527 */
43469 /***/ (function(module, exports, __webpack_require__) {
43470
43471 "use strict";
43472
43473 // https://tc39.github.io/proposal-setmap-offrom/
43474 var $export = __webpack_require__(13);
43475 var aFunction = __webpack_require__(38);
43476 var ctx = __webpack_require__(35);
43477 var forOf = __webpack_require__(80);
43478
43479 module.exports = function (COLLECTION) {
43480   $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
43481     var mapFn = arguments[1];
43482     var mapping, A, n, cb;
43483     aFunction(this);
43484     mapping = mapFn !== undefined;
43485     if (mapping) aFunction(mapFn);
43486     if (source == undefined) return new this();
43487     A = [];
43488     if (mapping) {
43489       n = 0;
43490       cb = ctx(mapFn, arguments[2], 2);
43491       forOf(source, false, function (nextItem) {
43492         A.push(cb(nextItem, n++));
43493       });
43494     } else {
43495       forOf(source, false, A.push, A);
43496     }
43497     return new this(A);
43498   } });
43499 };
43500
43501
43502 /***/ }),
43503 /* 528 */
43504 /***/ (function(module, __webpack_exports__, __webpack_require__) {
43505
43506 "use strict";
43507 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__ = __webpack_require__(69);
43508 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__);
43509 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
43510 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
43511 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__ = __webpack_require__(36);
43512 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__);
43513 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__types__ = __webpack_require__(129);
43514
43515
43516
43517
43518
43519 var NetworkMessage = function () {
43520   function NetworkMessage() {
43521     var _type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
43522
43523     var _payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43524
43525     var _resolver = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
43526
43527     var _domain = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
43528
43529     __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, NetworkMessage);
43530
43531     this.type = _type;
43532     this.payload = _payload;
43533     this.resolver = _resolver;
43534     this.domain = _domain;
43535   }
43536
43537   __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(NetworkMessage, [{
43538     key: 'respond',
43539     value: function respond(payload) {
43540       return new NetworkMessage(this.type, payload, this.resolver);
43541     }
43542   }, {
43543     key: 'error',
43544     value: function error(payload) {
43545       return new NetworkMessage(__WEBPACK_IMPORTED_MODULE_3__types__["c" /* ERROR */], payload, this.resolver);
43546     }
43547   }], [{
43548     key: 'placeholder',
43549     value: function placeholder() {
43550       return new NetworkMessage();
43551     }
43552   }, {
43553     key: 'fromJson',
43554     value: function fromJson(json) {
43555       var p = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default()(this.placeholder(), json);
43556       return p;
43557     }
43558   }, {
43559     key: 'payload',
43560     value: function payload(type, _payload2) {
43561       var p = this.placeholder();
43562       p.type = type;
43563       p.payload = _payload2;
43564       return p;
43565     }
43566   }, {
43567     key: 'signal',
43568     value: function signal(type) {
43569       var p = this.placeholder();
43570       p.type = type;
43571       return p;
43572     }
43573   }]);
43574
43575   return NetworkMessage;
43576 }();
43577
43578 /* harmony default export */ __webpack_exports__["a"] = (NetworkMessage);
43579
43580 /***/ }),
43581 /* 529 */,
43582 /* 530 */,
43583 /* 531 */,
43584 /* 532 */,
43585 /* 533 */,
43586 /* 534 */,
43587 /* 535 */,
43588 /* 536 */,
43589 /* 537 */,
43590 /* 538 */,
43591 /* 539 */,
43592 /* 540 */,
43593 /* 541 */,
43594 /* 542 */,
43595 /* 543 */,
43596 /* 544 */,
43597 /* 545 */,
43598 /* 546 */,
43599 /* 547 */,
43600 /* 548 */,
43601 /* 549 */,
43602 /* 550 */,
43603 /* 551 */,
43604 /* 552 */,
43605 /* 553 */,
43606 /* 554 */,
43607 /* 555 */,
43608 /* 556 */,
43609 /* 557 */,
43610 /* 558 */,
43611 /* 559 */,
43612 /* 560 */,
43613 /* 561 */,
43614 /* 562 */,
43615 /* 563 */,
43616 /* 564 */,
43617 /* 565 */,
43618 /* 566 */,
43619 /* 567 */
43620 /***/ (function(module, __webpack_exports__, __webpack_require__) {
43621
43622 "use strict";
43623 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
43624 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__ = __webpack_require__(138);
43625 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__);
43626 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(139);
43627 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator__);
43628 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
43629 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__);
43630 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__ = __webpack_require__(36);
43631 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__);
43632 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_core_js_weak_map__ = __webpack_require__(517);
43633 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_core_js_weak_map___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_babel_runtime_core_js_weak_map__);
43634 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_extension_streams__ = __webpack_require__(137);
43635 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_extension_streams___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_extension_streams__);
43636 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_IdGenerator__ = __webpack_require__(431);
43637 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__messages_network__ = __webpack_require__(528);
43638 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__messages_internal__ = __webpack_require__(267);
43639 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__messages_types__ = __webpack_require__(129);
43640 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__messages_event__ = __webpack_require__(432);
43641 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_GenericTools__ = __webpack_require__(568);
43642 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12_lodash__ = __webpack_require__(434);
43643 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12_lodash__);
43644
43645
43646
43647
43648
43649
43650
43651
43652
43653
43654
43655
43656
43657
43658 var stream = new __WEBPACK_IMPORTED_MODULE_4_babel_runtime_core_js_weak_map___default.a();
43659 var INJECTION_SCRIPT_FILENAME = 'js/inject.js';
43660 var isReady = false;
43661
43662 var Content = function () {
43663   function Content() {
43664     __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default()(this, Content);
43665
43666     this.setupEncryptedStream();
43667     this.injectInteractionScript();
43668   }
43669
43670   __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default()(Content, [{
43671     key: 'injectInteractionScript',
43672     value: function injectInteractionScript() {
43673       var script = document.createElement('script');
43674       script.src = chrome.extension.getURL(INJECTION_SCRIPT_FILENAME);(document.head || document.documentElement).appendChild(script);
43675       script.onload = function () {
43676         return script.remove();
43677       };
43678     }
43679   }, {
43680     key: 'setupEncryptedStream',
43681     value: function setupEncryptedStream() {
43682       var _this = this;
43683
43684       console.log('stream listening...', __WEBPACK_IMPORTED_MODULE_6__utils_IdGenerator__["a" /* default */].text(256));
43685
43686       stream = new __WEBPACK_IMPORTED_MODULE_5_extension_streams__["EncryptedStream"](__WEBPACK_IMPORTED_MODULE_10__messages_event__["a" /* BYTOM */], __WEBPACK_IMPORTED_MODULE_6__utils_IdGenerator__["a" /* default */].text(256));
43687       stream.listenWith(function (msg) {
43688         return _this.contentListener(msg);
43689       });
43690
43691       stream.onSync(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee() {
43692         var defaultAccount, net, chain;
43693         return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
43694           while (1) {
43695             switch (_context.prev = _context.next) {
43696               case 0:
43697                 _context.next = 2;
43698                 return _this.getDefaultAccount();
43699
43700               case 2:
43701                 defaultAccount = _context.sent;
43702                 _context.next = 5;
43703                 return _this.getDefaultNetwork();
43704
43705               case 5:
43706                 net = _context.sent;
43707                 _context.next = 8;
43708                 return _this.getDefaultChain();
43709
43710               case 8:
43711                 chain = _context.sent;
43712
43713
43714                 // Pushing an instance of Bytomdapp to the web application
43715                 stream.send(__WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["f" /* PUSH_BYTOM */], { defaultAccount: defaultAccount, net: net, chain: chain }), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43716
43717                 // Dispatching the loaded event to the web application.
43718                 isReady = true;
43719
43720                 document.dispatchEvent(new CustomEvent('bytomLoaded'));
43721                 document.dispatchEvent(new CustomEvent('chromeBytomLoaded'));
43722
43723               case 13:
43724               case 'end':
43725                 return _context.stop();
43726             }
43727           }
43728         }, _callee, _this);
43729       })));
43730
43731       chrome.storage.onChanged.addListener(function () {
43732         var _ref2 = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee2(evt) {
43733           var net, defaultAccount, _defaultAccount, chain, _defaultAccount2;
43734
43735           return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee2$(_context2) {
43736             while (1) {
43737               switch (_context2.prev = _context2.next) {
43738                 case 0:
43739                   if (!(evt.bytom.newValue.settings.network !== evt.bytom.oldValue.settings.network)) {
43740                     _context2.next = 11;
43741                     break;
43742                   }
43743
43744                   _context2.next = 3;
43745                   return _this.getDefaultNetwork();
43746
43747                 case 3:
43748                   net = _context2.sent;
43749                   _context2.next = 6;
43750                   return _this.getDefaultAccount();
43751
43752                 case 6:
43753                   defaultAccount = _context2.sent;
43754
43755                   stream.send(__WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["q" /* UPDATE_BYTOM */], { type: 'net', value: net }), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43756                   stream.send(__WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["q" /* UPDATE_BYTOM */], { type: 'default_account', value: defaultAccount }), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43757                   _context2.next = 27;
43758                   break;
43759
43760                 case 11:
43761                   if (__WEBPACK_IMPORTED_MODULE_12_lodash___default.a.isEqual(evt.bytom.newValue.currentAccount, evt.bytom.oldValue.currentAccount)) {
43762                     _context2.next = 18;
43763                     break;
43764                   }
43765
43766                   _context2.next = 14;
43767                   return _this.getDefaultAccount();
43768
43769                 case 14:
43770                   _defaultAccount = _context2.sent;
43771
43772                   if (_defaultAccount) {
43773                     stream.send(__WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["q" /* UPDATE_BYTOM */], { type: 'default_account', value: _defaultAccount }), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43774                   }
43775                   _context2.next = 27;
43776                   break;
43777
43778                 case 18:
43779                   if (!(evt.bytom.newValue.settings.netType !== evt.bytom.oldValue.settings.netType)) {
43780                     _context2.next = 27;
43781                     break;
43782                   }
43783
43784                   _context2.next = 21;
43785                   return _this.getDefaultChain();
43786
43787                 case 21:
43788                   chain = _context2.sent;
43789                   _context2.next = 24;
43790                   return _this.getDefaultAccount();
43791
43792                 case 24:
43793                   _defaultAccount2 = _context2.sent;
43794
43795                   stream.send(__WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["q" /* UPDATE_BYTOM */], { type: 'chain', value: chain }), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43796                   stream.send(__WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["q" /* UPDATE_BYTOM */], { type: 'default_account', value: _defaultAccount2 }), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43797
43798                 case 27:
43799                 case 'end':
43800                   return _context2.stop();
43801               }
43802             }
43803           }, _callee2, _this);
43804         }));
43805
43806         return function (_x) {
43807           return _ref2.apply(this, arguments);
43808         };
43809       }());
43810     }
43811   }, {
43812     key: 'contentListener',
43813     value: function contentListener(msg) {
43814       console.log('content.stream.listen:', msg, stream.key);
43815
43816       if (!isReady) return;
43817       if (!msg) return;
43818       if (!stream.synced && (!msg.hasOwnProperty('type') || msg.type !== 'sync')) {
43819         stream.send(new Error('inject Error'), PairingTags.INJECTED);
43820         return;
43821       }
43822
43823       var networkMessage = __WEBPACK_IMPORTED_MODULE_7__messages_network__["a" /* default */].fromJson(msg);
43824       switch (msg.type) {
43825         case 'sync':
43826           this.sync(msg);
43827           break;
43828         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["o" /* TRANSFER */]:
43829         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["n" /* SIGNTRANSACTION */]:
43830         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["a" /* ADVTRANSFER */]:
43831         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["m" /* SIGNMESSAGE */]:
43832         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["k" /* SETCHAIN */]:
43833         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["j" /* SEND */]:
43834           this.transfer(msg.type, networkMessage);
43835           break;
43836         case __WEBPACK_IMPORTED_MODULE_9__messages_types__["b" /* ENABLE */]:
43837           this.enable(msg.type, networkMessage);
43838           break;
43839         default:
43840           stream.send(networkMessage.error('errtest'), __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43841           break;
43842       }
43843     }
43844   }, {
43845     key: 'getVersion',
43846     value: function getVersion() {}
43847   }, {
43848     key: 'getDefaultAccount',
43849     value: function getDefaultAccount() {
43850       return __WEBPACK_IMPORTED_MODULE_8__messages_internal__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_9__messages_types__["g" /* REQUEST_CURRENT_ACCOUNT */], { domain: Object(__WEBPACK_IMPORTED_MODULE_11__utils_GenericTools__["a" /* strippedHost */])() }).send();
43851     }
43852   }, {
43853     key: 'getDefaultNetwork',
43854     value: function getDefaultNetwork() {
43855       return __WEBPACK_IMPORTED_MODULE_8__messages_internal__["a" /* default */].signal(__WEBPACK_IMPORTED_MODULE_9__messages_types__["i" /* REQUEST_CURRENT_NETWORK */]).send();
43856     }
43857   }, {
43858     key: 'getDefaultChain',
43859     value: function getDefaultChain() {
43860       return __WEBPACK_IMPORTED_MODULE_8__messages_internal__["a" /* default */].signal(__WEBPACK_IMPORTED_MODULE_9__messages_types__["h" /* REQUEST_CURRENT_CHAIN_TYPE */]).send();
43861     }
43862   }, {
43863     key: 'respond',
43864     value: function respond(message, payload) {
43865       if (!isReady) return;
43866
43867       console.log(222, message, payload);
43868       var response = !payload || payload.hasOwnProperty('isError') ? message.error(payload) : message.respond(payload);
43869       stream.send(response, __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43870     }
43871   }, {
43872     key: 'sync',
43873     value: function sync(message) {
43874       stream.key = message.handshake.length ? message.handshake : null;
43875       stream.send({ type: 'sync' }, __WEBPACK_IMPORTED_MODULE_10__messages_event__["b" /* INJECT */]);
43876       stream.synced = true;
43877     }
43878   }, {
43879     key: 'transfer',
43880     value: function transfer(type, message) {
43881       var _this2 = this;
43882
43883       if (!isReady) return;
43884
43885       __WEBPACK_IMPORTED_MODULE_8__messages_internal__["a" /* default */].payload(type, message.payload).send().then(function (res) {
43886         return _this2.respond(message, res);
43887       });
43888     }
43889   }, {
43890     key: 'enable',
43891     value: function enable(type, networkMessage) {
43892       networkMessage.payload = {
43893         domain: Object(__WEBPACK_IMPORTED_MODULE_11__utils_GenericTools__["a" /* strippedHost */])()
43894       };
43895
43896       this.transfer(type, networkMessage);
43897     }
43898   }]);
43899
43900   return Content;
43901 }();
43902
43903 var content = new Content();
43904
43905 /***/ }),
43906 /* 568 */
43907 /***/ (function(module, __webpack_exports__, __webpack_require__) {
43908
43909 "use strict";
43910 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return strippedHost; });
43911
43912 var strippedHost = function strippedHost() {
43913     var host = location.hostname;
43914
43915     // Replacing www. only if the domain starts with it.
43916     if (host.indexOf('www.') === 0) host = host.replace('www.', '');
43917
43918     return host;
43919 };
43920
43921 /***/ })
43922 /******/ ]);
43923 //# sourceMappingURL=content.js.map