OSDN Git Service

update version
[bytom/Byone.git] / js / background.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 = 571);
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 /***/ (function(module, exports, __webpack_require__) {
9581
9582 exports.f = __webpack_require__(7);
9583
9584
9585 /***/ }),
9586 /* 82 */
9587 /***/ (function(module, exports, __webpack_require__) {
9588
9589 var global = __webpack_require__(5);
9590 var core = __webpack_require__(8);
9591 var LIBRARY = __webpack_require__(37);
9592 var wksExt = __webpack_require__(81);
9593 var defineProperty = __webpack_require__(16).f;
9594 module.exports = function (name) {
9595   var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
9596   if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
9597 };
9598
9599
9600 /***/ }),
9601 /* 83 */,
9602 /* 84 */,
9603 /* 85 */
9604 /***/ (function(module, exports, __webpack_require__) {
9605
9606 "use strict";
9607
9608 var LIBRARY = __webpack_require__(37);
9609 var $export = __webpack_require__(13);
9610 var redefine = __webpack_require__(78);
9611 var hide = __webpack_require__(19);
9612 var Iterators = __webpack_require__(28);
9613 var $iterCreate = __webpack_require__(158);
9614 var setToStringTag = __webpack_require__(40);
9615 var getPrototypeOf = __webpack_require__(160);
9616 var ITERATOR = __webpack_require__(7)('iterator');
9617 var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
9618 var FF_ITERATOR = '@@iterator';
9619 var KEYS = 'keys';
9620 var VALUES = 'values';
9621
9622 var returnThis = function () { return this; };
9623
9624 module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
9625   $iterCreate(Constructor, NAME, next);
9626   var getMethod = function (kind) {
9627     if (!BUGGY && kind in proto) return proto[kind];
9628     switch (kind) {
9629       case KEYS: return function keys() { return new Constructor(this, kind); };
9630       case VALUES: return function values() { return new Constructor(this, kind); };
9631     } return function entries() { return new Constructor(this, kind); };
9632   };
9633   var TAG = NAME + ' Iterator';
9634   var DEF_VALUES = DEFAULT == VALUES;
9635   var VALUES_BUG = false;
9636   var proto = Base.prototype;
9637   var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
9638   var $default = $native || getMethod(DEFAULT);
9639   var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
9640   var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
9641   var methods, key, IteratorPrototype;
9642   // Fix native
9643   if ($anyNative) {
9644     IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
9645     if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
9646       // Set @@toStringTag to native iterators
9647       setToStringTag(IteratorPrototype, TAG, true);
9648       // fix for some old engines
9649       if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
9650     }
9651   }
9652   // fix Array#{values, @@iterator}.name in V8 / FF
9653   if (DEF_VALUES && $native && $native.name !== VALUES) {
9654     VALUES_BUG = true;
9655     $default = function values() { return $native.call(this); };
9656   }
9657   // Define iterator
9658   if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
9659     hide(proto, ITERATOR, $default);
9660   }
9661   // Plug for library
9662   Iterators[NAME] = $default;
9663   Iterators[TAG] = returnThis;
9664   if (DEFAULT) {
9665     methods = {
9666       values: DEF_VALUES ? $default : getMethod(VALUES),
9667       keys: IS_SET ? $default : getMethod(KEYS),
9668       entries: $entries
9669     };
9670     if (FORCED) for (key in methods) {
9671       if (!(key in proto)) redefine(proto, key, methods[key]);
9672     } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
9673   }
9674   return methods;
9675 };
9676
9677
9678 /***/ }),
9679 /* 86 */
9680 /***/ (function(module, exports, __webpack_require__) {
9681
9682 var document = __webpack_require__(5).document;
9683 module.exports = document && document.documentElement;
9684
9685
9686 /***/ }),
9687 /* 87 */
9688 /***/ (function(module, exports, __webpack_require__) {
9689
9690 // getting tag from 19.1.3.6 Object.prototype.toString()
9691 var cof = __webpack_require__(27);
9692 var TAG = __webpack_require__(7)('toStringTag');
9693 // ES3 wrong here
9694 var ARG = cof(function () { return arguments; }()) == 'Arguments';
9695
9696 // fallback for IE11 Script Access Denied error
9697 var tryGet = function (it, key) {
9698   try {
9699     return it[key];
9700   } catch (e) { /* empty */ }
9701 };
9702
9703 module.exports = function (it) {
9704   var O, T, B;
9705   return it === undefined ? 'Undefined' : it === null ? 'Null'
9706     // @@toStringTag case
9707     : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
9708     // builtinTag case
9709     : ARG ? cof(O)
9710     // ES3 arguments fallback
9711     : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
9712 };
9713
9714
9715 /***/ }),
9716 /* 88 */
9717 /***/ (function(module, exports, __webpack_require__) {
9718
9719 // 7.3.20 SpeciesConstructor(O, defaultConstructor)
9720 var anObject = __webpack_require__(15);
9721 var aFunction = __webpack_require__(38);
9722 var SPECIES = __webpack_require__(7)('species');
9723 module.exports = function (O, D) {
9724   var C = anObject(O).constructor;
9725   var S;
9726   return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
9727 };
9728
9729
9730 /***/ }),
9731 /* 89 */
9732 /***/ (function(module, exports, __webpack_require__) {
9733
9734 var ctx = __webpack_require__(35);
9735 var invoke = __webpack_require__(168);
9736 var html = __webpack_require__(86);
9737 var cel = __webpack_require__(50);
9738 var global = __webpack_require__(5);
9739 var process = global.process;
9740 var setTask = global.setImmediate;
9741 var clearTask = global.clearImmediate;
9742 var MessageChannel = global.MessageChannel;
9743 var Dispatch = global.Dispatch;
9744 var counter = 0;
9745 var queue = {};
9746 var ONREADYSTATECHANGE = 'onreadystatechange';
9747 var defer, channel, port;
9748 var run = function () {
9749   var id = +this;
9750   // eslint-disable-next-line no-prototype-builtins
9751   if (queue.hasOwnProperty(id)) {
9752     var fn = queue[id];
9753     delete queue[id];
9754     fn();
9755   }
9756 };
9757 var listener = function (event) {
9758   run.call(event.data);
9759 };
9760 // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
9761 if (!setTask || !clearTask) {
9762   setTask = function setImmediate(fn) {
9763     var args = [];
9764     var i = 1;
9765     while (arguments.length > i) args.push(arguments[i++]);
9766     queue[++counter] = function () {
9767       // eslint-disable-next-line no-new-func
9768       invoke(typeof fn == 'function' ? fn : Function(fn), args);
9769     };
9770     defer(counter);
9771     return counter;
9772   };
9773   clearTask = function clearImmediate(id) {
9774     delete queue[id];
9775   };
9776   // Node.js 0.8-
9777   if (__webpack_require__(27)(process) == 'process') {
9778     defer = function (id) {
9779       process.nextTick(ctx(run, id, 1));
9780     };
9781   // Sphere (JS game engine) Dispatch API
9782   } else if (Dispatch && Dispatch.now) {
9783     defer = function (id) {
9784       Dispatch.now(ctx(run, id, 1));
9785     };
9786   // Browsers with MessageChannel, includes WebWorkers
9787   } else if (MessageChannel) {
9788     channel = new MessageChannel();
9789     port = channel.port2;
9790     channel.port1.onmessage = listener;
9791     defer = ctx(port.postMessage, port, 1);
9792   // Browsers with postMessage, skip WebWorkers
9793   // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
9794   } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
9795     defer = function (id) {
9796       global.postMessage(id + '', '*');
9797     };
9798     global.addEventListener('message', listener, false);
9799   // IE8-
9800   } else if (ONREADYSTATECHANGE in cel('script')) {
9801     defer = function (id) {
9802       html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
9803         html.removeChild(this);
9804         run.call(id);
9805       };
9806     };
9807   // Rest old browsers
9808   } else {
9809     defer = function (id) {
9810       setTimeout(ctx(run, id, 1), 0);
9811     };
9812   }
9813 }
9814 module.exports = {
9815   set: setTask,
9816   clear: clearTask
9817 };
9818
9819
9820 /***/ }),
9821 /* 90 */
9822 /***/ (function(module, exports) {
9823
9824 module.exports = function (exec) {
9825   try {
9826     return { e: false, v: exec() };
9827   } catch (e) {
9828     return { e: true, v: e };
9829   }
9830 };
9831
9832
9833 /***/ }),
9834 /* 91 */
9835 /***/ (function(module, exports, __webpack_require__) {
9836
9837 var anObject = __webpack_require__(15);
9838 var isObject = __webpack_require__(12);
9839 var newPromiseCapability = __webpack_require__(55);
9840
9841 module.exports = function (C, x) {
9842   anObject(C);
9843   if (isObject(x) && x.constructor === C) return x;
9844   var promiseCapability = newPromiseCapability.f(C);
9845   var resolve = promiseCapability.resolve;
9846   resolve(x);
9847   return promiseCapability.promise;
9848 };
9849
9850
9851 /***/ }),
9852 /* 92 */
9853 /***/ (function(module, exports) {
9854
9855 var toString = {}.toString;
9856
9857 module.exports = Array.isArray || function (arr) {
9858   return toString.call(arr) == '[object Array]';
9859 };
9860
9861
9862 /***/ }),
9863 /* 93 */
9864 /***/ (function(module, exports, __webpack_require__) {
9865
9866 var META = __webpack_require__(47)('meta');
9867 var isObject = __webpack_require__(12);
9868 var has = __webpack_require__(20);
9869 var setDesc = __webpack_require__(16).f;
9870 var id = 0;
9871 var isExtensible = Object.isExtensible || function () {
9872   return true;
9873 };
9874 var FREEZE = !__webpack_require__(22)(function () {
9875   return isExtensible(Object.preventExtensions({}));
9876 });
9877 var setMeta = function (it) {
9878   setDesc(it, META, { value: {
9879     i: 'O' + ++id, // object ID
9880     w: {}          // weak collections IDs
9881   } });
9882 };
9883 var fastKey = function (it, create) {
9884   // return primitive with prefix
9885   if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
9886   if (!has(it, META)) {
9887     // can't set metadata to uncaught frozen object
9888     if (!isExtensible(it)) return 'F';
9889     // not necessary to add metadata
9890     if (!create) return 'E';
9891     // add missing metadata
9892     setMeta(it);
9893   // return object ID
9894   } return it[META].i;
9895 };
9896 var getWeak = function (it, create) {
9897   if (!has(it, META)) {
9898     // can't set metadata to uncaught frozen object
9899     if (!isExtensible(it)) return true;
9900     // not necessary to add metadata
9901     if (!create) return false;
9902     // add missing metadata
9903     setMeta(it);
9904   // return hash weak collections IDs
9905   } return it[META].w;
9906 };
9907 // add metadata on freeze-family methods calling
9908 var onFreeze = function (it) {
9909   if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
9910   return it;
9911 };
9912 var meta = module.exports = {
9913   KEY: META,
9914   NEED: false,
9915   fastKey: fastKey,
9916   getWeak: getWeak,
9917   onFreeze: onFreeze
9918 };
9919
9920
9921 /***/ }),
9922 /* 94 */
9923 /***/ (function(module, exports, __webpack_require__) {
9924
9925 "use strict";
9926
9927 var Buffer = __webpack_require__(2).Buffer
9928 var Transform = __webpack_require__(57).Transform
9929 var inherits = __webpack_require__(1)
9930
9931 function throwIfNotStringOrBuffer (val, prefix) {
9932   if (!Buffer.isBuffer(val) && typeof val !== 'string') {
9933     throw new TypeError(prefix + ' must be a string or a buffer')
9934   }
9935 }
9936
9937 function HashBase (blockSize) {
9938   Transform.call(this)
9939
9940   this._block = Buffer.allocUnsafe(blockSize)
9941   this._blockSize = blockSize
9942   this._blockOffset = 0
9943   this._length = [0, 0, 0, 0]
9944
9945   this._finalized = false
9946 }
9947
9948 inherits(HashBase, Transform)
9949
9950 HashBase.prototype._transform = function (chunk, encoding, callback) {
9951   var error = null
9952   try {
9953     this.update(chunk, encoding)
9954   } catch (err) {
9955     error = err
9956   }
9957
9958   callback(error)
9959 }
9960
9961 HashBase.prototype._flush = function (callback) {
9962   var error = null
9963   try {
9964     this.push(this.digest())
9965   } catch (err) {
9966     error = err
9967   }
9968
9969   callback(error)
9970 }
9971
9972 HashBase.prototype.update = function (data, encoding) {
9973   throwIfNotStringOrBuffer(data, 'Data')
9974   if (this._finalized) throw new Error('Digest already called')
9975   if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
9976
9977   // consume data
9978   var block = this._block
9979   var offset = 0
9980   while (this._blockOffset + data.length - offset >= this._blockSize) {
9981     for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
9982     this._update()
9983     this._blockOffset = 0
9984   }
9985   while (offset < data.length) block[this._blockOffset++] = data[offset++]
9986
9987   // update length
9988   for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
9989     this._length[j] += carry
9990     carry = (this._length[j] / 0x0100000000) | 0
9991     if (carry > 0) this._length[j] -= 0x0100000000 * carry
9992   }
9993
9994   return this
9995 }
9996
9997 HashBase.prototype._update = function () {
9998   throw new Error('_update is not implemented')
9999 }
10000
10001 HashBase.prototype.digest = function (encoding) {
10002   if (this._finalized) throw new Error('Digest already called')
10003   this._finalized = true
10004
10005   var digest = this._digest()
10006   if (encoding !== undefined) digest = digest.toString(encoding)
10007
10008   // reset state
10009   this._block.fill(0)
10010   this._blockOffset = 0
10011   for (var i = 0; i < 4; ++i) this._length[i] = 0
10012
10013   return digest
10014 }
10015
10016 HashBase.prototype._digest = function () {
10017   throw new Error('_digest is not implemented')
10018 }
10019
10020 module.exports = HashBase
10021
10022
10023 /***/ }),
10024 /* 95 */
10025 /***/ (function(module, exports, __webpack_require__) {
10026
10027 "use strict";
10028 /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
10029 //
10030 // Permission is hereby granted, free of charge, to any person obtaining a
10031 // copy of this software and associated documentation files (the
10032 // "Software"), to deal in the Software without restriction, including
10033 // without limitation the rights to use, copy, modify, merge, publish,
10034 // distribute, sublicense, and/or sell copies of the Software, and to permit
10035 // persons to whom the Software is furnished to do so, subject to the
10036 // following conditions:
10037 //
10038 // The above copyright notice and this permission notice shall be included
10039 // in all copies or substantial portions of the Software.
10040 //
10041 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10042 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10043 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10044 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10045 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10046 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10047 // USE OR OTHER DEALINGS IN THE SOFTWARE.
10048
10049
10050
10051 /*<replacement>*/
10052
10053 var pna = __webpack_require__(42);
10054 /*</replacement>*/
10055
10056 module.exports = Readable;
10057
10058 /*<replacement>*/
10059 var isArray = __webpack_require__(92);
10060 /*</replacement>*/
10061
10062 /*<replacement>*/
10063 var Duplex;
10064 /*</replacement>*/
10065
10066 Readable.ReadableState = ReadableState;
10067
10068 /*<replacement>*/
10069 var EE = __webpack_require__(58).EventEmitter;
10070
10071 var EElistenerCount = function (emitter, type) {
10072   return emitter.listeners(type).length;
10073 };
10074 /*</replacement>*/
10075
10076 /*<replacement>*/
10077 var Stream = __webpack_require__(96);
10078 /*</replacement>*/
10079
10080 /*<replacement>*/
10081
10082 var Buffer = __webpack_require__(2).Buffer;
10083 var OurUint8Array = global.Uint8Array || function () {};
10084 function _uint8ArrayToBuffer(chunk) {
10085   return Buffer.from(chunk);
10086 }
10087 function _isUint8Array(obj) {
10088   return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
10089 }
10090
10091 /*</replacement>*/
10092
10093 /*<replacement>*/
10094 var util = __webpack_require__(30);
10095 util.inherits = __webpack_require__(1);
10096 /*</replacement>*/
10097
10098 /*<replacement>*/
10099 var debugUtil = __webpack_require__(183);
10100 var debug = void 0;
10101 if (debugUtil && debugUtil.debuglog) {
10102   debug = debugUtil.debuglog('stream');
10103 } else {
10104   debug = function () {};
10105 }
10106 /*</replacement>*/
10107
10108 var BufferList = __webpack_require__(184);
10109 var destroyImpl = __webpack_require__(97);
10110 var StringDecoder;
10111
10112 util.inherits(Readable, Stream);
10113
10114 var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
10115
10116 function prependListener(emitter, event, fn) {
10117   // Sadly this is not cacheable as some libraries bundle their own
10118   // event emitter implementation with them.
10119   if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
10120
10121   // This is a hack to make sure that our error handler is attached before any
10122   // userland ones.  NEVER DO THIS. This is here only because this code needs
10123   // to continue to work with older versions of Node.js that do not include
10124   // the prependListener() method. The goal is to eventually remove this hack.
10125   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]];
10126 }
10127
10128 function ReadableState(options, stream) {
10129   Duplex = Duplex || __webpack_require__(21);
10130
10131   options = options || {};
10132
10133   // Duplex streams are both readable and writable, but share
10134   // the same options object.
10135   // However, some cases require setting options to different
10136   // values for the readable and the writable sides of the duplex stream.
10137   // These options can be provided separately as readableXXX and writableXXX.
10138   var isDuplex = stream instanceof Duplex;
10139
10140   // object stream flag. Used to make read(n) ignore n and to
10141   // make all the buffer merging and length checks go away
10142   this.objectMode = !!options.objectMode;
10143
10144   if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
10145
10146   // the point at which it stops calling _read() to fill the buffer
10147   // Note: 0 is a valid value, means "don't call _read preemptively ever"
10148   var hwm = options.highWaterMark;
10149   var readableHwm = options.readableHighWaterMark;
10150   var defaultHwm = this.objectMode ? 16 : 16 * 1024;
10151
10152   if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
10153
10154   // cast to ints.
10155   this.highWaterMark = Math.floor(this.highWaterMark);
10156
10157   // A linked list is used to store data chunks instead of an array because the
10158   // linked list can remove elements from the beginning faster than
10159   // array.shift()
10160   this.buffer = new BufferList();
10161   this.length = 0;
10162   this.pipes = null;
10163   this.pipesCount = 0;
10164   this.flowing = null;
10165   this.ended = false;
10166   this.endEmitted = false;
10167   this.reading = false;
10168
10169   // a flag to be able to tell if the event 'readable'/'data' is emitted
10170   // immediately, or on a later tick.  We set this to true at first, because
10171   // any actions that shouldn't happen until "later" should generally also
10172   // not happen before the first read call.
10173   this.sync = true;
10174
10175   // whenever we return null, then we set a flag to say
10176   // that we're awaiting a 'readable' event emission.
10177   this.needReadable = false;
10178   this.emittedReadable = false;
10179   this.readableListening = false;
10180   this.resumeScheduled = false;
10181
10182   // has it been destroyed
10183   this.destroyed = false;
10184
10185   // Crypto is kind of old and crusty.  Historically, its default string
10186   // encoding is 'binary' so we have to make this configurable.
10187   // Everything else in the universe uses 'utf8', though.
10188   this.defaultEncoding = options.defaultEncoding || 'utf8';
10189
10190   // the number of writers that are awaiting a drain event in .pipe()s
10191   this.awaitDrain = 0;
10192
10193   // if true, a maybeReadMore has been scheduled
10194   this.readingMore = false;
10195
10196   this.decoder = null;
10197   this.encoding = null;
10198   if (options.encoding) {
10199     if (!StringDecoder) StringDecoder = __webpack_require__(61).StringDecoder;
10200     this.decoder = new StringDecoder(options.encoding);
10201     this.encoding = options.encoding;
10202   }
10203 }
10204
10205 function Readable(options) {
10206   Duplex = Duplex || __webpack_require__(21);
10207
10208   if (!(this instanceof Readable)) return new Readable(options);
10209
10210   this._readableState = new ReadableState(options, this);
10211
10212   // legacy
10213   this.readable = true;
10214
10215   if (options) {
10216     if (typeof options.read === 'function') this._read = options.read;
10217
10218     if (typeof options.destroy === 'function') this._destroy = options.destroy;
10219   }
10220
10221   Stream.call(this);
10222 }
10223
10224 Object.defineProperty(Readable.prototype, 'destroyed', {
10225   get: function () {
10226     if (this._readableState === undefined) {
10227       return false;
10228     }
10229     return this._readableState.destroyed;
10230   },
10231   set: function (value) {
10232     // we ignore the value if the stream
10233     // has not been initialized yet
10234     if (!this._readableState) {
10235       return;
10236     }
10237
10238     // backward compatibility, the user is explicitly
10239     // managing destroyed
10240     this._readableState.destroyed = value;
10241   }
10242 });
10243
10244 Readable.prototype.destroy = destroyImpl.destroy;
10245 Readable.prototype._undestroy = destroyImpl.undestroy;
10246 Readable.prototype._destroy = function (err, cb) {
10247   this.push(null);
10248   cb(err);
10249 };
10250
10251 // Manually shove something into the read() buffer.
10252 // This returns true if the highWaterMark has not been hit yet,
10253 // similar to how Writable.write() returns true if you should
10254 // write() some more.
10255 Readable.prototype.push = function (chunk, encoding) {
10256   var state = this._readableState;
10257   var skipChunkCheck;
10258
10259   if (!state.objectMode) {
10260     if (typeof chunk === 'string') {
10261       encoding = encoding || state.defaultEncoding;
10262       if (encoding !== state.encoding) {
10263         chunk = Buffer.from(chunk, encoding);
10264         encoding = '';
10265       }
10266       skipChunkCheck = true;
10267     }
10268   } else {
10269     skipChunkCheck = true;
10270   }
10271
10272   return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
10273 };
10274
10275 // Unshift should *always* be something directly out of read()
10276 Readable.prototype.unshift = function (chunk) {
10277   return readableAddChunk(this, chunk, null, true, false);
10278 };
10279
10280 function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
10281   var state = stream._readableState;
10282   if (chunk === null) {
10283     state.reading = false;
10284     onEofChunk(stream, state);
10285   } else {
10286     var er;
10287     if (!skipChunkCheck) er = chunkInvalid(state, chunk);
10288     if (er) {
10289       stream.emit('error', er);
10290     } else if (state.objectMode || chunk && chunk.length > 0) {
10291       if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
10292         chunk = _uint8ArrayToBuffer(chunk);
10293       }
10294
10295       if (addToFront) {
10296         if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
10297       } else if (state.ended) {
10298         stream.emit('error', new Error('stream.push() after EOF'));
10299       } else {
10300         state.reading = false;
10301         if (state.decoder && !encoding) {
10302           chunk = state.decoder.write(chunk);
10303           if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
10304         } else {
10305           addChunk(stream, state, chunk, false);
10306         }
10307       }
10308     } else if (!addToFront) {
10309       state.reading = false;
10310     }
10311   }
10312
10313   return needMoreData(state);
10314 }
10315
10316 function addChunk(stream, state, chunk, addToFront) {
10317   if (state.flowing && state.length === 0 && !state.sync) {
10318     stream.emit('data', chunk);
10319     stream.read(0);
10320   } else {
10321     // update the buffer info.
10322     state.length += state.objectMode ? 1 : chunk.length;
10323     if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
10324
10325     if (state.needReadable) emitReadable(stream);
10326   }
10327   maybeReadMore(stream, state);
10328 }
10329
10330 function chunkInvalid(state, chunk) {
10331   var er;
10332   if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
10333     er = new TypeError('Invalid non-string/buffer chunk');
10334   }
10335   return er;
10336 }
10337
10338 // if it's past the high water mark, we can push in some more.
10339 // Also, if we have no data yet, we can stand some
10340 // more bytes.  This is to work around cases where hwm=0,
10341 // such as the repl.  Also, if the push() triggered a
10342 // readable event, and the user called read(largeNumber) such that
10343 // needReadable was set, then we ought to push more, so that another
10344 // 'readable' event will be triggered.
10345 function needMoreData(state) {
10346   return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
10347 }
10348
10349 Readable.prototype.isPaused = function () {
10350   return this._readableState.flowing === false;
10351 };
10352
10353 // backwards compatibility.
10354 Readable.prototype.setEncoding = function (enc) {
10355   if (!StringDecoder) StringDecoder = __webpack_require__(61).StringDecoder;
10356   this._readableState.decoder = new StringDecoder(enc);
10357   this._readableState.encoding = enc;
10358   return this;
10359 };
10360
10361 // Don't raise the hwm > 8MB
10362 var MAX_HWM = 0x800000;
10363 function computeNewHighWaterMark(n) {
10364   if (n >= MAX_HWM) {
10365     n = MAX_HWM;
10366   } else {
10367     // Get the next highest power of 2 to prevent increasing hwm excessively in
10368     // tiny amounts
10369     n--;
10370     n |= n >>> 1;
10371     n |= n >>> 2;
10372     n |= n >>> 4;
10373     n |= n >>> 8;
10374     n |= n >>> 16;
10375     n++;
10376   }
10377   return n;
10378 }
10379
10380 // This function is designed to be inlinable, so please take care when making
10381 // changes to the function body.
10382 function howMuchToRead(n, state) {
10383   if (n <= 0 || state.length === 0 && state.ended) return 0;
10384   if (state.objectMode) return 1;
10385   if (n !== n) {
10386     // Only flow one buffer at a time
10387     if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
10388   }
10389   // If we're asking for more than the current hwm, then raise the hwm.
10390   if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
10391   if (n <= state.length) return n;
10392   // Don't have enough
10393   if (!state.ended) {
10394     state.needReadable = true;
10395     return 0;
10396   }
10397   return state.length;
10398 }
10399
10400 // you can override either this method, or the async _read(n) below.
10401 Readable.prototype.read = function (n) {
10402   debug('read', n);
10403   n = parseInt(n, 10);
10404   var state = this._readableState;
10405   var nOrig = n;
10406
10407   if (n !== 0) state.emittedReadable = false;
10408
10409   // if we're doing read(0) to trigger a readable event, but we
10410   // already have a bunch of data in the buffer, then just trigger
10411   // the 'readable' event and move on.
10412   if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
10413     debug('read: emitReadable', state.length, state.ended);
10414     if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
10415     return null;
10416   }
10417
10418   n = howMuchToRead(n, state);
10419
10420   // if we've ended, and we're now clear, then finish it up.
10421   if (n === 0 && state.ended) {
10422     if (state.length === 0) endReadable(this);
10423     return null;
10424   }
10425
10426   // All the actual chunk generation logic needs to be
10427   // *below* the call to _read.  The reason is that in certain
10428   // synthetic stream cases, such as passthrough streams, _read
10429   // may be a completely synchronous operation which may change
10430   // the state of the read buffer, providing enough data when
10431   // before there was *not* enough.
10432   //
10433   // So, the steps are:
10434   // 1. Figure out what the state of things will be after we do
10435   // a read from the buffer.
10436   //
10437   // 2. If that resulting state will trigger a _read, then call _read.
10438   // Note that this may be asynchronous, or synchronous.  Yes, it is
10439   // deeply ugly to write APIs this way, but that still doesn't mean
10440   // that the Readable class should behave improperly, as streams are
10441   // designed to be sync/async agnostic.
10442   // Take note if the _read call is sync or async (ie, if the read call
10443   // has returned yet), so that we know whether or not it's safe to emit
10444   // 'readable' etc.
10445   //
10446   // 3. Actually pull the requested chunks out of the buffer and return.
10447
10448   // if we need a readable event, then we need to do some reading.
10449   var doRead = state.needReadable;
10450   debug('need readable', doRead);
10451
10452   // if we currently have less than the highWaterMark, then also read some
10453   if (state.length === 0 || state.length - n < state.highWaterMark) {
10454     doRead = true;
10455     debug('length less than watermark', doRead);
10456   }
10457
10458   // however, if we've ended, then there's no point, and if we're already
10459   // reading, then it's unnecessary.
10460   if (state.ended || state.reading) {
10461     doRead = false;
10462     debug('reading or ended', doRead);
10463   } else if (doRead) {
10464     debug('do read');
10465     state.reading = true;
10466     state.sync = true;
10467     // if the length is currently zero, then we *need* a readable event.
10468     if (state.length === 0) state.needReadable = true;
10469     // call internal read method
10470     this._read(state.highWaterMark);
10471     state.sync = false;
10472     // If _read pushed data synchronously, then `reading` will be false,
10473     // and we need to re-evaluate how much data we can return to the user.
10474     if (!state.reading) n = howMuchToRead(nOrig, state);
10475   }
10476
10477   var ret;
10478   if (n > 0) ret = fromList(n, state);else ret = null;
10479
10480   if (ret === null) {
10481     state.needReadable = true;
10482     n = 0;
10483   } else {
10484     state.length -= n;
10485   }
10486
10487   if (state.length === 0) {
10488     // If we have nothing in the buffer, then we want to know
10489     // as soon as we *do* get something into the buffer.
10490     if (!state.ended) state.needReadable = true;
10491
10492     // If we tried to read() past the EOF, then emit end on the next tick.
10493     if (nOrig !== n && state.ended) endReadable(this);
10494   }
10495
10496   if (ret !== null) this.emit('data', ret);
10497
10498   return ret;
10499 };
10500
10501 function onEofChunk(stream, state) {
10502   if (state.ended) return;
10503   if (state.decoder) {
10504     var chunk = state.decoder.end();
10505     if (chunk && chunk.length) {
10506       state.buffer.push(chunk);
10507       state.length += state.objectMode ? 1 : chunk.length;
10508     }
10509   }
10510   state.ended = true;
10511
10512   // emit 'readable' now to make sure it gets picked up.
10513   emitReadable(stream);
10514 }
10515
10516 // Don't emit readable right away in sync mode, because this can trigger
10517 // another read() call => stack overflow.  This way, it might trigger
10518 // a nextTick recursion warning, but that's not so bad.
10519 function emitReadable(stream) {
10520   var state = stream._readableState;
10521   state.needReadable = false;
10522   if (!state.emittedReadable) {
10523     debug('emitReadable', state.flowing);
10524     state.emittedReadable = true;
10525     if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
10526   }
10527 }
10528
10529 function emitReadable_(stream) {
10530   debug('emit readable');
10531   stream.emit('readable');
10532   flow(stream);
10533 }
10534
10535 // at this point, the user has presumably seen the 'readable' event,
10536 // and called read() to consume some data.  that may have triggered
10537 // in turn another _read(n) call, in which case reading = true if
10538 // it's in progress.
10539 // However, if we're not ended, or reading, and the length < hwm,
10540 // then go ahead and try to read some more preemptively.
10541 function maybeReadMore(stream, state) {
10542   if (!state.readingMore) {
10543     state.readingMore = true;
10544     pna.nextTick(maybeReadMore_, stream, state);
10545   }
10546 }
10547
10548 function maybeReadMore_(stream, state) {
10549   var len = state.length;
10550   while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
10551     debug('maybeReadMore read 0');
10552     stream.read(0);
10553     if (len === state.length)
10554       // didn't get any data, stop spinning.
10555       break;else len = state.length;
10556   }
10557   state.readingMore = false;
10558 }
10559
10560 // abstract method.  to be overridden in specific implementation classes.
10561 // call cb(er, data) where data is <= n in length.
10562 // for virtual (non-string, non-buffer) streams, "length" is somewhat
10563 // arbitrary, and perhaps not very meaningful.
10564 Readable.prototype._read = function (n) {
10565   this.emit('error', new Error('_read() is not implemented'));
10566 };
10567
10568 Readable.prototype.pipe = function (dest, pipeOpts) {
10569   var src = this;
10570   var state = this._readableState;
10571
10572   switch (state.pipesCount) {
10573     case 0:
10574       state.pipes = dest;
10575       break;
10576     case 1:
10577       state.pipes = [state.pipes, dest];
10578       break;
10579     default:
10580       state.pipes.push(dest);
10581       break;
10582   }
10583   state.pipesCount += 1;
10584   debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
10585
10586   var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
10587
10588   var endFn = doEnd ? onend : unpipe;
10589   if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
10590
10591   dest.on('unpipe', onunpipe);
10592   function onunpipe(readable, unpipeInfo) {
10593     debug('onunpipe');
10594     if (readable === src) {
10595       if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
10596         unpipeInfo.hasUnpiped = true;
10597         cleanup();
10598       }
10599     }
10600   }
10601
10602   function onend() {
10603     debug('onend');
10604     dest.end();
10605   }
10606
10607   // when the dest drains, it reduces the awaitDrain counter
10608   // on the source.  This would be more elegant with a .once()
10609   // handler in flow(), but adding and removing repeatedly is
10610   // too slow.
10611   var ondrain = pipeOnDrain(src);
10612   dest.on('drain', ondrain);
10613
10614   var cleanedUp = false;
10615   function cleanup() {
10616     debug('cleanup');
10617     // cleanup event handlers once the pipe is broken
10618     dest.removeListener('close', onclose);
10619     dest.removeListener('finish', onfinish);
10620     dest.removeListener('drain', ondrain);
10621     dest.removeListener('error', onerror);
10622     dest.removeListener('unpipe', onunpipe);
10623     src.removeListener('end', onend);
10624     src.removeListener('end', unpipe);
10625     src.removeListener('data', ondata);
10626
10627     cleanedUp = true;
10628
10629     // if the reader is waiting for a drain event from this
10630     // specific writer, then it would cause it to never start
10631     // flowing again.
10632     // So, if this is awaiting a drain, then we just call it now.
10633     // If we don't know, then assume that we are waiting for one.
10634     if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
10635   }
10636
10637   // If the user pushes more data while we're writing to dest then we'll end up
10638   // in ondata again. However, we only want to increase awaitDrain once because
10639   // dest will only emit one 'drain' event for the multiple writes.
10640   // => Introduce a guard on increasing awaitDrain.
10641   var increasedAwaitDrain = false;
10642   src.on('data', ondata);
10643   function ondata(chunk) {
10644     debug('ondata');
10645     increasedAwaitDrain = false;
10646     var ret = dest.write(chunk);
10647     if (false === ret && !increasedAwaitDrain) {
10648       // If the user unpiped during `dest.write()`, it is possible
10649       // to get stuck in a permanently paused state if that write
10650       // also returned false.
10651       // => Check whether `dest` is still a piping destination.
10652       if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
10653         debug('false write response, pause', src._readableState.awaitDrain);
10654         src._readableState.awaitDrain++;
10655         increasedAwaitDrain = true;
10656       }
10657       src.pause();
10658     }
10659   }
10660
10661   // if the dest has an error, then stop piping into it.
10662   // however, don't suppress the throwing behavior for this.
10663   function onerror(er) {
10664     debug('onerror', er);
10665     unpipe();
10666     dest.removeListener('error', onerror);
10667     if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
10668   }
10669
10670   // Make sure our error handler is attached before userland ones.
10671   prependListener(dest, 'error', onerror);
10672
10673   // Both close and finish should trigger unpipe, but only once.
10674   function onclose() {
10675     dest.removeListener('finish', onfinish);
10676     unpipe();
10677   }
10678   dest.once('close', onclose);
10679   function onfinish() {
10680     debug('onfinish');
10681     dest.removeListener('close', onclose);
10682     unpipe();
10683   }
10684   dest.once('finish', onfinish);
10685
10686   function unpipe() {
10687     debug('unpipe');
10688     src.unpipe(dest);
10689   }
10690
10691   // tell the dest that it's being piped to
10692   dest.emit('pipe', src);
10693
10694   // start the flow if it hasn't been started already.
10695   if (!state.flowing) {
10696     debug('pipe resume');
10697     src.resume();
10698   }
10699
10700   return dest;
10701 };
10702
10703 function pipeOnDrain(src) {
10704   return function () {
10705     var state = src._readableState;
10706     debug('pipeOnDrain', state.awaitDrain);
10707     if (state.awaitDrain) state.awaitDrain--;
10708     if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
10709       state.flowing = true;
10710       flow(src);
10711     }
10712   };
10713 }
10714
10715 Readable.prototype.unpipe = function (dest) {
10716   var state = this._readableState;
10717   var unpipeInfo = { hasUnpiped: false };
10718
10719   // if we're not piping anywhere, then do nothing.
10720   if (state.pipesCount === 0) return this;
10721
10722   // just one destination.  most common case.
10723   if (state.pipesCount === 1) {
10724     // passed in one, but it's not the right one.
10725     if (dest && dest !== state.pipes) return this;
10726
10727     if (!dest) dest = state.pipes;
10728
10729     // got a match.
10730     state.pipes = null;
10731     state.pipesCount = 0;
10732     state.flowing = false;
10733     if (dest) dest.emit('unpipe', this, unpipeInfo);
10734     return this;
10735   }
10736
10737   // slow case. multiple pipe destinations.
10738
10739   if (!dest) {
10740     // remove all.
10741     var dests = state.pipes;
10742     var len = state.pipesCount;
10743     state.pipes = null;
10744     state.pipesCount = 0;
10745     state.flowing = false;
10746
10747     for (var i = 0; i < len; i++) {
10748       dests[i].emit('unpipe', this, unpipeInfo);
10749     }return this;
10750   }
10751
10752   // try to find the right one.
10753   var index = indexOf(state.pipes, dest);
10754   if (index === -1) return this;
10755
10756   state.pipes.splice(index, 1);
10757   state.pipesCount -= 1;
10758   if (state.pipesCount === 1) state.pipes = state.pipes[0];
10759
10760   dest.emit('unpipe', this, unpipeInfo);
10761
10762   return this;
10763 };
10764
10765 // set up data events if they are asked for
10766 // Ensure readable listeners eventually get something
10767 Readable.prototype.on = function (ev, fn) {
10768   var res = Stream.prototype.on.call(this, ev, fn);
10769
10770   if (ev === 'data') {
10771     // Start flowing on next tick if stream isn't explicitly paused
10772     if (this._readableState.flowing !== false) this.resume();
10773   } else if (ev === 'readable') {
10774     var state = this._readableState;
10775     if (!state.endEmitted && !state.readableListening) {
10776       state.readableListening = state.needReadable = true;
10777       state.emittedReadable = false;
10778       if (!state.reading) {
10779         pna.nextTick(nReadingNextTick, this);
10780       } else if (state.length) {
10781         emitReadable(this);
10782       }
10783     }
10784   }
10785
10786   return res;
10787 };
10788 Readable.prototype.addListener = Readable.prototype.on;
10789
10790 function nReadingNextTick(self) {
10791   debug('readable nexttick read 0');
10792   self.read(0);
10793 }
10794
10795 // pause() and resume() are remnants of the legacy readable stream API
10796 // If the user uses them, then switch into old mode.
10797 Readable.prototype.resume = function () {
10798   var state = this._readableState;
10799   if (!state.flowing) {
10800     debug('resume');
10801     state.flowing = true;
10802     resume(this, state);
10803   }
10804   return this;
10805 };
10806
10807 function resume(stream, state) {
10808   if (!state.resumeScheduled) {
10809     state.resumeScheduled = true;
10810     pna.nextTick(resume_, stream, state);
10811   }
10812 }
10813
10814 function resume_(stream, state) {
10815   if (!state.reading) {
10816     debug('resume read 0');
10817     stream.read(0);
10818   }
10819
10820   state.resumeScheduled = false;
10821   state.awaitDrain = 0;
10822   stream.emit('resume');
10823   flow(stream);
10824   if (state.flowing && !state.reading) stream.read(0);
10825 }
10826
10827 Readable.prototype.pause = function () {
10828   debug('call pause flowing=%j', this._readableState.flowing);
10829   if (false !== this._readableState.flowing) {
10830     debug('pause');
10831     this._readableState.flowing = false;
10832     this.emit('pause');
10833   }
10834   return this;
10835 };
10836
10837 function flow(stream) {
10838   var state = stream._readableState;
10839   debug('flow', state.flowing);
10840   while (state.flowing && stream.read() !== null) {}
10841 }
10842
10843 // wrap an old-style stream as the async data source.
10844 // This is *not* part of the readable stream interface.
10845 // It is an ugly unfortunate mess of history.
10846 Readable.prototype.wrap = function (stream) {
10847   var _this = this;
10848
10849   var state = this._readableState;
10850   var paused = false;
10851
10852   stream.on('end', function () {
10853     debug('wrapped end');
10854     if (state.decoder && !state.ended) {
10855       var chunk = state.decoder.end();
10856       if (chunk && chunk.length) _this.push(chunk);
10857     }
10858
10859     _this.push(null);
10860   });
10861
10862   stream.on('data', function (chunk) {
10863     debug('wrapped data');
10864     if (state.decoder) chunk = state.decoder.write(chunk);
10865
10866     // don't skip over falsy values in objectMode
10867     if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
10868
10869     var ret = _this.push(chunk);
10870     if (!ret) {
10871       paused = true;
10872       stream.pause();
10873     }
10874   });
10875
10876   // proxy all the other methods.
10877   // important when wrapping filters and duplexes.
10878   for (var i in stream) {
10879     if (this[i] === undefined && typeof stream[i] === 'function') {
10880       this[i] = function (method) {
10881         return function () {
10882           return stream[method].apply(stream, arguments);
10883         };
10884       }(i);
10885     }
10886   }
10887
10888   // proxy certain important events.
10889   for (var n = 0; n < kProxyEvents.length; n++) {
10890     stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
10891   }
10892
10893   // when we try to consume some more bytes, simply unpause the
10894   // underlying stream.
10895   this._read = function (n) {
10896     debug('wrapped _read', n);
10897     if (paused) {
10898       paused = false;
10899       stream.resume();
10900     }
10901   };
10902
10903   return this;
10904 };
10905
10906 Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
10907   // making it explicit this property is not enumerable
10908   // because otherwise some prototype manipulation in
10909   // userland will fail
10910   enumerable: false,
10911   get: function () {
10912     return this._readableState.highWaterMark;
10913   }
10914 });
10915
10916 // exposed for testing purposes only.
10917 Readable._fromList = fromList;
10918
10919 // Pluck off n bytes from an array of buffers.
10920 // Length is the combined lengths of all the buffers in the list.
10921 // This function is designed to be inlinable, so please take care when making
10922 // changes to the function body.
10923 function fromList(n, state) {
10924   // nothing buffered
10925   if (state.length === 0) return null;
10926
10927   var ret;
10928   if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
10929     // read it all, truncate the list
10930     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);
10931     state.buffer.clear();
10932   } else {
10933     // read part of list
10934     ret = fromListPartial(n, state.buffer, state.decoder);
10935   }
10936
10937   return ret;
10938 }
10939
10940 // Extracts only enough buffered data to satisfy the amount requested.
10941 // This function is designed to be inlinable, so please take care when making
10942 // changes to the function body.
10943 function fromListPartial(n, list, hasStrings) {
10944   var ret;
10945   if (n < list.head.data.length) {
10946     // slice is the same for buffers and strings
10947     ret = list.head.data.slice(0, n);
10948     list.head.data = list.head.data.slice(n);
10949   } else if (n === list.head.data.length) {
10950     // first chunk is a perfect match
10951     ret = list.shift();
10952   } else {
10953     // result spans more than one buffer
10954     ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
10955   }
10956   return ret;
10957 }
10958
10959 // Copies a specified amount of characters from the list of buffered data
10960 // chunks.
10961 // This function is designed to be inlinable, so please take care when making
10962 // changes to the function body.
10963 function copyFromBufferString(n, list) {
10964   var p = list.head;
10965   var c = 1;
10966   var ret = p.data;
10967   n -= ret.length;
10968   while (p = p.next) {
10969     var str = p.data;
10970     var nb = n > str.length ? str.length : n;
10971     if (nb === str.length) ret += str;else ret += str.slice(0, n);
10972     n -= nb;
10973     if (n === 0) {
10974       if (nb === str.length) {
10975         ++c;
10976         if (p.next) list.head = p.next;else list.head = list.tail = null;
10977       } else {
10978         list.head = p;
10979         p.data = str.slice(nb);
10980       }
10981       break;
10982     }
10983     ++c;
10984   }
10985   list.length -= c;
10986   return ret;
10987 }
10988
10989 // Copies a specified amount of bytes from the list of buffered data chunks.
10990 // This function is designed to be inlinable, so please take care when making
10991 // changes to the function body.
10992 function copyFromBuffer(n, list) {
10993   var ret = Buffer.allocUnsafe(n);
10994   var p = list.head;
10995   var c = 1;
10996   p.data.copy(ret);
10997   n -= p.data.length;
10998   while (p = p.next) {
10999     var buf = p.data;
11000     var nb = n > buf.length ? buf.length : n;
11001     buf.copy(ret, ret.length - n, 0, nb);
11002     n -= nb;
11003     if (n === 0) {
11004       if (nb === buf.length) {
11005         ++c;
11006         if (p.next) list.head = p.next;else list.head = list.tail = null;
11007       } else {
11008         list.head = p;
11009         p.data = buf.slice(nb);
11010       }
11011       break;
11012     }
11013     ++c;
11014   }
11015   list.length -= c;
11016   return ret;
11017 }
11018
11019 function endReadable(stream) {
11020   var state = stream._readableState;
11021
11022   // If we get here before consuming all the bytes, then that is a
11023   // bug in node.  Should never happen.
11024   if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
11025
11026   if (!state.endEmitted) {
11027     state.ended = true;
11028     pna.nextTick(endReadableNT, state, stream);
11029   }
11030 }
11031
11032 function endReadableNT(state, stream) {
11033   // Check that we didn't get one last unshift.
11034   if (!state.endEmitted && state.length === 0) {
11035     state.endEmitted = true;
11036     stream.readable = false;
11037     stream.emit('end');
11038   }
11039 }
11040
11041 function indexOf(xs, x) {
11042   for (var i = 0, l = xs.length; i < l; i++) {
11043     if (xs[i] === x) return i;
11044   }
11045   return -1;
11046 }
11047 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
11048
11049 /***/ }),
11050 /* 96 */
11051 /***/ (function(module, exports, __webpack_require__) {
11052
11053 module.exports = __webpack_require__(58).EventEmitter;
11054
11055
11056 /***/ }),
11057 /* 97 */
11058 /***/ (function(module, exports, __webpack_require__) {
11059
11060 "use strict";
11061
11062
11063 /*<replacement>*/
11064
11065 var pna = __webpack_require__(42);
11066 /*</replacement>*/
11067
11068 // undocumented cb() API, needed for core, not for public API
11069 function destroy(err, cb) {
11070   var _this = this;
11071
11072   var readableDestroyed = this._readableState && this._readableState.destroyed;
11073   var writableDestroyed = this._writableState && this._writableState.destroyed;
11074
11075   if (readableDestroyed || writableDestroyed) {
11076     if (cb) {
11077       cb(err);
11078     } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
11079       pna.nextTick(emitErrorNT, this, err);
11080     }
11081     return this;
11082   }
11083
11084   // we set destroyed to true before firing error callbacks in order
11085   // to make it re-entrance safe in case destroy() is called within callbacks
11086
11087   if (this._readableState) {
11088     this._readableState.destroyed = true;
11089   }
11090
11091   // if this is a duplex stream mark the writable part as destroyed as well
11092   if (this._writableState) {
11093     this._writableState.destroyed = true;
11094   }
11095
11096   this._destroy(err || null, function (err) {
11097     if (!cb && err) {
11098       pna.nextTick(emitErrorNT, _this, err);
11099       if (_this._writableState) {
11100         _this._writableState.errorEmitted = true;
11101       }
11102     } else if (cb) {
11103       cb(err);
11104     }
11105   });
11106
11107   return this;
11108 }
11109
11110 function undestroy() {
11111   if (this._readableState) {
11112     this._readableState.destroyed = false;
11113     this._readableState.reading = false;
11114     this._readableState.ended = false;
11115     this._readableState.endEmitted = false;
11116   }
11117
11118   if (this._writableState) {
11119     this._writableState.destroyed = false;
11120     this._writableState.ended = false;
11121     this._writableState.ending = false;
11122     this._writableState.finished = false;
11123     this._writableState.errorEmitted = false;
11124   }
11125 }
11126
11127 function emitErrorNT(self, err) {
11128   self.emit('error', err);
11129 }
11130
11131 module.exports = {
11132   destroy: destroy,
11133   undestroy: undestroy
11134 };
11135
11136 /***/ }),
11137 /* 98 */
11138 /***/ (function(module, exports, __webpack_require__) {
11139
11140 "use strict";
11141 // Copyright Joyent, Inc. and other Node contributors.
11142 //
11143 // Permission is hereby granted, free of charge, to any person obtaining a
11144 // copy of this software and associated documentation files (the
11145 // "Software"), to deal in the Software without restriction, including
11146 // without limitation the rights to use, copy, modify, merge, publish,
11147 // distribute, sublicense, and/or sell copies of the Software, and to permit
11148 // persons to whom the Software is furnished to do so, subject to the
11149 // following conditions:
11150 //
11151 // The above copyright notice and this permission notice shall be included
11152 // in all copies or substantial portions of the Software.
11153 //
11154 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11155 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11156 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
11157 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
11158 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11159 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
11160 // USE OR OTHER DEALINGS IN THE SOFTWARE.
11161
11162 // a transform stream is a readable/writable stream where you do
11163 // something with the data.  Sometimes it's called a "filter",
11164 // but that's not a great name for it, since that implies a thing where
11165 // some bits pass through, and others are simply ignored.  (That would
11166 // be a valid example of a transform, of course.)
11167 //
11168 // While the output is causally related to the input, it's not a
11169 // necessarily symmetric or synchronous transformation.  For example,
11170 // a zlib stream might take multiple plain-text writes(), and then
11171 // emit a single compressed chunk some time in the future.
11172 //
11173 // Here's how this works:
11174 //
11175 // The Transform stream has all the aspects of the readable and writable
11176 // stream classes.  When you write(chunk), that calls _write(chunk,cb)
11177 // internally, and returns false if there's a lot of pending writes
11178 // buffered up.  When you call read(), that calls _read(n) until
11179 // there's enough pending readable data buffered up.
11180 //
11181 // In a transform stream, the written data is placed in a buffer.  When
11182 // _read(n) is called, it transforms the queued up data, calling the
11183 // buffered _write cb's as it consumes chunks.  If consuming a single
11184 // written chunk would result in multiple output chunks, then the first
11185 // outputted bit calls the readcb, and subsequent chunks just go into
11186 // the read buffer, and will cause it to emit 'readable' if necessary.
11187 //
11188 // This way, back-pressure is actually determined by the reading side,
11189 // since _read has to be called to start processing a new chunk.  However,
11190 // a pathological inflate type of transform can cause excessive buffering
11191 // here.  For example, imagine a stream where every byte of input is
11192 // interpreted as an integer from 0-255, and then results in that many
11193 // bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
11194 // 1kb of data being output.  In this case, you could write a very small
11195 // amount of input, and end up with a very large amount of output.  In
11196 // such a pathological inflating mechanism, there'd be no way to tell
11197 // the system to stop doing the transform.  A single 4MB write could
11198 // cause the system to run out of memory.
11199 //
11200 // However, even in such a pathological case, only a single written chunk
11201 // would be consumed, and then the rest would wait (un-transformed) until
11202 // the results of the previous transformed chunk were consumed.
11203
11204
11205
11206 module.exports = Transform;
11207
11208 var Duplex = __webpack_require__(21);
11209
11210 /*<replacement>*/
11211 var util = __webpack_require__(30);
11212 util.inherits = __webpack_require__(1);
11213 /*</replacement>*/
11214
11215 util.inherits(Transform, Duplex);
11216
11217 function afterTransform(er, data) {
11218   var ts = this._transformState;
11219   ts.transforming = false;
11220
11221   var cb = ts.writecb;
11222
11223   if (!cb) {
11224     return this.emit('error', new Error('write callback called multiple times'));
11225   }
11226
11227   ts.writechunk = null;
11228   ts.writecb = null;
11229
11230   if (data != null) // single equals check for both `null` and `undefined`
11231     this.push(data);
11232
11233   cb(er);
11234
11235   var rs = this._readableState;
11236   rs.reading = false;
11237   if (rs.needReadable || rs.length < rs.highWaterMark) {
11238     this._read(rs.highWaterMark);
11239   }
11240 }
11241
11242 function Transform(options) {
11243   if (!(this instanceof Transform)) return new Transform(options);
11244
11245   Duplex.call(this, options);
11246
11247   this._transformState = {
11248     afterTransform: afterTransform.bind(this),
11249     needTransform: false,
11250     transforming: false,
11251     writecb: null,
11252     writechunk: null,
11253     writeencoding: null
11254   };
11255
11256   // start out asking for a readable event once data is transformed.
11257   this._readableState.needReadable = true;
11258
11259   // we have implemented the _read method, and done the other things
11260   // that Readable wants before the first _read call, so unset the
11261   // sync guard flag.
11262   this._readableState.sync = false;
11263
11264   if (options) {
11265     if (typeof options.transform === 'function') this._transform = options.transform;
11266
11267     if (typeof options.flush === 'function') this._flush = options.flush;
11268   }
11269
11270   // When the writable side finishes, then flush out anything remaining.
11271   this.on('prefinish', prefinish);
11272 }
11273
11274 function prefinish() {
11275   var _this = this;
11276
11277   if (typeof this._flush === 'function') {
11278     this._flush(function (er, data) {
11279       done(_this, er, data);
11280     });
11281   } else {
11282     done(this, null, null);
11283   }
11284 }
11285
11286 Transform.prototype.push = function (chunk, encoding) {
11287   this._transformState.needTransform = false;
11288   return Duplex.prototype.push.call(this, chunk, encoding);
11289 };
11290
11291 // This is the part where you do stuff!
11292 // override this function in implementation classes.
11293 // 'chunk' is an input chunk.
11294 //
11295 // Call `push(newChunk)` to pass along transformed output
11296 // to the readable side.  You may call 'push' zero or more times.
11297 //
11298 // Call `cb(err)` when you are done with this chunk.  If you pass
11299 // an error, then that'll put the hurt on the whole operation.  If you
11300 // never call cb(), then you'll never get another chunk.
11301 Transform.prototype._transform = function (chunk, encoding, cb) {
11302   throw new Error('_transform() is not implemented');
11303 };
11304
11305 Transform.prototype._write = function (chunk, encoding, cb) {
11306   var ts = this._transformState;
11307   ts.writecb = cb;
11308   ts.writechunk = chunk;
11309   ts.writeencoding = encoding;
11310   if (!ts.transforming) {
11311     var rs = this._readableState;
11312     if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
11313   }
11314 };
11315
11316 // Doesn't matter what the args are here.
11317 // _transform does all the work.
11318 // That we got here means that the readable side wants more data.
11319 Transform.prototype._read = function (n) {
11320   var ts = this._transformState;
11321
11322   if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
11323     ts.transforming = true;
11324     this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
11325   } else {
11326     // mark that we need a transform, so that any data that comes in
11327     // will get processed, now that we've asked for it.
11328     ts.needTransform = true;
11329   }
11330 };
11331
11332 Transform.prototype._destroy = function (err, cb) {
11333   var _this2 = this;
11334
11335   Duplex.prototype._destroy.call(this, err, function (err2) {
11336     cb(err2);
11337     _this2.emit('close');
11338   });
11339 };
11340
11341 function done(stream, er, data) {
11342   if (er) return stream.emit('error', er);
11343
11344   if (data != null) // single equals check for both `null` and `undefined`
11345     stream.push(data);
11346
11347   // if there's nothing in the write buffer, then that means
11348   // that nothing more will ever be provided
11349   if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
11350
11351   if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
11352
11353   return stream.push(null);
11354 }
11355
11356 /***/ }),
11357 /* 99 */
11358 /***/ (function(module, exports, __webpack_require__) {
11359
11360 /**
11361  * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
11362  * in FIPS 180-2
11363  * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
11364  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
11365  *
11366  */
11367
11368 var inherits = __webpack_require__(1)
11369 var Hash = __webpack_require__(24)
11370 var Buffer = __webpack_require__(2).Buffer
11371
11372 var K = [
11373   0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
11374   0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
11375   0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
11376   0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
11377   0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
11378   0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
11379   0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
11380   0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
11381   0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
11382   0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
11383   0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
11384   0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
11385   0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
11386   0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
11387   0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
11388   0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
11389 ]
11390
11391 var W = new Array(64)
11392
11393 function Sha256 () {
11394   this.init()
11395
11396   this._w = W // new Array(64)
11397
11398   Hash.call(this, 64, 56)
11399 }
11400
11401 inherits(Sha256, Hash)
11402
11403 Sha256.prototype.init = function () {
11404   this._a = 0x6a09e667
11405   this._b = 0xbb67ae85
11406   this._c = 0x3c6ef372
11407   this._d = 0xa54ff53a
11408   this._e = 0x510e527f
11409   this._f = 0x9b05688c
11410   this._g = 0x1f83d9ab
11411   this._h = 0x5be0cd19
11412
11413   return this
11414 }
11415
11416 function ch (x, y, z) {
11417   return z ^ (x & (y ^ z))
11418 }
11419
11420 function maj (x, y, z) {
11421   return (x & y) | (z & (x | y))
11422 }
11423
11424 function sigma0 (x) {
11425   return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
11426 }
11427
11428 function sigma1 (x) {
11429   return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
11430 }
11431
11432 function gamma0 (x) {
11433   return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
11434 }
11435
11436 function gamma1 (x) {
11437   return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
11438 }
11439
11440 Sha256.prototype._update = function (M) {
11441   var W = this._w
11442
11443   var a = this._a | 0
11444   var b = this._b | 0
11445   var c = this._c | 0
11446   var d = this._d | 0
11447   var e = this._e | 0
11448   var f = this._f | 0
11449   var g = this._g | 0
11450   var h = this._h | 0
11451
11452   for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
11453   for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
11454
11455   for (var j = 0; j < 64; ++j) {
11456     var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
11457     var T2 = (sigma0(a) + maj(a, b, c)) | 0
11458
11459     h = g
11460     g = f
11461     f = e
11462     e = (d + T1) | 0
11463     d = c
11464     c = b
11465     b = a
11466     a = (T1 + T2) | 0
11467   }
11468
11469   this._a = (a + this._a) | 0
11470   this._b = (b + this._b) | 0
11471   this._c = (c + this._c) | 0
11472   this._d = (d + this._d) | 0
11473   this._e = (e + this._e) | 0
11474   this._f = (f + this._f) | 0
11475   this._g = (g + this._g) | 0
11476   this._h = (h + this._h) | 0
11477 }
11478
11479 Sha256.prototype._hash = function () {
11480   var H = Buffer.allocUnsafe(32)
11481
11482   H.writeInt32BE(this._a, 0)
11483   H.writeInt32BE(this._b, 4)
11484   H.writeInt32BE(this._c, 8)
11485   H.writeInt32BE(this._d, 12)
11486   H.writeInt32BE(this._e, 16)
11487   H.writeInt32BE(this._f, 20)
11488   H.writeInt32BE(this._g, 24)
11489   H.writeInt32BE(this._h, 28)
11490
11491   return H
11492 }
11493
11494 module.exports = Sha256
11495
11496
11497 /***/ }),
11498 /* 100 */
11499 /***/ (function(module, exports, __webpack_require__) {
11500
11501 var inherits = __webpack_require__(1)
11502 var Hash = __webpack_require__(24)
11503 var Buffer = __webpack_require__(2).Buffer
11504
11505 var K = [
11506   0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
11507   0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
11508   0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
11509   0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
11510   0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
11511   0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
11512   0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
11513   0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
11514   0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
11515   0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
11516   0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
11517   0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
11518   0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
11519   0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
11520   0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
11521   0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
11522   0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
11523   0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
11524   0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
11525   0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
11526   0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
11527   0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
11528   0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
11529   0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
11530   0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
11531   0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
11532   0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
11533   0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
11534   0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
11535   0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
11536   0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
11537   0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
11538   0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
11539   0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
11540   0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
11541   0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
11542   0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
11543   0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
11544   0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
11545   0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
11546 ]
11547
11548 var W = new Array(160)
11549
11550 function Sha512 () {
11551   this.init()
11552   this._w = W
11553
11554   Hash.call(this, 128, 112)
11555 }
11556
11557 inherits(Sha512, Hash)
11558
11559 Sha512.prototype.init = function () {
11560   this._ah = 0x6a09e667
11561   this._bh = 0xbb67ae85
11562   this._ch = 0x3c6ef372
11563   this._dh = 0xa54ff53a
11564   this._eh = 0x510e527f
11565   this._fh = 0x9b05688c
11566   this._gh = 0x1f83d9ab
11567   this._hh = 0x5be0cd19
11568
11569   this._al = 0xf3bcc908
11570   this._bl = 0x84caa73b
11571   this._cl = 0xfe94f82b
11572   this._dl = 0x5f1d36f1
11573   this._el = 0xade682d1
11574   this._fl = 0x2b3e6c1f
11575   this._gl = 0xfb41bd6b
11576   this._hl = 0x137e2179
11577
11578   return this
11579 }
11580
11581 function Ch (x, y, z) {
11582   return z ^ (x & (y ^ z))
11583 }
11584
11585 function maj (x, y, z) {
11586   return (x & y) | (z & (x | y))
11587 }
11588
11589 function sigma0 (x, xl) {
11590   return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
11591 }
11592
11593 function sigma1 (x, xl) {
11594   return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
11595 }
11596
11597 function Gamma0 (x, xl) {
11598   return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
11599 }
11600
11601 function Gamma0l (x, xl) {
11602   return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
11603 }
11604
11605 function Gamma1 (x, xl) {
11606   return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
11607 }
11608
11609 function Gamma1l (x, xl) {
11610   return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
11611 }
11612
11613 function getCarry (a, b) {
11614   return (a >>> 0) < (b >>> 0) ? 1 : 0
11615 }
11616
11617 Sha512.prototype._update = function (M) {
11618   var W = this._w
11619
11620   var ah = this._ah | 0
11621   var bh = this._bh | 0
11622   var ch = this._ch | 0
11623   var dh = this._dh | 0
11624   var eh = this._eh | 0
11625   var fh = this._fh | 0
11626   var gh = this._gh | 0
11627   var hh = this._hh | 0
11628
11629   var al = this._al | 0
11630   var bl = this._bl | 0
11631   var cl = this._cl | 0
11632   var dl = this._dl | 0
11633   var el = this._el | 0
11634   var fl = this._fl | 0
11635   var gl = this._gl | 0
11636   var hl = this._hl | 0
11637
11638   for (var i = 0; i < 32; i += 2) {
11639     W[i] = M.readInt32BE(i * 4)
11640     W[i + 1] = M.readInt32BE(i * 4 + 4)
11641   }
11642   for (; i < 160; i += 2) {
11643     var xh = W[i - 15 * 2]
11644     var xl = W[i - 15 * 2 + 1]
11645     var gamma0 = Gamma0(xh, xl)
11646     var gamma0l = Gamma0l(xl, xh)
11647
11648     xh = W[i - 2 * 2]
11649     xl = W[i - 2 * 2 + 1]
11650     var gamma1 = Gamma1(xh, xl)
11651     var gamma1l = Gamma1l(xl, xh)
11652
11653     // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
11654     var Wi7h = W[i - 7 * 2]
11655     var Wi7l = W[i - 7 * 2 + 1]
11656
11657     var Wi16h = W[i - 16 * 2]
11658     var Wi16l = W[i - 16 * 2 + 1]
11659
11660     var Wil = (gamma0l + Wi7l) | 0
11661     var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
11662     Wil = (Wil + gamma1l) | 0
11663     Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
11664     Wil = (Wil + Wi16l) | 0
11665     Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
11666
11667     W[i] = Wih
11668     W[i + 1] = Wil
11669   }
11670
11671   for (var j = 0; j < 160; j += 2) {
11672     Wih = W[j]
11673     Wil = W[j + 1]
11674
11675     var majh = maj(ah, bh, ch)
11676     var majl = maj(al, bl, cl)
11677
11678     var sigma0h = sigma0(ah, al)
11679     var sigma0l = sigma0(al, ah)
11680     var sigma1h = sigma1(eh, el)
11681     var sigma1l = sigma1(el, eh)
11682
11683     // t1 = h + sigma1 + ch + K[j] + W[j]
11684     var Kih = K[j]
11685     var Kil = K[j + 1]
11686
11687     var chh = Ch(eh, fh, gh)
11688     var chl = Ch(el, fl, gl)
11689
11690     var t1l = (hl + sigma1l) | 0
11691     var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
11692     t1l = (t1l + chl) | 0
11693     t1h = (t1h + chh + getCarry(t1l, chl)) | 0
11694     t1l = (t1l + Kil) | 0
11695     t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
11696     t1l = (t1l + Wil) | 0
11697     t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
11698
11699     // t2 = sigma0 + maj
11700     var t2l = (sigma0l + majl) | 0
11701     var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
11702
11703     hh = gh
11704     hl = gl
11705     gh = fh
11706     gl = fl
11707     fh = eh
11708     fl = el
11709     el = (dl + t1l) | 0
11710     eh = (dh + t1h + getCarry(el, dl)) | 0
11711     dh = ch
11712     dl = cl
11713     ch = bh
11714     cl = bl
11715     bh = ah
11716     bl = al
11717     al = (t1l + t2l) | 0
11718     ah = (t1h + t2h + getCarry(al, t1l)) | 0
11719   }
11720
11721   this._al = (this._al + al) | 0
11722   this._bl = (this._bl + bl) | 0
11723   this._cl = (this._cl + cl) | 0
11724   this._dl = (this._dl + dl) | 0
11725   this._el = (this._el + el) | 0
11726   this._fl = (this._fl + fl) | 0
11727   this._gl = (this._gl + gl) | 0
11728   this._hl = (this._hl + hl) | 0
11729
11730   this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
11731   this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
11732   this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
11733   this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
11734   this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
11735   this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
11736   this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
11737   this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
11738 }
11739
11740 Sha512.prototype._hash = function () {
11741   var H = Buffer.allocUnsafe(64)
11742
11743   function writeInt64BE (h, l, offset) {
11744     H.writeInt32BE(h, offset)
11745     H.writeInt32BE(l, offset + 4)
11746   }
11747
11748   writeInt64BE(this._ah, this._al, 0)
11749   writeInt64BE(this._bh, this._bl, 8)
11750   writeInt64BE(this._ch, this._cl, 16)
11751   writeInt64BE(this._dh, this._dl, 24)
11752   writeInt64BE(this._eh, this._el, 32)
11753   writeInt64BE(this._fh, this._fl, 40)
11754   writeInt64BE(this._gh, this._gl, 48)
11755   writeInt64BE(this._hh, this._hl, 56)
11756
11757   return H
11758 }
11759
11760 module.exports = Sha512
11761
11762
11763 /***/ }),
11764 /* 101 */
11765 /***/ (function(module, exports, __webpack_require__) {
11766
11767 "use strict";
11768
11769 var inherits = __webpack_require__(1)
11770 var Legacy = __webpack_require__(196)
11771 var Base = __webpack_require__(18)
11772 var Buffer = __webpack_require__(2).Buffer
11773 var md5 = __webpack_require__(102)
11774 var RIPEMD160 = __webpack_require__(62)
11775
11776 var sha = __webpack_require__(63)
11777
11778 var ZEROS = Buffer.alloc(128)
11779
11780 function Hmac (alg, key) {
11781   Base.call(this, 'digest')
11782   if (typeof key === 'string') {
11783     key = Buffer.from(key)
11784   }
11785
11786   var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
11787
11788   this._alg = alg
11789   this._key = key
11790   if (key.length > blocksize) {
11791     var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
11792     key = hash.update(key).digest()
11793   } else if (key.length < blocksize) {
11794     key = Buffer.concat([key, ZEROS], blocksize)
11795   }
11796
11797   var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
11798   var opad = this._opad = Buffer.allocUnsafe(blocksize)
11799
11800   for (var i = 0; i < blocksize; i++) {
11801     ipad[i] = key[i] ^ 0x36
11802     opad[i] = key[i] ^ 0x5C
11803   }
11804   this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
11805   this._hash.update(ipad)
11806 }
11807
11808 inherits(Hmac, Base)
11809
11810 Hmac.prototype._update = function (data) {
11811   this._hash.update(data)
11812 }
11813
11814 Hmac.prototype._final = function () {
11815   var h = this._hash.digest()
11816   var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
11817   return hash.update(this._opad).update(h).digest()
11818 }
11819
11820 module.exports = function createHmac (alg, key) {
11821   alg = alg.toLowerCase()
11822   if (alg === 'rmd160' || alg === 'ripemd160') {
11823     return new Hmac('rmd160', key)
11824   }
11825   if (alg === 'md5') {
11826     return new Legacy(md5, key)
11827   }
11828   return new Hmac(alg, key)
11829 }
11830
11831
11832 /***/ }),
11833 /* 102 */
11834 /***/ (function(module, exports, __webpack_require__) {
11835
11836 var MD5 = __webpack_require__(56)
11837
11838 module.exports = function (buffer) {
11839   return new MD5().update(buffer).digest()
11840 }
11841
11842
11843 /***/ }),
11844 /* 103 */
11845 /***/ (function(module, exports) {
11846
11847 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"}}
11848
11849 /***/ }),
11850 /* 104 */
11851 /***/ (function(module, exports, __webpack_require__) {
11852
11853 exports.pbkdf2 = __webpack_require__(198)
11854 exports.pbkdf2Sync = __webpack_require__(107)
11855
11856
11857 /***/ }),
11858 /* 105 */
11859 /***/ (function(module, exports, __webpack_require__) {
11860
11861 /* WEBPACK VAR INJECTION */(function(Buffer) {var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
11862
11863 function checkBuffer (buf, name) {
11864   if (typeof buf !== 'string' && !Buffer.isBuffer(buf)) {
11865     throw new TypeError(name + ' must be a buffer or string')
11866   }
11867 }
11868
11869 module.exports = function (password, salt, iterations, keylen) {
11870   checkBuffer(password, 'Password')
11871   checkBuffer(salt, 'Salt')
11872
11873   if (typeof iterations !== 'number') {
11874     throw new TypeError('Iterations not a number')
11875   }
11876
11877   if (iterations < 0) {
11878     throw new TypeError('Bad iterations')
11879   }
11880
11881   if (typeof keylen !== 'number') {
11882     throw new TypeError('Key length not a number')
11883   }
11884
11885   if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
11886     throw new TypeError('Bad key length')
11887   }
11888 }
11889
11890 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
11891
11892 /***/ }),
11893 /* 106 */
11894 /***/ (function(module, exports, __webpack_require__) {
11895
11896 /* WEBPACK VAR INJECTION */(function(process) {var defaultEncoding
11897 /* istanbul ignore next */
11898 if (process.browser) {
11899   defaultEncoding = 'utf-8'
11900 } else {
11901   var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
11902
11903   defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
11904 }
11905 module.exports = defaultEncoding
11906
11907 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(14)))
11908
11909 /***/ }),
11910 /* 107 */
11911 /***/ (function(module, exports, __webpack_require__) {
11912
11913 var md5 = __webpack_require__(102)
11914 var rmd160 = __webpack_require__(62)
11915 var sha = __webpack_require__(63)
11916
11917 var checkParameters = __webpack_require__(105)
11918 var defaultEncoding = __webpack_require__(106)
11919 var Buffer = __webpack_require__(2).Buffer
11920 var ZEROS = Buffer.alloc(128)
11921 var sizes = {
11922   md5: 16,
11923   sha1: 20,
11924   sha224: 28,
11925   sha256: 32,
11926   sha384: 48,
11927   sha512: 64,
11928   rmd160: 20,
11929   ripemd160: 20
11930 }
11931
11932 function Hmac (alg, key, saltLen) {
11933   var hash = getDigest(alg)
11934   var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
11935
11936   if (key.length > blocksize) {
11937     key = hash(key)
11938   } else if (key.length < blocksize) {
11939     key = Buffer.concat([key, ZEROS], blocksize)
11940   }
11941
11942   var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
11943   var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
11944   for (var i = 0; i < blocksize; i++) {
11945     ipad[i] = key[i] ^ 0x36
11946     opad[i] = key[i] ^ 0x5C
11947   }
11948
11949   var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
11950   ipad.copy(ipad1, 0, 0, blocksize)
11951   this.ipad1 = ipad1
11952   this.ipad2 = ipad
11953   this.opad = opad
11954   this.alg = alg
11955   this.blocksize = blocksize
11956   this.hash = hash
11957   this.size = sizes[alg]
11958 }
11959
11960 Hmac.prototype.run = function (data, ipad) {
11961   data.copy(ipad, this.blocksize)
11962   var h = this.hash(ipad)
11963   h.copy(this.opad, this.blocksize)
11964   return this.hash(this.opad)
11965 }
11966
11967 function getDigest (alg) {
11968   function shaFunc (data) {
11969     return sha(alg).update(data).digest()
11970   }
11971
11972   if (alg === 'rmd160' || alg === 'ripemd160') return rmd160
11973   if (alg === 'md5') return md5
11974   return shaFunc
11975 }
11976
11977 function pbkdf2 (password, salt, iterations, keylen, digest) {
11978   checkParameters(password, salt, iterations, keylen)
11979
11980   if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
11981   if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
11982
11983   digest = digest || 'sha1'
11984
11985   var hmac = new Hmac(digest, password, salt.length)
11986
11987   var DK = Buffer.allocUnsafe(keylen)
11988   var block1 = Buffer.allocUnsafe(salt.length + 4)
11989   salt.copy(block1, 0, 0, salt.length)
11990
11991   var destPos = 0
11992   var hLen = sizes[digest]
11993   var l = Math.ceil(keylen / hLen)
11994
11995   for (var i = 1; i <= l; i++) {
11996     block1.writeUInt32BE(i, salt.length)
11997
11998     var T = hmac.run(block1, hmac.ipad1)
11999     var U = T
12000
12001     for (var j = 1; j < iterations; j++) {
12002       U = hmac.run(U, hmac.ipad2)
12003       for (var k = 0; k < hLen; k++) T[k] ^= U[k]
12004     }
12005
12006     T.copy(DK, destPos)
12007     destPos += hLen
12008   }
12009
12010   return DK
12011 }
12012
12013 module.exports = pbkdf2
12014
12015
12016 /***/ }),
12017 /* 108 */
12018 /***/ (function(module, exports, __webpack_require__) {
12019
12020 var xor = __webpack_require__(31)
12021 var Buffer = __webpack_require__(2).Buffer
12022 var incr32 = __webpack_require__(109)
12023
12024 function getBlock (self) {
12025   var out = self._cipher.encryptBlockRaw(self._prev)
12026   incr32(self._prev)
12027   return out
12028 }
12029
12030 var blockSize = 16
12031 exports.encrypt = function (self, chunk) {
12032   var chunkNum = Math.ceil(chunk.length / blockSize)
12033   var start = self._cache.length
12034   self._cache = Buffer.concat([
12035     self._cache,
12036     Buffer.allocUnsafe(chunkNum * blockSize)
12037   ])
12038   for (var i = 0; i < chunkNum; i++) {
12039     var out = getBlock(self)
12040     var offset = start + i * blockSize
12041     self._cache.writeUInt32BE(out[0], offset + 0)
12042     self._cache.writeUInt32BE(out[1], offset + 4)
12043     self._cache.writeUInt32BE(out[2], offset + 8)
12044     self._cache.writeUInt32BE(out[3], offset + 12)
12045   }
12046   var pad = self._cache.slice(0, chunk.length)
12047   self._cache = self._cache.slice(chunk.length)
12048   return xor(chunk, pad)
12049 }
12050
12051
12052 /***/ }),
12053 /* 109 */
12054 /***/ (function(module, exports) {
12055
12056 function incr32 (iv) {
12057   var len = iv.length
12058   var item
12059   while (len--) {
12060     item = iv.readUInt8(len)
12061     if (item === 255) {
12062       iv.writeUInt8(0, len)
12063     } else {
12064       item++
12065       iv.writeUInt8(item, len)
12066       break
12067     }
12068   }
12069 }
12070 module.exports = incr32
12071
12072
12073 /***/ }),
12074 /* 110 */
12075 /***/ (function(module, exports) {
12076
12077 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"}}
12078
12079 /***/ }),
12080 /* 111 */
12081 /***/ (function(module, exports, __webpack_require__) {
12082
12083 var aes = __webpack_require__(43)
12084 var Buffer = __webpack_require__(2).Buffer
12085 var Transform = __webpack_require__(18)
12086 var inherits = __webpack_require__(1)
12087 var GHASH = __webpack_require__(213)
12088 var xor = __webpack_require__(31)
12089 var incr32 = __webpack_require__(109)
12090
12091 function xorTest (a, b) {
12092   var out = 0
12093   if (a.length !== b.length) out++
12094
12095   var len = Math.min(a.length, b.length)
12096   for (var i = 0; i < len; ++i) {
12097     out += (a[i] ^ b[i])
12098   }
12099
12100   return out
12101 }
12102
12103 function calcIv (self, iv, ck) {
12104   if (iv.length === 12) {
12105     self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
12106     return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
12107   }
12108   var ghash = new GHASH(ck)
12109   var len = iv.length
12110   var toPad = len % 16
12111   ghash.update(iv)
12112   if (toPad) {
12113     toPad = 16 - toPad
12114     ghash.update(Buffer.alloc(toPad, 0))
12115   }
12116   ghash.update(Buffer.alloc(8, 0))
12117   var ivBits = len * 8
12118   var tail = Buffer.alloc(8)
12119   tail.writeUIntBE(ivBits, 0, 8)
12120   ghash.update(tail)
12121   self._finID = ghash.state
12122   var out = Buffer.from(self._finID)
12123   incr32(out)
12124   return out
12125 }
12126 function StreamCipher (mode, key, iv, decrypt) {
12127   Transform.call(this)
12128
12129   var h = Buffer.alloc(4, 0)
12130
12131   this._cipher = new aes.AES(key)
12132   var ck = this._cipher.encryptBlock(h)
12133   this._ghash = new GHASH(ck)
12134   iv = calcIv(this, iv, ck)
12135
12136   this._prev = Buffer.from(iv)
12137   this._cache = Buffer.allocUnsafe(0)
12138   this._secCache = Buffer.allocUnsafe(0)
12139   this._decrypt = decrypt
12140   this._alen = 0
12141   this._len = 0
12142   this._mode = mode
12143
12144   this._authTag = null
12145   this._called = false
12146 }
12147
12148 inherits(StreamCipher, Transform)
12149
12150 StreamCipher.prototype._update = function (chunk) {
12151   if (!this._called && this._alen) {
12152     var rump = 16 - (this._alen % 16)
12153     if (rump < 16) {
12154       rump = Buffer.alloc(rump, 0)
12155       this._ghash.update(rump)
12156     }
12157   }
12158
12159   this._called = true
12160   var out = this._mode.encrypt(this, chunk)
12161   if (this._decrypt) {
12162     this._ghash.update(chunk)
12163   } else {
12164     this._ghash.update(out)
12165   }
12166   this._len += chunk.length
12167   return out
12168 }
12169
12170 StreamCipher.prototype._final = function () {
12171   if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
12172
12173   var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
12174   if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
12175
12176   this._authTag = tag
12177   this._cipher.scrub()
12178 }
12179
12180 StreamCipher.prototype.getAuthTag = function getAuthTag () {
12181   if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
12182
12183   return this._authTag
12184 }
12185
12186 StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
12187   if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
12188
12189   this._authTag = tag
12190 }
12191
12192 StreamCipher.prototype.setAAD = function setAAD (buf) {
12193   if (this._called) throw new Error('Attempting to set AAD in unsupported state')
12194
12195   this._ghash.update(buf)
12196   this._alen += buf.length
12197 }
12198
12199 module.exports = StreamCipher
12200
12201
12202 /***/ }),
12203 /* 112 */
12204 /***/ (function(module, exports, __webpack_require__) {
12205
12206 var aes = __webpack_require__(43)
12207 var Buffer = __webpack_require__(2).Buffer
12208 var Transform = __webpack_require__(18)
12209 var inherits = __webpack_require__(1)
12210
12211 function StreamCipher (mode, key, iv, decrypt) {
12212   Transform.call(this)
12213
12214   this._cipher = new aes.AES(key)
12215   this._prev = Buffer.from(iv)
12216   this._cache = Buffer.allocUnsafe(0)
12217   this._secCache = Buffer.allocUnsafe(0)
12218   this._decrypt = decrypt
12219   this._mode = mode
12220 }
12221
12222 inherits(StreamCipher, Transform)
12223
12224 StreamCipher.prototype._update = function (chunk) {
12225   return this._mode.encrypt(this, chunk, this._decrypt)
12226 }
12227
12228 StreamCipher.prototype._final = function () {
12229   this._cipher.scrub()
12230 }
12231
12232 module.exports = StreamCipher
12233
12234
12235 /***/ }),
12236 /* 113 */
12237 /***/ (function(module, exports, __webpack_require__) {
12238
12239 var randomBytes = __webpack_require__(23);
12240 module.exports = findPrime;
12241 findPrime.simpleSieve = simpleSieve;
12242 findPrime.fermatTest = fermatTest;
12243 var BN = __webpack_require__(4);
12244 var TWENTYFOUR = new BN(24);
12245 var MillerRabin = __webpack_require__(114);
12246 var millerRabin = new MillerRabin();
12247 var ONE = new BN(1);
12248 var TWO = new BN(2);
12249 var FIVE = new BN(5);
12250 var SIXTEEN = new BN(16);
12251 var EIGHT = new BN(8);
12252 var TEN = new BN(10);
12253 var THREE = new BN(3);
12254 var SEVEN = new BN(7);
12255 var ELEVEN = new BN(11);
12256 var FOUR = new BN(4);
12257 var TWELVE = new BN(12);
12258 var primes = null;
12259
12260 function _getPrimes() {
12261   if (primes !== null)
12262     return primes;
12263
12264   var limit = 0x100000;
12265   var res = [];
12266   res[0] = 2;
12267   for (var i = 1, k = 3; k < limit; k += 2) {
12268     var sqrt = Math.ceil(Math.sqrt(k));
12269     for (var j = 0; j < i && res[j] <= sqrt; j++)
12270       if (k % res[j] === 0)
12271         break;
12272
12273     if (i !== j && res[j] <= sqrt)
12274       continue;
12275
12276     res[i++] = k;
12277   }
12278   primes = res;
12279   return res;
12280 }
12281
12282 function simpleSieve(p) {
12283   var primes = _getPrimes();
12284
12285   for (var i = 0; i < primes.length; i++)
12286     if (p.modn(primes[i]) === 0) {
12287       if (p.cmpn(primes[i]) === 0) {
12288         return true;
12289       } else {
12290         return false;
12291       }
12292     }
12293
12294   return true;
12295 }
12296
12297 function fermatTest(p) {
12298   var red = BN.mont(p);
12299   return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
12300 }
12301
12302 function findPrime(bits, gen) {
12303   if (bits < 16) {
12304     // this is what openssl does
12305     if (gen === 2 || gen === 5) {
12306       return new BN([0x8c, 0x7b]);
12307     } else {
12308       return new BN([0x8c, 0x27]);
12309     }
12310   }
12311   gen = new BN(gen);
12312
12313   var num, n2;
12314
12315   while (true) {
12316     num = new BN(randomBytes(Math.ceil(bits / 8)));
12317     while (num.bitLength() > bits) {
12318       num.ishrn(1);
12319     }
12320     if (num.isEven()) {
12321       num.iadd(ONE);
12322     }
12323     if (!num.testn(1)) {
12324       num.iadd(TWO);
12325     }
12326     if (!gen.cmp(TWO)) {
12327       while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
12328         num.iadd(FOUR);
12329       }
12330     } else if (!gen.cmp(FIVE)) {
12331       while (num.mod(TEN).cmp(THREE)) {
12332         num.iadd(FOUR);
12333       }
12334     }
12335     n2 = num.shrn(1);
12336     if (simpleSieve(n2) && simpleSieve(num) &&
12337       fermatTest(n2) && fermatTest(num) &&
12338       millerRabin.test(n2) && millerRabin.test(num)) {
12339       return num;
12340     }
12341   }
12342
12343 }
12344
12345
12346 /***/ }),
12347 /* 114 */
12348 /***/ (function(module, exports, __webpack_require__) {
12349
12350 var bn = __webpack_require__(4);
12351 var brorand = __webpack_require__(115);
12352
12353 function MillerRabin(rand) {
12354   this.rand = rand || new brorand.Rand();
12355 }
12356 module.exports = MillerRabin;
12357
12358 MillerRabin.create = function create(rand) {
12359   return new MillerRabin(rand);
12360 };
12361
12362 MillerRabin.prototype._randbelow = function _randbelow(n) {
12363   var len = n.bitLength();
12364   var min_bytes = Math.ceil(len / 8);
12365
12366   // Generage random bytes until a number less than n is found.
12367   // This ensures that 0..n-1 have an equal probability of being selected.
12368   do
12369     var a = new bn(this.rand.generate(min_bytes));
12370   while (a.cmp(n) >= 0);
12371
12372   return a;
12373 };
12374
12375 MillerRabin.prototype._randrange = function _randrange(start, stop) {
12376   // Generate a random number greater than or equal to start and less than stop.
12377   var size = stop.sub(start);
12378   return start.add(this._randbelow(size));
12379 };
12380
12381 MillerRabin.prototype.test = function test(n, k, cb) {
12382   var len = n.bitLength();
12383   var red = bn.mont(n);
12384   var rone = new bn(1).toRed(red);
12385
12386   if (!k)
12387     k = Math.max(1, (len / 48) | 0);
12388
12389   // Find d and s, (n - 1) = (2 ^ s) * d;
12390   var n1 = n.subn(1);
12391   for (var s = 0; !n1.testn(s); s++) {}
12392   var d = n.shrn(s);
12393
12394   var rn1 = n1.toRed(red);
12395
12396   var prime = true;
12397   for (; k > 0; k--) {
12398     var a = this._randrange(new bn(2), n1);
12399     if (cb)
12400       cb(a);
12401
12402     var x = a.toRed(red).redPow(d);
12403     if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
12404       continue;
12405
12406     for (var i = 1; i < s; i++) {
12407       x = x.redSqr();
12408
12409       if (x.cmp(rone) === 0)
12410         return false;
12411       if (x.cmp(rn1) === 0)
12412         break;
12413     }
12414
12415     if (i === s)
12416       return false;
12417   }
12418
12419   return prime;
12420 };
12421
12422 MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
12423   var len = n.bitLength();
12424   var red = bn.mont(n);
12425   var rone = new bn(1).toRed(red);
12426
12427   if (!k)
12428     k = Math.max(1, (len / 48) | 0);
12429
12430   // Find d and s, (n - 1) = (2 ^ s) * d;
12431   var n1 = n.subn(1);
12432   for (var s = 0; !n1.testn(s); s++) {}
12433   var d = n.shrn(s);
12434
12435   var rn1 = n1.toRed(red);
12436
12437   for (; k > 0; k--) {
12438     var a = this._randrange(new bn(2), n1);
12439
12440     var g = n.gcd(a);
12441     if (g.cmpn(1) !== 0)
12442       return g;
12443
12444     var x = a.toRed(red).redPow(d);
12445     if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
12446       continue;
12447
12448     for (var i = 1; i < s; i++) {
12449       x = x.redSqr();
12450
12451       if (x.cmp(rone) === 0)
12452         return x.fromRed().subn(1).gcd(n);
12453       if (x.cmp(rn1) === 0)
12454         break;
12455     }
12456
12457     if (i === s) {
12458       x = x.redSqr();
12459       return x.fromRed().subn(1).gcd(n);
12460     }
12461   }
12462
12463   return false;
12464 };
12465
12466
12467 /***/ }),
12468 /* 115 */
12469 /***/ (function(module, exports, __webpack_require__) {
12470
12471 var r;
12472
12473 module.exports = function rand(len) {
12474   if (!r)
12475     r = new Rand(null);
12476
12477   return r.generate(len);
12478 };
12479
12480 function Rand(rand) {
12481   this.rand = rand;
12482 }
12483 module.exports.Rand = Rand;
12484
12485 Rand.prototype.generate = function generate(len) {
12486   return this._rand(len);
12487 };
12488
12489 // Emulate crypto API using randy
12490 Rand.prototype._rand = function _rand(n) {
12491   if (this.rand.getBytes)
12492     return this.rand.getBytes(n);
12493
12494   var res = new Uint8Array(n);
12495   for (var i = 0; i < res.length; i++)
12496     res[i] = this.rand.getByte();
12497   return res;
12498 };
12499
12500 if (typeof self === 'object') {
12501   if (self.crypto && self.crypto.getRandomValues) {
12502     // Modern browsers
12503     Rand.prototype._rand = function _rand(n) {
12504       var arr = new Uint8Array(n);
12505       self.crypto.getRandomValues(arr);
12506       return arr;
12507     };
12508   } else if (self.msCrypto && self.msCrypto.getRandomValues) {
12509     // IE
12510     Rand.prototype._rand = function _rand(n) {
12511       var arr = new Uint8Array(n);
12512       self.msCrypto.getRandomValues(arr);
12513       return arr;
12514     };
12515
12516   // Safari's WebWorkers do not have `crypto`
12517   } else if (typeof window === 'object') {
12518     // Old junk
12519     Rand.prototype._rand = function() {
12520       throw new Error('Not implemented yet');
12521     };
12522   }
12523 } else {
12524   // Node.js or Web worker with no crypto support
12525   try {
12526     var crypto = __webpack_require__(218);
12527     if (typeof crypto.randomBytes !== 'function')
12528       throw new Error('Not supported');
12529
12530     Rand.prototype._rand = function _rand(n) {
12531       return crypto.randomBytes(n);
12532     };
12533   } catch (e) {
12534   }
12535 }
12536
12537
12538 /***/ }),
12539 /* 116 */
12540 /***/ (function(module, exports, __webpack_require__) {
12541
12542 "use strict";
12543
12544
12545 var utils = exports;
12546
12547 function toArray(msg, enc) {
12548   if (Array.isArray(msg))
12549     return msg.slice();
12550   if (!msg)
12551     return [];
12552   var res = [];
12553   if (typeof msg !== 'string') {
12554     for (var i = 0; i < msg.length; i++)
12555       res[i] = msg[i] | 0;
12556     return res;
12557   }
12558   if (enc === 'hex') {
12559     msg = msg.replace(/[^a-z0-9]+/ig, '');
12560     if (msg.length % 2 !== 0)
12561       msg = '0' + msg;
12562     for (var i = 0; i < msg.length; i += 2)
12563       res.push(parseInt(msg[i] + msg[i + 1], 16));
12564   } else {
12565     for (var i = 0; i < msg.length; i++) {
12566       var c = msg.charCodeAt(i);
12567       var hi = c >> 8;
12568       var lo = c & 0xff;
12569       if (hi)
12570         res.push(hi, lo);
12571       else
12572         res.push(lo);
12573     }
12574   }
12575   return res;
12576 }
12577 utils.toArray = toArray;
12578
12579 function zero2(word) {
12580   if (word.length === 1)
12581     return '0' + word;
12582   else
12583     return word;
12584 }
12585 utils.zero2 = zero2;
12586
12587 function toHex(msg) {
12588   var res = '';
12589   for (var i = 0; i < msg.length; i++)
12590     res += zero2(msg[i].toString(16));
12591   return res;
12592 }
12593 utils.toHex = toHex;
12594
12595 utils.encode = function encode(arr, enc) {
12596   if (enc === 'hex')
12597     return toHex(arr);
12598   else
12599     return arr;
12600 };
12601
12602
12603 /***/ }),
12604 /* 117 */
12605 /***/ (function(module, exports, __webpack_require__) {
12606
12607 "use strict";
12608
12609
12610 var utils = __webpack_require__(11);
12611 var rotr32 = utils.rotr32;
12612
12613 function ft_1(s, x, y, z) {
12614   if (s === 0)
12615     return ch32(x, y, z);
12616   if (s === 1 || s === 3)
12617     return p32(x, y, z);
12618   if (s === 2)
12619     return maj32(x, y, z);
12620 }
12621 exports.ft_1 = ft_1;
12622
12623 function ch32(x, y, z) {
12624   return (x & y) ^ ((~x) & z);
12625 }
12626 exports.ch32 = ch32;
12627
12628 function maj32(x, y, z) {
12629   return (x & y) ^ (x & z) ^ (y & z);
12630 }
12631 exports.maj32 = maj32;
12632
12633 function p32(x, y, z) {
12634   return x ^ y ^ z;
12635 }
12636 exports.p32 = p32;
12637
12638 function s0_256(x) {
12639   return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
12640 }
12641 exports.s0_256 = s0_256;
12642
12643 function s1_256(x) {
12644   return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
12645 }
12646 exports.s1_256 = s1_256;
12647
12648 function g0_256(x) {
12649   return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
12650 }
12651 exports.g0_256 = g0_256;
12652
12653 function g1_256(x) {
12654   return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
12655 }
12656 exports.g1_256 = g1_256;
12657
12658
12659 /***/ }),
12660 /* 118 */
12661 /***/ (function(module, exports, __webpack_require__) {
12662
12663 "use strict";
12664
12665
12666 var utils = __webpack_require__(11);
12667 var common = __webpack_require__(32);
12668 var shaCommon = __webpack_require__(117);
12669 var assert = __webpack_require__(9);
12670
12671 var sum32 = utils.sum32;
12672 var sum32_4 = utils.sum32_4;
12673 var sum32_5 = utils.sum32_5;
12674 var ch32 = shaCommon.ch32;
12675 var maj32 = shaCommon.maj32;
12676 var s0_256 = shaCommon.s0_256;
12677 var s1_256 = shaCommon.s1_256;
12678 var g0_256 = shaCommon.g0_256;
12679 var g1_256 = shaCommon.g1_256;
12680
12681 var BlockHash = common.BlockHash;
12682
12683 var sha256_K = [
12684   0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
12685   0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
12686   0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
12687   0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
12688   0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
12689   0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
12690   0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
12691   0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
12692   0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
12693   0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
12694   0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
12695   0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
12696   0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
12697   0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
12698   0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
12699   0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
12700 ];
12701
12702 function SHA256() {
12703   if (!(this instanceof SHA256))
12704     return new SHA256();
12705
12706   BlockHash.call(this);
12707   this.h = [
12708     0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
12709     0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
12710   ];
12711   this.k = sha256_K;
12712   this.W = new Array(64);
12713 }
12714 utils.inherits(SHA256, BlockHash);
12715 module.exports = SHA256;
12716
12717 SHA256.blockSize = 512;
12718 SHA256.outSize = 256;
12719 SHA256.hmacStrength = 192;
12720 SHA256.padLength = 64;
12721
12722 SHA256.prototype._update = function _update(msg, start) {
12723   var W = this.W;
12724
12725   for (var i = 0; i < 16; i++)
12726     W[i] = msg[start + i];
12727   for (; i < W.length; i++)
12728     W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
12729
12730   var a = this.h[0];
12731   var b = this.h[1];
12732   var c = this.h[2];
12733   var d = this.h[3];
12734   var e = this.h[4];
12735   var f = this.h[5];
12736   var g = this.h[6];
12737   var h = this.h[7];
12738
12739   assert(this.k.length === W.length);
12740   for (i = 0; i < W.length; i++) {
12741     var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
12742     var T2 = sum32(s0_256(a), maj32(a, b, c));
12743     h = g;
12744     g = f;
12745     f = e;
12746     e = sum32(d, T1);
12747     d = c;
12748     c = b;
12749     b = a;
12750     a = sum32(T1, T2);
12751   }
12752
12753   this.h[0] = sum32(this.h[0], a);
12754   this.h[1] = sum32(this.h[1], b);
12755   this.h[2] = sum32(this.h[2], c);
12756   this.h[3] = sum32(this.h[3], d);
12757   this.h[4] = sum32(this.h[4], e);
12758   this.h[5] = sum32(this.h[5], f);
12759   this.h[6] = sum32(this.h[6], g);
12760   this.h[7] = sum32(this.h[7], h);
12761 };
12762
12763 SHA256.prototype._digest = function digest(enc) {
12764   if (enc === 'hex')
12765     return utils.toHex32(this.h, 'big');
12766   else
12767     return utils.split32(this.h, 'big');
12768 };
12769
12770
12771 /***/ }),
12772 /* 119 */
12773 /***/ (function(module, exports, __webpack_require__) {
12774
12775 "use strict";
12776
12777
12778 var utils = __webpack_require__(11);
12779 var common = __webpack_require__(32);
12780 var assert = __webpack_require__(9);
12781
12782 var rotr64_hi = utils.rotr64_hi;
12783 var rotr64_lo = utils.rotr64_lo;
12784 var shr64_hi = utils.shr64_hi;
12785 var shr64_lo = utils.shr64_lo;
12786 var sum64 = utils.sum64;
12787 var sum64_hi = utils.sum64_hi;
12788 var sum64_lo = utils.sum64_lo;
12789 var sum64_4_hi = utils.sum64_4_hi;
12790 var sum64_4_lo = utils.sum64_4_lo;
12791 var sum64_5_hi = utils.sum64_5_hi;
12792 var sum64_5_lo = utils.sum64_5_lo;
12793
12794 var BlockHash = common.BlockHash;
12795
12796 var sha512_K = [
12797   0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
12798   0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
12799   0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
12800   0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
12801   0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
12802   0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
12803   0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
12804   0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
12805   0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
12806   0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
12807   0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
12808   0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
12809   0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
12810   0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
12811   0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
12812   0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
12813   0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
12814   0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
12815   0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
12816   0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
12817   0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
12818   0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
12819   0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
12820   0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
12821   0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
12822   0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
12823   0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
12824   0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
12825   0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
12826   0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
12827   0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
12828   0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
12829   0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
12830   0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
12831   0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
12832   0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
12833   0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
12834   0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
12835   0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
12836   0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
12837 ];
12838
12839 function SHA512() {
12840   if (!(this instanceof SHA512))
12841     return new SHA512();
12842
12843   BlockHash.call(this);
12844   this.h = [
12845     0x6a09e667, 0xf3bcc908,
12846     0xbb67ae85, 0x84caa73b,
12847     0x3c6ef372, 0xfe94f82b,
12848     0xa54ff53a, 0x5f1d36f1,
12849     0x510e527f, 0xade682d1,
12850     0x9b05688c, 0x2b3e6c1f,
12851     0x1f83d9ab, 0xfb41bd6b,
12852     0x5be0cd19, 0x137e2179 ];
12853   this.k = sha512_K;
12854   this.W = new Array(160);
12855 }
12856 utils.inherits(SHA512, BlockHash);
12857 module.exports = SHA512;
12858
12859 SHA512.blockSize = 1024;
12860 SHA512.outSize = 512;
12861 SHA512.hmacStrength = 192;
12862 SHA512.padLength = 128;
12863
12864 SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
12865   var W = this.W;
12866
12867   // 32 x 32bit words
12868   for (var i = 0; i < 32; i++)
12869     W[i] = msg[start + i];
12870   for (; i < W.length; i += 2) {
12871     var c0_hi = g1_512_hi(W[i - 4], W[i - 3]);  // i - 2
12872     var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
12873     var c1_hi = W[i - 14];  // i - 7
12874     var c1_lo = W[i - 13];
12875     var c2_hi = g0_512_hi(W[i - 30], W[i - 29]);  // i - 15
12876     var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
12877     var c3_hi = W[i - 32];  // i - 16
12878     var c3_lo = W[i - 31];
12879
12880     W[i] = sum64_4_hi(
12881       c0_hi, c0_lo,
12882       c1_hi, c1_lo,
12883       c2_hi, c2_lo,
12884       c3_hi, c3_lo);
12885     W[i + 1] = sum64_4_lo(
12886       c0_hi, c0_lo,
12887       c1_hi, c1_lo,
12888       c2_hi, c2_lo,
12889       c3_hi, c3_lo);
12890   }
12891 };
12892
12893 SHA512.prototype._update = function _update(msg, start) {
12894   this._prepareBlock(msg, start);
12895
12896   var W = this.W;
12897
12898   var ah = this.h[0];
12899   var al = this.h[1];
12900   var bh = this.h[2];
12901   var bl = this.h[3];
12902   var ch = this.h[4];
12903   var cl = this.h[5];
12904   var dh = this.h[6];
12905   var dl = this.h[7];
12906   var eh = this.h[8];
12907   var el = this.h[9];
12908   var fh = this.h[10];
12909   var fl = this.h[11];
12910   var gh = this.h[12];
12911   var gl = this.h[13];
12912   var hh = this.h[14];
12913   var hl = this.h[15];
12914
12915   assert(this.k.length === W.length);
12916   for (var i = 0; i < W.length; i += 2) {
12917     var c0_hi = hh;
12918     var c0_lo = hl;
12919     var c1_hi = s1_512_hi(eh, el);
12920     var c1_lo = s1_512_lo(eh, el);
12921     var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
12922     var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
12923     var c3_hi = this.k[i];
12924     var c3_lo = this.k[i + 1];
12925     var c4_hi = W[i];
12926     var c4_lo = W[i + 1];
12927
12928     var T1_hi = sum64_5_hi(
12929       c0_hi, c0_lo,
12930       c1_hi, c1_lo,
12931       c2_hi, c2_lo,
12932       c3_hi, c3_lo,
12933       c4_hi, c4_lo);
12934     var T1_lo = sum64_5_lo(
12935       c0_hi, c0_lo,
12936       c1_hi, c1_lo,
12937       c2_hi, c2_lo,
12938       c3_hi, c3_lo,
12939       c4_hi, c4_lo);
12940
12941     c0_hi = s0_512_hi(ah, al);
12942     c0_lo = s0_512_lo(ah, al);
12943     c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
12944     c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
12945
12946     var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
12947     var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
12948
12949     hh = gh;
12950     hl = gl;
12951
12952     gh = fh;
12953     gl = fl;
12954
12955     fh = eh;
12956     fl = el;
12957
12958     eh = sum64_hi(dh, dl, T1_hi, T1_lo);
12959     el = sum64_lo(dl, dl, T1_hi, T1_lo);
12960
12961     dh = ch;
12962     dl = cl;
12963
12964     ch = bh;
12965     cl = bl;
12966
12967     bh = ah;
12968     bl = al;
12969
12970     ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
12971     al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
12972   }
12973
12974   sum64(this.h, 0, ah, al);
12975   sum64(this.h, 2, bh, bl);
12976   sum64(this.h, 4, ch, cl);
12977   sum64(this.h, 6, dh, dl);
12978   sum64(this.h, 8, eh, el);
12979   sum64(this.h, 10, fh, fl);
12980   sum64(this.h, 12, gh, gl);
12981   sum64(this.h, 14, hh, hl);
12982 };
12983
12984 SHA512.prototype._digest = function digest(enc) {
12985   if (enc === 'hex')
12986     return utils.toHex32(this.h, 'big');
12987   else
12988     return utils.split32(this.h, 'big');
12989 };
12990
12991 function ch64_hi(xh, xl, yh, yl, zh) {
12992   var r = (xh & yh) ^ ((~xh) & zh);
12993   if (r < 0)
12994     r += 0x100000000;
12995   return r;
12996 }
12997
12998 function ch64_lo(xh, xl, yh, yl, zh, zl) {
12999   var r = (xl & yl) ^ ((~xl) & zl);
13000   if (r < 0)
13001     r += 0x100000000;
13002   return r;
13003 }
13004
13005 function maj64_hi(xh, xl, yh, yl, zh) {
13006   var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
13007   if (r < 0)
13008     r += 0x100000000;
13009   return r;
13010 }
13011
13012 function maj64_lo(xh, xl, yh, yl, zh, zl) {
13013   var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
13014   if (r < 0)
13015     r += 0x100000000;
13016   return r;
13017 }
13018
13019 function s0_512_hi(xh, xl) {
13020   var c0_hi = rotr64_hi(xh, xl, 28);
13021   var c1_hi = rotr64_hi(xl, xh, 2);  // 34
13022   var c2_hi = rotr64_hi(xl, xh, 7);  // 39
13023
13024   var r = c0_hi ^ c1_hi ^ c2_hi;
13025   if (r < 0)
13026     r += 0x100000000;
13027   return r;
13028 }
13029
13030 function s0_512_lo(xh, xl) {
13031   var c0_lo = rotr64_lo(xh, xl, 28);
13032   var c1_lo = rotr64_lo(xl, xh, 2);  // 34
13033   var c2_lo = rotr64_lo(xl, xh, 7);  // 39
13034
13035   var r = c0_lo ^ c1_lo ^ c2_lo;
13036   if (r < 0)
13037     r += 0x100000000;
13038   return r;
13039 }
13040
13041 function s1_512_hi(xh, xl) {
13042   var c0_hi = rotr64_hi(xh, xl, 14);
13043   var c1_hi = rotr64_hi(xh, xl, 18);
13044   var c2_hi = rotr64_hi(xl, xh, 9);  // 41
13045
13046   var r = c0_hi ^ c1_hi ^ c2_hi;
13047   if (r < 0)
13048     r += 0x100000000;
13049   return r;
13050 }
13051
13052 function s1_512_lo(xh, xl) {
13053   var c0_lo = rotr64_lo(xh, xl, 14);
13054   var c1_lo = rotr64_lo(xh, xl, 18);
13055   var c2_lo = rotr64_lo(xl, xh, 9);  // 41
13056
13057   var r = c0_lo ^ c1_lo ^ c2_lo;
13058   if (r < 0)
13059     r += 0x100000000;
13060   return r;
13061 }
13062
13063 function g0_512_hi(xh, xl) {
13064   var c0_hi = rotr64_hi(xh, xl, 1);
13065   var c1_hi = rotr64_hi(xh, xl, 8);
13066   var c2_hi = shr64_hi(xh, xl, 7);
13067
13068   var r = c0_hi ^ c1_hi ^ c2_hi;
13069   if (r < 0)
13070     r += 0x100000000;
13071   return r;
13072 }
13073
13074 function g0_512_lo(xh, xl) {
13075   var c0_lo = rotr64_lo(xh, xl, 1);
13076   var c1_lo = rotr64_lo(xh, xl, 8);
13077   var c2_lo = shr64_lo(xh, xl, 7);
13078
13079   var r = c0_lo ^ c1_lo ^ c2_lo;
13080   if (r < 0)
13081     r += 0x100000000;
13082   return r;
13083 }
13084
13085 function g1_512_hi(xh, xl) {
13086   var c0_hi = rotr64_hi(xh, xl, 19);
13087   var c1_hi = rotr64_hi(xl, xh, 29);  // 61
13088   var c2_hi = shr64_hi(xh, xl, 6);
13089
13090   var r = c0_hi ^ c1_hi ^ c2_hi;
13091   if (r < 0)
13092     r += 0x100000000;
13093   return r;
13094 }
13095
13096 function g1_512_lo(xh, xl) {
13097   var c0_lo = rotr64_lo(xh, xl, 19);
13098   var c1_lo = rotr64_lo(xl, xh, 29);  // 61
13099   var c2_lo = shr64_lo(xh, xl, 6);
13100
13101   var r = c0_lo ^ c1_lo ^ c2_lo;
13102   if (r < 0)
13103     r += 0x100000000;
13104   return r;
13105 }
13106
13107
13108 /***/ }),
13109 /* 120 */
13110 /***/ (function(module, exports, __webpack_require__) {
13111
13112 var inherits = __webpack_require__(1);
13113 var Reporter = __webpack_require__(34).Reporter;
13114 var Buffer = __webpack_require__(3).Buffer;
13115
13116 function DecoderBuffer(base, options) {
13117   Reporter.call(this, options);
13118   if (!Buffer.isBuffer(base)) {
13119     this.error('Input not Buffer');
13120     return;
13121   }
13122
13123   this.base = base;
13124   this.offset = 0;
13125   this.length = base.length;
13126 }
13127 inherits(DecoderBuffer, Reporter);
13128 exports.DecoderBuffer = DecoderBuffer;
13129
13130 DecoderBuffer.prototype.save = function save() {
13131   return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
13132 };
13133
13134 DecoderBuffer.prototype.restore = function restore(save) {
13135   // Return skipped data
13136   var res = new DecoderBuffer(this.base);
13137   res.offset = save.offset;
13138   res.length = this.offset;
13139
13140   this.offset = save.offset;
13141   Reporter.prototype.restore.call(this, save.reporter);
13142
13143   return res;
13144 };
13145
13146 DecoderBuffer.prototype.isEmpty = function isEmpty() {
13147   return this.offset === this.length;
13148 };
13149
13150 DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
13151   if (this.offset + 1 <= this.length)
13152     return this.base.readUInt8(this.offset++, true);
13153   else
13154     return this.error(fail || 'DecoderBuffer overrun');
13155 }
13156
13157 DecoderBuffer.prototype.skip = function skip(bytes, fail) {
13158   if (!(this.offset + bytes <= this.length))
13159     return this.error(fail || 'DecoderBuffer overrun');
13160
13161   var res = new DecoderBuffer(this.base);
13162
13163   // Share reporter state
13164   res._reporterState = this._reporterState;
13165
13166   res.offset = this.offset;
13167   res.length = this.offset + bytes;
13168   this.offset += bytes;
13169   return res;
13170 }
13171
13172 DecoderBuffer.prototype.raw = function raw(save) {
13173   return this.base.slice(save ? save.offset : this.offset, this.length);
13174 }
13175
13176 function EncoderBuffer(value, reporter) {
13177   if (Array.isArray(value)) {
13178     this.length = 0;
13179     this.value = value.map(function(item) {
13180       if (!(item instanceof EncoderBuffer))
13181         item = new EncoderBuffer(item, reporter);
13182       this.length += item.length;
13183       return item;
13184     }, this);
13185   } else if (typeof value === 'number') {
13186     if (!(0 <= value && value <= 0xff))
13187       return reporter.error('non-byte EncoderBuffer value');
13188     this.value = value;
13189     this.length = 1;
13190   } else if (typeof value === 'string') {
13191     this.value = value;
13192     this.length = Buffer.byteLength(value);
13193   } else if (Buffer.isBuffer(value)) {
13194     this.value = value;
13195     this.length = value.length;
13196   } else {
13197     return reporter.error('Unsupported type: ' + typeof value);
13198   }
13199 }
13200 exports.EncoderBuffer = EncoderBuffer;
13201
13202 EncoderBuffer.prototype.join = function join(out, offset) {
13203   if (!out)
13204     out = new Buffer(this.length);
13205   if (!offset)
13206     offset = 0;
13207
13208   if (this.length === 0)
13209     return out;
13210
13211   if (Array.isArray(this.value)) {
13212     this.value.forEach(function(item) {
13213       item.join(out, offset);
13214       offset += item.length;
13215     });
13216   } else {
13217     if (typeof this.value === 'number')
13218       out[offset] = this.value;
13219     else if (typeof this.value === 'string')
13220       out.write(this.value, offset);
13221     else if (Buffer.isBuffer(this.value))
13222       this.value.copy(out, offset);
13223     offset += this.length;
13224   }
13225
13226   return out;
13227 };
13228
13229
13230 /***/ }),
13231 /* 121 */
13232 /***/ (function(module, exports, __webpack_require__) {
13233
13234 var constants = exports;
13235
13236 // Helper
13237 constants._reverse = function reverse(map) {
13238   var res = {};
13239
13240   Object.keys(map).forEach(function(key) {
13241     // Convert key to integer if it is stringified
13242     if ((key | 0) == key)
13243       key = key | 0;
13244
13245     var value = map[key];
13246     res[value] = key;
13247   });
13248
13249   return res;
13250 };
13251
13252 constants.der = __webpack_require__(250);
13253
13254
13255 /***/ }),
13256 /* 122 */
13257 /***/ (function(module, exports, __webpack_require__) {
13258
13259 var inherits = __webpack_require__(1);
13260
13261 var asn1 = __webpack_require__(33);
13262 var base = asn1.base;
13263 var bignum = asn1.bignum;
13264
13265 // Import DER constants
13266 var der = asn1.constants.der;
13267
13268 function DERDecoder(entity) {
13269   this.enc = 'der';
13270   this.name = entity.name;
13271   this.entity = entity;
13272
13273   // Construct base tree
13274   this.tree = new DERNode();
13275   this.tree._init(entity.body);
13276 };
13277 module.exports = DERDecoder;
13278
13279 DERDecoder.prototype.decode = function decode(data, options) {
13280   if (!(data instanceof base.DecoderBuffer))
13281     data = new base.DecoderBuffer(data, options);
13282
13283   return this.tree._decode(data, options);
13284 };
13285
13286 // Tree methods
13287
13288 function DERNode(parent) {
13289   base.Node.call(this, 'der', parent);
13290 }
13291 inherits(DERNode, base.Node);
13292
13293 DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
13294   if (buffer.isEmpty())
13295     return false;
13296
13297   var state = buffer.save();
13298   var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
13299   if (buffer.isError(decodedTag))
13300     return decodedTag;
13301
13302   buffer.restore(state);
13303
13304   return decodedTag.tag === tag || decodedTag.tagStr === tag ||
13305     (decodedTag.tagStr + 'of') === tag || any;
13306 };
13307
13308 DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
13309   var decodedTag = derDecodeTag(buffer,
13310                                 'Failed to decode tag of "' + tag + '"');
13311   if (buffer.isError(decodedTag))
13312     return decodedTag;
13313
13314   var len = derDecodeLen(buffer,
13315                          decodedTag.primitive,
13316                          'Failed to get length of "' + tag + '"');
13317
13318   // Failure
13319   if (buffer.isError(len))
13320     return len;
13321
13322   if (!any &&
13323       decodedTag.tag !== tag &&
13324       decodedTag.tagStr !== tag &&
13325       decodedTag.tagStr + 'of' !== tag) {
13326     return buffer.error('Failed to match tag: "' + tag + '"');
13327   }
13328
13329   if (decodedTag.primitive || len !== null)
13330     return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
13331
13332   // Indefinite length... find END tag
13333   var state = buffer.save();
13334   var res = this._skipUntilEnd(
13335       buffer,
13336       'Failed to skip indefinite length body: "' + this.tag + '"');
13337   if (buffer.isError(res))
13338     return res;
13339
13340   len = buffer.offset - state.offset;
13341   buffer.restore(state);
13342   return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
13343 };
13344
13345 DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
13346   while (true) {
13347     var tag = derDecodeTag(buffer, fail);
13348     if (buffer.isError(tag))
13349       return tag;
13350     var len = derDecodeLen(buffer, tag.primitive, fail);
13351     if (buffer.isError(len))
13352       return len;
13353
13354     var res;
13355     if (tag.primitive || len !== null)
13356       res = buffer.skip(len)
13357     else
13358       res = this._skipUntilEnd(buffer, fail);
13359
13360     // Failure
13361     if (buffer.isError(res))
13362       return res;
13363
13364     if (tag.tagStr === 'end')
13365       break;
13366   }
13367 };
13368
13369 DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
13370                                                     options) {
13371   var result = [];
13372   while (!buffer.isEmpty()) {
13373     var possibleEnd = this._peekTag(buffer, 'end');
13374     if (buffer.isError(possibleEnd))
13375       return possibleEnd;
13376
13377     var res = decoder.decode(buffer, 'der', options);
13378     if (buffer.isError(res) && possibleEnd)
13379       break;
13380     result.push(res);
13381   }
13382   return result;
13383 };
13384
13385 DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
13386   if (tag === 'bitstr') {
13387     var unused = buffer.readUInt8();
13388     if (buffer.isError(unused))
13389       return unused;
13390     return { unused: unused, data: buffer.raw() };
13391   } else if (tag === 'bmpstr') {
13392     var raw = buffer.raw();
13393     if (raw.length % 2 === 1)
13394       return buffer.error('Decoding of string type: bmpstr length mismatch');
13395
13396     var str = '';
13397     for (var i = 0; i < raw.length / 2; i++) {
13398       str += String.fromCharCode(raw.readUInt16BE(i * 2));
13399     }
13400     return str;
13401   } else if (tag === 'numstr') {
13402     var numstr = buffer.raw().toString('ascii');
13403     if (!this._isNumstr(numstr)) {
13404       return buffer.error('Decoding of string type: ' +
13405                           'numstr unsupported characters');
13406     }
13407     return numstr;
13408   } else if (tag === 'octstr') {
13409     return buffer.raw();
13410   } else if (tag === 'objDesc') {
13411     return buffer.raw();
13412   } else if (tag === 'printstr') {
13413     var printstr = buffer.raw().toString('ascii');
13414     if (!this._isPrintstr(printstr)) {
13415       return buffer.error('Decoding of string type: ' +
13416                           'printstr unsupported characters');
13417     }
13418     return printstr;
13419   } else if (/str$/.test(tag)) {
13420     return buffer.raw().toString();
13421   } else {
13422     return buffer.error('Decoding of string type: ' + tag + ' unsupported');
13423   }
13424 };
13425
13426 DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
13427   var result;
13428   var identifiers = [];
13429   var ident = 0;
13430   while (!buffer.isEmpty()) {
13431     var subident = buffer.readUInt8();
13432     ident <<= 7;
13433     ident |= subident & 0x7f;
13434     if ((subident & 0x80) === 0) {
13435       identifiers.push(ident);
13436       ident = 0;
13437     }
13438   }
13439   if (subident & 0x80)
13440     identifiers.push(ident);
13441
13442   var first = (identifiers[0] / 40) | 0;
13443   var second = identifiers[0] % 40;
13444
13445   if (relative)
13446     result = identifiers;
13447   else
13448     result = [first, second].concat(identifiers.slice(1));
13449
13450   if (values) {
13451     var tmp = values[result.join(' ')];
13452     if (tmp === undefined)
13453       tmp = values[result.join('.')];
13454     if (tmp !== undefined)
13455       result = tmp;
13456   }
13457
13458   return result;
13459 };
13460
13461 DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
13462   var str = buffer.raw().toString();
13463   if (tag === 'gentime') {
13464     var year = str.slice(0, 4) | 0;
13465     var mon = str.slice(4, 6) | 0;
13466     var day = str.slice(6, 8) | 0;
13467     var hour = str.slice(8, 10) | 0;
13468     var min = str.slice(10, 12) | 0;
13469     var sec = str.slice(12, 14) | 0;
13470   } else if (tag === 'utctime') {
13471     var year = str.slice(0, 2) | 0;
13472     var mon = str.slice(2, 4) | 0;
13473     var day = str.slice(4, 6) | 0;
13474     var hour = str.slice(6, 8) | 0;
13475     var min = str.slice(8, 10) | 0;
13476     var sec = str.slice(10, 12) | 0;
13477     if (year < 70)
13478       year = 2000 + year;
13479     else
13480       year = 1900 + year;
13481   } else {
13482     return buffer.error('Decoding ' + tag + ' time is not supported yet');
13483   }
13484
13485   return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
13486 };
13487
13488 DERNode.prototype._decodeNull = function decodeNull(buffer) {
13489   return null;
13490 };
13491
13492 DERNode.prototype._decodeBool = function decodeBool(buffer) {
13493   var res = buffer.readUInt8();
13494   if (buffer.isError(res))
13495     return res;
13496   else
13497     return res !== 0;
13498 };
13499
13500 DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
13501   // Bigint, return as it is (assume big endian)
13502   var raw = buffer.raw();
13503   var res = new bignum(raw);
13504
13505   if (values)
13506     res = values[res.toString(10)] || res;
13507
13508   return res;
13509 };
13510
13511 DERNode.prototype._use = function use(entity, obj) {
13512   if (typeof entity === 'function')
13513     entity = entity(obj);
13514   return entity._getDecoder('der').tree;
13515 };
13516
13517 // Utility methods
13518
13519 function derDecodeTag(buf, fail) {
13520   var tag = buf.readUInt8(fail);
13521   if (buf.isError(tag))
13522     return tag;
13523
13524   var cls = der.tagClass[tag >> 6];
13525   var primitive = (tag & 0x20) === 0;
13526
13527   // Multi-octet tag - load
13528   if ((tag & 0x1f) === 0x1f) {
13529     var oct = tag;
13530     tag = 0;
13531     while ((oct & 0x80) === 0x80) {
13532       oct = buf.readUInt8(fail);
13533       if (buf.isError(oct))
13534         return oct;
13535
13536       tag <<= 7;
13537       tag |= oct & 0x7f;
13538     }
13539   } else {
13540     tag &= 0x1f;
13541   }
13542   var tagStr = der.tag[tag];
13543
13544   return {
13545     cls: cls,
13546     primitive: primitive,
13547     tag: tag,
13548     tagStr: tagStr
13549   };
13550 }
13551
13552 function derDecodeLen(buf, primitive, fail) {
13553   var len = buf.readUInt8(fail);
13554   if (buf.isError(len))
13555     return len;
13556
13557   // Indefinite form
13558   if (!primitive && len === 0x80)
13559     return null;
13560
13561   // Definite form
13562   if ((len & 0x80) === 0) {
13563     // Short form
13564     return len;
13565   }
13566
13567   // Long form
13568   var num = len & 0x7f;
13569   if (num > 4)
13570     return buf.error('length octect is too long');
13571
13572   len = 0;
13573   for (var i = 0; i < num; i++) {
13574     len <<= 8;
13575     var j = buf.readUInt8(fail);
13576     if (buf.isError(j))
13577       return j;
13578     len |= j;
13579   }
13580
13581   return len;
13582 }
13583
13584
13585 /***/ }),
13586 /* 123 */
13587 /***/ (function(module, exports, __webpack_require__) {
13588
13589 var inherits = __webpack_require__(1);
13590 var Buffer = __webpack_require__(3).Buffer;
13591
13592 var asn1 = __webpack_require__(33);
13593 var base = asn1.base;
13594
13595 // Import DER constants
13596 var der = asn1.constants.der;
13597
13598 function DEREncoder(entity) {
13599   this.enc = 'der';
13600   this.name = entity.name;
13601   this.entity = entity;
13602
13603   // Construct base tree
13604   this.tree = new DERNode();
13605   this.tree._init(entity.body);
13606 };
13607 module.exports = DEREncoder;
13608
13609 DEREncoder.prototype.encode = function encode(data, reporter) {
13610   return this.tree._encode(data, reporter).join();
13611 };
13612
13613 // Tree methods
13614
13615 function DERNode(parent) {
13616   base.Node.call(this, 'der', parent);
13617 }
13618 inherits(DERNode, base.Node);
13619
13620 DERNode.prototype._encodeComposite = function encodeComposite(tag,
13621                                                               primitive,
13622                                                               cls,
13623                                                               content) {
13624   var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
13625
13626   // Short form
13627   if (content.length < 0x80) {
13628     var header = new Buffer(2);
13629     header[0] = encodedTag;
13630     header[1] = content.length;
13631     return this._createEncoderBuffer([ header, content ]);
13632   }
13633
13634   // Long form
13635   // Count octets required to store length
13636   var lenOctets = 1;
13637   for (var i = content.length; i >= 0x100; i >>= 8)
13638     lenOctets++;
13639
13640   var header = new Buffer(1 + 1 + lenOctets);
13641   header[0] = encodedTag;
13642   header[1] = 0x80 | lenOctets;
13643
13644   for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
13645     header[i] = j & 0xff;
13646
13647   return this._createEncoderBuffer([ header, content ]);
13648 };
13649
13650 DERNode.prototype._encodeStr = function encodeStr(str, tag) {
13651   if (tag === 'bitstr') {
13652     return this._createEncoderBuffer([ str.unused | 0, str.data ]);
13653   } else if (tag === 'bmpstr') {
13654     var buf = new Buffer(str.length * 2);
13655     for (var i = 0; i < str.length; i++) {
13656       buf.writeUInt16BE(str.charCodeAt(i), i * 2);
13657     }
13658     return this._createEncoderBuffer(buf);
13659   } else if (tag === 'numstr') {
13660     if (!this._isNumstr(str)) {
13661       return this.reporter.error('Encoding of string type: numstr supports ' +
13662                                  'only digits and space');
13663     }
13664     return this._createEncoderBuffer(str);
13665   } else if (tag === 'printstr') {
13666     if (!this._isPrintstr(str)) {
13667       return this.reporter.error('Encoding of string type: printstr supports ' +
13668                                  'only latin upper and lower case letters, ' +
13669                                  'digits, space, apostrophe, left and rigth ' +
13670                                  'parenthesis, plus sign, comma, hyphen, ' +
13671                                  'dot, slash, colon, equal sign, ' +
13672                                  'question mark');
13673     }
13674     return this._createEncoderBuffer(str);
13675   } else if (/str$/.test(tag)) {
13676     return this._createEncoderBuffer(str);
13677   } else if (tag === 'objDesc') {
13678     return this._createEncoderBuffer(str);
13679   } else {
13680     return this.reporter.error('Encoding of string type: ' + tag +
13681                                ' unsupported');
13682   }
13683 };
13684
13685 DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
13686   if (typeof id === 'string') {
13687     if (!values)
13688       return this.reporter.error('string objid given, but no values map found');
13689     if (!values.hasOwnProperty(id))
13690       return this.reporter.error('objid not found in values map');
13691     id = values[id].split(/[\s\.]+/g);
13692     for (var i = 0; i < id.length; i++)
13693       id[i] |= 0;
13694   } else if (Array.isArray(id)) {
13695     id = id.slice();
13696     for (var i = 0; i < id.length; i++)
13697       id[i] |= 0;
13698   }
13699
13700   if (!Array.isArray(id)) {
13701     return this.reporter.error('objid() should be either array or string, ' +
13702                                'got: ' + JSON.stringify(id));
13703   }
13704
13705   if (!relative) {
13706     if (id[1] >= 40)
13707       return this.reporter.error('Second objid identifier OOB');
13708     id.splice(0, 2, id[0] * 40 + id[1]);
13709   }
13710
13711   // Count number of octets
13712   var size = 0;
13713   for (var i = 0; i < id.length; i++) {
13714     var ident = id[i];
13715     for (size++; ident >= 0x80; ident >>= 7)
13716       size++;
13717   }
13718
13719   var objid = new Buffer(size);
13720   var offset = objid.length - 1;
13721   for (var i = id.length - 1; i >= 0; i--) {
13722     var ident = id[i];
13723     objid[offset--] = ident & 0x7f;
13724     while ((ident >>= 7) > 0)
13725       objid[offset--] = 0x80 | (ident & 0x7f);
13726   }
13727
13728   return this._createEncoderBuffer(objid);
13729 };
13730
13731 function two(num) {
13732   if (num < 10)
13733     return '0' + num;
13734   else
13735     return num;
13736 }
13737
13738 DERNode.prototype._encodeTime = function encodeTime(time, tag) {
13739   var str;
13740   var date = new Date(time);
13741
13742   if (tag === 'gentime') {
13743     str = [
13744       two(date.getFullYear()),
13745       two(date.getUTCMonth() + 1),
13746       two(date.getUTCDate()),
13747       two(date.getUTCHours()),
13748       two(date.getUTCMinutes()),
13749       two(date.getUTCSeconds()),
13750       'Z'
13751     ].join('');
13752   } else if (tag === 'utctime') {
13753     str = [
13754       two(date.getFullYear() % 100),
13755       two(date.getUTCMonth() + 1),
13756       two(date.getUTCDate()),
13757       two(date.getUTCHours()),
13758       two(date.getUTCMinutes()),
13759       two(date.getUTCSeconds()),
13760       'Z'
13761     ].join('');
13762   } else {
13763     this.reporter.error('Encoding ' + tag + ' time is not supported yet');
13764   }
13765
13766   return this._encodeStr(str, 'octstr');
13767 };
13768
13769 DERNode.prototype._encodeNull = function encodeNull() {
13770   return this._createEncoderBuffer('');
13771 };
13772
13773 DERNode.prototype._encodeInt = function encodeInt(num, values) {
13774   if (typeof num === 'string') {
13775     if (!values)
13776       return this.reporter.error('String int or enum given, but no values map');
13777     if (!values.hasOwnProperty(num)) {
13778       return this.reporter.error('Values map doesn\'t contain: ' +
13779                                  JSON.stringify(num));
13780     }
13781     num = values[num];
13782   }
13783
13784   // Bignum, assume big endian
13785   if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
13786     var numArray = num.toArray();
13787     if (!num.sign && numArray[0] & 0x80) {
13788       numArray.unshift(0);
13789     }
13790     num = new Buffer(numArray);
13791   }
13792
13793   if (Buffer.isBuffer(num)) {
13794     var size = num.length;
13795     if (num.length === 0)
13796       size++;
13797
13798     var out = new Buffer(size);
13799     num.copy(out);
13800     if (num.length === 0)
13801       out[0] = 0
13802     return this._createEncoderBuffer(out);
13803   }
13804
13805   if (num < 0x80)
13806     return this._createEncoderBuffer(num);
13807
13808   if (num < 0x100)
13809     return this._createEncoderBuffer([0, num]);
13810
13811   var size = 1;
13812   for (var i = num; i >= 0x100; i >>= 8)
13813     size++;
13814
13815   var out = new Array(size);
13816   for (var i = out.length - 1; i >= 0; i--) {
13817     out[i] = num & 0xff;
13818     num >>= 8;
13819   }
13820   if(out[0] & 0x80) {
13821     out.unshift(0);
13822   }
13823
13824   return this._createEncoderBuffer(new Buffer(out));
13825 };
13826
13827 DERNode.prototype._encodeBool = function encodeBool(value) {
13828   return this._createEncoderBuffer(value ? 0xff : 0);
13829 };
13830
13831 DERNode.prototype._use = function use(entity, obj) {
13832   if (typeof entity === 'function')
13833     entity = entity(obj);
13834   return entity._getEncoder('der').tree;
13835 };
13836
13837 DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
13838   var state = this._baseState;
13839   var i;
13840   if (state['default'] === null)
13841     return false;
13842
13843   var data = dataBuffer.join();
13844   if (state.defaultBuffer === undefined)
13845     state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
13846
13847   if (data.length !== state.defaultBuffer.length)
13848     return false;
13849
13850   for (i=0; i < data.length; i++)
13851     if (data[i] !== state.defaultBuffer[i])
13852       return false;
13853
13854   return true;
13855 };
13856
13857 // Utility methods
13858
13859 function encodeTag(tag, primitive, cls, reporter) {
13860   var res;
13861
13862   if (tag === 'seqof')
13863     tag = 'seq';
13864   else if (tag === 'setof')
13865     tag = 'set';
13866
13867   if (der.tagByName.hasOwnProperty(tag))
13868     res = der.tagByName[tag];
13869   else if (typeof tag === 'number' && (tag | 0) === tag)
13870     res = tag;
13871   else
13872     return reporter.error('Unknown tag: ' + tag);
13873
13874   if (res >= 0x1f)
13875     return reporter.error('Multi-octet tag encoding unsupported');
13876
13877   if (!primitive)
13878     res |= 0x20;
13879
13880   res |= (der.tagClassByName[cls || 'universal'] << 6);
13881
13882   return res;
13883 }
13884
13885
13886 /***/ }),
13887 /* 124 */
13888 /***/ (function(module, exports) {
13889
13890 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"}
13891
13892 /***/ }),
13893 /* 125 */
13894 /***/ (function(module, exports, __webpack_require__) {
13895
13896 /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(29);
13897 module.exports = function (seed, len) {
13898   var t = new Buffer('');
13899   var  i = 0, c;
13900   while (t.length < len) {
13901     c = i2ops(i++);
13902     t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
13903   }
13904   return t.slice(0, len);
13905 };
13906
13907 function i2ops(c) {
13908   var out = new Buffer(4);
13909   out.writeUInt32BE(c,0);
13910   return out;
13911 }
13912 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
13913
13914 /***/ }),
13915 /* 126 */
13916 /***/ (function(module, exports) {
13917
13918 module.exports = function xor(a, b) {
13919   var len = a.length;
13920   var i = -1;
13921   while (++i < len) {
13922     a[i] ^= b[i];
13923   }
13924   return a
13925 };
13926
13927 /***/ }),
13928 /* 127 */
13929 /***/ (function(module, exports, __webpack_require__) {
13930
13931 /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(4);
13932 function withPublic(paddedMsg, key) {
13933   return new Buffer(paddedMsg
13934     .toRed(bn.mont(key.modulus))
13935     .redPow(new bn(key.publicExponent))
13936     .fromRed()
13937     .toArray());
13938 }
13939
13940 module.exports = withPublic;
13941 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
13942
13943 /***/ }),
13944 /* 128 */
13945 /***/ (function(module, exports) {
13946
13947 module.exports = function(module) {\r
13948         if(!module.webpackPolyfill) {\r
13949                 module.deprecate = function() {};\r
13950                 module.paths = [];\r
13951                 // module.parent = undefined by default\r
13952                 if(!module.children) module.children = [];\r
13953                 Object.defineProperty(module, "loaded", {\r
13954                         enumerable: true,\r
13955                         get: function() {\r
13956                                 return module.l;\r
13957                         }\r
13958                 });\r
13959                 Object.defineProperty(module, "id", {\r
13960                         enumerable: true,\r
13961                         get: function() {\r
13962                                 return module.i;\r
13963                         }\r
13964                 });\r
13965                 module.webpackPolyfill = 1;\r
13966         }\r
13967         return module;\r
13968 };\r
13969
13970
13971 /***/ }),
13972 /* 129 */
13973 /***/ (function(module, __webpack_exports__, __webpack_require__) {
13974
13975 "use strict";
13976 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return ERROR; });
13977 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return PUSH_BYTOM; });
13978 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return UPDATE_BYTOM; });
13979 /* unused harmony export AUTHENTICATE */
13980 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return TRANSFER; });
13981 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ENABLE; });
13982 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ADVTRANSFER; });
13983 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return SIGNTRANSACTION; });
13984 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return SIGNMESSAGE; });
13985 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return SETCHAIN; });
13986 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return SEND; });
13987 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return LOAD; });
13988 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return UPDATE; });
13989 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return REQUEST_CURRENT_ACCOUNT; });
13990 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return REQUEST_CURRENT_NETWORK; });
13991 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return REQUEST_CURRENT_CHAIN_TYPE; });
13992 /* unused harmony export REQUEST_ACCOUNT_LIST */
13993 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return SET_PROMPT; });
13994 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return GET_PROMPT; });
13995 var ERROR = 'error';
13996
13997 var PUSH_BYTOM = 'pushBytom';
13998 var UPDATE_BYTOM = 'updateBytom';
13999 var AUTHENTICATE = 'authenticate';
14000 var TRANSFER = 'transfer';
14001 var ENABLE = 'enable';
14002 var ADVTRANSFER = 'advTransfer';
14003 var SIGNTRANSACTION = 'signTransaction';
14004 var SIGNMESSAGE = 'signMessage';
14005 var SETCHAIN = 'setChain';
14006 var SEND = 'send';
14007 var LOAD = 'load';
14008 var UPDATE = 'update';
14009
14010 var REQUEST_CURRENT_ACCOUNT = 'defaultAccount';
14011 var REQUEST_CURRENT_NETWORK = 'currentNetwork';
14012 var REQUEST_CURRENT_CHAIN_TYPE = 'currentChain';
14013 var REQUEST_ACCOUNT_LIST = 'accountList';
14014
14015 //Internal Message
14016 var SET_PROMPT = 'setPrompt';
14017 var GET_PROMPT = 'getPrompt';
14018
14019 /***/ }),
14020 /* 130 */
14021 /***/ (function(module, exports, __webpack_require__) {
14022
14023 module.exports = !__webpack_require__(17) && !__webpack_require__(22)(function () {
14024   return Object.defineProperty(__webpack_require__(50)('div'), 'a', { get: function () { return 7; } }).a != 7;
14025 });
14026
14027
14028 /***/ }),
14029 /* 131 */
14030 /***/ (function(module, exports, __webpack_require__) {
14031
14032 var has = __webpack_require__(20);
14033 var toIObject = __webpack_require__(25);
14034 var arrayIndexOf = __webpack_require__(150)(false);
14035 var IE_PROTO = __webpack_require__(53)('IE_PROTO');
14036
14037 module.exports = function (object, names) {
14038   var O = toIObject(object);
14039   var i = 0;
14040   var result = [];
14041   var key;
14042   for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
14043   // Don't enum bug & hidden keys
14044   while (names.length > i) if (has(O, key = names[i++])) {
14045     ~arrayIndexOf(result, key) || result.push(key);
14046   }
14047   return result;
14048 };
14049
14050
14051 /***/ }),
14052 /* 132 */
14053 /***/ (function(module, exports, __webpack_require__) {
14054
14055 "use strict";
14056
14057 var $at = __webpack_require__(157)(true);
14058
14059 // 21.1.3.27 String.prototype[@@iterator]()
14060 __webpack_require__(85)(String, 'String', function (iterated) {
14061   this._t = String(iterated); // target
14062   this._i = 0;                // next index
14063 // 21.1.5.2.1 %StringIteratorPrototype%.next()
14064 }, function () {
14065   var O = this._t;
14066   var index = this._i;
14067   var point;
14068   if (index >= O.length) return { value: undefined, done: true };
14069   point = $at(O, index);
14070   this._i += point.length;
14071   return { value: point, done: false };
14072 });
14073
14074
14075 /***/ }),
14076 /* 133 */
14077 /***/ (function(module, exports, __webpack_require__) {
14078
14079 // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
14080 var anObject = __webpack_require__(15);
14081 var dPs = __webpack_require__(159);
14082 var enumBugKeys = __webpack_require__(71);
14083 var IE_PROTO = __webpack_require__(53)('IE_PROTO');
14084 var Empty = function () { /* empty */ };
14085 var PROTOTYPE = 'prototype';
14086
14087 // Create object with fake `null` prototype: use iframe Object with cleared prototype
14088 var createDict = function () {
14089   // Thrash, waste and sodomy: IE GC bug
14090   var iframe = __webpack_require__(50)('iframe');
14091   var i = enumBugKeys.length;
14092   var lt = '<';
14093   var gt = '>';
14094   var iframeDocument;
14095   iframe.style.display = 'none';
14096   __webpack_require__(86).appendChild(iframe);
14097   iframe.src = 'javascript:'; // eslint-disable-line no-script-url
14098   // createDict = iframe.contentWindow.Object;
14099   // html.removeChild(iframe);
14100   iframeDocument = iframe.contentWindow.document;
14101   iframeDocument.open();
14102   iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
14103   iframeDocument.close();
14104   createDict = iframeDocument.F;
14105   while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
14106   return createDict();
14107 };
14108
14109 module.exports = Object.create || function create(O, Properties) {
14110   var result;
14111   if (O !== null) {
14112     Empty[PROTOTYPE] = anObject(O);
14113     result = new Empty();
14114     Empty[PROTOTYPE] = null;
14115     // add "__proto__" for Object.getPrototypeOf polyfill
14116     result[IE_PROTO] = O;
14117   } else result = createDict();
14118   return Properties === undefined ? result : dPs(result, Properties);
14119 };
14120
14121
14122 /***/ }),
14123 /* 134 */
14124 /***/ (function(module, exports) {
14125
14126 module.exports = function (it, Constructor, name, forbiddenField) {
14127   if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
14128     throw TypeError(name + ': incorrect invocation!');
14129   } return it;
14130 };
14131
14132
14133 /***/ }),
14134 /* 135 */
14135 /***/ (function(module, exports, __webpack_require__) {
14136
14137 var hide = __webpack_require__(19);
14138 module.exports = function (target, src, safe) {
14139   for (var key in src) {
14140     if (safe && target[key]) target[key] = src[key];
14141     else hide(target, key, src[key]);
14142   } return target;
14143 };
14144
14145
14146 /***/ }),
14147 /* 136 */
14148 /***/ (function(module, exports, __webpack_require__) {
14149
14150 module.exports = { "default": __webpack_require__(152), __esModule: true };
14151
14152 /***/ }),
14153 /* 137 */
14154 /***/ (function(module, exports, __webpack_require__) {
14155
14156 "use strict";
14157 \r
14158 Object.defineProperty(exports, "__esModule", { value: true });\r
14159 var EncryptedStream_1 = __webpack_require__(179);\r
14160 exports.EncryptedStream = EncryptedStream_1.EncryptedStream;\r
14161 var LocalStream_1 = __webpack_require__(264);\r
14162 exports.LocalStream = LocalStream_1.LocalStream;\r
14163 //# sourceMappingURL=index.js.map
14164
14165 /***/ }),
14166 /* 138 */
14167 /***/ (function(module, exports, __webpack_require__) {
14168
14169 module.exports = __webpack_require__(154);
14170
14171
14172 /***/ }),
14173 /* 139 */
14174 /***/ (function(module, exports, __webpack_require__) {
14175
14176 "use strict";
14177
14178
14179 exports.__esModule = true;
14180
14181 var _promise = __webpack_require__(76);
14182
14183 var _promise2 = _interopRequireDefault(_promise);
14184
14185 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14186
14187 exports.default = function (fn) {
14188   return function () {
14189     var gen = fn.apply(this, arguments);
14190     return new _promise2.default(function (resolve, reject) {
14191       function step(key, arg) {
14192         try {
14193           var info = gen[key](arg);
14194           var value = info.value;
14195         } catch (error) {
14196           reject(error);
14197           return;
14198         }
14199
14200         if (info.done) {
14201           resolve(value);
14202         } else {
14203           return _promise2.default.resolve(value).then(function (value) {
14204             step("next", value);
14205           }, function (err) {
14206             step("throw", err);
14207           });
14208         }
14209       }
14210
14211       return step("next");
14212     });
14213   };
14214 };
14215
14216 /***/ }),
14217 /* 140 */
14218 /***/ (function(module, exports, __webpack_require__) {
14219
14220 /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
14221             (typeof self !== "undefined" && self) ||
14222             window;
14223 var apply = Function.prototype.apply;
14224
14225 // DOM APIs, for completeness
14226
14227 exports.setTimeout = function() {
14228   return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
14229 };
14230 exports.setInterval = function() {
14231   return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
14232 };
14233 exports.clearTimeout =
14234 exports.clearInterval = function(timeout) {
14235   if (timeout) {
14236     timeout.close();
14237   }
14238 };
14239
14240 function Timeout(id, clearFn) {
14241   this._id = id;
14242   this._clearFn = clearFn;
14243 }
14244 Timeout.prototype.unref = Timeout.prototype.ref = function() {};
14245 Timeout.prototype.close = function() {
14246   this._clearFn.call(scope, this._id);
14247 };
14248
14249 // Does not start the time, just sets up the members needed.
14250 exports.enroll = function(item, msecs) {
14251   clearTimeout(item._idleTimeoutId);
14252   item._idleTimeout = msecs;
14253 };
14254
14255 exports.unenroll = function(item) {
14256   clearTimeout(item._idleTimeoutId);
14257   item._idleTimeout = -1;
14258 };
14259
14260 exports._unrefActive = exports.active = function(item) {
14261   clearTimeout(item._idleTimeoutId);
14262
14263   var msecs = item._idleTimeout;
14264   if (msecs >= 0) {
14265     item._idleTimeoutId = setTimeout(function onTimeout() {
14266       if (item._onTimeout)
14267         item._onTimeout();
14268     }, msecs);
14269   }
14270 };
14271
14272 // setimmediate attaches itself to the global object
14273 __webpack_require__(147);
14274 // On some exotic environments, it's not clear which object `setimmediate` was
14275 // able to install onto.  Search each possibility in the same order as the
14276 // `setimmediate` library.
14277 exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
14278                        (typeof global !== "undefined" && global.setImmediate) ||
14279                        (this && this.setImmediate);
14280 exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
14281                          (typeof global !== "undefined" && global.clearImmediate) ||
14282                          (this && this.clearImmediate);
14283
14284 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
14285
14286 /***/ }),
14287 /* 141 */
14288 /***/ (function(module, exports, __webpack_require__) {
14289
14290 "use strict";
14291
14292 // 19.1.2.1 Object.assign(target, source, ...)
14293 var getKeys = __webpack_require__(39);
14294 var gOPS = __webpack_require__(73);
14295 var pIE = __webpack_require__(49);
14296 var toObject = __webpack_require__(54);
14297 var IObject = __webpack_require__(74);
14298 var $assign = Object.assign;
14299
14300 // should work with symbols and should have deterministic property order (V8 bug)
14301 module.exports = !$assign || __webpack_require__(22)(function () {
14302   var A = {};
14303   var B = {};
14304   // eslint-disable-next-line no-undef
14305   var S = Symbol();
14306   var K = 'abcdefghijklmnopqrst';
14307   A[S] = 7;
14308   K.split('').forEach(function (k) { B[k] = k; });
14309   return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
14310 }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
14311   var T = toObject(target);
14312   var aLen = arguments.length;
14313   var index = 1;
14314   var getSymbols = gOPS.f;
14315   var isEnum = pIE.f;
14316   while (aLen > index) {
14317     var S = IObject(arguments[index++]);
14318     var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
14319     var length = keys.length;
14320     var j = 0;
14321     var key;
14322     while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
14323   } return T;
14324 } : $assign;
14325
14326
14327 /***/ }),
14328 /* 142 */
14329 /***/ (function(module, exports, __webpack_require__) {
14330
14331 // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
14332 var $keys = __webpack_require__(131);
14333 var hiddenKeys = __webpack_require__(71).concat('length', 'prototype');
14334
14335 exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
14336   return $keys(O, hiddenKeys);
14337 };
14338
14339
14340 /***/ }),
14341 /* 143 */
14342 /***/ (function(module, exports, __webpack_require__) {
14343
14344 // 7.2.2 IsArray(argument)
14345 var cof = __webpack_require__(27);
14346 module.exports = Array.isArray || function isArray(arg) {
14347   return cof(arg) == 'Array';
14348 };
14349
14350
14351 /***/ }),
14352 /* 144 */
14353 /***/ (function(module, exports, __webpack_require__) {
14354
14355 module.exports = { "default": __webpack_require__(416), __esModule: true };
14356
14357 /***/ }),
14358 /* 145 */
14359 /***/ (function(module, exports, __webpack_require__) {
14360
14361 "use strict";
14362
14363
14364 exports.__esModule = true;
14365
14366 var _iterator = __webpack_require__(272);
14367
14368 var _iterator2 = _interopRequireDefault(_iterator);
14369
14370 var _symbol = __webpack_require__(274);
14371
14372 var _symbol2 = _interopRequireDefault(_symbol);
14373
14374 var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
14375
14376 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14377
14378 exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
14379   return typeof obj === "undefined" ? "undefined" : _typeof(obj);
14380 } : function (obj) {
14381   return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
14382 };
14383
14384 /***/ }),
14385 /* 146 */,
14386 /* 147 */
14387 /***/ (function(module, exports, __webpack_require__) {
14388
14389 /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
14390     "use strict";
14391
14392     if (global.setImmediate) {
14393         return;
14394     }
14395
14396     var nextHandle = 1; // Spec says greater than zero
14397     var tasksByHandle = {};
14398     var currentlyRunningATask = false;
14399     var doc = global.document;
14400     var registerImmediate;
14401
14402     function setImmediate(callback) {
14403       // Callback can either be a function or a string
14404       if (typeof callback !== "function") {
14405         callback = new Function("" + callback);
14406       }
14407       // Copy function arguments
14408       var args = new Array(arguments.length - 1);
14409       for (var i = 0; i < args.length; i++) {
14410           args[i] = arguments[i + 1];
14411       }
14412       // Store and register the task
14413       var task = { callback: callback, args: args };
14414       tasksByHandle[nextHandle] = task;
14415       registerImmediate(nextHandle);
14416       return nextHandle++;
14417     }
14418
14419     function clearImmediate(handle) {
14420         delete tasksByHandle[handle];
14421     }
14422
14423     function run(task) {
14424         var callback = task.callback;
14425         var args = task.args;
14426         switch (args.length) {
14427         case 0:
14428             callback();
14429             break;
14430         case 1:
14431             callback(args[0]);
14432             break;
14433         case 2:
14434             callback(args[0], args[1]);
14435             break;
14436         case 3:
14437             callback(args[0], args[1], args[2]);
14438             break;
14439         default:
14440             callback.apply(undefined, args);
14441             break;
14442         }
14443     }
14444
14445     function runIfPresent(handle) {
14446         // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
14447         // So if we're currently running a task, we'll need to delay this invocation.
14448         if (currentlyRunningATask) {
14449             // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
14450             // "too much recursion" error.
14451             setTimeout(runIfPresent, 0, handle);
14452         } else {
14453             var task = tasksByHandle[handle];
14454             if (task) {
14455                 currentlyRunningATask = true;
14456                 try {
14457                     run(task);
14458                 } finally {
14459                     clearImmediate(handle);
14460                     currentlyRunningATask = false;
14461                 }
14462             }
14463         }
14464     }
14465
14466     function installNextTickImplementation() {
14467         registerImmediate = function(handle) {
14468             process.nextTick(function () { runIfPresent(handle); });
14469         };
14470     }
14471
14472     function canUsePostMessage() {
14473         // The test against `importScripts` prevents this implementation from being installed inside a web worker,
14474         // where `global.postMessage` means something completely different and can't be used for this purpose.
14475         if (global.postMessage && !global.importScripts) {
14476             var postMessageIsAsynchronous = true;
14477             var oldOnMessage = global.onmessage;
14478             global.onmessage = function() {
14479                 postMessageIsAsynchronous = false;
14480             };
14481             global.postMessage("", "*");
14482             global.onmessage = oldOnMessage;
14483             return postMessageIsAsynchronous;
14484         }
14485     }
14486
14487     function installPostMessageImplementation() {
14488         // Installs an event handler on `global` for the `message` event: see
14489         // * https://developer.mozilla.org/en/DOM/window.postMessage
14490         // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
14491
14492         var messagePrefix = "setImmediate$" + Math.random() + "$";
14493         var onGlobalMessage = function(event) {
14494             if (event.source === global &&
14495                 typeof event.data === "string" &&
14496                 event.data.indexOf(messagePrefix) === 0) {
14497                 runIfPresent(+event.data.slice(messagePrefix.length));
14498             }
14499         };
14500
14501         if (global.addEventListener) {
14502             global.addEventListener("message", onGlobalMessage, false);
14503         } else {
14504             global.attachEvent("onmessage", onGlobalMessage);
14505         }
14506
14507         registerImmediate = function(handle) {
14508             global.postMessage(messagePrefix + handle, "*");
14509         };
14510     }
14511
14512     function installMessageChannelImplementation() {
14513         var channel = new MessageChannel();
14514         channel.port1.onmessage = function(event) {
14515             var handle = event.data;
14516             runIfPresent(handle);
14517         };
14518
14519         registerImmediate = function(handle) {
14520             channel.port2.postMessage(handle);
14521         };
14522     }
14523
14524     function installReadyStateChangeImplementation() {
14525         var html = doc.documentElement;
14526         registerImmediate = function(handle) {
14527             // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
14528             // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
14529             var script = doc.createElement("script");
14530             script.onreadystatechange = function () {
14531                 runIfPresent(handle);
14532                 script.onreadystatechange = null;
14533                 html.removeChild(script);
14534                 script = null;
14535             };
14536             html.appendChild(script);
14537         };
14538     }
14539
14540     function installSetTimeoutImplementation() {
14541         registerImmediate = function(handle) {
14542             setTimeout(runIfPresent, 0, handle);
14543         };
14544     }
14545
14546     // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
14547     var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
14548     attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
14549
14550     // Don't get fooled by e.g. browserify environments.
14551     if ({}.toString.call(global.process) === "[object process]") {
14552         // For Node.js before 0.9
14553         installNextTickImplementation();
14554
14555     } else if (canUsePostMessage()) {
14556         // For non-IE10 modern browsers
14557         installPostMessageImplementation();
14558
14559     } else if (global.MessageChannel) {
14560         // For web workers, where supported
14561         installMessageChannelImplementation();
14562
14563     } else if (doc && "onreadystatechange" in doc.createElement("script")) {
14564         // For IE 6–8
14565         installReadyStateChangeImplementation();
14566
14567     } else {
14568         // For older browsers
14569         installSetTimeoutImplementation();
14570     }
14571
14572     attachTo.setImmediate = setImmediate;
14573     attachTo.clearImmediate = clearImmediate;
14574 }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
14575
14576 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
14577
14578 /***/ }),
14579 /* 148 */
14580 /***/ (function(module, exports, __webpack_require__) {
14581
14582 __webpack_require__(149);
14583 module.exports = __webpack_require__(8).Object.assign;
14584
14585
14586 /***/ }),
14587 /* 149 */
14588 /***/ (function(module, exports, __webpack_require__) {
14589
14590 // 19.1.3.1 Object.assign(target, source)
14591 var $export = __webpack_require__(13);
14592
14593 $export($export.S + $export.F, 'Object', { assign: __webpack_require__(141) });
14594
14595
14596 /***/ }),
14597 /* 150 */
14598 /***/ (function(module, exports, __webpack_require__) {
14599
14600 // false -> Array#indexOf
14601 // true  -> Array#includes
14602 var toIObject = __webpack_require__(25);
14603 var toLength = __webpack_require__(75);
14604 var toAbsoluteIndex = __webpack_require__(151);
14605 module.exports = function (IS_INCLUDES) {
14606   return function ($this, el, fromIndex) {
14607     var O = toIObject($this);
14608     var length = toLength(O.length);
14609     var index = toAbsoluteIndex(fromIndex, length);
14610     var value;
14611     // Array#includes uses SameValueZero equality algorithm
14612     // eslint-disable-next-line no-self-compare
14613     if (IS_INCLUDES && el != el) while (length > index) {
14614       value = O[index++];
14615       // eslint-disable-next-line no-self-compare
14616       if (value != value) return true;
14617     // Array#indexOf ignores holes, Array#includes - not
14618     } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
14619       if (O[index] === el) return IS_INCLUDES || index || 0;
14620     } return !IS_INCLUDES && -1;
14621   };
14622 };
14623
14624
14625 /***/ }),
14626 /* 151 */
14627 /***/ (function(module, exports, __webpack_require__) {
14628
14629 var toInteger = __webpack_require__(52);
14630 var max = Math.max;
14631 var min = Math.min;
14632 module.exports = function (index, length) {
14633   index = toInteger(index);
14634   return index < 0 ? max(index + length, 0) : min(index, length);
14635 };
14636
14637
14638 /***/ }),
14639 /* 152 */
14640 /***/ (function(module, exports, __webpack_require__) {
14641
14642 __webpack_require__(153);
14643 var $Object = __webpack_require__(8).Object;
14644 module.exports = function defineProperty(it, key, desc) {
14645   return $Object.defineProperty(it, key, desc);
14646 };
14647
14648
14649 /***/ }),
14650 /* 153 */
14651 /***/ (function(module, exports, __webpack_require__) {
14652
14653 var $export = __webpack_require__(13);
14654 // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
14655 $export($export.S + $export.F * !__webpack_require__(17), 'Object', { defineProperty: __webpack_require__(16).f });
14656
14657
14658 /***/ }),
14659 /* 154 */
14660 /***/ (function(module, exports, __webpack_require__) {
14661
14662 /**
14663  * Copyright (c) 2014-present, Facebook, Inc.
14664  *
14665  * This source code is licensed under the MIT license found in the
14666  * LICENSE file in the root directory of this source tree.
14667  */
14668
14669 // This method of obtaining a reference to the global object needs to be
14670 // kept identical to the way it is obtained in runtime.js
14671 var g = (function() { return this })() || Function("return this")();
14672
14673 // Use `getOwnPropertyNames` because not all browsers support calling
14674 // `hasOwnProperty` on the global `self` object in a worker. See #183.
14675 var hadRuntime = g.regeneratorRuntime &&
14676   Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
14677
14678 // Save the old regeneratorRuntime in case it needs to be restored later.
14679 var oldRuntime = hadRuntime && g.regeneratorRuntime;
14680
14681 // Force reevalutation of runtime.js.
14682 g.regeneratorRuntime = undefined;
14683
14684 module.exports = __webpack_require__(155);
14685
14686 if (hadRuntime) {
14687   // Restore the original runtime.
14688   g.regeneratorRuntime = oldRuntime;
14689 } else {
14690   // Remove the global property added by runtime.js.
14691   try {
14692     delete g.regeneratorRuntime;
14693   } catch(e) {
14694     g.regeneratorRuntime = undefined;
14695   }
14696 }
14697
14698
14699 /***/ }),
14700 /* 155 */
14701 /***/ (function(module, exports) {
14702
14703 /**
14704  * Copyright (c) 2014-present, Facebook, Inc.
14705  *
14706  * This source code is licensed under the MIT license found in the
14707  * LICENSE file in the root directory of this source tree.
14708  */
14709
14710 !(function(global) {
14711   "use strict";
14712
14713   var Op = Object.prototype;
14714   var hasOwn = Op.hasOwnProperty;
14715   var undefined; // More compressible than void 0.
14716   var $Symbol = typeof Symbol === "function" ? Symbol : {};
14717   var iteratorSymbol = $Symbol.iterator || "@@iterator";
14718   var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
14719   var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
14720
14721   var inModule = typeof module === "object";
14722   var runtime = global.regeneratorRuntime;
14723   if (runtime) {
14724     if (inModule) {
14725       // If regeneratorRuntime is defined globally and we're in a module,
14726       // make the exports object identical to regeneratorRuntime.
14727       module.exports = runtime;
14728     }
14729     // Don't bother evaluating the rest of this file if the runtime was
14730     // already defined globally.
14731     return;
14732   }
14733
14734   // Define the runtime globally (as expected by generated code) as either
14735   // module.exports (if we're in a module) or a new, empty object.
14736   runtime = global.regeneratorRuntime = inModule ? module.exports : {};
14737
14738   function wrap(innerFn, outerFn, self, tryLocsList) {
14739     // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
14740     var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
14741     var generator = Object.create(protoGenerator.prototype);
14742     var context = new Context(tryLocsList || []);
14743
14744     // The ._invoke method unifies the implementations of the .next,
14745     // .throw, and .return methods.
14746     generator._invoke = makeInvokeMethod(innerFn, self, context);
14747
14748     return generator;
14749   }
14750   runtime.wrap = wrap;
14751
14752   // Try/catch helper to minimize deoptimizations. Returns a completion
14753   // record like context.tryEntries[i].completion. This interface could
14754   // have been (and was previously) designed to take a closure to be
14755   // invoked without arguments, but in all the cases we care about we
14756   // already have an existing method we want to call, so there's no need
14757   // to create a new function object. We can even get away with assuming
14758   // the method takes exactly one argument, since that happens to be true
14759   // in every case, so we don't have to touch the arguments object. The
14760   // only additional allocation required is the completion record, which
14761   // has a stable shape and so hopefully should be cheap to allocate.
14762   function tryCatch(fn, obj, arg) {
14763     try {
14764       return { type: "normal", arg: fn.call(obj, arg) };
14765     } catch (err) {
14766       return { type: "throw", arg: err };
14767     }
14768   }
14769
14770   var GenStateSuspendedStart = "suspendedStart";
14771   var GenStateSuspendedYield = "suspendedYield";
14772   var GenStateExecuting = "executing";
14773   var GenStateCompleted = "completed";
14774
14775   // Returning this object from the innerFn has the same effect as
14776   // breaking out of the dispatch switch statement.
14777   var ContinueSentinel = {};
14778
14779   // Dummy constructor functions that we use as the .constructor and
14780   // .constructor.prototype properties for functions that return Generator
14781   // objects. For full spec compliance, you may wish to configure your
14782   // minifier not to mangle the names of these two functions.
14783   function Generator() {}
14784   function GeneratorFunction() {}
14785   function GeneratorFunctionPrototype() {}
14786
14787   // This is a polyfill for %IteratorPrototype% for environments that
14788   // don't natively support it.
14789   var IteratorPrototype = {};
14790   IteratorPrototype[iteratorSymbol] = function () {
14791     return this;
14792   };
14793
14794   var getProto = Object.getPrototypeOf;
14795   var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
14796   if (NativeIteratorPrototype &&
14797       NativeIteratorPrototype !== Op &&
14798       hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
14799     // This environment has a native %IteratorPrototype%; use it instead
14800     // of the polyfill.
14801     IteratorPrototype = NativeIteratorPrototype;
14802   }
14803
14804   var Gp = GeneratorFunctionPrototype.prototype =
14805     Generator.prototype = Object.create(IteratorPrototype);
14806   GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
14807   GeneratorFunctionPrototype.constructor = GeneratorFunction;
14808   GeneratorFunctionPrototype[toStringTagSymbol] =
14809     GeneratorFunction.displayName = "GeneratorFunction";
14810
14811   // Helper for defining the .next, .throw, and .return methods of the
14812   // Iterator interface in terms of a single ._invoke method.
14813   function defineIteratorMethods(prototype) {
14814     ["next", "throw", "return"].forEach(function(method) {
14815       prototype[method] = function(arg) {
14816         return this._invoke(method, arg);
14817       };
14818     });
14819   }
14820
14821   runtime.isGeneratorFunction = function(genFun) {
14822     var ctor = typeof genFun === "function" && genFun.constructor;
14823     return ctor
14824       ? ctor === GeneratorFunction ||
14825         // For the native GeneratorFunction constructor, the best we can
14826         // do is to check its .name property.
14827         (ctor.displayName || ctor.name) === "GeneratorFunction"
14828       : false;
14829   };
14830
14831   runtime.mark = function(genFun) {
14832     if (Object.setPrototypeOf) {
14833       Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
14834     } else {
14835       genFun.__proto__ = GeneratorFunctionPrototype;
14836       if (!(toStringTagSymbol in genFun)) {
14837         genFun[toStringTagSymbol] = "GeneratorFunction";
14838       }
14839     }
14840     genFun.prototype = Object.create(Gp);
14841     return genFun;
14842   };
14843
14844   // Within the body of any async function, `await x` is transformed to
14845   // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
14846   // `hasOwn.call(value, "__await")` to determine if the yielded value is
14847   // meant to be awaited.
14848   runtime.awrap = function(arg) {
14849     return { __await: arg };
14850   };
14851
14852   function AsyncIterator(generator) {
14853     function invoke(method, arg, resolve, reject) {
14854       var record = tryCatch(generator[method], generator, arg);
14855       if (record.type === "throw") {
14856         reject(record.arg);
14857       } else {
14858         var result = record.arg;
14859         var value = result.value;
14860         if (value &&
14861             typeof value === "object" &&
14862             hasOwn.call(value, "__await")) {
14863           return Promise.resolve(value.__await).then(function(value) {
14864             invoke("next", value, resolve, reject);
14865           }, function(err) {
14866             invoke("throw", err, resolve, reject);
14867           });
14868         }
14869
14870         return Promise.resolve(value).then(function(unwrapped) {
14871           // When a yielded Promise is resolved, its final value becomes
14872           // the .value of the Promise<{value,done}> result for the
14873           // current iteration. If the Promise is rejected, however, the
14874           // result for this iteration will be rejected with the same
14875           // reason. Note that rejections of yielded Promises are not
14876           // thrown back into the generator function, as is the case
14877           // when an awaited Promise is rejected. This difference in
14878           // behavior between yield and await is important, because it
14879           // allows the consumer to decide what to do with the yielded
14880           // rejection (swallow it and continue, manually .throw it back
14881           // into the generator, abandon iteration, whatever). With
14882           // await, by contrast, there is no opportunity to examine the
14883           // rejection reason outside the generator function, so the
14884           // only option is to throw it from the await expression, and
14885           // let the generator function handle the exception.
14886           result.value = unwrapped;
14887           resolve(result);
14888         }, reject);
14889       }
14890     }
14891
14892     var previousPromise;
14893
14894     function enqueue(method, arg) {
14895       function callInvokeWithMethodAndArg() {
14896         return new Promise(function(resolve, reject) {
14897           invoke(method, arg, resolve, reject);
14898         });
14899       }
14900
14901       return previousPromise =
14902         // If enqueue has been called before, then we want to wait until
14903         // all previous Promises have been resolved before calling invoke,
14904         // so that results are always delivered in the correct order. If
14905         // enqueue has not been called before, then it is important to
14906         // call invoke immediately, without waiting on a callback to fire,
14907         // so that the async generator function has the opportunity to do
14908         // any necessary setup in a predictable way. This predictability
14909         // is why the Promise constructor synchronously invokes its
14910         // executor callback, and why async functions synchronously
14911         // execute code before the first await. Since we implement simple
14912         // async functions in terms of async generators, it is especially
14913         // important to get this right, even though it requires care.
14914         previousPromise ? previousPromise.then(
14915           callInvokeWithMethodAndArg,
14916           // Avoid propagating failures to Promises returned by later
14917           // invocations of the iterator.
14918           callInvokeWithMethodAndArg
14919         ) : callInvokeWithMethodAndArg();
14920     }
14921
14922     // Define the unified helper method that is used to implement .next,
14923     // .throw, and .return (see defineIteratorMethods).
14924     this._invoke = enqueue;
14925   }
14926
14927   defineIteratorMethods(AsyncIterator.prototype);
14928   AsyncIterator.prototype[asyncIteratorSymbol] = function () {
14929     return this;
14930   };
14931   runtime.AsyncIterator = AsyncIterator;
14932
14933   // Note that simple async functions are implemented on top of
14934   // AsyncIterator objects; they just return a Promise for the value of
14935   // the final result produced by the iterator.
14936   runtime.async = function(innerFn, outerFn, self, tryLocsList) {
14937     var iter = new AsyncIterator(
14938       wrap(innerFn, outerFn, self, tryLocsList)
14939     );
14940
14941     return runtime.isGeneratorFunction(outerFn)
14942       ? iter // If outerFn is a generator, return the full iterator.
14943       : iter.next().then(function(result) {
14944           return result.done ? result.value : iter.next();
14945         });
14946   };
14947
14948   function makeInvokeMethod(innerFn, self, context) {
14949     var state = GenStateSuspendedStart;
14950
14951     return function invoke(method, arg) {
14952       if (state === GenStateExecuting) {
14953         throw new Error("Generator is already running");
14954       }
14955
14956       if (state === GenStateCompleted) {
14957         if (method === "throw") {
14958           throw arg;
14959         }
14960
14961         // Be forgiving, per 25.3.3.3.3 of the spec:
14962         // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
14963         return doneResult();
14964       }
14965
14966       context.method = method;
14967       context.arg = arg;
14968
14969       while (true) {
14970         var delegate = context.delegate;
14971         if (delegate) {
14972           var delegateResult = maybeInvokeDelegate(delegate, context);
14973           if (delegateResult) {
14974             if (delegateResult === ContinueSentinel) continue;
14975             return delegateResult;
14976           }
14977         }
14978
14979         if (context.method === "next") {
14980           // Setting context._sent for legacy support of Babel's
14981           // function.sent implementation.
14982           context.sent = context._sent = context.arg;
14983
14984         } else if (context.method === "throw") {
14985           if (state === GenStateSuspendedStart) {
14986             state = GenStateCompleted;
14987             throw context.arg;
14988           }
14989
14990           context.dispatchException(context.arg);
14991
14992         } else if (context.method === "return") {
14993           context.abrupt("return", context.arg);
14994         }
14995
14996         state = GenStateExecuting;
14997
14998         var record = tryCatch(innerFn, self, context);
14999         if (record.type === "normal") {
15000           // If an exception is thrown from innerFn, we leave state ===
15001           // GenStateExecuting and loop back for another invocation.
15002           state = context.done
15003             ? GenStateCompleted
15004             : GenStateSuspendedYield;
15005
15006           if (record.arg === ContinueSentinel) {
15007             continue;
15008           }
15009
15010           return {
15011             value: record.arg,
15012             done: context.done
15013           };
15014
15015         } else if (record.type === "throw") {
15016           state = GenStateCompleted;
15017           // Dispatch the exception by looping back around to the
15018           // context.dispatchException(context.arg) call above.
15019           context.method = "throw";
15020           context.arg = record.arg;
15021         }
15022       }
15023     };
15024   }
15025
15026   // Call delegate.iterator[context.method](context.arg) and handle the
15027   // result, either by returning a { value, done } result from the
15028   // delegate iterator, or by modifying context.method and context.arg,
15029   // setting context.delegate to null, and returning the ContinueSentinel.
15030   function maybeInvokeDelegate(delegate, context) {
15031     var method = delegate.iterator[context.method];
15032     if (method === undefined) {
15033       // A .throw or .return when the delegate iterator has no .throw
15034       // method always terminates the yield* loop.
15035       context.delegate = null;
15036
15037       if (context.method === "throw") {
15038         if (delegate.iterator.return) {
15039           // If the delegate iterator has a return method, give it a
15040           // chance to clean up.
15041           context.method = "return";
15042           context.arg = undefined;
15043           maybeInvokeDelegate(delegate, context);
15044
15045           if (context.method === "throw") {
15046             // If maybeInvokeDelegate(context) changed context.method from
15047             // "return" to "throw", let that override the TypeError below.
15048             return ContinueSentinel;
15049           }
15050         }
15051
15052         context.method = "throw";
15053         context.arg = new TypeError(
15054           "The iterator does not provide a 'throw' method");
15055       }
15056
15057       return ContinueSentinel;
15058     }
15059
15060     var record = tryCatch(method, delegate.iterator, context.arg);
15061
15062     if (record.type === "throw") {
15063       context.method = "throw";
15064       context.arg = record.arg;
15065       context.delegate = null;
15066       return ContinueSentinel;
15067     }
15068
15069     var info = record.arg;
15070
15071     if (! info) {
15072       context.method = "throw";
15073       context.arg = new TypeError("iterator result is not an object");
15074       context.delegate = null;
15075       return ContinueSentinel;
15076     }
15077
15078     if (info.done) {
15079       // Assign the result of the finished delegate to the temporary
15080       // variable specified by delegate.resultName (see delegateYield).
15081       context[delegate.resultName] = info.value;
15082
15083       // Resume execution at the desired location (see delegateYield).
15084       context.next = delegate.nextLoc;
15085
15086       // If context.method was "throw" but the delegate handled the
15087       // exception, let the outer generator proceed normally. If
15088       // context.method was "next", forget context.arg since it has been
15089       // "consumed" by the delegate iterator. If context.method was
15090       // "return", allow the original .return call to continue in the
15091       // outer generator.
15092       if (context.method !== "return") {
15093         context.method = "next";
15094         context.arg = undefined;
15095       }
15096
15097     } else {
15098       // Re-yield the result returned by the delegate method.
15099       return info;
15100     }
15101
15102     // The delegate iterator is finished, so forget it and continue with
15103     // the outer generator.
15104     context.delegate = null;
15105     return ContinueSentinel;
15106   }
15107
15108   // Define Generator.prototype.{next,throw,return} in terms of the
15109   // unified ._invoke helper method.
15110   defineIteratorMethods(Gp);
15111
15112   Gp[toStringTagSymbol] = "Generator";
15113
15114   // A Generator should always return itself as the iterator object when the
15115   // @@iterator function is called on it. Some browsers' implementations of the
15116   // iterator prototype chain incorrectly implement this, causing the Generator
15117   // object to not be returned from this call. This ensures that doesn't happen.
15118   // See https://github.com/facebook/regenerator/issues/274 for more details.
15119   Gp[iteratorSymbol] = function() {
15120     return this;
15121   };
15122
15123   Gp.toString = function() {
15124     return "[object Generator]";
15125   };
15126
15127   function pushTryEntry(locs) {
15128     var entry = { tryLoc: locs[0] };
15129
15130     if (1 in locs) {
15131       entry.catchLoc = locs[1];
15132     }
15133
15134     if (2 in locs) {
15135       entry.finallyLoc = locs[2];
15136       entry.afterLoc = locs[3];
15137     }
15138
15139     this.tryEntries.push(entry);
15140   }
15141
15142   function resetTryEntry(entry) {
15143     var record = entry.completion || {};
15144     record.type = "normal";
15145     delete record.arg;
15146     entry.completion = record;
15147   }
15148
15149   function Context(tryLocsList) {
15150     // The root entry object (effectively a try statement without a catch
15151     // or a finally block) gives us a place to store values thrown from
15152     // locations where there is no enclosing try statement.
15153     this.tryEntries = [{ tryLoc: "root" }];
15154     tryLocsList.forEach(pushTryEntry, this);
15155     this.reset(true);
15156   }
15157
15158   runtime.keys = function(object) {
15159     var keys = [];
15160     for (var key in object) {
15161       keys.push(key);
15162     }
15163     keys.reverse();
15164
15165     // Rather than returning an object with a next method, we keep
15166     // things simple and return the next function itself.
15167     return function next() {
15168       while (keys.length) {
15169         var key = keys.pop();
15170         if (key in object) {
15171           next.value = key;
15172           next.done = false;
15173           return next;
15174         }
15175       }
15176
15177       // To avoid creating an additional object, we just hang the .value
15178       // and .done properties off the next function object itself. This
15179       // also ensures that the minifier will not anonymize the function.
15180       next.done = true;
15181       return next;
15182     };
15183   };
15184
15185   function values(iterable) {
15186     if (iterable) {
15187       var iteratorMethod = iterable[iteratorSymbol];
15188       if (iteratorMethod) {
15189         return iteratorMethod.call(iterable);
15190       }
15191
15192       if (typeof iterable.next === "function") {
15193         return iterable;
15194       }
15195
15196       if (!isNaN(iterable.length)) {
15197         var i = -1, next = function next() {
15198           while (++i < iterable.length) {
15199             if (hasOwn.call(iterable, i)) {
15200               next.value = iterable[i];
15201               next.done = false;
15202               return next;
15203             }
15204           }
15205
15206           next.value = undefined;
15207           next.done = true;
15208
15209           return next;
15210         };
15211
15212         return next.next = next;
15213       }
15214     }
15215
15216     // Return an iterator with no values.
15217     return { next: doneResult };
15218   }
15219   runtime.values = values;
15220
15221   function doneResult() {
15222     return { value: undefined, done: true };
15223   }
15224
15225   Context.prototype = {
15226     constructor: Context,
15227
15228     reset: function(skipTempReset) {
15229       this.prev = 0;
15230       this.next = 0;
15231       // Resetting context._sent for legacy support of Babel's
15232       // function.sent implementation.
15233       this.sent = this._sent = undefined;
15234       this.done = false;
15235       this.delegate = null;
15236
15237       this.method = "next";
15238       this.arg = undefined;
15239
15240       this.tryEntries.forEach(resetTryEntry);
15241
15242       if (!skipTempReset) {
15243         for (var name in this) {
15244           // Not sure about the optimal order of these conditions:
15245           if (name.charAt(0) === "t" &&
15246               hasOwn.call(this, name) &&
15247               !isNaN(+name.slice(1))) {
15248             this[name] = undefined;
15249           }
15250         }
15251       }
15252     },
15253
15254     stop: function() {
15255       this.done = true;
15256
15257       var rootEntry = this.tryEntries[0];
15258       var rootRecord = rootEntry.completion;
15259       if (rootRecord.type === "throw") {
15260         throw rootRecord.arg;
15261       }
15262
15263       return this.rval;
15264     },
15265
15266     dispatchException: function(exception) {
15267       if (this.done) {
15268         throw exception;
15269       }
15270
15271       var context = this;
15272       function handle(loc, caught) {
15273         record.type = "throw";
15274         record.arg = exception;
15275         context.next = loc;
15276
15277         if (caught) {
15278           // If the dispatched exception was caught by a catch block,
15279           // then let that catch block handle the exception normally.
15280           context.method = "next";
15281           context.arg = undefined;
15282         }
15283
15284         return !! caught;
15285       }
15286
15287       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15288         var entry = this.tryEntries[i];
15289         var record = entry.completion;
15290
15291         if (entry.tryLoc === "root") {
15292           // Exception thrown outside of any try block that could handle
15293           // it, so set the completion value of the entire function to
15294           // throw the exception.
15295           return handle("end");
15296         }
15297
15298         if (entry.tryLoc <= this.prev) {
15299           var hasCatch = hasOwn.call(entry, "catchLoc");
15300           var hasFinally = hasOwn.call(entry, "finallyLoc");
15301
15302           if (hasCatch && hasFinally) {
15303             if (this.prev < entry.catchLoc) {
15304               return handle(entry.catchLoc, true);
15305             } else if (this.prev < entry.finallyLoc) {
15306               return handle(entry.finallyLoc);
15307             }
15308
15309           } else if (hasCatch) {
15310             if (this.prev < entry.catchLoc) {
15311               return handle(entry.catchLoc, true);
15312             }
15313
15314           } else if (hasFinally) {
15315             if (this.prev < entry.finallyLoc) {
15316               return handle(entry.finallyLoc);
15317             }
15318
15319           } else {
15320             throw new Error("try statement without catch or finally");
15321           }
15322         }
15323       }
15324     },
15325
15326     abrupt: function(type, arg) {
15327       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15328         var entry = this.tryEntries[i];
15329         if (entry.tryLoc <= this.prev &&
15330             hasOwn.call(entry, "finallyLoc") &&
15331             this.prev < entry.finallyLoc) {
15332           var finallyEntry = entry;
15333           break;
15334         }
15335       }
15336
15337       if (finallyEntry &&
15338           (type === "break" ||
15339            type === "continue") &&
15340           finallyEntry.tryLoc <= arg &&
15341           arg <= finallyEntry.finallyLoc) {
15342         // Ignore the finally entry if control is not jumping to a
15343         // location outside the try/catch block.
15344         finallyEntry = null;
15345       }
15346
15347       var record = finallyEntry ? finallyEntry.completion : {};
15348       record.type = type;
15349       record.arg = arg;
15350
15351       if (finallyEntry) {
15352         this.method = "next";
15353         this.next = finallyEntry.finallyLoc;
15354         return ContinueSentinel;
15355       }
15356
15357       return this.complete(record);
15358     },
15359
15360     complete: function(record, afterLoc) {
15361       if (record.type === "throw") {
15362         throw record.arg;
15363       }
15364
15365       if (record.type === "break" ||
15366           record.type === "continue") {
15367         this.next = record.arg;
15368       } else if (record.type === "return") {
15369         this.rval = this.arg = record.arg;
15370         this.method = "return";
15371         this.next = "end";
15372       } else if (record.type === "normal" && afterLoc) {
15373         this.next = afterLoc;
15374       }
15375
15376       return ContinueSentinel;
15377     },
15378
15379     finish: function(finallyLoc) {
15380       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15381         var entry = this.tryEntries[i];
15382         if (entry.finallyLoc === finallyLoc) {
15383           this.complete(entry.completion, entry.afterLoc);
15384           resetTryEntry(entry);
15385           return ContinueSentinel;
15386         }
15387       }
15388     },
15389
15390     "catch": function(tryLoc) {
15391       for (var i = this.tryEntries.length - 1; i >= 0; --i) {
15392         var entry = this.tryEntries[i];
15393         if (entry.tryLoc === tryLoc) {
15394           var record = entry.completion;
15395           if (record.type === "throw") {
15396             var thrown = record.arg;
15397             resetTryEntry(entry);
15398           }
15399           return thrown;
15400         }
15401       }
15402
15403       // The context.catch method must only be called with a location
15404       // argument that corresponds to a known catch block.
15405       throw new Error("illegal catch attempt");
15406     },
15407
15408     delegateYield: function(iterable, resultName, nextLoc) {
15409       this.delegate = {
15410         iterator: values(iterable),
15411         resultName: resultName,
15412         nextLoc: nextLoc
15413       };
15414
15415       if (this.method === "next") {
15416         // Deliberately forget the last sent value so that we don't
15417         // accidentally pass it on to the delegate.
15418         this.arg = undefined;
15419       }
15420
15421       return ContinueSentinel;
15422     }
15423   };
15424 })(
15425   // In sloppy mode, unbound `this` refers to the global object, fallback to
15426   // Function constructor if we're in global strict mode. That is sadly a form
15427   // of indirect eval which violates Content Security Policy.
15428   (function() { return this })() || Function("return this")()
15429 );
15430
15431
15432 /***/ }),
15433 /* 156 */
15434 /***/ (function(module, exports, __webpack_require__) {
15435
15436 __webpack_require__(77);
15437 __webpack_require__(132);
15438 __webpack_require__(79);
15439 __webpack_require__(164);
15440 __webpack_require__(173);
15441 __webpack_require__(174);
15442 module.exports = __webpack_require__(8).Promise;
15443
15444
15445 /***/ }),
15446 /* 157 */
15447 /***/ (function(module, exports, __webpack_require__) {
15448
15449 var toInteger = __webpack_require__(52);
15450 var defined = __webpack_require__(51);
15451 // true  -> String#at
15452 // false -> String#codePointAt
15453 module.exports = function (TO_STRING) {
15454   return function (that, pos) {
15455     var s = String(defined(that));
15456     var i = toInteger(pos);
15457     var l = s.length;
15458     var a, b;
15459     if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
15460     a = s.charCodeAt(i);
15461     return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
15462       ? TO_STRING ? s.charAt(i) : a
15463       : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
15464   };
15465 };
15466
15467
15468 /***/ }),
15469 /* 158 */
15470 /***/ (function(module, exports, __webpack_require__) {
15471
15472 "use strict";
15473
15474 var create = __webpack_require__(133);
15475 var descriptor = __webpack_require__(48);
15476 var setToStringTag = __webpack_require__(40);
15477 var IteratorPrototype = {};
15478
15479 // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
15480 __webpack_require__(19)(IteratorPrototype, __webpack_require__(7)('iterator'), function () { return this; });
15481
15482 module.exports = function (Constructor, NAME, next) {
15483   Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
15484   setToStringTag(Constructor, NAME + ' Iterator');
15485 };
15486
15487
15488 /***/ }),
15489 /* 159 */
15490 /***/ (function(module, exports, __webpack_require__) {
15491
15492 var dP = __webpack_require__(16);
15493 var anObject = __webpack_require__(15);
15494 var getKeys = __webpack_require__(39);
15495
15496 module.exports = __webpack_require__(17) ? Object.defineProperties : function defineProperties(O, Properties) {
15497   anObject(O);
15498   var keys = getKeys(Properties);
15499   var length = keys.length;
15500   var i = 0;
15501   var P;
15502   while (length > i) dP.f(O, P = keys[i++], Properties[P]);
15503   return O;
15504 };
15505
15506
15507 /***/ }),
15508 /* 160 */
15509 /***/ (function(module, exports, __webpack_require__) {
15510
15511 // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
15512 var has = __webpack_require__(20);
15513 var toObject = __webpack_require__(54);
15514 var IE_PROTO = __webpack_require__(53)('IE_PROTO');
15515 var ObjectProto = Object.prototype;
15516
15517 module.exports = Object.getPrototypeOf || function (O) {
15518   O = toObject(O);
15519   if (has(O, IE_PROTO)) return O[IE_PROTO];
15520   if (typeof O.constructor == 'function' && O instanceof O.constructor) {
15521     return O.constructor.prototype;
15522   } return O instanceof Object ? ObjectProto : null;
15523 };
15524
15525
15526 /***/ }),
15527 /* 161 */
15528 /***/ (function(module, exports, __webpack_require__) {
15529
15530 "use strict";
15531
15532 var addToUnscopables = __webpack_require__(162);
15533 var step = __webpack_require__(163);
15534 var Iterators = __webpack_require__(28);
15535 var toIObject = __webpack_require__(25);
15536
15537 // 22.1.3.4 Array.prototype.entries()
15538 // 22.1.3.13 Array.prototype.keys()
15539 // 22.1.3.29 Array.prototype.values()
15540 // 22.1.3.30 Array.prototype[@@iterator]()
15541 module.exports = __webpack_require__(85)(Array, 'Array', function (iterated, kind) {
15542   this._t = toIObject(iterated); // target
15543   this._i = 0;                   // next index
15544   this._k = kind;                // kind
15545 // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
15546 }, function () {
15547   var O = this._t;
15548   var kind = this._k;
15549   var index = this._i++;
15550   if (!O || index >= O.length) {
15551     this._t = undefined;
15552     return step(1);
15553   }
15554   if (kind == 'keys') return step(0, index);
15555   if (kind == 'values') return step(0, O[index]);
15556   return step(0, [index, O[index]]);
15557 }, 'values');
15558
15559 // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
15560 Iterators.Arguments = Iterators.Array;
15561
15562 addToUnscopables('keys');
15563 addToUnscopables('values');
15564 addToUnscopables('entries');
15565
15566
15567 /***/ }),
15568 /* 162 */
15569 /***/ (function(module, exports) {
15570
15571 module.exports = function () { /* empty */ };
15572
15573
15574 /***/ }),
15575 /* 163 */
15576 /***/ (function(module, exports) {
15577
15578 module.exports = function (done, value) {
15579   return { value: value, done: !!done };
15580 };
15581
15582
15583 /***/ }),
15584 /* 164 */
15585 /***/ (function(module, exports, __webpack_require__) {
15586
15587 "use strict";
15588
15589 var LIBRARY = __webpack_require__(37);
15590 var global = __webpack_require__(5);
15591 var ctx = __webpack_require__(35);
15592 var classof = __webpack_require__(87);
15593 var $export = __webpack_require__(13);
15594 var isObject = __webpack_require__(12);
15595 var aFunction = __webpack_require__(38);
15596 var anInstance = __webpack_require__(134);
15597 var forOf = __webpack_require__(80);
15598 var speciesConstructor = __webpack_require__(88);
15599 var task = __webpack_require__(89).set;
15600 var microtask = __webpack_require__(169)();
15601 var newPromiseCapabilityModule = __webpack_require__(55);
15602 var perform = __webpack_require__(90);
15603 var userAgent = __webpack_require__(170);
15604 var promiseResolve = __webpack_require__(91);
15605 var PROMISE = 'Promise';
15606 var TypeError = global.TypeError;
15607 var process = global.process;
15608 var versions = process && process.versions;
15609 var v8 = versions && versions.v8 || '';
15610 var $Promise = global[PROMISE];
15611 var isNode = classof(process) == 'process';
15612 var empty = function () { /* empty */ };
15613 var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
15614 var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
15615
15616 var USE_NATIVE = !!function () {
15617   try {
15618     // correct subclassing with @@species support
15619     var promise = $Promise.resolve(1);
15620     var FakePromise = (promise.constructor = {})[__webpack_require__(7)('species')] = function (exec) {
15621       exec(empty, empty);
15622     };
15623     // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
15624     return (isNode || typeof PromiseRejectionEvent == 'function')
15625       && promise.then(empty) instanceof FakePromise
15626       // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
15627       // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
15628       // we can't detect it synchronously, so just check versions
15629       && v8.indexOf('6.6') !== 0
15630       && userAgent.indexOf('Chrome/66') === -1;
15631   } catch (e) { /* empty */ }
15632 }();
15633
15634 // helpers
15635 var isThenable = function (it) {
15636   var then;
15637   return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
15638 };
15639 var notify = function (promise, isReject) {
15640   if (promise._n) return;
15641   promise._n = true;
15642   var chain = promise._c;
15643   microtask(function () {
15644     var value = promise._v;
15645     var ok = promise._s == 1;
15646     var i = 0;
15647     var run = function (reaction) {
15648       var handler = ok ? reaction.ok : reaction.fail;
15649       var resolve = reaction.resolve;
15650       var reject = reaction.reject;
15651       var domain = reaction.domain;
15652       var result, then, exited;
15653       try {
15654         if (handler) {
15655           if (!ok) {
15656             if (promise._h == 2) onHandleUnhandled(promise);
15657             promise._h = 1;
15658           }
15659           if (handler === true) result = value;
15660           else {
15661             if (domain) domain.enter();
15662             result = handler(value); // may throw
15663             if (domain) {
15664               domain.exit();
15665               exited = true;
15666             }
15667           }
15668           if (result === reaction.promise) {
15669             reject(TypeError('Promise-chain cycle'));
15670           } else if (then = isThenable(result)) {
15671             then.call(result, resolve, reject);
15672           } else resolve(result);
15673         } else reject(value);
15674       } catch (e) {
15675         if (domain && !exited) domain.exit();
15676         reject(e);
15677       }
15678     };
15679     while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
15680     promise._c = [];
15681     promise._n = false;
15682     if (isReject && !promise._h) onUnhandled(promise);
15683   });
15684 };
15685 var onUnhandled = function (promise) {
15686   task.call(global, function () {
15687     var value = promise._v;
15688     var unhandled = isUnhandled(promise);
15689     var result, handler, console;
15690     if (unhandled) {
15691       result = perform(function () {
15692         if (isNode) {
15693           process.emit('unhandledRejection', value, promise);
15694         } else if (handler = global.onunhandledrejection) {
15695           handler({ promise: promise, reason: value });
15696         } else if ((console = global.console) && console.error) {
15697           console.error('Unhandled promise rejection', value);
15698         }
15699       });
15700       // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
15701       promise._h = isNode || isUnhandled(promise) ? 2 : 1;
15702     } promise._a = undefined;
15703     if (unhandled && result.e) throw result.v;
15704   });
15705 };
15706 var isUnhandled = function (promise) {
15707   return promise._h !== 1 && (promise._a || promise._c).length === 0;
15708 };
15709 var onHandleUnhandled = function (promise) {
15710   task.call(global, function () {
15711     var handler;
15712     if (isNode) {
15713       process.emit('rejectionHandled', promise);
15714     } else if (handler = global.onrejectionhandled) {
15715       handler({ promise: promise, reason: promise._v });
15716     }
15717   });
15718 };
15719 var $reject = function (value) {
15720   var promise = this;
15721   if (promise._d) return;
15722   promise._d = true;
15723   promise = promise._w || promise; // unwrap
15724   promise._v = value;
15725   promise._s = 2;
15726   if (!promise._a) promise._a = promise._c.slice();
15727   notify(promise, true);
15728 };
15729 var $resolve = function (value) {
15730   var promise = this;
15731   var then;
15732   if (promise._d) return;
15733   promise._d = true;
15734   promise = promise._w || promise; // unwrap
15735   try {
15736     if (promise === value) throw TypeError("Promise can't be resolved itself");
15737     if (then = isThenable(value)) {
15738       microtask(function () {
15739         var wrapper = { _w: promise, _d: false }; // wrap
15740         try {
15741           then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
15742         } catch (e) {
15743           $reject.call(wrapper, e);
15744         }
15745       });
15746     } else {
15747       promise._v = value;
15748       promise._s = 1;
15749       notify(promise, false);
15750     }
15751   } catch (e) {
15752     $reject.call({ _w: promise, _d: false }, e); // wrap
15753   }
15754 };
15755
15756 // constructor polyfill
15757 if (!USE_NATIVE) {
15758   // 25.4.3.1 Promise(executor)
15759   $Promise = function Promise(executor) {
15760     anInstance(this, $Promise, PROMISE, '_h');
15761     aFunction(executor);
15762     Internal.call(this);
15763     try {
15764       executor(ctx($resolve, this, 1), ctx($reject, this, 1));
15765     } catch (err) {
15766       $reject.call(this, err);
15767     }
15768   };
15769   // eslint-disable-next-line no-unused-vars
15770   Internal = function Promise(executor) {
15771     this._c = [];             // <- awaiting reactions
15772     this._a = undefined;      // <- checked in isUnhandled reactions
15773     this._s = 0;              // <- state
15774     this._d = false;          // <- done
15775     this._v = undefined;      // <- value
15776     this._h = 0;              // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
15777     this._n = false;          // <- notify
15778   };
15779   Internal.prototype = __webpack_require__(135)($Promise.prototype, {
15780     // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
15781     then: function then(onFulfilled, onRejected) {
15782       var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
15783       reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
15784       reaction.fail = typeof onRejected == 'function' && onRejected;
15785       reaction.domain = isNode ? process.domain : undefined;
15786       this._c.push(reaction);
15787       if (this._a) this._a.push(reaction);
15788       if (this._s) notify(this, false);
15789       return reaction.promise;
15790     },
15791     // 25.4.5.1 Promise.prototype.catch(onRejected)
15792     'catch': function (onRejected) {
15793       return this.then(undefined, onRejected);
15794     }
15795   });
15796   OwnPromiseCapability = function () {
15797     var promise = new Internal();
15798     this.promise = promise;
15799     this.resolve = ctx($resolve, promise, 1);
15800     this.reject = ctx($reject, promise, 1);
15801   };
15802   newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
15803     return C === $Promise || C === Wrapper
15804       ? new OwnPromiseCapability(C)
15805       : newGenericPromiseCapability(C);
15806   };
15807 }
15808
15809 $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
15810 __webpack_require__(40)($Promise, PROMISE);
15811 __webpack_require__(171)(PROMISE);
15812 Wrapper = __webpack_require__(8)[PROMISE];
15813
15814 // statics
15815 $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
15816   // 25.4.4.5 Promise.reject(r)
15817   reject: function reject(r) {
15818     var capability = newPromiseCapability(this);
15819     var $$reject = capability.reject;
15820     $$reject(r);
15821     return capability.promise;
15822   }
15823 });
15824 $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
15825   // 25.4.4.6 Promise.resolve(x)
15826   resolve: function resolve(x) {
15827     return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
15828   }
15829 });
15830 $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(172)(function (iter) {
15831   $Promise.all(iter)['catch'](empty);
15832 })), PROMISE, {
15833   // 25.4.4.1 Promise.all(iterable)
15834   all: function all(iterable) {
15835     var C = this;
15836     var capability = newPromiseCapability(C);
15837     var resolve = capability.resolve;
15838     var reject = capability.reject;
15839     var result = perform(function () {
15840       var values = [];
15841       var index = 0;
15842       var remaining = 1;
15843       forOf(iterable, false, function (promise) {
15844         var $index = index++;
15845         var alreadyCalled = false;
15846         values.push(undefined);
15847         remaining++;
15848         C.resolve(promise).then(function (value) {
15849           if (alreadyCalled) return;
15850           alreadyCalled = true;
15851           values[$index] = value;
15852           --remaining || resolve(values);
15853         }, reject);
15854       });
15855       --remaining || resolve(values);
15856     });
15857     if (result.e) reject(result.v);
15858     return capability.promise;
15859   },
15860   // 25.4.4.4 Promise.race(iterable)
15861   race: function race(iterable) {
15862     var C = this;
15863     var capability = newPromiseCapability(C);
15864     var reject = capability.reject;
15865     var result = perform(function () {
15866       forOf(iterable, false, function (promise) {
15867         C.resolve(promise).then(capability.resolve, reject);
15868       });
15869     });
15870     if (result.e) reject(result.v);
15871     return capability.promise;
15872   }
15873 });
15874
15875
15876 /***/ }),
15877 /* 165 */
15878 /***/ (function(module, exports, __webpack_require__) {
15879
15880 // call something on iterator step with safe closing on error
15881 var anObject = __webpack_require__(15);
15882 module.exports = function (iterator, fn, value, entries) {
15883   try {
15884     return entries ? fn(anObject(value)[0], value[1]) : fn(value);
15885   // 7.4.6 IteratorClose(iterator, completion)
15886   } catch (e) {
15887     var ret = iterator['return'];
15888     if (ret !== undefined) anObject(ret.call(iterator));
15889     throw e;
15890   }
15891 };
15892
15893
15894 /***/ }),
15895 /* 166 */
15896 /***/ (function(module, exports, __webpack_require__) {
15897
15898 // check on default Array iterator
15899 var Iterators = __webpack_require__(28);
15900 var ITERATOR = __webpack_require__(7)('iterator');
15901 var ArrayProto = Array.prototype;
15902
15903 module.exports = function (it) {
15904   return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
15905 };
15906
15907
15908 /***/ }),
15909 /* 167 */
15910 /***/ (function(module, exports, __webpack_require__) {
15911
15912 var classof = __webpack_require__(87);
15913 var ITERATOR = __webpack_require__(7)('iterator');
15914 var Iterators = __webpack_require__(28);
15915 module.exports = __webpack_require__(8).getIteratorMethod = function (it) {
15916   if (it != undefined) return it[ITERATOR]
15917     || it['@@iterator']
15918     || Iterators[classof(it)];
15919 };
15920
15921
15922 /***/ }),
15923 /* 168 */
15924 /***/ (function(module, exports) {
15925
15926 // fast apply, http://jsperf.lnkit.com/fast-apply/5
15927 module.exports = function (fn, args, that) {
15928   var un = that === undefined;
15929   switch (args.length) {
15930     case 0: return un ? fn()
15931                       : fn.call(that);
15932     case 1: return un ? fn(args[0])
15933                       : fn.call(that, args[0]);
15934     case 2: return un ? fn(args[0], args[1])
15935                       : fn.call(that, args[0], args[1]);
15936     case 3: return un ? fn(args[0], args[1], args[2])
15937                       : fn.call(that, args[0], args[1], args[2]);
15938     case 4: return un ? fn(args[0], args[1], args[2], args[3])
15939                       : fn.call(that, args[0], args[1], args[2], args[3]);
15940   } return fn.apply(that, args);
15941 };
15942
15943
15944 /***/ }),
15945 /* 169 */
15946 /***/ (function(module, exports, __webpack_require__) {
15947
15948 var global = __webpack_require__(5);
15949 var macrotask = __webpack_require__(89).set;
15950 var Observer = global.MutationObserver || global.WebKitMutationObserver;
15951 var process = global.process;
15952 var Promise = global.Promise;
15953 var isNode = __webpack_require__(27)(process) == 'process';
15954
15955 module.exports = function () {
15956   var head, last, notify;
15957
15958   var flush = function () {
15959     var parent, fn;
15960     if (isNode && (parent = process.domain)) parent.exit();
15961     while (head) {
15962       fn = head.fn;
15963       head = head.next;
15964       try {
15965         fn();
15966       } catch (e) {
15967         if (head) notify();
15968         else last = undefined;
15969         throw e;
15970       }
15971     } last = undefined;
15972     if (parent) parent.enter();
15973   };
15974
15975   // Node.js
15976   if (isNode) {
15977     notify = function () {
15978       process.nextTick(flush);
15979     };
15980   // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
15981   } else if (Observer && !(global.navigator && global.navigator.standalone)) {
15982     var toggle = true;
15983     var node = document.createTextNode('');
15984     new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
15985     notify = function () {
15986       node.data = toggle = !toggle;
15987     };
15988   // environments with maybe non-completely correct, but existent Promise
15989   } else if (Promise && Promise.resolve) {
15990     // Promise.resolve without an argument throws an error in LG WebOS 2
15991     var promise = Promise.resolve(undefined);
15992     notify = function () {
15993       promise.then(flush);
15994     };
15995   // for other environments - macrotask based on:
15996   // - setImmediate
15997   // - MessageChannel
15998   // - window.postMessag
15999   // - onreadystatechange
16000   // - setTimeout
16001   } else {
16002     notify = function () {
16003       // strange IE + webpack dev server bug - use .call(global)
16004       macrotask.call(global, flush);
16005     };
16006   }
16007
16008   return function (fn) {
16009     var task = { fn: fn, next: undefined };
16010     if (last) last.next = task;
16011     if (!head) {
16012       head = task;
16013       notify();
16014     } last = task;
16015   };
16016 };
16017
16018
16019 /***/ }),
16020 /* 170 */
16021 /***/ (function(module, exports, __webpack_require__) {
16022
16023 var global = __webpack_require__(5);
16024 var navigator = global.navigator;
16025
16026 module.exports = navigator && navigator.userAgent || '';
16027
16028
16029 /***/ }),
16030 /* 171 */
16031 /***/ (function(module, exports, __webpack_require__) {
16032
16033 "use strict";
16034
16035 var global = __webpack_require__(5);
16036 var core = __webpack_require__(8);
16037 var dP = __webpack_require__(16);
16038 var DESCRIPTORS = __webpack_require__(17);
16039 var SPECIES = __webpack_require__(7)('species');
16040
16041 module.exports = function (KEY) {
16042   var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
16043   if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
16044     configurable: true,
16045     get: function () { return this; }
16046   });
16047 };
16048
16049
16050 /***/ }),
16051 /* 172 */
16052 /***/ (function(module, exports, __webpack_require__) {
16053
16054 var ITERATOR = __webpack_require__(7)('iterator');
16055 var SAFE_CLOSING = false;
16056
16057 try {
16058   var riter = [7][ITERATOR]();
16059   riter['return'] = function () { SAFE_CLOSING = true; };
16060   // eslint-disable-next-line no-throw-literal
16061   Array.from(riter, function () { throw 2; });
16062 } catch (e) { /* empty */ }
16063
16064 module.exports = function (exec, skipClosing) {
16065   if (!skipClosing && !SAFE_CLOSING) return false;
16066   var safe = false;
16067   try {
16068     var arr = [7];
16069     var iter = arr[ITERATOR]();
16070     iter.next = function () { return { done: safe = true }; };
16071     arr[ITERATOR] = function () { return iter; };
16072     exec(arr);
16073   } catch (e) { /* empty */ }
16074   return safe;
16075 };
16076
16077
16078 /***/ }),
16079 /* 173 */
16080 /***/ (function(module, exports, __webpack_require__) {
16081
16082 "use strict";
16083 // https://github.com/tc39/proposal-promise-finally
16084
16085 var $export = __webpack_require__(13);
16086 var core = __webpack_require__(8);
16087 var global = __webpack_require__(5);
16088 var speciesConstructor = __webpack_require__(88);
16089 var promiseResolve = __webpack_require__(91);
16090
16091 $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
16092   var C = speciesConstructor(this, core.Promise || global.Promise);
16093   var isFunction = typeof onFinally == 'function';
16094   return this.then(
16095     isFunction ? function (x) {
16096       return promiseResolve(C, onFinally()).then(function () { return x; });
16097     } : onFinally,
16098     isFunction ? function (e) {
16099       return promiseResolve(C, onFinally()).then(function () { throw e; });
16100     } : onFinally
16101   );
16102 } });
16103
16104
16105 /***/ }),
16106 /* 174 */
16107 /***/ (function(module, exports, __webpack_require__) {
16108
16109 "use strict";
16110
16111 // https://github.com/tc39/proposal-promise-try
16112 var $export = __webpack_require__(13);
16113 var newPromiseCapability = __webpack_require__(55);
16114 var perform = __webpack_require__(90);
16115
16116 $export($export.S, 'Promise', { 'try': function (callbackfn) {
16117   var promiseCapability = newPromiseCapability.f(this);
16118   var result = perform(callbackfn);
16119   (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
16120   return promiseCapability.promise;
16121 } });
16122
16123
16124 /***/ }),
16125 /* 175 */
16126 /***/ (function(module, exports, __webpack_require__) {
16127
16128 "use strict";
16129
16130
16131 exports.byteLength = byteLength
16132 exports.toByteArray = toByteArray
16133 exports.fromByteArray = fromByteArray
16134
16135 var lookup = []
16136 var revLookup = []
16137 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
16138
16139 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
16140 for (var i = 0, len = code.length; i < len; ++i) {
16141   lookup[i] = code[i]
16142   revLookup[code.charCodeAt(i)] = i
16143 }
16144
16145 // Support decoding URL-safe base64 strings, as Node.js does.
16146 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
16147 revLookup['-'.charCodeAt(0)] = 62
16148 revLookup['_'.charCodeAt(0)] = 63
16149
16150 function getLens (b64) {
16151   var len = b64.length
16152
16153   if (len % 4 > 0) {
16154     throw new Error('Invalid string. Length must be a multiple of 4')
16155   }
16156
16157   // Trim off extra bytes after placeholder bytes are found
16158   // See: https://github.com/beatgammit/base64-js/issues/42
16159   var validLen = b64.indexOf('=')
16160   if (validLen === -1) validLen = len
16161
16162   var placeHoldersLen = validLen === len
16163     ? 0
16164     : 4 - (validLen % 4)
16165
16166   return [validLen, placeHoldersLen]
16167 }
16168
16169 // base64 is 4/3 + up to two characters of the original data
16170 function byteLength (b64) {
16171   var lens = getLens(b64)
16172   var validLen = lens[0]
16173   var placeHoldersLen = lens[1]
16174   return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
16175 }
16176
16177 function _byteLength (b64, validLen, placeHoldersLen) {
16178   return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
16179 }
16180
16181 function toByteArray (b64) {
16182   var tmp
16183   var lens = getLens(b64)
16184   var validLen = lens[0]
16185   var placeHoldersLen = lens[1]
16186
16187   var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
16188
16189   var curByte = 0
16190
16191   // if there are placeholders, only get up to the last complete 4 chars
16192   var len = placeHoldersLen > 0
16193     ? validLen - 4
16194     : validLen
16195
16196   for (var i = 0; i < len; i += 4) {
16197     tmp =
16198       (revLookup[b64.charCodeAt(i)] << 18) |
16199       (revLookup[b64.charCodeAt(i + 1)] << 12) |
16200       (revLookup[b64.charCodeAt(i + 2)] << 6) |
16201       revLookup[b64.charCodeAt(i + 3)]
16202     arr[curByte++] = (tmp >> 16) & 0xFF
16203     arr[curByte++] = (tmp >> 8) & 0xFF
16204     arr[curByte++] = tmp & 0xFF
16205   }
16206
16207   if (placeHoldersLen === 2) {
16208     tmp =
16209       (revLookup[b64.charCodeAt(i)] << 2) |
16210       (revLookup[b64.charCodeAt(i + 1)] >> 4)
16211     arr[curByte++] = tmp & 0xFF
16212   }
16213
16214   if (placeHoldersLen === 1) {
16215     tmp =
16216       (revLookup[b64.charCodeAt(i)] << 10) |
16217       (revLookup[b64.charCodeAt(i + 1)] << 4) |
16218       (revLookup[b64.charCodeAt(i + 2)] >> 2)
16219     arr[curByte++] = (tmp >> 8) & 0xFF
16220     arr[curByte++] = tmp & 0xFF
16221   }
16222
16223   return arr
16224 }
16225
16226 function tripletToBase64 (num) {
16227   return lookup[num >> 18 & 0x3F] +
16228     lookup[num >> 12 & 0x3F] +
16229     lookup[num >> 6 & 0x3F] +
16230     lookup[num & 0x3F]
16231 }
16232
16233 function encodeChunk (uint8, start, end) {
16234   var tmp
16235   var output = []
16236   for (var i = start; i < end; i += 3) {
16237     tmp =
16238       ((uint8[i] << 16) & 0xFF0000) +
16239       ((uint8[i + 1] << 8) & 0xFF00) +
16240       (uint8[i + 2] & 0xFF)
16241     output.push(tripletToBase64(tmp))
16242   }
16243   return output.join('')
16244 }
16245
16246 function fromByteArray (uint8) {
16247   var tmp
16248   var len = uint8.length
16249   var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
16250   var parts = []
16251   var maxChunkLength = 16383 // must be multiple of 3
16252
16253   // go through the array every three bytes, we'll deal with trailing stuff later
16254   for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
16255     parts.push(encodeChunk(
16256       uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
16257     ))
16258   }
16259
16260   // pad the end with zeros, but make sure to not forget the extra bytes
16261   if (extraBytes === 1) {
16262     tmp = uint8[len - 1]
16263     parts.push(
16264       lookup[tmp >> 2] +
16265       lookup[(tmp << 4) & 0x3F] +
16266       '=='
16267     )
16268   } else if (extraBytes === 2) {
16269     tmp = (uint8[len - 2] << 8) + uint8[len - 1]
16270     parts.push(
16271       lookup[tmp >> 10] +
16272       lookup[(tmp >> 4) & 0x3F] +
16273       lookup[(tmp << 2) & 0x3F] +
16274       '='
16275     )
16276   }
16277
16278   return parts.join('')
16279 }
16280
16281
16282 /***/ }),
16283 /* 176 */
16284 /***/ (function(module, exports) {
16285
16286 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
16287   var e, m
16288   var eLen = (nBytes * 8) - mLen - 1
16289   var eMax = (1 << eLen) - 1
16290   var eBias = eMax >> 1
16291   var nBits = -7
16292   var i = isLE ? (nBytes - 1) : 0
16293   var d = isLE ? -1 : 1
16294   var s = buffer[offset + i]
16295
16296   i += d
16297
16298   e = s & ((1 << (-nBits)) - 1)
16299   s >>= (-nBits)
16300   nBits += eLen
16301   for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
16302
16303   m = e & ((1 << (-nBits)) - 1)
16304   e >>= (-nBits)
16305   nBits += mLen
16306   for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
16307
16308   if (e === 0) {
16309     e = 1 - eBias
16310   } else if (e === eMax) {
16311     return m ? NaN : ((s ? -1 : 1) * Infinity)
16312   } else {
16313     m = m + Math.pow(2, mLen)
16314     e = e - eBias
16315   }
16316   return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
16317 }
16318
16319 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
16320   var e, m, c
16321   var eLen = (nBytes * 8) - mLen - 1
16322   var eMax = (1 << eLen) - 1
16323   var eBias = eMax >> 1
16324   var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
16325   var i = isLE ? 0 : (nBytes - 1)
16326   var d = isLE ? 1 : -1
16327   var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
16328
16329   value = Math.abs(value)
16330
16331   if (isNaN(value) || value === Infinity) {
16332     m = isNaN(value) ? 1 : 0
16333     e = eMax
16334   } else {
16335     e = Math.floor(Math.log(value) / Math.LN2)
16336     if (value * (c = Math.pow(2, -e)) < 1) {
16337       e--
16338       c *= 2
16339     }
16340     if (e + eBias >= 1) {
16341       value += rt / c
16342     } else {
16343       value += rt * Math.pow(2, 1 - eBias)
16344     }
16345     if (value * c >= 2) {
16346       e++
16347       c /= 2
16348     }
16349
16350     if (e + eBias >= eMax) {
16351       m = 0
16352       e = eMax
16353     } else if (e + eBias >= 1) {
16354       m = ((value * c) - 1) * Math.pow(2, mLen)
16355       e = e + eBias
16356     } else {
16357       m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
16358       e = 0
16359     }
16360   }
16361
16362   for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
16363
16364   e = (e << mLen) | m
16365   eLen += mLen
16366   for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
16367
16368   buffer[offset + i - d] |= s * 128
16369 }
16370
16371
16372 /***/ }),
16373 /* 177 */,
16374 /* 178 */,
16375 /* 179 */
16376 /***/ (function(module, exports, __webpack_require__) {
16377
16378 "use strict";
16379 \r
16380 Object.defineProperty(exports, "__esModule", { value: true });\r
16381 const aes_oop_1 = __webpack_require__(180);\r
16382 class EncryptedStream {\r
16383     constructor(_eventName, _randomized) {\r
16384         this.eventName = _eventName;\r
16385         this.key = _randomized;\r
16386         this.synced = false;\r
16387         this.syncFn = null;\r
16388         this.listenForSync();\r
16389     }\r
16390     listenWith(func) {\r
16391         document.addEventListener(this.eventName, (event) => {\r
16392             if (!this.synced) return false;\r
16393             let msg = JSON.parse(event.detail);\r
16394             msg = (this.synced && typeof msg === 'string') ? aes_oop_1.default.decrypt(msg, this.key) : msg;\r
16395             func(msg);\r
16396         });\r
16397     }\r
16398     send(data, to) {\r
16399         const addSender = () => { data.from = this.eventName; };\r
16400         const encryptIfSynced = () => { data = (this.synced) ? aes_oop_1.default.encrypt(data, this.key) : data; };\r
16401         if (typeof data !== 'object')\r
16402             throw new Error("Payloads must be objects");\r
16403         addSender();\r
16404         encryptIfSynced();\r
16405         this.dispatch(JSON.stringify(data), to);\r
16406     }\r
16407     onSync(fn) {\r
16408         this.syncFn = fn;\r
16409     }\r
16410     sync(to, handshake) {\r
16411         this.send({ type: 'sync', handshake }, to);\r
16412     }\r
16413     listenForSync() {\r
16414         document.addEventListener(this.eventName, (event) => {\r
16415             let msg = JSON.parse(event.detail);\r
16416             if(!msg.hasOwnProperty('type')) return false;\r
16417             if(msg.type === 'sync') this.ackSync(msg);\r
16418             if(msg.type === 'synced') this.synced = true;\r
16419         });\r
16420     }\r
16421     ackSync(msg) {\r
16422         this.send({ type: 'synced' }, msg.from);\r
16423         this.key = msg.handshake;\r
16424         this.synced = true;\r
16425         this.syncFn();\r
16426     }\r
16427     dispatch(encryptedData, to) { document.dispatchEvent(this.getEvent(encryptedData, to)); }\r
16428     getEvent(encryptedData, to) { return new CustomEvent(to, this.getEventInit(encryptedData)); }\r
16429     getEventInit(encryptedData) { return { detail: encryptedData }; }\r
16430 }\r
16431 exports.EncryptedStream = EncryptedStream;\r
16432 exports.default = EncryptedStream;\r
16433 //# sourceMappingURL=EncryptedStream.js.map
16434
16435 /***/ }),
16436 /* 180 */
16437 /***/ (function(module, exports, __webpack_require__) {
16438
16439 "use strict";
16440 \r
16441 const sjcl = __webpack_require__(181);\r
16442 class AES {\r
16443     static encrypt(data, key) {\r
16444         if (typeof data === 'object')\r
16445             data = JSON.stringify(data);\r
16446         const { iv, salt, ct } = JSON.parse(sjcl.encrypt(key, data, { mode: 'gcm' }));\r
16447         return JSON.stringify({ iv, salt, ct });\r
16448     }\r
16449     static decrypt(encryptedData, key) {\r
16450         encryptedData = JSON.stringify(Object.assign(JSON.parse(encryptedData), { mode: 'gcm' }));\r
16451         let clear = sjcl.decrypt(key, encryptedData);\r
16452         try {\r
16453             return JSON.parse(clear);\r
16454         }\r
16455         catch (e) {\r
16456             return clear;\r
16457         }\r
16458     }\r
16459 }\r
16460 exports.AES = AES;\r
16461 Object.defineProperty(exports, "__esModule", { value: true });\r
16462 exports.default = AES;\r
16463 //# sourceMappingURL=AES.js.map
16464
16465 /***/ }),
16466 /* 181 */
16467 /***/ (function(module, exports, __webpack_require__) {
16468
16469 "use strict";
16470 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}}};
16471 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&
16472 255]]};
16473 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=
16474 0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}};
16475 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=
16476 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}
16477 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===
16478 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===
16479 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}};
16480 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}};
16481 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)}};
16482 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,
16483 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}};
16484 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)}};
16485 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));
16486 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()};
16487 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,
16488 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=
16489 !1;break}e&&(8>b&&(this.Y[b]=a(Math.pow(c,.5))),this.b[b]=a(Math.pow(c,1/3)),b++)}}};
16490 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]=
16491 f[7]+q|0}
16492 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,
16493 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");
16494 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");
16495 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/
16496 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)}}};
16497 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))));
16498 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,
16499 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);
16500 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)]}};
16501 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,
16502 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);
16503 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);
16504 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])};
16505 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};
16506 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};
16507 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};
16508 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=
16509 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,
16510 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]&&
16511 (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()))},
16512 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",
16513 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");
16514 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",
16515 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=
16516 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)}};
16517 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)}
16518 function B(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6);
16519 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);
16520 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))}
16521 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||
16522 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&&
16523 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"===
16524 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"===
16525 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+'"'+
16526 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!");
16527 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,
16528 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)}};
16529 "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__),
16530                                 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
16531
16532
16533 /***/ }),
16534 /* 182 */
16535 /***/ (function(module, exports, __webpack_require__) {
16536
16537 "use strict";
16538
16539
16540 exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(23)
16541 exports.createHash = exports.Hash = __webpack_require__(29)
16542 exports.createHmac = exports.Hmac = __webpack_require__(101)
16543
16544 var algos = __webpack_require__(197)
16545 var algoKeys = Object.keys(algos)
16546 var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
16547 exports.getHashes = function () {
16548   return hashes
16549 }
16550
16551 var p = __webpack_require__(104)
16552 exports.pbkdf2 = p.pbkdf2
16553 exports.pbkdf2Sync = p.pbkdf2Sync
16554
16555 var aes = __webpack_require__(199)
16556
16557 exports.Cipher = aes.Cipher
16558 exports.createCipher = aes.createCipher
16559 exports.Cipheriv = aes.Cipheriv
16560 exports.createCipheriv = aes.createCipheriv
16561 exports.Decipher = aes.Decipher
16562 exports.createDecipher = aes.createDecipher
16563 exports.Decipheriv = aes.Decipheriv
16564 exports.createDecipheriv = aes.createDecipheriv
16565 exports.getCiphers = aes.getCiphers
16566 exports.listCiphers = aes.listCiphers
16567
16568 var dh = __webpack_require__(216)
16569
16570 exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
16571 exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
16572 exports.getDiffieHellman = dh.getDiffieHellman
16573 exports.createDiffieHellman = dh.createDiffieHellman
16574 exports.DiffieHellman = dh.DiffieHellman
16575
16576 var sign = __webpack_require__(221)
16577
16578 exports.createSign = sign.createSign
16579 exports.Sign = sign.Sign
16580 exports.createVerify = sign.createVerify
16581 exports.Verify = sign.Verify
16582
16583 exports.createECDH = __webpack_require__(259)
16584
16585 var publicEncrypt = __webpack_require__(260)
16586
16587 exports.publicEncrypt = publicEncrypt.publicEncrypt
16588 exports.privateEncrypt = publicEncrypt.privateEncrypt
16589 exports.publicDecrypt = publicEncrypt.publicDecrypt
16590 exports.privateDecrypt = publicEncrypt.privateDecrypt
16591
16592 // the least I can do is make error messages for the rest of the node.js/crypto api.
16593 // ;[
16594 //   'createCredentials'
16595 // ].forEach(function (name) {
16596 //   exports[name] = function () {
16597 //     throw new Error([
16598 //       'sorry, ' + name + ' is not implemented yet',
16599 //       'we accept pull requests',
16600 //       'https://github.com/crypto-browserify/crypto-browserify'
16601 //     ].join('\n'))
16602 //   }
16603 // })
16604
16605 var rf = __webpack_require__(263)
16606
16607 exports.randomFill = rf.randomFill
16608 exports.randomFillSync = rf.randomFillSync
16609
16610 exports.createCredentials = function () {
16611   throw new Error([
16612     'sorry, createCredentials is not implemented yet',
16613     'we accept pull requests',
16614     'https://github.com/crypto-browserify/crypto-browserify'
16615   ].join('\n'))
16616 }
16617
16618 exports.constants = {
16619   'DH_CHECK_P_NOT_SAFE_PRIME': 2,
16620   'DH_CHECK_P_NOT_PRIME': 1,
16621   'DH_UNABLE_TO_CHECK_GENERATOR': 4,
16622   'DH_NOT_SUITABLE_GENERATOR': 8,
16623   'NPN_ENABLED': 1,
16624   'ALPN_ENABLED': 1,
16625   'RSA_PKCS1_PADDING': 1,
16626   'RSA_SSLV23_PADDING': 2,
16627   'RSA_NO_PADDING': 3,
16628   'RSA_PKCS1_OAEP_PADDING': 4,
16629   'RSA_X931_PADDING': 5,
16630   'RSA_PKCS1_PSS_PADDING': 6,
16631   'POINT_CONVERSION_COMPRESSED': 2,
16632   'POINT_CONVERSION_UNCOMPRESSED': 4,
16633   'POINT_CONVERSION_HYBRID': 6
16634 }
16635
16636
16637 /***/ }),
16638 /* 183 */
16639 /***/ (function(module, exports) {
16640
16641 /* (ignored) */
16642
16643 /***/ }),
16644 /* 184 */
16645 /***/ (function(module, exports, __webpack_require__) {
16646
16647 "use strict";
16648
16649
16650 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16651
16652 var Buffer = __webpack_require__(2).Buffer;
16653 var util = __webpack_require__(185);
16654
16655 function copyBuffer(src, target, offset) {
16656   src.copy(target, offset);
16657 }
16658
16659 module.exports = function () {
16660   function BufferList() {
16661     _classCallCheck(this, BufferList);
16662
16663     this.head = null;
16664     this.tail = null;
16665     this.length = 0;
16666   }
16667
16668   BufferList.prototype.push = function push(v) {
16669     var entry = { data: v, next: null };
16670     if (this.length > 0) this.tail.next = entry;else this.head = entry;
16671     this.tail = entry;
16672     ++this.length;
16673   };
16674
16675   BufferList.prototype.unshift = function unshift(v) {
16676     var entry = { data: v, next: this.head };
16677     if (this.length === 0) this.tail = entry;
16678     this.head = entry;
16679     ++this.length;
16680   };
16681
16682   BufferList.prototype.shift = function shift() {
16683     if (this.length === 0) return;
16684     var ret = this.head.data;
16685     if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
16686     --this.length;
16687     return ret;
16688   };
16689
16690   BufferList.prototype.clear = function clear() {
16691     this.head = this.tail = null;
16692     this.length = 0;
16693   };
16694
16695   BufferList.prototype.join = function join(s) {
16696     if (this.length === 0) return '';
16697     var p = this.head;
16698     var ret = '' + p.data;
16699     while (p = p.next) {
16700       ret += s + p.data;
16701     }return ret;
16702   };
16703
16704   BufferList.prototype.concat = function concat(n) {
16705     if (this.length === 0) return Buffer.alloc(0);
16706     if (this.length === 1) return this.head.data;
16707     var ret = Buffer.allocUnsafe(n >>> 0);
16708     var p = this.head;
16709     var i = 0;
16710     while (p) {
16711       copyBuffer(p.data, ret, i);
16712       i += p.data.length;
16713       p = p.next;
16714     }
16715     return ret;
16716   };
16717
16718   return BufferList;
16719 }();
16720
16721 if (util && util.inspect && util.inspect.custom) {
16722   module.exports.prototype[util.inspect.custom] = function () {
16723     var obj = util.inspect({ length: this.length });
16724     return this.constructor.name + ' ' + obj;
16725   };
16726 }
16727
16728 /***/ }),
16729 /* 185 */
16730 /***/ (function(module, exports) {
16731
16732 /* (ignored) */
16733
16734 /***/ }),
16735 /* 186 */
16736 /***/ (function(module, exports, __webpack_require__) {
16737
16738 /* WEBPACK VAR INJECTION */(function(global) {
16739 /**
16740  * Module exports.
16741  */
16742
16743 module.exports = deprecate;
16744
16745 /**
16746  * Mark that a method should not be used.
16747  * Returns a modified function which warns once by default.
16748  *
16749  * If `localStorage.noDeprecation = true` is set, then it is a no-op.
16750  *
16751  * If `localStorage.throwDeprecation = true` is set, then deprecated functions
16752  * will throw an Error when invoked.
16753  *
16754  * If `localStorage.traceDeprecation = true` is set, then deprecated functions
16755  * will invoke `console.trace()` instead of `console.error()`.
16756  *
16757  * @param {Function} fn - the function to deprecate
16758  * @param {String} msg - the string to print to the console when `fn` is invoked
16759  * @returns {Function} a new "deprecated" version of `fn`
16760  * @api public
16761  */
16762
16763 function deprecate (fn, msg) {
16764   if (config('noDeprecation')) {
16765     return fn;
16766   }
16767
16768   var warned = false;
16769   function deprecated() {
16770     if (!warned) {
16771       if (config('throwDeprecation')) {
16772         throw new Error(msg);
16773       } else if (config('traceDeprecation')) {
16774         console.trace(msg);
16775       } else {
16776         console.warn(msg);
16777       }
16778       warned = true;
16779     }
16780     return fn.apply(this, arguments);
16781   }
16782
16783   return deprecated;
16784 }
16785
16786 /**
16787  * Checks `localStorage` for boolean values for the given `name`.
16788  *
16789  * @param {String} name
16790  * @returns {Boolean}
16791  * @api private
16792  */
16793
16794 function config (name) {
16795   // accessing global.localStorage can trigger a DOMException in sandboxed iframes
16796   try {
16797     if (!global.localStorage) return false;
16798   } catch (_) {
16799     return false;
16800   }
16801   var val = global.localStorage[name];
16802   if (null == val) return false;
16803   return String(val).toLowerCase() === 'true';
16804 }
16805
16806 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
16807
16808 /***/ }),
16809 /* 187 */
16810 /***/ (function(module, exports, __webpack_require__) {
16811
16812 "use strict";
16813 // Copyright Joyent, Inc. and other Node contributors.
16814 //
16815 // Permission is hereby granted, free of charge, to any person obtaining a
16816 // copy of this software and associated documentation files (the
16817 // "Software"), to deal in the Software without restriction, including
16818 // without limitation the rights to use, copy, modify, merge, publish,
16819 // distribute, sublicense, and/or sell copies of the Software, and to permit
16820 // persons to whom the Software is furnished to do so, subject to the
16821 // following conditions:
16822 //
16823 // The above copyright notice and this permission notice shall be included
16824 // in all copies or substantial portions of the Software.
16825 //
16826 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16827 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16828 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16829 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16830 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16831 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16832 // USE OR OTHER DEALINGS IN THE SOFTWARE.
16833
16834 // a passthrough stream.
16835 // basically just the most minimal sort of Transform stream.
16836 // Every written chunk gets output as-is.
16837
16838
16839
16840 module.exports = PassThrough;
16841
16842 var Transform = __webpack_require__(98);
16843
16844 /*<replacement>*/
16845 var util = __webpack_require__(30);
16846 util.inherits = __webpack_require__(1);
16847 /*</replacement>*/
16848
16849 util.inherits(PassThrough, Transform);
16850
16851 function PassThrough(options) {
16852   if (!(this instanceof PassThrough)) return new PassThrough(options);
16853
16854   Transform.call(this, options);
16855 }
16856
16857 PassThrough.prototype._transform = function (chunk, encoding, cb) {
16858   cb(null, chunk);
16859 };
16860
16861 /***/ }),
16862 /* 188 */
16863 /***/ (function(module, exports, __webpack_require__) {
16864
16865 module.exports = __webpack_require__(60);
16866
16867
16868 /***/ }),
16869 /* 189 */
16870 /***/ (function(module, exports, __webpack_require__) {
16871
16872 module.exports = __webpack_require__(21);
16873
16874
16875 /***/ }),
16876 /* 190 */
16877 /***/ (function(module, exports, __webpack_require__) {
16878
16879 module.exports = __webpack_require__(59).Transform
16880
16881
16882 /***/ }),
16883 /* 191 */
16884 /***/ (function(module, exports, __webpack_require__) {
16885
16886 module.exports = __webpack_require__(59).PassThrough
16887
16888
16889 /***/ }),
16890 /* 192 */
16891 /***/ (function(module, exports, __webpack_require__) {
16892
16893 /*
16894  * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
16895  * in FIPS PUB 180-1
16896  * This source code is derived from sha1.js of the same repository.
16897  * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
16898  * operation was added.
16899  */
16900
16901 var inherits = __webpack_require__(1)
16902 var Hash = __webpack_require__(24)
16903 var Buffer = __webpack_require__(2).Buffer
16904
16905 var K = [
16906   0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
16907 ]
16908
16909 var W = new Array(80)
16910
16911 function Sha () {
16912   this.init()
16913   this._w = W
16914
16915   Hash.call(this, 64, 56)
16916 }
16917
16918 inherits(Sha, Hash)
16919
16920 Sha.prototype.init = function () {
16921   this._a = 0x67452301
16922   this._b = 0xefcdab89
16923   this._c = 0x98badcfe
16924   this._d = 0x10325476
16925   this._e = 0xc3d2e1f0
16926
16927   return this
16928 }
16929
16930 function rotl5 (num) {
16931   return (num << 5) | (num >>> 27)
16932 }
16933
16934 function rotl30 (num) {
16935   return (num << 30) | (num >>> 2)
16936 }
16937
16938 function ft (s, b, c, d) {
16939   if (s === 0) return (b & c) | ((~b) & d)
16940   if (s === 2) return (b & c) | (b & d) | (c & d)
16941   return b ^ c ^ d
16942 }
16943
16944 Sha.prototype._update = function (M) {
16945   var W = this._w
16946
16947   var a = this._a | 0
16948   var b = this._b | 0
16949   var c = this._c | 0
16950   var d = this._d | 0
16951   var e = this._e | 0
16952
16953   for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
16954   for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
16955
16956   for (var j = 0; j < 80; ++j) {
16957     var s = ~~(j / 20)
16958     var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
16959
16960     e = d
16961     d = c
16962     c = rotl30(b)
16963     b = a
16964     a = t
16965   }
16966
16967   this._a = (a + this._a) | 0
16968   this._b = (b + this._b) | 0
16969   this._c = (c + this._c) | 0
16970   this._d = (d + this._d) | 0
16971   this._e = (e + this._e) | 0
16972 }
16973
16974 Sha.prototype._hash = function () {
16975   var H = Buffer.allocUnsafe(20)
16976
16977   H.writeInt32BE(this._a | 0, 0)
16978   H.writeInt32BE(this._b | 0, 4)
16979   H.writeInt32BE(this._c | 0, 8)
16980   H.writeInt32BE(this._d | 0, 12)
16981   H.writeInt32BE(this._e | 0, 16)
16982
16983   return H
16984 }
16985
16986 module.exports = Sha
16987
16988
16989 /***/ }),
16990 /* 193 */
16991 /***/ (function(module, exports, __webpack_require__) {
16992
16993 /*
16994  * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
16995  * in FIPS PUB 180-1
16996  * Version 2.1a Copyright Paul Johnston 2000 - 2002.
16997  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
16998  * Distributed under the BSD License
16999  * See http://pajhome.org.uk/crypt/md5 for details.
17000  */
17001
17002 var inherits = __webpack_require__(1)
17003 var Hash = __webpack_require__(24)
17004 var Buffer = __webpack_require__(2).Buffer
17005
17006 var K = [
17007   0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
17008 ]
17009
17010 var W = new Array(80)
17011
17012 function Sha1 () {
17013   this.init()
17014   this._w = W
17015
17016   Hash.call(this, 64, 56)
17017 }
17018
17019 inherits(Sha1, Hash)
17020
17021 Sha1.prototype.init = function () {
17022   this._a = 0x67452301
17023   this._b = 0xefcdab89
17024   this._c = 0x98badcfe
17025   this._d = 0x10325476
17026   this._e = 0xc3d2e1f0
17027
17028   return this
17029 }
17030
17031 function rotl1 (num) {
17032   return (num << 1) | (num >>> 31)
17033 }
17034
17035 function rotl5 (num) {
17036   return (num << 5) | (num >>> 27)
17037 }
17038
17039 function rotl30 (num) {
17040   return (num << 30) | (num >>> 2)
17041 }
17042
17043 function ft (s, b, c, d) {
17044   if (s === 0) return (b & c) | ((~b) & d)
17045   if (s === 2) return (b & c) | (b & d) | (c & d)
17046   return b ^ c ^ d
17047 }
17048
17049 Sha1.prototype._update = function (M) {
17050   var W = this._w
17051
17052   var a = this._a | 0
17053   var b = this._b | 0
17054   var c = this._c | 0
17055   var d = this._d | 0
17056   var e = this._e | 0
17057
17058   for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
17059   for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
17060
17061   for (var j = 0; j < 80; ++j) {
17062     var s = ~~(j / 20)
17063     var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
17064
17065     e = d
17066     d = c
17067     c = rotl30(b)
17068     b = a
17069     a = t
17070   }
17071
17072   this._a = (a + this._a) | 0
17073   this._b = (b + this._b) | 0
17074   this._c = (c + this._c) | 0
17075   this._d = (d + this._d) | 0
17076   this._e = (e + this._e) | 0
17077 }
17078
17079 Sha1.prototype._hash = function () {
17080   var H = Buffer.allocUnsafe(20)
17081
17082   H.writeInt32BE(this._a | 0, 0)
17083   H.writeInt32BE(this._b | 0, 4)
17084   H.writeInt32BE(this._c | 0, 8)
17085   H.writeInt32BE(this._d | 0, 12)
17086   H.writeInt32BE(this._e | 0, 16)
17087
17088   return H
17089 }
17090
17091 module.exports = Sha1
17092
17093
17094 /***/ }),
17095 /* 194 */
17096 /***/ (function(module, exports, __webpack_require__) {
17097
17098 /**
17099  * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
17100  * in FIPS 180-2
17101  * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
17102  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
17103  *
17104  */
17105
17106 var inherits = __webpack_require__(1)
17107 var Sha256 = __webpack_require__(99)
17108 var Hash = __webpack_require__(24)
17109 var Buffer = __webpack_require__(2).Buffer
17110
17111 var W = new Array(64)
17112
17113 function Sha224 () {
17114   this.init()
17115
17116   this._w = W // new Array(64)
17117
17118   Hash.call(this, 64, 56)
17119 }
17120
17121 inherits(Sha224, Sha256)
17122
17123 Sha224.prototype.init = function () {
17124   this._a = 0xc1059ed8
17125   this._b = 0x367cd507
17126   this._c = 0x3070dd17
17127   this._d = 0xf70e5939
17128   this._e = 0xffc00b31
17129   this._f = 0x68581511
17130   this._g = 0x64f98fa7
17131   this._h = 0xbefa4fa4
17132
17133   return this
17134 }
17135
17136 Sha224.prototype._hash = function () {
17137   var H = Buffer.allocUnsafe(28)
17138
17139   H.writeInt32BE(this._a, 0)
17140   H.writeInt32BE(this._b, 4)
17141   H.writeInt32BE(this._c, 8)
17142   H.writeInt32BE(this._d, 12)
17143   H.writeInt32BE(this._e, 16)
17144   H.writeInt32BE(this._f, 20)
17145   H.writeInt32BE(this._g, 24)
17146
17147   return H
17148 }
17149
17150 module.exports = Sha224
17151
17152
17153 /***/ }),
17154 /* 195 */
17155 /***/ (function(module, exports, __webpack_require__) {
17156
17157 var inherits = __webpack_require__(1)
17158 var SHA512 = __webpack_require__(100)
17159 var Hash = __webpack_require__(24)
17160 var Buffer = __webpack_require__(2).Buffer
17161
17162 var W = new Array(160)
17163
17164 function Sha384 () {
17165   this.init()
17166   this._w = W
17167
17168   Hash.call(this, 128, 112)
17169 }
17170
17171 inherits(Sha384, SHA512)
17172
17173 Sha384.prototype.init = function () {
17174   this._ah = 0xcbbb9d5d
17175   this._bh = 0x629a292a
17176   this._ch = 0x9159015a
17177   this._dh = 0x152fecd8
17178   this._eh = 0x67332667
17179   this._fh = 0x8eb44a87
17180   this._gh = 0xdb0c2e0d
17181   this._hh = 0x47b5481d
17182
17183   this._al = 0xc1059ed8
17184   this._bl = 0x367cd507
17185   this._cl = 0x3070dd17
17186   this._dl = 0xf70e5939
17187   this._el = 0xffc00b31
17188   this._fl = 0x68581511
17189   this._gl = 0x64f98fa7
17190   this._hl = 0xbefa4fa4
17191
17192   return this
17193 }
17194
17195 Sha384.prototype._hash = function () {
17196   var H = Buffer.allocUnsafe(48)
17197
17198   function writeInt64BE (h, l, offset) {
17199     H.writeInt32BE(h, offset)
17200     H.writeInt32BE(l, offset + 4)
17201   }
17202
17203   writeInt64BE(this._ah, this._al, 0)
17204   writeInt64BE(this._bh, this._bl, 8)
17205   writeInt64BE(this._ch, this._cl, 16)
17206   writeInt64BE(this._dh, this._dl, 24)
17207   writeInt64BE(this._eh, this._el, 32)
17208   writeInt64BE(this._fh, this._fl, 40)
17209
17210   return H
17211 }
17212
17213 module.exports = Sha384
17214
17215
17216 /***/ }),
17217 /* 196 */
17218 /***/ (function(module, exports, __webpack_require__) {
17219
17220 "use strict";
17221
17222 var inherits = __webpack_require__(1)
17223 var Buffer = __webpack_require__(2).Buffer
17224
17225 var Base = __webpack_require__(18)
17226
17227 var ZEROS = Buffer.alloc(128)
17228 var blocksize = 64
17229
17230 function Hmac (alg, key) {
17231   Base.call(this, 'digest')
17232   if (typeof key === 'string') {
17233     key = Buffer.from(key)
17234   }
17235
17236   this._alg = alg
17237   this._key = key
17238
17239   if (key.length > blocksize) {
17240     key = alg(key)
17241   } else if (key.length < blocksize) {
17242     key = Buffer.concat([key, ZEROS], blocksize)
17243   }
17244
17245   var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
17246   var opad = this._opad = Buffer.allocUnsafe(blocksize)
17247
17248   for (var i = 0; i < blocksize; i++) {
17249     ipad[i] = key[i] ^ 0x36
17250     opad[i] = key[i] ^ 0x5C
17251   }
17252
17253   this._hash = [ipad]
17254 }
17255
17256 inherits(Hmac, Base)
17257
17258 Hmac.prototype._update = function (data) {
17259   this._hash.push(data)
17260 }
17261
17262 Hmac.prototype._final = function () {
17263   var h = this._alg(Buffer.concat(this._hash))
17264   return this._alg(Buffer.concat([this._opad, h]))
17265 }
17266 module.exports = Hmac
17267
17268
17269 /***/ }),
17270 /* 197 */
17271 /***/ (function(module, exports, __webpack_require__) {
17272
17273 module.exports = __webpack_require__(103)
17274
17275
17276 /***/ }),
17277 /* 198 */
17278 /***/ (function(module, exports, __webpack_require__) {
17279
17280 /* WEBPACK VAR INJECTION */(function(global, process) {var checkParameters = __webpack_require__(105)
17281 var defaultEncoding = __webpack_require__(106)
17282 var sync = __webpack_require__(107)
17283 var Buffer = __webpack_require__(2).Buffer
17284
17285 var ZERO_BUF
17286 var subtle = global.crypto && global.crypto.subtle
17287 var toBrowser = {
17288   'sha': 'SHA-1',
17289   'sha-1': 'SHA-1',
17290   'sha1': 'SHA-1',
17291   'sha256': 'SHA-256',
17292   'sha-256': 'SHA-256',
17293   'sha384': 'SHA-384',
17294   'sha-384': 'SHA-384',
17295   'sha-512': 'SHA-512',
17296   'sha512': 'SHA-512'
17297 }
17298 var checks = []
17299 function checkNative (algo) {
17300   if (global.process && !global.process.browser) {
17301     return Promise.resolve(false)
17302   }
17303   if (!subtle || !subtle.importKey || !subtle.deriveBits) {
17304     return Promise.resolve(false)
17305   }
17306   if (checks[algo] !== undefined) {
17307     return checks[algo]
17308   }
17309   ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
17310   var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
17311     .then(function () {
17312       return true
17313     }).catch(function () {
17314       return false
17315     })
17316   checks[algo] = prom
17317   return prom
17318 }
17319
17320 function browserPbkdf2 (password, salt, iterations, length, algo) {
17321   return subtle.importKey(
17322     'raw', password, {name: 'PBKDF2'}, false, ['deriveBits']
17323   ).then(function (key) {
17324     return subtle.deriveBits({
17325       name: 'PBKDF2',
17326       salt: salt,
17327       iterations: iterations,
17328       hash: {
17329         name: algo
17330       }
17331     }, key, length << 3)
17332   }).then(function (res) {
17333     return Buffer.from(res)
17334   })
17335 }
17336
17337 function resolvePromise (promise, callback) {
17338   promise.then(function (out) {
17339     process.nextTick(function () {
17340       callback(null, out)
17341     })
17342   }, function (e) {
17343     process.nextTick(function () {
17344       callback(e)
17345     })
17346   })
17347 }
17348 module.exports = function (password, salt, iterations, keylen, digest, callback) {
17349   if (typeof digest === 'function') {
17350     callback = digest
17351     digest = undefined
17352   }
17353
17354   digest = digest || 'sha1'
17355   var algo = toBrowser[digest.toLowerCase()]
17356
17357   if (!algo || typeof global.Promise !== 'function') {
17358     return process.nextTick(function () {
17359       var out
17360       try {
17361         out = sync(password, salt, iterations, keylen, digest)
17362       } catch (e) {
17363         return callback(e)
17364       }
17365       callback(null, out)
17366     })
17367   }
17368
17369   checkParameters(password, salt, iterations, keylen)
17370   if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
17371   if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
17372   if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
17373
17374   resolvePromise(checkNative(algo).then(function (resp) {
17375     if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)
17376
17377     return sync(password, salt, iterations, keylen, digest)
17378   }), callback)
17379 }
17380
17381 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
17382
17383 /***/ }),
17384 /* 199 */
17385 /***/ (function(module, exports, __webpack_require__) {
17386
17387 var DES = __webpack_require__(200)
17388 var aes = __webpack_require__(65)
17389 var aesModes = __webpack_require__(66)
17390 var desModes = __webpack_require__(215)
17391 var ebtk = __webpack_require__(44)
17392
17393 function createCipher (suite, password) {
17394   suite = suite.toLowerCase()
17395
17396   var keyLen, ivLen
17397   if (aesModes[suite]) {
17398     keyLen = aesModes[suite].key
17399     ivLen = aesModes[suite].iv
17400   } else if (desModes[suite]) {
17401     keyLen = desModes[suite].key * 8
17402     ivLen = desModes[suite].iv
17403   } else {
17404     throw new TypeError('invalid suite type')
17405   }
17406
17407   var keys = ebtk(password, false, keyLen, ivLen)
17408   return createCipheriv(suite, keys.key, keys.iv)
17409 }
17410
17411 function createDecipher (suite, password) {
17412   suite = suite.toLowerCase()
17413
17414   var keyLen, ivLen
17415   if (aesModes[suite]) {
17416     keyLen = aesModes[suite].key
17417     ivLen = aesModes[suite].iv
17418   } else if (desModes[suite]) {
17419     keyLen = desModes[suite].key * 8
17420     ivLen = desModes[suite].iv
17421   } else {
17422     throw new TypeError('invalid suite type')
17423   }
17424
17425   var keys = ebtk(password, false, keyLen, ivLen)
17426   return createDecipheriv(suite, keys.key, keys.iv)
17427 }
17428
17429 function createCipheriv (suite, key, iv) {
17430   suite = suite.toLowerCase()
17431   if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)
17432   if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })
17433
17434   throw new TypeError('invalid suite type')
17435 }
17436
17437 function createDecipheriv (suite, key, iv) {
17438   suite = suite.toLowerCase()
17439   if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
17440   if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
17441
17442   throw new TypeError('invalid suite type')
17443 }
17444
17445 function getCiphers () {
17446   return Object.keys(desModes).concat(aes.getCiphers())
17447 }
17448
17449 exports.createCipher = exports.Cipher = createCipher
17450 exports.createCipheriv = exports.Cipheriv = createCipheriv
17451 exports.createDecipher = exports.Decipher = createDecipher
17452 exports.createDecipheriv = exports.Decipheriv = createDecipheriv
17453 exports.listCiphers = exports.getCiphers = getCiphers
17454
17455
17456 /***/ }),
17457 /* 200 */
17458 /***/ (function(module, exports, __webpack_require__) {
17459
17460 var CipherBase = __webpack_require__(18)
17461 var des = __webpack_require__(64)
17462 var inherits = __webpack_require__(1)
17463 var Buffer = __webpack_require__(2).Buffer
17464
17465 var modes = {
17466   'des-ede3-cbc': des.CBC.instantiate(des.EDE),
17467   'des-ede3': des.EDE,
17468   'des-ede-cbc': des.CBC.instantiate(des.EDE),
17469   'des-ede': des.EDE,
17470   'des-cbc': des.CBC.instantiate(des.DES),
17471   'des-ecb': des.DES
17472 }
17473 modes.des = modes['des-cbc']
17474 modes.des3 = modes['des-ede3-cbc']
17475 module.exports = DES
17476 inherits(DES, CipherBase)
17477 function DES (opts) {
17478   CipherBase.call(this)
17479   var modeName = opts.mode.toLowerCase()
17480   var mode = modes[modeName]
17481   var type
17482   if (opts.decrypt) {
17483     type = 'decrypt'
17484   } else {
17485     type = 'encrypt'
17486   }
17487   var key = opts.key
17488   if (!Buffer.isBuffer(key)) {
17489     key = Buffer.from(key)
17490   }
17491   if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
17492     key = Buffer.concat([key, key.slice(0, 8)])
17493   }
17494   var iv = opts.iv
17495   if (!Buffer.isBuffer(iv)) {
17496     iv = Buffer.from(iv)
17497   }
17498   this._des = mode.create({
17499     key: key,
17500     iv: iv,
17501     type: type
17502   })
17503 }
17504 DES.prototype._update = function (data) {
17505   return Buffer.from(this._des.update(data))
17506 }
17507 DES.prototype._final = function () {
17508   return Buffer.from(this._des.final())
17509 }
17510
17511
17512 /***/ }),
17513 /* 201 */
17514 /***/ (function(module, exports, __webpack_require__) {
17515
17516 "use strict";
17517
17518
17519 exports.readUInt32BE = function readUInt32BE(bytes, off) {
17520   var res =  (bytes[0 + off] << 24) |
17521              (bytes[1 + off] << 16) |
17522              (bytes[2 + off] << 8) |
17523              bytes[3 + off];
17524   return res >>> 0;
17525 };
17526
17527 exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
17528   bytes[0 + off] = value >>> 24;
17529   bytes[1 + off] = (value >>> 16) & 0xff;
17530   bytes[2 + off] = (value >>> 8) & 0xff;
17531   bytes[3 + off] = value & 0xff;
17532 };
17533
17534 exports.ip = function ip(inL, inR, out, off) {
17535   var outL = 0;
17536   var outR = 0;
17537
17538   for (var i = 6; i >= 0; i -= 2) {
17539     for (var j = 0; j <= 24; j += 8) {
17540       outL <<= 1;
17541       outL |= (inR >>> (j + i)) & 1;
17542     }
17543     for (var j = 0; j <= 24; j += 8) {
17544       outL <<= 1;
17545       outL |= (inL >>> (j + i)) & 1;
17546     }
17547   }
17548
17549   for (var i = 6; i >= 0; i -= 2) {
17550     for (var j = 1; j <= 25; j += 8) {
17551       outR <<= 1;
17552       outR |= (inR >>> (j + i)) & 1;
17553     }
17554     for (var j = 1; j <= 25; j += 8) {
17555       outR <<= 1;
17556       outR |= (inL >>> (j + i)) & 1;
17557     }
17558   }
17559
17560   out[off + 0] = outL >>> 0;
17561   out[off + 1] = outR >>> 0;
17562 };
17563
17564 exports.rip = function rip(inL, inR, out, off) {
17565   var outL = 0;
17566   var outR = 0;
17567
17568   for (var i = 0; i < 4; i++) {
17569     for (var j = 24; j >= 0; j -= 8) {
17570       outL <<= 1;
17571       outL |= (inR >>> (j + i)) & 1;
17572       outL <<= 1;
17573       outL |= (inL >>> (j + i)) & 1;
17574     }
17575   }
17576   for (var i = 4; i < 8; i++) {
17577     for (var j = 24; j >= 0; j -= 8) {
17578       outR <<= 1;
17579       outR |= (inR >>> (j + i)) & 1;
17580       outR <<= 1;
17581       outR |= (inL >>> (j + i)) & 1;
17582     }
17583   }
17584
17585   out[off + 0] = outL >>> 0;
17586   out[off + 1] = outR >>> 0;
17587 };
17588
17589 exports.pc1 = function pc1(inL, inR, out, off) {
17590   var outL = 0;
17591   var outR = 0;
17592
17593   // 7, 15, 23, 31, 39, 47, 55, 63
17594   // 6, 14, 22, 30, 39, 47, 55, 63
17595   // 5, 13, 21, 29, 39, 47, 55, 63
17596   // 4, 12, 20, 28
17597   for (var i = 7; i >= 5; i--) {
17598     for (var j = 0; j <= 24; j += 8) {
17599       outL <<= 1;
17600       outL |= (inR >> (j + i)) & 1;
17601     }
17602     for (var j = 0; j <= 24; j += 8) {
17603       outL <<= 1;
17604       outL |= (inL >> (j + i)) & 1;
17605     }
17606   }
17607   for (var j = 0; j <= 24; j += 8) {
17608     outL <<= 1;
17609     outL |= (inR >> (j + i)) & 1;
17610   }
17611
17612   // 1, 9, 17, 25, 33, 41, 49, 57
17613   // 2, 10, 18, 26, 34, 42, 50, 58
17614   // 3, 11, 19, 27, 35, 43, 51, 59
17615   // 36, 44, 52, 60
17616   for (var i = 1; i <= 3; i++) {
17617     for (var j = 0; j <= 24; j += 8) {
17618       outR <<= 1;
17619       outR |= (inR >> (j + i)) & 1;
17620     }
17621     for (var j = 0; j <= 24; j += 8) {
17622       outR <<= 1;
17623       outR |= (inL >> (j + i)) & 1;
17624     }
17625   }
17626   for (var j = 0; j <= 24; j += 8) {
17627     outR <<= 1;
17628     outR |= (inL >> (j + i)) & 1;
17629   }
17630
17631   out[off + 0] = outL >>> 0;
17632   out[off + 1] = outR >>> 0;
17633 };
17634
17635 exports.r28shl = function r28shl(num, shift) {
17636   return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
17637 };
17638
17639 var pc2table = [
17640   // inL => outL
17641   14, 11, 17, 4, 27, 23, 25, 0,
17642   13, 22, 7, 18, 5, 9, 16, 24,
17643   2, 20, 12, 21, 1, 8, 15, 26,
17644
17645   // inR => outR
17646   15, 4, 25, 19, 9, 1, 26, 16,
17647   5, 11, 23, 8, 12, 7, 17, 0,
17648   22, 3, 10, 14, 6, 20, 27, 24
17649 ];
17650
17651 exports.pc2 = function pc2(inL, inR, out, off) {
17652   var outL = 0;
17653   var outR = 0;
17654
17655   var len = pc2table.length >>> 1;
17656   for (var i = 0; i < len; i++) {
17657     outL <<= 1;
17658     outL |= (inL >>> pc2table[i]) & 0x1;
17659   }
17660   for (var i = len; i < pc2table.length; i++) {
17661     outR <<= 1;
17662     outR |= (inR >>> pc2table[i]) & 0x1;
17663   }
17664
17665   out[off + 0] = outL >>> 0;
17666   out[off + 1] = outR >>> 0;
17667 };
17668
17669 exports.expand = function expand(r, out, off) {
17670   var outL = 0;
17671   var outR = 0;
17672
17673   outL = ((r & 1) << 5) | (r >>> 27);
17674   for (var i = 23; i >= 15; i -= 4) {
17675     outL <<= 6;
17676     outL |= (r >>> i) & 0x3f;
17677   }
17678   for (var i = 11; i >= 3; i -= 4) {
17679     outR |= (r >>> i) & 0x3f;
17680     outR <<= 6;
17681   }
17682   outR |= ((r & 0x1f) << 1) | (r >>> 31);
17683
17684   out[off + 0] = outL >>> 0;
17685   out[off + 1] = outR >>> 0;
17686 };
17687
17688 var sTable = [
17689   14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
17690   3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
17691   4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
17692   15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
17693
17694   15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
17695   9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
17696   0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
17697   5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
17698
17699   10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
17700   1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
17701   13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
17702   11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
17703
17704   7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
17705   1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
17706   10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
17707   15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
17708
17709   2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
17710   8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
17711   4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
17712   15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
17713
17714   12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
17715   0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
17716   9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
17717   7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
17718
17719   4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
17720   3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
17721   1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
17722   10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
17723
17724   13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
17725   10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
17726   7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
17727   0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
17728 ];
17729
17730 exports.substitute = function substitute(inL, inR) {
17731   var out = 0;
17732   for (var i = 0; i < 4; i++) {
17733     var b = (inL >>> (18 - i * 6)) & 0x3f;
17734     var sb = sTable[i * 0x40 + b];
17735
17736     out <<= 4;
17737     out |= sb;
17738   }
17739   for (var i = 0; i < 4; i++) {
17740     var b = (inR >>> (18 - i * 6)) & 0x3f;
17741     var sb = sTable[4 * 0x40 + i * 0x40 + b];
17742
17743     out <<= 4;
17744     out |= sb;
17745   }
17746   return out >>> 0;
17747 };
17748
17749 var permuteTable = [
17750   16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
17751   30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
17752 ];
17753
17754 exports.permute = function permute(num) {
17755   var out = 0;
17756   for (var i = 0; i < permuteTable.length; i++) {
17757     out <<= 1;
17758     out |= (num >>> permuteTable[i]) & 0x1;
17759   }
17760   return out >>> 0;
17761 };
17762
17763 exports.padSplit = function padSplit(num, size, group) {
17764   var str = num.toString(2);
17765   while (str.length < size)
17766     str = '0' + str;
17767
17768   var out = [];
17769   for (var i = 0; i < size; i += group)
17770     out.push(str.slice(i, i + group));
17771   return out.join(' ');
17772 };
17773
17774
17775 /***/ }),
17776 /* 202 */
17777 /***/ (function(module, exports, __webpack_require__) {
17778
17779 "use strict";
17780
17781
17782 var assert = __webpack_require__(9);
17783
17784 function Cipher(options) {
17785   this.options = options;
17786
17787   this.type = this.options.type;
17788   this.blockSize = 8;
17789   this._init();
17790
17791   this.buffer = new Array(this.blockSize);
17792   this.bufferOff = 0;
17793 }
17794 module.exports = Cipher;
17795
17796 Cipher.prototype._init = function _init() {
17797   // Might be overrided
17798 };
17799
17800 Cipher.prototype.update = function update(data) {
17801   if (data.length === 0)
17802     return [];
17803
17804   if (this.type === 'decrypt')
17805     return this._updateDecrypt(data);
17806   else
17807     return this._updateEncrypt(data);
17808 };
17809
17810 Cipher.prototype._buffer = function _buffer(data, off) {
17811   // Append data to buffer
17812   var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
17813   for (var i = 0; i < min; i++)
17814     this.buffer[this.bufferOff + i] = data[off + i];
17815   this.bufferOff += min;
17816
17817   // Shift next
17818   return min;
17819 };
17820
17821 Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
17822   this._update(this.buffer, 0, out, off);
17823   this.bufferOff = 0;
17824   return this.blockSize;
17825 };
17826
17827 Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
17828   var inputOff = 0;
17829   var outputOff = 0;
17830
17831   var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
17832   var out = new Array(count * this.blockSize);
17833
17834   if (this.bufferOff !== 0) {
17835     inputOff += this._buffer(data, inputOff);
17836
17837     if (this.bufferOff === this.buffer.length)
17838       outputOff += this._flushBuffer(out, outputOff);
17839   }
17840
17841   // Write blocks
17842   var max = data.length - ((data.length - inputOff) % this.blockSize);
17843   for (; inputOff < max; inputOff += this.blockSize) {
17844     this._update(data, inputOff, out, outputOff);
17845     outputOff += this.blockSize;
17846   }
17847
17848   // Queue rest
17849   for (; inputOff < data.length; inputOff++, this.bufferOff++)
17850     this.buffer[this.bufferOff] = data[inputOff];
17851
17852   return out;
17853 };
17854
17855 Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
17856   var inputOff = 0;
17857   var outputOff = 0;
17858
17859   var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
17860   var out = new Array(count * this.blockSize);
17861
17862   // TODO(indutny): optimize it, this is far from optimal
17863   for (; count > 0; count--) {
17864     inputOff += this._buffer(data, inputOff);
17865     outputOff += this._flushBuffer(out, outputOff);
17866   }
17867
17868   // Buffer rest of the input
17869   inputOff += this._buffer(data, inputOff);
17870
17871   return out;
17872 };
17873
17874 Cipher.prototype.final = function final(buffer) {
17875   var first;
17876   if (buffer)
17877     first = this.update(buffer);
17878
17879   var last;
17880   if (this.type === 'encrypt')
17881     last = this._finalEncrypt();
17882   else
17883     last = this._finalDecrypt();
17884
17885   if (first)
17886     return first.concat(last);
17887   else
17888     return last;
17889 };
17890
17891 Cipher.prototype._pad = function _pad(buffer, off) {
17892   if (off === 0)
17893     return false;
17894
17895   while (off < buffer.length)
17896     buffer[off++] = 0;
17897
17898   return true;
17899 };
17900
17901 Cipher.prototype._finalEncrypt = function _finalEncrypt() {
17902   if (!this._pad(this.buffer, this.bufferOff))
17903     return [];
17904
17905   var out = new Array(this.blockSize);
17906   this._update(this.buffer, 0, out, 0);
17907   return out;
17908 };
17909
17910 Cipher.prototype._unpad = function _unpad(buffer) {
17911   return buffer;
17912 };
17913
17914 Cipher.prototype._finalDecrypt = function _finalDecrypt() {
17915   assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
17916   var out = new Array(this.blockSize);
17917   this._flushBuffer(out, 0);
17918
17919   return this._unpad(out);
17920 };
17921
17922
17923 /***/ }),
17924 /* 203 */
17925 /***/ (function(module, exports, __webpack_require__) {
17926
17927 "use strict";
17928
17929
17930 var assert = __webpack_require__(9);
17931 var inherits = __webpack_require__(1);
17932
17933 var des = __webpack_require__(64);
17934 var utils = des.utils;
17935 var Cipher = des.Cipher;
17936
17937 function DESState() {
17938   this.tmp = new Array(2);
17939   this.keys = null;
17940 }
17941
17942 function DES(options) {
17943   Cipher.call(this, options);
17944
17945   var state = new DESState();
17946   this._desState = state;
17947
17948   this.deriveKeys(state, options.key);
17949 }
17950 inherits(DES, Cipher);
17951 module.exports = DES;
17952
17953 DES.create = function create(options) {
17954   return new DES(options);
17955 };
17956
17957 var shiftTable = [
17958   1, 1, 2, 2, 2, 2, 2, 2,
17959   1, 2, 2, 2, 2, 2, 2, 1
17960 ];
17961
17962 DES.prototype.deriveKeys = function deriveKeys(state, key) {
17963   state.keys = new Array(16 * 2);
17964
17965   assert.equal(key.length, this.blockSize, 'Invalid key length');
17966
17967   var kL = utils.readUInt32BE(key, 0);
17968   var kR = utils.readUInt32BE(key, 4);
17969
17970   utils.pc1(kL, kR, state.tmp, 0);
17971   kL = state.tmp[0];
17972   kR = state.tmp[1];
17973   for (var i = 0; i < state.keys.length; i += 2) {
17974     var shift = shiftTable[i >>> 1];
17975     kL = utils.r28shl(kL, shift);
17976     kR = utils.r28shl(kR, shift);
17977     utils.pc2(kL, kR, state.keys, i);
17978   }
17979 };
17980
17981 DES.prototype._update = function _update(inp, inOff, out, outOff) {
17982   var state = this._desState;
17983
17984   var l = utils.readUInt32BE(inp, inOff);
17985   var r = utils.readUInt32BE(inp, inOff + 4);
17986
17987   // Initial Permutation
17988   utils.ip(l, r, state.tmp, 0);
17989   l = state.tmp[0];
17990   r = state.tmp[1];
17991
17992   if (this.type === 'encrypt')
17993     this._encrypt(state, l, r, state.tmp, 0);
17994   else
17995     this._decrypt(state, l, r, state.tmp, 0);
17996
17997   l = state.tmp[0];
17998   r = state.tmp[1];
17999
18000   utils.writeUInt32BE(out, l, outOff);
18001   utils.writeUInt32BE(out, r, outOff + 4);
18002 };
18003
18004 DES.prototype._pad = function _pad(buffer, off) {
18005   var value = buffer.length - off;
18006   for (var i = off; i < buffer.length; i++)
18007     buffer[i] = value;
18008
18009   return true;
18010 };
18011
18012 DES.prototype._unpad = function _unpad(buffer) {
18013   var pad = buffer[buffer.length - 1];
18014   for (var i = buffer.length - pad; i < buffer.length; i++)
18015     assert.equal(buffer[i], pad);
18016
18017   return buffer.slice(0, buffer.length - pad);
18018 };
18019
18020 DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
18021   var l = lStart;
18022   var r = rStart;
18023
18024   // Apply f() x16 times
18025   for (var i = 0; i < state.keys.length; i += 2) {
18026     var keyL = state.keys[i];
18027     var keyR = state.keys[i + 1];
18028
18029     // f(r, k)
18030     utils.expand(r, state.tmp, 0);
18031
18032     keyL ^= state.tmp[0];
18033     keyR ^= state.tmp[1];
18034     var s = utils.substitute(keyL, keyR);
18035     var f = utils.permute(s);
18036
18037     var t = r;
18038     r = (l ^ f) >>> 0;
18039     l = t;
18040   }
18041
18042   // Reverse Initial Permutation
18043   utils.rip(r, l, out, off);
18044 };
18045
18046 DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
18047   var l = rStart;
18048   var r = lStart;
18049
18050   // Apply f() x16 times
18051   for (var i = state.keys.length - 2; i >= 0; i -= 2) {
18052     var keyL = state.keys[i];
18053     var keyR = state.keys[i + 1];
18054
18055     // f(r, k)
18056     utils.expand(l, state.tmp, 0);
18057
18058     keyL ^= state.tmp[0];
18059     keyR ^= state.tmp[1];
18060     var s = utils.substitute(keyL, keyR);
18061     var f = utils.permute(s);
18062
18063     var t = l;
18064     l = (r ^ f) >>> 0;
18065     r = t;
18066   }
18067
18068   // Reverse Initial Permutation
18069   utils.rip(l, r, out, off);
18070 };
18071
18072
18073 /***/ }),
18074 /* 204 */
18075 /***/ (function(module, exports, __webpack_require__) {
18076
18077 "use strict";
18078
18079
18080 var assert = __webpack_require__(9);
18081 var inherits = __webpack_require__(1);
18082
18083 var proto = {};
18084
18085 function CBCState(iv) {
18086   assert.equal(iv.length, 8, 'Invalid IV length');
18087
18088   this.iv = new Array(8);
18089   for (var i = 0; i < this.iv.length; i++)
18090     this.iv[i] = iv[i];
18091 }
18092
18093 function instantiate(Base) {
18094   function CBC(options) {
18095     Base.call(this, options);
18096     this._cbcInit();
18097   }
18098   inherits(CBC, Base);
18099
18100   var keys = Object.keys(proto);
18101   for (var i = 0; i < keys.length; i++) {
18102     var key = keys[i];
18103     CBC.prototype[key] = proto[key];
18104   }
18105
18106   CBC.create = function create(options) {
18107     return new CBC(options);
18108   };
18109
18110   return CBC;
18111 }
18112
18113 exports.instantiate = instantiate;
18114
18115 proto._cbcInit = function _cbcInit() {
18116   var state = new CBCState(this.options.iv);
18117   this._cbcState = state;
18118 };
18119
18120 proto._update = function _update(inp, inOff, out, outOff) {
18121   var state = this._cbcState;
18122   var superProto = this.constructor.super_.prototype;
18123
18124   var iv = state.iv;
18125   if (this.type === 'encrypt') {
18126     for (var i = 0; i < this.blockSize; i++)
18127       iv[i] ^= inp[inOff + i];
18128
18129     superProto._update.call(this, iv, 0, out, outOff);
18130
18131     for (var i = 0; i < this.blockSize; i++)
18132       iv[i] = out[outOff + i];
18133   } else {
18134     superProto._update.call(this, inp, inOff, out, outOff);
18135
18136     for (var i = 0; i < this.blockSize; i++)
18137       out[outOff + i] ^= iv[i];
18138
18139     for (var i = 0; i < this.blockSize; i++)
18140       iv[i] = inp[inOff + i];
18141   }
18142 };
18143
18144
18145 /***/ }),
18146 /* 205 */
18147 /***/ (function(module, exports, __webpack_require__) {
18148
18149 "use strict";
18150
18151
18152 var assert = __webpack_require__(9);
18153 var inherits = __webpack_require__(1);
18154
18155 var des = __webpack_require__(64);
18156 var Cipher = des.Cipher;
18157 var DES = des.DES;
18158
18159 function EDEState(type, key) {
18160   assert.equal(key.length, 24, 'Invalid key length');
18161
18162   var k1 = key.slice(0, 8);
18163   var k2 = key.slice(8, 16);
18164   var k3 = key.slice(16, 24);
18165
18166   if (type === 'encrypt') {
18167     this.ciphers = [
18168       DES.create({ type: 'encrypt', key: k1 }),
18169       DES.create({ type: 'decrypt', key: k2 }),
18170       DES.create({ type: 'encrypt', key: k3 })
18171     ];
18172   } else {
18173     this.ciphers = [
18174       DES.create({ type: 'decrypt', key: k3 }),
18175       DES.create({ type: 'encrypt', key: k2 }),
18176       DES.create({ type: 'decrypt', key: k1 })
18177     ];
18178   }
18179 }
18180
18181 function EDE(options) {
18182   Cipher.call(this, options);
18183
18184   var state = new EDEState(this.type, this.options.key);
18185   this._edeState = state;
18186 }
18187 inherits(EDE, Cipher);
18188
18189 module.exports = EDE;
18190
18191 EDE.create = function create(options) {
18192   return new EDE(options);
18193 };
18194
18195 EDE.prototype._update = function _update(inp, inOff, out, outOff) {
18196   var state = this._edeState;
18197
18198   state.ciphers[0]._update(inp, inOff, out, outOff);
18199   state.ciphers[1]._update(out, outOff, out, outOff);
18200   state.ciphers[2]._update(out, outOff, out, outOff);
18201 };
18202
18203 EDE.prototype._pad = DES.prototype._pad;
18204 EDE.prototype._unpad = DES.prototype._unpad;
18205
18206
18207 /***/ }),
18208 /* 206 */
18209 /***/ (function(module, exports, __webpack_require__) {
18210
18211 var MODES = __webpack_require__(66)
18212 var AuthCipher = __webpack_require__(111)
18213 var Buffer = __webpack_require__(2).Buffer
18214 var StreamCipher = __webpack_require__(112)
18215 var Transform = __webpack_require__(18)
18216 var aes = __webpack_require__(43)
18217 var ebtk = __webpack_require__(44)
18218 var inherits = __webpack_require__(1)
18219
18220 function Cipher (mode, key, iv) {
18221   Transform.call(this)
18222
18223   this._cache = new Splitter()
18224   this._cipher = new aes.AES(key)
18225   this._prev = Buffer.from(iv)
18226   this._mode = mode
18227   this._autopadding = true
18228 }
18229
18230 inherits(Cipher, Transform)
18231
18232 Cipher.prototype._update = function (data) {
18233   this._cache.add(data)
18234   var chunk
18235   var thing
18236   var out = []
18237
18238   while ((chunk = this._cache.get())) {
18239     thing = this._mode.encrypt(this, chunk)
18240     out.push(thing)
18241   }
18242
18243   return Buffer.concat(out)
18244 }
18245
18246 var PADDING = Buffer.alloc(16, 0x10)
18247
18248 Cipher.prototype._final = function () {
18249   var chunk = this._cache.flush()
18250   if (this._autopadding) {
18251     chunk = this._mode.encrypt(this, chunk)
18252     this._cipher.scrub()
18253     return chunk
18254   }
18255
18256   if (!chunk.equals(PADDING)) {
18257     this._cipher.scrub()
18258     throw new Error('data not multiple of block length')
18259   }
18260 }
18261
18262 Cipher.prototype.setAutoPadding = function (setTo) {
18263   this._autopadding = !!setTo
18264   return this
18265 }
18266
18267 function Splitter () {
18268   this.cache = Buffer.allocUnsafe(0)
18269 }
18270
18271 Splitter.prototype.add = function (data) {
18272   this.cache = Buffer.concat([this.cache, data])
18273 }
18274
18275 Splitter.prototype.get = function () {
18276   if (this.cache.length > 15) {
18277     var out = this.cache.slice(0, 16)
18278     this.cache = this.cache.slice(16)
18279     return out
18280   }
18281   return null
18282 }
18283
18284 Splitter.prototype.flush = function () {
18285   var len = 16 - this.cache.length
18286   var padBuff = Buffer.allocUnsafe(len)
18287
18288   var i = -1
18289   while (++i < len) {
18290     padBuff.writeUInt8(len, i)
18291   }
18292
18293   return Buffer.concat([this.cache, padBuff])
18294 }
18295
18296 function createCipheriv (suite, password, iv) {
18297   var config = MODES[suite.toLowerCase()]
18298   if (!config) throw new TypeError('invalid suite type')
18299
18300   if (typeof password === 'string') password = Buffer.from(password)
18301   if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
18302
18303   if (typeof iv === 'string') iv = Buffer.from(iv)
18304   if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
18305
18306   if (config.type === 'stream') {
18307     return new StreamCipher(config.module, password, iv)
18308   } else if (config.type === 'auth') {
18309     return new AuthCipher(config.module, password, iv)
18310   }
18311
18312   return new Cipher(config.module, password, iv)
18313 }
18314
18315 function createCipher (suite, password) {
18316   var config = MODES[suite.toLowerCase()]
18317   if (!config) throw new TypeError('invalid suite type')
18318
18319   var keys = ebtk(password, false, config.key, config.iv)
18320   return createCipheriv(suite, keys.key, keys.iv)
18321 }
18322
18323 exports.createCipheriv = createCipheriv
18324 exports.createCipher = createCipher
18325
18326
18327 /***/ }),
18328 /* 207 */
18329 /***/ (function(module, exports) {
18330
18331 exports.encrypt = function (self, block) {
18332   return self._cipher.encryptBlock(block)
18333 }
18334
18335 exports.decrypt = function (self, block) {
18336   return self._cipher.decryptBlock(block)
18337 }
18338
18339
18340 /***/ }),
18341 /* 208 */
18342 /***/ (function(module, exports, __webpack_require__) {
18343
18344 var xor = __webpack_require__(31)
18345
18346 exports.encrypt = function (self, block) {
18347   var data = xor(block, self._prev)
18348
18349   self._prev = self._cipher.encryptBlock(data)
18350   return self._prev
18351 }
18352
18353 exports.decrypt = function (self, block) {
18354   var pad = self._prev
18355
18356   self._prev = block
18357   var out = self._cipher.decryptBlock(block)
18358
18359   return xor(out, pad)
18360 }
18361
18362
18363 /***/ }),
18364 /* 209 */
18365 /***/ (function(module, exports, __webpack_require__) {
18366
18367 var Buffer = __webpack_require__(2).Buffer
18368 var xor = __webpack_require__(31)
18369
18370 function encryptStart (self, data, decrypt) {
18371   var len = data.length
18372   var out = xor(data, self._cache)
18373   self._cache = self._cache.slice(len)
18374   self._prev = Buffer.concat([self._prev, decrypt ? data : out])
18375   return out
18376 }
18377
18378 exports.encrypt = function (self, data, decrypt) {
18379   var out = Buffer.allocUnsafe(0)
18380   var len
18381
18382   while (data.length) {
18383     if (self._cache.length === 0) {
18384       self._cache = self._cipher.encryptBlock(self._prev)
18385       self._prev = Buffer.allocUnsafe(0)
18386     }
18387
18388     if (self._cache.length <= data.length) {
18389       len = self._cache.length
18390       out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
18391       data = data.slice(len)
18392     } else {
18393       out = Buffer.concat([out, encryptStart(self, data, decrypt)])
18394       break
18395     }
18396   }
18397
18398   return out
18399 }
18400
18401
18402 /***/ }),
18403 /* 210 */
18404 /***/ (function(module, exports, __webpack_require__) {
18405
18406 var Buffer = __webpack_require__(2).Buffer
18407
18408 function encryptByte (self, byteParam, decrypt) {
18409   var pad = self._cipher.encryptBlock(self._prev)
18410   var out = pad[0] ^ byteParam
18411
18412   self._prev = Buffer.concat([
18413     self._prev.slice(1),
18414     Buffer.from([decrypt ? byteParam : out])
18415   ])
18416
18417   return out
18418 }
18419
18420 exports.encrypt = function (self, chunk, decrypt) {
18421   var len = chunk.length
18422   var out = Buffer.allocUnsafe(len)
18423   var i = -1
18424
18425   while (++i < len) {
18426     out[i] = encryptByte(self, chunk[i], decrypt)
18427   }
18428
18429   return out
18430 }
18431
18432
18433 /***/ }),
18434 /* 211 */
18435 /***/ (function(module, exports, __webpack_require__) {
18436
18437 var Buffer = __webpack_require__(2).Buffer
18438
18439 function encryptByte (self, byteParam, decrypt) {
18440   var pad
18441   var i = -1
18442   var len = 8
18443   var out = 0
18444   var bit, value
18445   while (++i < len) {
18446     pad = self._cipher.encryptBlock(self._prev)
18447     bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
18448     value = pad[0] ^ bit
18449     out += ((value & 0x80) >> (i % 8))
18450     self._prev = shiftIn(self._prev, decrypt ? bit : value)
18451   }
18452   return out
18453 }
18454
18455 function shiftIn (buffer, value) {
18456   var len = buffer.length
18457   var i = -1
18458   var out = Buffer.allocUnsafe(buffer.length)
18459   buffer = Buffer.concat([buffer, Buffer.from([value])])
18460
18461   while (++i < len) {
18462     out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
18463   }
18464
18465   return out
18466 }
18467
18468 exports.encrypt = function (self, chunk, decrypt) {
18469   var len = chunk.length
18470   var out = Buffer.allocUnsafe(len)
18471   var i = -1
18472
18473   while (++i < len) {
18474     out[i] = encryptByte(self, chunk[i], decrypt)
18475   }
18476
18477   return out
18478 }
18479
18480
18481 /***/ }),
18482 /* 212 */
18483 /***/ (function(module, exports, __webpack_require__) {
18484
18485 /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(31)
18486
18487 function getBlock (self) {
18488   self._prev = self._cipher.encryptBlock(self._prev)
18489   return self._prev
18490 }
18491
18492 exports.encrypt = function (self, chunk) {
18493   while (self._cache.length < chunk.length) {
18494     self._cache = Buffer.concat([self._cache, getBlock(self)])
18495   }
18496
18497   var pad = self._cache.slice(0, chunk.length)
18498   self._cache = self._cache.slice(chunk.length)
18499   return xor(chunk, pad)
18500 }
18501
18502 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
18503
18504 /***/ }),
18505 /* 213 */
18506 /***/ (function(module, exports, __webpack_require__) {
18507
18508 var Buffer = __webpack_require__(2).Buffer
18509 var ZEROES = Buffer.alloc(16, 0)
18510
18511 function toArray (buf) {
18512   return [
18513     buf.readUInt32BE(0),
18514     buf.readUInt32BE(4),
18515     buf.readUInt32BE(8),
18516     buf.readUInt32BE(12)
18517   ]
18518 }
18519
18520 function fromArray (out) {
18521   var buf = Buffer.allocUnsafe(16)
18522   buf.writeUInt32BE(out[0] >>> 0, 0)
18523   buf.writeUInt32BE(out[1] >>> 0, 4)
18524   buf.writeUInt32BE(out[2] >>> 0, 8)
18525   buf.writeUInt32BE(out[3] >>> 0, 12)
18526   return buf
18527 }
18528
18529 function GHASH (key) {
18530   this.h = key
18531   this.state = Buffer.alloc(16, 0)
18532   this.cache = Buffer.allocUnsafe(0)
18533 }
18534
18535 // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
18536 // by Juho Vähä-Herttua
18537 GHASH.prototype.ghash = function (block) {
18538   var i = -1
18539   while (++i < block.length) {
18540     this.state[i] ^= block[i]
18541   }
18542   this._multiply()
18543 }
18544
18545 GHASH.prototype._multiply = function () {
18546   var Vi = toArray(this.h)
18547   var Zi = [0, 0, 0, 0]
18548   var j, xi, lsbVi
18549   var i = -1
18550   while (++i < 128) {
18551     xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
18552     if (xi) {
18553       // Z_i+1 = Z_i ^ V_i
18554       Zi[0] ^= Vi[0]
18555       Zi[1] ^= Vi[1]
18556       Zi[2] ^= Vi[2]
18557       Zi[3] ^= Vi[3]
18558     }
18559
18560     // Store the value of LSB(V_i)
18561     lsbVi = (Vi[3] & 1) !== 0
18562
18563     // V_i+1 = V_i >> 1
18564     for (j = 3; j > 0; j--) {
18565       Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
18566     }
18567     Vi[0] = Vi[0] >>> 1
18568
18569     // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
18570     if (lsbVi) {
18571       Vi[0] = Vi[0] ^ (0xe1 << 24)
18572     }
18573   }
18574   this.state = fromArray(Zi)
18575 }
18576
18577 GHASH.prototype.update = function (buf) {
18578   this.cache = Buffer.concat([this.cache, buf])
18579   var chunk
18580   while (this.cache.length >= 16) {
18581     chunk = this.cache.slice(0, 16)
18582     this.cache = this.cache.slice(16)
18583     this.ghash(chunk)
18584   }
18585 }
18586
18587 GHASH.prototype.final = function (abl, bl) {
18588   if (this.cache.length) {
18589     this.ghash(Buffer.concat([this.cache, ZEROES], 16))
18590   }
18591
18592   this.ghash(fromArray([0, abl, 0, bl]))
18593   return this.state
18594 }
18595
18596 module.exports = GHASH
18597
18598
18599 /***/ }),
18600 /* 214 */
18601 /***/ (function(module, exports, __webpack_require__) {
18602
18603 var AuthCipher = __webpack_require__(111)
18604 var Buffer = __webpack_require__(2).Buffer
18605 var MODES = __webpack_require__(66)
18606 var StreamCipher = __webpack_require__(112)
18607 var Transform = __webpack_require__(18)
18608 var aes = __webpack_require__(43)
18609 var ebtk = __webpack_require__(44)
18610 var inherits = __webpack_require__(1)
18611
18612 function Decipher (mode, key, iv) {
18613   Transform.call(this)
18614
18615   this._cache = new Splitter()
18616   this._last = void 0
18617   this._cipher = new aes.AES(key)
18618   this._prev = Buffer.from(iv)
18619   this._mode = mode
18620   this._autopadding = true
18621 }
18622
18623 inherits(Decipher, Transform)
18624
18625 Decipher.prototype._update = function (data) {
18626   this._cache.add(data)
18627   var chunk
18628   var thing
18629   var out = []
18630   while ((chunk = this._cache.get(this._autopadding))) {
18631     thing = this._mode.decrypt(this, chunk)
18632     out.push(thing)
18633   }
18634   return Buffer.concat(out)
18635 }
18636
18637 Decipher.prototype._final = function () {
18638   var chunk = this._cache.flush()
18639   if (this._autopadding) {
18640     return unpad(this._mode.decrypt(this, chunk))
18641   } else if (chunk) {
18642     throw new Error('data not multiple of block length')
18643   }
18644 }
18645
18646 Decipher.prototype.setAutoPadding = function (setTo) {
18647   this._autopadding = !!setTo
18648   return this
18649 }
18650
18651 function Splitter () {
18652   this.cache = Buffer.allocUnsafe(0)
18653 }
18654
18655 Splitter.prototype.add = function (data) {
18656   this.cache = Buffer.concat([this.cache, data])
18657 }
18658
18659 Splitter.prototype.get = function (autoPadding) {
18660   var out
18661   if (autoPadding) {
18662     if (this.cache.length > 16) {
18663       out = this.cache.slice(0, 16)
18664       this.cache = this.cache.slice(16)
18665       return out
18666     }
18667   } else {
18668     if (this.cache.length >= 16) {
18669       out = this.cache.slice(0, 16)
18670       this.cache = this.cache.slice(16)
18671       return out
18672     }
18673   }
18674
18675   return null
18676 }
18677
18678 Splitter.prototype.flush = function () {
18679   if (this.cache.length) return this.cache
18680 }
18681
18682 function unpad (last) {
18683   var padded = last[15]
18684   if (padded < 1 || padded > 16) {
18685     throw new Error('unable to decrypt data')
18686   }
18687   var i = -1
18688   while (++i < padded) {
18689     if (last[(i + (16 - padded))] !== padded) {
18690       throw new Error('unable to decrypt data')
18691     }
18692   }
18693   if (padded === 16) return
18694
18695   return last.slice(0, 16 - padded)
18696 }
18697
18698 function createDecipheriv (suite, password, iv) {
18699   var config = MODES[suite.toLowerCase()]
18700   if (!config) throw new TypeError('invalid suite type')
18701
18702   if (typeof iv === 'string') iv = Buffer.from(iv)
18703   if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
18704
18705   if (typeof password === 'string') password = Buffer.from(password)
18706   if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
18707
18708   if (config.type === 'stream') {
18709     return new StreamCipher(config.module, password, iv, true)
18710   } else if (config.type === 'auth') {
18711     return new AuthCipher(config.module, password, iv, true)
18712   }
18713
18714   return new Decipher(config.module, password, iv)
18715 }
18716
18717 function createDecipher (suite, password) {
18718   var config = MODES[suite.toLowerCase()]
18719   if (!config) throw new TypeError('invalid suite type')
18720
18721   var keys = ebtk(password, false, config.key, config.iv)
18722   return createDecipheriv(suite, keys.key, keys.iv)
18723 }
18724
18725 exports.createDecipher = createDecipher
18726 exports.createDecipheriv = createDecipheriv
18727
18728
18729 /***/ }),
18730 /* 215 */
18731 /***/ (function(module, exports) {
18732
18733 exports['des-ecb'] = {
18734   key: 8,
18735   iv: 0
18736 }
18737 exports['des-cbc'] = exports.des = {
18738   key: 8,
18739   iv: 8
18740 }
18741 exports['des-ede3-cbc'] = exports.des3 = {
18742   key: 24,
18743   iv: 8
18744 }
18745 exports['des-ede3'] = {
18746   key: 24,
18747   iv: 0
18748 }
18749 exports['des-ede-cbc'] = {
18750   key: 16,
18751   iv: 8
18752 }
18753 exports['des-ede'] = {
18754   key: 16,
18755   iv: 0
18756 }
18757
18758
18759 /***/ }),
18760 /* 216 */
18761 /***/ (function(module, exports, __webpack_require__) {
18762
18763 /* WEBPACK VAR INJECTION */(function(Buffer) {var generatePrime = __webpack_require__(113)
18764 var primes = __webpack_require__(219)
18765
18766 var DH = __webpack_require__(220)
18767
18768 function getDiffieHellman (mod) {
18769   var prime = new Buffer(primes[mod].prime, 'hex')
18770   var gen = new Buffer(primes[mod].gen, 'hex')
18771
18772   return new DH(prime, gen)
18773 }
18774
18775 var ENCODINGS = {
18776   'binary': true, 'hex': true, 'base64': true
18777 }
18778
18779 function createDiffieHellman (prime, enc, generator, genc) {
18780   if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
18781     return createDiffieHellman(prime, 'binary', enc, generator)
18782   }
18783
18784   enc = enc || 'binary'
18785   genc = genc || 'binary'
18786   generator = generator || new Buffer([2])
18787
18788   if (!Buffer.isBuffer(generator)) {
18789     generator = new Buffer(generator, genc)
18790   }
18791
18792   if (typeof prime === 'number') {
18793     return new DH(generatePrime(prime, generator), generator, true)
18794   }
18795
18796   if (!Buffer.isBuffer(prime)) {
18797     prime = new Buffer(prime, enc)
18798   }
18799
18800   return new DH(prime, generator, true)
18801 }
18802
18803 exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
18804 exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
18805
18806 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
18807
18808 /***/ }),
18809 /* 217 */
18810 /***/ (function(module, exports) {
18811
18812 /* (ignored) */
18813
18814 /***/ }),
18815 /* 218 */
18816 /***/ (function(module, exports) {
18817
18818 /* (ignored) */
18819
18820 /***/ }),
18821 /* 219 */
18822 /***/ (function(module, exports) {
18823
18824 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"}}
18825
18826 /***/ }),
18827 /* 220 */
18828 /***/ (function(module, exports, __webpack_require__) {
18829
18830 /* WEBPACK VAR INJECTION */(function(Buffer) {var BN = __webpack_require__(4);
18831 var MillerRabin = __webpack_require__(114);
18832 var millerRabin = new MillerRabin();
18833 var TWENTYFOUR = new BN(24);
18834 var ELEVEN = new BN(11);
18835 var TEN = new BN(10);
18836 var THREE = new BN(3);
18837 var SEVEN = new BN(7);
18838 var primes = __webpack_require__(113);
18839 var randomBytes = __webpack_require__(23);
18840 module.exports = DH;
18841
18842 function setPublicKey(pub, enc) {
18843   enc = enc || 'utf8';
18844   if (!Buffer.isBuffer(pub)) {
18845     pub = new Buffer(pub, enc);
18846   }
18847   this._pub = new BN(pub);
18848   return this;
18849 }
18850
18851 function setPrivateKey(priv, enc) {
18852   enc = enc || 'utf8';
18853   if (!Buffer.isBuffer(priv)) {
18854     priv = new Buffer(priv, enc);
18855   }
18856   this._priv = new BN(priv);
18857   return this;
18858 }
18859
18860 var primeCache = {};
18861 function checkPrime(prime, generator) {
18862   var gen = generator.toString('hex');
18863   var hex = [gen, prime.toString(16)].join('_');
18864   if (hex in primeCache) {
18865     return primeCache[hex];
18866   }
18867   var error = 0;
18868
18869   if (prime.isEven() ||
18870     !primes.simpleSieve ||
18871     !primes.fermatTest(prime) ||
18872     !millerRabin.test(prime)) {
18873     //not a prime so +1
18874     error += 1;
18875
18876     if (gen === '02' || gen === '05') {
18877       // we'd be able to check the generator
18878       // it would fail so +8
18879       error += 8;
18880     } else {
18881       //we wouldn't be able to test the generator
18882       // so +4
18883       error += 4;
18884     }
18885     primeCache[hex] = error;
18886     return error;
18887   }
18888   if (!millerRabin.test(prime.shrn(1))) {
18889     //not a safe prime
18890     error += 2;
18891   }
18892   var rem;
18893   switch (gen) {
18894     case '02':
18895       if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
18896         // unsuidable generator
18897         error += 8;
18898       }
18899       break;
18900     case '05':
18901       rem = prime.mod(TEN);
18902       if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
18903         // prime mod 10 needs to equal 3 or 7
18904         error += 8;
18905       }
18906       break;
18907     default:
18908       error += 4;
18909   }
18910   primeCache[hex] = error;
18911   return error;
18912 }
18913
18914 function DH(prime, generator, malleable) {
18915   this.setGenerator(generator);
18916   this.__prime = new BN(prime);
18917   this._prime = BN.mont(this.__prime);
18918   this._primeLen = prime.length;
18919   this._pub = undefined;
18920   this._priv = undefined;
18921   this._primeCode = undefined;
18922   if (malleable) {
18923     this.setPublicKey = setPublicKey;
18924     this.setPrivateKey = setPrivateKey;
18925   } else {
18926     this._primeCode = 8;
18927   }
18928 }
18929 Object.defineProperty(DH.prototype, 'verifyError', {
18930   enumerable: true,
18931   get: function () {
18932     if (typeof this._primeCode !== 'number') {
18933       this._primeCode = checkPrime(this.__prime, this.__gen);
18934     }
18935     return this._primeCode;
18936   }
18937 });
18938 DH.prototype.generateKeys = function () {
18939   if (!this._priv) {
18940     this._priv = new BN(randomBytes(this._primeLen));
18941   }
18942   this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
18943   return this.getPublicKey();
18944 };
18945
18946 DH.prototype.computeSecret = function (other) {
18947   other = new BN(other);
18948   other = other.toRed(this._prime);
18949   var secret = other.redPow(this._priv).fromRed();
18950   var out = new Buffer(secret.toArray());
18951   var prime = this.getPrime();
18952   if (out.length < prime.length) {
18953     var front = new Buffer(prime.length - out.length);
18954     front.fill(0);
18955     out = Buffer.concat([front, out]);
18956   }
18957   return out;
18958 };
18959
18960 DH.prototype.getPublicKey = function getPublicKey(enc) {
18961   return formatReturnValue(this._pub, enc);
18962 };
18963
18964 DH.prototype.getPrivateKey = function getPrivateKey(enc) {
18965   return formatReturnValue(this._priv, enc);
18966 };
18967
18968 DH.prototype.getPrime = function (enc) {
18969   return formatReturnValue(this.__prime, enc);
18970 };
18971
18972 DH.prototype.getGenerator = function (enc) {
18973   return formatReturnValue(this._gen, enc);
18974 };
18975
18976 DH.prototype.setGenerator = function (gen, enc) {
18977   enc = enc || 'utf8';
18978   if (!Buffer.isBuffer(gen)) {
18979     gen = new Buffer(gen, enc);
18980   }
18981   this.__gen = gen;
18982   this._gen = new BN(gen);
18983   return this;
18984 };
18985
18986 function formatReturnValue(bn, enc) {
18987   var buf = new Buffer(bn.toArray());
18988   if (!enc) {
18989     return buf;
18990   } else {
18991     return buf.toString(enc);
18992   }
18993 }
18994
18995 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
18996
18997 /***/ }),
18998 /* 221 */
18999 /***/ (function(module, exports, __webpack_require__) {
19000
19001 /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(29)
19002 var stream = __webpack_require__(57)
19003 var inherits = __webpack_require__(1)
19004 var sign = __webpack_require__(222)
19005 var verify = __webpack_require__(258)
19006
19007 var algorithms = __webpack_require__(103)
19008 Object.keys(algorithms).forEach(function (key) {
19009   algorithms[key].id = new Buffer(algorithms[key].id, 'hex')
19010   algorithms[key.toLowerCase()] = algorithms[key]
19011 })
19012
19013 function Sign (algorithm) {
19014   stream.Writable.call(this)
19015
19016   var data = algorithms[algorithm]
19017   if (!data) throw new Error('Unknown message digest')
19018
19019   this._hashType = data.hash
19020   this._hash = createHash(data.hash)
19021   this._tag = data.id
19022   this._signType = data.sign
19023 }
19024 inherits(Sign, stream.Writable)
19025
19026 Sign.prototype._write = function _write (data, _, done) {
19027   this._hash.update(data)
19028   done()
19029 }
19030
19031 Sign.prototype.update = function update (data, enc) {
19032   if (typeof data === 'string') data = new Buffer(data, enc)
19033
19034   this._hash.update(data)
19035   return this
19036 }
19037
19038 Sign.prototype.sign = function signMethod (key, enc) {
19039   this.end()
19040   var hash = this._hash.digest()
19041   var sig = sign(hash, key, this._hashType, this._signType, this._tag)
19042
19043   return enc ? sig.toString(enc) : sig
19044 }
19045
19046 function Verify (algorithm) {
19047   stream.Writable.call(this)
19048
19049   var data = algorithms[algorithm]
19050   if (!data) throw new Error('Unknown message digest')
19051
19052   this._hash = createHash(data.hash)
19053   this._tag = data.id
19054   this._signType = data.sign
19055 }
19056 inherits(Verify, stream.Writable)
19057
19058 Verify.prototype._write = function _write (data, _, done) {
19059   this._hash.update(data)
19060   done()
19061 }
19062
19063 Verify.prototype.update = function update (data, enc) {
19064   if (typeof data === 'string') data = new Buffer(data, enc)
19065
19066   this._hash.update(data)
19067   return this
19068 }
19069
19070 Verify.prototype.verify = function verifyMethod (key, sig, enc) {
19071   if (typeof sig === 'string') sig = new Buffer(sig, enc)
19072
19073   this.end()
19074   var hash = this._hash.digest()
19075   return verify(sig, hash, key, this._signType, this._tag)
19076 }
19077
19078 function createSign (algorithm) {
19079   return new Sign(algorithm)
19080 }
19081
19082 function createVerify (algorithm) {
19083   return new Verify(algorithm)
19084 }
19085
19086 module.exports = {
19087   Sign: createSign,
19088   Verify: createVerify,
19089   createSign: createSign,
19090   createVerify: createVerify
19091 }
19092
19093 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
19094
19095 /***/ }),
19096 /* 222 */
19097 /***/ (function(module, exports, __webpack_require__) {
19098
19099 /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
19100 var createHmac = __webpack_require__(101)
19101 var crt = __webpack_require__(67)
19102 var EC = __webpack_require__(6).ec
19103 var BN = __webpack_require__(4)
19104 var parseKeys = __webpack_require__(46)
19105 var curves = __webpack_require__(124)
19106
19107 function sign (hash, key, hashType, signType, tag) {
19108   var priv = parseKeys(key)
19109   if (priv.curve) {
19110     // rsa keys can be interpreted as ecdsa ones in openssl
19111     if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
19112     return ecSign(hash, priv)
19113   } else if (priv.type === 'dsa') {
19114     if (signType !== 'dsa') throw new Error('wrong private key type')
19115     return dsaSign(hash, priv, hashType)
19116   } else {
19117     if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
19118   }
19119   hash = Buffer.concat([tag, hash])
19120   var len = priv.modulus.byteLength()
19121   var pad = [ 0, 1 ]
19122   while (hash.length + pad.length + 1 < len) pad.push(0xff)
19123   pad.push(0x00)
19124   var i = -1
19125   while (++i < hash.length) pad.push(hash[i])
19126
19127   var out = crt(pad, priv)
19128   return out
19129 }
19130
19131 function ecSign (hash, priv) {
19132   var curveId = curves[priv.curve.join('.')]
19133   if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
19134
19135   var curve = new EC(curveId)
19136   var key = curve.keyFromPrivate(priv.privateKey)
19137   var out = key.sign(hash)
19138
19139   return new Buffer(out.toDER())
19140 }
19141
19142 function dsaSign (hash, priv, algo) {
19143   var x = priv.params.priv_key
19144   var p = priv.params.p
19145   var q = priv.params.q
19146   var g = priv.params.g
19147   var r = new BN(0)
19148   var k
19149   var H = bits2int(hash, q).mod(q)
19150   var s = false
19151   var kv = getKey(x, q, hash, algo)
19152   while (s === false) {
19153     k = makeKey(q, kv, algo)
19154     r = makeR(g, k, p, q)
19155     s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
19156     if (s.cmpn(0) === 0) {
19157       s = false
19158       r = new BN(0)
19159     }
19160   }
19161   return toDER(r, s)
19162 }
19163
19164 function toDER (r, s) {
19165   r = r.toArray()
19166   s = s.toArray()
19167
19168   // Pad values
19169   if (r[0] & 0x80) r = [ 0 ].concat(r)
19170   if (s[0] & 0x80) s = [ 0 ].concat(s)
19171
19172   var total = r.length + s.length + 4
19173   var res = [ 0x30, total, 0x02, r.length ]
19174   res = res.concat(r, [ 0x02, s.length ], s)
19175   return new Buffer(res)
19176 }
19177
19178 function getKey (x, q, hash, algo) {
19179   x = new Buffer(x.toArray())
19180   if (x.length < q.byteLength()) {
19181     var zeros = new Buffer(q.byteLength() - x.length)
19182     zeros.fill(0)
19183     x = Buffer.concat([ zeros, x ])
19184   }
19185   var hlen = hash.length
19186   var hbits = bits2octets(hash, q)
19187   var v = new Buffer(hlen)
19188   v.fill(1)
19189   var k = new Buffer(hlen)
19190   k.fill(0)
19191   k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest()
19192   v = createHmac(algo, k).update(v).digest()
19193   k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest()
19194   v = createHmac(algo, k).update(v).digest()
19195   return { k: k, v: v }
19196 }
19197
19198 function bits2int (obits, q) {
19199   var bits = new BN(obits)
19200   var shift = (obits.length << 3) - q.bitLength()
19201   if (shift > 0) bits.ishrn(shift)
19202   return bits
19203 }
19204
19205 function bits2octets (bits, q) {
19206   bits = bits2int(bits, q)
19207   bits = bits.mod(q)
19208   var out = new Buffer(bits.toArray())
19209   if (out.length < q.byteLength()) {
19210     var zeros = new Buffer(q.byteLength() - out.length)
19211     zeros.fill(0)
19212     out = Buffer.concat([ zeros, out ])
19213   }
19214   return out
19215 }
19216
19217 function makeKey (q, kv, algo) {
19218   var t
19219   var k
19220
19221   do {
19222     t = new Buffer(0)
19223
19224     while (t.length * 8 < q.bitLength()) {
19225       kv.v = createHmac(algo, kv.k).update(kv.v).digest()
19226       t = Buffer.concat([ t, kv.v ])
19227     }
19228
19229     k = bits2int(t, q)
19230     kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest()
19231     kv.v = createHmac(algo, kv.k).update(kv.v).digest()
19232   } while (k.cmp(q) !== -1)
19233
19234   return k
19235 }
19236
19237 function makeR (g, k, p, q) {
19238   return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
19239 }
19240
19241 module.exports = sign
19242 module.exports.getKey = getKey
19243 module.exports.makeKey = makeKey
19244
19245 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
19246
19247 /***/ }),
19248 /* 223 */
19249 /***/ (function(module, exports) {
19250
19251 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"}
19252
19253 /***/ }),
19254 /* 224 */
19255 /***/ (function(module, exports, __webpack_require__) {
19256
19257 "use strict";
19258
19259
19260 var utils = exports;
19261 var BN = __webpack_require__(4);
19262 var minAssert = __webpack_require__(9);
19263 var minUtils = __webpack_require__(116);
19264
19265 utils.assert = minAssert;
19266 utils.toArray = minUtils.toArray;
19267 utils.zero2 = minUtils.zero2;
19268 utils.toHex = minUtils.toHex;
19269 utils.encode = minUtils.encode;
19270
19271 // Represent num in a w-NAF form
19272 function getNAF(num, w) {
19273   var naf = [];
19274   var ws = 1 << (w + 1);
19275   var k = num.clone();
19276   while (k.cmpn(1) >= 0) {
19277     var z;
19278     if (k.isOdd()) {
19279       var mod = k.andln(ws - 1);
19280       if (mod > (ws >> 1) - 1)
19281         z = (ws >> 1) - mod;
19282       else
19283         z = mod;
19284       k.isubn(z);
19285     } else {
19286       z = 0;
19287     }
19288     naf.push(z);
19289
19290     // Optimization, shift by word if possible
19291     var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
19292     for (var i = 1; i < shift; i++)
19293       naf.push(0);
19294     k.iushrn(shift);
19295   }
19296
19297   return naf;
19298 }
19299 utils.getNAF = getNAF;
19300
19301 // Represent k1, k2 in a Joint Sparse Form
19302 function getJSF(k1, k2) {
19303   var jsf = [
19304     [],
19305     []
19306   ];
19307
19308   k1 = k1.clone();
19309   k2 = k2.clone();
19310   var d1 = 0;
19311   var d2 = 0;
19312   while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
19313
19314     // First phase
19315     var m14 = (k1.andln(3) + d1) & 3;
19316     var m24 = (k2.andln(3) + d2) & 3;
19317     if (m14 === 3)
19318       m14 = -1;
19319     if (m24 === 3)
19320       m24 = -1;
19321     var u1;
19322     if ((m14 & 1) === 0) {
19323       u1 = 0;
19324     } else {
19325       var m8 = (k1.andln(7) + d1) & 7;
19326       if ((m8 === 3 || m8 === 5) && m24 === 2)
19327         u1 = -m14;
19328       else
19329         u1 = m14;
19330     }
19331     jsf[0].push(u1);
19332
19333     var u2;
19334     if ((m24 & 1) === 0) {
19335       u2 = 0;
19336     } else {
19337       var m8 = (k2.andln(7) + d2) & 7;
19338       if ((m8 === 3 || m8 === 5) && m14 === 2)
19339         u2 = -m24;
19340       else
19341         u2 = m24;
19342     }
19343     jsf[1].push(u2);
19344
19345     // Second phase
19346     if (2 * d1 === u1 + 1)
19347       d1 = 1 - d1;
19348     if (2 * d2 === u2 + 1)
19349       d2 = 1 - d2;
19350     k1.iushrn(1);
19351     k2.iushrn(1);
19352   }
19353
19354   return jsf;
19355 }
19356 utils.getJSF = getJSF;
19357
19358 function cachedProperty(obj, name, computer) {
19359   var key = '_' + name;
19360   obj.prototype[name] = function cachedProperty() {
19361     return this[key] !== undefined ? this[key] :
19362            this[key] = computer.call(this);
19363   };
19364 }
19365 utils.cachedProperty = cachedProperty;
19366
19367 function parseBytes(bytes) {
19368   return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
19369                                      bytes;
19370 }
19371 utils.parseBytes = parseBytes;
19372
19373 function intFromLE(bytes) {
19374   return new BN(bytes, 'hex', 'le');
19375 }
19376 utils.intFromLE = intFromLE;
19377
19378
19379
19380 /***/ }),
19381 /* 225 */
19382 /***/ (function(module, exports, __webpack_require__) {
19383
19384 "use strict";
19385
19386
19387 var BN = __webpack_require__(4);
19388 var elliptic = __webpack_require__(6);
19389 var utils = elliptic.utils;
19390 var getNAF = utils.getNAF;
19391 var getJSF = utils.getJSF;
19392 var assert = utils.assert;
19393
19394 function BaseCurve(type, conf) {
19395   this.type = type;
19396   this.p = new BN(conf.p, 16);
19397
19398   // Use Montgomery, when there is no fast reduction for the prime
19399   this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
19400
19401   // Useful for many curves
19402   this.zero = new BN(0).toRed(this.red);
19403   this.one = new BN(1).toRed(this.red);
19404   this.two = new BN(2).toRed(this.red);
19405
19406   // Curve configuration, optional
19407   this.n = conf.n && new BN(conf.n, 16);
19408   this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
19409
19410   // Temporary arrays
19411   this._wnafT1 = new Array(4);
19412   this._wnafT2 = new Array(4);
19413   this._wnafT3 = new Array(4);
19414   this._wnafT4 = new Array(4);
19415
19416   // Generalized Greg Maxwell's trick
19417   var adjustCount = this.n && this.p.div(this.n);
19418   if (!adjustCount || adjustCount.cmpn(100) > 0) {
19419     this.redN = null;
19420   } else {
19421     this._maxwellTrick = true;
19422     this.redN = this.n.toRed(this.red);
19423   }
19424 }
19425 module.exports = BaseCurve;
19426
19427 BaseCurve.prototype.point = function point() {
19428   throw new Error('Not implemented');
19429 };
19430
19431 BaseCurve.prototype.validate = function validate() {
19432   throw new Error('Not implemented');
19433 };
19434
19435 BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
19436   assert(p.precomputed);
19437   var doubles = p._getDoubles();
19438
19439   var naf = getNAF(k, 1);
19440   var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
19441   I /= 3;
19442
19443   // Translate into more windowed form
19444   var repr = [];
19445   for (var j = 0; j < naf.length; j += doubles.step) {
19446     var nafW = 0;
19447     for (var k = j + doubles.step - 1; k >= j; k--)
19448       nafW = (nafW << 1) + naf[k];
19449     repr.push(nafW);
19450   }
19451
19452   var a = this.jpoint(null, null, null);
19453   var b = this.jpoint(null, null, null);
19454   for (var i = I; i > 0; i--) {
19455     for (var j = 0; j < repr.length; j++) {
19456       var nafW = repr[j];
19457       if (nafW === i)
19458         b = b.mixedAdd(doubles.points[j]);
19459       else if (nafW === -i)
19460         b = b.mixedAdd(doubles.points[j].neg());
19461     }
19462     a = a.add(b);
19463   }
19464   return a.toP();
19465 };
19466
19467 BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
19468   var w = 4;
19469
19470   // Precompute window
19471   var nafPoints = p._getNAFPoints(w);
19472   w = nafPoints.wnd;
19473   var wnd = nafPoints.points;
19474
19475   // Get NAF form
19476   var naf = getNAF(k, w);
19477
19478   // Add `this`*(N+1) for every w-NAF index
19479   var acc = this.jpoint(null, null, null);
19480   for (var i = naf.length - 1; i >= 0; i--) {
19481     // Count zeroes
19482     for (var k = 0; i >= 0 && naf[i] === 0; i--)
19483       k++;
19484     if (i >= 0)
19485       k++;
19486     acc = acc.dblp(k);
19487
19488     if (i < 0)
19489       break;
19490     var z = naf[i];
19491     assert(z !== 0);
19492     if (p.type === 'affine') {
19493       // J +- P
19494       if (z > 0)
19495         acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
19496       else
19497         acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
19498     } else {
19499       // J +- J
19500       if (z > 0)
19501         acc = acc.add(wnd[(z - 1) >> 1]);
19502       else
19503         acc = acc.add(wnd[(-z - 1) >> 1].neg());
19504     }
19505   }
19506   return p.type === 'affine' ? acc.toP() : acc;
19507 };
19508
19509 BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
19510                                                        points,
19511                                                        coeffs,
19512                                                        len,
19513                                                        jacobianResult) {
19514   var wndWidth = this._wnafT1;
19515   var wnd = this._wnafT2;
19516   var naf = this._wnafT3;
19517
19518   // Fill all arrays
19519   var max = 0;
19520   for (var i = 0; i < len; i++) {
19521     var p = points[i];
19522     var nafPoints = p._getNAFPoints(defW);
19523     wndWidth[i] = nafPoints.wnd;
19524     wnd[i] = nafPoints.points;
19525   }
19526
19527   // Comb small window NAFs
19528   for (var i = len - 1; i >= 1; i -= 2) {
19529     var a = i - 1;
19530     var b = i;
19531     if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
19532       naf[a] = getNAF(coeffs[a], wndWidth[a]);
19533       naf[b] = getNAF(coeffs[b], wndWidth[b]);
19534       max = Math.max(naf[a].length, max);
19535       max = Math.max(naf[b].length, max);
19536       continue;
19537     }
19538
19539     var comb = [
19540       points[a], /* 1 */
19541       null, /* 3 */
19542       null, /* 5 */
19543       points[b] /* 7 */
19544     ];
19545
19546     // Try to avoid Projective points, if possible
19547     if (points[a].y.cmp(points[b].y) === 0) {
19548       comb[1] = points[a].add(points[b]);
19549       comb[2] = points[a].toJ().mixedAdd(points[b].neg());
19550     } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
19551       comb[1] = points[a].toJ().mixedAdd(points[b]);
19552       comb[2] = points[a].add(points[b].neg());
19553     } else {
19554       comb[1] = points[a].toJ().mixedAdd(points[b]);
19555       comb[2] = points[a].toJ().mixedAdd(points[b].neg());
19556     }
19557
19558     var index = [
19559       -3, /* -1 -1 */
19560       -1, /* -1 0 */
19561       -5, /* -1 1 */
19562       -7, /* 0 -1 */
19563       0, /* 0 0 */
19564       7, /* 0 1 */
19565       5, /* 1 -1 */
19566       1, /* 1 0 */
19567       3  /* 1 1 */
19568     ];
19569
19570     var jsf = getJSF(coeffs[a], coeffs[b]);
19571     max = Math.max(jsf[0].length, max);
19572     naf[a] = new Array(max);
19573     naf[b] = new Array(max);
19574     for (var j = 0; j < max; j++) {
19575       var ja = jsf[0][j] | 0;
19576       var jb = jsf[1][j] | 0;
19577
19578       naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
19579       naf[b][j] = 0;
19580       wnd[a] = comb;
19581     }
19582   }
19583
19584   var acc = this.jpoint(null, null, null);
19585   var tmp = this._wnafT4;
19586   for (var i = max; i >= 0; i--) {
19587     var k = 0;
19588
19589     while (i >= 0) {
19590       var zero = true;
19591       for (var j = 0; j < len; j++) {
19592         tmp[j] = naf[j][i] | 0;
19593         if (tmp[j] !== 0)
19594           zero = false;
19595       }
19596       if (!zero)
19597         break;
19598       k++;
19599       i--;
19600     }
19601     if (i >= 0)
19602       k++;
19603     acc = acc.dblp(k);
19604     if (i < 0)
19605       break;
19606
19607     for (var j = 0; j < len; j++) {
19608       var z = tmp[j];
19609       var p;
19610       if (z === 0)
19611         continue;
19612       else if (z > 0)
19613         p = wnd[j][(z - 1) >> 1];
19614       else if (z < 0)
19615         p = wnd[j][(-z - 1) >> 1].neg();
19616
19617       if (p.type === 'affine')
19618         acc = acc.mixedAdd(p);
19619       else
19620         acc = acc.add(p);
19621     }
19622   }
19623   // Zeroify references
19624   for (var i = 0; i < len; i++)
19625     wnd[i] = null;
19626
19627   if (jacobianResult)
19628     return acc;
19629   else
19630     return acc.toP();
19631 };
19632
19633 function BasePoint(curve, type) {
19634   this.curve = curve;
19635   this.type = type;
19636   this.precomputed = null;
19637 }
19638 BaseCurve.BasePoint = BasePoint;
19639
19640 BasePoint.prototype.eq = function eq(/*other*/) {
19641   throw new Error('Not implemented');
19642 };
19643
19644 BasePoint.prototype.validate = function validate() {
19645   return this.curve.validate(this);
19646 };
19647
19648 BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
19649   bytes = utils.toArray(bytes, enc);
19650
19651   var len = this.p.byteLength();
19652
19653   // uncompressed, hybrid-odd, hybrid-even
19654   if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
19655       bytes.length - 1 === 2 * len) {
19656     if (bytes[0] === 0x06)
19657       assert(bytes[bytes.length - 1] % 2 === 0);
19658     else if (bytes[0] === 0x07)
19659       assert(bytes[bytes.length - 1] % 2 === 1);
19660
19661     var res =  this.point(bytes.slice(1, 1 + len),
19662                           bytes.slice(1 + len, 1 + 2 * len));
19663
19664     return res;
19665   } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
19666               bytes.length - 1 === len) {
19667     return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
19668   }
19669   throw new Error('Unknown point format');
19670 };
19671
19672 BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
19673   return this.encode(enc, true);
19674 };
19675
19676 BasePoint.prototype._encode = function _encode(compact) {
19677   var len = this.curve.p.byteLength();
19678   var x = this.getX().toArray('be', len);
19679
19680   if (compact)
19681     return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
19682
19683   return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
19684 };
19685
19686 BasePoint.prototype.encode = function encode(enc, compact) {
19687   return utils.encode(this._encode(compact), enc);
19688 };
19689
19690 BasePoint.prototype.precompute = function precompute(power) {
19691   if (this.precomputed)
19692     return this;
19693
19694   var precomputed = {
19695     doubles: null,
19696     naf: null,
19697     beta: null
19698   };
19699   precomputed.naf = this._getNAFPoints(8);
19700   precomputed.doubles = this._getDoubles(4, power);
19701   precomputed.beta = this._getBeta();
19702   this.precomputed = precomputed;
19703
19704   return this;
19705 };
19706
19707 BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
19708   if (!this.precomputed)
19709     return false;
19710
19711   var doubles = this.precomputed.doubles;
19712   if (!doubles)
19713     return false;
19714
19715   return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
19716 };
19717
19718 BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
19719   if (this.precomputed && this.precomputed.doubles)
19720     return this.precomputed.doubles;
19721
19722   var doubles = [ this ];
19723   var acc = this;
19724   for (var i = 0; i < power; i += step) {
19725     for (var j = 0; j < step; j++)
19726       acc = acc.dbl();
19727     doubles.push(acc);
19728   }
19729   return {
19730     step: step,
19731     points: doubles
19732   };
19733 };
19734
19735 BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
19736   if (this.precomputed && this.precomputed.naf)
19737     return this.precomputed.naf;
19738
19739   var res = [ this ];
19740   var max = (1 << wnd) - 1;
19741   var dbl = max === 1 ? null : this.dbl();
19742   for (var i = 1; i < max; i++)
19743     res[i] = res[i - 1].add(dbl);
19744   return {
19745     wnd: wnd,
19746     points: res
19747   };
19748 };
19749
19750 BasePoint.prototype._getBeta = function _getBeta() {
19751   return null;
19752 };
19753
19754 BasePoint.prototype.dblp = function dblp(k) {
19755   var r = this;
19756   for (var i = 0; i < k; i++)
19757     r = r.dbl();
19758   return r;
19759 };
19760
19761
19762 /***/ }),
19763 /* 226 */
19764 /***/ (function(module, exports, __webpack_require__) {
19765
19766 "use strict";
19767
19768
19769 var curve = __webpack_require__(45);
19770 var elliptic = __webpack_require__(6);
19771 var BN = __webpack_require__(4);
19772 var inherits = __webpack_require__(1);
19773 var Base = curve.base;
19774
19775 var assert = elliptic.utils.assert;
19776
19777 function ShortCurve(conf) {
19778   Base.call(this, 'short', conf);
19779
19780   this.a = new BN(conf.a, 16).toRed(this.red);
19781   this.b = new BN(conf.b, 16).toRed(this.red);
19782   this.tinv = this.two.redInvm();
19783
19784   this.zeroA = this.a.fromRed().cmpn(0) === 0;
19785   this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
19786
19787   // If the curve is endomorphic, precalculate beta and lambda
19788   this.endo = this._getEndomorphism(conf);
19789   this._endoWnafT1 = new Array(4);
19790   this._endoWnafT2 = new Array(4);
19791 }
19792 inherits(ShortCurve, Base);
19793 module.exports = ShortCurve;
19794
19795 ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
19796   // No efficient endomorphism
19797   if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
19798     return;
19799
19800   // Compute beta and lambda, that lambda * P = (beta * Px; Py)
19801   var beta;
19802   var lambda;
19803   if (conf.beta) {
19804     beta = new BN(conf.beta, 16).toRed(this.red);
19805   } else {
19806     var betas = this._getEndoRoots(this.p);
19807     // Choose the smallest beta
19808     beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
19809     beta = beta.toRed(this.red);
19810   }
19811   if (conf.lambda) {
19812     lambda = new BN(conf.lambda, 16);
19813   } else {
19814     // Choose the lambda that is matching selected beta
19815     var lambdas = this._getEndoRoots(this.n);
19816     if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
19817       lambda = lambdas[0];
19818     } else {
19819       lambda = lambdas[1];
19820       assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
19821     }
19822   }
19823
19824   // Get basis vectors, used for balanced length-two representation
19825   var basis;
19826   if (conf.basis) {
19827     basis = conf.basis.map(function(vec) {
19828       return {
19829         a: new BN(vec.a, 16),
19830         b: new BN(vec.b, 16)
19831       };
19832     });
19833   } else {
19834     basis = this._getEndoBasis(lambda);
19835   }
19836
19837   return {
19838     beta: beta,
19839     lambda: lambda,
19840     basis: basis
19841   };
19842 };
19843
19844 ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
19845   // Find roots of for x^2 + x + 1 in F
19846   // Root = (-1 +- Sqrt(-3)) / 2
19847   //
19848   var red = num === this.p ? this.red : BN.mont(num);
19849   var tinv = new BN(2).toRed(red).redInvm();
19850   var ntinv = tinv.redNeg();
19851
19852   var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
19853
19854   var l1 = ntinv.redAdd(s).fromRed();
19855   var l2 = ntinv.redSub(s).fromRed();
19856   return [ l1, l2 ];
19857 };
19858
19859 ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
19860   // aprxSqrt >= sqrt(this.n)
19861   var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
19862
19863   // 3.74
19864   // Run EGCD, until r(L + 1) < aprxSqrt
19865   var u = lambda;
19866   var v = this.n.clone();
19867   var x1 = new BN(1);
19868   var y1 = new BN(0);
19869   var x2 = new BN(0);
19870   var y2 = new BN(1);
19871
19872   // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
19873   var a0;
19874   var b0;
19875   // First vector
19876   var a1;
19877   var b1;
19878   // Second vector
19879   var a2;
19880   var b2;
19881
19882   var prevR;
19883   var i = 0;
19884   var r;
19885   var x;
19886   while (u.cmpn(0) !== 0) {
19887     var q = v.div(u);
19888     r = v.sub(q.mul(u));
19889     x = x2.sub(q.mul(x1));
19890     var y = y2.sub(q.mul(y1));
19891
19892     if (!a1 && r.cmp(aprxSqrt) < 0) {
19893       a0 = prevR.neg();
19894       b0 = x1;
19895       a1 = r.neg();
19896       b1 = x;
19897     } else if (a1 && ++i === 2) {
19898       break;
19899     }
19900     prevR = r;
19901
19902     v = u;
19903     u = r;
19904     x2 = x1;
19905     x1 = x;
19906     y2 = y1;
19907     y1 = y;
19908   }
19909   a2 = r.neg();
19910   b2 = x;
19911
19912   var len1 = a1.sqr().add(b1.sqr());
19913   var len2 = a2.sqr().add(b2.sqr());
19914   if (len2.cmp(len1) >= 0) {
19915     a2 = a0;
19916     b2 = b0;
19917   }
19918
19919   // Normalize signs
19920   if (a1.negative) {
19921     a1 = a1.neg();
19922     b1 = b1.neg();
19923   }
19924   if (a2.negative) {
19925     a2 = a2.neg();
19926     b2 = b2.neg();
19927   }
19928
19929   return [
19930     { a: a1, b: b1 },
19931     { a: a2, b: b2 }
19932   ];
19933 };
19934
19935 ShortCurve.prototype._endoSplit = function _endoSplit(k) {
19936   var basis = this.endo.basis;
19937   var v1 = basis[0];
19938   var v2 = basis[1];
19939
19940   var c1 = v2.b.mul(k).divRound(this.n);
19941   var c2 = v1.b.neg().mul(k).divRound(this.n);
19942
19943   var p1 = c1.mul(v1.a);
19944   var p2 = c2.mul(v2.a);
19945   var q1 = c1.mul(v1.b);
19946   var q2 = c2.mul(v2.b);
19947
19948   // Calculate answer
19949   var k1 = k.sub(p1).sub(p2);
19950   var k2 = q1.add(q2).neg();
19951   return { k1: k1, k2: k2 };
19952 };
19953
19954 ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
19955   x = new BN(x, 16);
19956   if (!x.red)
19957     x = x.toRed(this.red);
19958
19959   var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
19960   var y = y2.redSqrt();
19961   if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
19962     throw new Error('invalid point');
19963
19964   // XXX Is there any way to tell if the number is odd without converting it
19965   // to non-red form?
19966   var isOdd = y.fromRed().isOdd();
19967   if (odd && !isOdd || !odd && isOdd)
19968     y = y.redNeg();
19969
19970   return this.point(x, y);
19971 };
19972
19973 ShortCurve.prototype.validate = function validate(point) {
19974   if (point.inf)
19975     return true;
19976
19977   var x = point.x;
19978   var y = point.y;
19979
19980   var ax = this.a.redMul(x);
19981   var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
19982   return y.redSqr().redISub(rhs).cmpn(0) === 0;
19983 };
19984
19985 ShortCurve.prototype._endoWnafMulAdd =
19986     function _endoWnafMulAdd(points, coeffs, jacobianResult) {
19987   var npoints = this._endoWnafT1;
19988   var ncoeffs = this._endoWnafT2;
19989   for (var i = 0; i < points.length; i++) {
19990     var split = this._endoSplit(coeffs[i]);
19991     var p = points[i];
19992     var beta = p._getBeta();
19993
19994     if (split.k1.negative) {
19995       split.k1.ineg();
19996       p = p.neg(true);
19997     }
19998     if (split.k2.negative) {
19999       split.k2.ineg();
20000       beta = beta.neg(true);
20001     }
20002
20003     npoints[i * 2] = p;
20004     npoints[i * 2 + 1] = beta;
20005     ncoeffs[i * 2] = split.k1;
20006     ncoeffs[i * 2 + 1] = split.k2;
20007   }
20008   var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
20009
20010   // Clean-up references to points and coefficients
20011   for (var j = 0; j < i * 2; j++) {
20012     npoints[j] = null;
20013     ncoeffs[j] = null;
20014   }
20015   return res;
20016 };
20017
20018 function Point(curve, x, y, isRed) {
20019   Base.BasePoint.call(this, curve, 'affine');
20020   if (x === null && y === null) {
20021     this.x = null;
20022     this.y = null;
20023     this.inf = true;
20024   } else {
20025     this.x = new BN(x, 16);
20026     this.y = new BN(y, 16);
20027     // Force redgomery representation when loading from JSON
20028     if (isRed) {
20029       this.x.forceRed(this.curve.red);
20030       this.y.forceRed(this.curve.red);
20031     }
20032     if (!this.x.red)
20033       this.x = this.x.toRed(this.curve.red);
20034     if (!this.y.red)
20035       this.y = this.y.toRed(this.curve.red);
20036     this.inf = false;
20037   }
20038 }
20039 inherits(Point, Base.BasePoint);
20040
20041 ShortCurve.prototype.point = function point(x, y, isRed) {
20042   return new Point(this, x, y, isRed);
20043 };
20044
20045 ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
20046   return Point.fromJSON(this, obj, red);
20047 };
20048
20049 Point.prototype._getBeta = function _getBeta() {
20050   if (!this.curve.endo)
20051     return;
20052
20053   var pre = this.precomputed;
20054   if (pre && pre.beta)
20055     return pre.beta;
20056
20057   var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
20058   if (pre) {
20059     var curve = this.curve;
20060     var endoMul = function(p) {
20061       return curve.point(p.x.redMul(curve.endo.beta), p.y);
20062     };
20063     pre.beta = beta;
20064     beta.precomputed = {
20065       beta: null,
20066       naf: pre.naf && {
20067         wnd: pre.naf.wnd,
20068         points: pre.naf.points.map(endoMul)
20069       },
20070       doubles: pre.doubles && {
20071         step: pre.doubles.step,
20072         points: pre.doubles.points.map(endoMul)
20073       }
20074     };
20075   }
20076   return beta;
20077 };
20078
20079 Point.prototype.toJSON = function toJSON() {
20080   if (!this.precomputed)
20081     return [ this.x, this.y ];
20082
20083   return [ this.x, this.y, this.precomputed && {
20084     doubles: this.precomputed.doubles && {
20085       step: this.precomputed.doubles.step,
20086       points: this.precomputed.doubles.points.slice(1)
20087     },
20088     naf: this.precomputed.naf && {
20089       wnd: this.precomputed.naf.wnd,
20090       points: this.precomputed.naf.points.slice(1)
20091     }
20092   } ];
20093 };
20094
20095 Point.fromJSON = function fromJSON(curve, obj, red) {
20096   if (typeof obj === 'string')
20097     obj = JSON.parse(obj);
20098   var res = curve.point(obj[0], obj[1], red);
20099   if (!obj[2])
20100     return res;
20101
20102   function obj2point(obj) {
20103     return curve.point(obj[0], obj[1], red);
20104   }
20105
20106   var pre = obj[2];
20107   res.precomputed = {
20108     beta: null,
20109     doubles: pre.doubles && {
20110       step: pre.doubles.step,
20111       points: [ res ].concat(pre.doubles.points.map(obj2point))
20112     },
20113     naf: pre.naf && {
20114       wnd: pre.naf.wnd,
20115       points: [ res ].concat(pre.naf.points.map(obj2point))
20116     }
20117   };
20118   return res;
20119 };
20120
20121 Point.prototype.inspect = function inspect() {
20122   if (this.isInfinity())
20123     return '<EC Point Infinity>';
20124   return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
20125       ' y: ' + this.y.fromRed().toString(16, 2) + '>';
20126 };
20127
20128 Point.prototype.isInfinity = function isInfinity() {
20129   return this.inf;
20130 };
20131
20132 Point.prototype.add = function add(p) {
20133   // O + P = P
20134   if (this.inf)
20135     return p;
20136
20137   // P + O = P
20138   if (p.inf)
20139     return this;
20140
20141   // P + P = 2P
20142   if (this.eq(p))
20143     return this.dbl();
20144
20145   // P + (-P) = O
20146   if (this.neg().eq(p))
20147     return this.curve.point(null, null);
20148
20149   // P + Q = O
20150   if (this.x.cmp(p.x) === 0)
20151     return this.curve.point(null, null);
20152
20153   var c = this.y.redSub(p.y);
20154   if (c.cmpn(0) !== 0)
20155     c = c.redMul(this.x.redSub(p.x).redInvm());
20156   var nx = c.redSqr().redISub(this.x).redISub(p.x);
20157   var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
20158   return this.curve.point(nx, ny);
20159 };
20160
20161 Point.prototype.dbl = function dbl() {
20162   if (this.inf)
20163     return this;
20164
20165   // 2P = O
20166   var ys1 = this.y.redAdd(this.y);
20167   if (ys1.cmpn(0) === 0)
20168     return this.curve.point(null, null);
20169
20170   var a = this.curve.a;
20171
20172   var x2 = this.x.redSqr();
20173   var dyinv = ys1.redInvm();
20174   var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
20175
20176   var nx = c.redSqr().redISub(this.x.redAdd(this.x));
20177   var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
20178   return this.curve.point(nx, ny);
20179 };
20180
20181 Point.prototype.getX = function getX() {
20182   return this.x.fromRed();
20183 };
20184
20185 Point.prototype.getY = function getY() {
20186   return this.y.fromRed();
20187 };
20188
20189 Point.prototype.mul = function mul(k) {
20190   k = new BN(k, 16);
20191
20192   if (this._hasDoubles(k))
20193     return this.curve._fixedNafMul(this, k);
20194   else if (this.curve.endo)
20195     return this.curve._endoWnafMulAdd([ this ], [ k ]);
20196   else
20197     return this.curve._wnafMul(this, k);
20198 };
20199
20200 Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
20201   var points = [ this, p2 ];
20202   var coeffs = [ k1, k2 ];
20203   if (this.curve.endo)
20204     return this.curve._endoWnafMulAdd(points, coeffs);
20205   else
20206     return this.curve._wnafMulAdd(1, points, coeffs, 2);
20207 };
20208
20209 Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
20210   var points = [ this, p2 ];
20211   var coeffs = [ k1, k2 ];
20212   if (this.curve.endo)
20213     return this.curve._endoWnafMulAdd(points, coeffs, true);
20214   else
20215     return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
20216 };
20217
20218 Point.prototype.eq = function eq(p) {
20219   return this === p ||
20220          this.inf === p.inf &&
20221              (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
20222 };
20223
20224 Point.prototype.neg = function neg(_precompute) {
20225   if (this.inf)
20226     return this;
20227
20228   var res = this.curve.point(this.x, this.y.redNeg());
20229   if (_precompute && this.precomputed) {
20230     var pre = this.precomputed;
20231     var negate = function(p) {
20232       return p.neg();
20233     };
20234     res.precomputed = {
20235       naf: pre.naf && {
20236         wnd: pre.naf.wnd,
20237         points: pre.naf.points.map(negate)
20238       },
20239       doubles: pre.doubles && {
20240         step: pre.doubles.step,
20241         points: pre.doubles.points.map(negate)
20242       }
20243     };
20244   }
20245   return res;
20246 };
20247
20248 Point.prototype.toJ = function toJ() {
20249   if (this.inf)
20250     return this.curve.jpoint(null, null, null);
20251
20252   var res = this.curve.jpoint(this.x, this.y, this.curve.one);
20253   return res;
20254 };
20255
20256 function JPoint(curve, x, y, z) {
20257   Base.BasePoint.call(this, curve, 'jacobian');
20258   if (x === null && y === null && z === null) {
20259     this.x = this.curve.one;
20260     this.y = this.curve.one;
20261     this.z = new BN(0);
20262   } else {
20263     this.x = new BN(x, 16);
20264     this.y = new BN(y, 16);
20265     this.z = new BN(z, 16);
20266   }
20267   if (!this.x.red)
20268     this.x = this.x.toRed(this.curve.red);
20269   if (!this.y.red)
20270     this.y = this.y.toRed(this.curve.red);
20271   if (!this.z.red)
20272     this.z = this.z.toRed(this.curve.red);
20273
20274   this.zOne = this.z === this.curve.one;
20275 }
20276 inherits(JPoint, Base.BasePoint);
20277
20278 ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
20279   return new JPoint(this, x, y, z);
20280 };
20281
20282 JPoint.prototype.toP = function toP() {
20283   if (this.isInfinity())
20284     return this.curve.point(null, null);
20285
20286   var zinv = this.z.redInvm();
20287   var zinv2 = zinv.redSqr();
20288   var ax = this.x.redMul(zinv2);
20289   var ay = this.y.redMul(zinv2).redMul(zinv);
20290
20291   return this.curve.point(ax, ay);
20292 };
20293
20294 JPoint.prototype.neg = function neg() {
20295   return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
20296 };
20297
20298 JPoint.prototype.add = function add(p) {
20299   // O + P = P
20300   if (this.isInfinity())
20301     return p;
20302
20303   // P + O = P
20304   if (p.isInfinity())
20305     return this;
20306
20307   // 12M + 4S + 7A
20308   var pz2 = p.z.redSqr();
20309   var z2 = this.z.redSqr();
20310   var u1 = this.x.redMul(pz2);
20311   var u2 = p.x.redMul(z2);
20312   var s1 = this.y.redMul(pz2.redMul(p.z));
20313   var s2 = p.y.redMul(z2.redMul(this.z));
20314
20315   var h = u1.redSub(u2);
20316   var r = s1.redSub(s2);
20317   if (h.cmpn(0) === 0) {
20318     if (r.cmpn(0) !== 0)
20319       return this.curve.jpoint(null, null, null);
20320     else
20321       return this.dbl();
20322   }
20323
20324   var h2 = h.redSqr();
20325   var h3 = h2.redMul(h);
20326   var v = u1.redMul(h2);
20327
20328   var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
20329   var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
20330   var nz = this.z.redMul(p.z).redMul(h);
20331
20332   return this.curve.jpoint(nx, ny, nz);
20333 };
20334
20335 JPoint.prototype.mixedAdd = function mixedAdd(p) {
20336   // O + P = P
20337   if (this.isInfinity())
20338     return p.toJ();
20339
20340   // P + O = P
20341   if (p.isInfinity())
20342     return this;
20343
20344   // 8M + 3S + 7A
20345   var z2 = this.z.redSqr();
20346   var u1 = this.x;
20347   var u2 = p.x.redMul(z2);
20348   var s1 = this.y;
20349   var s2 = p.y.redMul(z2).redMul(this.z);
20350
20351   var h = u1.redSub(u2);
20352   var r = s1.redSub(s2);
20353   if (h.cmpn(0) === 0) {
20354     if (r.cmpn(0) !== 0)
20355       return this.curve.jpoint(null, null, null);
20356     else
20357       return this.dbl();
20358   }
20359
20360   var h2 = h.redSqr();
20361   var h3 = h2.redMul(h);
20362   var v = u1.redMul(h2);
20363
20364   var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
20365   var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
20366   var nz = this.z.redMul(h);
20367
20368   return this.curve.jpoint(nx, ny, nz);
20369 };
20370
20371 JPoint.prototype.dblp = function dblp(pow) {
20372   if (pow === 0)
20373     return this;
20374   if (this.isInfinity())
20375     return this;
20376   if (!pow)
20377     return this.dbl();
20378
20379   if (this.curve.zeroA || this.curve.threeA) {
20380     var r = this;
20381     for (var i = 0; i < pow; i++)
20382       r = r.dbl();
20383     return r;
20384   }
20385
20386   // 1M + 2S + 1A + N * (4S + 5M + 8A)
20387   // N = 1 => 6M + 6S + 9A
20388   var a = this.curve.a;
20389   var tinv = this.curve.tinv;
20390
20391   var jx = this.x;
20392   var jy = this.y;
20393   var jz = this.z;
20394   var jz4 = jz.redSqr().redSqr();
20395
20396   // Reuse results
20397   var jyd = jy.redAdd(jy);
20398   for (var i = 0; i < pow; i++) {
20399     var jx2 = jx.redSqr();
20400     var jyd2 = jyd.redSqr();
20401     var jyd4 = jyd2.redSqr();
20402     var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
20403
20404     var t1 = jx.redMul(jyd2);
20405     var nx = c.redSqr().redISub(t1.redAdd(t1));
20406     var t2 = t1.redISub(nx);
20407     var dny = c.redMul(t2);
20408     dny = dny.redIAdd(dny).redISub(jyd4);
20409     var nz = jyd.redMul(jz);
20410     if (i + 1 < pow)
20411       jz4 = jz4.redMul(jyd4);
20412
20413     jx = nx;
20414     jz = nz;
20415     jyd = dny;
20416   }
20417
20418   return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
20419 };
20420
20421 JPoint.prototype.dbl = function dbl() {
20422   if (this.isInfinity())
20423     return this;
20424
20425   if (this.curve.zeroA)
20426     return this._zeroDbl();
20427   else if (this.curve.threeA)
20428     return this._threeDbl();
20429   else
20430     return this._dbl();
20431 };
20432
20433 JPoint.prototype._zeroDbl = function _zeroDbl() {
20434   var nx;
20435   var ny;
20436   var nz;
20437   // Z = 1
20438   if (this.zOne) {
20439     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
20440     //     #doubling-mdbl-2007-bl
20441     // 1M + 5S + 14A
20442
20443     // XX = X1^2
20444     var xx = this.x.redSqr();
20445     // YY = Y1^2
20446     var yy = this.y.redSqr();
20447     // YYYY = YY^2
20448     var yyyy = yy.redSqr();
20449     // S = 2 * ((X1 + YY)^2 - XX - YYYY)
20450     var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
20451     s = s.redIAdd(s);
20452     // M = 3 * XX + a; a = 0
20453     var m = xx.redAdd(xx).redIAdd(xx);
20454     // T = M ^ 2 - 2*S
20455     var t = m.redSqr().redISub(s).redISub(s);
20456
20457     // 8 * YYYY
20458     var yyyy8 = yyyy.redIAdd(yyyy);
20459     yyyy8 = yyyy8.redIAdd(yyyy8);
20460     yyyy8 = yyyy8.redIAdd(yyyy8);
20461
20462     // X3 = T
20463     nx = t;
20464     // Y3 = M * (S - T) - 8 * YYYY
20465     ny = m.redMul(s.redISub(t)).redISub(yyyy8);
20466     // Z3 = 2*Y1
20467     nz = this.y.redAdd(this.y);
20468   } else {
20469     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
20470     //     #doubling-dbl-2009-l
20471     // 2M + 5S + 13A
20472
20473     // A = X1^2
20474     var a = this.x.redSqr();
20475     // B = Y1^2
20476     var b = this.y.redSqr();
20477     // C = B^2
20478     var c = b.redSqr();
20479     // D = 2 * ((X1 + B)^2 - A - C)
20480     var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
20481     d = d.redIAdd(d);
20482     // E = 3 * A
20483     var e = a.redAdd(a).redIAdd(a);
20484     // F = E^2
20485     var f = e.redSqr();
20486
20487     // 8 * C
20488     var c8 = c.redIAdd(c);
20489     c8 = c8.redIAdd(c8);
20490     c8 = c8.redIAdd(c8);
20491
20492     // X3 = F - 2 * D
20493     nx = f.redISub(d).redISub(d);
20494     // Y3 = E * (D - X3) - 8 * C
20495     ny = e.redMul(d.redISub(nx)).redISub(c8);
20496     // Z3 = 2 * Y1 * Z1
20497     nz = this.y.redMul(this.z);
20498     nz = nz.redIAdd(nz);
20499   }
20500
20501   return this.curve.jpoint(nx, ny, nz);
20502 };
20503
20504 JPoint.prototype._threeDbl = function _threeDbl() {
20505   var nx;
20506   var ny;
20507   var nz;
20508   // Z = 1
20509   if (this.zOne) {
20510     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
20511     //     #doubling-mdbl-2007-bl
20512     // 1M + 5S + 15A
20513
20514     // XX = X1^2
20515     var xx = this.x.redSqr();
20516     // YY = Y1^2
20517     var yy = this.y.redSqr();
20518     // YYYY = YY^2
20519     var yyyy = yy.redSqr();
20520     // S = 2 * ((X1 + YY)^2 - XX - YYYY)
20521     var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
20522     s = s.redIAdd(s);
20523     // M = 3 * XX + a
20524     var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
20525     // T = M^2 - 2 * S
20526     var t = m.redSqr().redISub(s).redISub(s);
20527     // X3 = T
20528     nx = t;
20529     // Y3 = M * (S - T) - 8 * YYYY
20530     var yyyy8 = yyyy.redIAdd(yyyy);
20531     yyyy8 = yyyy8.redIAdd(yyyy8);
20532     yyyy8 = yyyy8.redIAdd(yyyy8);
20533     ny = m.redMul(s.redISub(t)).redISub(yyyy8);
20534     // Z3 = 2 * Y1
20535     nz = this.y.redAdd(this.y);
20536   } else {
20537     // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
20538     // 3M + 5S
20539
20540     // delta = Z1^2
20541     var delta = this.z.redSqr();
20542     // gamma = Y1^2
20543     var gamma = this.y.redSqr();
20544     // beta = X1 * gamma
20545     var beta = this.x.redMul(gamma);
20546     // alpha = 3 * (X1 - delta) * (X1 + delta)
20547     var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
20548     alpha = alpha.redAdd(alpha).redIAdd(alpha);
20549     // X3 = alpha^2 - 8 * beta
20550     var beta4 = beta.redIAdd(beta);
20551     beta4 = beta4.redIAdd(beta4);
20552     var beta8 = beta4.redAdd(beta4);
20553     nx = alpha.redSqr().redISub(beta8);
20554     // Z3 = (Y1 + Z1)^2 - gamma - delta
20555     nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
20556     // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
20557     var ggamma8 = gamma.redSqr();
20558     ggamma8 = ggamma8.redIAdd(ggamma8);
20559     ggamma8 = ggamma8.redIAdd(ggamma8);
20560     ggamma8 = ggamma8.redIAdd(ggamma8);
20561     ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
20562   }
20563
20564   return this.curve.jpoint(nx, ny, nz);
20565 };
20566
20567 JPoint.prototype._dbl = function _dbl() {
20568   var a = this.curve.a;
20569
20570   // 4M + 6S + 10A
20571   var jx = this.x;
20572   var jy = this.y;
20573   var jz = this.z;
20574   var jz4 = jz.redSqr().redSqr();
20575
20576   var jx2 = jx.redSqr();
20577   var jy2 = jy.redSqr();
20578
20579   var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
20580
20581   var jxd4 = jx.redAdd(jx);
20582   jxd4 = jxd4.redIAdd(jxd4);
20583   var t1 = jxd4.redMul(jy2);
20584   var nx = c.redSqr().redISub(t1.redAdd(t1));
20585   var t2 = t1.redISub(nx);
20586
20587   var jyd8 = jy2.redSqr();
20588   jyd8 = jyd8.redIAdd(jyd8);
20589   jyd8 = jyd8.redIAdd(jyd8);
20590   jyd8 = jyd8.redIAdd(jyd8);
20591   var ny = c.redMul(t2).redISub(jyd8);
20592   var nz = jy.redAdd(jy).redMul(jz);
20593
20594   return this.curve.jpoint(nx, ny, nz);
20595 };
20596
20597 JPoint.prototype.trpl = function trpl() {
20598   if (!this.curve.zeroA)
20599     return this.dbl().add(this);
20600
20601   // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
20602   // 5M + 10S + ...
20603
20604   // XX = X1^2
20605   var xx = this.x.redSqr();
20606   // YY = Y1^2
20607   var yy = this.y.redSqr();
20608   // ZZ = Z1^2
20609   var zz = this.z.redSqr();
20610   // YYYY = YY^2
20611   var yyyy = yy.redSqr();
20612   // M = 3 * XX + a * ZZ2; a = 0
20613   var m = xx.redAdd(xx).redIAdd(xx);
20614   // MM = M^2
20615   var mm = m.redSqr();
20616   // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
20617   var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
20618   e = e.redIAdd(e);
20619   e = e.redAdd(e).redIAdd(e);
20620   e = e.redISub(mm);
20621   // EE = E^2
20622   var ee = e.redSqr();
20623   // T = 16*YYYY
20624   var t = yyyy.redIAdd(yyyy);
20625   t = t.redIAdd(t);
20626   t = t.redIAdd(t);
20627   t = t.redIAdd(t);
20628   // U = (M + E)^2 - MM - EE - T
20629   var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
20630   // X3 = 4 * (X1 * EE - 4 * YY * U)
20631   var yyu4 = yy.redMul(u);
20632   yyu4 = yyu4.redIAdd(yyu4);
20633   yyu4 = yyu4.redIAdd(yyu4);
20634   var nx = this.x.redMul(ee).redISub(yyu4);
20635   nx = nx.redIAdd(nx);
20636   nx = nx.redIAdd(nx);
20637   // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
20638   var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
20639   ny = ny.redIAdd(ny);
20640   ny = ny.redIAdd(ny);
20641   ny = ny.redIAdd(ny);
20642   // Z3 = (Z1 + E)^2 - ZZ - EE
20643   var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
20644
20645   return this.curve.jpoint(nx, ny, nz);
20646 };
20647
20648 JPoint.prototype.mul = function mul(k, kbase) {
20649   k = new BN(k, kbase);
20650
20651   return this.curve._wnafMul(this, k);
20652 };
20653
20654 JPoint.prototype.eq = function eq(p) {
20655   if (p.type === 'affine')
20656     return this.eq(p.toJ());
20657
20658   if (this === p)
20659     return true;
20660
20661   // x1 * z2^2 == x2 * z1^2
20662   var z2 = this.z.redSqr();
20663   var pz2 = p.z.redSqr();
20664   if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
20665     return false;
20666
20667   // y1 * z2^3 == y2 * z1^3
20668   var z3 = z2.redMul(this.z);
20669   var pz3 = pz2.redMul(p.z);
20670   return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
20671 };
20672
20673 JPoint.prototype.eqXToP = function eqXToP(x) {
20674   var zs = this.z.redSqr();
20675   var rx = x.toRed(this.curve.red).redMul(zs);
20676   if (this.x.cmp(rx) === 0)
20677     return true;
20678
20679   var xc = x.clone();
20680   var t = this.curve.redN.redMul(zs);
20681   for (;;) {
20682     xc.iadd(this.curve.n);
20683     if (xc.cmp(this.curve.p) >= 0)
20684       return false;
20685
20686     rx.redIAdd(t);
20687     if (this.x.cmp(rx) === 0)
20688       return true;
20689   }
20690 };
20691
20692 JPoint.prototype.inspect = function inspect() {
20693   if (this.isInfinity())
20694     return '<EC JPoint Infinity>';
20695   return '<EC JPoint x: ' + this.x.toString(16, 2) +
20696       ' y: ' + this.y.toString(16, 2) +
20697       ' z: ' + this.z.toString(16, 2) + '>';
20698 };
20699
20700 JPoint.prototype.isInfinity = function isInfinity() {
20701   // XXX This code assumes that zero is always zero in red
20702   return this.z.cmpn(0) === 0;
20703 };
20704
20705
20706 /***/ }),
20707 /* 227 */
20708 /***/ (function(module, exports, __webpack_require__) {
20709
20710 "use strict";
20711
20712
20713 var curve = __webpack_require__(45);
20714 var BN = __webpack_require__(4);
20715 var inherits = __webpack_require__(1);
20716 var Base = curve.base;
20717
20718 var elliptic = __webpack_require__(6);
20719 var utils = elliptic.utils;
20720
20721 function MontCurve(conf) {
20722   Base.call(this, 'mont', conf);
20723
20724   this.a = new BN(conf.a, 16).toRed(this.red);
20725   this.b = new BN(conf.b, 16).toRed(this.red);
20726   this.i4 = new BN(4).toRed(this.red).redInvm();
20727   this.two = new BN(2).toRed(this.red);
20728   this.a24 = this.i4.redMul(this.a.redAdd(this.two));
20729 }
20730 inherits(MontCurve, Base);
20731 module.exports = MontCurve;
20732
20733 MontCurve.prototype.validate = function validate(point) {
20734   var x = point.normalize().x;
20735   var x2 = x.redSqr();
20736   var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
20737   var y = rhs.redSqrt();
20738
20739   return y.redSqr().cmp(rhs) === 0;
20740 };
20741
20742 function Point(curve, x, z) {
20743   Base.BasePoint.call(this, curve, 'projective');
20744   if (x === null && z === null) {
20745     this.x = this.curve.one;
20746     this.z = this.curve.zero;
20747   } else {
20748     this.x = new BN(x, 16);
20749     this.z = new BN(z, 16);
20750     if (!this.x.red)
20751       this.x = this.x.toRed(this.curve.red);
20752     if (!this.z.red)
20753       this.z = this.z.toRed(this.curve.red);
20754   }
20755 }
20756 inherits(Point, Base.BasePoint);
20757
20758 MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
20759   return this.point(utils.toArray(bytes, enc), 1);
20760 };
20761
20762 MontCurve.prototype.point = function point(x, z) {
20763   return new Point(this, x, z);
20764 };
20765
20766 MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
20767   return Point.fromJSON(this, obj);
20768 };
20769
20770 Point.prototype.precompute = function precompute() {
20771   // No-op
20772 };
20773
20774 Point.prototype._encode = function _encode() {
20775   return this.getX().toArray('be', this.curve.p.byteLength());
20776 };
20777
20778 Point.fromJSON = function fromJSON(curve, obj) {
20779   return new Point(curve, obj[0], obj[1] || curve.one);
20780 };
20781
20782 Point.prototype.inspect = function inspect() {
20783   if (this.isInfinity())
20784     return '<EC Point Infinity>';
20785   return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
20786       ' z: ' + this.z.fromRed().toString(16, 2) + '>';
20787 };
20788
20789 Point.prototype.isInfinity = function isInfinity() {
20790   // XXX This code assumes that zero is always zero in red
20791   return this.z.cmpn(0) === 0;
20792 };
20793
20794 Point.prototype.dbl = function dbl() {
20795   // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
20796   // 2M + 2S + 4A
20797
20798   // A = X1 + Z1
20799   var a = this.x.redAdd(this.z);
20800   // AA = A^2
20801   var aa = a.redSqr();
20802   // B = X1 - Z1
20803   var b = this.x.redSub(this.z);
20804   // BB = B^2
20805   var bb = b.redSqr();
20806   // C = AA - BB
20807   var c = aa.redSub(bb);
20808   // X3 = AA * BB
20809   var nx = aa.redMul(bb);
20810   // Z3 = C * (BB + A24 * C)
20811   var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
20812   return this.curve.point(nx, nz);
20813 };
20814
20815 Point.prototype.add = function add() {
20816   throw new Error('Not supported on Montgomery curve');
20817 };
20818
20819 Point.prototype.diffAdd = function diffAdd(p, diff) {
20820   // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
20821   // 4M + 2S + 6A
20822
20823   // A = X2 + Z2
20824   var a = this.x.redAdd(this.z);
20825   // B = X2 - Z2
20826   var b = this.x.redSub(this.z);
20827   // C = X3 + Z3
20828   var c = p.x.redAdd(p.z);
20829   // D = X3 - Z3
20830   var d = p.x.redSub(p.z);
20831   // DA = D * A
20832   var da = d.redMul(a);
20833   // CB = C * B
20834   var cb = c.redMul(b);
20835   // X5 = Z1 * (DA + CB)^2
20836   var nx = diff.z.redMul(da.redAdd(cb).redSqr());
20837   // Z5 = X1 * (DA - CB)^2
20838   var nz = diff.x.redMul(da.redISub(cb).redSqr());
20839   return this.curve.point(nx, nz);
20840 };
20841
20842 Point.prototype.mul = function mul(k) {
20843   var t = k.clone();
20844   var a = this; // (N / 2) * Q + Q
20845   var b = this.curve.point(null, null); // (N / 2) * Q
20846   var c = this; // Q
20847
20848   for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
20849     bits.push(t.andln(1));
20850
20851   for (var i = bits.length - 1; i >= 0; i--) {
20852     if (bits[i] === 0) {
20853       // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
20854       a = a.diffAdd(b, c);
20855       // N * Q = 2 * ((N / 2) * Q + Q))
20856       b = b.dbl();
20857     } else {
20858       // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
20859       b = a.diffAdd(b, c);
20860       // N * Q + Q = 2 * ((N / 2) * Q + Q)
20861       a = a.dbl();
20862     }
20863   }
20864   return b;
20865 };
20866
20867 Point.prototype.mulAdd = function mulAdd() {
20868   throw new Error('Not supported on Montgomery curve');
20869 };
20870
20871 Point.prototype.jumlAdd = function jumlAdd() {
20872   throw new Error('Not supported on Montgomery curve');
20873 };
20874
20875 Point.prototype.eq = function eq(other) {
20876   return this.getX().cmp(other.getX()) === 0;
20877 };
20878
20879 Point.prototype.normalize = function normalize() {
20880   this.x = this.x.redMul(this.z.redInvm());
20881   this.z = this.curve.one;
20882   return this;
20883 };
20884
20885 Point.prototype.getX = function getX() {
20886   // Normalize coordinates
20887   this.normalize();
20888
20889   return this.x.fromRed();
20890 };
20891
20892
20893 /***/ }),
20894 /* 228 */
20895 /***/ (function(module, exports, __webpack_require__) {
20896
20897 "use strict";
20898
20899
20900 var curve = __webpack_require__(45);
20901 var elliptic = __webpack_require__(6);
20902 var BN = __webpack_require__(4);
20903 var inherits = __webpack_require__(1);
20904 var Base = curve.base;
20905
20906 var assert = elliptic.utils.assert;
20907
20908 function EdwardsCurve(conf) {
20909   // NOTE: Important as we are creating point in Base.call()
20910   this.twisted = (conf.a | 0) !== 1;
20911   this.mOneA = this.twisted && (conf.a | 0) === -1;
20912   this.extended = this.mOneA;
20913
20914   Base.call(this, 'edwards', conf);
20915
20916   this.a = new BN(conf.a, 16).umod(this.red.m);
20917   this.a = this.a.toRed(this.red);
20918   this.c = new BN(conf.c, 16).toRed(this.red);
20919   this.c2 = this.c.redSqr();
20920   this.d = new BN(conf.d, 16).toRed(this.red);
20921   this.dd = this.d.redAdd(this.d);
20922
20923   assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
20924   this.oneC = (conf.c | 0) === 1;
20925 }
20926 inherits(EdwardsCurve, Base);
20927 module.exports = EdwardsCurve;
20928
20929 EdwardsCurve.prototype._mulA = function _mulA(num) {
20930   if (this.mOneA)
20931     return num.redNeg();
20932   else
20933     return this.a.redMul(num);
20934 };
20935
20936 EdwardsCurve.prototype._mulC = function _mulC(num) {
20937   if (this.oneC)
20938     return num;
20939   else
20940     return this.c.redMul(num);
20941 };
20942
20943 // Just for compatibility with Short curve
20944 EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
20945   return this.point(x, y, z, t);
20946 };
20947
20948 EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
20949   x = new BN(x, 16);
20950   if (!x.red)
20951     x = x.toRed(this.red);
20952
20953   var x2 = x.redSqr();
20954   var rhs = this.c2.redSub(this.a.redMul(x2));
20955   var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
20956
20957   var y2 = rhs.redMul(lhs.redInvm());
20958   var y = y2.redSqrt();
20959   if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
20960     throw new Error('invalid point');
20961
20962   var isOdd = y.fromRed().isOdd();
20963   if (odd && !isOdd || !odd && isOdd)
20964     y = y.redNeg();
20965
20966   return this.point(x, y);
20967 };
20968
20969 EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
20970   y = new BN(y, 16);
20971   if (!y.red)
20972     y = y.toRed(this.red);
20973
20974   // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
20975   var y2 = y.redSqr();
20976   var lhs = y2.redSub(this.c2);
20977   var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
20978   var x2 = lhs.redMul(rhs.redInvm());
20979
20980   if (x2.cmp(this.zero) === 0) {
20981     if (odd)
20982       throw new Error('invalid point');
20983     else
20984       return this.point(this.zero, y);
20985   }
20986
20987   var x = x2.redSqrt();
20988   if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
20989     throw new Error('invalid point');
20990
20991   if (x.fromRed().isOdd() !== odd)
20992     x = x.redNeg();
20993
20994   return this.point(x, y);
20995 };
20996
20997 EdwardsCurve.prototype.validate = function validate(point) {
20998   if (point.isInfinity())
20999     return true;
21000
21001   // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
21002   point.normalize();
21003
21004   var x2 = point.x.redSqr();
21005   var y2 = point.y.redSqr();
21006   var lhs = x2.redMul(this.a).redAdd(y2);
21007   var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
21008
21009   return lhs.cmp(rhs) === 0;
21010 };
21011
21012 function Point(curve, x, y, z, t) {
21013   Base.BasePoint.call(this, curve, 'projective');
21014   if (x === null && y === null && z === null) {
21015     this.x = this.curve.zero;
21016     this.y = this.curve.one;
21017     this.z = this.curve.one;
21018     this.t = this.curve.zero;
21019     this.zOne = true;
21020   } else {
21021     this.x = new BN(x, 16);
21022     this.y = new BN(y, 16);
21023     this.z = z ? new BN(z, 16) : this.curve.one;
21024     this.t = t && new BN(t, 16);
21025     if (!this.x.red)
21026       this.x = this.x.toRed(this.curve.red);
21027     if (!this.y.red)
21028       this.y = this.y.toRed(this.curve.red);
21029     if (!this.z.red)
21030       this.z = this.z.toRed(this.curve.red);
21031     if (this.t && !this.t.red)
21032       this.t = this.t.toRed(this.curve.red);
21033     this.zOne = this.z === this.curve.one;
21034
21035     // Use extended coordinates
21036     if (this.curve.extended && !this.t) {
21037       this.t = this.x.redMul(this.y);
21038       if (!this.zOne)
21039         this.t = this.t.redMul(this.z.redInvm());
21040     }
21041   }
21042 }
21043 inherits(Point, Base.BasePoint);
21044
21045 EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
21046   return Point.fromJSON(this, obj);
21047 };
21048
21049 EdwardsCurve.prototype.point = function point(x, y, z, t) {
21050   return new Point(this, x, y, z, t);
21051 };
21052
21053 Point.fromJSON = function fromJSON(curve, obj) {
21054   return new Point(curve, obj[0], obj[1], obj[2]);
21055 };
21056
21057 Point.prototype.inspect = function inspect() {
21058   if (this.isInfinity())
21059     return '<EC Point Infinity>';
21060   return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
21061       ' y: ' + this.y.fromRed().toString(16, 2) +
21062       ' z: ' + this.z.fromRed().toString(16, 2) + '>';
21063 };
21064
21065 Point.prototype.isInfinity = function isInfinity() {
21066   // XXX This code assumes that zero is always zero in red
21067   return this.x.cmpn(0) === 0 &&
21068     (this.y.cmp(this.z) === 0 ||
21069     (this.zOne && this.y.cmp(this.curve.c) === 0));
21070 };
21071
21072 Point.prototype._extDbl = function _extDbl() {
21073   // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
21074   //     #doubling-dbl-2008-hwcd
21075   // 4M + 4S
21076
21077   // A = X1^2
21078   var a = this.x.redSqr();
21079   // B = Y1^2
21080   var b = this.y.redSqr();
21081   // C = 2 * Z1^2
21082   var c = this.z.redSqr();
21083   c = c.redIAdd(c);
21084   // D = a * A
21085   var d = this.curve._mulA(a);
21086   // E = (X1 + Y1)^2 - A - B
21087   var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
21088   // G = D + B
21089   var g = d.redAdd(b);
21090   // F = G - C
21091   var f = g.redSub(c);
21092   // H = D - B
21093   var h = d.redSub(b);
21094   // X3 = E * F
21095   var nx = e.redMul(f);
21096   // Y3 = G * H
21097   var ny = g.redMul(h);
21098   // T3 = E * H
21099   var nt = e.redMul(h);
21100   // Z3 = F * G
21101   var nz = f.redMul(g);
21102   return this.curve.point(nx, ny, nz, nt);
21103 };
21104
21105 Point.prototype._projDbl = function _projDbl() {
21106   // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
21107   //     #doubling-dbl-2008-bbjlp
21108   //     #doubling-dbl-2007-bl
21109   // and others
21110   // Generally 3M + 4S or 2M + 4S
21111
21112   // B = (X1 + Y1)^2
21113   var b = this.x.redAdd(this.y).redSqr();
21114   // C = X1^2
21115   var c = this.x.redSqr();
21116   // D = Y1^2
21117   var d = this.y.redSqr();
21118
21119   var nx;
21120   var ny;
21121   var nz;
21122   if (this.curve.twisted) {
21123     // E = a * C
21124     var e = this.curve._mulA(c);
21125     // F = E + D
21126     var f = e.redAdd(d);
21127     if (this.zOne) {
21128       // X3 = (B - C - D) * (F - 2)
21129       nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
21130       // Y3 = F * (E - D)
21131       ny = f.redMul(e.redSub(d));
21132       // Z3 = F^2 - 2 * F
21133       nz = f.redSqr().redSub(f).redSub(f);
21134     } else {
21135       // H = Z1^2
21136       var h = this.z.redSqr();
21137       // J = F - 2 * H
21138       var j = f.redSub(h).redISub(h);
21139       // X3 = (B-C-D)*J
21140       nx = b.redSub(c).redISub(d).redMul(j);
21141       // Y3 = F * (E - D)
21142       ny = f.redMul(e.redSub(d));
21143       // Z3 = F * J
21144       nz = f.redMul(j);
21145     }
21146   } else {
21147     // E = C + D
21148     var e = c.redAdd(d);
21149     // H = (c * Z1)^2
21150     var h = this.curve._mulC(this.z).redSqr();
21151     // J = E - 2 * H
21152     var j = e.redSub(h).redSub(h);
21153     // X3 = c * (B - E) * J
21154     nx = this.curve._mulC(b.redISub(e)).redMul(j);
21155     // Y3 = c * E * (C - D)
21156     ny = this.curve._mulC(e).redMul(c.redISub(d));
21157     // Z3 = E * J
21158     nz = e.redMul(j);
21159   }
21160   return this.curve.point(nx, ny, nz);
21161 };
21162
21163 Point.prototype.dbl = function dbl() {
21164   if (this.isInfinity())
21165     return this;
21166
21167   // Double in extended coordinates
21168   if (this.curve.extended)
21169     return this._extDbl();
21170   else
21171     return this._projDbl();
21172 };
21173
21174 Point.prototype._extAdd = function _extAdd(p) {
21175   // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
21176   //     #addition-add-2008-hwcd-3
21177   // 8M
21178
21179   // A = (Y1 - X1) * (Y2 - X2)
21180   var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
21181   // B = (Y1 + X1) * (Y2 + X2)
21182   var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
21183   // C = T1 * k * T2
21184   var c = this.t.redMul(this.curve.dd).redMul(p.t);
21185   // D = Z1 * 2 * Z2
21186   var d = this.z.redMul(p.z.redAdd(p.z));
21187   // E = B - A
21188   var e = b.redSub(a);
21189   // F = D - C
21190   var f = d.redSub(c);
21191   // G = D + C
21192   var g = d.redAdd(c);
21193   // H = B + A
21194   var h = b.redAdd(a);
21195   // X3 = E * F
21196   var nx = e.redMul(f);
21197   // Y3 = G * H
21198   var ny = g.redMul(h);
21199   // T3 = E * H
21200   var nt = e.redMul(h);
21201   // Z3 = F * G
21202   var nz = f.redMul(g);
21203   return this.curve.point(nx, ny, nz, nt);
21204 };
21205
21206 Point.prototype._projAdd = function _projAdd(p) {
21207   // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
21208   //     #addition-add-2008-bbjlp
21209   //     #addition-add-2007-bl
21210   // 10M + 1S
21211
21212   // A = Z1 * Z2
21213   var a = this.z.redMul(p.z);
21214   // B = A^2
21215   var b = a.redSqr();
21216   // C = X1 * X2
21217   var c = this.x.redMul(p.x);
21218   // D = Y1 * Y2
21219   var d = this.y.redMul(p.y);
21220   // E = d * C * D
21221   var e = this.curve.d.redMul(c).redMul(d);
21222   // F = B - E
21223   var f = b.redSub(e);
21224   // G = B + E
21225   var g = b.redAdd(e);
21226   // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
21227   var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
21228   var nx = a.redMul(f).redMul(tmp);
21229   var ny;
21230   var nz;
21231   if (this.curve.twisted) {
21232     // Y3 = A * G * (D - a * C)
21233     ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
21234     // Z3 = F * G
21235     nz = f.redMul(g);
21236   } else {
21237     // Y3 = A * G * (D - C)
21238     ny = a.redMul(g).redMul(d.redSub(c));
21239     // Z3 = c * F * G
21240     nz = this.curve._mulC(f).redMul(g);
21241   }
21242   return this.curve.point(nx, ny, nz);
21243 };
21244
21245 Point.prototype.add = function add(p) {
21246   if (this.isInfinity())
21247     return p;
21248   if (p.isInfinity())
21249     return this;
21250
21251   if (this.curve.extended)
21252     return this._extAdd(p);
21253   else
21254     return this._projAdd(p);
21255 };
21256
21257 Point.prototype.mul = function mul(k) {
21258   if (this._hasDoubles(k))
21259     return this.curve._fixedNafMul(this, k);
21260   else
21261     return this.curve._wnafMul(this, k);
21262 };
21263
21264 Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
21265   return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
21266 };
21267
21268 Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
21269   return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
21270 };
21271
21272 Point.prototype.normalize = function normalize() {
21273   if (this.zOne)
21274     return this;
21275
21276   // Normalize coordinates
21277   var zi = this.z.redInvm();
21278   this.x = this.x.redMul(zi);
21279   this.y = this.y.redMul(zi);
21280   if (this.t)
21281     this.t = this.t.redMul(zi);
21282   this.z = this.curve.one;
21283   this.zOne = true;
21284   return this;
21285 };
21286
21287 Point.prototype.neg = function neg() {
21288   return this.curve.point(this.x.redNeg(),
21289                           this.y,
21290                           this.z,
21291                           this.t && this.t.redNeg());
21292 };
21293
21294 Point.prototype.getX = function getX() {
21295   this.normalize();
21296   return this.x.fromRed();
21297 };
21298
21299 Point.prototype.getY = function getY() {
21300   this.normalize();
21301   return this.y.fromRed();
21302 };
21303
21304 Point.prototype.eq = function eq(other) {
21305   return this === other ||
21306          this.getX().cmp(other.getX()) === 0 &&
21307          this.getY().cmp(other.getY()) === 0;
21308 };
21309
21310 Point.prototype.eqXToP = function eqXToP(x) {
21311   var rx = x.toRed(this.curve.red).redMul(this.z);
21312   if (this.x.cmp(rx) === 0)
21313     return true;
21314
21315   var xc = x.clone();
21316   var t = this.curve.redN.redMul(this.z);
21317   for (;;) {
21318     xc.iadd(this.curve.n);
21319     if (xc.cmp(this.curve.p) >= 0)
21320       return false;
21321
21322     rx.redIAdd(t);
21323     if (this.x.cmp(rx) === 0)
21324       return true;
21325   }
21326 };
21327
21328 // Compatibility with BaseCurve
21329 Point.prototype.toP = Point.prototype.normalize;
21330 Point.prototype.mixedAdd = Point.prototype.add;
21331
21332
21333 /***/ }),
21334 /* 229 */
21335 /***/ (function(module, exports, __webpack_require__) {
21336
21337 "use strict";
21338
21339
21340 var curves = exports;
21341
21342 var hash = __webpack_require__(68);
21343 var elliptic = __webpack_require__(6);
21344
21345 var assert = elliptic.utils.assert;
21346
21347 function PresetCurve(options) {
21348   if (options.type === 'short')
21349     this.curve = new elliptic.curve.short(options);
21350   else if (options.type === 'edwards')
21351     this.curve = new elliptic.curve.edwards(options);
21352   else
21353     this.curve = new elliptic.curve.mont(options);
21354   this.g = this.curve.g;
21355   this.n = this.curve.n;
21356   this.hash = options.hash;
21357
21358   assert(this.g.validate(), 'Invalid curve');
21359   assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
21360 }
21361 curves.PresetCurve = PresetCurve;
21362
21363 function defineCurve(name, options) {
21364   Object.defineProperty(curves, name, {
21365     configurable: true,
21366     enumerable: true,
21367     get: function() {
21368       var curve = new PresetCurve(options);
21369       Object.defineProperty(curves, name, {
21370         configurable: true,
21371         enumerable: true,
21372         value: curve
21373       });
21374       return curve;
21375     }
21376   });
21377 }
21378
21379 defineCurve('p192', {
21380   type: 'short',
21381   prime: 'p192',
21382   p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
21383   a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
21384   b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
21385   n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
21386   hash: hash.sha256,
21387   gRed: false,
21388   g: [
21389     '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
21390     '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
21391   ]
21392 });
21393
21394 defineCurve('p224', {
21395   type: 'short',
21396   prime: 'p224',
21397   p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
21398   a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
21399   b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
21400   n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
21401   hash: hash.sha256,
21402   gRed: false,
21403   g: [
21404     'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
21405     'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
21406   ]
21407 });
21408
21409 defineCurve('p256', {
21410   type: 'short',
21411   prime: null,
21412   p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
21413   a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
21414   b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
21415   n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
21416   hash: hash.sha256,
21417   gRed: false,
21418   g: [
21419     '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
21420     '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
21421   ]
21422 });
21423
21424 defineCurve('p384', {
21425   type: 'short',
21426   prime: null,
21427   p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21428      'fffffffe ffffffff 00000000 00000000 ffffffff',
21429   a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21430      'fffffffe ffffffff 00000000 00000000 fffffffc',
21431   b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
21432      '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
21433   n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
21434      'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
21435   hash: hash.sha384,
21436   gRed: false,
21437   g: [
21438     'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
21439     '5502f25d bf55296c 3a545e38 72760ab7',
21440     '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
21441     '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
21442   ]
21443 });
21444
21445 defineCurve('p521', {
21446   type: 'short',
21447   prime: null,
21448   p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21449      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21450      'ffffffff ffffffff ffffffff ffffffff ffffffff',
21451   a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21452      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21453      'ffffffff ffffffff ffffffff ffffffff fffffffc',
21454   b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
21455      '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
21456      '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
21457   n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
21458      'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
21459      'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
21460   hash: hash.sha512,
21461   gRed: false,
21462   g: [
21463     '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
21464     '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
21465     'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
21466     '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
21467     '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
21468     '3fad0761 353c7086 a272c240 88be9476 9fd16650'
21469   ]
21470 });
21471
21472 defineCurve('curve25519', {
21473   type: 'mont',
21474   prime: 'p25519',
21475   p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
21476   a: '76d06',
21477   b: '1',
21478   n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
21479   hash: hash.sha256,
21480   gRed: false,
21481   g: [
21482     '9'
21483   ]
21484 });
21485
21486 defineCurve('ed25519', {
21487   type: 'edwards',
21488   prime: 'p25519',
21489   p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
21490   a: '-1',
21491   c: '1',
21492   // -121665 * (121666^(-1)) (mod P)
21493   d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
21494   n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
21495   hash: hash.sha256,
21496   gRed: false,
21497   g: [
21498     '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
21499
21500     // 4/5
21501     '6666666666666666666666666666666666666666666666666666666666666658'
21502   ]
21503 });
21504
21505 var pre;
21506 try {
21507   pre = __webpack_require__(236);
21508 } catch (e) {
21509   pre = undefined;
21510 }
21511
21512 defineCurve('secp256k1', {
21513   type: 'short',
21514   prime: 'k256',
21515   p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
21516   a: '0',
21517   b: '7',
21518   n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
21519   h: '1',
21520   hash: hash.sha256,
21521
21522   // Precomputed endomorphism
21523   beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
21524   lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
21525   basis: [
21526     {
21527       a: '3086d221a7d46bcde86c90e49284eb15',
21528       b: '-e4437ed6010e88286f547fa90abfe4c3'
21529     },
21530     {
21531       a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
21532       b: '3086d221a7d46bcde86c90e49284eb15'
21533     }
21534   ],
21535
21536   gRed: false,
21537   g: [
21538     '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
21539     '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
21540     pre
21541   ]
21542 });
21543
21544
21545 /***/ }),
21546 /* 230 */
21547 /***/ (function(module, exports, __webpack_require__) {
21548
21549 "use strict";
21550
21551
21552 exports.sha1 = __webpack_require__(231);
21553 exports.sha224 = __webpack_require__(232);
21554 exports.sha256 = __webpack_require__(118);
21555 exports.sha384 = __webpack_require__(233);
21556 exports.sha512 = __webpack_require__(119);
21557
21558
21559 /***/ }),
21560 /* 231 */
21561 /***/ (function(module, exports, __webpack_require__) {
21562
21563 "use strict";
21564
21565
21566 var utils = __webpack_require__(11);
21567 var common = __webpack_require__(32);
21568 var shaCommon = __webpack_require__(117);
21569
21570 var rotl32 = utils.rotl32;
21571 var sum32 = utils.sum32;
21572 var sum32_5 = utils.sum32_5;
21573 var ft_1 = shaCommon.ft_1;
21574 var BlockHash = common.BlockHash;
21575
21576 var sha1_K = [
21577   0x5A827999, 0x6ED9EBA1,
21578   0x8F1BBCDC, 0xCA62C1D6
21579 ];
21580
21581 function SHA1() {
21582   if (!(this instanceof SHA1))
21583     return new SHA1();
21584
21585   BlockHash.call(this);
21586   this.h = [
21587     0x67452301, 0xefcdab89, 0x98badcfe,
21588     0x10325476, 0xc3d2e1f0 ];
21589   this.W = new Array(80);
21590 }
21591
21592 utils.inherits(SHA1, BlockHash);
21593 module.exports = SHA1;
21594
21595 SHA1.blockSize = 512;
21596 SHA1.outSize = 160;
21597 SHA1.hmacStrength = 80;
21598 SHA1.padLength = 64;
21599
21600 SHA1.prototype._update = function _update(msg, start) {
21601   var W = this.W;
21602
21603   for (var i = 0; i < 16; i++)
21604     W[i] = msg[start + i];
21605
21606   for(; i < W.length; i++)
21607     W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
21608
21609   var a = this.h[0];
21610   var b = this.h[1];
21611   var c = this.h[2];
21612   var d = this.h[3];
21613   var e = this.h[4];
21614
21615   for (i = 0; i < W.length; i++) {
21616     var s = ~~(i / 20);
21617     var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
21618     e = d;
21619     d = c;
21620     c = rotl32(b, 30);
21621     b = a;
21622     a = t;
21623   }
21624
21625   this.h[0] = sum32(this.h[0], a);
21626   this.h[1] = sum32(this.h[1], b);
21627   this.h[2] = sum32(this.h[2], c);
21628   this.h[3] = sum32(this.h[3], d);
21629   this.h[4] = sum32(this.h[4], e);
21630 };
21631
21632 SHA1.prototype._digest = function digest(enc) {
21633   if (enc === 'hex')
21634     return utils.toHex32(this.h, 'big');
21635   else
21636     return utils.split32(this.h, 'big');
21637 };
21638
21639
21640 /***/ }),
21641 /* 232 */
21642 /***/ (function(module, exports, __webpack_require__) {
21643
21644 "use strict";
21645
21646
21647 var utils = __webpack_require__(11);
21648 var SHA256 = __webpack_require__(118);
21649
21650 function SHA224() {
21651   if (!(this instanceof SHA224))
21652     return new SHA224();
21653
21654   SHA256.call(this);
21655   this.h = [
21656     0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
21657     0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
21658 }
21659 utils.inherits(SHA224, SHA256);
21660 module.exports = SHA224;
21661
21662 SHA224.blockSize = 512;
21663 SHA224.outSize = 224;
21664 SHA224.hmacStrength = 192;
21665 SHA224.padLength = 64;
21666
21667 SHA224.prototype._digest = function digest(enc) {
21668   // Just truncate output
21669   if (enc === 'hex')
21670     return utils.toHex32(this.h.slice(0, 7), 'big');
21671   else
21672     return utils.split32(this.h.slice(0, 7), 'big');
21673 };
21674
21675
21676
21677 /***/ }),
21678 /* 233 */
21679 /***/ (function(module, exports, __webpack_require__) {
21680
21681 "use strict";
21682
21683
21684 var utils = __webpack_require__(11);
21685
21686 var SHA512 = __webpack_require__(119);
21687
21688 function SHA384() {
21689   if (!(this instanceof SHA384))
21690     return new SHA384();
21691
21692   SHA512.call(this);
21693   this.h = [
21694     0xcbbb9d5d, 0xc1059ed8,
21695     0x629a292a, 0x367cd507,
21696     0x9159015a, 0x3070dd17,
21697     0x152fecd8, 0xf70e5939,
21698     0x67332667, 0xffc00b31,
21699     0x8eb44a87, 0x68581511,
21700     0xdb0c2e0d, 0x64f98fa7,
21701     0x47b5481d, 0xbefa4fa4 ];
21702 }
21703 utils.inherits(SHA384, SHA512);
21704 module.exports = SHA384;
21705
21706 SHA384.blockSize = 1024;
21707 SHA384.outSize = 384;
21708 SHA384.hmacStrength = 192;
21709 SHA384.padLength = 128;
21710
21711 SHA384.prototype._digest = function digest(enc) {
21712   if (enc === 'hex')
21713     return utils.toHex32(this.h.slice(0, 12), 'big');
21714   else
21715     return utils.split32(this.h.slice(0, 12), 'big');
21716 };
21717
21718
21719 /***/ }),
21720 /* 234 */
21721 /***/ (function(module, exports, __webpack_require__) {
21722
21723 "use strict";
21724
21725
21726 var utils = __webpack_require__(11);
21727 var common = __webpack_require__(32);
21728
21729 var rotl32 = utils.rotl32;
21730 var sum32 = utils.sum32;
21731 var sum32_3 = utils.sum32_3;
21732 var sum32_4 = utils.sum32_4;
21733 var BlockHash = common.BlockHash;
21734
21735 function RIPEMD160() {
21736   if (!(this instanceof RIPEMD160))
21737     return new RIPEMD160();
21738
21739   BlockHash.call(this);
21740
21741   this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
21742   this.endian = 'little';
21743 }
21744 utils.inherits(RIPEMD160, BlockHash);
21745 exports.ripemd160 = RIPEMD160;
21746
21747 RIPEMD160.blockSize = 512;
21748 RIPEMD160.outSize = 160;
21749 RIPEMD160.hmacStrength = 192;
21750 RIPEMD160.padLength = 64;
21751
21752 RIPEMD160.prototype._update = function update(msg, start) {
21753   var A = this.h[0];
21754   var B = this.h[1];
21755   var C = this.h[2];
21756   var D = this.h[3];
21757   var E = this.h[4];
21758   var Ah = A;
21759   var Bh = B;
21760   var Ch = C;
21761   var Dh = D;
21762   var Eh = E;
21763   for (var j = 0; j < 80; j++) {
21764     var T = sum32(
21765       rotl32(
21766         sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
21767         s[j]),
21768       E);
21769     A = E;
21770     E = D;
21771     D = rotl32(C, 10);
21772     C = B;
21773     B = T;
21774     T = sum32(
21775       rotl32(
21776         sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
21777         sh[j]),
21778       Eh);
21779     Ah = Eh;
21780     Eh = Dh;
21781     Dh = rotl32(Ch, 10);
21782     Ch = Bh;
21783     Bh = T;
21784   }
21785   T = sum32_3(this.h[1], C, Dh);
21786   this.h[1] = sum32_3(this.h[2], D, Eh);
21787   this.h[2] = sum32_3(this.h[3], E, Ah);
21788   this.h[3] = sum32_3(this.h[4], A, Bh);
21789   this.h[4] = sum32_3(this.h[0], B, Ch);
21790   this.h[0] = T;
21791 };
21792
21793 RIPEMD160.prototype._digest = function digest(enc) {
21794   if (enc === 'hex')
21795     return utils.toHex32(this.h, 'little');
21796   else
21797     return utils.split32(this.h, 'little');
21798 };
21799
21800 function f(j, x, y, z) {
21801   if (j <= 15)
21802     return x ^ y ^ z;
21803   else if (j <= 31)
21804     return (x & y) | ((~x) & z);
21805   else if (j <= 47)
21806     return (x | (~y)) ^ z;
21807   else if (j <= 63)
21808     return (x & z) | (y & (~z));
21809   else
21810     return x ^ (y | (~z));
21811 }
21812
21813 function K(j) {
21814   if (j <= 15)
21815     return 0x00000000;
21816   else if (j <= 31)
21817     return 0x5a827999;
21818   else if (j <= 47)
21819     return 0x6ed9eba1;
21820   else if (j <= 63)
21821     return 0x8f1bbcdc;
21822   else
21823     return 0xa953fd4e;
21824 }
21825
21826 function Kh(j) {
21827   if (j <= 15)
21828     return 0x50a28be6;
21829   else if (j <= 31)
21830     return 0x5c4dd124;
21831   else if (j <= 47)
21832     return 0x6d703ef3;
21833   else if (j <= 63)
21834     return 0x7a6d76e9;
21835   else
21836     return 0x00000000;
21837 }
21838
21839 var r = [
21840   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
21841   7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
21842   3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
21843   1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
21844   4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
21845 ];
21846
21847 var rh = [
21848   5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
21849   6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
21850   15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
21851   8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
21852   12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
21853 ];
21854
21855 var s = [
21856   11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
21857   7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
21858   11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
21859   11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
21860   9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
21861 ];
21862
21863 var sh = [
21864   8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
21865   9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
21866   9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
21867   15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
21868   8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
21869 ];
21870
21871
21872 /***/ }),
21873 /* 235 */
21874 /***/ (function(module, exports, __webpack_require__) {
21875
21876 "use strict";
21877
21878
21879 var utils = __webpack_require__(11);
21880 var assert = __webpack_require__(9);
21881
21882 function Hmac(hash, key, enc) {
21883   if (!(this instanceof Hmac))
21884     return new Hmac(hash, key, enc);
21885   this.Hash = hash;
21886   this.blockSize = hash.blockSize / 8;
21887   this.outSize = hash.outSize / 8;
21888   this.inner = null;
21889   this.outer = null;
21890
21891   this._init(utils.toArray(key, enc));
21892 }
21893 module.exports = Hmac;
21894
21895 Hmac.prototype._init = function init(key) {
21896   // Shorten key, if needed
21897   if (key.length > this.blockSize)
21898     key = new this.Hash().update(key).digest();
21899   assert(key.length <= this.blockSize);
21900
21901   // Add padding to key
21902   for (var i = key.length; i < this.blockSize; i++)
21903     key.push(0);
21904
21905   for (i = 0; i < key.length; i++)
21906     key[i] ^= 0x36;
21907   this.inner = new this.Hash().update(key);
21908
21909   // 0x36 ^ 0x5c = 0x6a
21910   for (i = 0; i < key.length; i++)
21911     key[i] ^= 0x6a;
21912   this.outer = new this.Hash().update(key);
21913 };
21914
21915 Hmac.prototype.update = function update(msg, enc) {
21916   this.inner.update(msg, enc);
21917   return this;
21918 };
21919
21920 Hmac.prototype.digest = function digest(enc) {
21921   this.outer.update(this.inner.digest());
21922   return this.outer.digest(enc);
21923 };
21924
21925
21926 /***/ }),
21927 /* 236 */
21928 /***/ (function(module, exports) {
21929
21930 module.exports = {
21931   doubles: {
21932     step: 4,
21933     points: [
21934       [
21935         'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
21936         'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
21937       ],
21938       [
21939         '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
21940         '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
21941       ],
21942       [
21943         '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
21944         'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
21945       ],
21946       [
21947         '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
21948         '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
21949       ],
21950       [
21951         '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
21952         '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
21953       ],
21954       [
21955         '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
21956         '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
21957       ],
21958       [
21959         'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
21960         '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
21961       ],
21962       [
21963         '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
21964         'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
21965       ],
21966       [
21967         'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
21968         '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
21969       ],
21970       [
21971         'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
21972         'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
21973       ],
21974       [
21975         'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
21976         '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
21977       ],
21978       [
21979         '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
21980         '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
21981       ],
21982       [
21983         '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
21984         '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
21985       ],
21986       [
21987         '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
21988         '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
21989       ],
21990       [
21991         '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
21992         '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
21993       ],
21994       [
21995         '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
21996         '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
21997       ],
21998       [
21999         '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
22000         '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
22001       ],
22002       [
22003         '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
22004         '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
22005       ],
22006       [
22007         '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
22008         'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
22009       ],
22010       [
22011         'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
22012         '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
22013       ],
22014       [
22015         'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
22016         '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
22017       ],
22018       [
22019         '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
22020         '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
22021       ],
22022       [
22023         '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
22024         '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
22025       ],
22026       [
22027         'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
22028         '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
22029       ],
22030       [
22031         '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
22032         'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
22033       ],
22034       [
22035         'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
22036         '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
22037       ],
22038       [
22039         'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
22040         'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
22041       ],
22042       [
22043         'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
22044         '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
22045       ],
22046       [
22047         'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
22048         'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
22049       ],
22050       [
22051         'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
22052         '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
22053       ],
22054       [
22055         '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
22056         'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
22057       ],
22058       [
22059         '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
22060         '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
22061       ],
22062       [
22063         'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
22064         '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
22065       ],
22066       [
22067         '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
22068         'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
22069       ],
22070       [
22071         'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
22072         '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
22073       ],
22074       [
22075         'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
22076         '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
22077       ],
22078       [
22079         'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
22080         'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
22081       ],
22082       [
22083         '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
22084         '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
22085       ],
22086       [
22087         '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
22088         '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
22089       ],
22090       [
22091         '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
22092         'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
22093       ],
22094       [
22095         '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
22096         '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
22097       ],
22098       [
22099         'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
22100         '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
22101       ],
22102       [
22103         '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
22104         '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
22105       ],
22106       [
22107         '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
22108         'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
22109       ],
22110       [
22111         '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
22112         '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
22113       ],
22114       [
22115         'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
22116         '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
22117       ],
22118       [
22119         '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
22120         'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
22121       ],
22122       [
22123         'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
22124         'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
22125       ],
22126       [
22127         'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
22128         '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
22129       ],
22130       [
22131         '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
22132         'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
22133       ],
22134       [
22135         '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
22136         'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
22137       ],
22138       [
22139         'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
22140         '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
22141       ],
22142       [
22143         'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
22144         '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
22145       ],
22146       [
22147         'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
22148         '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
22149       ],
22150       [
22151         '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
22152         'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
22153       ],
22154       [
22155         '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
22156         '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
22157       ],
22158       [
22159         'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
22160         'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
22161       ],
22162       [
22163         '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
22164         'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
22165       ],
22166       [
22167         '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
22168         '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
22169       ],
22170       [
22171         '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
22172         '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
22173       ],
22174       [
22175         'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
22176         'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
22177       ],
22178       [
22179         '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
22180         '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
22181       ],
22182       [
22183         '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
22184         '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
22185       ],
22186       [
22187         'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
22188         '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
22189       ],
22190       [
22191         'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
22192         'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
22193       ]
22194     ]
22195   },
22196   naf: {
22197     wnd: 7,
22198     points: [
22199       [
22200         'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
22201         '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
22202       ],
22203       [
22204         '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
22205         'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
22206       ],
22207       [
22208         '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
22209         '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
22210       ],
22211       [
22212         'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
22213         'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
22214       ],
22215       [
22216         '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
22217         'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
22218       ],
22219       [
22220         'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
22221         'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
22222       ],
22223       [
22224         'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
22225         '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
22226       ],
22227       [
22228         'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
22229         '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
22230       ],
22231       [
22232         '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
22233         '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
22234       ],
22235       [
22236         '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
22237         '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
22238       ],
22239       [
22240         '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
22241         '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
22242       ],
22243       [
22244         '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
22245         '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
22246       ],
22247       [
22248         'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
22249         'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
22250       ],
22251       [
22252         'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
22253         '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
22254       ],
22255       [
22256         '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
22257         'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
22258       ],
22259       [
22260         '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
22261         'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
22262       ],
22263       [
22264         '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
22265         '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
22266       ],
22267       [
22268         '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
22269         '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
22270       ],
22271       [
22272         '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
22273         '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
22274       ],
22275       [
22276         '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
22277         'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
22278       ],
22279       [
22280         'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
22281         'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
22282       ],
22283       [
22284         '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
22285         '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
22286       ],
22287       [
22288         '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
22289         '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
22290       ],
22291       [
22292         'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
22293         'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
22294       ],
22295       [
22296         '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
22297         '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
22298       ],
22299       [
22300         'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
22301         'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
22302       ],
22303       [
22304         'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
22305         'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
22306       ],
22307       [
22308         '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
22309         '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
22310       ],
22311       [
22312         '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
22313         '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
22314       ],
22315       [
22316         '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
22317         '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
22318       ],
22319       [
22320         'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
22321         '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
22322       ],
22323       [
22324         '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
22325         '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
22326       ],
22327       [
22328         'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
22329         '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
22330       ],
22331       [
22332         '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
22333         'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
22334       ],
22335       [
22336         '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
22337         'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
22338       ],
22339       [
22340         'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
22341         'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
22342       ],
22343       [
22344         '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
22345         '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
22346       ],
22347       [
22348         '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
22349         'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
22350       ],
22351       [
22352         'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
22353         'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
22354       ],
22355       [
22356         '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
22357         '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
22358       ],
22359       [
22360         '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
22361         'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
22362       ],
22363       [
22364         '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
22365         '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
22366       ],
22367       [
22368         '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
22369         'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
22370       ],
22371       [
22372         'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
22373         '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
22374       ],
22375       [
22376         '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
22377         '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
22378       ],
22379       [
22380         '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
22381         'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
22382       ],
22383       [
22384         '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
22385         'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
22386       ],
22387       [
22388         'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
22389         'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
22390       ],
22391       [
22392         'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
22393         'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
22394       ],
22395       [
22396         '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
22397         '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
22398       ],
22399       [
22400         '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
22401         '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
22402       ],
22403       [
22404         'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
22405         '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
22406       ],
22407       [
22408         'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
22409         'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
22410       ],
22411       [
22412         '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
22413         '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
22414       ],
22415       [
22416         '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
22417         '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
22418       ],
22419       [
22420         'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
22421         '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
22422       ],
22423       [
22424         '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
22425         '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
22426       ],
22427       [
22428         'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
22429         'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
22430       ],
22431       [
22432         '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
22433         'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
22434       ],
22435       [
22436         '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
22437         '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
22438       ],
22439       [
22440         'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
22441         '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
22442       ],
22443       [
22444         'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
22445         '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
22446       ],
22447       [
22448         '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
22449         '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
22450       ],
22451       [
22452         '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
22453         '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
22454       ],
22455       [
22456         '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
22457         'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
22458       ],
22459       [
22460         '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
22461         'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
22462       ],
22463       [
22464         '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
22465         '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
22466       ],
22467       [
22468         '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
22469         '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
22470       ],
22471       [
22472         '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
22473         '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
22474       ],
22475       [
22476         '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
22477         'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
22478       ],
22479       [
22480         'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
22481         'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
22482       ],
22483       [
22484         '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
22485         'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
22486       ],
22487       [
22488         'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
22489         '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
22490       ],
22491       [
22492         'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
22493         '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
22494       ],
22495       [
22496         'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
22497         '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
22498       ],
22499       [
22500         'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
22501         '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
22502       ],
22503       [
22504         '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
22505         'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
22506       ],
22507       [
22508         '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
22509         '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
22510       ],
22511       [
22512         '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
22513         'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
22514       ],
22515       [
22516         'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
22517         'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
22518       ],
22519       [
22520         'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
22521         '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
22522       ],
22523       [
22524         'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
22525         'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
22526       ],
22527       [
22528         'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
22529         '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
22530       ],
22531       [
22532         '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
22533         '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
22534       ],
22535       [
22536         'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
22537         '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
22538       ],
22539       [
22540         'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
22541         '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
22542       ],
22543       [
22544         '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
22545         '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
22546       ],
22547       [
22548         '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
22549         'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
22550       ],
22551       [
22552         'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
22553         '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
22554       ],
22555       [
22556         'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
22557         '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
22558       ],
22559       [
22560         'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
22561         '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
22562       ],
22563       [
22564         '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
22565         '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
22566       ],
22567       [
22568         'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
22569         'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
22570       ],
22571       [
22572         '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
22573         'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
22574       ],
22575       [
22576         'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
22577         'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
22578       ],
22579       [
22580         'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
22581         '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
22582       ],
22583       [
22584         '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
22585         'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
22586       ],
22587       [
22588         'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
22589         '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
22590       ],
22591       [
22592         'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
22593         '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
22594       ],
22595       [
22596         'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
22597         '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
22598       ],
22599       [
22600         '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
22601         'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
22602       ],
22603       [
22604         '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
22605         'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
22606       ],
22607       [
22608         'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
22609         '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
22610       ],
22611       [
22612         '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
22613         'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
22614       ],
22615       [
22616         '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
22617         '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
22618       ],
22619       [
22620         '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
22621         'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
22622       ],
22623       [
22624         'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
22625         'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
22626       ],
22627       [
22628         '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
22629         'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
22630       ],
22631       [
22632         '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
22633         '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
22634       ],
22635       [
22636         '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
22637         'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
22638       ],
22639       [
22640         '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
22641         '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
22642       ],
22643       [
22644         'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
22645         'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
22646       ],
22647       [
22648         '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
22649         '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
22650       ],
22651       [
22652         'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
22653         '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
22654       ],
22655       [
22656         '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
22657         '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
22658       ],
22659       [
22660         'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
22661         'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
22662       ],
22663       [
22664         'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
22665         '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
22666       ],
22667       [
22668         'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
22669         'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
22670       ],
22671       [
22672         '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
22673         'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
22674       ],
22675       [
22676         '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
22677         '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
22678       ],
22679       [
22680         '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
22681         'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
22682       ],
22683       [
22684         '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
22685         '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
22686       ],
22687       [
22688         '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
22689         '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
22690       ],
22691       [
22692         '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
22693         'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
22694       ],
22695       [
22696         '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
22697         '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
22698       ],
22699       [
22700         '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
22701         '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
22702       ],
22703       [
22704         '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
22705         '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
22706       ]
22707     ]
22708   }
22709 };
22710
22711
22712 /***/ }),
22713 /* 237 */
22714 /***/ (function(module, exports, __webpack_require__) {
22715
22716 "use strict";
22717
22718
22719 var BN = __webpack_require__(4);
22720 var HmacDRBG = __webpack_require__(238);
22721 var elliptic = __webpack_require__(6);
22722 var utils = elliptic.utils;
22723 var assert = utils.assert;
22724
22725 var KeyPair = __webpack_require__(239);
22726 var Signature = __webpack_require__(240);
22727
22728 function EC(options) {
22729   if (!(this instanceof EC))
22730     return new EC(options);
22731
22732   // Shortcut `elliptic.ec(curve-name)`
22733   if (typeof options === 'string') {
22734     assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
22735
22736     options = elliptic.curves[options];
22737   }
22738
22739   // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
22740   if (options instanceof elliptic.curves.PresetCurve)
22741     options = { curve: options };
22742
22743   this.curve = options.curve.curve;
22744   this.n = this.curve.n;
22745   this.nh = this.n.ushrn(1);
22746   this.g = this.curve.g;
22747
22748   // Point on curve
22749   this.g = options.curve.g;
22750   this.g.precompute(options.curve.n.bitLength() + 1);
22751
22752   // Hash for function for DRBG
22753   this.hash = options.hash || options.curve.hash;
22754 }
22755 module.exports = EC;
22756
22757 EC.prototype.keyPair = function keyPair(options) {
22758   return new KeyPair(this, options);
22759 };
22760
22761 EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
22762   return KeyPair.fromPrivate(this, priv, enc);
22763 };
22764
22765 EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
22766   return KeyPair.fromPublic(this, pub, enc);
22767 };
22768
22769 EC.prototype.genKeyPair = function genKeyPair(options) {
22770   if (!options)
22771     options = {};
22772
22773   // Instantiate Hmac_DRBG
22774   var drbg = new HmacDRBG({
22775     hash: this.hash,
22776     pers: options.pers,
22777     persEnc: options.persEnc || 'utf8',
22778     entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
22779     entropyEnc: options.entropy && options.entropyEnc || 'utf8',
22780     nonce: this.n.toArray()
22781   });
22782
22783   var bytes = this.n.byteLength();
22784   var ns2 = this.n.sub(new BN(2));
22785   do {
22786     var priv = new BN(drbg.generate(bytes));
22787     if (priv.cmp(ns2) > 0)
22788       continue;
22789
22790     priv.iaddn(1);
22791     return this.keyFromPrivate(priv);
22792   } while (true);
22793 };
22794
22795 EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
22796   var delta = msg.byteLength() * 8 - this.n.bitLength();
22797   if (delta > 0)
22798     msg = msg.ushrn(delta);
22799   if (!truncOnly && msg.cmp(this.n) >= 0)
22800     return msg.sub(this.n);
22801   else
22802     return msg;
22803 };
22804
22805 EC.prototype.sign = function sign(msg, key, enc, options) {
22806   if (typeof enc === 'object') {
22807     options = enc;
22808     enc = null;
22809   }
22810   if (!options)
22811     options = {};
22812
22813   key = this.keyFromPrivate(key, enc);
22814   msg = this._truncateToN(new BN(msg, 16));
22815
22816   // Zero-extend key to provide enough entropy
22817   var bytes = this.n.byteLength();
22818   var bkey = key.getPrivate().toArray('be', bytes);
22819
22820   // Zero-extend nonce to have the same byte size as N
22821   var nonce = msg.toArray('be', bytes);
22822
22823   // Instantiate Hmac_DRBG
22824   var drbg = new HmacDRBG({
22825     hash: this.hash,
22826     entropy: bkey,
22827     nonce: nonce,
22828     pers: options.pers,
22829     persEnc: options.persEnc || 'utf8'
22830   });
22831
22832   // Number of bytes to generate
22833   var ns1 = this.n.sub(new BN(1));
22834
22835   for (var iter = 0; true; iter++) {
22836     var k = options.k ?
22837         options.k(iter) :
22838         new BN(drbg.generate(this.n.byteLength()));
22839     k = this._truncateToN(k, true);
22840     if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
22841       continue;
22842
22843     var kp = this.g.mul(k);
22844     if (kp.isInfinity())
22845       continue;
22846
22847     var kpX = kp.getX();
22848     var r = kpX.umod(this.n);
22849     if (r.cmpn(0) === 0)
22850       continue;
22851
22852     var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
22853     s = s.umod(this.n);
22854     if (s.cmpn(0) === 0)
22855       continue;
22856
22857     var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
22858                         (kpX.cmp(r) !== 0 ? 2 : 0);
22859
22860     // Use complement of `s`, if it is > `n / 2`
22861     if (options.canonical && s.cmp(this.nh) > 0) {
22862       s = this.n.sub(s);
22863       recoveryParam ^= 1;
22864     }
22865
22866     return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
22867   }
22868 };
22869
22870 EC.prototype.verify = function verify(msg, signature, key, enc) {
22871   msg = this._truncateToN(new BN(msg, 16));
22872   key = this.keyFromPublic(key, enc);
22873   signature = new Signature(signature, 'hex');
22874
22875   // Perform primitive values validation
22876   var r = signature.r;
22877   var s = signature.s;
22878   if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
22879     return false;
22880   if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
22881     return false;
22882
22883   // Validate signature
22884   var sinv = s.invm(this.n);
22885   var u1 = sinv.mul(msg).umod(this.n);
22886   var u2 = sinv.mul(r).umod(this.n);
22887
22888   if (!this.curve._maxwellTrick) {
22889     var p = this.g.mulAdd(u1, key.getPublic(), u2);
22890     if (p.isInfinity())
22891       return false;
22892
22893     return p.getX().umod(this.n).cmp(r) === 0;
22894   }
22895
22896   // NOTE: Greg Maxwell's trick, inspired by:
22897   // https://git.io/vad3K
22898
22899   var p = this.g.jmulAdd(u1, key.getPublic(), u2);
22900   if (p.isInfinity())
22901     return false;
22902
22903   // Compare `p.x` of Jacobian point with `r`,
22904   // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
22905   // inverse of `p.z^2`
22906   return p.eqXToP(r);
22907 };
22908
22909 EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
22910   assert((3 & j) === j, 'The recovery param is more than two bits');
22911   signature = new Signature(signature, enc);
22912
22913   var n = this.n;
22914   var e = new BN(msg);
22915   var r = signature.r;
22916   var s = signature.s;
22917
22918   // A set LSB signifies that the y-coordinate is odd
22919   var isYOdd = j & 1;
22920   var isSecondKey = j >> 1;
22921   if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
22922     throw new Error('Unable to find sencond key candinate');
22923
22924   // 1.1. Let x = r + jn.
22925   if (isSecondKey)
22926     r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
22927   else
22928     r = this.curve.pointFromX(r, isYOdd);
22929
22930   var rInv = signature.r.invm(n);
22931   var s1 = n.sub(e).mul(rInv).umod(n);
22932   var s2 = s.mul(rInv).umod(n);
22933
22934   // 1.6.1 Compute Q = r^-1 (sR -  eG)
22935   //               Q = r^-1 (sR + -eG)
22936   return this.g.mulAdd(s1, r, s2);
22937 };
22938
22939 EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
22940   signature = new Signature(signature, enc);
22941   if (signature.recoveryParam !== null)
22942     return signature.recoveryParam;
22943
22944   for (var i = 0; i < 4; i++) {
22945     var Qprime;
22946     try {
22947       Qprime = this.recoverPubKey(e, signature, i);
22948     } catch (e) {
22949       continue;
22950     }
22951
22952     if (Qprime.eq(Q))
22953       return i;
22954   }
22955   throw new Error('Unable to find valid recovery factor');
22956 };
22957
22958
22959 /***/ }),
22960 /* 238 */
22961 /***/ (function(module, exports, __webpack_require__) {
22962
22963 "use strict";
22964
22965
22966 var hash = __webpack_require__(68);
22967 var utils = __webpack_require__(116);
22968 var assert = __webpack_require__(9);
22969
22970 function HmacDRBG(options) {
22971   if (!(this instanceof HmacDRBG))
22972     return new HmacDRBG(options);
22973   this.hash = options.hash;
22974   this.predResist = !!options.predResist;
22975
22976   this.outLen = this.hash.outSize;
22977   this.minEntropy = options.minEntropy || this.hash.hmacStrength;
22978
22979   this._reseed = null;
22980   this.reseedInterval = null;
22981   this.K = null;
22982   this.V = null;
22983
22984   var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
22985   var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
22986   var pers = utils.toArray(options.pers, options.persEnc || 'hex');
22987   assert(entropy.length >= (this.minEntropy / 8),
22988          'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
22989   this._init(entropy, nonce, pers);
22990 }
22991 module.exports = HmacDRBG;
22992
22993 HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
22994   var seed = entropy.concat(nonce).concat(pers);
22995
22996   this.K = new Array(this.outLen / 8);
22997   this.V = new Array(this.outLen / 8);
22998   for (var i = 0; i < this.V.length; i++) {
22999     this.K[i] = 0x00;
23000     this.V[i] = 0x01;
23001   }
23002
23003   this._update(seed);
23004   this._reseed = 1;
23005   this.reseedInterval = 0x1000000000000;  // 2^48
23006 };
23007
23008 HmacDRBG.prototype._hmac = function hmac() {
23009   return new hash.hmac(this.hash, this.K);
23010 };
23011
23012 HmacDRBG.prototype._update = function update(seed) {
23013   var kmac = this._hmac()
23014                  .update(this.V)
23015                  .update([ 0x00 ]);
23016   if (seed)
23017     kmac = kmac.update(seed);
23018   this.K = kmac.digest();
23019   this.V = this._hmac().update(this.V).digest();
23020   if (!seed)
23021     return;
23022
23023   this.K = this._hmac()
23024                .update(this.V)
23025                .update([ 0x01 ])
23026                .update(seed)
23027                .digest();
23028   this.V = this._hmac().update(this.V).digest();
23029 };
23030
23031 HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
23032   // Optional entropy enc
23033   if (typeof entropyEnc !== 'string') {
23034     addEnc = add;
23035     add = entropyEnc;
23036     entropyEnc = null;
23037   }
23038
23039   entropy = utils.toArray(entropy, entropyEnc);
23040   add = utils.toArray(add, addEnc);
23041
23042   assert(entropy.length >= (this.minEntropy / 8),
23043          'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
23044
23045   this._update(entropy.concat(add || []));
23046   this._reseed = 1;
23047 };
23048
23049 HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
23050   if (this._reseed > this.reseedInterval)
23051     throw new Error('Reseed is required');
23052
23053   // Optional encoding
23054   if (typeof enc !== 'string') {
23055     addEnc = add;
23056     add = enc;
23057     enc = null;
23058   }
23059
23060   // Optional additional data
23061   if (add) {
23062     add = utils.toArray(add, addEnc || 'hex');
23063     this._update(add);
23064   }
23065
23066   var temp = [];
23067   while (temp.length < len) {
23068     this.V = this._hmac().update(this.V).digest();
23069     temp = temp.concat(this.V);
23070   }
23071
23072   var res = temp.slice(0, len);
23073   this._update(add);
23074   this._reseed++;
23075   return utils.encode(res, enc);
23076 };
23077
23078
23079 /***/ }),
23080 /* 239 */
23081 /***/ (function(module, exports, __webpack_require__) {
23082
23083 "use strict";
23084
23085
23086 var BN = __webpack_require__(4);
23087 var elliptic = __webpack_require__(6);
23088 var utils = elliptic.utils;
23089 var assert = utils.assert;
23090
23091 function KeyPair(ec, options) {
23092   this.ec = ec;
23093   this.priv = null;
23094   this.pub = null;
23095
23096   // KeyPair(ec, { priv: ..., pub: ... })
23097   if (options.priv)
23098     this._importPrivate(options.priv, options.privEnc);
23099   if (options.pub)
23100     this._importPublic(options.pub, options.pubEnc);
23101 }
23102 module.exports = KeyPair;
23103
23104 KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
23105   if (pub instanceof KeyPair)
23106     return pub;
23107
23108   return new KeyPair(ec, {
23109     pub: pub,
23110     pubEnc: enc
23111   });
23112 };
23113
23114 KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
23115   if (priv instanceof KeyPair)
23116     return priv;
23117
23118   return new KeyPair(ec, {
23119     priv: priv,
23120     privEnc: enc
23121   });
23122 };
23123
23124 KeyPair.prototype.validate = function validate() {
23125   var pub = this.getPublic();
23126
23127   if (pub.isInfinity())
23128     return { result: false, reason: 'Invalid public key' };
23129   if (!pub.validate())
23130     return { result: false, reason: 'Public key is not a point' };
23131   if (!pub.mul(this.ec.curve.n).isInfinity())
23132     return { result: false, reason: 'Public key * N != O' };
23133
23134   return { result: true, reason: null };
23135 };
23136
23137 KeyPair.prototype.getPublic = function getPublic(compact, enc) {
23138   // compact is optional argument
23139   if (typeof compact === 'string') {
23140     enc = compact;
23141     compact = null;
23142   }
23143
23144   if (!this.pub)
23145     this.pub = this.ec.g.mul(this.priv);
23146
23147   if (!enc)
23148     return this.pub;
23149
23150   return this.pub.encode(enc, compact);
23151 };
23152
23153 KeyPair.prototype.getPrivate = function getPrivate(enc) {
23154   if (enc === 'hex')
23155     return this.priv.toString(16, 2);
23156   else
23157     return this.priv;
23158 };
23159
23160 KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
23161   this.priv = new BN(key, enc || 16);
23162
23163   // Ensure that the priv won't be bigger than n, otherwise we may fail
23164   // in fixed multiplication method
23165   this.priv = this.priv.umod(this.ec.curve.n);
23166 };
23167
23168 KeyPair.prototype._importPublic = function _importPublic(key, enc) {
23169   if (key.x || key.y) {
23170     // Montgomery points only have an `x` coordinate.
23171     // Weierstrass/Edwards points on the other hand have both `x` and
23172     // `y` coordinates.
23173     if (this.ec.curve.type === 'mont') {
23174       assert(key.x, 'Need x coordinate');
23175     } else if (this.ec.curve.type === 'short' ||
23176                this.ec.curve.type === 'edwards') {
23177       assert(key.x && key.y, 'Need both x and y coordinate');
23178     }
23179     this.pub = this.ec.curve.point(key.x, key.y);
23180     return;
23181   }
23182   this.pub = this.ec.curve.decodePoint(key, enc);
23183 };
23184
23185 // ECDH
23186 KeyPair.prototype.derive = function derive(pub) {
23187   return pub.mul(this.priv).getX();
23188 };
23189
23190 // ECDSA
23191 KeyPair.prototype.sign = function sign(msg, enc, options) {
23192   return this.ec.sign(msg, this, enc, options);
23193 };
23194
23195 KeyPair.prototype.verify = function verify(msg, signature) {
23196   return this.ec.verify(msg, signature, this);
23197 };
23198
23199 KeyPair.prototype.inspect = function inspect() {
23200   return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
23201          ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
23202 };
23203
23204
23205 /***/ }),
23206 /* 240 */
23207 /***/ (function(module, exports, __webpack_require__) {
23208
23209 "use strict";
23210
23211
23212 var BN = __webpack_require__(4);
23213
23214 var elliptic = __webpack_require__(6);
23215 var utils = elliptic.utils;
23216 var assert = utils.assert;
23217
23218 function Signature(options, enc) {
23219   if (options instanceof Signature)
23220     return options;
23221
23222   if (this._importDER(options, enc))
23223     return;
23224
23225   assert(options.r && options.s, 'Signature without r or s');
23226   this.r = new BN(options.r, 16);
23227   this.s = new BN(options.s, 16);
23228   if (options.recoveryParam === undefined)
23229     this.recoveryParam = null;
23230   else
23231     this.recoveryParam = options.recoveryParam;
23232 }
23233 module.exports = Signature;
23234
23235 function Position() {
23236   this.place = 0;
23237 }
23238
23239 function getLength(buf, p) {
23240   var initial = buf[p.place++];
23241   if (!(initial & 0x80)) {
23242     return initial;
23243   }
23244   var octetLen = initial & 0xf;
23245   var val = 0;
23246   for (var i = 0, off = p.place; i < octetLen; i++, off++) {
23247     val <<= 8;
23248     val |= buf[off];
23249   }
23250   p.place = off;
23251   return val;
23252 }
23253
23254 function rmPadding(buf) {
23255   var i = 0;
23256   var len = buf.length - 1;
23257   while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
23258     i++;
23259   }
23260   if (i === 0) {
23261     return buf;
23262   }
23263   return buf.slice(i);
23264 }
23265
23266 Signature.prototype._importDER = function _importDER(data, enc) {
23267   data = utils.toArray(data, enc);
23268   var p = new Position();
23269   if (data[p.place++] !== 0x30) {
23270     return false;
23271   }
23272   var len = getLength(data, p);
23273   if ((len + p.place) !== data.length) {
23274     return false;
23275   }
23276   if (data[p.place++] !== 0x02) {
23277     return false;
23278   }
23279   var rlen = getLength(data, p);
23280   var r = data.slice(p.place, rlen + p.place);
23281   p.place += rlen;
23282   if (data[p.place++] !== 0x02) {
23283     return false;
23284   }
23285   var slen = getLength(data, p);
23286   if (data.length !== slen + p.place) {
23287     return false;
23288   }
23289   var s = data.slice(p.place, slen + p.place);
23290   if (r[0] === 0 && (r[1] & 0x80)) {
23291     r = r.slice(1);
23292   }
23293   if (s[0] === 0 && (s[1] & 0x80)) {
23294     s = s.slice(1);
23295   }
23296
23297   this.r = new BN(r);
23298   this.s = new BN(s);
23299   this.recoveryParam = null;
23300
23301   return true;
23302 };
23303
23304 function constructLength(arr, len) {
23305   if (len < 0x80) {
23306     arr.push(len);
23307     return;
23308   }
23309   var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
23310   arr.push(octets | 0x80);
23311   while (--octets) {
23312     arr.push((len >>> (octets << 3)) & 0xff);
23313   }
23314   arr.push(len);
23315 }
23316
23317 Signature.prototype.toDER = function toDER(enc) {
23318   var r = this.r.toArray();
23319   var s = this.s.toArray();
23320
23321   // Pad values
23322   if (r[0] & 0x80)
23323     r = [ 0 ].concat(r);
23324   // Pad values
23325   if (s[0] & 0x80)
23326     s = [ 0 ].concat(s);
23327
23328   r = rmPadding(r);
23329   s = rmPadding(s);
23330
23331   while (!s[0] && !(s[1] & 0x80)) {
23332     s = s.slice(1);
23333   }
23334   var arr = [ 0x02 ];
23335   constructLength(arr, r.length);
23336   arr = arr.concat(r);
23337   arr.push(0x02);
23338   constructLength(arr, s.length);
23339   var backHalf = arr.concat(s);
23340   var res = [ 0x30 ];
23341   constructLength(res, backHalf.length);
23342   res = res.concat(backHalf);
23343   return utils.encode(res, enc);
23344 };
23345
23346
23347 /***/ }),
23348 /* 241 */
23349 /***/ (function(module, exports, __webpack_require__) {
23350
23351 "use strict";
23352
23353
23354 var hash = __webpack_require__(68);
23355 var elliptic = __webpack_require__(6);
23356 var utils = elliptic.utils;
23357 var assert = utils.assert;
23358 var parseBytes = utils.parseBytes;
23359 var KeyPair = __webpack_require__(242);
23360 var Signature = __webpack_require__(243);
23361
23362 function EDDSA(curve) {
23363   assert(curve === 'ed25519', 'only tested with ed25519 so far');
23364
23365   if (!(this instanceof EDDSA))
23366     return new EDDSA(curve);
23367
23368   var curve = elliptic.curves[curve].curve;
23369   this.curve = curve;
23370   this.g = curve.g;
23371   this.g.precompute(curve.n.bitLength() + 1);
23372
23373   this.pointClass = curve.point().constructor;
23374   this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
23375   this.hash = hash.sha512;
23376 }
23377
23378 module.exports = EDDSA;
23379
23380 /**
23381 * @param {Array|String} message - message bytes
23382 * @param {Array|String|KeyPair} secret - secret bytes or a keypair
23383 * @returns {Signature} - signature
23384 */
23385 EDDSA.prototype.sign = function sign(message, secret) {
23386   message = parseBytes(message);
23387   var key = this.keyFromSecret(secret);
23388   var r = this.hashInt(key.messagePrefix(), message);
23389   var R = this.g.mul(r);
23390   var Rencoded = this.encodePoint(R);
23391   var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
23392                .mul(key.priv());
23393   var S = r.add(s_).umod(this.curve.n);
23394   return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
23395 };
23396
23397 /**
23398 * @param {Array} message - message bytes
23399 * @param {Array|String|Signature} sig - sig bytes
23400 * @param {Array|String|Point|KeyPair} pub - public key
23401 * @returns {Boolean} - true if public key matches sig of message
23402 */
23403 EDDSA.prototype.verify = function verify(message, sig, pub) {
23404   message = parseBytes(message);
23405   sig = this.makeSignature(sig);
23406   var key = this.keyFromPublic(pub);
23407   var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
23408   var SG = this.g.mul(sig.S());
23409   var RplusAh = sig.R().add(key.pub().mul(h));
23410   return RplusAh.eq(SG);
23411 };
23412
23413 EDDSA.prototype.hashInt = function hashInt() {
23414   var hash = this.hash();
23415   for (var i = 0; i < arguments.length; i++)
23416     hash.update(arguments[i]);
23417   return utils.intFromLE(hash.digest()).umod(this.curve.n);
23418 };
23419
23420 EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
23421   return KeyPair.fromPublic(this, pub);
23422 };
23423
23424 EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
23425   return KeyPair.fromSecret(this, secret);
23426 };
23427
23428 EDDSA.prototype.makeSignature = function makeSignature(sig) {
23429   if (sig instanceof Signature)
23430     return sig;
23431   return new Signature(this, sig);
23432 };
23433
23434 /**
23435 * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
23436 *
23437 * EDDSA defines methods for encoding and decoding points and integers. These are
23438 * helper convenience methods, that pass along to utility functions implied
23439 * parameters.
23440 *
23441 */
23442 EDDSA.prototype.encodePoint = function encodePoint(point) {
23443   var enc = point.getY().toArray('le', this.encodingLength);
23444   enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
23445   return enc;
23446 };
23447
23448 EDDSA.prototype.decodePoint = function decodePoint(bytes) {
23449   bytes = utils.parseBytes(bytes);
23450
23451   var lastIx = bytes.length - 1;
23452   var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
23453   var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
23454
23455   var y = utils.intFromLE(normed);
23456   return this.curve.pointFromY(y, xIsOdd);
23457 };
23458
23459 EDDSA.prototype.encodeInt = function encodeInt(num) {
23460   return num.toArray('le', this.encodingLength);
23461 };
23462
23463 EDDSA.prototype.decodeInt = function decodeInt(bytes) {
23464   return utils.intFromLE(bytes);
23465 };
23466
23467 EDDSA.prototype.isPoint = function isPoint(val) {
23468   return val instanceof this.pointClass;
23469 };
23470
23471
23472 /***/ }),
23473 /* 242 */
23474 /***/ (function(module, exports, __webpack_require__) {
23475
23476 "use strict";
23477
23478
23479 var elliptic = __webpack_require__(6);
23480 var utils = elliptic.utils;
23481 var assert = utils.assert;
23482 var parseBytes = utils.parseBytes;
23483 var cachedProperty = utils.cachedProperty;
23484
23485 /**
23486 * @param {EDDSA} eddsa - instance
23487 * @param {Object} params - public/private key parameters
23488 *
23489 * @param {Array<Byte>} [params.secret] - secret seed bytes
23490 * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
23491 * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
23492 *
23493 */
23494 function KeyPair(eddsa, params) {
23495   this.eddsa = eddsa;
23496   this._secret = parseBytes(params.secret);
23497   if (eddsa.isPoint(params.pub))
23498     this._pub = params.pub;
23499   else
23500     this._pubBytes = parseBytes(params.pub);
23501 }
23502
23503 KeyPair.fromPublic = function fromPublic(eddsa, pub) {
23504   if (pub instanceof KeyPair)
23505     return pub;
23506   return new KeyPair(eddsa, { pub: pub });
23507 };
23508
23509 KeyPair.fromSecret = function fromSecret(eddsa, secret) {
23510   if (secret instanceof KeyPair)
23511     return secret;
23512   return new KeyPair(eddsa, { secret: secret });
23513 };
23514
23515 KeyPair.prototype.secret = function secret() {
23516   return this._secret;
23517 };
23518
23519 cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
23520   return this.eddsa.encodePoint(this.pub());
23521 });
23522
23523 cachedProperty(KeyPair, 'pub', function pub() {
23524   if (this._pubBytes)
23525     return this.eddsa.decodePoint(this._pubBytes);
23526   return this.eddsa.g.mul(this.priv());
23527 });
23528
23529 cachedProperty(KeyPair, 'privBytes', function privBytes() {
23530   var eddsa = this.eddsa;
23531   var hash = this.hash();
23532   var lastIx = eddsa.encodingLength - 1;
23533
23534   var a = hash.slice(0, eddsa.encodingLength);
23535   a[0] &= 248;
23536   a[lastIx] &= 127;
23537   a[lastIx] |= 64;
23538
23539   return a;
23540 });
23541
23542 cachedProperty(KeyPair, 'priv', function priv() {
23543   return this.eddsa.decodeInt(this.privBytes());
23544 });
23545
23546 cachedProperty(KeyPair, 'hash', function hash() {
23547   return this.eddsa.hash().update(this.secret()).digest();
23548 });
23549
23550 cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
23551   return this.hash().slice(this.eddsa.encodingLength);
23552 });
23553
23554 KeyPair.prototype.sign = function sign(message) {
23555   assert(this._secret, 'KeyPair can only verify');
23556   return this.eddsa.sign(message, this);
23557 };
23558
23559 KeyPair.prototype.verify = function verify(message, sig) {
23560   return this.eddsa.verify(message, sig, this);
23561 };
23562
23563 KeyPair.prototype.getSecret = function getSecret(enc) {
23564   assert(this._secret, 'KeyPair is public only');
23565   return utils.encode(this.secret(), enc);
23566 };
23567
23568 KeyPair.prototype.getPublic = function getPublic(enc) {
23569   return utils.encode(this.pubBytes(), enc);
23570 };
23571
23572 module.exports = KeyPair;
23573
23574
23575 /***/ }),
23576 /* 243 */
23577 /***/ (function(module, exports, __webpack_require__) {
23578
23579 "use strict";
23580
23581
23582 var BN = __webpack_require__(4);
23583 var elliptic = __webpack_require__(6);
23584 var utils = elliptic.utils;
23585 var assert = utils.assert;
23586 var cachedProperty = utils.cachedProperty;
23587 var parseBytes = utils.parseBytes;
23588
23589 /**
23590 * @param {EDDSA} eddsa - eddsa instance
23591 * @param {Array<Bytes>|Object} sig -
23592 * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
23593 * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
23594 * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
23595 * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
23596 */
23597 function Signature(eddsa, sig) {
23598   this.eddsa = eddsa;
23599
23600   if (typeof sig !== 'object')
23601     sig = parseBytes(sig);
23602
23603   if (Array.isArray(sig)) {
23604     sig = {
23605       R: sig.slice(0, eddsa.encodingLength),
23606       S: sig.slice(eddsa.encodingLength)
23607     };
23608   }
23609
23610   assert(sig.R && sig.S, 'Signature without R or S');
23611
23612   if (eddsa.isPoint(sig.R))
23613     this._R = sig.R;
23614   if (sig.S instanceof BN)
23615     this._S = sig.S;
23616
23617   this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
23618   this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
23619 }
23620
23621 cachedProperty(Signature, 'S', function S() {
23622   return this.eddsa.decodeInt(this.Sencoded());
23623 });
23624
23625 cachedProperty(Signature, 'R', function R() {
23626   return this.eddsa.decodePoint(this.Rencoded());
23627 });
23628
23629 cachedProperty(Signature, 'Rencoded', function Rencoded() {
23630   return this.eddsa.encodePoint(this.R());
23631 });
23632
23633 cachedProperty(Signature, 'Sencoded', function Sencoded() {
23634   return this.eddsa.encodeInt(this.S());
23635 });
23636
23637 Signature.prototype.toBytes = function toBytes() {
23638   return this.Rencoded().concat(this.Sencoded());
23639 };
23640
23641 Signature.prototype.toHex = function toHex() {
23642   return utils.encode(this.toBytes(), 'hex').toUpperCase();
23643 };
23644
23645 module.exports = Signature;
23646
23647
23648 /***/ }),
23649 /* 244 */
23650 /***/ (function(module, exports, __webpack_require__) {
23651
23652 "use strict";
23653 // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
23654 // Fedor, you are amazing.
23655
23656
23657 var asn1 = __webpack_require__(33)
23658
23659 exports.certificate = __webpack_require__(255)
23660
23661 var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
23662   this.seq().obj(
23663     this.key('version').int(),
23664     this.key('modulus').int(),
23665     this.key('publicExponent').int(),
23666     this.key('privateExponent').int(),
23667     this.key('prime1').int(),
23668     this.key('prime2').int(),
23669     this.key('exponent1').int(),
23670     this.key('exponent2').int(),
23671     this.key('coefficient').int()
23672   )
23673 })
23674 exports.RSAPrivateKey = RSAPrivateKey
23675
23676 var RSAPublicKey = asn1.define('RSAPublicKey', function () {
23677   this.seq().obj(
23678     this.key('modulus').int(),
23679     this.key('publicExponent').int()
23680   )
23681 })
23682 exports.RSAPublicKey = RSAPublicKey
23683
23684 var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
23685   this.seq().obj(
23686     this.key('algorithm').use(AlgorithmIdentifier),
23687     this.key('subjectPublicKey').bitstr()
23688   )
23689 })
23690 exports.PublicKey = PublicKey
23691
23692 var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
23693   this.seq().obj(
23694     this.key('algorithm').objid(),
23695     this.key('none').null_().optional(),
23696     this.key('curve').objid().optional(),
23697     this.key('params').seq().obj(
23698       this.key('p').int(),
23699       this.key('q').int(),
23700       this.key('g').int()
23701     ).optional()
23702   )
23703 })
23704
23705 var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
23706   this.seq().obj(
23707     this.key('version').int(),
23708     this.key('algorithm').use(AlgorithmIdentifier),
23709     this.key('subjectPrivateKey').octstr()
23710   )
23711 })
23712 exports.PrivateKey = PrivateKeyInfo
23713 var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
23714   this.seq().obj(
23715     this.key('algorithm').seq().obj(
23716       this.key('id').objid(),
23717       this.key('decrypt').seq().obj(
23718         this.key('kde').seq().obj(
23719           this.key('id').objid(),
23720           this.key('kdeparams').seq().obj(
23721             this.key('salt').octstr(),
23722             this.key('iters').int()
23723           )
23724         ),
23725         this.key('cipher').seq().obj(
23726           this.key('algo').objid(),
23727           this.key('iv').octstr()
23728         )
23729       )
23730     ),
23731     this.key('subjectPrivateKey').octstr()
23732   )
23733 })
23734
23735 exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
23736
23737 var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
23738   this.seq().obj(
23739     this.key('version').int(),
23740     this.key('p').int(),
23741     this.key('q').int(),
23742     this.key('g').int(),
23743     this.key('pub_key').int(),
23744     this.key('priv_key').int()
23745   )
23746 })
23747 exports.DSAPrivateKey = DSAPrivateKey
23748
23749 exports.DSAparam = asn1.define('DSAparam', function () {
23750   this.int()
23751 })
23752
23753 var ECPrivateKey = asn1.define('ECPrivateKey', function () {
23754   this.seq().obj(
23755     this.key('version').int(),
23756     this.key('privateKey').octstr(),
23757     this.key('parameters').optional().explicit(0).use(ECParameters),
23758     this.key('publicKey').optional().explicit(1).bitstr()
23759   )
23760 })
23761 exports.ECPrivateKey = ECPrivateKey
23762
23763 var ECParameters = asn1.define('ECParameters', function () {
23764   this.choice({
23765     namedCurve: this.objid()
23766   })
23767 })
23768
23769 exports.signature = asn1.define('signature', function () {
23770   this.seq().obj(
23771     this.key('r').int(),
23772     this.key('s').int()
23773   )
23774 })
23775
23776
23777 /***/ }),
23778 /* 245 */
23779 /***/ (function(module, exports, __webpack_require__) {
23780
23781 var asn1 = __webpack_require__(33);
23782 var inherits = __webpack_require__(1);
23783
23784 var api = exports;
23785
23786 api.define = function define(name, body) {
23787   return new Entity(name, body);
23788 };
23789
23790 function Entity(name, body) {
23791   this.name = name;
23792   this.body = body;
23793
23794   this.decoders = {};
23795   this.encoders = {};
23796 };
23797
23798 Entity.prototype._createNamed = function createNamed(base) {
23799   var named;
23800   try {
23801     named = __webpack_require__(246).runInThisContext(
23802       '(function ' + this.name + '(entity) {\n' +
23803       '  this._initNamed(entity);\n' +
23804       '})'
23805     );
23806   } catch (e) {
23807     named = function (entity) {
23808       this._initNamed(entity);
23809     };
23810   }
23811   inherits(named, base);
23812   named.prototype._initNamed = function initnamed(entity) {
23813     base.call(this, entity);
23814   };
23815
23816   return new named(this);
23817 };
23818
23819 Entity.prototype._getDecoder = function _getDecoder(enc) {
23820   enc = enc || 'der';
23821   // Lazily create decoder
23822   if (!this.decoders.hasOwnProperty(enc))
23823     this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
23824   return this.decoders[enc];
23825 };
23826
23827 Entity.prototype.decode = function decode(data, enc, options) {
23828   return this._getDecoder(enc).decode(data, options);
23829 };
23830
23831 Entity.prototype._getEncoder = function _getEncoder(enc) {
23832   enc = enc || 'der';
23833   // Lazily create encoder
23834   if (!this.encoders.hasOwnProperty(enc))
23835     this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
23836   return this.encoders[enc];
23837 };
23838
23839 Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
23840   return this._getEncoder(enc).encode(data, reporter);
23841 };
23842
23843
23844 /***/ }),
23845 /* 246 */
23846 /***/ (function(module, exports, __webpack_require__) {
23847
23848 var indexOf = __webpack_require__(247);
23849
23850 var Object_keys = function (obj) {
23851     if (Object.keys) return Object.keys(obj)
23852     else {
23853         var res = [];
23854         for (var key in obj) res.push(key)
23855         return res;
23856     }
23857 };
23858
23859 var forEach = function (xs, fn) {
23860     if (xs.forEach) return xs.forEach(fn)
23861     else for (var i = 0; i < xs.length; i++) {
23862         fn(xs[i], i, xs);
23863     }
23864 };
23865
23866 var defineProp = (function() {
23867     try {
23868         Object.defineProperty({}, '_', {});
23869         return function(obj, name, value) {
23870             Object.defineProperty(obj, name, {
23871                 writable: true,
23872                 enumerable: false,
23873                 configurable: true,
23874                 value: value
23875             })
23876         };
23877     } catch(e) {
23878         return function(obj, name, value) {
23879             obj[name] = value;
23880         };
23881     }
23882 }());
23883
23884 var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
23885 'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
23886 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
23887 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
23888 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
23889
23890 function Context() {}
23891 Context.prototype = {};
23892
23893 var Script = exports.Script = function NodeScript (code) {
23894     if (!(this instanceof Script)) return new Script(code);
23895     this.code = code;
23896 };
23897
23898 Script.prototype.runInContext = function (context) {
23899     if (!(context instanceof Context)) {
23900         throw new TypeError("needs a 'context' argument.");
23901     }
23902     
23903     var iframe = document.createElement('iframe');
23904     if (!iframe.style) iframe.style = {};
23905     iframe.style.display = 'none';
23906     
23907     document.body.appendChild(iframe);
23908     
23909     var win = iframe.contentWindow;
23910     var wEval = win.eval, wExecScript = win.execScript;
23911
23912     if (!wEval && wExecScript) {
23913         // win.eval() magically appears when this is called in IE:
23914         wExecScript.call(win, 'null');
23915         wEval = win.eval;
23916     }
23917     
23918     forEach(Object_keys(context), function (key) {
23919         win[key] = context[key];
23920     });
23921     forEach(globals, function (key) {
23922         if (context[key]) {
23923             win[key] = context[key];
23924         }
23925     });
23926     
23927     var winKeys = Object_keys(win);
23928
23929     var res = wEval.call(win, this.code);
23930     
23931     forEach(Object_keys(win), function (key) {
23932         // Avoid copying circular objects like `top` and `window` by only
23933         // updating existing context properties or new properties in the `win`
23934         // that was only introduced after the eval.
23935         if (key in context || indexOf(winKeys, key) === -1) {
23936             context[key] = win[key];
23937         }
23938     });
23939
23940     forEach(globals, function (key) {
23941         if (!(key in context)) {
23942             defineProp(context, key, win[key]);
23943         }
23944     });
23945     
23946     document.body.removeChild(iframe);
23947     
23948     return res;
23949 };
23950
23951 Script.prototype.runInThisContext = function () {
23952     return eval(this.code); // maybe...
23953 };
23954
23955 Script.prototype.runInNewContext = function (context) {
23956     var ctx = Script.createContext(context);
23957     var res = this.runInContext(ctx);
23958
23959     forEach(Object_keys(ctx), function (key) {
23960         context[key] = ctx[key];
23961     });
23962
23963     return res;
23964 };
23965
23966 forEach(Object_keys(Script.prototype), function (name) {
23967     exports[name] = Script[name] = function (code) {
23968         var s = Script(code);
23969         return s[name].apply(s, [].slice.call(arguments, 1));
23970     };
23971 });
23972
23973 exports.createScript = function (code) {
23974     return exports.Script(code);
23975 };
23976
23977 exports.createContext = Script.createContext = function (context) {
23978     var copy = new Context();
23979     if(typeof context === 'object') {
23980         forEach(Object_keys(context), function (key) {
23981             copy[key] = context[key];
23982         });
23983     }
23984     return copy;
23985 };
23986
23987
23988 /***/ }),
23989 /* 247 */
23990 /***/ (function(module, exports) {
23991
23992
23993 var indexOf = [].indexOf;
23994
23995 module.exports = function(arr, obj){
23996   if (indexOf) return arr.indexOf(obj);
23997   for (var i = 0; i < arr.length; ++i) {
23998     if (arr[i] === obj) return i;
23999   }
24000   return -1;
24001 };
24002
24003 /***/ }),
24004 /* 248 */
24005 /***/ (function(module, exports, __webpack_require__) {
24006
24007 var inherits = __webpack_require__(1);
24008
24009 function Reporter(options) {
24010   this._reporterState = {
24011     obj: null,
24012     path: [],
24013     options: options || {},
24014     errors: []
24015   };
24016 }
24017 exports.Reporter = Reporter;
24018
24019 Reporter.prototype.isError = function isError(obj) {
24020   return obj instanceof ReporterError;
24021 };
24022
24023 Reporter.prototype.save = function save() {
24024   var state = this._reporterState;
24025
24026   return { obj: state.obj, pathLen: state.path.length };
24027 };
24028
24029 Reporter.prototype.restore = function restore(data) {
24030   var state = this._reporterState;
24031
24032   state.obj = data.obj;
24033   state.path = state.path.slice(0, data.pathLen);
24034 };
24035
24036 Reporter.prototype.enterKey = function enterKey(key) {
24037   return this._reporterState.path.push(key);
24038 };
24039
24040 Reporter.prototype.exitKey = function exitKey(index) {
24041   var state = this._reporterState;
24042
24043   state.path = state.path.slice(0, index - 1);
24044 };
24045
24046 Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
24047   var state = this._reporterState;
24048
24049   this.exitKey(index);
24050   if (state.obj !== null)
24051     state.obj[key] = value;
24052 };
24053
24054 Reporter.prototype.path = function path() {
24055   return this._reporterState.path.join('/');
24056 };
24057
24058 Reporter.prototype.enterObject = function enterObject() {
24059   var state = this._reporterState;
24060
24061   var prev = state.obj;
24062   state.obj = {};
24063   return prev;
24064 };
24065
24066 Reporter.prototype.leaveObject = function leaveObject(prev) {
24067   var state = this._reporterState;
24068
24069   var now = state.obj;
24070   state.obj = prev;
24071   return now;
24072 };
24073
24074 Reporter.prototype.error = function error(msg) {
24075   var err;
24076   var state = this._reporterState;
24077
24078   var inherited = msg instanceof ReporterError;
24079   if (inherited) {
24080     err = msg;
24081   } else {
24082     err = new ReporterError(state.path.map(function(elem) {
24083       return '[' + JSON.stringify(elem) + ']';
24084     }).join(''), msg.message || msg, msg.stack);
24085   }
24086
24087   if (!state.options.partial)
24088     throw err;
24089
24090   if (!inherited)
24091     state.errors.push(err);
24092
24093   return err;
24094 };
24095
24096 Reporter.prototype.wrapResult = function wrapResult(result) {
24097   var state = this._reporterState;
24098   if (!state.options.partial)
24099     return result;
24100
24101   return {
24102     result: this.isError(result) ? null : result,
24103     errors: state.errors
24104   };
24105 };
24106
24107 function ReporterError(path, msg) {
24108   this.path = path;
24109   this.rethrow(msg);
24110 };
24111 inherits(ReporterError, Error);
24112
24113 ReporterError.prototype.rethrow = function rethrow(msg) {
24114   this.message = msg + ' at: ' + (this.path || '(shallow)');
24115   if (Error.captureStackTrace)
24116     Error.captureStackTrace(this, ReporterError);
24117
24118   if (!this.stack) {
24119     try {
24120       // IE only adds stack when thrown
24121       throw new Error(this.message);
24122     } catch (e) {
24123       this.stack = e.stack;
24124     }
24125   }
24126   return this;
24127 };
24128
24129
24130 /***/ }),
24131 /* 249 */
24132 /***/ (function(module, exports, __webpack_require__) {
24133
24134 var Reporter = __webpack_require__(34).Reporter;
24135 var EncoderBuffer = __webpack_require__(34).EncoderBuffer;
24136 var DecoderBuffer = __webpack_require__(34).DecoderBuffer;
24137 var assert = __webpack_require__(9);
24138
24139 // Supported tags
24140 var tags = [
24141   'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
24142   'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
24143   'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
24144   'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
24145 ];
24146
24147 // Public methods list
24148 var methods = [
24149   'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
24150   'any', 'contains'
24151 ].concat(tags);
24152
24153 // Overrided methods list
24154 var overrided = [
24155   '_peekTag', '_decodeTag', '_use',
24156   '_decodeStr', '_decodeObjid', '_decodeTime',
24157   '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
24158
24159   '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
24160   '_encodeNull', '_encodeInt', '_encodeBool'
24161 ];
24162
24163 function Node(enc, parent) {
24164   var state = {};
24165   this._baseState = state;
24166
24167   state.enc = enc;
24168
24169   state.parent = parent || null;
24170   state.children = null;
24171
24172   // State
24173   state.tag = null;
24174   state.args = null;
24175   state.reverseArgs = null;
24176   state.choice = null;
24177   state.optional = false;
24178   state.any = false;
24179   state.obj = false;
24180   state.use = null;
24181   state.useDecoder = null;
24182   state.key = null;
24183   state['default'] = null;
24184   state.explicit = null;
24185   state.implicit = null;
24186   state.contains = null;
24187
24188   // Should create new instance on each method
24189   if (!state.parent) {
24190     state.children = [];
24191     this._wrap();
24192   }
24193 }
24194 module.exports = Node;
24195
24196 var stateProps = [
24197   'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
24198   'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
24199   'implicit', 'contains'
24200 ];
24201
24202 Node.prototype.clone = function clone() {
24203   var state = this._baseState;
24204   var cstate = {};
24205   stateProps.forEach(function(prop) {
24206     cstate[prop] = state[prop];
24207   });
24208   var res = new this.constructor(cstate.parent);
24209   res._baseState = cstate;
24210   return res;
24211 };
24212
24213 Node.prototype._wrap = function wrap() {
24214   var state = this._baseState;
24215   methods.forEach(function(method) {
24216     this[method] = function _wrappedMethod() {
24217       var clone = new this.constructor(this);
24218       state.children.push(clone);
24219       return clone[method].apply(clone, arguments);
24220     };
24221   }, this);
24222 };
24223
24224 Node.prototype._init = function init(body) {
24225   var state = this._baseState;
24226
24227   assert(state.parent === null);
24228   body.call(this);
24229
24230   // Filter children
24231   state.children = state.children.filter(function(child) {
24232     return child._baseState.parent === this;
24233   }, this);
24234   assert.equal(state.children.length, 1, 'Root node can have only one child');
24235 };
24236
24237 Node.prototype._useArgs = function useArgs(args) {
24238   var state = this._baseState;
24239
24240   // Filter children and args
24241   var children = args.filter(function(arg) {
24242     return arg instanceof this.constructor;
24243   }, this);
24244   args = args.filter(function(arg) {
24245     return !(arg instanceof this.constructor);
24246   }, this);
24247
24248   if (children.length !== 0) {
24249     assert(state.children === null);
24250     state.children = children;
24251
24252     // Replace parent to maintain backward link
24253     children.forEach(function(child) {
24254       child._baseState.parent = this;
24255     }, this);
24256   }
24257   if (args.length !== 0) {
24258     assert(state.args === null);
24259     state.args = args;
24260     state.reverseArgs = args.map(function(arg) {
24261       if (typeof arg !== 'object' || arg.constructor !== Object)
24262         return arg;
24263
24264       var res = {};
24265       Object.keys(arg).forEach(function(key) {
24266         if (key == (key | 0))
24267           key |= 0;
24268         var value = arg[key];
24269         res[value] = key;
24270       });
24271       return res;
24272     });
24273   }
24274 };
24275
24276 //
24277 // Overrided methods
24278 //
24279
24280 overrided.forEach(function(method) {
24281   Node.prototype[method] = function _overrided() {
24282     var state = this._baseState;
24283     throw new Error(method + ' not implemented for encoding: ' + state.enc);
24284   };
24285 });
24286
24287 //
24288 // Public methods
24289 //
24290
24291 tags.forEach(function(tag) {
24292   Node.prototype[tag] = function _tagMethod() {
24293     var state = this._baseState;
24294     var args = Array.prototype.slice.call(arguments);
24295
24296     assert(state.tag === null);
24297     state.tag = tag;
24298
24299     this._useArgs(args);
24300
24301     return this;
24302   };
24303 });
24304
24305 Node.prototype.use = function use(item) {
24306   assert(item);
24307   var state = this._baseState;
24308
24309   assert(state.use === null);
24310   state.use = item;
24311
24312   return this;
24313 };
24314
24315 Node.prototype.optional = function optional() {
24316   var state = this._baseState;
24317
24318   state.optional = true;
24319
24320   return this;
24321 };
24322
24323 Node.prototype.def = function def(val) {
24324   var state = this._baseState;
24325
24326   assert(state['default'] === null);
24327   state['default'] = val;
24328   state.optional = true;
24329
24330   return this;
24331 };
24332
24333 Node.prototype.explicit = function explicit(num) {
24334   var state = this._baseState;
24335
24336   assert(state.explicit === null && state.implicit === null);
24337   state.explicit = num;
24338
24339   return this;
24340 };
24341
24342 Node.prototype.implicit = function implicit(num) {
24343   var state = this._baseState;
24344
24345   assert(state.explicit === null && state.implicit === null);
24346   state.implicit = num;
24347
24348   return this;
24349 };
24350
24351 Node.prototype.obj = function obj() {
24352   var state = this._baseState;
24353   var args = Array.prototype.slice.call(arguments);
24354
24355   state.obj = true;
24356
24357   if (args.length !== 0)
24358     this._useArgs(args);
24359
24360   return this;
24361 };
24362
24363 Node.prototype.key = function key(newKey) {
24364   var state = this._baseState;
24365
24366   assert(state.key === null);
24367   state.key = newKey;
24368
24369   return this;
24370 };
24371
24372 Node.prototype.any = function any() {
24373   var state = this._baseState;
24374
24375   state.any = true;
24376
24377   return this;
24378 };
24379
24380 Node.prototype.choice = function choice(obj) {
24381   var state = this._baseState;
24382
24383   assert(state.choice === null);
24384   state.choice = obj;
24385   this._useArgs(Object.keys(obj).map(function(key) {
24386     return obj[key];
24387   }));
24388
24389   return this;
24390 };
24391
24392 Node.prototype.contains = function contains(item) {
24393   var state = this._baseState;
24394
24395   assert(state.use === null);
24396   state.contains = item;
24397
24398   return this;
24399 };
24400
24401 //
24402 // Decoding
24403 //
24404
24405 Node.prototype._decode = function decode(input, options) {
24406   var state = this._baseState;
24407
24408   // Decode root node
24409   if (state.parent === null)
24410     return input.wrapResult(state.children[0]._decode(input, options));
24411
24412   var result = state['default'];
24413   var present = true;
24414
24415   var prevKey = null;
24416   if (state.key !== null)
24417     prevKey = input.enterKey(state.key);
24418
24419   // Check if tag is there
24420   if (state.optional) {
24421     var tag = null;
24422     if (state.explicit !== null)
24423       tag = state.explicit;
24424     else if (state.implicit !== null)
24425       tag = state.implicit;
24426     else if (state.tag !== null)
24427       tag = state.tag;
24428
24429     if (tag === null && !state.any) {
24430       // Trial and Error
24431       var save = input.save();
24432       try {
24433         if (state.choice === null)
24434           this._decodeGeneric(state.tag, input, options);
24435         else
24436           this._decodeChoice(input, options);
24437         present = true;
24438       } catch (e) {
24439         present = false;
24440       }
24441       input.restore(save);
24442     } else {
24443       present = this._peekTag(input, tag, state.any);
24444
24445       if (input.isError(present))
24446         return present;
24447     }
24448   }
24449
24450   // Push object on stack
24451   var prevObj;
24452   if (state.obj && present)
24453     prevObj = input.enterObject();
24454
24455   if (present) {
24456     // Unwrap explicit values
24457     if (state.explicit !== null) {
24458       var explicit = this._decodeTag(input, state.explicit);
24459       if (input.isError(explicit))
24460         return explicit;
24461       input = explicit;
24462     }
24463
24464     var start = input.offset;
24465
24466     // Unwrap implicit and normal values
24467     if (state.use === null && state.choice === null) {
24468       if (state.any)
24469         var save = input.save();
24470       var body = this._decodeTag(
24471         input,
24472         state.implicit !== null ? state.implicit : state.tag,
24473         state.any
24474       );
24475       if (input.isError(body))
24476         return body;
24477
24478       if (state.any)
24479         result = input.raw(save);
24480       else
24481         input = body;
24482     }
24483
24484     if (options && options.track && state.tag !== null)
24485       options.track(input.path(), start, input.length, 'tagged');
24486
24487     if (options && options.track && state.tag !== null)
24488       options.track(input.path(), input.offset, input.length, 'content');
24489
24490     // Select proper method for tag
24491     if (state.any)
24492       result = result;
24493     else if (state.choice === null)
24494       result = this._decodeGeneric(state.tag, input, options);
24495     else
24496       result = this._decodeChoice(input, options);
24497
24498     if (input.isError(result))
24499       return result;
24500
24501     // Decode children
24502     if (!state.any && state.choice === null && state.children !== null) {
24503       state.children.forEach(function decodeChildren(child) {
24504         // NOTE: We are ignoring errors here, to let parser continue with other
24505         // parts of encoded data
24506         child._decode(input, options);
24507       });
24508     }
24509
24510     // Decode contained/encoded by schema, only in bit or octet strings
24511     if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
24512       var data = new DecoderBuffer(result);
24513       result = this._getUse(state.contains, input._reporterState.obj)
24514           ._decode(data, options);
24515     }
24516   }
24517
24518   // Pop object
24519   if (state.obj && present)
24520     result = input.leaveObject(prevObj);
24521
24522   // Set key
24523   if (state.key !== null && (result !== null || present === true))
24524     input.leaveKey(prevKey, state.key, result);
24525   else if (prevKey !== null)
24526     input.exitKey(prevKey);
24527
24528   return result;
24529 };
24530
24531 Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
24532   var state = this._baseState;
24533
24534   if (tag === 'seq' || tag === 'set')
24535     return null;
24536   if (tag === 'seqof' || tag === 'setof')
24537     return this._decodeList(input, tag, state.args[0], options);
24538   else if (/str$/.test(tag))
24539     return this._decodeStr(input, tag, options);
24540   else if (tag === 'objid' && state.args)
24541     return this._decodeObjid(input, state.args[0], state.args[1], options);
24542   else if (tag === 'objid')
24543     return this._decodeObjid(input, null, null, options);
24544   else if (tag === 'gentime' || tag === 'utctime')
24545     return this._decodeTime(input, tag, options);
24546   else if (tag === 'null_')
24547     return this._decodeNull(input, options);
24548   else if (tag === 'bool')
24549     return this._decodeBool(input, options);
24550   else if (tag === 'objDesc')
24551     return this._decodeStr(input, tag, options);
24552   else if (tag === 'int' || tag === 'enum')
24553     return this._decodeInt(input, state.args && state.args[0], options);
24554
24555   if (state.use !== null) {
24556     return this._getUse(state.use, input._reporterState.obj)
24557         ._decode(input, options);
24558   } else {
24559     return input.error('unknown tag: ' + tag);
24560   }
24561 };
24562
24563 Node.prototype._getUse = function _getUse(entity, obj) {
24564
24565   var state = this._baseState;
24566   // Create altered use decoder if implicit is set
24567   state.useDecoder = this._use(entity, obj);
24568   assert(state.useDecoder._baseState.parent === null);
24569   state.useDecoder = state.useDecoder._baseState.children[0];
24570   if (state.implicit !== state.useDecoder._baseState.implicit) {
24571     state.useDecoder = state.useDecoder.clone();
24572     state.useDecoder._baseState.implicit = state.implicit;
24573   }
24574   return state.useDecoder;
24575 };
24576
24577 Node.prototype._decodeChoice = function decodeChoice(input, options) {
24578   var state = this._baseState;
24579   var result = null;
24580   var match = false;
24581
24582   Object.keys(state.choice).some(function(key) {
24583     var save = input.save();
24584     var node = state.choice[key];
24585     try {
24586       var value = node._decode(input, options);
24587       if (input.isError(value))
24588         return false;
24589
24590       result = { type: key, value: value };
24591       match = true;
24592     } catch (e) {
24593       input.restore(save);
24594       return false;
24595     }
24596     return true;
24597   }, this);
24598
24599   if (!match)
24600     return input.error('Choice not matched');
24601
24602   return result;
24603 };
24604
24605 //
24606 // Encoding
24607 //
24608
24609 Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
24610   return new EncoderBuffer(data, this.reporter);
24611 };
24612
24613 Node.prototype._encode = function encode(data, reporter, parent) {
24614   var state = this._baseState;
24615   if (state['default'] !== null && state['default'] === data)
24616     return;
24617
24618   var result = this._encodeValue(data, reporter, parent);
24619   if (result === undefined)
24620     return;
24621
24622   if (this._skipDefault(result, reporter, parent))
24623     return;
24624
24625   return result;
24626 };
24627
24628 Node.prototype._encodeValue = function encode(data, reporter, parent) {
24629   var state = this._baseState;
24630
24631   // Decode root node
24632   if (state.parent === null)
24633     return state.children[0]._encode(data, reporter || new Reporter());
24634
24635   var result = null;
24636
24637   // Set reporter to share it with a child class
24638   this.reporter = reporter;
24639
24640   // Check if data is there
24641   if (state.optional && data === undefined) {
24642     if (state['default'] !== null)
24643       data = state['default']
24644     else
24645       return;
24646   }
24647
24648   // Encode children first
24649   var content = null;
24650   var primitive = false;
24651   if (state.any) {
24652     // Anything that was given is translated to buffer
24653     result = this._createEncoderBuffer(data);
24654   } else if (state.choice) {
24655     result = this._encodeChoice(data, reporter);
24656   } else if (state.contains) {
24657     content = this._getUse(state.contains, parent)._encode(data, reporter);
24658     primitive = true;
24659   } else if (state.children) {
24660     content = state.children.map(function(child) {
24661       if (child._baseState.tag === 'null_')
24662         return child._encode(null, reporter, data);
24663
24664       if (child._baseState.key === null)
24665         return reporter.error('Child should have a key');
24666       var prevKey = reporter.enterKey(child._baseState.key);
24667
24668       if (typeof data !== 'object')
24669         return reporter.error('Child expected, but input is not object');
24670
24671       var res = child._encode(data[child._baseState.key], reporter, data);
24672       reporter.leaveKey(prevKey);
24673
24674       return res;
24675     }, this).filter(function(child) {
24676       return child;
24677     });
24678     content = this._createEncoderBuffer(content);
24679   } else {
24680     if (state.tag === 'seqof' || state.tag === 'setof') {
24681       // TODO(indutny): this should be thrown on DSL level
24682       if (!(state.args && state.args.length === 1))
24683         return reporter.error('Too many args for : ' + state.tag);
24684
24685       if (!Array.isArray(data))
24686         return reporter.error('seqof/setof, but data is not Array');
24687
24688       var child = this.clone();
24689       child._baseState.implicit = null;
24690       content = this._createEncoderBuffer(data.map(function(item) {
24691         var state = this._baseState;
24692
24693         return this._getUse(state.args[0], data)._encode(item, reporter);
24694       }, child));
24695     } else if (state.use !== null) {
24696       result = this._getUse(state.use, parent)._encode(data, reporter);
24697     } else {
24698       content = this._encodePrimitive(state.tag, data);
24699       primitive = true;
24700     }
24701   }
24702
24703   // Encode data itself
24704   var result;
24705   if (!state.any && state.choice === null) {
24706     var tag = state.implicit !== null ? state.implicit : state.tag;
24707     var cls = state.implicit === null ? 'universal' : 'context';
24708
24709     if (tag === null) {
24710       if (state.use === null)
24711         reporter.error('Tag could be omitted only for .use()');
24712     } else {
24713       if (state.use === null)
24714         result = this._encodeComposite(tag, primitive, cls, content);
24715     }
24716   }
24717
24718   // Wrap in explicit
24719   if (state.explicit !== null)
24720     result = this._encodeComposite(state.explicit, false, 'context', result);
24721
24722   return result;
24723 };
24724
24725 Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
24726   var state = this._baseState;
24727
24728   var node = state.choice[data.type];
24729   if (!node) {
24730     assert(
24731         false,
24732         data.type + ' not found in ' +
24733             JSON.stringify(Object.keys(state.choice)));
24734   }
24735   return node._encode(data.value, reporter);
24736 };
24737
24738 Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
24739   var state = this._baseState;
24740
24741   if (/str$/.test(tag))
24742     return this._encodeStr(data, tag);
24743   else if (tag === 'objid' && state.args)
24744     return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
24745   else if (tag === 'objid')
24746     return this._encodeObjid(data, null, null);
24747   else if (tag === 'gentime' || tag === 'utctime')
24748     return this._encodeTime(data, tag);
24749   else if (tag === 'null_')
24750     return this._encodeNull();
24751   else if (tag === 'int' || tag === 'enum')
24752     return this._encodeInt(data, state.args && state.reverseArgs[0]);
24753   else if (tag === 'bool')
24754     return this._encodeBool(data);
24755   else if (tag === 'objDesc')
24756     return this._encodeStr(data, tag);
24757   else
24758     throw new Error('Unsupported tag: ' + tag);
24759 };
24760
24761 Node.prototype._isNumstr = function isNumstr(str) {
24762   return /^[0-9 ]*$/.test(str);
24763 };
24764
24765 Node.prototype._isPrintstr = function isPrintstr(str) {
24766   return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
24767 };
24768
24769
24770 /***/ }),
24771 /* 250 */
24772 /***/ (function(module, exports, __webpack_require__) {
24773
24774 var constants = __webpack_require__(121);
24775
24776 exports.tagClass = {
24777   0: 'universal',
24778   1: 'application',
24779   2: 'context',
24780   3: 'private'
24781 };
24782 exports.tagClassByName = constants._reverse(exports.tagClass);
24783
24784 exports.tag = {
24785   0x00: 'end',
24786   0x01: 'bool',
24787   0x02: 'int',
24788   0x03: 'bitstr',
24789   0x04: 'octstr',
24790   0x05: 'null_',
24791   0x06: 'objid',
24792   0x07: 'objDesc',
24793   0x08: 'external',
24794   0x09: 'real',
24795   0x0a: 'enum',
24796   0x0b: 'embed',
24797   0x0c: 'utf8str',
24798   0x0d: 'relativeOid',
24799   0x10: 'seq',
24800   0x11: 'set',
24801   0x12: 'numstr',
24802   0x13: 'printstr',
24803   0x14: 't61str',
24804   0x15: 'videostr',
24805   0x16: 'ia5str',
24806   0x17: 'utctime',
24807   0x18: 'gentime',
24808   0x19: 'graphstr',
24809   0x1a: 'iso646str',
24810   0x1b: 'genstr',
24811   0x1c: 'unistr',
24812   0x1d: 'charstr',
24813   0x1e: 'bmpstr'
24814 };
24815 exports.tagByName = constants._reverse(exports.tag);
24816
24817
24818 /***/ }),
24819 /* 251 */
24820 /***/ (function(module, exports, __webpack_require__) {
24821
24822 var decoders = exports;
24823
24824 decoders.der = __webpack_require__(122);
24825 decoders.pem = __webpack_require__(252);
24826
24827
24828 /***/ }),
24829 /* 252 */
24830 /***/ (function(module, exports, __webpack_require__) {
24831
24832 var inherits = __webpack_require__(1);
24833 var Buffer = __webpack_require__(3).Buffer;
24834
24835 var DERDecoder = __webpack_require__(122);
24836
24837 function PEMDecoder(entity) {
24838   DERDecoder.call(this, entity);
24839   this.enc = 'pem';
24840 };
24841 inherits(PEMDecoder, DERDecoder);
24842 module.exports = PEMDecoder;
24843
24844 PEMDecoder.prototype.decode = function decode(data, options) {
24845   var lines = data.toString().split(/[\r\n]+/g);
24846
24847   var label = options.label.toUpperCase();
24848
24849   var re = /^-----(BEGIN|END) ([^-]+)-----$/;
24850   var start = -1;
24851   var end = -1;
24852   for (var i = 0; i < lines.length; i++) {
24853     var match = lines[i].match(re);
24854     if (match === null)
24855       continue;
24856
24857     if (match[2] !== label)
24858       continue;
24859
24860     if (start === -1) {
24861       if (match[1] !== 'BEGIN')
24862         break;
24863       start = i;
24864     } else {
24865       if (match[1] !== 'END')
24866         break;
24867       end = i;
24868       break;
24869     }
24870   }
24871   if (start === -1 || end === -1)
24872     throw new Error('PEM section not found for: ' + label);
24873
24874   var base64 = lines.slice(start + 1, end).join('');
24875   // Remove excessive symbols
24876   base64.replace(/[^a-z0-9\+\/=]+/gi, '');
24877
24878   var input = new Buffer(base64, 'base64');
24879   return DERDecoder.prototype.decode.call(this, input, options);
24880 };
24881
24882
24883 /***/ }),
24884 /* 253 */
24885 /***/ (function(module, exports, __webpack_require__) {
24886
24887 var encoders = exports;
24888
24889 encoders.der = __webpack_require__(123);
24890 encoders.pem = __webpack_require__(254);
24891
24892
24893 /***/ }),
24894 /* 254 */
24895 /***/ (function(module, exports, __webpack_require__) {
24896
24897 var inherits = __webpack_require__(1);
24898
24899 var DEREncoder = __webpack_require__(123);
24900
24901 function PEMEncoder(entity) {
24902   DEREncoder.call(this, entity);
24903   this.enc = 'pem';
24904 };
24905 inherits(PEMEncoder, DEREncoder);
24906 module.exports = PEMEncoder;
24907
24908 PEMEncoder.prototype.encode = function encode(data, options) {
24909   var buf = DEREncoder.prototype.encode.call(this, data);
24910
24911   var p = buf.toString('base64');
24912   var out = [ '-----BEGIN ' + options.label + '-----' ];
24913   for (var i = 0; i < p.length; i += 64)
24914     out.push(p.slice(i, i + 64));
24915   out.push('-----END ' + options.label + '-----');
24916   return out.join('\n');
24917 };
24918
24919
24920 /***/ }),
24921 /* 255 */
24922 /***/ (function(module, exports, __webpack_require__) {
24923
24924 "use strict";
24925 // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
24926 // thanks to @Rantanen
24927
24928
24929
24930 var asn = __webpack_require__(33)
24931
24932 var Time = asn.define('Time', function () {
24933   this.choice({
24934     utcTime: this.utctime(),
24935     generalTime: this.gentime()
24936   })
24937 })
24938
24939 var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
24940   this.seq().obj(
24941     this.key('type').objid(),
24942     this.key('value').any()
24943   )
24944 })
24945
24946 var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
24947   this.seq().obj(
24948     this.key('algorithm').objid(),
24949     this.key('parameters').optional()
24950   )
24951 })
24952
24953 var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
24954   this.seq().obj(
24955     this.key('algorithm').use(AlgorithmIdentifier),
24956     this.key('subjectPublicKey').bitstr()
24957   )
24958 })
24959
24960 var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
24961   this.setof(AttributeTypeValue)
24962 })
24963
24964 var RDNSequence = asn.define('RDNSequence', function () {
24965   this.seqof(RelativeDistinguishedName)
24966 })
24967
24968 var Name = asn.define('Name', function () {
24969   this.choice({
24970     rdnSequence: this.use(RDNSequence)
24971   })
24972 })
24973
24974 var Validity = asn.define('Validity', function () {
24975   this.seq().obj(
24976     this.key('notBefore').use(Time),
24977     this.key('notAfter').use(Time)
24978   )
24979 })
24980
24981 var Extension = asn.define('Extension', function () {
24982   this.seq().obj(
24983     this.key('extnID').objid(),
24984     this.key('critical').bool().def(false),
24985     this.key('extnValue').octstr()
24986   )
24987 })
24988
24989 var TBSCertificate = asn.define('TBSCertificate', function () {
24990   this.seq().obj(
24991     this.key('version').explicit(0).int(),
24992     this.key('serialNumber').int(),
24993     this.key('signature').use(AlgorithmIdentifier),
24994     this.key('issuer').use(Name),
24995     this.key('validity').use(Validity),
24996     this.key('subject').use(Name),
24997     this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
24998     this.key('issuerUniqueID').implicit(1).bitstr().optional(),
24999     this.key('subjectUniqueID').implicit(2).bitstr().optional(),
25000     this.key('extensions').explicit(3).seqof(Extension).optional()
25001   )
25002 })
25003
25004 var X509Certificate = asn.define('X509Certificate', function () {
25005   this.seq().obj(
25006     this.key('tbsCertificate').use(TBSCertificate),
25007     this.key('signatureAlgorithm').use(AlgorithmIdentifier),
25008     this.key('signatureValue').bitstr()
25009   )
25010 })
25011
25012 module.exports = X509Certificate
25013
25014
25015 /***/ }),
25016 /* 256 */
25017 /***/ (function(module, exports) {
25018
25019 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"}
25020
25021 /***/ }),
25022 /* 257 */
25023 /***/ (function(module, exports, __webpack_require__) {
25024
25025 /* WEBPACK VAR INJECTION */(function(Buffer) {// adapted from https://github.com/apatil/pemstrip
25026 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
25027 var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m
25028 var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m
25029 var evp = __webpack_require__(44)
25030 var ciphers = __webpack_require__(65)
25031 module.exports = function (okey, password) {
25032   var key = okey.toString()
25033   var match = key.match(findProc)
25034   var decrypted
25035   if (!match) {
25036     var match2 = key.match(fullRegex)
25037     decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64')
25038   } else {
25039     var suite = 'aes' + match[1]
25040     var iv = new Buffer(match[2], 'hex')
25041     var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64')
25042     var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
25043     var out = []
25044     var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
25045     out.push(cipher.update(cipherText))
25046     out.push(cipher.final())
25047     decrypted = Buffer.concat(out)
25048   }
25049   var tag = key.match(startRegex)[1]
25050   return {
25051     tag: tag,
25052     data: decrypted
25053   }
25054 }
25055
25056 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25057
25058 /***/ }),
25059 /* 258 */
25060 /***/ (function(module, exports, __webpack_require__) {
25061
25062 /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
25063 var BN = __webpack_require__(4)
25064 var EC = __webpack_require__(6).ec
25065 var parseKeys = __webpack_require__(46)
25066 var curves = __webpack_require__(124)
25067
25068 function verify (sig, hash, key, signType, tag) {
25069   var pub = parseKeys(key)
25070   if (pub.type === 'ec') {
25071     // rsa keys can be interpreted as ecdsa ones in openssl
25072     if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
25073     return ecVerify(sig, hash, pub)
25074   } else if (pub.type === 'dsa') {
25075     if (signType !== 'dsa') throw new Error('wrong public key type')
25076     return dsaVerify(sig, hash, pub)
25077   } else {
25078     if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
25079   }
25080   hash = Buffer.concat([tag, hash])
25081   var len = pub.modulus.byteLength()
25082   var pad = [ 1 ]
25083   var padNum = 0
25084   while (hash.length + pad.length + 2 < len) {
25085     pad.push(0xff)
25086     padNum++
25087   }
25088   pad.push(0x00)
25089   var i = -1
25090   while (++i < hash.length) {
25091     pad.push(hash[i])
25092   }
25093   pad = new Buffer(pad)
25094   var red = BN.mont(pub.modulus)
25095   sig = new BN(sig).toRed(red)
25096
25097   sig = sig.redPow(new BN(pub.publicExponent))
25098   sig = new Buffer(sig.fromRed().toArray())
25099   var out = padNum < 8 ? 1 : 0
25100   len = Math.min(sig.length, pad.length)
25101   if (sig.length !== pad.length) out = 1
25102
25103   i = -1
25104   while (++i < len) out |= sig[i] ^ pad[i]
25105   return out === 0
25106 }
25107
25108 function ecVerify (sig, hash, pub) {
25109   var curveId = curves[pub.data.algorithm.curve.join('.')]
25110   if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
25111
25112   var curve = new EC(curveId)
25113   var pubkey = pub.data.subjectPrivateKey.data
25114
25115   return curve.verify(hash, sig, pubkey)
25116 }
25117
25118 function dsaVerify (sig, hash, pub) {
25119   var p = pub.data.p
25120   var q = pub.data.q
25121   var g = pub.data.g
25122   var y = pub.data.pub_key
25123   var unpacked = parseKeys.signature.decode(sig, 'der')
25124   var s = unpacked.s
25125   var r = unpacked.r
25126   checkValue(s, q)
25127   checkValue(r, q)
25128   var montp = BN.mont(p)
25129   var w = s.invm(q)
25130   var v = g.toRed(montp)
25131     .redPow(new BN(hash).mul(w).mod(q))
25132     .fromRed()
25133     .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
25134     .mod(p)
25135     .mod(q)
25136   return v.cmp(r) === 0
25137 }
25138
25139 function checkValue (b, q) {
25140   if (b.cmpn(0) <= 0) throw new Error('invalid sig')
25141   if (b.cmp(q) >= q) throw new Error('invalid sig')
25142 }
25143
25144 module.exports = verify
25145
25146 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25147
25148 /***/ }),
25149 /* 259 */
25150 /***/ (function(module, exports, __webpack_require__) {
25151
25152 /* WEBPACK VAR INJECTION */(function(Buffer) {var elliptic = __webpack_require__(6)
25153 var BN = __webpack_require__(4)
25154
25155 module.exports = function createECDH (curve) {
25156   return new ECDH(curve)
25157 }
25158
25159 var aliases = {
25160   secp256k1: {
25161     name: 'secp256k1',
25162     byteLength: 32
25163   },
25164   secp224r1: {
25165     name: 'p224',
25166     byteLength: 28
25167   },
25168   prime256v1: {
25169     name: 'p256',
25170     byteLength: 32
25171   },
25172   prime192v1: {
25173     name: 'p192',
25174     byteLength: 24
25175   },
25176   ed25519: {
25177     name: 'ed25519',
25178     byteLength: 32
25179   },
25180   secp384r1: {
25181     name: 'p384',
25182     byteLength: 48
25183   },
25184   secp521r1: {
25185     name: 'p521',
25186     byteLength: 66
25187   }
25188 }
25189
25190 aliases.p224 = aliases.secp224r1
25191 aliases.p256 = aliases.secp256r1 = aliases.prime256v1
25192 aliases.p192 = aliases.secp192r1 = aliases.prime192v1
25193 aliases.p384 = aliases.secp384r1
25194 aliases.p521 = aliases.secp521r1
25195
25196 function ECDH (curve) {
25197   this.curveType = aliases[curve]
25198   if (!this.curveType) {
25199     this.curveType = {
25200       name: curve
25201     }
25202   }
25203   this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
25204   this.keys = void 0
25205 }
25206
25207 ECDH.prototype.generateKeys = function (enc, format) {
25208   this.keys = this.curve.genKeyPair()
25209   return this.getPublicKey(enc, format)
25210 }
25211
25212 ECDH.prototype.computeSecret = function (other, inenc, enc) {
25213   inenc = inenc || 'utf8'
25214   if (!Buffer.isBuffer(other)) {
25215     other = new Buffer(other, inenc)
25216   }
25217   var otherPub = this.curve.keyFromPublic(other).getPublic()
25218   var out = otherPub.mul(this.keys.getPrivate()).getX()
25219   return formatReturnValue(out, enc, this.curveType.byteLength)
25220 }
25221
25222 ECDH.prototype.getPublicKey = function (enc, format) {
25223   var key = this.keys.getPublic(format === 'compressed', true)
25224   if (format === 'hybrid') {
25225     if (key[key.length - 1] % 2) {
25226       key[0] = 7
25227     } else {
25228       key[0] = 6
25229     }
25230   }
25231   return formatReturnValue(key, enc)
25232 }
25233
25234 ECDH.prototype.getPrivateKey = function (enc) {
25235   return formatReturnValue(this.keys.getPrivate(), enc)
25236 }
25237
25238 ECDH.prototype.setPublicKey = function (pub, enc) {
25239   enc = enc || 'utf8'
25240   if (!Buffer.isBuffer(pub)) {
25241     pub = new Buffer(pub, enc)
25242   }
25243   this.keys._importPublic(pub)
25244   return this
25245 }
25246
25247 ECDH.prototype.setPrivateKey = function (priv, enc) {
25248   enc = enc || 'utf8'
25249   if (!Buffer.isBuffer(priv)) {
25250     priv = new Buffer(priv, enc)
25251   }
25252
25253   var _priv = new BN(priv)
25254   _priv = _priv.toString(16)
25255   this.keys = this.curve.genKeyPair()
25256   this.keys._importPrivate(_priv)
25257   return this
25258 }
25259
25260 function formatReturnValue (bn, enc, len) {
25261   if (!Array.isArray(bn)) {
25262     bn = bn.toArray()
25263   }
25264   var buf = new Buffer(bn)
25265   if (len && buf.length < len) {
25266     var zeros = new Buffer(len - buf.length)
25267     zeros.fill(0)
25268     buf = Buffer.concat([zeros, buf])
25269   }
25270   if (!enc) {
25271     return buf
25272   } else {
25273     return buf.toString(enc)
25274   }
25275 }
25276
25277 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25278
25279 /***/ }),
25280 /* 260 */
25281 /***/ (function(module, exports, __webpack_require__) {
25282
25283 exports.publicEncrypt = __webpack_require__(261);
25284 exports.privateDecrypt = __webpack_require__(262);
25285
25286 exports.privateEncrypt = function privateEncrypt(key, buf) {
25287   return exports.publicEncrypt(key, buf, true);
25288 };
25289
25290 exports.publicDecrypt = function publicDecrypt(key, buf) {
25291   return exports.privateDecrypt(key, buf, true);
25292 };
25293
25294 /***/ }),
25295 /* 261 */
25296 /***/ (function(module, exports, __webpack_require__) {
25297
25298 /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(46);
25299 var randomBytes = __webpack_require__(23);
25300 var createHash = __webpack_require__(29);
25301 var mgf = __webpack_require__(125);
25302 var xor = __webpack_require__(126);
25303 var bn = __webpack_require__(4);
25304 var withPublic = __webpack_require__(127);
25305 var crt = __webpack_require__(67);
25306
25307 var constants = {
25308   RSA_PKCS1_OAEP_PADDING: 4,
25309   RSA_PKCS1_PADDIN: 1,
25310   RSA_NO_PADDING: 3
25311 };
25312
25313 module.exports = function publicEncrypt(public_key, msg, reverse) {
25314   var padding;
25315   if (public_key.padding) {
25316     padding = public_key.padding;
25317   } else if (reverse) {
25318     padding = 1;
25319   } else {
25320     padding = 4;
25321   }
25322   var key = parseKeys(public_key);
25323   var paddedMsg;
25324   if (padding === 4) {
25325     paddedMsg = oaep(key, msg);
25326   } else if (padding === 1) {
25327     paddedMsg = pkcs1(key, msg, reverse);
25328   } else if (padding === 3) {
25329     paddedMsg = new bn(msg);
25330     if (paddedMsg.cmp(key.modulus) >= 0) {
25331       throw new Error('data too long for modulus');
25332     }
25333   } else {
25334     throw new Error('unknown padding');
25335   }
25336   if (reverse) {
25337     return crt(paddedMsg, key);
25338   } else {
25339     return withPublic(paddedMsg, key);
25340   }
25341 };
25342
25343 function oaep(key, msg){
25344   var k = key.modulus.byteLength();
25345   var mLen = msg.length;
25346   var iHash = createHash('sha1').update(new Buffer('')).digest();
25347   var hLen = iHash.length;
25348   var hLen2 = 2 * hLen;
25349   if (mLen > k - hLen2 - 2) {
25350     throw new Error('message too long');
25351   }
25352   var ps = new Buffer(k - mLen - hLen2 - 2);
25353   ps.fill(0);
25354   var dblen = k - hLen - 1;
25355   var seed = randomBytes(hLen);
25356   var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen));
25357   var maskedSeed = xor(seed, mgf(maskedDb, hLen));
25358   return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k));
25359 }
25360 function pkcs1(key, msg, reverse){
25361   var mLen = msg.length;
25362   var k = key.modulus.byteLength();
25363   if (mLen > k - 11) {
25364     throw new Error('message too long');
25365   }
25366   var ps;
25367   if (reverse) {
25368     ps = new Buffer(k - mLen - 3);
25369     ps.fill(0xff);
25370   } else {
25371     ps = nonZero(k - mLen - 3);
25372   }
25373   return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k));
25374 }
25375 function nonZero(len, crypto) {
25376   var out = new Buffer(len);
25377   var i = 0;
25378   var cache = randomBytes(len*2);
25379   var cur = 0;
25380   var num;
25381   while (i < len) {
25382     if (cur === cache.length) {
25383       cache = randomBytes(len*2);
25384       cur = 0;
25385     }
25386     num = cache[cur++];
25387     if (num) {
25388       out[i++] = num;
25389     }
25390   }
25391   return out;
25392 }
25393 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25394
25395 /***/ }),
25396 /* 262 */
25397 /***/ (function(module, exports, __webpack_require__) {
25398
25399 /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(46);
25400 var mgf = __webpack_require__(125);
25401 var xor = __webpack_require__(126);
25402 var bn = __webpack_require__(4);
25403 var crt = __webpack_require__(67);
25404 var createHash = __webpack_require__(29);
25405 var withPublic = __webpack_require__(127);
25406 module.exports = function privateDecrypt(private_key, enc, reverse) {
25407   var padding;
25408   if (private_key.padding) {
25409     padding = private_key.padding;
25410   } else if (reverse) {
25411     padding = 1;
25412   } else {
25413     padding = 4;
25414   }
25415   
25416   var key = parseKeys(private_key);
25417   var k = key.modulus.byteLength();
25418   if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
25419     throw new Error('decryption error');
25420   }
25421   var msg;
25422   if (reverse) {
25423     msg = withPublic(new bn(enc), key);
25424   } else {
25425     msg = crt(enc, key);
25426   }
25427   var zBuffer = new Buffer(k - msg.length);
25428   zBuffer.fill(0);
25429   msg = Buffer.concat([zBuffer, msg], k);
25430   if (padding === 4) {
25431     return oaep(key, msg);
25432   } else if (padding === 1) {
25433     return pkcs1(key, msg, reverse);
25434   } else if (padding === 3) {
25435     return msg;
25436   } else {
25437     throw new Error('unknown padding');
25438   }
25439 };
25440
25441 function oaep(key, msg){
25442   var n = key.modulus;
25443   var k = key.modulus.byteLength();
25444   var mLen = msg.length;
25445   var iHash = createHash('sha1').update(new Buffer('')).digest();
25446   var hLen = iHash.length;
25447   var hLen2 = 2 * hLen;
25448   if (msg[0] !== 0) {
25449     throw new Error('decryption error');
25450   }
25451   var maskedSeed = msg.slice(1, hLen + 1);
25452   var maskedDb =  msg.slice(hLen + 1);
25453   var seed = xor(maskedSeed, mgf(maskedDb, hLen));
25454   var db = xor(maskedDb, mgf(seed, k - hLen - 1));
25455   if (compare(iHash, db.slice(0, hLen))) {
25456     throw new Error('decryption error');
25457   }
25458   var i = hLen;
25459   while (db[i] === 0) {
25460     i++;
25461   }
25462   if (db[i++] !== 1) {
25463     throw new Error('decryption error');
25464   }
25465   return db.slice(i);
25466 }
25467
25468 function pkcs1(key, msg, reverse){
25469   var p1 = msg.slice(0, 2);
25470   var i = 2;
25471   var status = 0;
25472   while (msg[i++] !== 0) {
25473     if (i >= msg.length) {
25474       status++;
25475       break;
25476     }
25477   }
25478   var ps = msg.slice(2, i - 1);
25479   var p2 = msg.slice(i - 1, i);
25480
25481   if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){
25482     status++;
25483   }
25484   if (ps.length < 8) {
25485     status++;
25486   }
25487   if (status) {
25488     throw new Error('decryption error');
25489   }
25490   return  msg.slice(i);
25491 }
25492 function compare(a, b){
25493   a = new Buffer(a);
25494   b = new Buffer(b);
25495   var dif = 0;
25496   var len = a.length;
25497   if (a.length !== b.length) {
25498     dif++;
25499     len = Math.min(a.length, b.length);
25500   }
25501   var i = -1;
25502   while (++i < len) {
25503     dif += (a[i] ^ b[i]);
25504   }
25505   return dif;
25506 }
25507 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).Buffer))
25508
25509 /***/ }),
25510 /* 263 */
25511 /***/ (function(module, exports, __webpack_require__) {
25512
25513 "use strict";
25514 /* WEBPACK VAR INJECTION */(function(global, process) {
25515
25516 function oldBrowser () {
25517   throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
25518 }
25519 var safeBuffer = __webpack_require__(2)
25520 var randombytes = __webpack_require__(23)
25521 var Buffer = safeBuffer.Buffer
25522 var kBufferMaxLength = safeBuffer.kMaxLength
25523 var crypto = global.crypto || global.msCrypto
25524 var kMaxUint32 = Math.pow(2, 32) - 1
25525 function assertOffset (offset, length) {
25526   if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
25527     throw new TypeError('offset must be a number')
25528   }
25529
25530   if (offset > kMaxUint32 || offset < 0) {
25531     throw new TypeError('offset must be a uint32')
25532   }
25533
25534   if (offset > kBufferMaxLength || offset > length) {
25535     throw new RangeError('offset out of range')
25536   }
25537 }
25538
25539 function assertSize (size, offset, length) {
25540   if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
25541     throw new TypeError('size must be a number')
25542   }
25543
25544   if (size > kMaxUint32 || size < 0) {
25545     throw new TypeError('size must be a uint32')
25546   }
25547
25548   if (size + offset > length || size > kBufferMaxLength) {
25549     throw new RangeError('buffer too small')
25550   }
25551 }
25552 if ((crypto && crypto.getRandomValues) || !process.browser) {
25553   exports.randomFill = randomFill
25554   exports.randomFillSync = randomFillSync
25555 } else {
25556   exports.randomFill = oldBrowser
25557   exports.randomFillSync = oldBrowser
25558 }
25559 function randomFill (buf, offset, size, cb) {
25560   if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
25561     throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25562   }
25563
25564   if (typeof offset === 'function') {
25565     cb = offset
25566     offset = 0
25567     size = buf.length
25568   } else if (typeof size === 'function') {
25569     cb = size
25570     size = buf.length - offset
25571   } else if (typeof cb !== 'function') {
25572     throw new TypeError('"cb" argument must be a function')
25573   }
25574   assertOffset(offset, buf.length)
25575   assertSize(size, offset, buf.length)
25576   return actualFill(buf, offset, size, cb)
25577 }
25578
25579 function actualFill (buf, offset, size, cb) {
25580   if (process.browser) {
25581     var ourBuf = buf.buffer
25582     var uint = new Uint8Array(ourBuf, offset, size)
25583     crypto.getRandomValues(uint)
25584     if (cb) {
25585       process.nextTick(function () {
25586         cb(null, buf)
25587       })
25588       return
25589     }
25590     return buf
25591   }
25592   if (cb) {
25593     randombytes(size, function (err, bytes) {
25594       if (err) {
25595         return cb(err)
25596       }
25597       bytes.copy(buf, offset)
25598       cb(null, buf)
25599     })
25600     return
25601   }
25602   var bytes = randombytes(size)
25603   bytes.copy(buf, offset)
25604   return buf
25605 }
25606 function randomFillSync (buf, offset, size) {
25607   if (typeof offset === 'undefined') {
25608     offset = 0
25609   }
25610   if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
25611     throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25612   }
25613
25614   assertOffset(offset, buf.length)
25615
25616   if (size === undefined) size = buf.length - offset
25617
25618   assertSize(size, offset, buf.length)
25619
25620   return actualFill(buf, offset, size)
25621 }
25622
25623 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(14)))
25624
25625 /***/ }),
25626 /* 264 */
25627 /***/ (function(module, exports, __webpack_require__) {
25628
25629 "use strict";
25630 \r
25631 Object.defineProperty(exports, "__esModule", { value: true });\r
25632 class LocalStream {\r
25633     static send(msg) {\r
25634         return new Promise((resolve, reject) => {\r
25635             chrome.runtime.sendMessage(msg, (response) => resolve(response));\r
25636         });\r
25637     }\r
25638     static watch(callback) {\r
25639         chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {\r
25640             if (sender.id !== chrome.runtime.id)\r
25641                 return;\r
25642             callback(request, sendResponse);\r
25643             return true;\r
25644         });\r
25645     }\r
25646 }\r
25647 exports.LocalStream = LocalStream;\r
25648 exports.default = LocalStream;\r
25649 //# sourceMappingURL=LocalStream.js.map
25650
25651 /***/ }),
25652 /* 265 */
25653 /***/ (function(module, exports, __webpack_require__) {
25654
25655 "use strict";
25656
25657
25658 exports.__esModule = true;
25659
25660 var _defineProperty = __webpack_require__(136);
25661
25662 var _defineProperty2 = _interopRequireDefault(_defineProperty);
25663
25664 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25665
25666 exports.default = function (obj, key, value) {
25667   if (key in obj) {
25668     (0, _defineProperty2.default)(obj, key, {
25669       value: value,
25670       enumerable: true,
25671       configurable: true,
25672       writable: true
25673     });
25674   } else {
25675     obj[key] = value;
25676   }
25677
25678   return obj;
25679 };
25680
25681 /***/ }),
25682 /* 266 */,
25683 /* 267 */
25684 /***/ (function(module, __webpack_exports__, __webpack_require__) {
25685
25686 "use strict";
25687 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__ = __webpack_require__(69);
25688 /* 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__);
25689 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
25690 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
25691 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__ = __webpack_require__(36);
25692 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__);
25693 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_extension_streams__ = __webpack_require__(137);
25694 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_extension_streams___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_extension_streams__);
25695
25696
25697
25698
25699
25700 var InternalMessage = function () {
25701   function InternalMessage() {
25702     __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, InternalMessage);
25703
25704     this.type = '';
25705     this.payload = '';
25706   }
25707
25708   __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(InternalMessage, [{
25709     key: 'send',
25710     value: function send() {
25711       return __WEBPACK_IMPORTED_MODULE_3_extension_streams__["LocalStream"].send(this);
25712     }
25713   }], [{
25714     key: 'initMessage',
25715     value: function initMessage() {
25716       return new InternalMessage();
25717     }
25718   }, {
25719     key: 'fromJson',
25720     value: function fromJson(json) {
25721       return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default()(this.initMessage(), json);
25722     }
25723   }, {
25724     key: 'payload',
25725     value: function payload(type, _payload) {
25726       var p = this.initMessage();
25727       p.type = type;
25728       p.payload = _payload;
25729       return p;
25730     }
25731   }, {
25732     key: 'signal',
25733     value: function signal(type) {
25734       var p = this.initMessage();
25735       p.type = type;
25736       return p;
25737     }
25738   }]);
25739
25740   return InternalMessage;
25741 }();
25742
25743 /* harmony default export */ __webpack_exports__["a"] = (InternalMessage);
25744
25745 /***/ }),
25746 /* 268 */
25747 /***/ (function(module, __webpack_exports__, __webpack_require__) {
25748
25749 "use strict";
25750 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return BTM; });
25751 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return camelize; });
25752 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return networks; });
25753 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return networksJS; });
25754 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__ = __webpack_require__(145);
25755 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof__);
25756
25757 var BTM = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
25758
25759 var camelize = function camelize(object) {
25760   for (var key in object) {
25761     var value = object[key];
25762     var newKey = key;
25763
25764     if (/_/.test(key)) {
25765       newKey = key.replace(/([_][a-z])/g, function (v) {
25766         return v[1].toUpperCase();
25767       });
25768       delete object[key];
25769     }
25770
25771     if ((typeof value === 'undefined' ? 'undefined' : __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_typeof___default()(value)) == 'object') {
25772       value = camelize(value);
25773     }
25774
25775     object[newKey] = value;
25776   }
25777
25778   return object;
25779 };
25780
25781 var networks = {
25782   mainnet: 'https://bcapi.movapi.com'
25783 };
25784
25785 var networksJS = {
25786   mainnet: networks['mainnet'] + '/bytom/v3/',
25787   mainnetvapor: networks['mainnet'] + '/vapor/v3/'
25788 };
25789
25790 /***/ }),
25791 /* 269 */,
25792 /* 270 */,
25793 /* 271 */,
25794 /* 272 */
25795 /***/ (function(module, exports, __webpack_require__) {
25796
25797 module.exports = { "default": __webpack_require__(273), __esModule: true };
25798
25799 /***/ }),
25800 /* 273 */
25801 /***/ (function(module, exports, __webpack_require__) {
25802
25803 __webpack_require__(132);
25804 __webpack_require__(79);
25805 module.exports = __webpack_require__(81).f('iterator');
25806
25807
25808 /***/ }),
25809 /* 274 */
25810 /***/ (function(module, exports, __webpack_require__) {
25811
25812 module.exports = { "default": __webpack_require__(275), __esModule: true };
25813
25814 /***/ }),
25815 /* 275 */
25816 /***/ (function(module, exports, __webpack_require__) {
25817
25818 __webpack_require__(276);
25819 __webpack_require__(77);
25820 __webpack_require__(280);
25821 __webpack_require__(281);
25822 module.exports = __webpack_require__(8).Symbol;
25823
25824
25825 /***/ }),
25826 /* 276 */
25827 /***/ (function(module, exports, __webpack_require__) {
25828
25829 "use strict";
25830
25831 // ECMAScript 6 symbols shim
25832 var global = __webpack_require__(5);
25833 var has = __webpack_require__(20);
25834 var DESCRIPTORS = __webpack_require__(17);
25835 var $export = __webpack_require__(13);
25836 var redefine = __webpack_require__(78);
25837 var META = __webpack_require__(93).KEY;
25838 var $fails = __webpack_require__(22);
25839 var shared = __webpack_require__(70);
25840 var setToStringTag = __webpack_require__(40);
25841 var uid = __webpack_require__(47);
25842 var wks = __webpack_require__(7);
25843 var wksExt = __webpack_require__(81);
25844 var wksDefine = __webpack_require__(82);
25845 var enumKeys = __webpack_require__(277);
25846 var isArray = __webpack_require__(143);
25847 var anObject = __webpack_require__(15);
25848 var isObject = __webpack_require__(12);
25849 var toIObject = __webpack_require__(25);
25850 var toPrimitive = __webpack_require__(72);
25851 var createDesc = __webpack_require__(48);
25852 var _create = __webpack_require__(133);
25853 var gOPNExt = __webpack_require__(278);
25854 var $GOPD = __webpack_require__(279);
25855 var $DP = __webpack_require__(16);
25856 var $keys = __webpack_require__(39);
25857 var gOPD = $GOPD.f;
25858 var dP = $DP.f;
25859 var gOPN = gOPNExt.f;
25860 var $Symbol = global.Symbol;
25861 var $JSON = global.JSON;
25862 var _stringify = $JSON && $JSON.stringify;
25863 var PROTOTYPE = 'prototype';
25864 var HIDDEN = wks('_hidden');
25865 var TO_PRIMITIVE = wks('toPrimitive');
25866 var isEnum = {}.propertyIsEnumerable;
25867 var SymbolRegistry = shared('symbol-registry');
25868 var AllSymbols = shared('symbols');
25869 var OPSymbols = shared('op-symbols');
25870 var ObjectProto = Object[PROTOTYPE];
25871 var USE_NATIVE = typeof $Symbol == 'function';
25872 var QObject = global.QObject;
25873 // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
25874 var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
25875
25876 // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
25877 var setSymbolDesc = DESCRIPTORS && $fails(function () {
25878   return _create(dP({}, 'a', {
25879     get: function () { return dP(this, 'a', { value: 7 }).a; }
25880   })).a != 7;
25881 }) ? function (it, key, D) {
25882   var protoDesc = gOPD(ObjectProto, key);
25883   if (protoDesc) delete ObjectProto[key];
25884   dP(it, key, D);
25885   if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
25886 } : dP;
25887
25888 var wrap = function (tag) {
25889   var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
25890   sym._k = tag;
25891   return sym;
25892 };
25893
25894 var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
25895   return typeof it == 'symbol';
25896 } : function (it) {
25897   return it instanceof $Symbol;
25898 };
25899
25900 var $defineProperty = function defineProperty(it, key, D) {
25901   if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
25902   anObject(it);
25903   key = toPrimitive(key, true);
25904   anObject(D);
25905   if (has(AllSymbols, key)) {
25906     if (!D.enumerable) {
25907       if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
25908       it[HIDDEN][key] = true;
25909     } else {
25910       if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
25911       D = _create(D, { enumerable: createDesc(0, false) });
25912     } return setSymbolDesc(it, key, D);
25913   } return dP(it, key, D);
25914 };
25915 var $defineProperties = function defineProperties(it, P) {
25916   anObject(it);
25917   var keys = enumKeys(P = toIObject(P));
25918   var i = 0;
25919   var l = keys.length;
25920   var key;
25921   while (l > i) $defineProperty(it, key = keys[i++], P[key]);
25922   return it;
25923 };
25924 var $create = function create(it, P) {
25925   return P === undefined ? _create(it) : $defineProperties(_create(it), P);
25926 };
25927 var $propertyIsEnumerable = function propertyIsEnumerable(key) {
25928   var E = isEnum.call(this, key = toPrimitive(key, true));
25929   if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
25930   return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
25931 };
25932 var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
25933   it = toIObject(it);
25934   key = toPrimitive(key, true);
25935   if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
25936   var D = gOPD(it, key);
25937   if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
25938   return D;
25939 };
25940 var $getOwnPropertyNames = function getOwnPropertyNames(it) {
25941   var names = gOPN(toIObject(it));
25942   var result = [];
25943   var i = 0;
25944   var key;
25945   while (names.length > i) {
25946     if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
25947   } return result;
25948 };
25949 var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
25950   var IS_OP = it === ObjectProto;
25951   var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
25952   var result = [];
25953   var i = 0;
25954   var key;
25955   while (names.length > i) {
25956     if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
25957   } return result;
25958 };
25959
25960 // 19.4.1.1 Symbol([description])
25961 if (!USE_NATIVE) {
25962   $Symbol = function Symbol() {
25963     if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
25964     var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
25965     var $set = function (value) {
25966       if (this === ObjectProto) $set.call(OPSymbols, value);
25967       if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
25968       setSymbolDesc(this, tag, createDesc(1, value));
25969     };
25970     if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
25971     return wrap(tag);
25972   };
25973   redefine($Symbol[PROTOTYPE], 'toString', function toString() {
25974     return this._k;
25975   });
25976
25977   $GOPD.f = $getOwnPropertyDescriptor;
25978   $DP.f = $defineProperty;
25979   __webpack_require__(142).f = gOPNExt.f = $getOwnPropertyNames;
25980   __webpack_require__(49).f = $propertyIsEnumerable;
25981   __webpack_require__(73).f = $getOwnPropertySymbols;
25982
25983   if (DESCRIPTORS && !__webpack_require__(37)) {
25984     redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
25985   }
25986
25987   wksExt.f = function (name) {
25988     return wrap(wks(name));
25989   };
25990 }
25991
25992 $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
25993
25994 for (var es6Symbols = (
25995   // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
25996   'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
25997 ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
25998
25999 for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
26000
26001 $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
26002   // 19.4.2.1 Symbol.for(key)
26003   'for': function (key) {
26004     return has(SymbolRegistry, key += '')
26005       ? SymbolRegistry[key]
26006       : SymbolRegistry[key] = $Symbol(key);
26007   },
26008   // 19.4.2.5 Symbol.keyFor(sym)
26009   keyFor: function keyFor(sym) {
26010     if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
26011     for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
26012   },
26013   useSetter: function () { setter = true; },
26014   useSimple: function () { setter = false; }
26015 });
26016
26017 $export($export.S + $export.F * !USE_NATIVE, 'Object', {
26018   // 19.1.2.2 Object.create(O [, Properties])
26019   create: $create,
26020   // 19.1.2.4 Object.defineProperty(O, P, Attributes)
26021   defineProperty: $defineProperty,
26022   // 19.1.2.3 Object.defineProperties(O, Properties)
26023   defineProperties: $defineProperties,
26024   // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
26025   getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
26026   // 19.1.2.7 Object.getOwnPropertyNames(O)
26027   getOwnPropertyNames: $getOwnPropertyNames,
26028   // 19.1.2.8 Object.getOwnPropertySymbols(O)
26029   getOwnPropertySymbols: $getOwnPropertySymbols
26030 });
26031
26032 // 24.3.2 JSON.stringify(value [, replacer [, space]])
26033 $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
26034   var S = $Symbol();
26035   // MS Edge converts symbol values to JSON as {}
26036   // WebKit converts symbol values to JSON as null
26037   // V8 throws on boxed symbols
26038   return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
26039 })), 'JSON', {
26040   stringify: function stringify(it) {
26041     var args = [it];
26042     var i = 1;
26043     var replacer, $replacer;
26044     while (arguments.length > i) args.push(arguments[i++]);
26045     $replacer = replacer = args[1];
26046     if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
26047     if (!isArray(replacer)) replacer = function (key, value) {
26048       if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
26049       if (!isSymbol(value)) return value;
26050     };
26051     args[1] = replacer;
26052     return _stringify.apply($JSON, args);
26053   }
26054 });
26055
26056 // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
26057 $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(19)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
26058 // 19.4.3.5 Symbol.prototype[@@toStringTag]
26059 setToStringTag($Symbol, 'Symbol');
26060 // 20.2.1.9 Math[@@toStringTag]
26061 setToStringTag(Math, 'Math', true);
26062 // 24.3.3 JSON[@@toStringTag]
26063 setToStringTag(global.JSON, 'JSON', true);
26064
26065
26066 /***/ }),
26067 /* 277 */
26068 /***/ (function(module, exports, __webpack_require__) {
26069
26070 // all enumerable object keys, includes symbols
26071 var getKeys = __webpack_require__(39);
26072 var gOPS = __webpack_require__(73);
26073 var pIE = __webpack_require__(49);
26074 module.exports = function (it) {
26075   var result = getKeys(it);
26076   var getSymbols = gOPS.f;
26077   if (getSymbols) {
26078     var symbols = getSymbols(it);
26079     var isEnum = pIE.f;
26080     var i = 0;
26081     var key;
26082     while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
26083   } return result;
26084 };
26085
26086
26087 /***/ }),
26088 /* 278 */
26089 /***/ (function(module, exports, __webpack_require__) {
26090
26091 // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
26092 var toIObject = __webpack_require__(25);
26093 var gOPN = __webpack_require__(142).f;
26094 var toString = {}.toString;
26095
26096 var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
26097   ? Object.getOwnPropertyNames(window) : [];
26098
26099 var getWindowNames = function (it) {
26100   try {
26101     return gOPN(it);
26102   } catch (e) {
26103     return windowNames.slice();
26104   }
26105 };
26106
26107 module.exports.f = function getOwnPropertyNames(it) {
26108   return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
26109 };
26110
26111
26112 /***/ }),
26113 /* 279 */
26114 /***/ (function(module, exports, __webpack_require__) {
26115
26116 var pIE = __webpack_require__(49);
26117 var createDesc = __webpack_require__(48);
26118 var toIObject = __webpack_require__(25);
26119 var toPrimitive = __webpack_require__(72);
26120 var has = __webpack_require__(20);
26121 var IE8_DOM_DEFINE = __webpack_require__(130);
26122 var gOPD = Object.getOwnPropertyDescriptor;
26123
26124 exports.f = __webpack_require__(17) ? gOPD : function getOwnPropertyDescriptor(O, P) {
26125   O = toIObject(O);
26126   P = toPrimitive(P, true);
26127   if (IE8_DOM_DEFINE) try {
26128     return gOPD(O, P);
26129   } catch (e) { /* empty */ }
26130   if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
26131 };
26132
26133
26134 /***/ }),
26135 /* 280 */
26136 /***/ (function(module, exports, __webpack_require__) {
26137
26138 __webpack_require__(82)('asyncIterator');
26139
26140
26141 /***/ }),
26142 /* 281 */
26143 /***/ (function(module, exports, __webpack_require__) {
26144
26145 __webpack_require__(82)('observable');
26146
26147
26148 /***/ }),
26149 /* 282 */,
26150 /* 283 */,
26151 /* 284 */,
26152 /* 285 */,
26153 /* 286 */,
26154 /* 287 */,
26155 /* 288 */,
26156 /* 289 */,
26157 /* 290 */,
26158 /* 291 */,
26159 /* 292 */,
26160 /* 293 */,
26161 /* 294 */,
26162 /* 295 */,
26163 /* 296 */,
26164 /* 297 */,
26165 /* 298 */,
26166 /* 299 */,
26167 /* 300 */,
26168 /* 301 */,
26169 /* 302 */,
26170 /* 303 */,
26171 /* 304 */,
26172 /* 305 */,
26173 /* 306 */,
26174 /* 307 */,
26175 /* 308 */,
26176 /* 309 */,
26177 /* 310 */,
26178 /* 311 */,
26179 /* 312 */,
26180 /* 313 */,
26181 /* 314 */,
26182 /* 315 */,
26183 /* 316 */,
26184 /* 317 */,
26185 /* 318 */,
26186 /* 319 */,
26187 /* 320 */,
26188 /* 321 */,
26189 /* 322 */,
26190 /* 323 */,
26191 /* 324 */,
26192 /* 325 */,
26193 /* 326 */,
26194 /* 327 */,
26195 /* 328 */,
26196 /* 329 */,
26197 /* 330 */,
26198 /* 331 */,
26199 /* 332 */,
26200 /* 333 */,
26201 /* 334 */,
26202 /* 335 */,
26203 /* 336 */,
26204 /* 337 */,
26205 /* 338 */,
26206 /* 339 */,
26207 /* 340 */,
26208 /* 341 */,
26209 /* 342 */,
26210 /* 343 */,
26211 /* 344 */,
26212 /* 345 */,
26213 /* 346 */,
26214 /* 347 */,
26215 /* 348 */,
26216 /* 349 */,
26217 /* 350 */,
26218 /* 351 */,
26219 /* 352 */,
26220 /* 353 */,
26221 /* 354 */,
26222 /* 355 */,
26223 /* 356 */,
26224 /* 357 */,
26225 /* 358 */,
26226 /* 359 */,
26227 /* 360 */,
26228 /* 361 */,
26229 /* 362 */,
26230 /* 363 */,
26231 /* 364 */,
26232 /* 365 */,
26233 /* 366 */,
26234 /* 367 */,
26235 /* 368 */,
26236 /* 369 */,
26237 /* 370 */,
26238 /* 371 */,
26239 /* 372 */,
26240 /* 373 */,
26241 /* 374 */,
26242 /* 375 */,
26243 /* 376 */,
26244 /* 377 */,
26245 /* 378 */,
26246 /* 379 */,
26247 /* 380 */,
26248 /* 381 */,
26249 /* 382 */,
26250 /* 383 */,
26251 /* 384 */,
26252 /* 385 */,
26253 /* 386 */,
26254 /* 387 */,
26255 /* 388 */,
26256 /* 389 */,
26257 /* 390 */,
26258 /* 391 */,
26259 /* 392 */,
26260 /* 393 */,
26261 /* 394 */,
26262 /* 395 */,
26263 /* 396 */,
26264 /* 397 */,
26265 /* 398 */,
26266 /* 399 */,
26267 /* 400 */,
26268 /* 401 */,
26269 /* 402 */,
26270 /* 403 */,
26271 /* 404 */,
26272 /* 405 */,
26273 /* 406 */,
26274 /* 407 */,
26275 /* 408 */,
26276 /* 409 */,
26277 /* 410 */,
26278 /* 411 */,
26279 /* 412 */,
26280 /* 413 */,
26281 /* 414 */,
26282 /* 415 */,
26283 /* 416 */
26284 /***/ (function(module, exports, __webpack_require__) {
26285
26286 var core = __webpack_require__(8);
26287 var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
26288 module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
26289   return $JSON.stringify.apply($JSON, arguments);
26290 };
26291
26292
26293 /***/ }),
26294 /* 417 */,
26295 /* 418 */,
26296 /* 419 */,
26297 /* 420 */
26298 /***/ (function(module, exports, __webpack_require__) {
26299
26300 module.exports = { "default": __webpack_require__(421), __esModule: true };
26301
26302 /***/ }),
26303 /* 421 */
26304 /***/ (function(module, exports, __webpack_require__) {
26305
26306 __webpack_require__(422);
26307 module.exports = __webpack_require__(8).Object.keys;
26308
26309
26310 /***/ }),
26311 /* 422 */
26312 /***/ (function(module, exports, __webpack_require__) {
26313
26314 // 19.1.2.14 Object.keys(O)
26315 var toObject = __webpack_require__(54);
26316 var $keys = __webpack_require__(39);
26317
26318 __webpack_require__(423)('keys', function () {
26319   return function keys(it) {
26320     return $keys(toObject(it));
26321   };
26322 });
26323
26324
26325 /***/ }),
26326 /* 423 */
26327 /***/ (function(module, exports, __webpack_require__) {
26328
26329 // most Object methods by ES6 should accept primitives
26330 var $export = __webpack_require__(13);
26331 var core = __webpack_require__(8);
26332 var fails = __webpack_require__(22);
26333 module.exports = function (KEY, exec) {
26334   var fn = (core.Object || {})[KEY] || Object[KEY];
26335   var exp = {};
26336   exp[KEY] = exec(fn);
26337   $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
26338 };
26339
26340
26341 /***/ }),
26342 /* 424 */,
26343 /* 425 */,
26344 /* 426 */,
26345 /* 427 */,
26346 /* 428 */
26347 /***/ (function(module, __webpack_exports__, __webpack_require__) {
26348
26349 "use strict";
26350 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__ = __webpack_require__(69);
26351 /* 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__);
26352 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
26353 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify__);
26354 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
26355 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__);
26356 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__ = __webpack_require__(36);
26357 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__);
26358 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Settings__ = __webpack_require__(429);
26359
26360
26361
26362
26363
26364
26365 var BytomObj = function () {
26366     function BytomObj() {
26367         __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default()(this, BytomObj);
26368
26369         this.settings = __WEBPACK_IMPORTED_MODULE_4__Settings__["a" /* default */].placeholder();
26370     }
26371
26372     __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default()(BytomObj, [{
26373         key: 'clone',
26374         value: function clone() {
26375             return BytomObj.fromJson(JSON.parse(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default()(this)));
26376         }
26377     }], [{
26378         key: 'placeholder',
26379         value: function placeholder() {
26380             return new BytomObj();
26381         }
26382     }, {
26383         key: 'fromJson',
26384         value: function fromJson(json) {
26385             var p = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default()(this.placeholder(), json);
26386             if (json.hasOwnProperty('settings')) p.settings = __WEBPACK_IMPORTED_MODULE_4__Settings__["a" /* default */].fromJson(json.settings);
26387             return p;
26388         }
26389     }]);
26390
26391     return BytomObj;
26392 }();
26393
26394 /* harmony default export */ __webpack_exports__["a"] = (BytomObj);
26395
26396 /***/ }),
26397 /* 429 */
26398 /***/ (function(module, __webpack_exports__, __webpack_require__) {
26399
26400 "use strict";
26401 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__ = __webpack_require__(69);
26402 /* 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__);
26403 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
26404 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
26405 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__ = __webpack_require__(36);
26406 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__);
26407
26408
26409
26410
26411 var Settings = function () {
26412     function Settings() {
26413         __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, Settings);
26414
26415         this.domains = [];
26416         this.language = 'ENGLISH';
26417     }
26418
26419     __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(Settings, null, [{
26420         key: 'placeholder',
26421         value: function placeholder() {
26422             return new Settings();
26423         }
26424     }, {
26425         key: 'fromJson',
26426         value: function fromJson(json) {
26427             var p = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default()(this.placeholder(), json);
26428             if (json.hasOwnProperty('domains')) p.domains = json.domains;
26429             return p;
26430         }
26431     }]);
26432
26433     return Settings;
26434 }();
26435
26436 /* harmony default export */ __webpack_exports__["a"] = (Settings);
26437
26438 /***/ }),
26439 /* 430 */,
26440 /* 431 */,
26441 /* 432 */,
26442 /* 433 */,
26443 /* 434 */
26444 /***/ (function(module, exports, __webpack_require__) {
26445
26446 /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
26447  * @license
26448  * Lodash <https://lodash.com/>
26449  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
26450  * Released under MIT license <https://lodash.com/license>
26451  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
26452  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
26453  */
26454 ;(function() {
26455
26456   /** Used as a safe reference for `undefined` in pre-ES5 environments. */
26457   var undefined;
26458
26459   /** Used as the semantic version number. */
26460   var VERSION = '4.17.15';
26461
26462   /** Used as the size to enable large array optimizations. */
26463   var LARGE_ARRAY_SIZE = 200;
26464
26465   /** Error message constants. */
26466   var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
26467       FUNC_ERROR_TEXT = 'Expected a function';
26468
26469   /** Used to stand-in for `undefined` hash values. */
26470   var HASH_UNDEFINED = '__lodash_hash_undefined__';
26471
26472   /** Used as the maximum memoize cache size. */
26473   var MAX_MEMOIZE_SIZE = 500;
26474
26475   /** Used as the internal argument placeholder. */
26476   var PLACEHOLDER = '__lodash_placeholder__';
26477
26478   /** Used to compose bitmasks for cloning. */
26479   var CLONE_DEEP_FLAG = 1,
26480       CLONE_FLAT_FLAG = 2,
26481       CLONE_SYMBOLS_FLAG = 4;
26482
26483   /** Used to compose bitmasks for value comparisons. */
26484   var COMPARE_PARTIAL_FLAG = 1,
26485       COMPARE_UNORDERED_FLAG = 2;
26486
26487   /** Used to compose bitmasks for function metadata. */
26488   var WRAP_BIND_FLAG = 1,
26489       WRAP_BIND_KEY_FLAG = 2,
26490       WRAP_CURRY_BOUND_FLAG = 4,
26491       WRAP_CURRY_FLAG = 8,
26492       WRAP_CURRY_RIGHT_FLAG = 16,
26493       WRAP_PARTIAL_FLAG = 32,
26494       WRAP_PARTIAL_RIGHT_FLAG = 64,
26495       WRAP_ARY_FLAG = 128,
26496       WRAP_REARG_FLAG = 256,
26497       WRAP_FLIP_FLAG = 512;
26498
26499   /** Used as default options for `_.truncate`. */
26500   var DEFAULT_TRUNC_LENGTH = 30,
26501       DEFAULT_TRUNC_OMISSION = '...';
26502
26503   /** Used to detect hot functions by number of calls within a span of milliseconds. */
26504   var HOT_COUNT = 800,
26505       HOT_SPAN = 16;
26506
26507   /** Used to indicate the type of lazy iteratees. */
26508   var LAZY_FILTER_FLAG = 1,
26509       LAZY_MAP_FLAG = 2,
26510       LAZY_WHILE_FLAG = 3;
26511
26512   /** Used as references for various `Number` constants. */
26513   var INFINITY = 1 / 0,
26514       MAX_SAFE_INTEGER = 9007199254740991,
26515       MAX_INTEGER = 1.7976931348623157e+308,
26516       NAN = 0 / 0;
26517
26518   /** Used as references for the maximum length and index of an array. */
26519   var MAX_ARRAY_LENGTH = 4294967295,
26520       MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
26521       HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
26522
26523   /** Used to associate wrap methods with their bit flags. */
26524   var wrapFlags = [
26525     ['ary', WRAP_ARY_FLAG],
26526     ['bind', WRAP_BIND_FLAG],
26527     ['bindKey', WRAP_BIND_KEY_FLAG],
26528     ['curry', WRAP_CURRY_FLAG],
26529     ['curryRight', WRAP_CURRY_RIGHT_FLAG],
26530     ['flip', WRAP_FLIP_FLAG],
26531     ['partial', WRAP_PARTIAL_FLAG],
26532     ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
26533     ['rearg', WRAP_REARG_FLAG]
26534   ];
26535
26536   /** `Object#toString` result references. */
26537   var argsTag = '[object Arguments]',
26538       arrayTag = '[object Array]',
26539       asyncTag = '[object AsyncFunction]',
26540       boolTag = '[object Boolean]',
26541       dateTag = '[object Date]',
26542       domExcTag = '[object DOMException]',
26543       errorTag = '[object Error]',
26544       funcTag = '[object Function]',
26545       genTag = '[object GeneratorFunction]',
26546       mapTag = '[object Map]',
26547       numberTag = '[object Number]',
26548       nullTag = '[object Null]',
26549       objectTag = '[object Object]',
26550       promiseTag = '[object Promise]',
26551       proxyTag = '[object Proxy]',
26552       regexpTag = '[object RegExp]',
26553       setTag = '[object Set]',
26554       stringTag = '[object String]',
26555       symbolTag = '[object Symbol]',
26556       undefinedTag = '[object Undefined]',
26557       weakMapTag = '[object WeakMap]',
26558       weakSetTag = '[object WeakSet]';
26559
26560   var arrayBufferTag = '[object ArrayBuffer]',
26561       dataViewTag = '[object DataView]',
26562       float32Tag = '[object Float32Array]',
26563       float64Tag = '[object Float64Array]',
26564       int8Tag = '[object Int8Array]',
26565       int16Tag = '[object Int16Array]',
26566       int32Tag = '[object Int32Array]',
26567       uint8Tag = '[object Uint8Array]',
26568       uint8ClampedTag = '[object Uint8ClampedArray]',
26569       uint16Tag = '[object Uint16Array]',
26570       uint32Tag = '[object Uint32Array]';
26571
26572   /** Used to match empty string literals in compiled template source. */
26573   var reEmptyStringLeading = /\b__p \+= '';/g,
26574       reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
26575       reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
26576
26577   /** Used to match HTML entities and HTML characters. */
26578   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
26579       reUnescapedHtml = /[&<>"']/g,
26580       reHasEscapedHtml = RegExp(reEscapedHtml.source),
26581       reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
26582
26583   /** Used to match template delimiters. */
26584   var reEscape = /<%-([\s\S]+?)%>/g,
26585       reEvaluate = /<%([\s\S]+?)%>/g,
26586       reInterpolate = /<%=([\s\S]+?)%>/g;
26587
26588   /** Used to match property names within property paths. */
26589   var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
26590       reIsPlainProp = /^\w*$/,
26591       rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
26592
26593   /**
26594    * Used to match `RegExp`
26595    * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
26596    */
26597   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
26598       reHasRegExpChar = RegExp(reRegExpChar.source);
26599
26600   /** Used to match leading and trailing whitespace. */
26601   var reTrim = /^\s+|\s+$/g,
26602       reTrimStart = /^\s+/,
26603       reTrimEnd = /\s+$/;
26604
26605   /** Used to match wrap detail comments. */
26606   var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
26607       reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
26608       reSplitDetails = /,? & /;
26609
26610   /** Used to match words composed of alphanumeric characters. */
26611   var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
26612
26613   /** Used to match backslashes in property paths. */
26614   var reEscapeChar = /\\(\\)?/g;
26615
26616   /**
26617    * Used to match
26618    * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
26619    */
26620   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
26621
26622   /** Used to match `RegExp` flags from their coerced string values. */
26623   var reFlags = /\w*$/;
26624
26625   /** Used to detect bad signed hexadecimal string values. */
26626   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
26627
26628   /** Used to detect binary string values. */
26629   var reIsBinary = /^0b[01]+$/i;
26630
26631   /** Used to detect host constructors (Safari). */
26632   var reIsHostCtor = /^\[object .+?Constructor\]$/;
26633
26634   /** Used to detect octal string values. */
26635   var reIsOctal = /^0o[0-7]+$/i;
26636
26637   /** Used to detect unsigned integer values. */
26638   var reIsUint = /^(?:0|[1-9]\d*)$/;
26639
26640   /** Used to match Latin Unicode letters (excluding mathematical operators). */
26641   var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
26642
26643   /** Used to ensure capturing order of template delimiters. */
26644   var reNoMatch = /($^)/;
26645
26646   /** Used to match unescaped characters in compiled string literals. */
26647   var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
26648
26649   /** Used to compose unicode character classes. */
26650   var rsAstralRange = '\\ud800-\\udfff',
26651       rsComboMarksRange = '\\u0300-\\u036f',
26652       reComboHalfMarksRange = '\\ufe20-\\ufe2f',
26653       rsComboSymbolsRange = '\\u20d0-\\u20ff',
26654       rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
26655       rsDingbatRange = '\\u2700-\\u27bf',
26656       rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
26657       rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
26658       rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
26659       rsPunctuationRange = '\\u2000-\\u206f',
26660       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',
26661       rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
26662       rsVarRange = '\\ufe0e\\ufe0f',
26663       rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
26664
26665   /** Used to compose unicode capture groups. */
26666   var rsApos = "['\u2019]",
26667       rsAstral = '[' + rsAstralRange + ']',
26668       rsBreak = '[' + rsBreakRange + ']',
26669       rsCombo = '[' + rsComboRange + ']',
26670       rsDigits = '\\d+',
26671       rsDingbat = '[' + rsDingbatRange + ']',
26672       rsLower = '[' + rsLowerRange + ']',
26673       rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
26674       rsFitz = '\\ud83c[\\udffb-\\udfff]',
26675       rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
26676       rsNonAstral = '[^' + rsAstralRange + ']',
26677       rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
26678       rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
26679       rsUpper = '[' + rsUpperRange + ']',
26680       rsZWJ = '\\u200d';
26681
26682   /** Used to compose unicode regexes. */
26683   var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
26684       rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
26685       rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
26686       rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
26687       reOptMod = rsModifier + '?',
26688       rsOptVar = '[' + rsVarRange + ']?',
26689       rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
26690       rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
26691       rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
26692       rsSeq = rsOptVar + reOptMod + rsOptJoin,
26693       rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
26694       rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
26695
26696   /** Used to match apostrophes. */
26697   var reApos = RegExp(rsApos, 'g');
26698
26699   /**
26700    * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
26701    * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
26702    */
26703   var reComboMark = RegExp(rsCombo, 'g');
26704
26705   /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
26706   var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
26707
26708   /** Used to match complex or compound words. */
26709   var reUnicodeWord = RegExp([
26710     rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
26711     rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
26712     rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
26713     rsUpper + '+' + rsOptContrUpper,
26714     rsOrdUpper,
26715     rsOrdLower,
26716     rsDigits,
26717     rsEmoji
26718   ].join('|'), 'g');
26719
26720   /** 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/). */
26721   var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange  + rsComboRange + rsVarRange + ']');
26722
26723   /** Used to detect strings that need a more robust regexp to match words. */
26724   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 ]/;
26725
26726   /** Used to assign default `context` object properties. */
26727   var contextProps = [
26728     'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
26729     'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
26730     'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
26731     'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
26732     '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
26733   ];
26734
26735   /** Used to make template sourceURLs easier to identify. */
26736   var templateCounter = -1;
26737
26738   /** Used to identify `toStringTag` values of typed arrays. */
26739   var typedArrayTags = {};
26740   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
26741   typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
26742   typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
26743   typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
26744   typedArrayTags[uint32Tag] = true;
26745   typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
26746   typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
26747   typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
26748   typedArrayTags[errorTag] = typedArrayTags[funcTag] =
26749   typedArrayTags[mapTag] = typedArrayTags[numberTag] =
26750   typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
26751   typedArrayTags[setTag] = typedArrayTags[stringTag] =
26752   typedArrayTags[weakMapTag] = false;
26753
26754   /** Used to identify `toStringTag` values supported by `_.clone`. */
26755   var cloneableTags = {};
26756   cloneableTags[argsTag] = cloneableTags[arrayTag] =
26757   cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
26758   cloneableTags[boolTag] = cloneableTags[dateTag] =
26759   cloneableTags[float32Tag] = cloneableTags[float64Tag] =
26760   cloneableTags[int8Tag] = cloneableTags[int16Tag] =
26761   cloneableTags[int32Tag] = cloneableTags[mapTag] =
26762   cloneableTags[numberTag] = cloneableTags[objectTag] =
26763   cloneableTags[regexpTag] = cloneableTags[setTag] =
26764   cloneableTags[stringTag] = cloneableTags[symbolTag] =
26765   cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
26766   cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
26767   cloneableTags[errorTag] = cloneableTags[funcTag] =
26768   cloneableTags[weakMapTag] = false;
26769
26770   /** Used to map Latin Unicode letters to basic Latin letters. */
26771   var deburredLetters = {
26772     // Latin-1 Supplement block.
26773     '\xc0': 'A',  '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
26774     '\xe0': 'a',  '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
26775     '\xc7': 'C',  '\xe7': 'c',
26776     '\xd0': 'D',  '\xf0': 'd',
26777     '\xc8': 'E',  '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
26778     '\xe8': 'e',  '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
26779     '\xcc': 'I',  '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
26780     '\xec': 'i',  '\xed': 'i', '\xee': 'i', '\xef': 'i',
26781     '\xd1': 'N',  '\xf1': 'n',
26782     '\xd2': 'O',  '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
26783     '\xf2': 'o',  '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
26784     '\xd9': 'U',  '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
26785     '\xf9': 'u',  '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
26786     '\xdd': 'Y',  '\xfd': 'y', '\xff': 'y',
26787     '\xc6': 'Ae', '\xe6': 'ae',
26788     '\xde': 'Th', '\xfe': 'th',
26789     '\xdf': 'ss',
26790     // Latin Extended-A block.
26791     '\u0100': 'A',  '\u0102': 'A', '\u0104': 'A',
26792     '\u0101': 'a',  '\u0103': 'a', '\u0105': 'a',
26793     '\u0106': 'C',  '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
26794     '\u0107': 'c',  '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
26795     '\u010e': 'D',  '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
26796     '\u0112': 'E',  '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
26797     '\u0113': 'e',  '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
26798     '\u011c': 'G',  '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
26799     '\u011d': 'g',  '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
26800     '\u0124': 'H',  '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
26801     '\u0128': 'I',  '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
26802     '\u0129': 'i',  '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
26803     '\u0134': 'J',  '\u0135': 'j',
26804     '\u0136': 'K',  '\u0137': 'k', '\u0138': 'k',
26805     '\u0139': 'L',  '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
26806     '\u013a': 'l',  '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
26807     '\u0143': 'N',  '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
26808     '\u0144': 'n',  '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
26809     '\u014c': 'O',  '\u014e': 'O', '\u0150': 'O',
26810     '\u014d': 'o',  '\u014f': 'o', '\u0151': 'o',
26811     '\u0154': 'R',  '\u0156': 'R', '\u0158': 'R',
26812     '\u0155': 'r',  '\u0157': 'r', '\u0159': 'r',
26813     '\u015a': 'S',  '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
26814     '\u015b': 's',  '\u015d': 's', '\u015f': 's', '\u0161': 's',
26815     '\u0162': 'T',  '\u0164': 'T', '\u0166': 'T',
26816     '\u0163': 't',  '\u0165': 't', '\u0167': 't',
26817     '\u0168': 'U',  '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
26818     '\u0169': 'u',  '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
26819     '\u0174': 'W',  '\u0175': 'w',
26820     '\u0176': 'Y',  '\u0177': 'y', '\u0178': 'Y',
26821     '\u0179': 'Z',  '\u017b': 'Z', '\u017d': 'Z',
26822     '\u017a': 'z',  '\u017c': 'z', '\u017e': 'z',
26823     '\u0132': 'IJ', '\u0133': 'ij',
26824     '\u0152': 'Oe', '\u0153': 'oe',
26825     '\u0149': "'n", '\u017f': 's'
26826   };
26827
26828   /** Used to map characters to HTML entities. */
26829   var htmlEscapes = {
26830     '&': '&amp;',
26831     '<': '&lt;',
26832     '>': '&gt;',
26833     '"': '&quot;',
26834     "'": '&#39;'
26835   };
26836
26837   /** Used to map HTML entities to characters. */
26838   var htmlUnescapes = {
26839     '&amp;': '&',
26840     '&lt;': '<',
26841     '&gt;': '>',
26842     '&quot;': '"',
26843     '&#39;': "'"
26844   };
26845
26846   /** Used to escape characters for inclusion in compiled string literals. */
26847   var stringEscapes = {
26848     '\\': '\\',
26849     "'": "'",
26850     '\n': 'n',
26851     '\r': 'r',
26852     '\u2028': 'u2028',
26853     '\u2029': 'u2029'
26854   };
26855
26856   /** Built-in method references without a dependency on `root`. */
26857   var freeParseFloat = parseFloat,
26858       freeParseInt = parseInt;
26859
26860   /** Detect free variable `global` from Node.js. */
26861   var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
26862
26863   /** Detect free variable `self`. */
26864   var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
26865
26866   /** Used as a reference to the global object. */
26867   var root = freeGlobal || freeSelf || Function('return this')();
26868
26869   /** Detect free variable `exports`. */
26870   var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
26871
26872   /** Detect free variable `module`. */
26873   var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
26874
26875   /** Detect the popular CommonJS extension `module.exports`. */
26876   var moduleExports = freeModule && freeModule.exports === freeExports;
26877
26878   /** Detect free variable `process` from Node.js. */
26879   var freeProcess = moduleExports && freeGlobal.process;
26880
26881   /** Used to access faster Node.js helpers. */
26882   var nodeUtil = (function() {
26883     try {
26884       // Use `util.types` for Node.js 10+.
26885       var types = freeModule && freeModule.require && freeModule.require('util').types;
26886
26887       if (types) {
26888         return types;
26889       }
26890
26891       // Legacy `process.binding('util')` for Node.js < 10.
26892       return freeProcess && freeProcess.binding && freeProcess.binding('util');
26893     } catch (e) {}
26894   }());
26895
26896   /* Node.js helper references. */
26897   var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
26898       nodeIsDate = nodeUtil && nodeUtil.isDate,
26899       nodeIsMap = nodeUtil && nodeUtil.isMap,
26900       nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
26901       nodeIsSet = nodeUtil && nodeUtil.isSet,
26902       nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
26903
26904   /*--------------------------------------------------------------------------*/
26905
26906   /**
26907    * A faster alternative to `Function#apply`, this function invokes `func`
26908    * with the `this` binding of `thisArg` and the arguments of `args`.
26909    *
26910    * @private
26911    * @param {Function} func The function to invoke.
26912    * @param {*} thisArg The `this` binding of `func`.
26913    * @param {Array} args The arguments to invoke `func` with.
26914    * @returns {*} Returns the result of `func`.
26915    */
26916   function apply(func, thisArg, args) {
26917     switch (args.length) {
26918       case 0: return func.call(thisArg);
26919       case 1: return func.call(thisArg, args[0]);
26920       case 2: return func.call(thisArg, args[0], args[1]);
26921       case 3: return func.call(thisArg, args[0], args[1], args[2]);
26922     }
26923     return func.apply(thisArg, args);
26924   }
26925
26926   /**
26927    * A specialized version of `baseAggregator` for arrays.
26928    *
26929    * @private
26930    * @param {Array} [array] The array to iterate over.
26931    * @param {Function} setter The function to set `accumulator` values.
26932    * @param {Function} iteratee The iteratee to transform keys.
26933    * @param {Object} accumulator The initial aggregated object.
26934    * @returns {Function} Returns `accumulator`.
26935    */
26936   function arrayAggregator(array, setter, iteratee, accumulator) {
26937     var index = -1,
26938         length = array == null ? 0 : array.length;
26939
26940     while (++index < length) {
26941       var value = array[index];
26942       setter(accumulator, value, iteratee(value), array);
26943     }
26944     return accumulator;
26945   }
26946
26947   /**
26948    * A specialized version of `_.forEach` for arrays without support for
26949    * iteratee shorthands.
26950    *
26951    * @private
26952    * @param {Array} [array] The array to iterate over.
26953    * @param {Function} iteratee The function invoked per iteration.
26954    * @returns {Array} Returns `array`.
26955    */
26956   function arrayEach(array, iteratee) {
26957     var index = -1,
26958         length = array == null ? 0 : array.length;
26959
26960     while (++index < length) {
26961       if (iteratee(array[index], index, array) === false) {
26962         break;
26963       }
26964     }
26965     return array;
26966   }
26967
26968   /**
26969    * A specialized version of `_.forEachRight` for arrays without support for
26970    * iteratee shorthands.
26971    *
26972    * @private
26973    * @param {Array} [array] The array to iterate over.
26974    * @param {Function} iteratee The function invoked per iteration.
26975    * @returns {Array} Returns `array`.
26976    */
26977   function arrayEachRight(array, iteratee) {
26978     var length = array == null ? 0 : array.length;
26979
26980     while (length--) {
26981       if (iteratee(array[length], length, array) === false) {
26982         break;
26983       }
26984     }
26985     return array;
26986   }
26987
26988   /**
26989    * A specialized version of `_.every` for arrays without support for
26990    * iteratee shorthands.
26991    *
26992    * @private
26993    * @param {Array} [array] The array to iterate over.
26994    * @param {Function} predicate The function invoked per iteration.
26995    * @returns {boolean} Returns `true` if all elements pass the predicate check,
26996    *  else `false`.
26997    */
26998   function arrayEvery(array, predicate) {
26999     var index = -1,
27000         length = array == null ? 0 : array.length;
27001
27002     while (++index < length) {
27003       if (!predicate(array[index], index, array)) {
27004         return false;
27005       }
27006     }
27007     return true;
27008   }
27009
27010   /**
27011    * A specialized version of `_.filter` for arrays without support for
27012    * iteratee shorthands.
27013    *
27014    * @private
27015    * @param {Array} [array] The array to iterate over.
27016    * @param {Function} predicate The function invoked per iteration.
27017    * @returns {Array} Returns the new filtered array.
27018    */
27019   function arrayFilter(array, predicate) {
27020     var index = -1,
27021         length = array == null ? 0 : array.length,
27022         resIndex = 0,
27023         result = [];
27024
27025     while (++index < length) {
27026       var value = array[index];
27027       if (predicate(value, index, array)) {
27028         result[resIndex++] = value;
27029       }
27030     }
27031     return result;
27032   }
27033
27034   /**
27035    * A specialized version of `_.includes` for arrays without support for
27036    * specifying an index to search from.
27037    *
27038    * @private
27039    * @param {Array} [array] The array to inspect.
27040    * @param {*} target The value to search for.
27041    * @returns {boolean} Returns `true` if `target` is found, else `false`.
27042    */
27043   function arrayIncludes(array, value) {
27044     var length = array == null ? 0 : array.length;
27045     return !!length && baseIndexOf(array, value, 0) > -1;
27046   }
27047
27048   /**
27049    * This function is like `arrayIncludes` except that it accepts a comparator.
27050    *
27051    * @private
27052    * @param {Array} [array] The array to inspect.
27053    * @param {*} target The value to search for.
27054    * @param {Function} comparator The comparator invoked per element.
27055    * @returns {boolean} Returns `true` if `target` is found, else `false`.
27056    */
27057   function arrayIncludesWith(array, value, comparator) {
27058     var index = -1,
27059         length = array == null ? 0 : array.length;
27060
27061     while (++index < length) {
27062       if (comparator(value, array[index])) {
27063         return true;
27064       }
27065     }
27066     return false;
27067   }
27068
27069   /**
27070    * A specialized version of `_.map` for arrays without support for iteratee
27071    * shorthands.
27072    *
27073    * @private
27074    * @param {Array} [array] The array to iterate over.
27075    * @param {Function} iteratee The function invoked per iteration.
27076    * @returns {Array} Returns the new mapped array.
27077    */
27078   function arrayMap(array, iteratee) {
27079     var index = -1,
27080         length = array == null ? 0 : array.length,
27081         result = Array(length);
27082
27083     while (++index < length) {
27084       result[index] = iteratee(array[index], index, array);
27085     }
27086     return result;
27087   }
27088
27089   /**
27090    * Appends the elements of `values` to `array`.
27091    *
27092    * @private
27093    * @param {Array} array The array to modify.
27094    * @param {Array} values The values to append.
27095    * @returns {Array} Returns `array`.
27096    */
27097   function arrayPush(array, values) {
27098     var index = -1,
27099         length = values.length,
27100         offset = array.length;
27101
27102     while (++index < length) {
27103       array[offset + index] = values[index];
27104     }
27105     return array;
27106   }
27107
27108   /**
27109    * A specialized version of `_.reduce` for arrays without support for
27110    * iteratee shorthands.
27111    *
27112    * @private
27113    * @param {Array} [array] The array to iterate over.
27114    * @param {Function} iteratee The function invoked per iteration.
27115    * @param {*} [accumulator] The initial value.
27116    * @param {boolean} [initAccum] Specify using the first element of `array` as
27117    *  the initial value.
27118    * @returns {*} Returns the accumulated value.
27119    */
27120   function arrayReduce(array, iteratee, accumulator, initAccum) {
27121     var index = -1,
27122         length = array == null ? 0 : array.length;
27123
27124     if (initAccum && length) {
27125       accumulator = array[++index];
27126     }
27127     while (++index < length) {
27128       accumulator = iteratee(accumulator, array[index], index, array);
27129     }
27130     return accumulator;
27131   }
27132
27133   /**
27134    * A specialized version of `_.reduceRight` for arrays without support for
27135    * iteratee shorthands.
27136    *
27137    * @private
27138    * @param {Array} [array] The array to iterate over.
27139    * @param {Function} iteratee The function invoked per iteration.
27140    * @param {*} [accumulator] The initial value.
27141    * @param {boolean} [initAccum] Specify using the last element of `array` as
27142    *  the initial value.
27143    * @returns {*} Returns the accumulated value.
27144    */
27145   function arrayReduceRight(array, iteratee, accumulator, initAccum) {
27146     var length = array == null ? 0 : array.length;
27147     if (initAccum && length) {
27148       accumulator = array[--length];
27149     }
27150     while (length--) {
27151       accumulator = iteratee(accumulator, array[length], length, array);
27152     }
27153     return accumulator;
27154   }
27155
27156   /**
27157    * A specialized version of `_.some` for arrays without support for iteratee
27158    * shorthands.
27159    *
27160    * @private
27161    * @param {Array} [array] The array to iterate over.
27162    * @param {Function} predicate The function invoked per iteration.
27163    * @returns {boolean} Returns `true` if any element passes the predicate check,
27164    *  else `false`.
27165    */
27166   function arraySome(array, predicate) {
27167     var index = -1,
27168         length = array == null ? 0 : array.length;
27169
27170     while (++index < length) {
27171       if (predicate(array[index], index, array)) {
27172         return true;
27173       }
27174     }
27175     return false;
27176   }
27177
27178   /**
27179    * Gets the size of an ASCII `string`.
27180    *
27181    * @private
27182    * @param {string} string The string inspect.
27183    * @returns {number} Returns the string size.
27184    */
27185   var asciiSize = baseProperty('length');
27186
27187   /**
27188    * Converts an ASCII `string` to an array.
27189    *
27190    * @private
27191    * @param {string} string The string to convert.
27192    * @returns {Array} Returns the converted array.
27193    */
27194   function asciiToArray(string) {
27195     return string.split('');
27196   }
27197
27198   /**
27199    * Splits an ASCII `string` into an array of its words.
27200    *
27201    * @private
27202    * @param {string} The string to inspect.
27203    * @returns {Array} Returns the words of `string`.
27204    */
27205   function asciiWords(string) {
27206     return string.match(reAsciiWord) || [];
27207   }
27208
27209   /**
27210    * The base implementation of methods like `_.findKey` and `_.findLastKey`,
27211    * without support for iteratee shorthands, which iterates over `collection`
27212    * using `eachFunc`.
27213    *
27214    * @private
27215    * @param {Array|Object} collection The collection to inspect.
27216    * @param {Function} predicate The function invoked per iteration.
27217    * @param {Function} eachFunc The function to iterate over `collection`.
27218    * @returns {*} Returns the found element or its key, else `undefined`.
27219    */
27220   function baseFindKey(collection, predicate, eachFunc) {
27221     var result;
27222     eachFunc(collection, function(value, key, collection) {
27223       if (predicate(value, key, collection)) {
27224         result = key;
27225         return false;
27226       }
27227     });
27228     return result;
27229   }
27230
27231   /**
27232    * The base implementation of `_.findIndex` and `_.findLastIndex` without
27233    * support for iteratee shorthands.
27234    *
27235    * @private
27236    * @param {Array} array The array to inspect.
27237    * @param {Function} predicate The function invoked per iteration.
27238    * @param {number} fromIndex The index to search from.
27239    * @param {boolean} [fromRight] Specify iterating from right to left.
27240    * @returns {number} Returns the index of the matched value, else `-1`.
27241    */
27242   function baseFindIndex(array, predicate, fromIndex, fromRight) {
27243     var length = array.length,
27244         index = fromIndex + (fromRight ? 1 : -1);
27245
27246     while ((fromRight ? index-- : ++index < length)) {
27247       if (predicate(array[index], index, array)) {
27248         return index;
27249       }
27250     }
27251     return -1;
27252   }
27253
27254   /**
27255    * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
27256    *
27257    * @private
27258    * @param {Array} array The array to inspect.
27259    * @param {*} value The value to search for.
27260    * @param {number} fromIndex The index to search from.
27261    * @returns {number} Returns the index of the matched value, else `-1`.
27262    */
27263   function baseIndexOf(array, value, fromIndex) {
27264     return value === value
27265       ? strictIndexOf(array, value, fromIndex)
27266       : baseFindIndex(array, baseIsNaN, fromIndex);
27267   }
27268
27269   /**
27270    * This function is like `baseIndexOf` except that it accepts a comparator.
27271    *
27272    * @private
27273    * @param {Array} array The array to inspect.
27274    * @param {*} value The value to search for.
27275    * @param {number} fromIndex The index to search from.
27276    * @param {Function} comparator The comparator invoked per element.
27277    * @returns {number} Returns the index of the matched value, else `-1`.
27278    */
27279   function baseIndexOfWith(array, value, fromIndex, comparator) {
27280     var index = fromIndex - 1,
27281         length = array.length;
27282
27283     while (++index < length) {
27284       if (comparator(array[index], value)) {
27285         return index;
27286       }
27287     }
27288     return -1;
27289   }
27290
27291   /**
27292    * The base implementation of `_.isNaN` without support for number objects.
27293    *
27294    * @private
27295    * @param {*} value The value to check.
27296    * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
27297    */
27298   function baseIsNaN(value) {
27299     return value !== value;
27300   }
27301
27302   /**
27303    * The base implementation of `_.mean` and `_.meanBy` without support for
27304    * iteratee shorthands.
27305    *
27306    * @private
27307    * @param {Array} array The array to iterate over.
27308    * @param {Function} iteratee The function invoked per iteration.
27309    * @returns {number} Returns the mean.
27310    */
27311   function baseMean(array, iteratee) {
27312     var length = array == null ? 0 : array.length;
27313     return length ? (baseSum(array, iteratee) / length) : NAN;
27314   }
27315
27316   /**
27317    * The base implementation of `_.property` without support for deep paths.
27318    *
27319    * @private
27320    * @param {string} key The key of the property to get.
27321    * @returns {Function} Returns the new accessor function.
27322    */
27323   function baseProperty(key) {
27324     return function(object) {
27325       return object == null ? undefined : object[key];
27326     };
27327   }
27328
27329   /**
27330    * The base implementation of `_.propertyOf` without support for deep paths.
27331    *
27332    * @private
27333    * @param {Object} object The object to query.
27334    * @returns {Function} Returns the new accessor function.
27335    */
27336   function basePropertyOf(object) {
27337     return function(key) {
27338       return object == null ? undefined : object[key];
27339     };
27340   }
27341
27342   /**
27343    * The base implementation of `_.reduce` and `_.reduceRight`, without support
27344    * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
27345    *
27346    * @private
27347    * @param {Array|Object} collection The collection to iterate over.
27348    * @param {Function} iteratee The function invoked per iteration.
27349    * @param {*} accumulator The initial value.
27350    * @param {boolean} initAccum Specify using the first or last element of
27351    *  `collection` as the initial value.
27352    * @param {Function} eachFunc The function to iterate over `collection`.
27353    * @returns {*} Returns the accumulated value.
27354    */
27355   function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
27356     eachFunc(collection, function(value, index, collection) {
27357       accumulator = initAccum
27358         ? (initAccum = false, value)
27359         : iteratee(accumulator, value, index, collection);
27360     });
27361     return accumulator;
27362   }
27363
27364   /**
27365    * The base implementation of `_.sortBy` which uses `comparer` to define the
27366    * sort order of `array` and replaces criteria objects with their corresponding
27367    * values.
27368    *
27369    * @private
27370    * @param {Array} array The array to sort.
27371    * @param {Function} comparer The function to define sort order.
27372    * @returns {Array} Returns `array`.
27373    */
27374   function baseSortBy(array, comparer) {
27375     var length = array.length;
27376
27377     array.sort(comparer);
27378     while (length--) {
27379       array[length] = array[length].value;
27380     }
27381     return array;
27382   }
27383
27384   /**
27385    * The base implementation of `_.sum` and `_.sumBy` without support for
27386    * iteratee shorthands.
27387    *
27388    * @private
27389    * @param {Array} array The array to iterate over.
27390    * @param {Function} iteratee The function invoked per iteration.
27391    * @returns {number} Returns the sum.
27392    */
27393   function baseSum(array, iteratee) {
27394     var result,
27395         index = -1,
27396         length = array.length;
27397
27398     while (++index < length) {
27399       var current = iteratee(array[index]);
27400       if (current !== undefined) {
27401         result = result === undefined ? current : (result + current);
27402       }
27403     }
27404     return result;
27405   }
27406
27407   /**
27408    * The base implementation of `_.times` without support for iteratee shorthands
27409    * or max array length checks.
27410    *
27411    * @private
27412    * @param {number} n The number of times to invoke `iteratee`.
27413    * @param {Function} iteratee The function invoked per iteration.
27414    * @returns {Array} Returns the array of results.
27415    */
27416   function baseTimes(n, iteratee) {
27417     var index = -1,
27418         result = Array(n);
27419
27420     while (++index < n) {
27421       result[index] = iteratee(index);
27422     }
27423     return result;
27424   }
27425
27426   /**
27427    * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
27428    * of key-value pairs for `object` corresponding to the property names of `props`.
27429    *
27430    * @private
27431    * @param {Object} object The object to query.
27432    * @param {Array} props The property names to get values for.
27433    * @returns {Object} Returns the key-value pairs.
27434    */
27435   function baseToPairs(object, props) {
27436     return arrayMap(props, function(key) {
27437       return [key, object[key]];
27438     });
27439   }
27440
27441   /**
27442    * The base implementation of `_.unary` without support for storing metadata.
27443    *
27444    * @private
27445    * @param {Function} func The function to cap arguments for.
27446    * @returns {Function} Returns the new capped function.
27447    */
27448   function baseUnary(func) {
27449     return function(value) {
27450       return func(value);
27451     };
27452   }
27453
27454   /**
27455    * The base implementation of `_.values` and `_.valuesIn` which creates an
27456    * array of `object` property values corresponding to the property names
27457    * of `props`.
27458    *
27459    * @private
27460    * @param {Object} object The object to query.
27461    * @param {Array} props The property names to get values for.
27462    * @returns {Object} Returns the array of property values.
27463    */
27464   function baseValues(object, props) {
27465     return arrayMap(props, function(key) {
27466       return object[key];
27467     });
27468   }
27469
27470   /**
27471    * Checks if a `cache` value for `key` exists.
27472    *
27473    * @private
27474    * @param {Object} cache The cache to query.
27475    * @param {string} key The key of the entry to check.
27476    * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
27477    */
27478   function cacheHas(cache, key) {
27479     return cache.has(key);
27480   }
27481
27482   /**
27483    * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
27484    * that is not found in the character symbols.
27485    *
27486    * @private
27487    * @param {Array} strSymbols The string symbols to inspect.
27488    * @param {Array} chrSymbols The character symbols to find.
27489    * @returns {number} Returns the index of the first unmatched string symbol.
27490    */
27491   function charsStartIndex(strSymbols, chrSymbols) {
27492     var index = -1,
27493         length = strSymbols.length;
27494
27495     while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
27496     return index;
27497   }
27498
27499   /**
27500    * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
27501    * that is not found in the character symbols.
27502    *
27503    * @private
27504    * @param {Array} strSymbols The string symbols to inspect.
27505    * @param {Array} chrSymbols The character symbols to find.
27506    * @returns {number} Returns the index of the last unmatched string symbol.
27507    */
27508   function charsEndIndex(strSymbols, chrSymbols) {
27509     var index = strSymbols.length;
27510
27511     while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
27512     return index;
27513   }
27514
27515   /**
27516    * Gets the number of `placeholder` occurrences in `array`.
27517    *
27518    * @private
27519    * @param {Array} array The array to inspect.
27520    * @param {*} placeholder The placeholder to search for.
27521    * @returns {number} Returns the placeholder count.
27522    */
27523   function countHolders(array, placeholder) {
27524     var length = array.length,
27525         result = 0;
27526
27527     while (length--) {
27528       if (array[length] === placeholder) {
27529         ++result;
27530       }
27531     }
27532     return result;
27533   }
27534
27535   /**
27536    * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
27537    * letters to basic Latin letters.
27538    *
27539    * @private
27540    * @param {string} letter The matched letter to deburr.
27541    * @returns {string} Returns the deburred letter.
27542    */
27543   var deburrLetter = basePropertyOf(deburredLetters);
27544
27545   /**
27546    * Used by `_.escape` to convert characters to HTML entities.
27547    *
27548    * @private
27549    * @param {string} chr The matched character to escape.
27550    * @returns {string} Returns the escaped character.
27551    */
27552   var escapeHtmlChar = basePropertyOf(htmlEscapes);
27553
27554   /**
27555    * Used by `_.template` to escape characters for inclusion in compiled string literals.
27556    *
27557    * @private
27558    * @param {string} chr The matched character to escape.
27559    * @returns {string} Returns the escaped character.
27560    */
27561   function escapeStringChar(chr) {
27562     return '\\' + stringEscapes[chr];
27563   }
27564
27565   /**
27566    * Gets the value at `key` of `object`.
27567    *
27568    * @private
27569    * @param {Object} [object] The object to query.
27570    * @param {string} key The key of the property to get.
27571    * @returns {*} Returns the property value.
27572    */
27573   function getValue(object, key) {
27574     return object == null ? undefined : object[key];
27575   }
27576
27577   /**
27578    * Checks if `string` contains Unicode symbols.
27579    *
27580    * @private
27581    * @param {string} string The string to inspect.
27582    * @returns {boolean} Returns `true` if a symbol is found, else `false`.
27583    */
27584   function hasUnicode(string) {
27585     return reHasUnicode.test(string);
27586   }
27587
27588   /**
27589    * Checks if `string` contains a word composed of Unicode symbols.
27590    *
27591    * @private
27592    * @param {string} string The string to inspect.
27593    * @returns {boolean} Returns `true` if a word is found, else `false`.
27594    */
27595   function hasUnicodeWord(string) {
27596     return reHasUnicodeWord.test(string);
27597   }
27598
27599   /**
27600    * Converts `iterator` to an array.
27601    *
27602    * @private
27603    * @param {Object} iterator The iterator to convert.
27604    * @returns {Array} Returns the converted array.
27605    */
27606   function iteratorToArray(iterator) {
27607     var data,
27608         result = [];
27609
27610     while (!(data = iterator.next()).done) {
27611       result.push(data.value);
27612     }
27613     return result;
27614   }
27615
27616   /**
27617    * Converts `map` to its key-value pairs.
27618    *
27619    * @private
27620    * @param {Object} map The map to convert.
27621    * @returns {Array} Returns the key-value pairs.
27622    */
27623   function mapToArray(map) {
27624     var index = -1,
27625         result = Array(map.size);
27626
27627     map.forEach(function(value, key) {
27628       result[++index] = [key, value];
27629     });
27630     return result;
27631   }
27632
27633   /**
27634    * Creates a unary function that invokes `func` with its argument transformed.
27635    *
27636    * @private
27637    * @param {Function} func The function to wrap.
27638    * @param {Function} transform The argument transform.
27639    * @returns {Function} Returns the new function.
27640    */
27641   function overArg(func, transform) {
27642     return function(arg) {
27643       return func(transform(arg));
27644     };
27645   }
27646
27647   /**
27648    * Replaces all `placeholder` elements in `array` with an internal placeholder
27649    * and returns an array of their indexes.
27650    *
27651    * @private
27652    * @param {Array} array The array to modify.
27653    * @param {*} placeholder The placeholder to replace.
27654    * @returns {Array} Returns the new array of placeholder indexes.
27655    */
27656   function replaceHolders(array, placeholder) {
27657     var index = -1,
27658         length = array.length,
27659         resIndex = 0,
27660         result = [];
27661
27662     while (++index < length) {
27663       var value = array[index];
27664       if (value === placeholder || value === PLACEHOLDER) {
27665         array[index] = PLACEHOLDER;
27666         result[resIndex++] = index;
27667       }
27668     }
27669     return result;
27670   }
27671
27672   /**
27673    * Converts `set` to an array of its values.
27674    *
27675    * @private
27676    * @param {Object} set The set to convert.
27677    * @returns {Array} Returns the values.
27678    */
27679   function setToArray(set) {
27680     var index = -1,
27681         result = Array(set.size);
27682
27683     set.forEach(function(value) {
27684       result[++index] = value;
27685     });
27686     return result;
27687   }
27688
27689   /**
27690    * Converts `set` to its value-value pairs.
27691    *
27692    * @private
27693    * @param {Object} set The set to convert.
27694    * @returns {Array} Returns the value-value pairs.
27695    */
27696   function setToPairs(set) {
27697     var index = -1,
27698         result = Array(set.size);
27699
27700     set.forEach(function(value) {
27701       result[++index] = [value, value];
27702     });
27703     return result;
27704   }
27705
27706   /**
27707    * A specialized version of `_.indexOf` which performs strict equality
27708    * comparisons of values, i.e. `===`.
27709    *
27710    * @private
27711    * @param {Array} array The array to inspect.
27712    * @param {*} value The value to search for.
27713    * @param {number} fromIndex The index to search from.
27714    * @returns {number} Returns the index of the matched value, else `-1`.
27715    */
27716   function strictIndexOf(array, value, fromIndex) {
27717     var index = fromIndex - 1,
27718         length = array.length;
27719
27720     while (++index < length) {
27721       if (array[index] === value) {
27722         return index;
27723       }
27724     }
27725     return -1;
27726   }
27727
27728   /**
27729    * A specialized version of `_.lastIndexOf` which performs strict equality
27730    * comparisons of values, i.e. `===`.
27731    *
27732    * @private
27733    * @param {Array} array The array to inspect.
27734    * @param {*} value The value to search for.
27735    * @param {number} fromIndex The index to search from.
27736    * @returns {number} Returns the index of the matched value, else `-1`.
27737    */
27738   function strictLastIndexOf(array, value, fromIndex) {
27739     var index = fromIndex + 1;
27740     while (index--) {
27741       if (array[index] === value) {
27742         return index;
27743       }
27744     }
27745     return index;
27746   }
27747
27748   /**
27749    * Gets the number of symbols in `string`.
27750    *
27751    * @private
27752    * @param {string} string The string to inspect.
27753    * @returns {number} Returns the string size.
27754    */
27755   function stringSize(string) {
27756     return hasUnicode(string)
27757       ? unicodeSize(string)
27758       : asciiSize(string);
27759   }
27760
27761   /**
27762    * Converts `string` to an array.
27763    *
27764    * @private
27765    * @param {string} string The string to convert.
27766    * @returns {Array} Returns the converted array.
27767    */
27768   function stringToArray(string) {
27769     return hasUnicode(string)
27770       ? unicodeToArray(string)
27771       : asciiToArray(string);
27772   }
27773
27774   /**
27775    * Used by `_.unescape` to convert HTML entities to characters.
27776    *
27777    * @private
27778    * @param {string} chr The matched character to unescape.
27779    * @returns {string} Returns the unescaped character.
27780    */
27781   var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
27782
27783   /**
27784    * Gets the size of a Unicode `string`.
27785    *
27786    * @private
27787    * @param {string} string The string inspect.
27788    * @returns {number} Returns the string size.
27789    */
27790   function unicodeSize(string) {
27791     var result = reUnicode.lastIndex = 0;
27792     while (reUnicode.test(string)) {
27793       ++result;
27794     }
27795     return result;
27796   }
27797
27798   /**
27799    * Converts a Unicode `string` to an array.
27800    *
27801    * @private
27802    * @param {string} string The string to convert.
27803    * @returns {Array} Returns the converted array.
27804    */
27805   function unicodeToArray(string) {
27806     return string.match(reUnicode) || [];
27807   }
27808
27809   /**
27810    * Splits a Unicode `string` into an array of its words.
27811    *
27812    * @private
27813    * @param {string} The string to inspect.
27814    * @returns {Array} Returns the words of `string`.
27815    */
27816   function unicodeWords(string) {
27817     return string.match(reUnicodeWord) || [];
27818   }
27819
27820   /*--------------------------------------------------------------------------*/
27821
27822   /**
27823    * Create a new pristine `lodash` function using the `context` object.
27824    *
27825    * @static
27826    * @memberOf _
27827    * @since 1.1.0
27828    * @category Util
27829    * @param {Object} [context=root] The context object.
27830    * @returns {Function} Returns a new `lodash` function.
27831    * @example
27832    *
27833    * _.mixin({ 'foo': _.constant('foo') });
27834    *
27835    * var lodash = _.runInContext();
27836    * lodash.mixin({ 'bar': lodash.constant('bar') });
27837    *
27838    * _.isFunction(_.foo);
27839    * // => true
27840    * _.isFunction(_.bar);
27841    * // => false
27842    *
27843    * lodash.isFunction(lodash.foo);
27844    * // => false
27845    * lodash.isFunction(lodash.bar);
27846    * // => true
27847    *
27848    * // Create a suped-up `defer` in Node.js.
27849    * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
27850    */
27851   var runInContext = (function runInContext(context) {
27852     context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
27853
27854     /** Built-in constructor references. */
27855     var Array = context.Array,
27856         Date = context.Date,
27857         Error = context.Error,
27858         Function = context.Function,
27859         Math = context.Math,
27860         Object = context.Object,
27861         RegExp = context.RegExp,
27862         String = context.String,
27863         TypeError = context.TypeError;
27864
27865     /** Used for built-in method references. */
27866     var arrayProto = Array.prototype,
27867         funcProto = Function.prototype,
27868         objectProto = Object.prototype;
27869
27870     /** Used to detect overreaching core-js shims. */
27871     var coreJsData = context['__core-js_shared__'];
27872
27873     /** Used to resolve the decompiled source of functions. */
27874     var funcToString = funcProto.toString;
27875
27876     /** Used to check objects for own properties. */
27877     var hasOwnProperty = objectProto.hasOwnProperty;
27878
27879     /** Used to generate unique IDs. */
27880     var idCounter = 0;
27881
27882     /** Used to detect methods masquerading as native. */
27883     var maskSrcKey = (function() {
27884       var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
27885       return uid ? ('Symbol(src)_1.' + uid) : '';
27886     }());
27887
27888     /**
27889      * Used to resolve the
27890      * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
27891      * of values.
27892      */
27893     var nativeObjectToString = objectProto.toString;
27894
27895     /** Used to infer the `Object` constructor. */
27896     var objectCtorString = funcToString.call(Object);
27897
27898     /** Used to restore the original `_` reference in `_.noConflict`. */
27899     var oldDash = root._;
27900
27901     /** Used to detect if a method is native. */
27902     var reIsNative = RegExp('^' +
27903       funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
27904       .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
27905     );
27906
27907     /** Built-in value references. */
27908     var Buffer = moduleExports ? context.Buffer : undefined,
27909         Symbol = context.Symbol,
27910         Uint8Array = context.Uint8Array,
27911         allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
27912         getPrototype = overArg(Object.getPrototypeOf, Object),
27913         objectCreate = Object.create,
27914         propertyIsEnumerable = objectProto.propertyIsEnumerable,
27915         splice = arrayProto.splice,
27916         spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
27917         symIterator = Symbol ? Symbol.iterator : undefined,
27918         symToStringTag = Symbol ? Symbol.toStringTag : undefined;
27919
27920     var defineProperty = (function() {
27921       try {
27922         var func = getNative(Object, 'defineProperty');
27923         func({}, '', {});
27924         return func;
27925       } catch (e) {}
27926     }());
27927
27928     /** Mocked built-ins. */
27929     var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
27930         ctxNow = Date && Date.now !== root.Date.now && Date.now,
27931         ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
27932
27933     /* Built-in method references for those with the same name as other `lodash` methods. */
27934     var nativeCeil = Math.ceil,
27935         nativeFloor = Math.floor,
27936         nativeGetSymbols = Object.getOwnPropertySymbols,
27937         nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
27938         nativeIsFinite = context.isFinite,
27939         nativeJoin = arrayProto.join,
27940         nativeKeys = overArg(Object.keys, Object),
27941         nativeMax = Math.max,
27942         nativeMin = Math.min,
27943         nativeNow = Date.now,
27944         nativeParseInt = context.parseInt,
27945         nativeRandom = Math.random,
27946         nativeReverse = arrayProto.reverse;
27947
27948     /* Built-in method references that are verified to be native. */
27949     var DataView = getNative(context, 'DataView'),
27950         Map = getNative(context, 'Map'),
27951         Promise = getNative(context, 'Promise'),
27952         Set = getNative(context, 'Set'),
27953         WeakMap = getNative(context, 'WeakMap'),
27954         nativeCreate = getNative(Object, 'create');
27955
27956     /** Used to store function metadata. */
27957     var metaMap = WeakMap && new WeakMap;
27958
27959     /** Used to lookup unminified function names. */
27960     var realNames = {};
27961
27962     /** Used to detect maps, sets, and weakmaps. */
27963     var dataViewCtorString = toSource(DataView),
27964         mapCtorString = toSource(Map),
27965         promiseCtorString = toSource(Promise),
27966         setCtorString = toSource(Set),
27967         weakMapCtorString = toSource(WeakMap);
27968
27969     /** Used to convert symbols to primitives and strings. */
27970     var symbolProto = Symbol ? Symbol.prototype : undefined,
27971         symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
27972         symbolToString = symbolProto ? symbolProto.toString : undefined;
27973
27974     /*------------------------------------------------------------------------*/
27975
27976     /**
27977      * Creates a `lodash` object which wraps `value` to enable implicit method
27978      * chain sequences. Methods that operate on and return arrays, collections,
27979      * and functions can be chained together. Methods that retrieve a single value
27980      * or may return a primitive value will automatically end the chain sequence
27981      * and return the unwrapped value. Otherwise, the value must be unwrapped
27982      * with `_#value`.
27983      *
27984      * Explicit chain sequences, which must be unwrapped with `_#value`, may be
27985      * enabled using `_.chain`.
27986      *
27987      * The execution of chained methods is lazy, that is, it's deferred until
27988      * `_#value` is implicitly or explicitly called.
27989      *
27990      * Lazy evaluation allows several methods to support shortcut fusion.
27991      * Shortcut fusion is an optimization to merge iteratee calls; this avoids
27992      * the creation of intermediate arrays and can greatly reduce the number of
27993      * iteratee executions. Sections of a chain sequence qualify for shortcut
27994      * fusion if the section is applied to an array and iteratees accept only
27995      * one argument. The heuristic for whether a section qualifies for shortcut
27996      * fusion is subject to change.
27997      *
27998      * Chaining is supported in custom builds as long as the `_#value` method is
27999      * directly or indirectly included in the build.
28000      *
28001      * In addition to lodash methods, wrappers have `Array` and `String` methods.
28002      *
28003      * The wrapper `Array` methods are:
28004      * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
28005      *
28006      * The wrapper `String` methods are:
28007      * `replace` and `split`
28008      *
28009      * The wrapper methods that support shortcut fusion are:
28010      * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
28011      * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
28012      * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
28013      *
28014      * The chainable wrapper methods are:
28015      * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
28016      * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
28017      * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
28018      * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
28019      * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
28020      * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
28021      * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
28022      * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
28023      * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
28024      * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
28025      * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
28026      * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
28027      * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
28028      * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
28029      * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
28030      * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
28031      * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
28032      * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
28033      * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
28034      * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
28035      * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
28036      * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
28037      * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
28038      * `zipObject`, `zipObjectDeep`, and `zipWith`
28039      *
28040      * The wrapper methods that are **not** chainable by default are:
28041      * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
28042      * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
28043      * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
28044      * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
28045      * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
28046      * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
28047      * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
28048      * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
28049      * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
28050      * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
28051      * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
28052      * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
28053      * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
28054      * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
28055      * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
28056      * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
28057      * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
28058      * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
28059      * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
28060      * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
28061      * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
28062      * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
28063      * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
28064      * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
28065      * `upperFirst`, `value`, and `words`
28066      *
28067      * @name _
28068      * @constructor
28069      * @category Seq
28070      * @param {*} value The value to wrap in a `lodash` instance.
28071      * @returns {Object} Returns the new `lodash` wrapper instance.
28072      * @example
28073      *
28074      * function square(n) {
28075      *   return n * n;
28076      * }
28077      *
28078      * var wrapped = _([1, 2, 3]);
28079      *
28080      * // Returns an unwrapped value.
28081      * wrapped.reduce(_.add);
28082      * // => 6
28083      *
28084      * // Returns a wrapped value.
28085      * var squares = wrapped.map(square);
28086      *
28087      * _.isArray(squares);
28088      * // => false
28089      *
28090      * _.isArray(squares.value());
28091      * // => true
28092      */
28093     function lodash(value) {
28094       if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
28095         if (value instanceof LodashWrapper) {
28096           return value;
28097         }
28098         if (hasOwnProperty.call(value, '__wrapped__')) {
28099           return wrapperClone(value);
28100         }
28101       }
28102       return new LodashWrapper(value);
28103     }
28104
28105     /**
28106      * The base implementation of `_.create` without support for assigning
28107      * properties to the created object.
28108      *
28109      * @private
28110      * @param {Object} proto The object to inherit from.
28111      * @returns {Object} Returns the new object.
28112      */
28113     var baseCreate = (function() {
28114       function object() {}
28115       return function(proto) {
28116         if (!isObject(proto)) {
28117           return {};
28118         }
28119         if (objectCreate) {
28120           return objectCreate(proto);
28121         }
28122         object.prototype = proto;
28123         var result = new object;
28124         object.prototype = undefined;
28125         return result;
28126       };
28127     }());
28128
28129     /**
28130      * The function whose prototype chain sequence wrappers inherit from.
28131      *
28132      * @private
28133      */
28134     function baseLodash() {
28135       // No operation performed.
28136     }
28137
28138     /**
28139      * The base constructor for creating `lodash` wrapper objects.
28140      *
28141      * @private
28142      * @param {*} value The value to wrap.
28143      * @param {boolean} [chainAll] Enable explicit method chain sequences.
28144      */
28145     function LodashWrapper(value, chainAll) {
28146       this.__wrapped__ = value;
28147       this.__actions__ = [];
28148       this.__chain__ = !!chainAll;
28149       this.__index__ = 0;
28150       this.__values__ = undefined;
28151     }
28152
28153     /**
28154      * By default, the template delimiters used by lodash are like those in
28155      * embedded Ruby (ERB) as well as ES2015 template strings. Change the
28156      * following template settings to use alternative delimiters.
28157      *
28158      * @static
28159      * @memberOf _
28160      * @type {Object}
28161      */
28162     lodash.templateSettings = {
28163
28164       /**
28165        * Used to detect `data` property values to be HTML-escaped.
28166        *
28167        * @memberOf _.templateSettings
28168        * @type {RegExp}
28169        */
28170       'escape': reEscape,
28171
28172       /**
28173        * Used to detect code to be evaluated.
28174        *
28175        * @memberOf _.templateSettings
28176        * @type {RegExp}
28177        */
28178       'evaluate': reEvaluate,
28179
28180       /**
28181        * Used to detect `data` property values to inject.
28182        *
28183        * @memberOf _.templateSettings
28184        * @type {RegExp}
28185        */
28186       'interpolate': reInterpolate,
28187
28188       /**
28189        * Used to reference the data object in the template text.
28190        *
28191        * @memberOf _.templateSettings
28192        * @type {string}
28193        */
28194       'variable': '',
28195
28196       /**
28197        * Used to import variables into the compiled template.
28198        *
28199        * @memberOf _.templateSettings
28200        * @type {Object}
28201        */
28202       'imports': {
28203
28204         /**
28205          * A reference to the `lodash` function.
28206          *
28207          * @memberOf _.templateSettings.imports
28208          * @type {Function}
28209          */
28210         '_': lodash
28211       }
28212     };
28213
28214     // Ensure wrappers are instances of `baseLodash`.
28215     lodash.prototype = baseLodash.prototype;
28216     lodash.prototype.constructor = lodash;
28217
28218     LodashWrapper.prototype = baseCreate(baseLodash.prototype);
28219     LodashWrapper.prototype.constructor = LodashWrapper;
28220
28221     /*------------------------------------------------------------------------*/
28222
28223     /**
28224      * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
28225      *
28226      * @private
28227      * @constructor
28228      * @param {*} value The value to wrap.
28229      */
28230     function LazyWrapper(value) {
28231       this.__wrapped__ = value;
28232       this.__actions__ = [];
28233       this.__dir__ = 1;
28234       this.__filtered__ = false;
28235       this.__iteratees__ = [];
28236       this.__takeCount__ = MAX_ARRAY_LENGTH;
28237       this.__views__ = [];
28238     }
28239
28240     /**
28241      * Creates a clone of the lazy wrapper object.
28242      *
28243      * @private
28244      * @name clone
28245      * @memberOf LazyWrapper
28246      * @returns {Object} Returns the cloned `LazyWrapper` object.
28247      */
28248     function lazyClone() {
28249       var result = new LazyWrapper(this.__wrapped__);
28250       result.__actions__ = copyArray(this.__actions__);
28251       result.__dir__ = this.__dir__;
28252       result.__filtered__ = this.__filtered__;
28253       result.__iteratees__ = copyArray(this.__iteratees__);
28254       result.__takeCount__ = this.__takeCount__;
28255       result.__views__ = copyArray(this.__views__);
28256       return result;
28257     }
28258
28259     /**
28260      * Reverses the direction of lazy iteration.
28261      *
28262      * @private
28263      * @name reverse
28264      * @memberOf LazyWrapper
28265      * @returns {Object} Returns the new reversed `LazyWrapper` object.
28266      */
28267     function lazyReverse() {
28268       if (this.__filtered__) {
28269         var result = new LazyWrapper(this);
28270         result.__dir__ = -1;
28271         result.__filtered__ = true;
28272       } else {
28273         result = this.clone();
28274         result.__dir__ *= -1;
28275       }
28276       return result;
28277     }
28278
28279     /**
28280      * Extracts the unwrapped value from its lazy wrapper.
28281      *
28282      * @private
28283      * @name value
28284      * @memberOf LazyWrapper
28285      * @returns {*} Returns the unwrapped value.
28286      */
28287     function lazyValue() {
28288       var array = this.__wrapped__.value(),
28289           dir = this.__dir__,
28290           isArr = isArray(array),
28291           isRight = dir < 0,
28292           arrLength = isArr ? array.length : 0,
28293           view = getView(0, arrLength, this.__views__),
28294           start = view.start,
28295           end = view.end,
28296           length = end - start,
28297           index = isRight ? end : (start - 1),
28298           iteratees = this.__iteratees__,
28299           iterLength = iteratees.length,
28300           resIndex = 0,
28301           takeCount = nativeMin(length, this.__takeCount__);
28302
28303       if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
28304         return baseWrapperValue(array, this.__actions__);
28305       }
28306       var result = [];
28307
28308       outer:
28309       while (length-- && resIndex < takeCount) {
28310         index += dir;
28311
28312         var iterIndex = -1,
28313             value = array[index];
28314
28315         while (++iterIndex < iterLength) {
28316           var data = iteratees[iterIndex],
28317               iteratee = data.iteratee,
28318               type = data.type,
28319               computed = iteratee(value);
28320
28321           if (type == LAZY_MAP_FLAG) {
28322             value = computed;
28323           } else if (!computed) {
28324             if (type == LAZY_FILTER_FLAG) {
28325               continue outer;
28326             } else {
28327               break outer;
28328             }
28329           }
28330         }
28331         result[resIndex++] = value;
28332       }
28333       return result;
28334     }
28335
28336     // Ensure `LazyWrapper` is an instance of `baseLodash`.
28337     LazyWrapper.prototype = baseCreate(baseLodash.prototype);
28338     LazyWrapper.prototype.constructor = LazyWrapper;
28339
28340     /*------------------------------------------------------------------------*/
28341
28342     /**
28343      * Creates a hash object.
28344      *
28345      * @private
28346      * @constructor
28347      * @param {Array} [entries] The key-value pairs to cache.
28348      */
28349     function Hash(entries) {
28350       var index = -1,
28351           length = entries == null ? 0 : entries.length;
28352
28353       this.clear();
28354       while (++index < length) {
28355         var entry = entries[index];
28356         this.set(entry[0], entry[1]);
28357       }
28358     }
28359
28360     /**
28361      * Removes all key-value entries from the hash.
28362      *
28363      * @private
28364      * @name clear
28365      * @memberOf Hash
28366      */
28367     function hashClear() {
28368       this.__data__ = nativeCreate ? nativeCreate(null) : {};
28369       this.size = 0;
28370     }
28371
28372     /**
28373      * Removes `key` and its value from the hash.
28374      *
28375      * @private
28376      * @name delete
28377      * @memberOf Hash
28378      * @param {Object} hash The hash to modify.
28379      * @param {string} key The key of the value to remove.
28380      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
28381      */
28382     function hashDelete(key) {
28383       var result = this.has(key) && delete this.__data__[key];
28384       this.size -= result ? 1 : 0;
28385       return result;
28386     }
28387
28388     /**
28389      * Gets the hash value for `key`.
28390      *
28391      * @private
28392      * @name get
28393      * @memberOf Hash
28394      * @param {string} key The key of the value to get.
28395      * @returns {*} Returns the entry value.
28396      */
28397     function hashGet(key) {
28398       var data = this.__data__;
28399       if (nativeCreate) {
28400         var result = data[key];
28401         return result === HASH_UNDEFINED ? undefined : result;
28402       }
28403       return hasOwnProperty.call(data, key) ? data[key] : undefined;
28404     }
28405
28406     /**
28407      * Checks if a hash value for `key` exists.
28408      *
28409      * @private
28410      * @name has
28411      * @memberOf Hash
28412      * @param {string} key The key of the entry to check.
28413      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28414      */
28415     function hashHas(key) {
28416       var data = this.__data__;
28417       return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
28418     }
28419
28420     /**
28421      * Sets the hash `key` to `value`.
28422      *
28423      * @private
28424      * @name set
28425      * @memberOf Hash
28426      * @param {string} key The key of the value to set.
28427      * @param {*} value The value to set.
28428      * @returns {Object} Returns the hash instance.
28429      */
28430     function hashSet(key, value) {
28431       var data = this.__data__;
28432       this.size += this.has(key) ? 0 : 1;
28433       data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
28434       return this;
28435     }
28436
28437     // Add methods to `Hash`.
28438     Hash.prototype.clear = hashClear;
28439     Hash.prototype['delete'] = hashDelete;
28440     Hash.prototype.get = hashGet;
28441     Hash.prototype.has = hashHas;
28442     Hash.prototype.set = hashSet;
28443
28444     /*------------------------------------------------------------------------*/
28445
28446     /**
28447      * Creates an list cache object.
28448      *
28449      * @private
28450      * @constructor
28451      * @param {Array} [entries] The key-value pairs to cache.
28452      */
28453     function ListCache(entries) {
28454       var index = -1,
28455           length = entries == null ? 0 : entries.length;
28456
28457       this.clear();
28458       while (++index < length) {
28459         var entry = entries[index];
28460         this.set(entry[0], entry[1]);
28461       }
28462     }
28463
28464     /**
28465      * Removes all key-value entries from the list cache.
28466      *
28467      * @private
28468      * @name clear
28469      * @memberOf ListCache
28470      */
28471     function listCacheClear() {
28472       this.__data__ = [];
28473       this.size = 0;
28474     }
28475
28476     /**
28477      * Removes `key` and its value from the list cache.
28478      *
28479      * @private
28480      * @name delete
28481      * @memberOf ListCache
28482      * @param {string} key The key of the value to remove.
28483      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
28484      */
28485     function listCacheDelete(key) {
28486       var data = this.__data__,
28487           index = assocIndexOf(data, key);
28488
28489       if (index < 0) {
28490         return false;
28491       }
28492       var lastIndex = data.length - 1;
28493       if (index == lastIndex) {
28494         data.pop();
28495       } else {
28496         splice.call(data, index, 1);
28497       }
28498       --this.size;
28499       return true;
28500     }
28501
28502     /**
28503      * Gets the list cache value for `key`.
28504      *
28505      * @private
28506      * @name get
28507      * @memberOf ListCache
28508      * @param {string} key The key of the value to get.
28509      * @returns {*} Returns the entry value.
28510      */
28511     function listCacheGet(key) {
28512       var data = this.__data__,
28513           index = assocIndexOf(data, key);
28514
28515       return index < 0 ? undefined : data[index][1];
28516     }
28517
28518     /**
28519      * Checks if a list cache value for `key` exists.
28520      *
28521      * @private
28522      * @name has
28523      * @memberOf ListCache
28524      * @param {string} key The key of the entry to check.
28525      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28526      */
28527     function listCacheHas(key) {
28528       return assocIndexOf(this.__data__, key) > -1;
28529     }
28530
28531     /**
28532      * Sets the list cache `key` to `value`.
28533      *
28534      * @private
28535      * @name set
28536      * @memberOf ListCache
28537      * @param {string} key The key of the value to set.
28538      * @param {*} value The value to set.
28539      * @returns {Object} Returns the list cache instance.
28540      */
28541     function listCacheSet(key, value) {
28542       var data = this.__data__,
28543           index = assocIndexOf(data, key);
28544
28545       if (index < 0) {
28546         ++this.size;
28547         data.push([key, value]);
28548       } else {
28549         data[index][1] = value;
28550       }
28551       return this;
28552     }
28553
28554     // Add methods to `ListCache`.
28555     ListCache.prototype.clear = listCacheClear;
28556     ListCache.prototype['delete'] = listCacheDelete;
28557     ListCache.prototype.get = listCacheGet;
28558     ListCache.prototype.has = listCacheHas;
28559     ListCache.prototype.set = listCacheSet;
28560
28561     /*------------------------------------------------------------------------*/
28562
28563     /**
28564      * Creates a map cache object to store key-value pairs.
28565      *
28566      * @private
28567      * @constructor
28568      * @param {Array} [entries] The key-value pairs to cache.
28569      */
28570     function MapCache(entries) {
28571       var index = -1,
28572           length = entries == null ? 0 : entries.length;
28573
28574       this.clear();
28575       while (++index < length) {
28576         var entry = entries[index];
28577         this.set(entry[0], entry[1]);
28578       }
28579     }
28580
28581     /**
28582      * Removes all key-value entries from the map.
28583      *
28584      * @private
28585      * @name clear
28586      * @memberOf MapCache
28587      */
28588     function mapCacheClear() {
28589       this.size = 0;
28590       this.__data__ = {
28591         'hash': new Hash,
28592         'map': new (Map || ListCache),
28593         'string': new Hash
28594       };
28595     }
28596
28597     /**
28598      * Removes `key` and its value from the map.
28599      *
28600      * @private
28601      * @name delete
28602      * @memberOf MapCache
28603      * @param {string} key The key of the value to remove.
28604      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
28605      */
28606     function mapCacheDelete(key) {
28607       var result = getMapData(this, key)['delete'](key);
28608       this.size -= result ? 1 : 0;
28609       return result;
28610     }
28611
28612     /**
28613      * Gets the map value for `key`.
28614      *
28615      * @private
28616      * @name get
28617      * @memberOf MapCache
28618      * @param {string} key The key of the value to get.
28619      * @returns {*} Returns the entry value.
28620      */
28621     function mapCacheGet(key) {
28622       return getMapData(this, key).get(key);
28623     }
28624
28625     /**
28626      * Checks if a map value for `key` exists.
28627      *
28628      * @private
28629      * @name has
28630      * @memberOf MapCache
28631      * @param {string} key The key of the entry to check.
28632      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28633      */
28634     function mapCacheHas(key) {
28635       return getMapData(this, key).has(key);
28636     }
28637
28638     /**
28639      * Sets the map `key` to `value`.
28640      *
28641      * @private
28642      * @name set
28643      * @memberOf MapCache
28644      * @param {string} key The key of the value to set.
28645      * @param {*} value The value to set.
28646      * @returns {Object} Returns the map cache instance.
28647      */
28648     function mapCacheSet(key, value) {
28649       var data = getMapData(this, key),
28650           size = data.size;
28651
28652       data.set(key, value);
28653       this.size += data.size == size ? 0 : 1;
28654       return this;
28655     }
28656
28657     // Add methods to `MapCache`.
28658     MapCache.prototype.clear = mapCacheClear;
28659     MapCache.prototype['delete'] = mapCacheDelete;
28660     MapCache.prototype.get = mapCacheGet;
28661     MapCache.prototype.has = mapCacheHas;
28662     MapCache.prototype.set = mapCacheSet;
28663
28664     /*------------------------------------------------------------------------*/
28665
28666     /**
28667      *
28668      * Creates an array cache object to store unique values.
28669      *
28670      * @private
28671      * @constructor
28672      * @param {Array} [values] The values to cache.
28673      */
28674     function SetCache(values) {
28675       var index = -1,
28676           length = values == null ? 0 : values.length;
28677
28678       this.__data__ = new MapCache;
28679       while (++index < length) {
28680         this.add(values[index]);
28681       }
28682     }
28683
28684     /**
28685      * Adds `value` to the array cache.
28686      *
28687      * @private
28688      * @name add
28689      * @memberOf SetCache
28690      * @alias push
28691      * @param {*} value The value to cache.
28692      * @returns {Object} Returns the cache instance.
28693      */
28694     function setCacheAdd(value) {
28695       this.__data__.set(value, HASH_UNDEFINED);
28696       return this;
28697     }
28698
28699     /**
28700      * Checks if `value` is in the array cache.
28701      *
28702      * @private
28703      * @name has
28704      * @memberOf SetCache
28705      * @param {*} value The value to search for.
28706      * @returns {number} Returns `true` if `value` is found, else `false`.
28707      */
28708     function setCacheHas(value) {
28709       return this.__data__.has(value);
28710     }
28711
28712     // Add methods to `SetCache`.
28713     SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
28714     SetCache.prototype.has = setCacheHas;
28715
28716     /*------------------------------------------------------------------------*/
28717
28718     /**
28719      * Creates a stack cache object to store key-value pairs.
28720      *
28721      * @private
28722      * @constructor
28723      * @param {Array} [entries] The key-value pairs to cache.
28724      */
28725     function Stack(entries) {
28726       var data = this.__data__ = new ListCache(entries);
28727       this.size = data.size;
28728     }
28729
28730     /**
28731      * Removes all key-value entries from the stack.
28732      *
28733      * @private
28734      * @name clear
28735      * @memberOf Stack
28736      */
28737     function stackClear() {
28738       this.__data__ = new ListCache;
28739       this.size = 0;
28740     }
28741
28742     /**
28743      * Removes `key` and its value from the stack.
28744      *
28745      * @private
28746      * @name delete
28747      * @memberOf Stack
28748      * @param {string} key The key of the value to remove.
28749      * @returns {boolean} Returns `true` if the entry was removed, else `false`.
28750      */
28751     function stackDelete(key) {
28752       var data = this.__data__,
28753           result = data['delete'](key);
28754
28755       this.size = data.size;
28756       return result;
28757     }
28758
28759     /**
28760      * Gets the stack value for `key`.
28761      *
28762      * @private
28763      * @name get
28764      * @memberOf Stack
28765      * @param {string} key The key of the value to get.
28766      * @returns {*} Returns the entry value.
28767      */
28768     function stackGet(key) {
28769       return this.__data__.get(key);
28770     }
28771
28772     /**
28773      * Checks if a stack value for `key` exists.
28774      *
28775      * @private
28776      * @name has
28777      * @memberOf Stack
28778      * @param {string} key The key of the entry to check.
28779      * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
28780      */
28781     function stackHas(key) {
28782       return this.__data__.has(key);
28783     }
28784
28785     /**
28786      * Sets the stack `key` to `value`.
28787      *
28788      * @private
28789      * @name set
28790      * @memberOf Stack
28791      * @param {string} key The key of the value to set.
28792      * @param {*} value The value to set.
28793      * @returns {Object} Returns the stack cache instance.
28794      */
28795     function stackSet(key, value) {
28796       var data = this.__data__;
28797       if (data instanceof ListCache) {
28798         var pairs = data.__data__;
28799         if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
28800           pairs.push([key, value]);
28801           this.size = ++data.size;
28802           return this;
28803         }
28804         data = this.__data__ = new MapCache(pairs);
28805       }
28806       data.set(key, value);
28807       this.size = data.size;
28808       return this;
28809     }
28810
28811     // Add methods to `Stack`.
28812     Stack.prototype.clear = stackClear;
28813     Stack.prototype['delete'] = stackDelete;
28814     Stack.prototype.get = stackGet;
28815     Stack.prototype.has = stackHas;
28816     Stack.prototype.set = stackSet;
28817
28818     /*------------------------------------------------------------------------*/
28819
28820     /**
28821      * Creates an array of the enumerable property names of the array-like `value`.
28822      *
28823      * @private
28824      * @param {*} value The value to query.
28825      * @param {boolean} inherited Specify returning inherited property names.
28826      * @returns {Array} Returns the array of property names.
28827      */
28828     function arrayLikeKeys(value, inherited) {
28829       var isArr = isArray(value),
28830           isArg = !isArr && isArguments(value),
28831           isBuff = !isArr && !isArg && isBuffer(value),
28832           isType = !isArr && !isArg && !isBuff && isTypedArray(value),
28833           skipIndexes = isArr || isArg || isBuff || isType,
28834           result = skipIndexes ? baseTimes(value.length, String) : [],
28835           length = result.length;
28836
28837       for (var key in value) {
28838         if ((inherited || hasOwnProperty.call(value, key)) &&
28839             !(skipIndexes && (
28840                // Safari 9 has enumerable `arguments.length` in strict mode.
28841                key == 'length' ||
28842                // Node.js 0.10 has enumerable non-index properties on buffers.
28843                (isBuff && (key == 'offset' || key == 'parent')) ||
28844                // PhantomJS 2 has enumerable non-index properties on typed arrays.
28845                (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
28846                // Skip index properties.
28847                isIndex(key, length)
28848             ))) {
28849           result.push(key);
28850         }
28851       }
28852       return result;
28853     }
28854
28855     /**
28856      * A specialized version of `_.sample` for arrays.
28857      *
28858      * @private
28859      * @param {Array} array The array to sample.
28860      * @returns {*} Returns the random element.
28861      */
28862     function arraySample(array) {
28863       var length = array.length;
28864       return length ? array[baseRandom(0, length - 1)] : undefined;
28865     }
28866
28867     /**
28868      * A specialized version of `_.sampleSize` for arrays.
28869      *
28870      * @private
28871      * @param {Array} array The array to sample.
28872      * @param {number} n The number of elements to sample.
28873      * @returns {Array} Returns the random elements.
28874      */
28875     function arraySampleSize(array, n) {
28876       return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
28877     }
28878
28879     /**
28880      * A specialized version of `_.shuffle` for arrays.
28881      *
28882      * @private
28883      * @param {Array} array The array to shuffle.
28884      * @returns {Array} Returns the new shuffled array.
28885      */
28886     function arrayShuffle(array) {
28887       return shuffleSelf(copyArray(array));
28888     }
28889
28890     /**
28891      * This function is like `assignValue` except that it doesn't assign
28892      * `undefined` values.
28893      *
28894      * @private
28895      * @param {Object} object The object to modify.
28896      * @param {string} key The key of the property to assign.
28897      * @param {*} value The value to assign.
28898      */
28899     function assignMergeValue(object, key, value) {
28900       if ((value !== undefined && !eq(object[key], value)) ||
28901           (value === undefined && !(key in object))) {
28902         baseAssignValue(object, key, value);
28903       }
28904     }
28905
28906     /**
28907      * Assigns `value` to `key` of `object` if the existing value is not equivalent
28908      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
28909      * for equality comparisons.
28910      *
28911      * @private
28912      * @param {Object} object The object to modify.
28913      * @param {string} key The key of the property to assign.
28914      * @param {*} value The value to assign.
28915      */
28916     function assignValue(object, key, value) {
28917       var objValue = object[key];
28918       if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
28919           (value === undefined && !(key in object))) {
28920         baseAssignValue(object, key, value);
28921       }
28922     }
28923
28924     /**
28925      * Gets the index at which the `key` is found in `array` of key-value pairs.
28926      *
28927      * @private
28928      * @param {Array} array The array to inspect.
28929      * @param {*} key The key to search for.
28930      * @returns {number} Returns the index of the matched value, else `-1`.
28931      */
28932     function assocIndexOf(array, key) {
28933       var length = array.length;
28934       while (length--) {
28935         if (eq(array[length][0], key)) {
28936           return length;
28937         }
28938       }
28939       return -1;
28940     }
28941
28942     /**
28943      * Aggregates elements of `collection` on `accumulator` with keys transformed
28944      * by `iteratee` and values set by `setter`.
28945      *
28946      * @private
28947      * @param {Array|Object} collection The collection to iterate over.
28948      * @param {Function} setter The function to set `accumulator` values.
28949      * @param {Function} iteratee The iteratee to transform keys.
28950      * @param {Object} accumulator The initial aggregated object.
28951      * @returns {Function} Returns `accumulator`.
28952      */
28953     function baseAggregator(collection, setter, iteratee, accumulator) {
28954       baseEach(collection, function(value, key, collection) {
28955         setter(accumulator, value, iteratee(value), collection);
28956       });
28957       return accumulator;
28958     }
28959
28960     /**
28961      * The base implementation of `_.assign` without support for multiple sources
28962      * or `customizer` functions.
28963      *
28964      * @private
28965      * @param {Object} object The destination object.
28966      * @param {Object} source The source object.
28967      * @returns {Object} Returns `object`.
28968      */
28969     function baseAssign(object, source) {
28970       return object && copyObject(source, keys(source), object);
28971     }
28972
28973     /**
28974      * The base implementation of `_.assignIn` without support for multiple sources
28975      * or `customizer` functions.
28976      *
28977      * @private
28978      * @param {Object} object The destination object.
28979      * @param {Object} source The source object.
28980      * @returns {Object} Returns `object`.
28981      */
28982     function baseAssignIn(object, source) {
28983       return object && copyObject(source, keysIn(source), object);
28984     }
28985
28986     /**
28987      * The base implementation of `assignValue` and `assignMergeValue` without
28988      * value checks.
28989      *
28990      * @private
28991      * @param {Object} object The object to modify.
28992      * @param {string} key The key of the property to assign.
28993      * @param {*} value The value to assign.
28994      */
28995     function baseAssignValue(object, key, value) {
28996       if (key == '__proto__' && defineProperty) {
28997         defineProperty(object, key, {
28998           'configurable': true,
28999           'enumerable': true,
29000           'value': value,
29001           'writable': true
29002         });
29003       } else {
29004         object[key] = value;
29005       }
29006     }
29007
29008     /**
29009      * The base implementation of `_.at` without support for individual paths.
29010      *
29011      * @private
29012      * @param {Object} object The object to iterate over.
29013      * @param {string[]} paths The property paths to pick.
29014      * @returns {Array} Returns the picked elements.
29015      */
29016     function baseAt(object, paths) {
29017       var index = -1,
29018           length = paths.length,
29019           result = Array(length),
29020           skip = object == null;
29021
29022       while (++index < length) {
29023         result[index] = skip ? undefined : get(object, paths[index]);
29024       }
29025       return result;
29026     }
29027
29028     /**
29029      * The base implementation of `_.clamp` which doesn't coerce arguments.
29030      *
29031      * @private
29032      * @param {number} number The number to clamp.
29033      * @param {number} [lower] The lower bound.
29034      * @param {number} upper The upper bound.
29035      * @returns {number} Returns the clamped number.
29036      */
29037     function baseClamp(number, lower, upper) {
29038       if (number === number) {
29039         if (upper !== undefined) {
29040           number = number <= upper ? number : upper;
29041         }
29042         if (lower !== undefined) {
29043           number = number >= lower ? number : lower;
29044         }
29045       }
29046       return number;
29047     }
29048
29049     /**
29050      * The base implementation of `_.clone` and `_.cloneDeep` which tracks
29051      * traversed objects.
29052      *
29053      * @private
29054      * @param {*} value The value to clone.
29055      * @param {boolean} bitmask The bitmask flags.
29056      *  1 - Deep clone
29057      *  2 - Flatten inherited properties
29058      *  4 - Clone symbols
29059      * @param {Function} [customizer] The function to customize cloning.
29060      * @param {string} [key] The key of `value`.
29061      * @param {Object} [object] The parent object of `value`.
29062      * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
29063      * @returns {*} Returns the cloned value.
29064      */
29065     function baseClone(value, bitmask, customizer, key, object, stack) {
29066       var result,
29067           isDeep = bitmask & CLONE_DEEP_FLAG,
29068           isFlat = bitmask & CLONE_FLAT_FLAG,
29069           isFull = bitmask & CLONE_SYMBOLS_FLAG;
29070
29071       if (customizer) {
29072         result = object ? customizer(value, key, object, stack) : customizer(value);
29073       }
29074       if (result !== undefined) {
29075         return result;
29076       }
29077       if (!isObject(value)) {
29078         return value;
29079       }
29080       var isArr = isArray(value);
29081       if (isArr) {
29082         result = initCloneArray(value);
29083         if (!isDeep) {
29084           return copyArray(value, result);
29085         }
29086       } else {
29087         var tag = getTag(value),
29088             isFunc = tag == funcTag || tag == genTag;
29089
29090         if (isBuffer(value)) {
29091           return cloneBuffer(value, isDeep);
29092         }
29093         if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
29094           result = (isFlat || isFunc) ? {} : initCloneObject(value);
29095           if (!isDeep) {
29096             return isFlat
29097               ? copySymbolsIn(value, baseAssignIn(result, value))
29098               : copySymbols(value, baseAssign(result, value));
29099           }
29100         } else {
29101           if (!cloneableTags[tag]) {
29102             return object ? value : {};
29103           }
29104           result = initCloneByTag(value, tag, isDeep);
29105         }
29106       }
29107       // Check for circular references and return its corresponding clone.
29108       stack || (stack = new Stack);
29109       var stacked = stack.get(value);
29110       if (stacked) {
29111         return stacked;
29112       }
29113       stack.set(value, result);
29114
29115       if (isSet(value)) {
29116         value.forEach(function(subValue) {
29117           result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
29118         });
29119       } else if (isMap(value)) {
29120         value.forEach(function(subValue, key) {
29121           result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
29122         });
29123       }
29124
29125       var keysFunc = isFull
29126         ? (isFlat ? getAllKeysIn : getAllKeys)
29127         : (isFlat ? keysIn : keys);
29128
29129       var props = isArr ? undefined : keysFunc(value);
29130       arrayEach(props || value, function(subValue, key) {
29131         if (props) {
29132           key = subValue;
29133           subValue = value[key];
29134         }
29135         // Recursively populate clone (susceptible to call stack limits).
29136         assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
29137       });
29138       return result;
29139     }
29140
29141     /**
29142      * The base implementation of `_.conforms` which doesn't clone `source`.
29143      *
29144      * @private
29145      * @param {Object} source The object of property predicates to conform to.
29146      * @returns {Function} Returns the new spec function.
29147      */
29148     function baseConforms(source) {
29149       var props = keys(source);
29150       return function(object) {
29151         return baseConformsTo(object, source, props);
29152       };
29153     }
29154
29155     /**
29156      * The base implementation of `_.conformsTo` which accepts `props` to check.
29157      *
29158      * @private
29159      * @param {Object} object The object to inspect.
29160      * @param {Object} source The object of property predicates to conform to.
29161      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
29162      */
29163     function baseConformsTo(object, source, props) {
29164       var length = props.length;
29165       if (object == null) {
29166         return !length;
29167       }
29168       object = Object(object);
29169       while (length--) {
29170         var key = props[length],
29171             predicate = source[key],
29172             value = object[key];
29173
29174         if ((value === undefined && !(key in object)) || !predicate(value)) {
29175           return false;
29176         }
29177       }
29178       return true;
29179     }
29180
29181     /**
29182      * The base implementation of `_.delay` and `_.defer` which accepts `args`
29183      * to provide to `func`.
29184      *
29185      * @private
29186      * @param {Function} func The function to delay.
29187      * @param {number} wait The number of milliseconds to delay invocation.
29188      * @param {Array} args The arguments to provide to `func`.
29189      * @returns {number|Object} Returns the timer id or timeout object.
29190      */
29191     function baseDelay(func, wait, args) {
29192       if (typeof func != 'function') {
29193         throw new TypeError(FUNC_ERROR_TEXT);
29194       }
29195       return setTimeout(function() { func.apply(undefined, args); }, wait);
29196     }
29197
29198     /**
29199      * The base implementation of methods like `_.difference` without support
29200      * for excluding multiple arrays or iteratee shorthands.
29201      *
29202      * @private
29203      * @param {Array} array The array to inspect.
29204      * @param {Array} values The values to exclude.
29205      * @param {Function} [iteratee] The iteratee invoked per element.
29206      * @param {Function} [comparator] The comparator invoked per element.
29207      * @returns {Array} Returns the new array of filtered values.
29208      */
29209     function baseDifference(array, values, iteratee, comparator) {
29210       var index = -1,
29211           includes = arrayIncludes,
29212           isCommon = true,
29213           length = array.length,
29214           result = [],
29215           valuesLength = values.length;
29216
29217       if (!length) {
29218         return result;
29219       }
29220       if (iteratee) {
29221         values = arrayMap(values, baseUnary(iteratee));
29222       }
29223       if (comparator) {
29224         includes = arrayIncludesWith;
29225         isCommon = false;
29226       }
29227       else if (values.length >= LARGE_ARRAY_SIZE) {
29228         includes = cacheHas;
29229         isCommon = false;
29230         values = new SetCache(values);
29231       }
29232       outer:
29233       while (++index < length) {
29234         var value = array[index],
29235             computed = iteratee == null ? value : iteratee(value);
29236
29237         value = (comparator || value !== 0) ? value : 0;
29238         if (isCommon && computed === computed) {
29239           var valuesIndex = valuesLength;
29240           while (valuesIndex--) {
29241             if (values[valuesIndex] === computed) {
29242               continue outer;
29243             }
29244           }
29245           result.push(value);
29246         }
29247         else if (!includes(values, computed, comparator)) {
29248           result.push(value);
29249         }
29250       }
29251       return result;
29252     }
29253
29254     /**
29255      * The base implementation of `_.forEach` without support for iteratee shorthands.
29256      *
29257      * @private
29258      * @param {Array|Object} collection The collection to iterate over.
29259      * @param {Function} iteratee The function invoked per iteration.
29260      * @returns {Array|Object} Returns `collection`.
29261      */
29262     var baseEach = createBaseEach(baseForOwn);
29263
29264     /**
29265      * The base implementation of `_.forEachRight` without support for iteratee shorthands.
29266      *
29267      * @private
29268      * @param {Array|Object} collection The collection to iterate over.
29269      * @param {Function} iteratee The function invoked per iteration.
29270      * @returns {Array|Object} Returns `collection`.
29271      */
29272     var baseEachRight = createBaseEach(baseForOwnRight, true);
29273
29274     /**
29275      * The base implementation of `_.every` without support for iteratee shorthands.
29276      *
29277      * @private
29278      * @param {Array|Object} collection The collection to iterate over.
29279      * @param {Function} predicate The function invoked per iteration.
29280      * @returns {boolean} Returns `true` if all elements pass the predicate check,
29281      *  else `false`
29282      */
29283     function baseEvery(collection, predicate) {
29284       var result = true;
29285       baseEach(collection, function(value, index, collection) {
29286         result = !!predicate(value, index, collection);
29287         return result;
29288       });
29289       return result;
29290     }
29291
29292     /**
29293      * The base implementation of methods like `_.max` and `_.min` which accepts a
29294      * `comparator` to determine the extremum value.
29295      *
29296      * @private
29297      * @param {Array} array The array to iterate over.
29298      * @param {Function} iteratee The iteratee invoked per iteration.
29299      * @param {Function} comparator The comparator used to compare values.
29300      * @returns {*} Returns the extremum value.
29301      */
29302     function baseExtremum(array, iteratee, comparator) {
29303       var index = -1,
29304           length = array.length;
29305
29306       while (++index < length) {
29307         var value = array[index],
29308             current = iteratee(value);
29309
29310         if (current != null && (computed === undefined
29311               ? (current === current && !isSymbol(current))
29312               : comparator(current, computed)
29313             )) {
29314           var computed = current,
29315               result = value;
29316         }
29317       }
29318       return result;
29319     }
29320
29321     /**
29322      * The base implementation of `_.fill` without an iteratee call guard.
29323      *
29324      * @private
29325      * @param {Array} array The array to fill.
29326      * @param {*} value The value to fill `array` with.
29327      * @param {number} [start=0] The start position.
29328      * @param {number} [end=array.length] The end position.
29329      * @returns {Array} Returns `array`.
29330      */
29331     function baseFill(array, value, start, end) {
29332       var length = array.length;
29333
29334       start = toInteger(start);
29335       if (start < 0) {
29336         start = -start > length ? 0 : (length + start);
29337       }
29338       end = (end === undefined || end > length) ? length : toInteger(end);
29339       if (end < 0) {
29340         end += length;
29341       }
29342       end = start > end ? 0 : toLength(end);
29343       while (start < end) {
29344         array[start++] = value;
29345       }
29346       return array;
29347     }
29348
29349     /**
29350      * The base implementation of `_.filter` without support for iteratee shorthands.
29351      *
29352      * @private
29353      * @param {Array|Object} collection The collection to iterate over.
29354      * @param {Function} predicate The function invoked per iteration.
29355      * @returns {Array} Returns the new filtered array.
29356      */
29357     function baseFilter(collection, predicate) {
29358       var result = [];
29359       baseEach(collection, function(value, index, collection) {
29360         if (predicate(value, index, collection)) {
29361           result.push(value);
29362         }
29363       });
29364       return result;
29365     }
29366
29367     /**
29368      * The base implementation of `_.flatten` with support for restricting flattening.
29369      *
29370      * @private
29371      * @param {Array} array The array to flatten.
29372      * @param {number} depth The maximum recursion depth.
29373      * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
29374      * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
29375      * @param {Array} [result=[]] The initial result value.
29376      * @returns {Array} Returns the new flattened array.
29377      */
29378     function baseFlatten(array, depth, predicate, isStrict, result) {
29379       var index = -1,
29380           length = array.length;
29381
29382       predicate || (predicate = isFlattenable);
29383       result || (result = []);
29384
29385       while (++index < length) {
29386         var value = array[index];
29387         if (depth > 0 && predicate(value)) {
29388           if (depth > 1) {
29389             // Recursively flatten arrays (susceptible to call stack limits).
29390             baseFlatten(value, depth - 1, predicate, isStrict, result);
29391           } else {
29392             arrayPush(result, value);
29393           }
29394         } else if (!isStrict) {
29395           result[result.length] = value;
29396         }
29397       }
29398       return result;
29399     }
29400
29401     /**
29402      * The base implementation of `baseForOwn` which iterates over `object`
29403      * properties returned by `keysFunc` and invokes `iteratee` for each property.
29404      * Iteratee functions may exit iteration early by explicitly returning `false`.
29405      *
29406      * @private
29407      * @param {Object} object The object to iterate over.
29408      * @param {Function} iteratee The function invoked per iteration.
29409      * @param {Function} keysFunc The function to get the keys of `object`.
29410      * @returns {Object} Returns `object`.
29411      */
29412     var baseFor = createBaseFor();
29413
29414     /**
29415      * This function is like `baseFor` except that it iterates over properties
29416      * in the opposite order.
29417      *
29418      * @private
29419      * @param {Object} object The object to iterate over.
29420      * @param {Function} iteratee The function invoked per iteration.
29421      * @param {Function} keysFunc The function to get the keys of `object`.
29422      * @returns {Object} Returns `object`.
29423      */
29424     var baseForRight = createBaseFor(true);
29425
29426     /**
29427      * The base implementation of `_.forOwn` without support for iteratee shorthands.
29428      *
29429      * @private
29430      * @param {Object} object The object to iterate over.
29431      * @param {Function} iteratee The function invoked per iteration.
29432      * @returns {Object} Returns `object`.
29433      */
29434     function baseForOwn(object, iteratee) {
29435       return object && baseFor(object, iteratee, keys);
29436     }
29437
29438     /**
29439      * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
29440      *
29441      * @private
29442      * @param {Object} object The object to iterate over.
29443      * @param {Function} iteratee The function invoked per iteration.
29444      * @returns {Object} Returns `object`.
29445      */
29446     function baseForOwnRight(object, iteratee) {
29447       return object && baseForRight(object, iteratee, keys);
29448     }
29449
29450     /**
29451      * The base implementation of `_.functions` which creates an array of
29452      * `object` function property names filtered from `props`.
29453      *
29454      * @private
29455      * @param {Object} object The object to inspect.
29456      * @param {Array} props The property names to filter.
29457      * @returns {Array} Returns the function names.
29458      */
29459     function baseFunctions(object, props) {
29460       return arrayFilter(props, function(key) {
29461         return isFunction(object[key]);
29462       });
29463     }
29464
29465     /**
29466      * The base implementation of `_.get` without support for default values.
29467      *
29468      * @private
29469      * @param {Object} object The object to query.
29470      * @param {Array|string} path The path of the property to get.
29471      * @returns {*} Returns the resolved value.
29472      */
29473     function baseGet(object, path) {
29474       path = castPath(path, object);
29475
29476       var index = 0,
29477           length = path.length;
29478
29479       while (object != null && index < length) {
29480         object = object[toKey(path[index++])];
29481       }
29482       return (index && index == length) ? object : undefined;
29483     }
29484
29485     /**
29486      * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
29487      * `keysFunc` and `symbolsFunc` to get the enumerable property names and
29488      * symbols of `object`.
29489      *
29490      * @private
29491      * @param {Object} object The object to query.
29492      * @param {Function} keysFunc The function to get the keys of `object`.
29493      * @param {Function} symbolsFunc The function to get the symbols of `object`.
29494      * @returns {Array} Returns the array of property names and symbols.
29495      */
29496     function baseGetAllKeys(object, keysFunc, symbolsFunc) {
29497       var result = keysFunc(object);
29498       return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
29499     }
29500
29501     /**
29502      * The base implementation of `getTag` without fallbacks for buggy environments.
29503      *
29504      * @private
29505      * @param {*} value The value to query.
29506      * @returns {string} Returns the `toStringTag`.
29507      */
29508     function baseGetTag(value) {
29509       if (value == null) {
29510         return value === undefined ? undefinedTag : nullTag;
29511       }
29512       return (symToStringTag && symToStringTag in Object(value))
29513         ? getRawTag(value)
29514         : objectToString(value);
29515     }
29516
29517     /**
29518      * The base implementation of `_.gt` which doesn't coerce arguments.
29519      *
29520      * @private
29521      * @param {*} value The value to compare.
29522      * @param {*} other The other value to compare.
29523      * @returns {boolean} Returns `true` if `value` is greater than `other`,
29524      *  else `false`.
29525      */
29526     function baseGt(value, other) {
29527       return value > other;
29528     }
29529
29530     /**
29531      * The base implementation of `_.has` without support for deep paths.
29532      *
29533      * @private
29534      * @param {Object} [object] The object to query.
29535      * @param {Array|string} key The key to check.
29536      * @returns {boolean} Returns `true` if `key` exists, else `false`.
29537      */
29538     function baseHas(object, key) {
29539       return object != null && hasOwnProperty.call(object, key);
29540     }
29541
29542     /**
29543      * The base implementation of `_.hasIn` without support for deep paths.
29544      *
29545      * @private
29546      * @param {Object} [object] The object to query.
29547      * @param {Array|string} key The key to check.
29548      * @returns {boolean} Returns `true` if `key` exists, else `false`.
29549      */
29550     function baseHasIn(object, key) {
29551       return object != null && key in Object(object);
29552     }
29553
29554     /**
29555      * The base implementation of `_.inRange` which doesn't coerce arguments.
29556      *
29557      * @private
29558      * @param {number} number The number to check.
29559      * @param {number} start The start of the range.
29560      * @param {number} end The end of the range.
29561      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
29562      */
29563     function baseInRange(number, start, end) {
29564       return number >= nativeMin(start, end) && number < nativeMax(start, end);
29565     }
29566
29567     /**
29568      * The base implementation of methods like `_.intersection`, without support
29569      * for iteratee shorthands, that accepts an array of arrays to inspect.
29570      *
29571      * @private
29572      * @param {Array} arrays The arrays to inspect.
29573      * @param {Function} [iteratee] The iteratee invoked per element.
29574      * @param {Function} [comparator] The comparator invoked per element.
29575      * @returns {Array} Returns the new array of shared values.
29576      */
29577     function baseIntersection(arrays, iteratee, comparator) {
29578       var includes = comparator ? arrayIncludesWith : arrayIncludes,
29579           length = arrays[0].length,
29580           othLength = arrays.length,
29581           othIndex = othLength,
29582           caches = Array(othLength),
29583           maxLength = Infinity,
29584           result = [];
29585
29586       while (othIndex--) {
29587         var array = arrays[othIndex];
29588         if (othIndex && iteratee) {
29589           array = arrayMap(array, baseUnary(iteratee));
29590         }
29591         maxLength = nativeMin(array.length, maxLength);
29592         caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
29593           ? new SetCache(othIndex && array)
29594           : undefined;
29595       }
29596       array = arrays[0];
29597
29598       var index = -1,
29599           seen = caches[0];
29600
29601       outer:
29602       while (++index < length && result.length < maxLength) {
29603         var value = array[index],
29604             computed = iteratee ? iteratee(value) : value;
29605
29606         value = (comparator || value !== 0) ? value : 0;
29607         if (!(seen
29608               ? cacheHas(seen, computed)
29609               : includes(result, computed, comparator)
29610             )) {
29611           othIndex = othLength;
29612           while (--othIndex) {
29613             var cache = caches[othIndex];
29614             if (!(cache
29615                   ? cacheHas(cache, computed)
29616                   : includes(arrays[othIndex], computed, comparator))
29617                 ) {
29618               continue outer;
29619             }
29620           }
29621           if (seen) {
29622             seen.push(computed);
29623           }
29624           result.push(value);
29625         }
29626       }
29627       return result;
29628     }
29629
29630     /**
29631      * The base implementation of `_.invert` and `_.invertBy` which inverts
29632      * `object` with values transformed by `iteratee` and set by `setter`.
29633      *
29634      * @private
29635      * @param {Object} object The object to iterate over.
29636      * @param {Function} setter The function to set `accumulator` values.
29637      * @param {Function} iteratee The iteratee to transform values.
29638      * @param {Object} accumulator The initial inverted object.
29639      * @returns {Function} Returns `accumulator`.
29640      */
29641     function baseInverter(object, setter, iteratee, accumulator) {
29642       baseForOwn(object, function(value, key, object) {
29643         setter(accumulator, iteratee(value), key, object);
29644       });
29645       return accumulator;
29646     }
29647
29648     /**
29649      * The base implementation of `_.invoke` without support for individual
29650      * method arguments.
29651      *
29652      * @private
29653      * @param {Object} object The object to query.
29654      * @param {Array|string} path The path of the method to invoke.
29655      * @param {Array} args The arguments to invoke the method with.
29656      * @returns {*} Returns the result of the invoked method.
29657      */
29658     function baseInvoke(object, path, args) {
29659       path = castPath(path, object);
29660       object = parent(object, path);
29661       var func = object == null ? object : object[toKey(last(path))];
29662       return func == null ? undefined : apply(func, object, args);
29663     }
29664
29665     /**
29666      * The base implementation of `_.isArguments`.
29667      *
29668      * @private
29669      * @param {*} value The value to check.
29670      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
29671      */
29672     function baseIsArguments(value) {
29673       return isObjectLike(value) && baseGetTag(value) == argsTag;
29674     }
29675
29676     /**
29677      * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
29678      *
29679      * @private
29680      * @param {*} value The value to check.
29681      * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
29682      */
29683     function baseIsArrayBuffer(value) {
29684       return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
29685     }
29686
29687     /**
29688      * The base implementation of `_.isDate` without Node.js optimizations.
29689      *
29690      * @private
29691      * @param {*} value The value to check.
29692      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
29693      */
29694     function baseIsDate(value) {
29695       return isObjectLike(value) && baseGetTag(value) == dateTag;
29696     }
29697
29698     /**
29699      * The base implementation of `_.isEqual` which supports partial comparisons
29700      * and tracks traversed objects.
29701      *
29702      * @private
29703      * @param {*} value The value to compare.
29704      * @param {*} other The other value to compare.
29705      * @param {boolean} bitmask The bitmask flags.
29706      *  1 - Unordered comparison
29707      *  2 - Partial comparison
29708      * @param {Function} [customizer] The function to customize comparisons.
29709      * @param {Object} [stack] Tracks traversed `value` and `other` objects.
29710      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
29711      */
29712     function baseIsEqual(value, other, bitmask, customizer, stack) {
29713       if (value === other) {
29714         return true;
29715       }
29716       if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
29717         return value !== value && other !== other;
29718       }
29719       return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
29720     }
29721
29722     /**
29723      * A specialized version of `baseIsEqual` for arrays and objects which performs
29724      * deep comparisons and tracks traversed objects enabling objects with circular
29725      * references to be compared.
29726      *
29727      * @private
29728      * @param {Object} object The object to compare.
29729      * @param {Object} other The other object to compare.
29730      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
29731      * @param {Function} customizer The function to customize comparisons.
29732      * @param {Function} equalFunc The function to determine equivalents of values.
29733      * @param {Object} [stack] Tracks traversed `object` and `other` objects.
29734      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
29735      */
29736     function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
29737       var objIsArr = isArray(object),
29738           othIsArr = isArray(other),
29739           objTag = objIsArr ? arrayTag : getTag(object),
29740           othTag = othIsArr ? arrayTag : getTag(other);
29741
29742       objTag = objTag == argsTag ? objectTag : objTag;
29743       othTag = othTag == argsTag ? objectTag : othTag;
29744
29745       var objIsObj = objTag == objectTag,
29746           othIsObj = othTag == objectTag,
29747           isSameTag = objTag == othTag;
29748
29749       if (isSameTag && isBuffer(object)) {
29750         if (!isBuffer(other)) {
29751           return false;
29752         }
29753         objIsArr = true;
29754         objIsObj = false;
29755       }
29756       if (isSameTag && !objIsObj) {
29757         stack || (stack = new Stack);
29758         return (objIsArr || isTypedArray(object))
29759           ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
29760           : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
29761       }
29762       if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
29763         var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
29764             othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
29765
29766         if (objIsWrapped || othIsWrapped) {
29767           var objUnwrapped = objIsWrapped ? object.value() : object,
29768               othUnwrapped = othIsWrapped ? other.value() : other;
29769
29770           stack || (stack = new Stack);
29771           return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
29772         }
29773       }
29774       if (!isSameTag) {
29775         return false;
29776       }
29777       stack || (stack = new Stack);
29778       return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
29779     }
29780
29781     /**
29782      * The base implementation of `_.isMap` without Node.js optimizations.
29783      *
29784      * @private
29785      * @param {*} value The value to check.
29786      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
29787      */
29788     function baseIsMap(value) {
29789       return isObjectLike(value) && getTag(value) == mapTag;
29790     }
29791
29792     /**
29793      * The base implementation of `_.isMatch` without support for iteratee shorthands.
29794      *
29795      * @private
29796      * @param {Object} object The object to inspect.
29797      * @param {Object} source The object of property values to match.
29798      * @param {Array} matchData The property names, values, and compare flags to match.
29799      * @param {Function} [customizer] The function to customize comparisons.
29800      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
29801      */
29802     function baseIsMatch(object, source, matchData, customizer) {
29803       var index = matchData.length,
29804           length = index,
29805           noCustomizer = !customizer;
29806
29807       if (object == null) {
29808         return !length;
29809       }
29810       object = Object(object);
29811       while (index--) {
29812         var data = matchData[index];
29813         if ((noCustomizer && data[2])
29814               ? data[1] !== object[data[0]]
29815               : !(data[0] in object)
29816             ) {
29817           return false;
29818         }
29819       }
29820       while (++index < length) {
29821         data = matchData[index];
29822         var key = data[0],
29823             objValue = object[key],
29824             srcValue = data[1];
29825
29826         if (noCustomizer && data[2]) {
29827           if (objValue === undefined && !(key in object)) {
29828             return false;
29829           }
29830         } else {
29831           var stack = new Stack;
29832           if (customizer) {
29833             var result = customizer(objValue, srcValue, key, object, source, stack);
29834           }
29835           if (!(result === undefined
29836                 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
29837                 : result
29838               )) {
29839             return false;
29840           }
29841         }
29842       }
29843       return true;
29844     }
29845
29846     /**
29847      * The base implementation of `_.isNative` without bad shim checks.
29848      *
29849      * @private
29850      * @param {*} value The value to check.
29851      * @returns {boolean} Returns `true` if `value` is a native function,
29852      *  else `false`.
29853      */
29854     function baseIsNative(value) {
29855       if (!isObject(value) || isMasked(value)) {
29856         return false;
29857       }
29858       var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
29859       return pattern.test(toSource(value));
29860     }
29861
29862     /**
29863      * The base implementation of `_.isRegExp` without Node.js optimizations.
29864      *
29865      * @private
29866      * @param {*} value The value to check.
29867      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
29868      */
29869     function baseIsRegExp(value) {
29870       return isObjectLike(value) && baseGetTag(value) == regexpTag;
29871     }
29872
29873     /**
29874      * The base implementation of `_.isSet` without Node.js optimizations.
29875      *
29876      * @private
29877      * @param {*} value The value to check.
29878      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
29879      */
29880     function baseIsSet(value) {
29881       return isObjectLike(value) && getTag(value) == setTag;
29882     }
29883
29884     /**
29885      * The base implementation of `_.isTypedArray` without Node.js optimizations.
29886      *
29887      * @private
29888      * @param {*} value The value to check.
29889      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
29890      */
29891     function baseIsTypedArray(value) {
29892       return isObjectLike(value) &&
29893         isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
29894     }
29895
29896     /**
29897      * The base implementation of `_.iteratee`.
29898      *
29899      * @private
29900      * @param {*} [value=_.identity] The value to convert to an iteratee.
29901      * @returns {Function} Returns the iteratee.
29902      */
29903     function baseIteratee(value) {
29904       // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
29905       // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
29906       if (typeof value == 'function') {
29907         return value;
29908       }
29909       if (value == null) {
29910         return identity;
29911       }
29912       if (typeof value == 'object') {
29913         return isArray(value)
29914           ? baseMatchesProperty(value[0], value[1])
29915           : baseMatches(value);
29916       }
29917       return property(value);
29918     }
29919
29920     /**
29921      * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
29922      *
29923      * @private
29924      * @param {Object} object The object to query.
29925      * @returns {Array} Returns the array of property names.
29926      */
29927     function baseKeys(object) {
29928       if (!isPrototype(object)) {
29929         return nativeKeys(object);
29930       }
29931       var result = [];
29932       for (var key in Object(object)) {
29933         if (hasOwnProperty.call(object, key) && key != 'constructor') {
29934           result.push(key);
29935         }
29936       }
29937       return result;
29938     }
29939
29940     /**
29941      * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
29942      *
29943      * @private
29944      * @param {Object} object The object to query.
29945      * @returns {Array} Returns the array of property names.
29946      */
29947     function baseKeysIn(object) {
29948       if (!isObject(object)) {
29949         return nativeKeysIn(object);
29950       }
29951       var isProto = isPrototype(object),
29952           result = [];
29953
29954       for (var key in object) {
29955         if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
29956           result.push(key);
29957         }
29958       }
29959       return result;
29960     }
29961
29962     /**
29963      * The base implementation of `_.lt` which doesn't coerce arguments.
29964      *
29965      * @private
29966      * @param {*} value The value to compare.
29967      * @param {*} other The other value to compare.
29968      * @returns {boolean} Returns `true` if `value` is less than `other`,
29969      *  else `false`.
29970      */
29971     function baseLt(value, other) {
29972       return value < other;
29973     }
29974
29975     /**
29976      * The base implementation of `_.map` without support for iteratee shorthands.
29977      *
29978      * @private
29979      * @param {Array|Object} collection The collection to iterate over.
29980      * @param {Function} iteratee The function invoked per iteration.
29981      * @returns {Array} Returns the new mapped array.
29982      */
29983     function baseMap(collection, iteratee) {
29984       var index = -1,
29985           result = isArrayLike(collection) ? Array(collection.length) : [];
29986
29987       baseEach(collection, function(value, key, collection) {
29988         result[++index] = iteratee(value, key, collection);
29989       });
29990       return result;
29991     }
29992
29993     /**
29994      * The base implementation of `_.matches` which doesn't clone `source`.
29995      *
29996      * @private
29997      * @param {Object} source The object of property values to match.
29998      * @returns {Function} Returns the new spec function.
29999      */
30000     function baseMatches(source) {
30001       var matchData = getMatchData(source);
30002       if (matchData.length == 1 && matchData[0][2]) {
30003         return matchesStrictComparable(matchData[0][0], matchData[0][1]);
30004       }
30005       return function(object) {
30006         return object === source || baseIsMatch(object, source, matchData);
30007       };
30008     }
30009
30010     /**
30011      * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
30012      *
30013      * @private
30014      * @param {string} path The path of the property to get.
30015      * @param {*} srcValue The value to match.
30016      * @returns {Function} Returns the new spec function.
30017      */
30018     function baseMatchesProperty(path, srcValue) {
30019       if (isKey(path) && isStrictComparable(srcValue)) {
30020         return matchesStrictComparable(toKey(path), srcValue);
30021       }
30022       return function(object) {
30023         var objValue = get(object, path);
30024         return (objValue === undefined && objValue === srcValue)
30025           ? hasIn(object, path)
30026           : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
30027       };
30028     }
30029
30030     /**
30031      * The base implementation of `_.merge` without support for multiple sources.
30032      *
30033      * @private
30034      * @param {Object} object The destination object.
30035      * @param {Object} source The source object.
30036      * @param {number} srcIndex The index of `source`.
30037      * @param {Function} [customizer] The function to customize merged values.
30038      * @param {Object} [stack] Tracks traversed source values and their merged
30039      *  counterparts.
30040      */
30041     function baseMerge(object, source, srcIndex, customizer, stack) {
30042       if (object === source) {
30043         return;
30044       }
30045       baseFor(source, function(srcValue, key) {
30046         stack || (stack = new Stack);
30047         if (isObject(srcValue)) {
30048           baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
30049         }
30050         else {
30051           var newValue = customizer
30052             ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
30053             : undefined;
30054
30055           if (newValue === undefined) {
30056             newValue = srcValue;
30057           }
30058           assignMergeValue(object, key, newValue);
30059         }
30060       }, keysIn);
30061     }
30062
30063     /**
30064      * A specialized version of `baseMerge` for arrays and objects which performs
30065      * deep merges and tracks traversed objects enabling objects with circular
30066      * references to be merged.
30067      *
30068      * @private
30069      * @param {Object} object The destination object.
30070      * @param {Object} source The source object.
30071      * @param {string} key The key of the value to merge.
30072      * @param {number} srcIndex The index of `source`.
30073      * @param {Function} mergeFunc The function to merge values.
30074      * @param {Function} [customizer] The function to customize assigned values.
30075      * @param {Object} [stack] Tracks traversed source values and their merged
30076      *  counterparts.
30077      */
30078     function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
30079       var objValue = safeGet(object, key),
30080           srcValue = safeGet(source, key),
30081           stacked = stack.get(srcValue);
30082
30083       if (stacked) {
30084         assignMergeValue(object, key, stacked);
30085         return;
30086       }
30087       var newValue = customizer
30088         ? customizer(objValue, srcValue, (key + ''), object, source, stack)
30089         : undefined;
30090
30091       var isCommon = newValue === undefined;
30092
30093       if (isCommon) {
30094         var isArr = isArray(srcValue),
30095             isBuff = !isArr && isBuffer(srcValue),
30096             isTyped = !isArr && !isBuff && isTypedArray(srcValue);
30097
30098         newValue = srcValue;
30099         if (isArr || isBuff || isTyped) {
30100           if (isArray(objValue)) {
30101             newValue = objValue;
30102           }
30103           else if (isArrayLikeObject(objValue)) {
30104             newValue = copyArray(objValue);
30105           }
30106           else if (isBuff) {
30107             isCommon = false;
30108             newValue = cloneBuffer(srcValue, true);
30109           }
30110           else if (isTyped) {
30111             isCommon = false;
30112             newValue = cloneTypedArray(srcValue, true);
30113           }
30114           else {
30115             newValue = [];
30116           }
30117         }
30118         else if (isPlainObject(srcValue) || isArguments(srcValue)) {
30119           newValue = objValue;
30120           if (isArguments(objValue)) {
30121             newValue = toPlainObject(objValue);
30122           }
30123           else if (!isObject(objValue) || isFunction(objValue)) {
30124             newValue = initCloneObject(srcValue);
30125           }
30126         }
30127         else {
30128           isCommon = false;
30129         }
30130       }
30131       if (isCommon) {
30132         // Recursively merge objects and arrays (susceptible to call stack limits).
30133         stack.set(srcValue, newValue);
30134         mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
30135         stack['delete'](srcValue);
30136       }
30137       assignMergeValue(object, key, newValue);
30138     }
30139
30140     /**
30141      * The base implementation of `_.nth` which doesn't coerce arguments.
30142      *
30143      * @private
30144      * @param {Array} array The array to query.
30145      * @param {number} n The index of the element to return.
30146      * @returns {*} Returns the nth element of `array`.
30147      */
30148     function baseNth(array, n) {
30149       var length = array.length;
30150       if (!length) {
30151         return;
30152       }
30153       n += n < 0 ? length : 0;
30154       return isIndex(n, length) ? array[n] : undefined;
30155     }
30156
30157     /**
30158      * The base implementation of `_.orderBy` without param guards.
30159      *
30160      * @private
30161      * @param {Array|Object} collection The collection to iterate over.
30162      * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
30163      * @param {string[]} orders The sort orders of `iteratees`.
30164      * @returns {Array} Returns the new sorted array.
30165      */
30166     function baseOrderBy(collection, iteratees, orders) {
30167       var index = -1;
30168       iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
30169
30170       var result = baseMap(collection, function(value, key, collection) {
30171         var criteria = arrayMap(iteratees, function(iteratee) {
30172           return iteratee(value);
30173         });
30174         return { 'criteria': criteria, 'index': ++index, 'value': value };
30175       });
30176
30177       return baseSortBy(result, function(object, other) {
30178         return compareMultiple(object, other, orders);
30179       });
30180     }
30181
30182     /**
30183      * The base implementation of `_.pick` without support for individual
30184      * property identifiers.
30185      *
30186      * @private
30187      * @param {Object} object The source object.
30188      * @param {string[]} paths The property paths to pick.
30189      * @returns {Object} Returns the new object.
30190      */
30191     function basePick(object, paths) {
30192       return basePickBy(object, paths, function(value, path) {
30193         return hasIn(object, path);
30194       });
30195     }
30196
30197     /**
30198      * The base implementation of  `_.pickBy` without support for iteratee shorthands.
30199      *
30200      * @private
30201      * @param {Object} object The source object.
30202      * @param {string[]} paths The property paths to pick.
30203      * @param {Function} predicate The function invoked per property.
30204      * @returns {Object} Returns the new object.
30205      */
30206     function basePickBy(object, paths, predicate) {
30207       var index = -1,
30208           length = paths.length,
30209           result = {};
30210
30211       while (++index < length) {
30212         var path = paths[index],
30213             value = baseGet(object, path);
30214
30215         if (predicate(value, path)) {
30216           baseSet(result, castPath(path, object), value);
30217         }
30218       }
30219       return result;
30220     }
30221
30222     /**
30223      * A specialized version of `baseProperty` which supports deep paths.
30224      *
30225      * @private
30226      * @param {Array|string} path The path of the property to get.
30227      * @returns {Function} Returns the new accessor function.
30228      */
30229     function basePropertyDeep(path) {
30230       return function(object) {
30231         return baseGet(object, path);
30232       };
30233     }
30234
30235     /**
30236      * The base implementation of `_.pullAllBy` without support for iteratee
30237      * shorthands.
30238      *
30239      * @private
30240      * @param {Array} array The array to modify.
30241      * @param {Array} values The values to remove.
30242      * @param {Function} [iteratee] The iteratee invoked per element.
30243      * @param {Function} [comparator] The comparator invoked per element.
30244      * @returns {Array} Returns `array`.
30245      */
30246     function basePullAll(array, values, iteratee, comparator) {
30247       var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
30248           index = -1,
30249           length = values.length,
30250           seen = array;
30251
30252       if (array === values) {
30253         values = copyArray(values);
30254       }
30255       if (iteratee) {
30256         seen = arrayMap(array, baseUnary(iteratee));
30257       }
30258       while (++index < length) {
30259         var fromIndex = 0,
30260             value = values[index],
30261             computed = iteratee ? iteratee(value) : value;
30262
30263         while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
30264           if (seen !== array) {
30265             splice.call(seen, fromIndex, 1);
30266           }
30267           splice.call(array, fromIndex, 1);
30268         }
30269       }
30270       return array;
30271     }
30272
30273     /**
30274      * The base implementation of `_.pullAt` without support for individual
30275      * indexes or capturing the removed elements.
30276      *
30277      * @private
30278      * @param {Array} array The array to modify.
30279      * @param {number[]} indexes The indexes of elements to remove.
30280      * @returns {Array} Returns `array`.
30281      */
30282     function basePullAt(array, indexes) {
30283       var length = array ? indexes.length : 0,
30284           lastIndex = length - 1;
30285
30286       while (length--) {
30287         var index = indexes[length];
30288         if (length == lastIndex || index !== previous) {
30289           var previous = index;
30290           if (isIndex(index)) {
30291             splice.call(array, index, 1);
30292           } else {
30293             baseUnset(array, index);
30294           }
30295         }
30296       }
30297       return array;
30298     }
30299
30300     /**
30301      * The base implementation of `_.random` without support for returning
30302      * floating-point numbers.
30303      *
30304      * @private
30305      * @param {number} lower The lower bound.
30306      * @param {number} upper The upper bound.
30307      * @returns {number} Returns the random number.
30308      */
30309     function baseRandom(lower, upper) {
30310       return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
30311     }
30312
30313     /**
30314      * The base implementation of `_.range` and `_.rangeRight` which doesn't
30315      * coerce arguments.
30316      *
30317      * @private
30318      * @param {number} start The start of the range.
30319      * @param {number} end The end of the range.
30320      * @param {number} step The value to increment or decrement by.
30321      * @param {boolean} [fromRight] Specify iterating from right to left.
30322      * @returns {Array} Returns the range of numbers.
30323      */
30324     function baseRange(start, end, step, fromRight) {
30325       var index = -1,
30326           length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
30327           result = Array(length);
30328
30329       while (length--) {
30330         result[fromRight ? length : ++index] = start;
30331         start += step;
30332       }
30333       return result;
30334     }
30335
30336     /**
30337      * The base implementation of `_.repeat` which doesn't coerce arguments.
30338      *
30339      * @private
30340      * @param {string} string The string to repeat.
30341      * @param {number} n The number of times to repeat the string.
30342      * @returns {string} Returns the repeated string.
30343      */
30344     function baseRepeat(string, n) {
30345       var result = '';
30346       if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
30347         return result;
30348       }
30349       // Leverage the exponentiation by squaring algorithm for a faster repeat.
30350       // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
30351       do {
30352         if (n % 2) {
30353           result += string;
30354         }
30355         n = nativeFloor(n / 2);
30356         if (n) {
30357           string += string;
30358         }
30359       } while (n);
30360
30361       return result;
30362     }
30363
30364     /**
30365      * The base implementation of `_.rest` which doesn't validate or coerce arguments.
30366      *
30367      * @private
30368      * @param {Function} func The function to apply a rest parameter to.
30369      * @param {number} [start=func.length-1] The start position of the rest parameter.
30370      * @returns {Function} Returns the new function.
30371      */
30372     function baseRest(func, start) {
30373       return setToString(overRest(func, start, identity), func + '');
30374     }
30375
30376     /**
30377      * The base implementation of `_.sample`.
30378      *
30379      * @private
30380      * @param {Array|Object} collection The collection to sample.
30381      * @returns {*} Returns the random element.
30382      */
30383     function baseSample(collection) {
30384       return arraySample(values(collection));
30385     }
30386
30387     /**
30388      * The base implementation of `_.sampleSize` without param guards.
30389      *
30390      * @private
30391      * @param {Array|Object} collection The collection to sample.
30392      * @param {number} n The number of elements to sample.
30393      * @returns {Array} Returns the random elements.
30394      */
30395     function baseSampleSize(collection, n) {
30396       var array = values(collection);
30397       return shuffleSelf(array, baseClamp(n, 0, array.length));
30398     }
30399
30400     /**
30401      * The base implementation of `_.set`.
30402      *
30403      * @private
30404      * @param {Object} object The object to modify.
30405      * @param {Array|string} path The path of the property to set.
30406      * @param {*} value The value to set.
30407      * @param {Function} [customizer] The function to customize path creation.
30408      * @returns {Object} Returns `object`.
30409      */
30410     function baseSet(object, path, value, customizer) {
30411       if (!isObject(object)) {
30412         return object;
30413       }
30414       path = castPath(path, object);
30415
30416       var index = -1,
30417           length = path.length,
30418           lastIndex = length - 1,
30419           nested = object;
30420
30421       while (nested != null && ++index < length) {
30422         var key = toKey(path[index]),
30423             newValue = value;
30424
30425         if (index != lastIndex) {
30426           var objValue = nested[key];
30427           newValue = customizer ? customizer(objValue, key, nested) : undefined;
30428           if (newValue === undefined) {
30429             newValue = isObject(objValue)
30430               ? objValue
30431               : (isIndex(path[index + 1]) ? [] : {});
30432           }
30433         }
30434         assignValue(nested, key, newValue);
30435         nested = nested[key];
30436       }
30437       return object;
30438     }
30439
30440     /**
30441      * The base implementation of `setData` without support for hot loop shorting.
30442      *
30443      * @private
30444      * @param {Function} func The function to associate metadata with.
30445      * @param {*} data The metadata.
30446      * @returns {Function} Returns `func`.
30447      */
30448     var baseSetData = !metaMap ? identity : function(func, data) {
30449       metaMap.set(func, data);
30450       return func;
30451     };
30452
30453     /**
30454      * The base implementation of `setToString` without support for hot loop shorting.
30455      *
30456      * @private
30457      * @param {Function} func The function to modify.
30458      * @param {Function} string The `toString` result.
30459      * @returns {Function} Returns `func`.
30460      */
30461     var baseSetToString = !defineProperty ? identity : function(func, string) {
30462       return defineProperty(func, 'toString', {
30463         'configurable': true,
30464         'enumerable': false,
30465         'value': constant(string),
30466         'writable': true
30467       });
30468     };
30469
30470     /**
30471      * The base implementation of `_.shuffle`.
30472      *
30473      * @private
30474      * @param {Array|Object} collection The collection to shuffle.
30475      * @returns {Array} Returns the new shuffled array.
30476      */
30477     function baseShuffle(collection) {
30478       return shuffleSelf(values(collection));
30479     }
30480
30481     /**
30482      * The base implementation of `_.slice` without an iteratee call guard.
30483      *
30484      * @private
30485      * @param {Array} array The array to slice.
30486      * @param {number} [start=0] The start position.
30487      * @param {number} [end=array.length] The end position.
30488      * @returns {Array} Returns the slice of `array`.
30489      */
30490     function baseSlice(array, start, end) {
30491       var index = -1,
30492           length = array.length;
30493
30494       if (start < 0) {
30495         start = -start > length ? 0 : (length + start);
30496       }
30497       end = end > length ? length : end;
30498       if (end < 0) {
30499         end += length;
30500       }
30501       length = start > end ? 0 : ((end - start) >>> 0);
30502       start >>>= 0;
30503
30504       var result = Array(length);
30505       while (++index < length) {
30506         result[index] = array[index + start];
30507       }
30508       return result;
30509     }
30510
30511     /**
30512      * The base implementation of `_.some` without support for iteratee shorthands.
30513      *
30514      * @private
30515      * @param {Array|Object} collection The collection to iterate over.
30516      * @param {Function} predicate The function invoked per iteration.
30517      * @returns {boolean} Returns `true` if any element passes the predicate check,
30518      *  else `false`.
30519      */
30520     function baseSome(collection, predicate) {
30521       var result;
30522
30523       baseEach(collection, function(value, index, collection) {
30524         result = predicate(value, index, collection);
30525         return !result;
30526       });
30527       return !!result;
30528     }
30529
30530     /**
30531      * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
30532      * performs a binary search of `array` to determine the index at which `value`
30533      * should be inserted into `array` in order to maintain its sort order.
30534      *
30535      * @private
30536      * @param {Array} array The sorted array to inspect.
30537      * @param {*} value The value to evaluate.
30538      * @param {boolean} [retHighest] Specify returning the highest qualified index.
30539      * @returns {number} Returns the index at which `value` should be inserted
30540      *  into `array`.
30541      */
30542     function baseSortedIndex(array, value, retHighest) {
30543       var low = 0,
30544           high = array == null ? low : array.length;
30545
30546       if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
30547         while (low < high) {
30548           var mid = (low + high) >>> 1,
30549               computed = array[mid];
30550
30551           if (computed !== null && !isSymbol(computed) &&
30552               (retHighest ? (computed <= value) : (computed < value))) {
30553             low = mid + 1;
30554           } else {
30555             high = mid;
30556           }
30557         }
30558         return high;
30559       }
30560       return baseSortedIndexBy(array, value, identity, retHighest);
30561     }
30562
30563     /**
30564      * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
30565      * which invokes `iteratee` for `value` and each element of `array` to compute
30566      * their sort ranking. The iteratee is invoked with one argument; (value).
30567      *
30568      * @private
30569      * @param {Array} array The sorted array to inspect.
30570      * @param {*} value The value to evaluate.
30571      * @param {Function} iteratee The iteratee invoked per element.
30572      * @param {boolean} [retHighest] Specify returning the highest qualified index.
30573      * @returns {number} Returns the index at which `value` should be inserted
30574      *  into `array`.
30575      */
30576     function baseSortedIndexBy(array, value, iteratee, retHighest) {
30577       value = iteratee(value);
30578
30579       var low = 0,
30580           high = array == null ? 0 : array.length,
30581           valIsNaN = value !== value,
30582           valIsNull = value === null,
30583           valIsSymbol = isSymbol(value),
30584           valIsUndefined = value === undefined;
30585
30586       while (low < high) {
30587         var mid = nativeFloor((low + high) / 2),
30588             computed = iteratee(array[mid]),
30589             othIsDefined = computed !== undefined,
30590             othIsNull = computed === null,
30591             othIsReflexive = computed === computed,
30592             othIsSymbol = isSymbol(computed);
30593
30594         if (valIsNaN) {
30595           var setLow = retHighest || othIsReflexive;
30596         } else if (valIsUndefined) {
30597           setLow = othIsReflexive && (retHighest || othIsDefined);
30598         } else if (valIsNull) {
30599           setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
30600         } else if (valIsSymbol) {
30601           setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
30602         } else if (othIsNull || othIsSymbol) {
30603           setLow = false;
30604         } else {
30605           setLow = retHighest ? (computed <= value) : (computed < value);
30606         }
30607         if (setLow) {
30608           low = mid + 1;
30609         } else {
30610           high = mid;
30611         }
30612       }
30613       return nativeMin(high, MAX_ARRAY_INDEX);
30614     }
30615
30616     /**
30617      * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
30618      * support for iteratee shorthands.
30619      *
30620      * @private
30621      * @param {Array} array The array to inspect.
30622      * @param {Function} [iteratee] The iteratee invoked per element.
30623      * @returns {Array} Returns the new duplicate free array.
30624      */
30625     function baseSortedUniq(array, iteratee) {
30626       var index = -1,
30627           length = array.length,
30628           resIndex = 0,
30629           result = [];
30630
30631       while (++index < length) {
30632         var value = array[index],
30633             computed = iteratee ? iteratee(value) : value;
30634
30635         if (!index || !eq(computed, seen)) {
30636           var seen = computed;
30637           result[resIndex++] = value === 0 ? 0 : value;
30638         }
30639       }
30640       return result;
30641     }
30642
30643     /**
30644      * The base implementation of `_.toNumber` which doesn't ensure correct
30645      * conversions of binary, hexadecimal, or octal string values.
30646      *
30647      * @private
30648      * @param {*} value The value to process.
30649      * @returns {number} Returns the number.
30650      */
30651     function baseToNumber(value) {
30652       if (typeof value == 'number') {
30653         return value;
30654       }
30655       if (isSymbol(value)) {
30656         return NAN;
30657       }
30658       return +value;
30659     }
30660
30661     /**
30662      * The base implementation of `_.toString` which doesn't convert nullish
30663      * values to empty strings.
30664      *
30665      * @private
30666      * @param {*} value The value to process.
30667      * @returns {string} Returns the string.
30668      */
30669     function baseToString(value) {
30670       // Exit early for strings to avoid a performance hit in some environments.
30671       if (typeof value == 'string') {
30672         return value;
30673       }
30674       if (isArray(value)) {
30675         // Recursively convert values (susceptible to call stack limits).
30676         return arrayMap(value, baseToString) + '';
30677       }
30678       if (isSymbol(value)) {
30679         return symbolToString ? symbolToString.call(value) : '';
30680       }
30681       var result = (value + '');
30682       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
30683     }
30684
30685     /**
30686      * The base implementation of `_.uniqBy` without support for iteratee shorthands.
30687      *
30688      * @private
30689      * @param {Array} array The array to inspect.
30690      * @param {Function} [iteratee] The iteratee invoked per element.
30691      * @param {Function} [comparator] The comparator invoked per element.
30692      * @returns {Array} Returns the new duplicate free array.
30693      */
30694     function baseUniq(array, iteratee, comparator) {
30695       var index = -1,
30696           includes = arrayIncludes,
30697           length = array.length,
30698           isCommon = true,
30699           result = [],
30700           seen = result;
30701
30702       if (comparator) {
30703         isCommon = false;
30704         includes = arrayIncludesWith;
30705       }
30706       else if (length >= LARGE_ARRAY_SIZE) {
30707         var set = iteratee ? null : createSet(array);
30708         if (set) {
30709           return setToArray(set);
30710         }
30711         isCommon = false;
30712         includes = cacheHas;
30713         seen = new SetCache;
30714       }
30715       else {
30716         seen = iteratee ? [] : result;
30717       }
30718       outer:
30719       while (++index < length) {
30720         var value = array[index],
30721             computed = iteratee ? iteratee(value) : value;
30722
30723         value = (comparator || value !== 0) ? value : 0;
30724         if (isCommon && computed === computed) {
30725           var seenIndex = seen.length;
30726           while (seenIndex--) {
30727             if (seen[seenIndex] === computed) {
30728               continue outer;
30729             }
30730           }
30731           if (iteratee) {
30732             seen.push(computed);
30733           }
30734           result.push(value);
30735         }
30736         else if (!includes(seen, computed, comparator)) {
30737           if (seen !== result) {
30738             seen.push(computed);
30739           }
30740           result.push(value);
30741         }
30742       }
30743       return result;
30744     }
30745
30746     /**
30747      * The base implementation of `_.unset`.
30748      *
30749      * @private
30750      * @param {Object} object The object to modify.
30751      * @param {Array|string} path The property path to unset.
30752      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
30753      */
30754     function baseUnset(object, path) {
30755       path = castPath(path, object);
30756       object = parent(object, path);
30757       return object == null || delete object[toKey(last(path))];
30758     }
30759
30760     /**
30761      * The base implementation of `_.update`.
30762      *
30763      * @private
30764      * @param {Object} object The object to modify.
30765      * @param {Array|string} path The path of the property to update.
30766      * @param {Function} updater The function to produce the updated value.
30767      * @param {Function} [customizer] The function to customize path creation.
30768      * @returns {Object} Returns `object`.
30769      */
30770     function baseUpdate(object, path, updater, customizer) {
30771       return baseSet(object, path, updater(baseGet(object, path)), customizer);
30772     }
30773
30774     /**
30775      * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
30776      * without support for iteratee shorthands.
30777      *
30778      * @private
30779      * @param {Array} array The array to query.
30780      * @param {Function} predicate The function invoked per iteration.
30781      * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
30782      * @param {boolean} [fromRight] Specify iterating from right to left.
30783      * @returns {Array} Returns the slice of `array`.
30784      */
30785     function baseWhile(array, predicate, isDrop, fromRight) {
30786       var length = array.length,
30787           index = fromRight ? length : -1;
30788
30789       while ((fromRight ? index-- : ++index < length) &&
30790         predicate(array[index], index, array)) {}
30791
30792       return isDrop
30793         ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
30794         : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
30795     }
30796
30797     /**
30798      * The base implementation of `wrapperValue` which returns the result of
30799      * performing a sequence of actions on the unwrapped `value`, where each
30800      * successive action is supplied the return value of the previous.
30801      *
30802      * @private
30803      * @param {*} value The unwrapped value.
30804      * @param {Array} actions Actions to perform to resolve the unwrapped value.
30805      * @returns {*} Returns the resolved value.
30806      */
30807     function baseWrapperValue(value, actions) {
30808       var result = value;
30809       if (result instanceof LazyWrapper) {
30810         result = result.value();
30811       }
30812       return arrayReduce(actions, function(result, action) {
30813         return action.func.apply(action.thisArg, arrayPush([result], action.args));
30814       }, result);
30815     }
30816
30817     /**
30818      * The base implementation of methods like `_.xor`, without support for
30819      * iteratee shorthands, that accepts an array of arrays to inspect.
30820      *
30821      * @private
30822      * @param {Array} arrays The arrays to inspect.
30823      * @param {Function} [iteratee] The iteratee invoked per element.
30824      * @param {Function} [comparator] The comparator invoked per element.
30825      * @returns {Array} Returns the new array of values.
30826      */
30827     function baseXor(arrays, iteratee, comparator) {
30828       var length = arrays.length;
30829       if (length < 2) {
30830         return length ? baseUniq(arrays[0]) : [];
30831       }
30832       var index = -1,
30833           result = Array(length);
30834
30835       while (++index < length) {
30836         var array = arrays[index],
30837             othIndex = -1;
30838
30839         while (++othIndex < length) {
30840           if (othIndex != index) {
30841             result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
30842           }
30843         }
30844       }
30845       return baseUniq(baseFlatten(result, 1), iteratee, comparator);
30846     }
30847
30848     /**
30849      * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
30850      *
30851      * @private
30852      * @param {Array} props The property identifiers.
30853      * @param {Array} values The property values.
30854      * @param {Function} assignFunc The function to assign values.
30855      * @returns {Object} Returns the new object.
30856      */
30857     function baseZipObject(props, values, assignFunc) {
30858       var index = -1,
30859           length = props.length,
30860           valsLength = values.length,
30861           result = {};
30862
30863       while (++index < length) {
30864         var value = index < valsLength ? values[index] : undefined;
30865         assignFunc(result, props[index], value);
30866       }
30867       return result;
30868     }
30869
30870     /**
30871      * Casts `value` to an empty array if it's not an array like object.
30872      *
30873      * @private
30874      * @param {*} value The value to inspect.
30875      * @returns {Array|Object} Returns the cast array-like object.
30876      */
30877     function castArrayLikeObject(value) {
30878       return isArrayLikeObject(value) ? value : [];
30879     }
30880
30881     /**
30882      * Casts `value` to `identity` if it's not a function.
30883      *
30884      * @private
30885      * @param {*} value The value to inspect.
30886      * @returns {Function} Returns cast function.
30887      */
30888     function castFunction(value) {
30889       return typeof value == 'function' ? value : identity;
30890     }
30891
30892     /**
30893      * Casts `value` to a path array if it's not one.
30894      *
30895      * @private
30896      * @param {*} value The value to inspect.
30897      * @param {Object} [object] The object to query keys on.
30898      * @returns {Array} Returns the cast property path array.
30899      */
30900     function castPath(value, object) {
30901       if (isArray(value)) {
30902         return value;
30903       }
30904       return isKey(value, object) ? [value] : stringToPath(toString(value));
30905     }
30906
30907     /**
30908      * A `baseRest` alias which can be replaced with `identity` by module
30909      * replacement plugins.
30910      *
30911      * @private
30912      * @type {Function}
30913      * @param {Function} func The function to apply a rest parameter to.
30914      * @returns {Function} Returns the new function.
30915      */
30916     var castRest = baseRest;
30917
30918     /**
30919      * Casts `array` to a slice if it's needed.
30920      *
30921      * @private
30922      * @param {Array} array The array to inspect.
30923      * @param {number} start The start position.
30924      * @param {number} [end=array.length] The end position.
30925      * @returns {Array} Returns the cast slice.
30926      */
30927     function castSlice(array, start, end) {
30928       var length = array.length;
30929       end = end === undefined ? length : end;
30930       return (!start && end >= length) ? array : baseSlice(array, start, end);
30931     }
30932
30933     /**
30934      * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
30935      *
30936      * @private
30937      * @param {number|Object} id The timer id or timeout object of the timer to clear.
30938      */
30939     var clearTimeout = ctxClearTimeout || function(id) {
30940       return root.clearTimeout(id);
30941     };
30942
30943     /**
30944      * Creates a clone of  `buffer`.
30945      *
30946      * @private
30947      * @param {Buffer} buffer The buffer to clone.
30948      * @param {boolean} [isDeep] Specify a deep clone.
30949      * @returns {Buffer} Returns the cloned buffer.
30950      */
30951     function cloneBuffer(buffer, isDeep) {
30952       if (isDeep) {
30953         return buffer.slice();
30954       }
30955       var length = buffer.length,
30956           result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
30957
30958       buffer.copy(result);
30959       return result;
30960     }
30961
30962     /**
30963      * Creates a clone of `arrayBuffer`.
30964      *
30965      * @private
30966      * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
30967      * @returns {ArrayBuffer} Returns the cloned array buffer.
30968      */
30969     function cloneArrayBuffer(arrayBuffer) {
30970       var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
30971       new Uint8Array(result).set(new Uint8Array(arrayBuffer));
30972       return result;
30973     }
30974
30975     /**
30976      * Creates a clone of `dataView`.
30977      *
30978      * @private
30979      * @param {Object} dataView The data view to clone.
30980      * @param {boolean} [isDeep] Specify a deep clone.
30981      * @returns {Object} Returns the cloned data view.
30982      */
30983     function cloneDataView(dataView, isDeep) {
30984       var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
30985       return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
30986     }
30987
30988     /**
30989      * Creates a clone of `regexp`.
30990      *
30991      * @private
30992      * @param {Object} regexp The regexp to clone.
30993      * @returns {Object} Returns the cloned regexp.
30994      */
30995     function cloneRegExp(regexp) {
30996       var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
30997       result.lastIndex = regexp.lastIndex;
30998       return result;
30999     }
31000
31001     /**
31002      * Creates a clone of the `symbol` object.
31003      *
31004      * @private
31005      * @param {Object} symbol The symbol object to clone.
31006      * @returns {Object} Returns the cloned symbol object.
31007      */
31008     function cloneSymbol(symbol) {
31009       return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
31010     }
31011
31012     /**
31013      * Creates a clone of `typedArray`.
31014      *
31015      * @private
31016      * @param {Object} typedArray The typed array to clone.
31017      * @param {boolean} [isDeep] Specify a deep clone.
31018      * @returns {Object} Returns the cloned typed array.
31019      */
31020     function cloneTypedArray(typedArray, isDeep) {
31021       var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
31022       return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
31023     }
31024
31025     /**
31026      * Compares values to sort them in ascending order.
31027      *
31028      * @private
31029      * @param {*} value The value to compare.
31030      * @param {*} other The other value to compare.
31031      * @returns {number} Returns the sort order indicator for `value`.
31032      */
31033     function compareAscending(value, other) {
31034       if (value !== other) {
31035         var valIsDefined = value !== undefined,
31036             valIsNull = value === null,
31037             valIsReflexive = value === value,
31038             valIsSymbol = isSymbol(value);
31039
31040         var othIsDefined = other !== undefined,
31041             othIsNull = other === null,
31042             othIsReflexive = other === other,
31043             othIsSymbol = isSymbol(other);
31044
31045         if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
31046             (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
31047             (valIsNull && othIsDefined && othIsReflexive) ||
31048             (!valIsDefined && othIsReflexive) ||
31049             !valIsReflexive) {
31050           return 1;
31051         }
31052         if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
31053             (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
31054             (othIsNull && valIsDefined && valIsReflexive) ||
31055             (!othIsDefined && valIsReflexive) ||
31056             !othIsReflexive) {
31057           return -1;
31058         }
31059       }
31060       return 0;
31061     }
31062
31063     /**
31064      * Used by `_.orderBy` to compare multiple properties of a value to another
31065      * and stable sort them.
31066      *
31067      * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
31068      * specify an order of "desc" for descending or "asc" for ascending sort order
31069      * of corresponding values.
31070      *
31071      * @private
31072      * @param {Object} object The object to compare.
31073      * @param {Object} other The other object to compare.
31074      * @param {boolean[]|string[]} orders The order to sort by for each property.
31075      * @returns {number} Returns the sort order indicator for `object`.
31076      */
31077     function compareMultiple(object, other, orders) {
31078       var index = -1,
31079           objCriteria = object.criteria,
31080           othCriteria = other.criteria,
31081           length = objCriteria.length,
31082           ordersLength = orders.length;
31083
31084       while (++index < length) {
31085         var result = compareAscending(objCriteria[index], othCriteria[index]);
31086         if (result) {
31087           if (index >= ordersLength) {
31088             return result;
31089           }
31090           var order = orders[index];
31091           return result * (order == 'desc' ? -1 : 1);
31092         }
31093       }
31094       // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
31095       // that causes it, under certain circumstances, to provide the same value for
31096       // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
31097       // for more details.
31098       //
31099       // This also ensures a stable sort in V8 and other engines.
31100       // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
31101       return object.index - other.index;
31102     }
31103
31104     /**
31105      * Creates an array that is the composition of partially applied arguments,
31106      * placeholders, and provided arguments into a single array of arguments.
31107      *
31108      * @private
31109      * @param {Array} args The provided arguments.
31110      * @param {Array} partials The arguments to prepend to those provided.
31111      * @param {Array} holders The `partials` placeholder indexes.
31112      * @params {boolean} [isCurried] Specify composing for a curried function.
31113      * @returns {Array} Returns the new array of composed arguments.
31114      */
31115     function composeArgs(args, partials, holders, isCurried) {
31116       var argsIndex = -1,
31117           argsLength = args.length,
31118           holdersLength = holders.length,
31119           leftIndex = -1,
31120           leftLength = partials.length,
31121           rangeLength = nativeMax(argsLength - holdersLength, 0),
31122           result = Array(leftLength + rangeLength),
31123           isUncurried = !isCurried;
31124
31125       while (++leftIndex < leftLength) {
31126         result[leftIndex] = partials[leftIndex];
31127       }
31128       while (++argsIndex < holdersLength) {
31129         if (isUncurried || argsIndex < argsLength) {
31130           result[holders[argsIndex]] = args[argsIndex];
31131         }
31132       }
31133       while (rangeLength--) {
31134         result[leftIndex++] = args[argsIndex++];
31135       }
31136       return result;
31137     }
31138
31139     /**
31140      * This function is like `composeArgs` except that the arguments composition
31141      * is tailored for `_.partialRight`.
31142      *
31143      * @private
31144      * @param {Array} args The provided arguments.
31145      * @param {Array} partials The arguments to append to those provided.
31146      * @param {Array} holders The `partials` placeholder indexes.
31147      * @params {boolean} [isCurried] Specify composing for a curried function.
31148      * @returns {Array} Returns the new array of composed arguments.
31149      */
31150     function composeArgsRight(args, partials, holders, isCurried) {
31151       var argsIndex = -1,
31152           argsLength = args.length,
31153           holdersIndex = -1,
31154           holdersLength = holders.length,
31155           rightIndex = -1,
31156           rightLength = partials.length,
31157           rangeLength = nativeMax(argsLength - holdersLength, 0),
31158           result = Array(rangeLength + rightLength),
31159           isUncurried = !isCurried;
31160
31161       while (++argsIndex < rangeLength) {
31162         result[argsIndex] = args[argsIndex];
31163       }
31164       var offset = argsIndex;
31165       while (++rightIndex < rightLength) {
31166         result[offset + rightIndex] = partials[rightIndex];
31167       }
31168       while (++holdersIndex < holdersLength) {
31169         if (isUncurried || argsIndex < argsLength) {
31170           result[offset + holders[holdersIndex]] = args[argsIndex++];
31171         }
31172       }
31173       return result;
31174     }
31175
31176     /**
31177      * Copies the values of `source` to `array`.
31178      *
31179      * @private
31180      * @param {Array} source The array to copy values from.
31181      * @param {Array} [array=[]] The array to copy values to.
31182      * @returns {Array} Returns `array`.
31183      */
31184     function copyArray(source, array) {
31185       var index = -1,
31186           length = source.length;
31187
31188       array || (array = Array(length));
31189       while (++index < length) {
31190         array[index] = source[index];
31191       }
31192       return array;
31193     }
31194
31195     /**
31196      * Copies properties of `source` to `object`.
31197      *
31198      * @private
31199      * @param {Object} source The object to copy properties from.
31200      * @param {Array} props The property identifiers to copy.
31201      * @param {Object} [object={}] The object to copy properties to.
31202      * @param {Function} [customizer] The function to customize copied values.
31203      * @returns {Object} Returns `object`.
31204      */
31205     function copyObject(source, props, object, customizer) {
31206       var isNew = !object;
31207       object || (object = {});
31208
31209       var index = -1,
31210           length = props.length;
31211
31212       while (++index < length) {
31213         var key = props[index];
31214
31215         var newValue = customizer
31216           ? customizer(object[key], source[key], key, object, source)
31217           : undefined;
31218
31219         if (newValue === undefined) {
31220           newValue = source[key];
31221         }
31222         if (isNew) {
31223           baseAssignValue(object, key, newValue);
31224         } else {
31225           assignValue(object, key, newValue);
31226         }
31227       }
31228       return object;
31229     }
31230
31231     /**
31232      * Copies own symbols of `source` to `object`.
31233      *
31234      * @private
31235      * @param {Object} source The object to copy symbols from.
31236      * @param {Object} [object={}] The object to copy symbols to.
31237      * @returns {Object} Returns `object`.
31238      */
31239     function copySymbols(source, object) {
31240       return copyObject(source, getSymbols(source), object);
31241     }
31242
31243     /**
31244      * Copies own and inherited symbols of `source` to `object`.
31245      *
31246      * @private
31247      * @param {Object} source The object to copy symbols from.
31248      * @param {Object} [object={}] The object to copy symbols to.
31249      * @returns {Object} Returns `object`.
31250      */
31251     function copySymbolsIn(source, object) {
31252       return copyObject(source, getSymbolsIn(source), object);
31253     }
31254
31255     /**
31256      * Creates a function like `_.groupBy`.
31257      *
31258      * @private
31259      * @param {Function} setter The function to set accumulator values.
31260      * @param {Function} [initializer] The accumulator object initializer.
31261      * @returns {Function} Returns the new aggregator function.
31262      */
31263     function createAggregator(setter, initializer) {
31264       return function(collection, iteratee) {
31265         var func = isArray(collection) ? arrayAggregator : baseAggregator,
31266             accumulator = initializer ? initializer() : {};
31267
31268         return func(collection, setter, getIteratee(iteratee, 2), accumulator);
31269       };
31270     }
31271
31272     /**
31273      * Creates a function like `_.assign`.
31274      *
31275      * @private
31276      * @param {Function} assigner The function to assign values.
31277      * @returns {Function} Returns the new assigner function.
31278      */
31279     function createAssigner(assigner) {
31280       return baseRest(function(object, sources) {
31281         var index = -1,
31282             length = sources.length,
31283             customizer = length > 1 ? sources[length - 1] : undefined,
31284             guard = length > 2 ? sources[2] : undefined;
31285
31286         customizer = (assigner.length > 3 && typeof customizer == 'function')
31287           ? (length--, customizer)
31288           : undefined;
31289
31290         if (guard && isIterateeCall(sources[0], sources[1], guard)) {
31291           customizer = length < 3 ? undefined : customizer;
31292           length = 1;
31293         }
31294         object = Object(object);
31295         while (++index < length) {
31296           var source = sources[index];
31297           if (source) {
31298             assigner(object, source, index, customizer);
31299           }
31300         }
31301         return object;
31302       });
31303     }
31304
31305     /**
31306      * Creates a `baseEach` or `baseEachRight` function.
31307      *
31308      * @private
31309      * @param {Function} eachFunc The function to iterate over a collection.
31310      * @param {boolean} [fromRight] Specify iterating from right to left.
31311      * @returns {Function} Returns the new base function.
31312      */
31313     function createBaseEach(eachFunc, fromRight) {
31314       return function(collection, iteratee) {
31315         if (collection == null) {
31316           return collection;
31317         }
31318         if (!isArrayLike(collection)) {
31319           return eachFunc(collection, iteratee);
31320         }
31321         var length = collection.length,
31322             index = fromRight ? length : -1,
31323             iterable = Object(collection);
31324
31325         while ((fromRight ? index-- : ++index < length)) {
31326           if (iteratee(iterable[index], index, iterable) === false) {
31327             break;
31328           }
31329         }
31330         return collection;
31331       };
31332     }
31333
31334     /**
31335      * Creates a base function for methods like `_.forIn` and `_.forOwn`.
31336      *
31337      * @private
31338      * @param {boolean} [fromRight] Specify iterating from right to left.
31339      * @returns {Function} Returns the new base function.
31340      */
31341     function createBaseFor(fromRight) {
31342       return function(object, iteratee, keysFunc) {
31343         var index = -1,
31344             iterable = Object(object),
31345             props = keysFunc(object),
31346             length = props.length;
31347
31348         while (length--) {
31349           var key = props[fromRight ? length : ++index];
31350           if (iteratee(iterable[key], key, iterable) === false) {
31351             break;
31352           }
31353         }
31354         return object;
31355       };
31356     }
31357
31358     /**
31359      * Creates a function that wraps `func` to invoke it with the optional `this`
31360      * binding of `thisArg`.
31361      *
31362      * @private
31363      * @param {Function} func The function to wrap.
31364      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31365      * @param {*} [thisArg] The `this` binding of `func`.
31366      * @returns {Function} Returns the new wrapped function.
31367      */
31368     function createBind(func, bitmask, thisArg) {
31369       var isBind = bitmask & WRAP_BIND_FLAG,
31370           Ctor = createCtor(func);
31371
31372       function wrapper() {
31373         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
31374         return fn.apply(isBind ? thisArg : this, arguments);
31375       }
31376       return wrapper;
31377     }
31378
31379     /**
31380      * Creates a function like `_.lowerFirst`.
31381      *
31382      * @private
31383      * @param {string} methodName The name of the `String` case method to use.
31384      * @returns {Function} Returns the new case function.
31385      */
31386     function createCaseFirst(methodName) {
31387       return function(string) {
31388         string = toString(string);
31389
31390         var strSymbols = hasUnicode(string)
31391           ? stringToArray(string)
31392           : undefined;
31393
31394         var chr = strSymbols
31395           ? strSymbols[0]
31396           : string.charAt(0);
31397
31398         var trailing = strSymbols
31399           ? castSlice(strSymbols, 1).join('')
31400           : string.slice(1);
31401
31402         return chr[methodName]() + trailing;
31403       };
31404     }
31405
31406     /**
31407      * Creates a function like `_.camelCase`.
31408      *
31409      * @private
31410      * @param {Function} callback The function to combine each word.
31411      * @returns {Function} Returns the new compounder function.
31412      */
31413     function createCompounder(callback) {
31414       return function(string) {
31415         return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
31416       };
31417     }
31418
31419     /**
31420      * Creates a function that produces an instance of `Ctor` regardless of
31421      * whether it was invoked as part of a `new` expression or by `call` or `apply`.
31422      *
31423      * @private
31424      * @param {Function} Ctor The constructor to wrap.
31425      * @returns {Function} Returns the new wrapped function.
31426      */
31427     function createCtor(Ctor) {
31428       return function() {
31429         // Use a `switch` statement to work with class constructors. See
31430         // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
31431         // for more details.
31432         var args = arguments;
31433         switch (args.length) {
31434           case 0: return new Ctor;
31435           case 1: return new Ctor(args[0]);
31436           case 2: return new Ctor(args[0], args[1]);
31437           case 3: return new Ctor(args[0], args[1], args[2]);
31438           case 4: return new Ctor(args[0], args[1], args[2], args[3]);
31439           case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
31440           case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
31441           case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
31442         }
31443         var thisBinding = baseCreate(Ctor.prototype),
31444             result = Ctor.apply(thisBinding, args);
31445
31446         // Mimic the constructor's `return` behavior.
31447         // See https://es5.github.io/#x13.2.2 for more details.
31448         return isObject(result) ? result : thisBinding;
31449       };
31450     }
31451
31452     /**
31453      * Creates a function that wraps `func` to enable currying.
31454      *
31455      * @private
31456      * @param {Function} func The function to wrap.
31457      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31458      * @param {number} arity The arity of `func`.
31459      * @returns {Function} Returns the new wrapped function.
31460      */
31461     function createCurry(func, bitmask, arity) {
31462       var Ctor = createCtor(func);
31463
31464       function wrapper() {
31465         var length = arguments.length,
31466             args = Array(length),
31467             index = length,
31468             placeholder = getHolder(wrapper);
31469
31470         while (index--) {
31471           args[index] = arguments[index];
31472         }
31473         var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
31474           ? []
31475           : replaceHolders(args, placeholder);
31476
31477         length -= holders.length;
31478         if (length < arity) {
31479           return createRecurry(
31480             func, bitmask, createHybrid, wrapper.placeholder, undefined,
31481             args, holders, undefined, undefined, arity - length);
31482         }
31483         var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
31484         return apply(fn, this, args);
31485       }
31486       return wrapper;
31487     }
31488
31489     /**
31490      * Creates a `_.find` or `_.findLast` function.
31491      *
31492      * @private
31493      * @param {Function} findIndexFunc The function to find the collection index.
31494      * @returns {Function} Returns the new find function.
31495      */
31496     function createFind(findIndexFunc) {
31497       return function(collection, predicate, fromIndex) {
31498         var iterable = Object(collection);
31499         if (!isArrayLike(collection)) {
31500           var iteratee = getIteratee(predicate, 3);
31501           collection = keys(collection);
31502           predicate = function(key) { return iteratee(iterable[key], key, iterable); };
31503         }
31504         var index = findIndexFunc(collection, predicate, fromIndex);
31505         return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
31506       };
31507     }
31508
31509     /**
31510      * Creates a `_.flow` or `_.flowRight` function.
31511      *
31512      * @private
31513      * @param {boolean} [fromRight] Specify iterating from right to left.
31514      * @returns {Function} Returns the new flow function.
31515      */
31516     function createFlow(fromRight) {
31517       return flatRest(function(funcs) {
31518         var length = funcs.length,
31519             index = length,
31520             prereq = LodashWrapper.prototype.thru;
31521
31522         if (fromRight) {
31523           funcs.reverse();
31524         }
31525         while (index--) {
31526           var func = funcs[index];
31527           if (typeof func != 'function') {
31528             throw new TypeError(FUNC_ERROR_TEXT);
31529           }
31530           if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
31531             var wrapper = new LodashWrapper([], true);
31532           }
31533         }
31534         index = wrapper ? index : length;
31535         while (++index < length) {
31536           func = funcs[index];
31537
31538           var funcName = getFuncName(func),
31539               data = funcName == 'wrapper' ? getData(func) : undefined;
31540
31541           if (data && isLaziable(data[0]) &&
31542                 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
31543                 !data[4].length && data[9] == 1
31544               ) {
31545             wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
31546           } else {
31547             wrapper = (func.length == 1 && isLaziable(func))
31548               ? wrapper[funcName]()
31549               : wrapper.thru(func);
31550           }
31551         }
31552         return function() {
31553           var args = arguments,
31554               value = args[0];
31555
31556           if (wrapper && args.length == 1 && isArray(value)) {
31557             return wrapper.plant(value).value();
31558           }
31559           var index = 0,
31560               result = length ? funcs[index].apply(this, args) : value;
31561
31562           while (++index < length) {
31563             result = funcs[index].call(this, result);
31564           }
31565           return result;
31566         };
31567       });
31568     }
31569
31570     /**
31571      * Creates a function that wraps `func` to invoke it with optional `this`
31572      * binding of `thisArg`, partial application, and currying.
31573      *
31574      * @private
31575      * @param {Function|string} func The function or method name to wrap.
31576      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31577      * @param {*} [thisArg] The `this` binding of `func`.
31578      * @param {Array} [partials] The arguments to prepend to those provided to
31579      *  the new function.
31580      * @param {Array} [holders] The `partials` placeholder indexes.
31581      * @param {Array} [partialsRight] The arguments to append to those provided
31582      *  to the new function.
31583      * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
31584      * @param {Array} [argPos] The argument positions of the new function.
31585      * @param {number} [ary] The arity cap of `func`.
31586      * @param {number} [arity] The arity of `func`.
31587      * @returns {Function} Returns the new wrapped function.
31588      */
31589     function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
31590       var isAry = bitmask & WRAP_ARY_FLAG,
31591           isBind = bitmask & WRAP_BIND_FLAG,
31592           isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
31593           isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
31594           isFlip = bitmask & WRAP_FLIP_FLAG,
31595           Ctor = isBindKey ? undefined : createCtor(func);
31596
31597       function wrapper() {
31598         var length = arguments.length,
31599             args = Array(length),
31600             index = length;
31601
31602         while (index--) {
31603           args[index] = arguments[index];
31604         }
31605         if (isCurried) {
31606           var placeholder = getHolder(wrapper),
31607               holdersCount = countHolders(args, placeholder);
31608         }
31609         if (partials) {
31610           args = composeArgs(args, partials, holders, isCurried);
31611         }
31612         if (partialsRight) {
31613           args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
31614         }
31615         length -= holdersCount;
31616         if (isCurried && length < arity) {
31617           var newHolders = replaceHolders(args, placeholder);
31618           return createRecurry(
31619             func, bitmask, createHybrid, wrapper.placeholder, thisArg,
31620             args, newHolders, argPos, ary, arity - length
31621           );
31622         }
31623         var thisBinding = isBind ? thisArg : this,
31624             fn = isBindKey ? thisBinding[func] : func;
31625
31626         length = args.length;
31627         if (argPos) {
31628           args = reorder(args, argPos);
31629         } else if (isFlip && length > 1) {
31630           args.reverse();
31631         }
31632         if (isAry && ary < length) {
31633           args.length = ary;
31634         }
31635         if (this && this !== root && this instanceof wrapper) {
31636           fn = Ctor || createCtor(fn);
31637         }
31638         return fn.apply(thisBinding, args);
31639       }
31640       return wrapper;
31641     }
31642
31643     /**
31644      * Creates a function like `_.invertBy`.
31645      *
31646      * @private
31647      * @param {Function} setter The function to set accumulator values.
31648      * @param {Function} toIteratee The function to resolve iteratees.
31649      * @returns {Function} Returns the new inverter function.
31650      */
31651     function createInverter(setter, toIteratee) {
31652       return function(object, iteratee) {
31653         return baseInverter(object, setter, toIteratee(iteratee), {});
31654       };
31655     }
31656
31657     /**
31658      * Creates a function that performs a mathematical operation on two values.
31659      *
31660      * @private
31661      * @param {Function} operator The function to perform the operation.
31662      * @param {number} [defaultValue] The value used for `undefined` arguments.
31663      * @returns {Function} Returns the new mathematical operation function.
31664      */
31665     function createMathOperation(operator, defaultValue) {
31666       return function(value, other) {
31667         var result;
31668         if (value === undefined && other === undefined) {
31669           return defaultValue;
31670         }
31671         if (value !== undefined) {
31672           result = value;
31673         }
31674         if (other !== undefined) {
31675           if (result === undefined) {
31676             return other;
31677           }
31678           if (typeof value == 'string' || typeof other == 'string') {
31679             value = baseToString(value);
31680             other = baseToString(other);
31681           } else {
31682             value = baseToNumber(value);
31683             other = baseToNumber(other);
31684           }
31685           result = operator(value, other);
31686         }
31687         return result;
31688       };
31689     }
31690
31691     /**
31692      * Creates a function like `_.over`.
31693      *
31694      * @private
31695      * @param {Function} arrayFunc The function to iterate over iteratees.
31696      * @returns {Function} Returns the new over function.
31697      */
31698     function createOver(arrayFunc) {
31699       return flatRest(function(iteratees) {
31700         iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
31701         return baseRest(function(args) {
31702           var thisArg = this;
31703           return arrayFunc(iteratees, function(iteratee) {
31704             return apply(iteratee, thisArg, args);
31705           });
31706         });
31707       });
31708     }
31709
31710     /**
31711      * Creates the padding for `string` based on `length`. The `chars` string
31712      * is truncated if the number of characters exceeds `length`.
31713      *
31714      * @private
31715      * @param {number} length The padding length.
31716      * @param {string} [chars=' '] The string used as padding.
31717      * @returns {string} Returns the padding for `string`.
31718      */
31719     function createPadding(length, chars) {
31720       chars = chars === undefined ? ' ' : baseToString(chars);
31721
31722       var charsLength = chars.length;
31723       if (charsLength < 2) {
31724         return charsLength ? baseRepeat(chars, length) : chars;
31725       }
31726       var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
31727       return hasUnicode(chars)
31728         ? castSlice(stringToArray(result), 0, length).join('')
31729         : result.slice(0, length);
31730     }
31731
31732     /**
31733      * Creates a function that wraps `func` to invoke it with the `this` binding
31734      * of `thisArg` and `partials` prepended to the arguments it receives.
31735      *
31736      * @private
31737      * @param {Function} func The function to wrap.
31738      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31739      * @param {*} thisArg The `this` binding of `func`.
31740      * @param {Array} partials The arguments to prepend to those provided to
31741      *  the new function.
31742      * @returns {Function} Returns the new wrapped function.
31743      */
31744     function createPartial(func, bitmask, thisArg, partials) {
31745       var isBind = bitmask & WRAP_BIND_FLAG,
31746           Ctor = createCtor(func);
31747
31748       function wrapper() {
31749         var argsIndex = -1,
31750             argsLength = arguments.length,
31751             leftIndex = -1,
31752             leftLength = partials.length,
31753             args = Array(leftLength + argsLength),
31754             fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
31755
31756         while (++leftIndex < leftLength) {
31757           args[leftIndex] = partials[leftIndex];
31758         }
31759         while (argsLength--) {
31760           args[leftIndex++] = arguments[++argsIndex];
31761         }
31762         return apply(fn, isBind ? thisArg : this, args);
31763       }
31764       return wrapper;
31765     }
31766
31767     /**
31768      * Creates a `_.range` or `_.rangeRight` function.
31769      *
31770      * @private
31771      * @param {boolean} [fromRight] Specify iterating from right to left.
31772      * @returns {Function} Returns the new range function.
31773      */
31774     function createRange(fromRight) {
31775       return function(start, end, step) {
31776         if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
31777           end = step = undefined;
31778         }
31779         // Ensure the sign of `-0` is preserved.
31780         start = toFinite(start);
31781         if (end === undefined) {
31782           end = start;
31783           start = 0;
31784         } else {
31785           end = toFinite(end);
31786         }
31787         step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
31788         return baseRange(start, end, step, fromRight);
31789       };
31790     }
31791
31792     /**
31793      * Creates a function that performs a relational operation on two values.
31794      *
31795      * @private
31796      * @param {Function} operator The function to perform the operation.
31797      * @returns {Function} Returns the new relational operation function.
31798      */
31799     function createRelationalOperation(operator) {
31800       return function(value, other) {
31801         if (!(typeof value == 'string' && typeof other == 'string')) {
31802           value = toNumber(value);
31803           other = toNumber(other);
31804         }
31805         return operator(value, other);
31806       };
31807     }
31808
31809     /**
31810      * Creates a function that wraps `func` to continue currying.
31811      *
31812      * @private
31813      * @param {Function} func The function to wrap.
31814      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
31815      * @param {Function} wrapFunc The function to create the `func` wrapper.
31816      * @param {*} placeholder The placeholder value.
31817      * @param {*} [thisArg] The `this` binding of `func`.
31818      * @param {Array} [partials] The arguments to prepend to those provided to
31819      *  the new function.
31820      * @param {Array} [holders] The `partials` placeholder indexes.
31821      * @param {Array} [argPos] The argument positions of the new function.
31822      * @param {number} [ary] The arity cap of `func`.
31823      * @param {number} [arity] The arity of `func`.
31824      * @returns {Function} Returns the new wrapped function.
31825      */
31826     function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
31827       var isCurry = bitmask & WRAP_CURRY_FLAG,
31828           newHolders = isCurry ? holders : undefined,
31829           newHoldersRight = isCurry ? undefined : holders,
31830           newPartials = isCurry ? partials : undefined,
31831           newPartialsRight = isCurry ? undefined : partials;
31832
31833       bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
31834       bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
31835
31836       if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
31837         bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
31838       }
31839       var newData = [
31840         func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
31841         newHoldersRight, argPos, ary, arity
31842       ];
31843
31844       var result = wrapFunc.apply(undefined, newData);
31845       if (isLaziable(func)) {
31846         setData(result, newData);
31847       }
31848       result.placeholder = placeholder;
31849       return setWrapToString(result, func, bitmask);
31850     }
31851
31852     /**
31853      * Creates a function like `_.round`.
31854      *
31855      * @private
31856      * @param {string} methodName The name of the `Math` method to use when rounding.
31857      * @returns {Function} Returns the new round function.
31858      */
31859     function createRound(methodName) {
31860       var func = Math[methodName];
31861       return function(number, precision) {
31862         number = toNumber(number);
31863         precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
31864         if (precision && nativeIsFinite(number)) {
31865           // Shift with exponential notation to avoid floating-point issues.
31866           // See [MDN](https://mdn.io/round#Examples) for more details.
31867           var pair = (toString(number) + 'e').split('e'),
31868               value = func(pair[0] + 'e' + (+pair[1] + precision));
31869
31870           pair = (toString(value) + 'e').split('e');
31871           return +(pair[0] + 'e' + (+pair[1] - precision));
31872         }
31873         return func(number);
31874       };
31875     }
31876
31877     /**
31878      * Creates a set object of `values`.
31879      *
31880      * @private
31881      * @param {Array} values The values to add to the set.
31882      * @returns {Object} Returns the new set.
31883      */
31884     var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
31885       return new Set(values);
31886     };
31887
31888     /**
31889      * Creates a `_.toPairs` or `_.toPairsIn` function.
31890      *
31891      * @private
31892      * @param {Function} keysFunc The function to get the keys of a given object.
31893      * @returns {Function} Returns the new pairs function.
31894      */
31895     function createToPairs(keysFunc) {
31896       return function(object) {
31897         var tag = getTag(object);
31898         if (tag == mapTag) {
31899           return mapToArray(object);
31900         }
31901         if (tag == setTag) {
31902           return setToPairs(object);
31903         }
31904         return baseToPairs(object, keysFunc(object));
31905       };
31906     }
31907
31908     /**
31909      * Creates a function that either curries or invokes `func` with optional
31910      * `this` binding and partially applied arguments.
31911      *
31912      * @private
31913      * @param {Function|string} func The function or method name to wrap.
31914      * @param {number} bitmask The bitmask flags.
31915      *    1 - `_.bind`
31916      *    2 - `_.bindKey`
31917      *    4 - `_.curry` or `_.curryRight` of a bound function
31918      *    8 - `_.curry`
31919      *   16 - `_.curryRight`
31920      *   32 - `_.partial`
31921      *   64 - `_.partialRight`
31922      *  128 - `_.rearg`
31923      *  256 - `_.ary`
31924      *  512 - `_.flip`
31925      * @param {*} [thisArg] The `this` binding of `func`.
31926      * @param {Array} [partials] The arguments to be partially applied.
31927      * @param {Array} [holders] The `partials` placeholder indexes.
31928      * @param {Array} [argPos] The argument positions of the new function.
31929      * @param {number} [ary] The arity cap of `func`.
31930      * @param {number} [arity] The arity of `func`.
31931      * @returns {Function} Returns the new wrapped function.
31932      */
31933     function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
31934       var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
31935       if (!isBindKey && typeof func != 'function') {
31936         throw new TypeError(FUNC_ERROR_TEXT);
31937       }
31938       var length = partials ? partials.length : 0;
31939       if (!length) {
31940         bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
31941         partials = holders = undefined;
31942       }
31943       ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
31944       arity = arity === undefined ? arity : toInteger(arity);
31945       length -= holders ? holders.length : 0;
31946
31947       if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
31948         var partialsRight = partials,
31949             holdersRight = holders;
31950
31951         partials = holders = undefined;
31952       }
31953       var data = isBindKey ? undefined : getData(func);
31954
31955       var newData = [
31956         func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
31957         argPos, ary, arity
31958       ];
31959
31960       if (data) {
31961         mergeData(newData, data);
31962       }
31963       func = newData[0];
31964       bitmask = newData[1];
31965       thisArg = newData[2];
31966       partials = newData[3];
31967       holders = newData[4];
31968       arity = newData[9] = newData[9] === undefined
31969         ? (isBindKey ? 0 : func.length)
31970         : nativeMax(newData[9] - length, 0);
31971
31972       if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
31973         bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
31974       }
31975       if (!bitmask || bitmask == WRAP_BIND_FLAG) {
31976         var result = createBind(func, bitmask, thisArg);
31977       } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
31978         result = createCurry(func, bitmask, arity);
31979       } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
31980         result = createPartial(func, bitmask, thisArg, partials);
31981       } else {
31982         result = createHybrid.apply(undefined, newData);
31983       }
31984       var setter = data ? baseSetData : setData;
31985       return setWrapToString(setter(result, newData), func, bitmask);
31986     }
31987
31988     /**
31989      * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
31990      * of source objects to the destination object for all destination properties
31991      * that resolve to `undefined`.
31992      *
31993      * @private
31994      * @param {*} objValue The destination value.
31995      * @param {*} srcValue The source value.
31996      * @param {string} key The key of the property to assign.
31997      * @param {Object} object The parent object of `objValue`.
31998      * @returns {*} Returns the value to assign.
31999      */
32000     function customDefaultsAssignIn(objValue, srcValue, key, object) {
32001       if (objValue === undefined ||
32002           (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
32003         return srcValue;
32004       }
32005       return objValue;
32006     }
32007
32008     /**
32009      * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
32010      * objects into destination objects that are passed thru.
32011      *
32012      * @private
32013      * @param {*} objValue The destination value.
32014      * @param {*} srcValue The source value.
32015      * @param {string} key The key of the property to merge.
32016      * @param {Object} object The parent object of `objValue`.
32017      * @param {Object} source The parent object of `srcValue`.
32018      * @param {Object} [stack] Tracks traversed source values and their merged
32019      *  counterparts.
32020      * @returns {*} Returns the value to assign.
32021      */
32022     function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
32023       if (isObject(objValue) && isObject(srcValue)) {
32024         // Recursively merge objects and arrays (susceptible to call stack limits).
32025         stack.set(srcValue, objValue);
32026         baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
32027         stack['delete'](srcValue);
32028       }
32029       return objValue;
32030     }
32031
32032     /**
32033      * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
32034      * objects.
32035      *
32036      * @private
32037      * @param {*} value The value to inspect.
32038      * @param {string} key The key of the property to inspect.
32039      * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
32040      */
32041     function customOmitClone(value) {
32042       return isPlainObject(value) ? undefined : value;
32043     }
32044
32045     /**
32046      * A specialized version of `baseIsEqualDeep` for arrays with support for
32047      * partial deep comparisons.
32048      *
32049      * @private
32050      * @param {Array} array The array to compare.
32051      * @param {Array} other The other array to compare.
32052      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
32053      * @param {Function} customizer The function to customize comparisons.
32054      * @param {Function} equalFunc The function to determine equivalents of values.
32055      * @param {Object} stack Tracks traversed `array` and `other` objects.
32056      * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
32057      */
32058     function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
32059       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
32060           arrLength = array.length,
32061           othLength = other.length;
32062
32063       if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
32064         return false;
32065       }
32066       // Assume cyclic values are equal.
32067       var stacked = stack.get(array);
32068       if (stacked && stack.get(other)) {
32069         return stacked == other;
32070       }
32071       var index = -1,
32072           result = true,
32073           seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
32074
32075       stack.set(array, other);
32076       stack.set(other, array);
32077
32078       // Ignore non-index properties.
32079       while (++index < arrLength) {
32080         var arrValue = array[index],
32081             othValue = other[index];
32082
32083         if (customizer) {
32084           var compared = isPartial
32085             ? customizer(othValue, arrValue, index, other, array, stack)
32086             : customizer(arrValue, othValue, index, array, other, stack);
32087         }
32088         if (compared !== undefined) {
32089           if (compared) {
32090             continue;
32091           }
32092           result = false;
32093           break;
32094         }
32095         // Recursively compare arrays (susceptible to call stack limits).
32096         if (seen) {
32097           if (!arraySome(other, function(othValue, othIndex) {
32098                 if (!cacheHas(seen, othIndex) &&
32099                     (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
32100                   return seen.push(othIndex);
32101                 }
32102               })) {
32103             result = false;
32104             break;
32105           }
32106         } else if (!(
32107               arrValue === othValue ||
32108                 equalFunc(arrValue, othValue, bitmask, customizer, stack)
32109             )) {
32110           result = false;
32111           break;
32112         }
32113       }
32114       stack['delete'](array);
32115       stack['delete'](other);
32116       return result;
32117     }
32118
32119     /**
32120      * A specialized version of `baseIsEqualDeep` for comparing objects of
32121      * the same `toStringTag`.
32122      *
32123      * **Note:** This function only supports comparing values with tags of
32124      * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
32125      *
32126      * @private
32127      * @param {Object} object The object to compare.
32128      * @param {Object} other The other object to compare.
32129      * @param {string} tag The `toStringTag` of the objects to compare.
32130      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
32131      * @param {Function} customizer The function to customize comparisons.
32132      * @param {Function} equalFunc The function to determine equivalents of values.
32133      * @param {Object} stack Tracks traversed `object` and `other` objects.
32134      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
32135      */
32136     function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
32137       switch (tag) {
32138         case dataViewTag:
32139           if ((object.byteLength != other.byteLength) ||
32140               (object.byteOffset != other.byteOffset)) {
32141             return false;
32142           }
32143           object = object.buffer;
32144           other = other.buffer;
32145
32146         case arrayBufferTag:
32147           if ((object.byteLength != other.byteLength) ||
32148               !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
32149             return false;
32150           }
32151           return true;
32152
32153         case boolTag:
32154         case dateTag:
32155         case numberTag:
32156           // Coerce booleans to `1` or `0` and dates to milliseconds.
32157           // Invalid dates are coerced to `NaN`.
32158           return eq(+object, +other);
32159
32160         case errorTag:
32161           return object.name == other.name && object.message == other.message;
32162
32163         case regexpTag:
32164         case stringTag:
32165           // Coerce regexes to strings and treat strings, primitives and objects,
32166           // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
32167           // for more details.
32168           return object == (other + '');
32169
32170         case mapTag:
32171           var convert = mapToArray;
32172
32173         case setTag:
32174           var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
32175           convert || (convert = setToArray);
32176
32177           if (object.size != other.size && !isPartial) {
32178             return false;
32179           }
32180           // Assume cyclic values are equal.
32181           var stacked = stack.get(object);
32182           if (stacked) {
32183             return stacked == other;
32184           }
32185           bitmask |= COMPARE_UNORDERED_FLAG;
32186
32187           // Recursively compare objects (susceptible to call stack limits).
32188           stack.set(object, other);
32189           var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
32190           stack['delete'](object);
32191           return result;
32192
32193         case symbolTag:
32194           if (symbolValueOf) {
32195             return symbolValueOf.call(object) == symbolValueOf.call(other);
32196           }
32197       }
32198       return false;
32199     }
32200
32201     /**
32202      * A specialized version of `baseIsEqualDeep` for objects with support for
32203      * partial deep comparisons.
32204      *
32205      * @private
32206      * @param {Object} object The object to compare.
32207      * @param {Object} other The other object to compare.
32208      * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
32209      * @param {Function} customizer The function to customize comparisons.
32210      * @param {Function} equalFunc The function to determine equivalents of values.
32211      * @param {Object} stack Tracks traversed `object` and `other` objects.
32212      * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
32213      */
32214     function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
32215       var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
32216           objProps = getAllKeys(object),
32217           objLength = objProps.length,
32218           othProps = getAllKeys(other),
32219           othLength = othProps.length;
32220
32221       if (objLength != othLength && !isPartial) {
32222         return false;
32223       }
32224       var index = objLength;
32225       while (index--) {
32226         var key = objProps[index];
32227         if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
32228           return false;
32229         }
32230       }
32231       // Assume cyclic values are equal.
32232       var stacked = stack.get(object);
32233       if (stacked && stack.get(other)) {
32234         return stacked == other;
32235       }
32236       var result = true;
32237       stack.set(object, other);
32238       stack.set(other, object);
32239
32240       var skipCtor = isPartial;
32241       while (++index < objLength) {
32242         key = objProps[index];
32243         var objValue = object[key],
32244             othValue = other[key];
32245
32246         if (customizer) {
32247           var compared = isPartial
32248             ? customizer(othValue, objValue, key, other, object, stack)
32249             : customizer(objValue, othValue, key, object, other, stack);
32250         }
32251         // Recursively compare objects (susceptible to call stack limits).
32252         if (!(compared === undefined
32253               ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
32254               : compared
32255             )) {
32256           result = false;
32257           break;
32258         }
32259         skipCtor || (skipCtor = key == 'constructor');
32260       }
32261       if (result && !skipCtor) {
32262         var objCtor = object.constructor,
32263             othCtor = other.constructor;
32264
32265         // Non `Object` object instances with different constructors are not equal.
32266         if (objCtor != othCtor &&
32267             ('constructor' in object && 'constructor' in other) &&
32268             !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
32269               typeof othCtor == 'function' && othCtor instanceof othCtor)) {
32270           result = false;
32271         }
32272       }
32273       stack['delete'](object);
32274       stack['delete'](other);
32275       return result;
32276     }
32277
32278     /**
32279      * A specialized version of `baseRest` which flattens the rest array.
32280      *
32281      * @private
32282      * @param {Function} func The function to apply a rest parameter to.
32283      * @returns {Function} Returns the new function.
32284      */
32285     function flatRest(func) {
32286       return setToString(overRest(func, undefined, flatten), func + '');
32287     }
32288
32289     /**
32290      * Creates an array of own enumerable property names and symbols of `object`.
32291      *
32292      * @private
32293      * @param {Object} object The object to query.
32294      * @returns {Array} Returns the array of property names and symbols.
32295      */
32296     function getAllKeys(object) {
32297       return baseGetAllKeys(object, keys, getSymbols);
32298     }
32299
32300     /**
32301      * Creates an array of own and inherited enumerable property names and
32302      * symbols of `object`.
32303      *
32304      * @private
32305      * @param {Object} object The object to query.
32306      * @returns {Array} Returns the array of property names and symbols.
32307      */
32308     function getAllKeysIn(object) {
32309       return baseGetAllKeys(object, keysIn, getSymbolsIn);
32310     }
32311
32312     /**
32313      * Gets metadata for `func`.
32314      *
32315      * @private
32316      * @param {Function} func The function to query.
32317      * @returns {*} Returns the metadata for `func`.
32318      */
32319     var getData = !metaMap ? noop : function(func) {
32320       return metaMap.get(func);
32321     };
32322
32323     /**
32324      * Gets the name of `func`.
32325      *
32326      * @private
32327      * @param {Function} func The function to query.
32328      * @returns {string} Returns the function name.
32329      */
32330     function getFuncName(func) {
32331       var result = (func.name + ''),
32332           array = realNames[result],
32333           length = hasOwnProperty.call(realNames, result) ? array.length : 0;
32334
32335       while (length--) {
32336         var data = array[length],
32337             otherFunc = data.func;
32338         if (otherFunc == null || otherFunc == func) {
32339           return data.name;
32340         }
32341       }
32342       return result;
32343     }
32344
32345     /**
32346      * Gets the argument placeholder value for `func`.
32347      *
32348      * @private
32349      * @param {Function} func The function to inspect.
32350      * @returns {*} Returns the placeholder value.
32351      */
32352     function getHolder(func) {
32353       var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
32354       return object.placeholder;
32355     }
32356
32357     /**
32358      * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
32359      * this function returns the custom method, otherwise it returns `baseIteratee`.
32360      * If arguments are provided, the chosen function is invoked with them and
32361      * its result is returned.
32362      *
32363      * @private
32364      * @param {*} [value] The value to convert to an iteratee.
32365      * @param {number} [arity] The arity of the created iteratee.
32366      * @returns {Function} Returns the chosen function or its result.
32367      */
32368     function getIteratee() {
32369       var result = lodash.iteratee || iteratee;
32370       result = result === iteratee ? baseIteratee : result;
32371       return arguments.length ? result(arguments[0], arguments[1]) : result;
32372     }
32373
32374     /**
32375      * Gets the data for `map`.
32376      *
32377      * @private
32378      * @param {Object} map The map to query.
32379      * @param {string} key The reference key.
32380      * @returns {*} Returns the map data.
32381      */
32382     function getMapData(map, key) {
32383       var data = map.__data__;
32384       return isKeyable(key)
32385         ? data[typeof key == 'string' ? 'string' : 'hash']
32386         : data.map;
32387     }
32388
32389     /**
32390      * Gets the property names, values, and compare flags of `object`.
32391      *
32392      * @private
32393      * @param {Object} object The object to query.
32394      * @returns {Array} Returns the match data of `object`.
32395      */
32396     function getMatchData(object) {
32397       var result = keys(object),
32398           length = result.length;
32399
32400       while (length--) {
32401         var key = result[length],
32402             value = object[key];
32403
32404         result[length] = [key, value, isStrictComparable(value)];
32405       }
32406       return result;
32407     }
32408
32409     /**
32410      * Gets the native function at `key` of `object`.
32411      *
32412      * @private
32413      * @param {Object} object The object to query.
32414      * @param {string} key The key of the method to get.
32415      * @returns {*} Returns the function if it's native, else `undefined`.
32416      */
32417     function getNative(object, key) {
32418       var value = getValue(object, key);
32419       return baseIsNative(value) ? value : undefined;
32420     }
32421
32422     /**
32423      * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
32424      *
32425      * @private
32426      * @param {*} value The value to query.
32427      * @returns {string} Returns the raw `toStringTag`.
32428      */
32429     function getRawTag(value) {
32430       var isOwn = hasOwnProperty.call(value, symToStringTag),
32431           tag = value[symToStringTag];
32432
32433       try {
32434         value[symToStringTag] = undefined;
32435         var unmasked = true;
32436       } catch (e) {}
32437
32438       var result = nativeObjectToString.call(value);
32439       if (unmasked) {
32440         if (isOwn) {
32441           value[symToStringTag] = tag;
32442         } else {
32443           delete value[symToStringTag];
32444         }
32445       }
32446       return result;
32447     }
32448
32449     /**
32450      * Creates an array of the own enumerable symbols of `object`.
32451      *
32452      * @private
32453      * @param {Object} object The object to query.
32454      * @returns {Array} Returns the array of symbols.
32455      */
32456     var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
32457       if (object == null) {
32458         return [];
32459       }
32460       object = Object(object);
32461       return arrayFilter(nativeGetSymbols(object), function(symbol) {
32462         return propertyIsEnumerable.call(object, symbol);
32463       });
32464     };
32465
32466     /**
32467      * Creates an array of the own and inherited enumerable symbols of `object`.
32468      *
32469      * @private
32470      * @param {Object} object The object to query.
32471      * @returns {Array} Returns the array of symbols.
32472      */
32473     var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
32474       var result = [];
32475       while (object) {
32476         arrayPush(result, getSymbols(object));
32477         object = getPrototype(object);
32478       }
32479       return result;
32480     };
32481
32482     /**
32483      * Gets the `toStringTag` of `value`.
32484      *
32485      * @private
32486      * @param {*} value The value to query.
32487      * @returns {string} Returns the `toStringTag`.
32488      */
32489     var getTag = baseGetTag;
32490
32491     // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
32492     if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
32493         (Map && getTag(new Map) != mapTag) ||
32494         (Promise && getTag(Promise.resolve()) != promiseTag) ||
32495         (Set && getTag(new Set) != setTag) ||
32496         (WeakMap && getTag(new WeakMap) != weakMapTag)) {
32497       getTag = function(value) {
32498         var result = baseGetTag(value),
32499             Ctor = result == objectTag ? value.constructor : undefined,
32500             ctorString = Ctor ? toSource(Ctor) : '';
32501
32502         if (ctorString) {
32503           switch (ctorString) {
32504             case dataViewCtorString: return dataViewTag;
32505             case mapCtorString: return mapTag;
32506             case promiseCtorString: return promiseTag;
32507             case setCtorString: return setTag;
32508             case weakMapCtorString: return weakMapTag;
32509           }
32510         }
32511         return result;
32512       };
32513     }
32514
32515     /**
32516      * Gets the view, applying any `transforms` to the `start` and `end` positions.
32517      *
32518      * @private
32519      * @param {number} start The start of the view.
32520      * @param {number} end The end of the view.
32521      * @param {Array} transforms The transformations to apply to the view.
32522      * @returns {Object} Returns an object containing the `start` and `end`
32523      *  positions of the view.
32524      */
32525     function getView(start, end, transforms) {
32526       var index = -1,
32527           length = transforms.length;
32528
32529       while (++index < length) {
32530         var data = transforms[index],
32531             size = data.size;
32532
32533         switch (data.type) {
32534           case 'drop':      start += size; break;
32535           case 'dropRight': end -= size; break;
32536           case 'take':      end = nativeMin(end, start + size); break;
32537           case 'takeRight': start = nativeMax(start, end - size); break;
32538         }
32539       }
32540       return { 'start': start, 'end': end };
32541     }
32542
32543     /**
32544      * Extracts wrapper details from the `source` body comment.
32545      *
32546      * @private
32547      * @param {string} source The source to inspect.
32548      * @returns {Array} Returns the wrapper details.
32549      */
32550     function getWrapDetails(source) {
32551       var match = source.match(reWrapDetails);
32552       return match ? match[1].split(reSplitDetails) : [];
32553     }
32554
32555     /**
32556      * Checks if `path` exists on `object`.
32557      *
32558      * @private
32559      * @param {Object} object The object to query.
32560      * @param {Array|string} path The path to check.
32561      * @param {Function} hasFunc The function to check properties.
32562      * @returns {boolean} Returns `true` if `path` exists, else `false`.
32563      */
32564     function hasPath(object, path, hasFunc) {
32565       path = castPath(path, object);
32566
32567       var index = -1,
32568           length = path.length,
32569           result = false;
32570
32571       while (++index < length) {
32572         var key = toKey(path[index]);
32573         if (!(result = object != null && hasFunc(object, key))) {
32574           break;
32575         }
32576         object = object[key];
32577       }
32578       if (result || ++index != length) {
32579         return result;
32580       }
32581       length = object == null ? 0 : object.length;
32582       return !!length && isLength(length) && isIndex(key, length) &&
32583         (isArray(object) || isArguments(object));
32584     }
32585
32586     /**
32587      * Initializes an array clone.
32588      *
32589      * @private
32590      * @param {Array} array The array to clone.
32591      * @returns {Array} Returns the initialized clone.
32592      */
32593     function initCloneArray(array) {
32594       var length = array.length,
32595           result = new array.constructor(length);
32596
32597       // Add properties assigned by `RegExp#exec`.
32598       if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
32599         result.index = array.index;
32600         result.input = array.input;
32601       }
32602       return result;
32603     }
32604
32605     /**
32606      * Initializes an object clone.
32607      *
32608      * @private
32609      * @param {Object} object The object to clone.
32610      * @returns {Object} Returns the initialized clone.
32611      */
32612     function initCloneObject(object) {
32613       return (typeof object.constructor == 'function' && !isPrototype(object))
32614         ? baseCreate(getPrototype(object))
32615         : {};
32616     }
32617
32618     /**
32619      * Initializes an object clone based on its `toStringTag`.
32620      *
32621      * **Note:** This function only supports cloning values with tags of
32622      * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
32623      *
32624      * @private
32625      * @param {Object} object The object to clone.
32626      * @param {string} tag The `toStringTag` of the object to clone.
32627      * @param {boolean} [isDeep] Specify a deep clone.
32628      * @returns {Object} Returns the initialized clone.
32629      */
32630     function initCloneByTag(object, tag, isDeep) {
32631       var Ctor = object.constructor;
32632       switch (tag) {
32633         case arrayBufferTag:
32634           return cloneArrayBuffer(object);
32635
32636         case boolTag:
32637         case dateTag:
32638           return new Ctor(+object);
32639
32640         case dataViewTag:
32641           return cloneDataView(object, isDeep);
32642
32643         case float32Tag: case float64Tag:
32644         case int8Tag: case int16Tag: case int32Tag:
32645         case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
32646           return cloneTypedArray(object, isDeep);
32647
32648         case mapTag:
32649           return new Ctor;
32650
32651         case numberTag:
32652         case stringTag:
32653           return new Ctor(object);
32654
32655         case regexpTag:
32656           return cloneRegExp(object);
32657
32658         case setTag:
32659           return new Ctor;
32660
32661         case symbolTag:
32662           return cloneSymbol(object);
32663       }
32664     }
32665
32666     /**
32667      * Inserts wrapper `details` in a comment at the top of the `source` body.
32668      *
32669      * @private
32670      * @param {string} source The source to modify.
32671      * @returns {Array} details The details to insert.
32672      * @returns {string} Returns the modified source.
32673      */
32674     function insertWrapDetails(source, details) {
32675       var length = details.length;
32676       if (!length) {
32677         return source;
32678       }
32679       var lastIndex = length - 1;
32680       details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
32681       details = details.join(length > 2 ? ', ' : ' ');
32682       return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
32683     }
32684
32685     /**
32686      * Checks if `value` is a flattenable `arguments` object or array.
32687      *
32688      * @private
32689      * @param {*} value The value to check.
32690      * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
32691      */
32692     function isFlattenable(value) {
32693       return isArray(value) || isArguments(value) ||
32694         !!(spreadableSymbol && value && value[spreadableSymbol]);
32695     }
32696
32697     /**
32698      * Checks if `value` is a valid array-like index.
32699      *
32700      * @private
32701      * @param {*} value The value to check.
32702      * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
32703      * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
32704      */
32705     function isIndex(value, length) {
32706       var type = typeof value;
32707       length = length == null ? MAX_SAFE_INTEGER : length;
32708
32709       return !!length &&
32710         (type == 'number' ||
32711           (type != 'symbol' && reIsUint.test(value))) &&
32712             (value > -1 && value % 1 == 0 && value < length);
32713     }
32714
32715     /**
32716      * Checks if the given arguments are from an iteratee call.
32717      *
32718      * @private
32719      * @param {*} value The potential iteratee value argument.
32720      * @param {*} index The potential iteratee index or key argument.
32721      * @param {*} object The potential iteratee object argument.
32722      * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
32723      *  else `false`.
32724      */
32725     function isIterateeCall(value, index, object) {
32726       if (!isObject(object)) {
32727         return false;
32728       }
32729       var type = typeof index;
32730       if (type == 'number'
32731             ? (isArrayLike(object) && isIndex(index, object.length))
32732             : (type == 'string' && index in object)
32733           ) {
32734         return eq(object[index], value);
32735       }
32736       return false;
32737     }
32738
32739     /**
32740      * Checks if `value` is a property name and not a property path.
32741      *
32742      * @private
32743      * @param {*} value The value to check.
32744      * @param {Object} [object] The object to query keys on.
32745      * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
32746      */
32747     function isKey(value, object) {
32748       if (isArray(value)) {
32749         return false;
32750       }
32751       var type = typeof value;
32752       if (type == 'number' || type == 'symbol' || type == 'boolean' ||
32753           value == null || isSymbol(value)) {
32754         return true;
32755       }
32756       return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
32757         (object != null && value in Object(object));
32758     }
32759
32760     /**
32761      * Checks if `value` is suitable for use as unique object key.
32762      *
32763      * @private
32764      * @param {*} value The value to check.
32765      * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
32766      */
32767     function isKeyable(value) {
32768       var type = typeof value;
32769       return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
32770         ? (value !== '__proto__')
32771         : (value === null);
32772     }
32773
32774     /**
32775      * Checks if `func` has a lazy counterpart.
32776      *
32777      * @private
32778      * @param {Function} func The function to check.
32779      * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
32780      *  else `false`.
32781      */
32782     function isLaziable(func) {
32783       var funcName = getFuncName(func),
32784           other = lodash[funcName];
32785
32786       if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
32787         return false;
32788       }
32789       if (func === other) {
32790         return true;
32791       }
32792       var data = getData(other);
32793       return !!data && func === data[0];
32794     }
32795
32796     /**
32797      * Checks if `func` has its source masked.
32798      *
32799      * @private
32800      * @param {Function} func The function to check.
32801      * @returns {boolean} Returns `true` if `func` is masked, else `false`.
32802      */
32803     function isMasked(func) {
32804       return !!maskSrcKey && (maskSrcKey in func);
32805     }
32806
32807     /**
32808      * Checks if `func` is capable of being masked.
32809      *
32810      * @private
32811      * @param {*} value The value to check.
32812      * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
32813      */
32814     var isMaskable = coreJsData ? isFunction : stubFalse;
32815
32816     /**
32817      * Checks if `value` is likely a prototype object.
32818      *
32819      * @private
32820      * @param {*} value The value to check.
32821      * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
32822      */
32823     function isPrototype(value) {
32824       var Ctor = value && value.constructor,
32825           proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
32826
32827       return value === proto;
32828     }
32829
32830     /**
32831      * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
32832      *
32833      * @private
32834      * @param {*} value The value to check.
32835      * @returns {boolean} Returns `true` if `value` if suitable for strict
32836      *  equality comparisons, else `false`.
32837      */
32838     function isStrictComparable(value) {
32839       return value === value && !isObject(value);
32840     }
32841
32842     /**
32843      * A specialized version of `matchesProperty` for source values suitable
32844      * for strict equality comparisons, i.e. `===`.
32845      *
32846      * @private
32847      * @param {string} key The key of the property to get.
32848      * @param {*} srcValue The value to match.
32849      * @returns {Function} Returns the new spec function.
32850      */
32851     function matchesStrictComparable(key, srcValue) {
32852       return function(object) {
32853         if (object == null) {
32854           return false;
32855         }
32856         return object[key] === srcValue &&
32857           (srcValue !== undefined || (key in Object(object)));
32858       };
32859     }
32860
32861     /**
32862      * A specialized version of `_.memoize` which clears the memoized function's
32863      * cache when it exceeds `MAX_MEMOIZE_SIZE`.
32864      *
32865      * @private
32866      * @param {Function} func The function to have its output memoized.
32867      * @returns {Function} Returns the new memoized function.
32868      */
32869     function memoizeCapped(func) {
32870       var result = memoize(func, function(key) {
32871         if (cache.size === MAX_MEMOIZE_SIZE) {
32872           cache.clear();
32873         }
32874         return key;
32875       });
32876
32877       var cache = result.cache;
32878       return result;
32879     }
32880
32881     /**
32882      * Merges the function metadata of `source` into `data`.
32883      *
32884      * Merging metadata reduces the number of wrappers used to invoke a function.
32885      * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
32886      * may be applied regardless of execution order. Methods like `_.ary` and
32887      * `_.rearg` modify function arguments, making the order in which they are
32888      * executed important, preventing the merging of metadata. However, we make
32889      * an exception for a safe combined case where curried functions have `_.ary`
32890      * and or `_.rearg` applied.
32891      *
32892      * @private
32893      * @param {Array} data The destination metadata.
32894      * @param {Array} source The source metadata.
32895      * @returns {Array} Returns `data`.
32896      */
32897     function mergeData(data, source) {
32898       var bitmask = data[1],
32899           srcBitmask = source[1],
32900           newBitmask = bitmask | srcBitmask,
32901           isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
32902
32903       var isCombo =
32904         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
32905         ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
32906         ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
32907
32908       // Exit early if metadata can't be merged.
32909       if (!(isCommon || isCombo)) {
32910         return data;
32911       }
32912       // Use source `thisArg` if available.
32913       if (srcBitmask & WRAP_BIND_FLAG) {
32914         data[2] = source[2];
32915         // Set when currying a bound function.
32916         newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
32917       }
32918       // Compose partial arguments.
32919       var value = source[3];
32920       if (value) {
32921         var partials = data[3];
32922         data[3] = partials ? composeArgs(partials, value, source[4]) : value;
32923         data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
32924       }
32925       // Compose partial right arguments.
32926       value = source[5];
32927       if (value) {
32928         partials = data[5];
32929         data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
32930         data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
32931       }
32932       // Use source `argPos` if available.
32933       value = source[7];
32934       if (value) {
32935         data[7] = value;
32936       }
32937       // Use source `ary` if it's smaller.
32938       if (srcBitmask & WRAP_ARY_FLAG) {
32939         data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
32940       }
32941       // Use source `arity` if one is not provided.
32942       if (data[9] == null) {
32943         data[9] = source[9];
32944       }
32945       // Use source `func` and merge bitmasks.
32946       data[0] = source[0];
32947       data[1] = newBitmask;
32948
32949       return data;
32950     }
32951
32952     /**
32953      * This function is like
32954      * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
32955      * except that it includes inherited enumerable properties.
32956      *
32957      * @private
32958      * @param {Object} object The object to query.
32959      * @returns {Array} Returns the array of property names.
32960      */
32961     function nativeKeysIn(object) {
32962       var result = [];
32963       if (object != null) {
32964         for (var key in Object(object)) {
32965           result.push(key);
32966         }
32967       }
32968       return result;
32969     }
32970
32971     /**
32972      * Converts `value` to a string using `Object.prototype.toString`.
32973      *
32974      * @private
32975      * @param {*} value The value to convert.
32976      * @returns {string} Returns the converted string.
32977      */
32978     function objectToString(value) {
32979       return nativeObjectToString.call(value);
32980     }
32981
32982     /**
32983      * A specialized version of `baseRest` which transforms the rest array.
32984      *
32985      * @private
32986      * @param {Function} func The function to apply a rest parameter to.
32987      * @param {number} [start=func.length-1] The start position of the rest parameter.
32988      * @param {Function} transform The rest array transform.
32989      * @returns {Function} Returns the new function.
32990      */
32991     function overRest(func, start, transform) {
32992       start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
32993       return function() {
32994         var args = arguments,
32995             index = -1,
32996             length = nativeMax(args.length - start, 0),
32997             array = Array(length);
32998
32999         while (++index < length) {
33000           array[index] = args[start + index];
33001         }
33002         index = -1;
33003         var otherArgs = Array(start + 1);
33004         while (++index < start) {
33005           otherArgs[index] = args[index];
33006         }
33007         otherArgs[start] = transform(array);
33008         return apply(func, this, otherArgs);
33009       };
33010     }
33011
33012     /**
33013      * Gets the parent value at `path` of `object`.
33014      *
33015      * @private
33016      * @param {Object} object The object to query.
33017      * @param {Array} path The path to get the parent value of.
33018      * @returns {*} Returns the parent value.
33019      */
33020     function parent(object, path) {
33021       return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
33022     }
33023
33024     /**
33025      * Reorder `array` according to the specified indexes where the element at
33026      * the first index is assigned as the first element, the element at
33027      * the second index is assigned as the second element, and so on.
33028      *
33029      * @private
33030      * @param {Array} array The array to reorder.
33031      * @param {Array} indexes The arranged array indexes.
33032      * @returns {Array} Returns `array`.
33033      */
33034     function reorder(array, indexes) {
33035       var arrLength = array.length,
33036           length = nativeMin(indexes.length, arrLength),
33037           oldArray = copyArray(array);
33038
33039       while (length--) {
33040         var index = indexes[length];
33041         array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
33042       }
33043       return array;
33044     }
33045
33046     /**
33047      * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
33048      *
33049      * @private
33050      * @param {Object} object The object to query.
33051      * @param {string} key The key of the property to get.
33052      * @returns {*} Returns the property value.
33053      */
33054     function safeGet(object, key) {
33055       if (key === 'constructor' && typeof object[key] === 'function') {
33056         return;
33057       }
33058
33059       if (key == '__proto__') {
33060         return;
33061       }
33062
33063       return object[key];
33064     }
33065
33066     /**
33067      * Sets metadata for `func`.
33068      *
33069      * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
33070      * period of time, it will trip its breaker and transition to an identity
33071      * function to avoid garbage collection pauses in V8. See
33072      * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
33073      * for more details.
33074      *
33075      * @private
33076      * @param {Function} func The function to associate metadata with.
33077      * @param {*} data The metadata.
33078      * @returns {Function} Returns `func`.
33079      */
33080     var setData = shortOut(baseSetData);
33081
33082     /**
33083      * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
33084      *
33085      * @private
33086      * @param {Function} func The function to delay.
33087      * @param {number} wait The number of milliseconds to delay invocation.
33088      * @returns {number|Object} Returns the timer id or timeout object.
33089      */
33090     var setTimeout = ctxSetTimeout || function(func, wait) {
33091       return root.setTimeout(func, wait);
33092     };
33093
33094     /**
33095      * Sets the `toString` method of `func` to return `string`.
33096      *
33097      * @private
33098      * @param {Function} func The function to modify.
33099      * @param {Function} string The `toString` result.
33100      * @returns {Function} Returns `func`.
33101      */
33102     var setToString = shortOut(baseSetToString);
33103
33104     /**
33105      * Sets the `toString` method of `wrapper` to mimic the source of `reference`
33106      * with wrapper details in a comment at the top of the source body.
33107      *
33108      * @private
33109      * @param {Function} wrapper The function to modify.
33110      * @param {Function} reference The reference function.
33111      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33112      * @returns {Function} Returns `wrapper`.
33113      */
33114     function setWrapToString(wrapper, reference, bitmask) {
33115       var source = (reference + '');
33116       return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
33117     }
33118
33119     /**
33120      * Creates a function that'll short out and invoke `identity` instead
33121      * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
33122      * milliseconds.
33123      *
33124      * @private
33125      * @param {Function} func The function to restrict.
33126      * @returns {Function} Returns the new shortable function.
33127      */
33128     function shortOut(func) {
33129       var count = 0,
33130           lastCalled = 0;
33131
33132       return function() {
33133         var stamp = nativeNow(),
33134             remaining = HOT_SPAN - (stamp - lastCalled);
33135
33136         lastCalled = stamp;
33137         if (remaining > 0) {
33138           if (++count >= HOT_COUNT) {
33139             return arguments[0];
33140           }
33141         } else {
33142           count = 0;
33143         }
33144         return func.apply(undefined, arguments);
33145       };
33146     }
33147
33148     /**
33149      * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
33150      *
33151      * @private
33152      * @param {Array} array The array to shuffle.
33153      * @param {number} [size=array.length] The size of `array`.
33154      * @returns {Array} Returns `array`.
33155      */
33156     function shuffleSelf(array, size) {
33157       var index = -1,
33158           length = array.length,
33159           lastIndex = length - 1;
33160
33161       size = size === undefined ? length : size;
33162       while (++index < size) {
33163         var rand = baseRandom(index, lastIndex),
33164             value = array[rand];
33165
33166         array[rand] = array[index];
33167         array[index] = value;
33168       }
33169       array.length = size;
33170       return array;
33171     }
33172
33173     /**
33174      * Converts `string` to a property path array.
33175      *
33176      * @private
33177      * @param {string} string The string to convert.
33178      * @returns {Array} Returns the property path array.
33179      */
33180     var stringToPath = memoizeCapped(function(string) {
33181       var result = [];
33182       if (string.charCodeAt(0) === 46 /* . */) {
33183         result.push('');
33184       }
33185       string.replace(rePropName, function(match, number, quote, subString) {
33186         result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
33187       });
33188       return result;
33189     });
33190
33191     /**
33192      * Converts `value` to a string key if it's not a string or symbol.
33193      *
33194      * @private
33195      * @param {*} value The value to inspect.
33196      * @returns {string|symbol} Returns the key.
33197      */
33198     function toKey(value) {
33199       if (typeof value == 'string' || isSymbol(value)) {
33200         return value;
33201       }
33202       var result = (value + '');
33203       return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
33204     }
33205
33206     /**
33207      * Converts `func` to its source code.
33208      *
33209      * @private
33210      * @param {Function} func The function to convert.
33211      * @returns {string} Returns the source code.
33212      */
33213     function toSource(func) {
33214       if (func != null) {
33215         try {
33216           return funcToString.call(func);
33217         } catch (e) {}
33218         try {
33219           return (func + '');
33220         } catch (e) {}
33221       }
33222       return '';
33223     }
33224
33225     /**
33226      * Updates wrapper `details` based on `bitmask` flags.
33227      *
33228      * @private
33229      * @returns {Array} details The details to modify.
33230      * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
33231      * @returns {Array} Returns `details`.
33232      */
33233     function updateWrapDetails(details, bitmask) {
33234       arrayEach(wrapFlags, function(pair) {
33235         var value = '_.' + pair[0];
33236         if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
33237           details.push(value);
33238         }
33239       });
33240       return details.sort();
33241     }
33242
33243     /**
33244      * Creates a clone of `wrapper`.
33245      *
33246      * @private
33247      * @param {Object} wrapper The wrapper to clone.
33248      * @returns {Object} Returns the cloned wrapper.
33249      */
33250     function wrapperClone(wrapper) {
33251       if (wrapper instanceof LazyWrapper) {
33252         return wrapper.clone();
33253       }
33254       var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
33255       result.__actions__ = copyArray(wrapper.__actions__);
33256       result.__index__  = wrapper.__index__;
33257       result.__values__ = wrapper.__values__;
33258       return result;
33259     }
33260
33261     /*------------------------------------------------------------------------*/
33262
33263     /**
33264      * Creates an array of elements split into groups the length of `size`.
33265      * If `array` can't be split evenly, the final chunk will be the remaining
33266      * elements.
33267      *
33268      * @static
33269      * @memberOf _
33270      * @since 3.0.0
33271      * @category Array
33272      * @param {Array} array The array to process.
33273      * @param {number} [size=1] The length of each chunk
33274      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
33275      * @returns {Array} Returns the new array of chunks.
33276      * @example
33277      *
33278      * _.chunk(['a', 'b', 'c', 'd'], 2);
33279      * // => [['a', 'b'], ['c', 'd']]
33280      *
33281      * _.chunk(['a', 'b', 'c', 'd'], 3);
33282      * // => [['a', 'b', 'c'], ['d']]
33283      */
33284     function chunk(array, size, guard) {
33285       if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
33286         size = 1;
33287       } else {
33288         size = nativeMax(toInteger(size), 0);
33289       }
33290       var length = array == null ? 0 : array.length;
33291       if (!length || size < 1) {
33292         return [];
33293       }
33294       var index = 0,
33295           resIndex = 0,
33296           result = Array(nativeCeil(length / size));
33297
33298       while (index < length) {
33299         result[resIndex++] = baseSlice(array, index, (index += size));
33300       }
33301       return result;
33302     }
33303
33304     /**
33305      * Creates an array with all falsey values removed. The values `false`, `null`,
33306      * `0`, `""`, `undefined`, and `NaN` are falsey.
33307      *
33308      * @static
33309      * @memberOf _
33310      * @since 0.1.0
33311      * @category Array
33312      * @param {Array} array The array to compact.
33313      * @returns {Array} Returns the new array of filtered values.
33314      * @example
33315      *
33316      * _.compact([0, 1, false, 2, '', 3]);
33317      * // => [1, 2, 3]
33318      */
33319     function compact(array) {
33320       var index = -1,
33321           length = array == null ? 0 : array.length,
33322           resIndex = 0,
33323           result = [];
33324
33325       while (++index < length) {
33326         var value = array[index];
33327         if (value) {
33328           result[resIndex++] = value;
33329         }
33330       }
33331       return result;
33332     }
33333
33334     /**
33335      * Creates a new array concatenating `array` with any additional arrays
33336      * and/or values.
33337      *
33338      * @static
33339      * @memberOf _
33340      * @since 4.0.0
33341      * @category Array
33342      * @param {Array} array The array to concatenate.
33343      * @param {...*} [values] The values to concatenate.
33344      * @returns {Array} Returns the new concatenated array.
33345      * @example
33346      *
33347      * var array = [1];
33348      * var other = _.concat(array, 2, [3], [[4]]);
33349      *
33350      * console.log(other);
33351      * // => [1, 2, 3, [4]]
33352      *
33353      * console.log(array);
33354      * // => [1]
33355      */
33356     function concat() {
33357       var length = arguments.length;
33358       if (!length) {
33359         return [];
33360       }
33361       var args = Array(length - 1),
33362           array = arguments[0],
33363           index = length;
33364
33365       while (index--) {
33366         args[index - 1] = arguments[index];
33367       }
33368       return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
33369     }
33370
33371     /**
33372      * Creates an array of `array` values not included in the other given arrays
33373      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33374      * for equality comparisons. The order and references of result values are
33375      * determined by the first array.
33376      *
33377      * **Note:** Unlike `_.pullAll`, this method returns a new array.
33378      *
33379      * @static
33380      * @memberOf _
33381      * @since 0.1.0
33382      * @category Array
33383      * @param {Array} array The array to inspect.
33384      * @param {...Array} [values] The values to exclude.
33385      * @returns {Array} Returns the new array of filtered values.
33386      * @see _.without, _.xor
33387      * @example
33388      *
33389      * _.difference([2, 1], [2, 3]);
33390      * // => [1]
33391      */
33392     var difference = baseRest(function(array, values) {
33393       return isArrayLikeObject(array)
33394         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
33395         : [];
33396     });
33397
33398     /**
33399      * This method is like `_.difference` except that it accepts `iteratee` which
33400      * is invoked for each element of `array` and `values` to generate the criterion
33401      * by which they're compared. The order and references of result values are
33402      * determined by the first array. The iteratee is invoked with one argument:
33403      * (value).
33404      *
33405      * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
33406      *
33407      * @static
33408      * @memberOf _
33409      * @since 4.0.0
33410      * @category Array
33411      * @param {Array} array The array to inspect.
33412      * @param {...Array} [values] The values to exclude.
33413      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
33414      * @returns {Array} Returns the new array of filtered values.
33415      * @example
33416      *
33417      * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
33418      * // => [1.2]
33419      *
33420      * // The `_.property` iteratee shorthand.
33421      * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
33422      * // => [{ 'x': 2 }]
33423      */
33424     var differenceBy = baseRest(function(array, values) {
33425       var iteratee = last(values);
33426       if (isArrayLikeObject(iteratee)) {
33427         iteratee = undefined;
33428       }
33429       return isArrayLikeObject(array)
33430         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
33431         : [];
33432     });
33433
33434     /**
33435      * This method is like `_.difference` except that it accepts `comparator`
33436      * which is invoked to compare elements of `array` to `values`. The order and
33437      * references of result values are determined by the first array. The comparator
33438      * is invoked with two arguments: (arrVal, othVal).
33439      *
33440      * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
33441      *
33442      * @static
33443      * @memberOf _
33444      * @since 4.0.0
33445      * @category Array
33446      * @param {Array} array The array to inspect.
33447      * @param {...Array} [values] The values to exclude.
33448      * @param {Function} [comparator] The comparator invoked per element.
33449      * @returns {Array} Returns the new array of filtered values.
33450      * @example
33451      *
33452      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
33453      *
33454      * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
33455      * // => [{ 'x': 2, 'y': 1 }]
33456      */
33457     var differenceWith = baseRest(function(array, values) {
33458       var comparator = last(values);
33459       if (isArrayLikeObject(comparator)) {
33460         comparator = undefined;
33461       }
33462       return isArrayLikeObject(array)
33463         ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
33464         : [];
33465     });
33466
33467     /**
33468      * Creates a slice of `array` with `n` elements dropped from the beginning.
33469      *
33470      * @static
33471      * @memberOf _
33472      * @since 0.5.0
33473      * @category Array
33474      * @param {Array} array The array to query.
33475      * @param {number} [n=1] The number of elements to drop.
33476      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
33477      * @returns {Array} Returns the slice of `array`.
33478      * @example
33479      *
33480      * _.drop([1, 2, 3]);
33481      * // => [2, 3]
33482      *
33483      * _.drop([1, 2, 3], 2);
33484      * // => [3]
33485      *
33486      * _.drop([1, 2, 3], 5);
33487      * // => []
33488      *
33489      * _.drop([1, 2, 3], 0);
33490      * // => [1, 2, 3]
33491      */
33492     function drop(array, n, guard) {
33493       var length = array == null ? 0 : array.length;
33494       if (!length) {
33495         return [];
33496       }
33497       n = (guard || n === undefined) ? 1 : toInteger(n);
33498       return baseSlice(array, n < 0 ? 0 : n, length);
33499     }
33500
33501     /**
33502      * Creates a slice of `array` with `n` elements dropped from the end.
33503      *
33504      * @static
33505      * @memberOf _
33506      * @since 3.0.0
33507      * @category Array
33508      * @param {Array} array The array to query.
33509      * @param {number} [n=1] The number of elements to drop.
33510      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
33511      * @returns {Array} Returns the slice of `array`.
33512      * @example
33513      *
33514      * _.dropRight([1, 2, 3]);
33515      * // => [1, 2]
33516      *
33517      * _.dropRight([1, 2, 3], 2);
33518      * // => [1]
33519      *
33520      * _.dropRight([1, 2, 3], 5);
33521      * // => []
33522      *
33523      * _.dropRight([1, 2, 3], 0);
33524      * // => [1, 2, 3]
33525      */
33526     function dropRight(array, n, guard) {
33527       var length = array == null ? 0 : array.length;
33528       if (!length) {
33529         return [];
33530       }
33531       n = (guard || n === undefined) ? 1 : toInteger(n);
33532       n = length - n;
33533       return baseSlice(array, 0, n < 0 ? 0 : n);
33534     }
33535
33536     /**
33537      * Creates a slice of `array` excluding elements dropped from the end.
33538      * Elements are dropped until `predicate` returns falsey. The predicate is
33539      * invoked with three arguments: (value, index, array).
33540      *
33541      * @static
33542      * @memberOf _
33543      * @since 3.0.0
33544      * @category Array
33545      * @param {Array} array The array to query.
33546      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33547      * @returns {Array} Returns the slice of `array`.
33548      * @example
33549      *
33550      * var users = [
33551      *   { 'user': 'barney',  'active': true },
33552      *   { 'user': 'fred',    'active': false },
33553      *   { 'user': 'pebbles', 'active': false }
33554      * ];
33555      *
33556      * _.dropRightWhile(users, function(o) { return !o.active; });
33557      * // => objects for ['barney']
33558      *
33559      * // The `_.matches` iteratee shorthand.
33560      * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
33561      * // => objects for ['barney', 'fred']
33562      *
33563      * // The `_.matchesProperty` iteratee shorthand.
33564      * _.dropRightWhile(users, ['active', false]);
33565      * // => objects for ['barney']
33566      *
33567      * // The `_.property` iteratee shorthand.
33568      * _.dropRightWhile(users, 'active');
33569      * // => objects for ['barney', 'fred', 'pebbles']
33570      */
33571     function dropRightWhile(array, predicate) {
33572       return (array && array.length)
33573         ? baseWhile(array, getIteratee(predicate, 3), true, true)
33574         : [];
33575     }
33576
33577     /**
33578      * Creates a slice of `array` excluding elements dropped from the beginning.
33579      * Elements are dropped until `predicate` returns falsey. The predicate is
33580      * invoked with three arguments: (value, index, array).
33581      *
33582      * @static
33583      * @memberOf _
33584      * @since 3.0.0
33585      * @category Array
33586      * @param {Array} array The array to query.
33587      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33588      * @returns {Array} Returns the slice of `array`.
33589      * @example
33590      *
33591      * var users = [
33592      *   { 'user': 'barney',  'active': false },
33593      *   { 'user': 'fred',    'active': false },
33594      *   { 'user': 'pebbles', 'active': true }
33595      * ];
33596      *
33597      * _.dropWhile(users, function(o) { return !o.active; });
33598      * // => objects for ['pebbles']
33599      *
33600      * // The `_.matches` iteratee shorthand.
33601      * _.dropWhile(users, { 'user': 'barney', 'active': false });
33602      * // => objects for ['fred', 'pebbles']
33603      *
33604      * // The `_.matchesProperty` iteratee shorthand.
33605      * _.dropWhile(users, ['active', false]);
33606      * // => objects for ['pebbles']
33607      *
33608      * // The `_.property` iteratee shorthand.
33609      * _.dropWhile(users, 'active');
33610      * // => objects for ['barney', 'fred', 'pebbles']
33611      */
33612     function dropWhile(array, predicate) {
33613       return (array && array.length)
33614         ? baseWhile(array, getIteratee(predicate, 3), true)
33615         : [];
33616     }
33617
33618     /**
33619      * Fills elements of `array` with `value` from `start` up to, but not
33620      * including, `end`.
33621      *
33622      * **Note:** This method mutates `array`.
33623      *
33624      * @static
33625      * @memberOf _
33626      * @since 3.2.0
33627      * @category Array
33628      * @param {Array} array The array to fill.
33629      * @param {*} value The value to fill `array` with.
33630      * @param {number} [start=0] The start position.
33631      * @param {number} [end=array.length] The end position.
33632      * @returns {Array} Returns `array`.
33633      * @example
33634      *
33635      * var array = [1, 2, 3];
33636      *
33637      * _.fill(array, 'a');
33638      * console.log(array);
33639      * // => ['a', 'a', 'a']
33640      *
33641      * _.fill(Array(3), 2);
33642      * // => [2, 2, 2]
33643      *
33644      * _.fill([4, 6, 8, 10], '*', 1, 3);
33645      * // => [4, '*', '*', 10]
33646      */
33647     function fill(array, value, start, end) {
33648       var length = array == null ? 0 : array.length;
33649       if (!length) {
33650         return [];
33651       }
33652       if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
33653         start = 0;
33654         end = length;
33655       }
33656       return baseFill(array, value, start, end);
33657     }
33658
33659     /**
33660      * This method is like `_.find` except that it returns the index of the first
33661      * element `predicate` returns truthy for instead of the element itself.
33662      *
33663      * @static
33664      * @memberOf _
33665      * @since 1.1.0
33666      * @category Array
33667      * @param {Array} array The array to inspect.
33668      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33669      * @param {number} [fromIndex=0] The index to search from.
33670      * @returns {number} Returns the index of the found element, else `-1`.
33671      * @example
33672      *
33673      * var users = [
33674      *   { 'user': 'barney',  'active': false },
33675      *   { 'user': 'fred',    'active': false },
33676      *   { 'user': 'pebbles', 'active': true }
33677      * ];
33678      *
33679      * _.findIndex(users, function(o) { return o.user == 'barney'; });
33680      * // => 0
33681      *
33682      * // The `_.matches` iteratee shorthand.
33683      * _.findIndex(users, { 'user': 'fred', 'active': false });
33684      * // => 1
33685      *
33686      * // The `_.matchesProperty` iteratee shorthand.
33687      * _.findIndex(users, ['active', false]);
33688      * // => 0
33689      *
33690      * // The `_.property` iteratee shorthand.
33691      * _.findIndex(users, 'active');
33692      * // => 2
33693      */
33694     function findIndex(array, predicate, fromIndex) {
33695       var length = array == null ? 0 : array.length;
33696       if (!length) {
33697         return -1;
33698       }
33699       var index = fromIndex == null ? 0 : toInteger(fromIndex);
33700       if (index < 0) {
33701         index = nativeMax(length + index, 0);
33702       }
33703       return baseFindIndex(array, getIteratee(predicate, 3), index);
33704     }
33705
33706     /**
33707      * This method is like `_.findIndex` except that it iterates over elements
33708      * of `collection` from right to left.
33709      *
33710      * @static
33711      * @memberOf _
33712      * @since 2.0.0
33713      * @category Array
33714      * @param {Array} array The array to inspect.
33715      * @param {Function} [predicate=_.identity] The function invoked per iteration.
33716      * @param {number} [fromIndex=array.length-1] The index to search from.
33717      * @returns {number} Returns the index of the found element, else `-1`.
33718      * @example
33719      *
33720      * var users = [
33721      *   { 'user': 'barney',  'active': true },
33722      *   { 'user': 'fred',    'active': false },
33723      *   { 'user': 'pebbles', 'active': false }
33724      * ];
33725      *
33726      * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
33727      * // => 2
33728      *
33729      * // The `_.matches` iteratee shorthand.
33730      * _.findLastIndex(users, { 'user': 'barney', 'active': true });
33731      * // => 0
33732      *
33733      * // The `_.matchesProperty` iteratee shorthand.
33734      * _.findLastIndex(users, ['active', false]);
33735      * // => 2
33736      *
33737      * // The `_.property` iteratee shorthand.
33738      * _.findLastIndex(users, 'active');
33739      * // => 0
33740      */
33741     function findLastIndex(array, predicate, fromIndex) {
33742       var length = array == null ? 0 : array.length;
33743       if (!length) {
33744         return -1;
33745       }
33746       var index = length - 1;
33747       if (fromIndex !== undefined) {
33748         index = toInteger(fromIndex);
33749         index = fromIndex < 0
33750           ? nativeMax(length + index, 0)
33751           : nativeMin(index, length - 1);
33752       }
33753       return baseFindIndex(array, getIteratee(predicate, 3), index, true);
33754     }
33755
33756     /**
33757      * Flattens `array` a single level deep.
33758      *
33759      * @static
33760      * @memberOf _
33761      * @since 0.1.0
33762      * @category Array
33763      * @param {Array} array The array to flatten.
33764      * @returns {Array} Returns the new flattened array.
33765      * @example
33766      *
33767      * _.flatten([1, [2, [3, [4]], 5]]);
33768      * // => [1, 2, [3, [4]], 5]
33769      */
33770     function flatten(array) {
33771       var length = array == null ? 0 : array.length;
33772       return length ? baseFlatten(array, 1) : [];
33773     }
33774
33775     /**
33776      * Recursively flattens `array`.
33777      *
33778      * @static
33779      * @memberOf _
33780      * @since 3.0.0
33781      * @category Array
33782      * @param {Array} array The array to flatten.
33783      * @returns {Array} Returns the new flattened array.
33784      * @example
33785      *
33786      * _.flattenDeep([1, [2, [3, [4]], 5]]);
33787      * // => [1, 2, 3, 4, 5]
33788      */
33789     function flattenDeep(array) {
33790       var length = array == null ? 0 : array.length;
33791       return length ? baseFlatten(array, INFINITY) : [];
33792     }
33793
33794     /**
33795      * Recursively flatten `array` up to `depth` times.
33796      *
33797      * @static
33798      * @memberOf _
33799      * @since 4.4.0
33800      * @category Array
33801      * @param {Array} array The array to flatten.
33802      * @param {number} [depth=1] The maximum recursion depth.
33803      * @returns {Array} Returns the new flattened array.
33804      * @example
33805      *
33806      * var array = [1, [2, [3, [4]], 5]];
33807      *
33808      * _.flattenDepth(array, 1);
33809      * // => [1, 2, [3, [4]], 5]
33810      *
33811      * _.flattenDepth(array, 2);
33812      * // => [1, 2, 3, [4], 5]
33813      */
33814     function flattenDepth(array, depth) {
33815       var length = array == null ? 0 : array.length;
33816       if (!length) {
33817         return [];
33818       }
33819       depth = depth === undefined ? 1 : toInteger(depth);
33820       return baseFlatten(array, depth);
33821     }
33822
33823     /**
33824      * The inverse of `_.toPairs`; this method returns an object composed
33825      * from key-value `pairs`.
33826      *
33827      * @static
33828      * @memberOf _
33829      * @since 4.0.0
33830      * @category Array
33831      * @param {Array} pairs The key-value pairs.
33832      * @returns {Object} Returns the new object.
33833      * @example
33834      *
33835      * _.fromPairs([['a', 1], ['b', 2]]);
33836      * // => { 'a': 1, 'b': 2 }
33837      */
33838     function fromPairs(pairs) {
33839       var index = -1,
33840           length = pairs == null ? 0 : pairs.length,
33841           result = {};
33842
33843       while (++index < length) {
33844         var pair = pairs[index];
33845         result[pair[0]] = pair[1];
33846       }
33847       return result;
33848     }
33849
33850     /**
33851      * Gets the first element of `array`.
33852      *
33853      * @static
33854      * @memberOf _
33855      * @since 0.1.0
33856      * @alias first
33857      * @category Array
33858      * @param {Array} array The array to query.
33859      * @returns {*} Returns the first element of `array`.
33860      * @example
33861      *
33862      * _.head([1, 2, 3]);
33863      * // => 1
33864      *
33865      * _.head([]);
33866      * // => undefined
33867      */
33868     function head(array) {
33869       return (array && array.length) ? array[0] : undefined;
33870     }
33871
33872     /**
33873      * Gets the index at which the first occurrence of `value` is found in `array`
33874      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33875      * for equality comparisons. If `fromIndex` is negative, it's used as the
33876      * offset from the end of `array`.
33877      *
33878      * @static
33879      * @memberOf _
33880      * @since 0.1.0
33881      * @category Array
33882      * @param {Array} array The array to inspect.
33883      * @param {*} value The value to search for.
33884      * @param {number} [fromIndex=0] The index to search from.
33885      * @returns {number} Returns the index of the matched value, else `-1`.
33886      * @example
33887      *
33888      * _.indexOf([1, 2, 1, 2], 2);
33889      * // => 1
33890      *
33891      * // Search from the `fromIndex`.
33892      * _.indexOf([1, 2, 1, 2], 2, 2);
33893      * // => 3
33894      */
33895     function indexOf(array, value, fromIndex) {
33896       var length = array == null ? 0 : array.length;
33897       if (!length) {
33898         return -1;
33899       }
33900       var index = fromIndex == null ? 0 : toInteger(fromIndex);
33901       if (index < 0) {
33902         index = nativeMax(length + index, 0);
33903       }
33904       return baseIndexOf(array, value, index);
33905     }
33906
33907     /**
33908      * Gets all but the last element of `array`.
33909      *
33910      * @static
33911      * @memberOf _
33912      * @since 0.1.0
33913      * @category Array
33914      * @param {Array} array The array to query.
33915      * @returns {Array} Returns the slice of `array`.
33916      * @example
33917      *
33918      * _.initial([1, 2, 3]);
33919      * // => [1, 2]
33920      */
33921     function initial(array) {
33922       var length = array == null ? 0 : array.length;
33923       return length ? baseSlice(array, 0, -1) : [];
33924     }
33925
33926     /**
33927      * Creates an array of unique values that are included in all given arrays
33928      * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33929      * for equality comparisons. The order and references of result values are
33930      * determined by the first array.
33931      *
33932      * @static
33933      * @memberOf _
33934      * @since 0.1.0
33935      * @category Array
33936      * @param {...Array} [arrays] The arrays to inspect.
33937      * @returns {Array} Returns the new array of intersecting values.
33938      * @example
33939      *
33940      * _.intersection([2, 1], [2, 3]);
33941      * // => [2]
33942      */
33943     var intersection = baseRest(function(arrays) {
33944       var mapped = arrayMap(arrays, castArrayLikeObject);
33945       return (mapped.length && mapped[0] === arrays[0])
33946         ? baseIntersection(mapped)
33947         : [];
33948     });
33949
33950     /**
33951      * This method is like `_.intersection` except that it accepts `iteratee`
33952      * which is invoked for each element of each `arrays` to generate the criterion
33953      * by which they're compared. The order and references of result values are
33954      * determined by the first array. The iteratee is invoked with one argument:
33955      * (value).
33956      *
33957      * @static
33958      * @memberOf _
33959      * @since 4.0.0
33960      * @category Array
33961      * @param {...Array} [arrays] The arrays to inspect.
33962      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
33963      * @returns {Array} Returns the new array of intersecting values.
33964      * @example
33965      *
33966      * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
33967      * // => [2.1]
33968      *
33969      * // The `_.property` iteratee shorthand.
33970      * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
33971      * // => [{ 'x': 1 }]
33972      */
33973     var intersectionBy = baseRest(function(arrays) {
33974       var iteratee = last(arrays),
33975           mapped = arrayMap(arrays, castArrayLikeObject);
33976
33977       if (iteratee === last(mapped)) {
33978         iteratee = undefined;
33979       } else {
33980         mapped.pop();
33981       }
33982       return (mapped.length && mapped[0] === arrays[0])
33983         ? baseIntersection(mapped, getIteratee(iteratee, 2))
33984         : [];
33985     });
33986
33987     /**
33988      * This method is like `_.intersection` except that it accepts `comparator`
33989      * which is invoked to compare elements of `arrays`. The order and references
33990      * of result values are determined by the first array. The comparator is
33991      * invoked with two arguments: (arrVal, othVal).
33992      *
33993      * @static
33994      * @memberOf _
33995      * @since 4.0.0
33996      * @category Array
33997      * @param {...Array} [arrays] The arrays to inspect.
33998      * @param {Function} [comparator] The comparator invoked per element.
33999      * @returns {Array} Returns the new array of intersecting values.
34000      * @example
34001      *
34002      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
34003      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
34004      *
34005      * _.intersectionWith(objects, others, _.isEqual);
34006      * // => [{ 'x': 1, 'y': 2 }]
34007      */
34008     var intersectionWith = baseRest(function(arrays) {
34009       var comparator = last(arrays),
34010           mapped = arrayMap(arrays, castArrayLikeObject);
34011
34012       comparator = typeof comparator == 'function' ? comparator : undefined;
34013       if (comparator) {
34014         mapped.pop();
34015       }
34016       return (mapped.length && mapped[0] === arrays[0])
34017         ? baseIntersection(mapped, undefined, comparator)
34018         : [];
34019     });
34020
34021     /**
34022      * Converts all elements in `array` into a string separated by `separator`.
34023      *
34024      * @static
34025      * @memberOf _
34026      * @since 4.0.0
34027      * @category Array
34028      * @param {Array} array The array to convert.
34029      * @param {string} [separator=','] The element separator.
34030      * @returns {string} Returns the joined string.
34031      * @example
34032      *
34033      * _.join(['a', 'b', 'c'], '~');
34034      * // => 'a~b~c'
34035      */
34036     function join(array, separator) {
34037       return array == null ? '' : nativeJoin.call(array, separator);
34038     }
34039
34040     /**
34041      * Gets the last element of `array`.
34042      *
34043      * @static
34044      * @memberOf _
34045      * @since 0.1.0
34046      * @category Array
34047      * @param {Array} array The array to query.
34048      * @returns {*} Returns the last element of `array`.
34049      * @example
34050      *
34051      * _.last([1, 2, 3]);
34052      * // => 3
34053      */
34054     function last(array) {
34055       var length = array == null ? 0 : array.length;
34056       return length ? array[length - 1] : undefined;
34057     }
34058
34059     /**
34060      * This method is like `_.indexOf` except that it iterates over elements of
34061      * `array` from right to left.
34062      *
34063      * @static
34064      * @memberOf _
34065      * @since 0.1.0
34066      * @category Array
34067      * @param {Array} array The array to inspect.
34068      * @param {*} value The value to search for.
34069      * @param {number} [fromIndex=array.length-1] The index to search from.
34070      * @returns {number} Returns the index of the matched value, else `-1`.
34071      * @example
34072      *
34073      * _.lastIndexOf([1, 2, 1, 2], 2);
34074      * // => 3
34075      *
34076      * // Search from the `fromIndex`.
34077      * _.lastIndexOf([1, 2, 1, 2], 2, 2);
34078      * // => 1
34079      */
34080     function lastIndexOf(array, value, fromIndex) {
34081       var length = array == null ? 0 : array.length;
34082       if (!length) {
34083         return -1;
34084       }
34085       var index = length;
34086       if (fromIndex !== undefined) {
34087         index = toInteger(fromIndex);
34088         index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
34089       }
34090       return value === value
34091         ? strictLastIndexOf(array, value, index)
34092         : baseFindIndex(array, baseIsNaN, index, true);
34093     }
34094
34095     /**
34096      * Gets the element at index `n` of `array`. If `n` is negative, the nth
34097      * element from the end is returned.
34098      *
34099      * @static
34100      * @memberOf _
34101      * @since 4.11.0
34102      * @category Array
34103      * @param {Array} array The array to query.
34104      * @param {number} [n=0] The index of the element to return.
34105      * @returns {*} Returns the nth element of `array`.
34106      * @example
34107      *
34108      * var array = ['a', 'b', 'c', 'd'];
34109      *
34110      * _.nth(array, 1);
34111      * // => 'b'
34112      *
34113      * _.nth(array, -2);
34114      * // => 'c';
34115      */
34116     function nth(array, n) {
34117       return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
34118     }
34119
34120     /**
34121      * Removes all given values from `array` using
34122      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34123      * for equality comparisons.
34124      *
34125      * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
34126      * to remove elements from an array by predicate.
34127      *
34128      * @static
34129      * @memberOf _
34130      * @since 2.0.0
34131      * @category Array
34132      * @param {Array} array The array to modify.
34133      * @param {...*} [values] The values to remove.
34134      * @returns {Array} Returns `array`.
34135      * @example
34136      *
34137      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
34138      *
34139      * _.pull(array, 'a', 'c');
34140      * console.log(array);
34141      * // => ['b', 'b']
34142      */
34143     var pull = baseRest(pullAll);
34144
34145     /**
34146      * This method is like `_.pull` except that it accepts an array of values to remove.
34147      *
34148      * **Note:** Unlike `_.difference`, this method mutates `array`.
34149      *
34150      * @static
34151      * @memberOf _
34152      * @since 4.0.0
34153      * @category Array
34154      * @param {Array} array The array to modify.
34155      * @param {Array} values The values to remove.
34156      * @returns {Array} Returns `array`.
34157      * @example
34158      *
34159      * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
34160      *
34161      * _.pullAll(array, ['a', 'c']);
34162      * console.log(array);
34163      * // => ['b', 'b']
34164      */
34165     function pullAll(array, values) {
34166       return (array && array.length && values && values.length)
34167         ? basePullAll(array, values)
34168         : array;
34169     }
34170
34171     /**
34172      * This method is like `_.pullAll` except that it accepts `iteratee` which is
34173      * invoked for each element of `array` and `values` to generate the criterion
34174      * by which they're compared. The iteratee is invoked with one argument: (value).
34175      *
34176      * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
34177      *
34178      * @static
34179      * @memberOf _
34180      * @since 4.0.0
34181      * @category Array
34182      * @param {Array} array The array to modify.
34183      * @param {Array} values The values to remove.
34184      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34185      * @returns {Array} Returns `array`.
34186      * @example
34187      *
34188      * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
34189      *
34190      * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
34191      * console.log(array);
34192      * // => [{ 'x': 2 }]
34193      */
34194     function pullAllBy(array, values, iteratee) {
34195       return (array && array.length && values && values.length)
34196         ? basePullAll(array, values, getIteratee(iteratee, 2))
34197         : array;
34198     }
34199
34200     /**
34201      * This method is like `_.pullAll` except that it accepts `comparator` which
34202      * is invoked to compare elements of `array` to `values`. The comparator is
34203      * invoked with two arguments: (arrVal, othVal).
34204      *
34205      * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
34206      *
34207      * @static
34208      * @memberOf _
34209      * @since 4.6.0
34210      * @category Array
34211      * @param {Array} array The array to modify.
34212      * @param {Array} values The values to remove.
34213      * @param {Function} [comparator] The comparator invoked per element.
34214      * @returns {Array} Returns `array`.
34215      * @example
34216      *
34217      * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
34218      *
34219      * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
34220      * console.log(array);
34221      * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
34222      */
34223     function pullAllWith(array, values, comparator) {
34224       return (array && array.length && values && values.length)
34225         ? basePullAll(array, values, undefined, comparator)
34226         : array;
34227     }
34228
34229     /**
34230      * Removes elements from `array` corresponding to `indexes` and returns an
34231      * array of removed elements.
34232      *
34233      * **Note:** Unlike `_.at`, this method mutates `array`.
34234      *
34235      * @static
34236      * @memberOf _
34237      * @since 3.0.0
34238      * @category Array
34239      * @param {Array} array The array to modify.
34240      * @param {...(number|number[])} [indexes] The indexes of elements to remove.
34241      * @returns {Array} Returns the new array of removed elements.
34242      * @example
34243      *
34244      * var array = ['a', 'b', 'c', 'd'];
34245      * var pulled = _.pullAt(array, [1, 3]);
34246      *
34247      * console.log(array);
34248      * // => ['a', 'c']
34249      *
34250      * console.log(pulled);
34251      * // => ['b', 'd']
34252      */
34253     var pullAt = flatRest(function(array, indexes) {
34254       var length = array == null ? 0 : array.length,
34255           result = baseAt(array, indexes);
34256
34257       basePullAt(array, arrayMap(indexes, function(index) {
34258         return isIndex(index, length) ? +index : index;
34259       }).sort(compareAscending));
34260
34261       return result;
34262     });
34263
34264     /**
34265      * Removes all elements from `array` that `predicate` returns truthy for
34266      * and returns an array of the removed elements. The predicate is invoked
34267      * with three arguments: (value, index, array).
34268      *
34269      * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
34270      * to pull elements from an array by value.
34271      *
34272      * @static
34273      * @memberOf _
34274      * @since 2.0.0
34275      * @category Array
34276      * @param {Array} array The array to modify.
34277      * @param {Function} [predicate=_.identity] The function invoked per iteration.
34278      * @returns {Array} Returns the new array of removed elements.
34279      * @example
34280      *
34281      * var array = [1, 2, 3, 4];
34282      * var evens = _.remove(array, function(n) {
34283      *   return n % 2 == 0;
34284      * });
34285      *
34286      * console.log(array);
34287      * // => [1, 3]
34288      *
34289      * console.log(evens);
34290      * // => [2, 4]
34291      */
34292     function remove(array, predicate) {
34293       var result = [];
34294       if (!(array && array.length)) {
34295         return result;
34296       }
34297       var index = -1,
34298           indexes = [],
34299           length = array.length;
34300
34301       predicate = getIteratee(predicate, 3);
34302       while (++index < length) {
34303         var value = array[index];
34304         if (predicate(value, index, array)) {
34305           result.push(value);
34306           indexes.push(index);
34307         }
34308       }
34309       basePullAt(array, indexes);
34310       return result;
34311     }
34312
34313     /**
34314      * Reverses `array` so that the first element becomes the last, the second
34315      * element becomes the second to last, and so on.
34316      *
34317      * **Note:** This method mutates `array` and is based on
34318      * [`Array#reverse`](https://mdn.io/Array/reverse).
34319      *
34320      * @static
34321      * @memberOf _
34322      * @since 4.0.0
34323      * @category Array
34324      * @param {Array} array The array to modify.
34325      * @returns {Array} Returns `array`.
34326      * @example
34327      *
34328      * var array = [1, 2, 3];
34329      *
34330      * _.reverse(array);
34331      * // => [3, 2, 1]
34332      *
34333      * console.log(array);
34334      * // => [3, 2, 1]
34335      */
34336     function reverse(array) {
34337       return array == null ? array : nativeReverse.call(array);
34338     }
34339
34340     /**
34341      * Creates a slice of `array` from `start` up to, but not including, `end`.
34342      *
34343      * **Note:** This method is used instead of
34344      * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
34345      * returned.
34346      *
34347      * @static
34348      * @memberOf _
34349      * @since 3.0.0
34350      * @category Array
34351      * @param {Array} array The array to slice.
34352      * @param {number} [start=0] The start position.
34353      * @param {number} [end=array.length] The end position.
34354      * @returns {Array} Returns the slice of `array`.
34355      */
34356     function slice(array, start, end) {
34357       var length = array == null ? 0 : array.length;
34358       if (!length) {
34359         return [];
34360       }
34361       if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
34362         start = 0;
34363         end = length;
34364       }
34365       else {
34366         start = start == null ? 0 : toInteger(start);
34367         end = end === undefined ? length : toInteger(end);
34368       }
34369       return baseSlice(array, start, end);
34370     }
34371
34372     /**
34373      * Uses a binary search to determine the lowest index at which `value`
34374      * should be inserted into `array` in order to maintain its sort order.
34375      *
34376      * @static
34377      * @memberOf _
34378      * @since 0.1.0
34379      * @category Array
34380      * @param {Array} array The sorted array to inspect.
34381      * @param {*} value The value to evaluate.
34382      * @returns {number} Returns the index at which `value` should be inserted
34383      *  into `array`.
34384      * @example
34385      *
34386      * _.sortedIndex([30, 50], 40);
34387      * // => 1
34388      */
34389     function sortedIndex(array, value) {
34390       return baseSortedIndex(array, value);
34391     }
34392
34393     /**
34394      * This method is like `_.sortedIndex` except that it accepts `iteratee`
34395      * which is invoked for `value` and each element of `array` to compute their
34396      * sort ranking. The iteratee is invoked with one argument: (value).
34397      *
34398      * @static
34399      * @memberOf _
34400      * @since 4.0.0
34401      * @category Array
34402      * @param {Array} array The sorted array to inspect.
34403      * @param {*} value The value to evaluate.
34404      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34405      * @returns {number} Returns the index at which `value` should be inserted
34406      *  into `array`.
34407      * @example
34408      *
34409      * var objects = [{ 'x': 4 }, { 'x': 5 }];
34410      *
34411      * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
34412      * // => 0
34413      *
34414      * // The `_.property` iteratee shorthand.
34415      * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
34416      * // => 0
34417      */
34418     function sortedIndexBy(array, value, iteratee) {
34419       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
34420     }
34421
34422     /**
34423      * This method is like `_.indexOf` except that it performs a binary
34424      * search on a sorted `array`.
34425      *
34426      * @static
34427      * @memberOf _
34428      * @since 4.0.0
34429      * @category Array
34430      * @param {Array} array The array to inspect.
34431      * @param {*} value The value to search for.
34432      * @returns {number} Returns the index of the matched value, else `-1`.
34433      * @example
34434      *
34435      * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
34436      * // => 1
34437      */
34438     function sortedIndexOf(array, value) {
34439       var length = array == null ? 0 : array.length;
34440       if (length) {
34441         var index = baseSortedIndex(array, value);
34442         if (index < length && eq(array[index], value)) {
34443           return index;
34444         }
34445       }
34446       return -1;
34447     }
34448
34449     /**
34450      * This method is like `_.sortedIndex` except that it returns the highest
34451      * index at which `value` should be inserted into `array` in order to
34452      * maintain its sort order.
34453      *
34454      * @static
34455      * @memberOf _
34456      * @since 3.0.0
34457      * @category Array
34458      * @param {Array} array The sorted array to inspect.
34459      * @param {*} value The value to evaluate.
34460      * @returns {number} Returns the index at which `value` should be inserted
34461      *  into `array`.
34462      * @example
34463      *
34464      * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
34465      * // => 4
34466      */
34467     function sortedLastIndex(array, value) {
34468       return baseSortedIndex(array, value, true);
34469     }
34470
34471     /**
34472      * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
34473      * which is invoked for `value` and each element of `array` to compute their
34474      * sort ranking. The iteratee is invoked with one argument: (value).
34475      *
34476      * @static
34477      * @memberOf _
34478      * @since 4.0.0
34479      * @category Array
34480      * @param {Array} array The sorted array to inspect.
34481      * @param {*} value The value to evaluate.
34482      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34483      * @returns {number} Returns the index at which `value` should be inserted
34484      *  into `array`.
34485      * @example
34486      *
34487      * var objects = [{ 'x': 4 }, { 'x': 5 }];
34488      *
34489      * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
34490      * // => 1
34491      *
34492      * // The `_.property` iteratee shorthand.
34493      * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
34494      * // => 1
34495      */
34496     function sortedLastIndexBy(array, value, iteratee) {
34497       return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
34498     }
34499
34500     /**
34501      * This method is like `_.lastIndexOf` except that it performs a binary
34502      * search on a sorted `array`.
34503      *
34504      * @static
34505      * @memberOf _
34506      * @since 4.0.0
34507      * @category Array
34508      * @param {Array} array The array to inspect.
34509      * @param {*} value The value to search for.
34510      * @returns {number} Returns the index of the matched value, else `-1`.
34511      * @example
34512      *
34513      * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
34514      * // => 3
34515      */
34516     function sortedLastIndexOf(array, value) {
34517       var length = array == null ? 0 : array.length;
34518       if (length) {
34519         var index = baseSortedIndex(array, value, true) - 1;
34520         if (eq(array[index], value)) {
34521           return index;
34522         }
34523       }
34524       return -1;
34525     }
34526
34527     /**
34528      * This method is like `_.uniq` except that it's designed and optimized
34529      * for sorted arrays.
34530      *
34531      * @static
34532      * @memberOf _
34533      * @since 4.0.0
34534      * @category Array
34535      * @param {Array} array The array to inspect.
34536      * @returns {Array} Returns the new duplicate free array.
34537      * @example
34538      *
34539      * _.sortedUniq([1, 1, 2]);
34540      * // => [1, 2]
34541      */
34542     function sortedUniq(array) {
34543       return (array && array.length)
34544         ? baseSortedUniq(array)
34545         : [];
34546     }
34547
34548     /**
34549      * This method is like `_.uniqBy` except that it's designed and optimized
34550      * for sorted arrays.
34551      *
34552      * @static
34553      * @memberOf _
34554      * @since 4.0.0
34555      * @category Array
34556      * @param {Array} array The array to inspect.
34557      * @param {Function} [iteratee] The iteratee invoked per element.
34558      * @returns {Array} Returns the new duplicate free array.
34559      * @example
34560      *
34561      * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
34562      * // => [1.1, 2.3]
34563      */
34564     function sortedUniqBy(array, iteratee) {
34565       return (array && array.length)
34566         ? baseSortedUniq(array, getIteratee(iteratee, 2))
34567         : [];
34568     }
34569
34570     /**
34571      * Gets all but the first element of `array`.
34572      *
34573      * @static
34574      * @memberOf _
34575      * @since 4.0.0
34576      * @category Array
34577      * @param {Array} array The array to query.
34578      * @returns {Array} Returns the slice of `array`.
34579      * @example
34580      *
34581      * _.tail([1, 2, 3]);
34582      * // => [2, 3]
34583      */
34584     function tail(array) {
34585       var length = array == null ? 0 : array.length;
34586       return length ? baseSlice(array, 1, length) : [];
34587     }
34588
34589     /**
34590      * Creates a slice of `array` with `n` elements taken from the beginning.
34591      *
34592      * @static
34593      * @memberOf _
34594      * @since 0.1.0
34595      * @category Array
34596      * @param {Array} array The array to query.
34597      * @param {number} [n=1] The number of elements to take.
34598      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
34599      * @returns {Array} Returns the slice of `array`.
34600      * @example
34601      *
34602      * _.take([1, 2, 3]);
34603      * // => [1]
34604      *
34605      * _.take([1, 2, 3], 2);
34606      * // => [1, 2]
34607      *
34608      * _.take([1, 2, 3], 5);
34609      * // => [1, 2, 3]
34610      *
34611      * _.take([1, 2, 3], 0);
34612      * // => []
34613      */
34614     function take(array, n, guard) {
34615       if (!(array && array.length)) {
34616         return [];
34617       }
34618       n = (guard || n === undefined) ? 1 : toInteger(n);
34619       return baseSlice(array, 0, n < 0 ? 0 : n);
34620     }
34621
34622     /**
34623      * Creates a slice of `array` with `n` elements taken from the end.
34624      *
34625      * @static
34626      * @memberOf _
34627      * @since 3.0.0
34628      * @category Array
34629      * @param {Array} array The array to query.
34630      * @param {number} [n=1] The number of elements to take.
34631      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
34632      * @returns {Array} Returns the slice of `array`.
34633      * @example
34634      *
34635      * _.takeRight([1, 2, 3]);
34636      * // => [3]
34637      *
34638      * _.takeRight([1, 2, 3], 2);
34639      * // => [2, 3]
34640      *
34641      * _.takeRight([1, 2, 3], 5);
34642      * // => [1, 2, 3]
34643      *
34644      * _.takeRight([1, 2, 3], 0);
34645      * // => []
34646      */
34647     function takeRight(array, n, guard) {
34648       var length = array == null ? 0 : array.length;
34649       if (!length) {
34650         return [];
34651       }
34652       n = (guard || n === undefined) ? 1 : toInteger(n);
34653       n = length - n;
34654       return baseSlice(array, n < 0 ? 0 : n, length);
34655     }
34656
34657     /**
34658      * Creates a slice of `array` with elements taken from the end. Elements are
34659      * taken until `predicate` returns falsey. The predicate is invoked with
34660      * three arguments: (value, index, array).
34661      *
34662      * @static
34663      * @memberOf _
34664      * @since 3.0.0
34665      * @category Array
34666      * @param {Array} array The array to query.
34667      * @param {Function} [predicate=_.identity] The function invoked per iteration.
34668      * @returns {Array} Returns the slice of `array`.
34669      * @example
34670      *
34671      * var users = [
34672      *   { 'user': 'barney',  'active': true },
34673      *   { 'user': 'fred',    'active': false },
34674      *   { 'user': 'pebbles', 'active': false }
34675      * ];
34676      *
34677      * _.takeRightWhile(users, function(o) { return !o.active; });
34678      * // => objects for ['fred', 'pebbles']
34679      *
34680      * // The `_.matches` iteratee shorthand.
34681      * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
34682      * // => objects for ['pebbles']
34683      *
34684      * // The `_.matchesProperty` iteratee shorthand.
34685      * _.takeRightWhile(users, ['active', false]);
34686      * // => objects for ['fred', 'pebbles']
34687      *
34688      * // The `_.property` iteratee shorthand.
34689      * _.takeRightWhile(users, 'active');
34690      * // => []
34691      */
34692     function takeRightWhile(array, predicate) {
34693       return (array && array.length)
34694         ? baseWhile(array, getIteratee(predicate, 3), false, true)
34695         : [];
34696     }
34697
34698     /**
34699      * Creates a slice of `array` with elements taken from the beginning. Elements
34700      * are taken until `predicate` returns falsey. The predicate is invoked with
34701      * three arguments: (value, index, array).
34702      *
34703      * @static
34704      * @memberOf _
34705      * @since 3.0.0
34706      * @category Array
34707      * @param {Array} array The array to query.
34708      * @param {Function} [predicate=_.identity] The function invoked per iteration.
34709      * @returns {Array} Returns the slice of `array`.
34710      * @example
34711      *
34712      * var users = [
34713      *   { 'user': 'barney',  'active': false },
34714      *   { 'user': 'fred',    'active': false },
34715      *   { 'user': 'pebbles', 'active': true }
34716      * ];
34717      *
34718      * _.takeWhile(users, function(o) { return !o.active; });
34719      * // => objects for ['barney', 'fred']
34720      *
34721      * // The `_.matches` iteratee shorthand.
34722      * _.takeWhile(users, { 'user': 'barney', 'active': false });
34723      * // => objects for ['barney']
34724      *
34725      * // The `_.matchesProperty` iteratee shorthand.
34726      * _.takeWhile(users, ['active', false]);
34727      * // => objects for ['barney', 'fred']
34728      *
34729      * // The `_.property` iteratee shorthand.
34730      * _.takeWhile(users, 'active');
34731      * // => []
34732      */
34733     function takeWhile(array, predicate) {
34734       return (array && array.length)
34735         ? baseWhile(array, getIteratee(predicate, 3))
34736         : [];
34737     }
34738
34739     /**
34740      * Creates an array of unique values, in order, from all given arrays using
34741      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34742      * for equality comparisons.
34743      *
34744      * @static
34745      * @memberOf _
34746      * @since 0.1.0
34747      * @category Array
34748      * @param {...Array} [arrays] The arrays to inspect.
34749      * @returns {Array} Returns the new array of combined values.
34750      * @example
34751      *
34752      * _.union([2], [1, 2]);
34753      * // => [2, 1]
34754      */
34755     var union = baseRest(function(arrays) {
34756       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
34757     });
34758
34759     /**
34760      * This method is like `_.union` except that it accepts `iteratee` which is
34761      * invoked for each element of each `arrays` to generate the criterion by
34762      * which uniqueness is computed. Result values are chosen from the first
34763      * array in which the value occurs. The iteratee is invoked with one argument:
34764      * (value).
34765      *
34766      * @static
34767      * @memberOf _
34768      * @since 4.0.0
34769      * @category Array
34770      * @param {...Array} [arrays] The arrays to inspect.
34771      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34772      * @returns {Array} Returns the new array of combined values.
34773      * @example
34774      *
34775      * _.unionBy([2.1], [1.2, 2.3], Math.floor);
34776      * // => [2.1, 1.2]
34777      *
34778      * // The `_.property` iteratee shorthand.
34779      * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
34780      * // => [{ 'x': 1 }, { 'x': 2 }]
34781      */
34782     var unionBy = baseRest(function(arrays) {
34783       var iteratee = last(arrays);
34784       if (isArrayLikeObject(iteratee)) {
34785         iteratee = undefined;
34786       }
34787       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
34788     });
34789
34790     /**
34791      * This method is like `_.union` except that it accepts `comparator` which
34792      * is invoked to compare elements of `arrays`. Result values are chosen from
34793      * the first array in which the value occurs. The comparator is invoked
34794      * with two arguments: (arrVal, othVal).
34795      *
34796      * @static
34797      * @memberOf _
34798      * @since 4.0.0
34799      * @category Array
34800      * @param {...Array} [arrays] The arrays to inspect.
34801      * @param {Function} [comparator] The comparator invoked per element.
34802      * @returns {Array} Returns the new array of combined values.
34803      * @example
34804      *
34805      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
34806      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
34807      *
34808      * _.unionWith(objects, others, _.isEqual);
34809      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
34810      */
34811     var unionWith = baseRest(function(arrays) {
34812       var comparator = last(arrays);
34813       comparator = typeof comparator == 'function' ? comparator : undefined;
34814       return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
34815     });
34816
34817     /**
34818      * Creates a duplicate-free version of an array, using
34819      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34820      * for equality comparisons, in which only the first occurrence of each element
34821      * is kept. The order of result values is determined by the order they occur
34822      * in the array.
34823      *
34824      * @static
34825      * @memberOf _
34826      * @since 0.1.0
34827      * @category Array
34828      * @param {Array} array The array to inspect.
34829      * @returns {Array} Returns the new duplicate free array.
34830      * @example
34831      *
34832      * _.uniq([2, 1, 2]);
34833      * // => [2, 1]
34834      */
34835     function uniq(array) {
34836       return (array && array.length) ? baseUniq(array) : [];
34837     }
34838
34839     /**
34840      * This method is like `_.uniq` except that it accepts `iteratee` which is
34841      * invoked for each element in `array` to generate the criterion by which
34842      * uniqueness is computed. The order of result values is determined by the
34843      * order they occur in the array. The iteratee is invoked with one argument:
34844      * (value).
34845      *
34846      * @static
34847      * @memberOf _
34848      * @since 4.0.0
34849      * @category Array
34850      * @param {Array} array The array to inspect.
34851      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
34852      * @returns {Array} Returns the new duplicate free array.
34853      * @example
34854      *
34855      * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
34856      * // => [2.1, 1.2]
34857      *
34858      * // The `_.property` iteratee shorthand.
34859      * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
34860      * // => [{ 'x': 1 }, { 'x': 2 }]
34861      */
34862     function uniqBy(array, iteratee) {
34863       return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
34864     }
34865
34866     /**
34867      * This method is like `_.uniq` except that it accepts `comparator` which
34868      * is invoked to compare elements of `array`. The order of result values is
34869      * determined by the order they occur in the array.The comparator is invoked
34870      * with two arguments: (arrVal, othVal).
34871      *
34872      * @static
34873      * @memberOf _
34874      * @since 4.0.0
34875      * @category Array
34876      * @param {Array} array The array to inspect.
34877      * @param {Function} [comparator] The comparator invoked per element.
34878      * @returns {Array} Returns the new duplicate free array.
34879      * @example
34880      *
34881      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
34882      *
34883      * _.uniqWith(objects, _.isEqual);
34884      * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
34885      */
34886     function uniqWith(array, comparator) {
34887       comparator = typeof comparator == 'function' ? comparator : undefined;
34888       return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
34889     }
34890
34891     /**
34892      * This method is like `_.zip` except that it accepts an array of grouped
34893      * elements and creates an array regrouping the elements to their pre-zip
34894      * configuration.
34895      *
34896      * @static
34897      * @memberOf _
34898      * @since 1.2.0
34899      * @category Array
34900      * @param {Array} array The array of grouped elements to process.
34901      * @returns {Array} Returns the new array of regrouped elements.
34902      * @example
34903      *
34904      * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
34905      * // => [['a', 1, true], ['b', 2, false]]
34906      *
34907      * _.unzip(zipped);
34908      * // => [['a', 'b'], [1, 2], [true, false]]
34909      */
34910     function unzip(array) {
34911       if (!(array && array.length)) {
34912         return [];
34913       }
34914       var length = 0;
34915       array = arrayFilter(array, function(group) {
34916         if (isArrayLikeObject(group)) {
34917           length = nativeMax(group.length, length);
34918           return true;
34919         }
34920       });
34921       return baseTimes(length, function(index) {
34922         return arrayMap(array, baseProperty(index));
34923       });
34924     }
34925
34926     /**
34927      * This method is like `_.unzip` except that it accepts `iteratee` to specify
34928      * how regrouped values should be combined. The iteratee is invoked with the
34929      * elements of each group: (...group).
34930      *
34931      * @static
34932      * @memberOf _
34933      * @since 3.8.0
34934      * @category Array
34935      * @param {Array} array The array of grouped elements to process.
34936      * @param {Function} [iteratee=_.identity] The function to combine
34937      *  regrouped values.
34938      * @returns {Array} Returns the new array of regrouped elements.
34939      * @example
34940      *
34941      * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
34942      * // => [[1, 10, 100], [2, 20, 200]]
34943      *
34944      * _.unzipWith(zipped, _.add);
34945      * // => [3, 30, 300]
34946      */
34947     function unzipWith(array, iteratee) {
34948       if (!(array && array.length)) {
34949         return [];
34950       }
34951       var result = unzip(array);
34952       if (iteratee == null) {
34953         return result;
34954       }
34955       return arrayMap(result, function(group) {
34956         return apply(iteratee, undefined, group);
34957       });
34958     }
34959
34960     /**
34961      * Creates an array excluding all given values using
34962      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
34963      * for equality comparisons.
34964      *
34965      * **Note:** Unlike `_.pull`, this method returns a new array.
34966      *
34967      * @static
34968      * @memberOf _
34969      * @since 0.1.0
34970      * @category Array
34971      * @param {Array} array The array to inspect.
34972      * @param {...*} [values] The values to exclude.
34973      * @returns {Array} Returns the new array of filtered values.
34974      * @see _.difference, _.xor
34975      * @example
34976      *
34977      * _.without([2, 1, 2, 3], 1, 2);
34978      * // => [3]
34979      */
34980     var without = baseRest(function(array, values) {
34981       return isArrayLikeObject(array)
34982         ? baseDifference(array, values)
34983         : [];
34984     });
34985
34986     /**
34987      * Creates an array of unique values that is the
34988      * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
34989      * of the given arrays. The order of result values is determined by the order
34990      * they occur in the arrays.
34991      *
34992      * @static
34993      * @memberOf _
34994      * @since 2.4.0
34995      * @category Array
34996      * @param {...Array} [arrays] The arrays to inspect.
34997      * @returns {Array} Returns the new array of filtered values.
34998      * @see _.difference, _.without
34999      * @example
35000      *
35001      * _.xor([2, 1], [2, 3]);
35002      * // => [1, 3]
35003      */
35004     var xor = baseRest(function(arrays) {
35005       return baseXor(arrayFilter(arrays, isArrayLikeObject));
35006     });
35007
35008     /**
35009      * This method is like `_.xor` except that it accepts `iteratee` which is
35010      * invoked for each element of each `arrays` to generate the criterion by
35011      * which by which they're compared. The order of result values is determined
35012      * by the order they occur in the arrays. The iteratee is invoked with one
35013      * argument: (value).
35014      *
35015      * @static
35016      * @memberOf _
35017      * @since 4.0.0
35018      * @category Array
35019      * @param {...Array} [arrays] The arrays to inspect.
35020      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
35021      * @returns {Array} Returns the new array of filtered values.
35022      * @example
35023      *
35024      * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
35025      * // => [1.2, 3.4]
35026      *
35027      * // The `_.property` iteratee shorthand.
35028      * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
35029      * // => [{ 'x': 2 }]
35030      */
35031     var xorBy = baseRest(function(arrays) {
35032       var iteratee = last(arrays);
35033       if (isArrayLikeObject(iteratee)) {
35034         iteratee = undefined;
35035       }
35036       return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
35037     });
35038
35039     /**
35040      * This method is like `_.xor` except that it accepts `comparator` which is
35041      * invoked to compare elements of `arrays`. The order of result values is
35042      * determined by the order they occur in the arrays. The comparator is invoked
35043      * with two arguments: (arrVal, othVal).
35044      *
35045      * @static
35046      * @memberOf _
35047      * @since 4.0.0
35048      * @category Array
35049      * @param {...Array} [arrays] The arrays to inspect.
35050      * @param {Function} [comparator] The comparator invoked per element.
35051      * @returns {Array} Returns the new array of filtered values.
35052      * @example
35053      *
35054      * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
35055      * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
35056      *
35057      * _.xorWith(objects, others, _.isEqual);
35058      * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
35059      */
35060     var xorWith = baseRest(function(arrays) {
35061       var comparator = last(arrays);
35062       comparator = typeof comparator == 'function' ? comparator : undefined;
35063       return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
35064     });
35065
35066     /**
35067      * Creates an array of grouped elements, the first of which contains the
35068      * first elements of the given arrays, the second of which contains the
35069      * second elements of the given arrays, and so on.
35070      *
35071      * @static
35072      * @memberOf _
35073      * @since 0.1.0
35074      * @category Array
35075      * @param {...Array} [arrays] The arrays to process.
35076      * @returns {Array} Returns the new array of grouped elements.
35077      * @example
35078      *
35079      * _.zip(['a', 'b'], [1, 2], [true, false]);
35080      * // => [['a', 1, true], ['b', 2, false]]
35081      */
35082     var zip = baseRest(unzip);
35083
35084     /**
35085      * This method is like `_.fromPairs` except that it accepts two arrays,
35086      * one of property identifiers and one of corresponding values.
35087      *
35088      * @static
35089      * @memberOf _
35090      * @since 0.4.0
35091      * @category Array
35092      * @param {Array} [props=[]] The property identifiers.
35093      * @param {Array} [values=[]] The property values.
35094      * @returns {Object} Returns the new object.
35095      * @example
35096      *
35097      * _.zipObject(['a', 'b'], [1, 2]);
35098      * // => { 'a': 1, 'b': 2 }
35099      */
35100     function zipObject(props, values) {
35101       return baseZipObject(props || [], values || [], assignValue);
35102     }
35103
35104     /**
35105      * This method is like `_.zipObject` except that it supports property paths.
35106      *
35107      * @static
35108      * @memberOf _
35109      * @since 4.1.0
35110      * @category Array
35111      * @param {Array} [props=[]] The property identifiers.
35112      * @param {Array} [values=[]] The property values.
35113      * @returns {Object} Returns the new object.
35114      * @example
35115      *
35116      * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
35117      * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
35118      */
35119     function zipObjectDeep(props, values) {
35120       return baseZipObject(props || [], values || [], baseSet);
35121     }
35122
35123     /**
35124      * This method is like `_.zip` except that it accepts `iteratee` to specify
35125      * how grouped values should be combined. The iteratee is invoked with the
35126      * elements of each group: (...group).
35127      *
35128      * @static
35129      * @memberOf _
35130      * @since 3.8.0
35131      * @category Array
35132      * @param {...Array} [arrays] The arrays to process.
35133      * @param {Function} [iteratee=_.identity] The function to combine
35134      *  grouped values.
35135      * @returns {Array} Returns the new array of grouped elements.
35136      * @example
35137      *
35138      * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
35139      *   return a + b + c;
35140      * });
35141      * // => [111, 222]
35142      */
35143     var zipWith = baseRest(function(arrays) {
35144       var length = arrays.length,
35145           iteratee = length > 1 ? arrays[length - 1] : undefined;
35146
35147       iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
35148       return unzipWith(arrays, iteratee);
35149     });
35150
35151     /*------------------------------------------------------------------------*/
35152
35153     /**
35154      * Creates a `lodash` wrapper instance that wraps `value` with explicit method
35155      * chain sequences enabled. The result of such sequences must be unwrapped
35156      * with `_#value`.
35157      *
35158      * @static
35159      * @memberOf _
35160      * @since 1.3.0
35161      * @category Seq
35162      * @param {*} value The value to wrap.
35163      * @returns {Object} Returns the new `lodash` wrapper instance.
35164      * @example
35165      *
35166      * var users = [
35167      *   { 'user': 'barney',  'age': 36 },
35168      *   { 'user': 'fred',    'age': 40 },
35169      *   { 'user': 'pebbles', 'age': 1 }
35170      * ];
35171      *
35172      * var youngest = _
35173      *   .chain(users)
35174      *   .sortBy('age')
35175      *   .map(function(o) {
35176      *     return o.user + ' is ' + o.age;
35177      *   })
35178      *   .head()
35179      *   .value();
35180      * // => 'pebbles is 1'
35181      */
35182     function chain(value) {
35183       var result = lodash(value);
35184       result.__chain__ = true;
35185       return result;
35186     }
35187
35188     /**
35189      * This method invokes `interceptor` and returns `value`. The interceptor
35190      * is invoked with one argument; (value). The purpose of this method is to
35191      * "tap into" a method chain sequence in order to modify intermediate results.
35192      *
35193      * @static
35194      * @memberOf _
35195      * @since 0.1.0
35196      * @category Seq
35197      * @param {*} value The value to provide to `interceptor`.
35198      * @param {Function} interceptor The function to invoke.
35199      * @returns {*} Returns `value`.
35200      * @example
35201      *
35202      * _([1, 2, 3])
35203      *  .tap(function(array) {
35204      *    // Mutate input array.
35205      *    array.pop();
35206      *  })
35207      *  .reverse()
35208      *  .value();
35209      * // => [2, 1]
35210      */
35211     function tap(value, interceptor) {
35212       interceptor(value);
35213       return value;
35214     }
35215
35216     /**
35217      * This method is like `_.tap` except that it returns the result of `interceptor`.
35218      * The purpose of this method is to "pass thru" values replacing intermediate
35219      * results in a method chain sequence.
35220      *
35221      * @static
35222      * @memberOf _
35223      * @since 3.0.0
35224      * @category Seq
35225      * @param {*} value The value to provide to `interceptor`.
35226      * @param {Function} interceptor The function to invoke.
35227      * @returns {*} Returns the result of `interceptor`.
35228      * @example
35229      *
35230      * _('  abc  ')
35231      *  .chain()
35232      *  .trim()
35233      *  .thru(function(value) {
35234      *    return [value];
35235      *  })
35236      *  .value();
35237      * // => ['abc']
35238      */
35239     function thru(value, interceptor) {
35240       return interceptor(value);
35241     }
35242
35243     /**
35244      * This method is the wrapper version of `_.at`.
35245      *
35246      * @name at
35247      * @memberOf _
35248      * @since 1.0.0
35249      * @category Seq
35250      * @param {...(string|string[])} [paths] The property paths to pick.
35251      * @returns {Object} Returns the new `lodash` wrapper instance.
35252      * @example
35253      *
35254      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
35255      *
35256      * _(object).at(['a[0].b.c', 'a[1]']).value();
35257      * // => [3, 4]
35258      */
35259     var wrapperAt = flatRest(function(paths) {
35260       var length = paths.length,
35261           start = length ? paths[0] : 0,
35262           value = this.__wrapped__,
35263           interceptor = function(object) { return baseAt(object, paths); };
35264
35265       if (length > 1 || this.__actions__.length ||
35266           !(value instanceof LazyWrapper) || !isIndex(start)) {
35267         return this.thru(interceptor);
35268       }
35269       value = value.slice(start, +start + (length ? 1 : 0));
35270       value.__actions__.push({
35271         'func': thru,
35272         'args': [interceptor],
35273         'thisArg': undefined
35274       });
35275       return new LodashWrapper(value, this.__chain__).thru(function(array) {
35276         if (length && !array.length) {
35277           array.push(undefined);
35278         }
35279         return array;
35280       });
35281     });
35282
35283     /**
35284      * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
35285      *
35286      * @name chain
35287      * @memberOf _
35288      * @since 0.1.0
35289      * @category Seq
35290      * @returns {Object} Returns the new `lodash` wrapper instance.
35291      * @example
35292      *
35293      * var users = [
35294      *   { 'user': 'barney', 'age': 36 },
35295      *   { 'user': 'fred',   'age': 40 }
35296      * ];
35297      *
35298      * // A sequence without explicit chaining.
35299      * _(users).head();
35300      * // => { 'user': 'barney', 'age': 36 }
35301      *
35302      * // A sequence with explicit chaining.
35303      * _(users)
35304      *   .chain()
35305      *   .head()
35306      *   .pick('user')
35307      *   .value();
35308      * // => { 'user': 'barney' }
35309      */
35310     function wrapperChain() {
35311       return chain(this);
35312     }
35313
35314     /**
35315      * Executes the chain sequence and returns the wrapped result.
35316      *
35317      * @name commit
35318      * @memberOf _
35319      * @since 3.2.0
35320      * @category Seq
35321      * @returns {Object} Returns the new `lodash` wrapper instance.
35322      * @example
35323      *
35324      * var array = [1, 2];
35325      * var wrapped = _(array).push(3);
35326      *
35327      * console.log(array);
35328      * // => [1, 2]
35329      *
35330      * wrapped = wrapped.commit();
35331      * console.log(array);
35332      * // => [1, 2, 3]
35333      *
35334      * wrapped.last();
35335      * // => 3
35336      *
35337      * console.log(array);
35338      * // => [1, 2, 3]
35339      */
35340     function wrapperCommit() {
35341       return new LodashWrapper(this.value(), this.__chain__);
35342     }
35343
35344     /**
35345      * Gets the next value on a wrapped object following the
35346      * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
35347      *
35348      * @name next
35349      * @memberOf _
35350      * @since 4.0.0
35351      * @category Seq
35352      * @returns {Object} Returns the next iterator value.
35353      * @example
35354      *
35355      * var wrapped = _([1, 2]);
35356      *
35357      * wrapped.next();
35358      * // => { 'done': false, 'value': 1 }
35359      *
35360      * wrapped.next();
35361      * // => { 'done': false, 'value': 2 }
35362      *
35363      * wrapped.next();
35364      * // => { 'done': true, 'value': undefined }
35365      */
35366     function wrapperNext() {
35367       if (this.__values__ === undefined) {
35368         this.__values__ = toArray(this.value());
35369       }
35370       var done = this.__index__ >= this.__values__.length,
35371           value = done ? undefined : this.__values__[this.__index__++];
35372
35373       return { 'done': done, 'value': value };
35374     }
35375
35376     /**
35377      * Enables the wrapper to be iterable.
35378      *
35379      * @name Symbol.iterator
35380      * @memberOf _
35381      * @since 4.0.0
35382      * @category Seq
35383      * @returns {Object} Returns the wrapper object.
35384      * @example
35385      *
35386      * var wrapped = _([1, 2]);
35387      *
35388      * wrapped[Symbol.iterator]() === wrapped;
35389      * // => true
35390      *
35391      * Array.from(wrapped);
35392      * // => [1, 2]
35393      */
35394     function wrapperToIterator() {
35395       return this;
35396     }
35397
35398     /**
35399      * Creates a clone of the chain sequence planting `value` as the wrapped value.
35400      *
35401      * @name plant
35402      * @memberOf _
35403      * @since 3.2.0
35404      * @category Seq
35405      * @param {*} value The value to plant.
35406      * @returns {Object} Returns the new `lodash` wrapper instance.
35407      * @example
35408      *
35409      * function square(n) {
35410      *   return n * n;
35411      * }
35412      *
35413      * var wrapped = _([1, 2]).map(square);
35414      * var other = wrapped.plant([3, 4]);
35415      *
35416      * other.value();
35417      * // => [9, 16]
35418      *
35419      * wrapped.value();
35420      * // => [1, 4]
35421      */
35422     function wrapperPlant(value) {
35423       var result,
35424           parent = this;
35425
35426       while (parent instanceof baseLodash) {
35427         var clone = wrapperClone(parent);
35428         clone.__index__ = 0;
35429         clone.__values__ = undefined;
35430         if (result) {
35431           previous.__wrapped__ = clone;
35432         } else {
35433           result = clone;
35434         }
35435         var previous = clone;
35436         parent = parent.__wrapped__;
35437       }
35438       previous.__wrapped__ = value;
35439       return result;
35440     }
35441
35442     /**
35443      * This method is the wrapper version of `_.reverse`.
35444      *
35445      * **Note:** This method mutates the wrapped array.
35446      *
35447      * @name reverse
35448      * @memberOf _
35449      * @since 0.1.0
35450      * @category Seq
35451      * @returns {Object} Returns the new `lodash` wrapper instance.
35452      * @example
35453      *
35454      * var array = [1, 2, 3];
35455      *
35456      * _(array).reverse().value()
35457      * // => [3, 2, 1]
35458      *
35459      * console.log(array);
35460      * // => [3, 2, 1]
35461      */
35462     function wrapperReverse() {
35463       var value = this.__wrapped__;
35464       if (value instanceof LazyWrapper) {
35465         var wrapped = value;
35466         if (this.__actions__.length) {
35467           wrapped = new LazyWrapper(this);
35468         }
35469         wrapped = wrapped.reverse();
35470         wrapped.__actions__.push({
35471           'func': thru,
35472           'args': [reverse],
35473           'thisArg': undefined
35474         });
35475         return new LodashWrapper(wrapped, this.__chain__);
35476       }
35477       return this.thru(reverse);
35478     }
35479
35480     /**
35481      * Executes the chain sequence to resolve the unwrapped value.
35482      *
35483      * @name value
35484      * @memberOf _
35485      * @since 0.1.0
35486      * @alias toJSON, valueOf
35487      * @category Seq
35488      * @returns {*} Returns the resolved unwrapped value.
35489      * @example
35490      *
35491      * _([1, 2, 3]).value();
35492      * // => [1, 2, 3]
35493      */
35494     function wrapperValue() {
35495       return baseWrapperValue(this.__wrapped__, this.__actions__);
35496     }
35497
35498     /*------------------------------------------------------------------------*/
35499
35500     /**
35501      * Creates an object composed of keys generated from the results of running
35502      * each element of `collection` thru `iteratee`. The corresponding value of
35503      * each key is the number of times the key was returned by `iteratee`. The
35504      * iteratee is invoked with one argument: (value).
35505      *
35506      * @static
35507      * @memberOf _
35508      * @since 0.5.0
35509      * @category Collection
35510      * @param {Array|Object} collection The collection to iterate over.
35511      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
35512      * @returns {Object} Returns the composed aggregate object.
35513      * @example
35514      *
35515      * _.countBy([6.1, 4.2, 6.3], Math.floor);
35516      * // => { '4': 1, '6': 2 }
35517      *
35518      * // The `_.property` iteratee shorthand.
35519      * _.countBy(['one', 'two', 'three'], 'length');
35520      * // => { '3': 2, '5': 1 }
35521      */
35522     var countBy = createAggregator(function(result, value, key) {
35523       if (hasOwnProperty.call(result, key)) {
35524         ++result[key];
35525       } else {
35526         baseAssignValue(result, key, 1);
35527       }
35528     });
35529
35530     /**
35531      * Checks if `predicate` returns truthy for **all** elements of `collection`.
35532      * Iteration is stopped once `predicate` returns falsey. The predicate is
35533      * invoked with three arguments: (value, index|key, collection).
35534      *
35535      * **Note:** This method returns `true` for
35536      * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
35537      * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
35538      * elements of empty collections.
35539      *
35540      * @static
35541      * @memberOf _
35542      * @since 0.1.0
35543      * @category Collection
35544      * @param {Array|Object} collection The collection to iterate over.
35545      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35546      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
35547      * @returns {boolean} Returns `true` if all elements pass the predicate check,
35548      *  else `false`.
35549      * @example
35550      *
35551      * _.every([true, 1, null, 'yes'], Boolean);
35552      * // => false
35553      *
35554      * var users = [
35555      *   { 'user': 'barney', 'age': 36, 'active': false },
35556      *   { 'user': 'fred',   'age': 40, 'active': false }
35557      * ];
35558      *
35559      * // The `_.matches` iteratee shorthand.
35560      * _.every(users, { 'user': 'barney', 'active': false });
35561      * // => false
35562      *
35563      * // The `_.matchesProperty` iteratee shorthand.
35564      * _.every(users, ['active', false]);
35565      * // => true
35566      *
35567      * // The `_.property` iteratee shorthand.
35568      * _.every(users, 'active');
35569      * // => false
35570      */
35571     function every(collection, predicate, guard) {
35572       var func = isArray(collection) ? arrayEvery : baseEvery;
35573       if (guard && isIterateeCall(collection, predicate, guard)) {
35574         predicate = undefined;
35575       }
35576       return func(collection, getIteratee(predicate, 3));
35577     }
35578
35579     /**
35580      * Iterates over elements of `collection`, returning an array of all elements
35581      * `predicate` returns truthy for. The predicate is invoked with three
35582      * arguments: (value, index|key, collection).
35583      *
35584      * **Note:** Unlike `_.remove`, this method returns a new array.
35585      *
35586      * @static
35587      * @memberOf _
35588      * @since 0.1.0
35589      * @category Collection
35590      * @param {Array|Object} collection The collection to iterate over.
35591      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35592      * @returns {Array} Returns the new filtered array.
35593      * @see _.reject
35594      * @example
35595      *
35596      * var users = [
35597      *   { 'user': 'barney', 'age': 36, 'active': true },
35598      *   { 'user': 'fred',   'age': 40, 'active': false }
35599      * ];
35600      *
35601      * _.filter(users, function(o) { return !o.active; });
35602      * // => objects for ['fred']
35603      *
35604      * // The `_.matches` iteratee shorthand.
35605      * _.filter(users, { 'age': 36, 'active': true });
35606      * // => objects for ['barney']
35607      *
35608      * // The `_.matchesProperty` iteratee shorthand.
35609      * _.filter(users, ['active', false]);
35610      * // => objects for ['fred']
35611      *
35612      * // The `_.property` iteratee shorthand.
35613      * _.filter(users, 'active');
35614      * // => objects for ['barney']
35615      */
35616     function filter(collection, predicate) {
35617       var func = isArray(collection) ? arrayFilter : baseFilter;
35618       return func(collection, getIteratee(predicate, 3));
35619     }
35620
35621     /**
35622      * Iterates over elements of `collection`, returning the first element
35623      * `predicate` returns truthy for. The predicate is invoked with three
35624      * arguments: (value, index|key, collection).
35625      *
35626      * @static
35627      * @memberOf _
35628      * @since 0.1.0
35629      * @category Collection
35630      * @param {Array|Object} collection The collection to inspect.
35631      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35632      * @param {number} [fromIndex=0] The index to search from.
35633      * @returns {*} Returns the matched element, else `undefined`.
35634      * @example
35635      *
35636      * var users = [
35637      *   { 'user': 'barney',  'age': 36, 'active': true },
35638      *   { 'user': 'fred',    'age': 40, 'active': false },
35639      *   { 'user': 'pebbles', 'age': 1,  'active': true }
35640      * ];
35641      *
35642      * _.find(users, function(o) { return o.age < 40; });
35643      * // => object for 'barney'
35644      *
35645      * // The `_.matches` iteratee shorthand.
35646      * _.find(users, { 'age': 1, 'active': true });
35647      * // => object for 'pebbles'
35648      *
35649      * // The `_.matchesProperty` iteratee shorthand.
35650      * _.find(users, ['active', false]);
35651      * // => object for 'fred'
35652      *
35653      * // The `_.property` iteratee shorthand.
35654      * _.find(users, 'active');
35655      * // => object for 'barney'
35656      */
35657     var find = createFind(findIndex);
35658
35659     /**
35660      * This method is like `_.find` except that it iterates over elements of
35661      * `collection` from right to left.
35662      *
35663      * @static
35664      * @memberOf _
35665      * @since 2.0.0
35666      * @category Collection
35667      * @param {Array|Object} collection The collection to inspect.
35668      * @param {Function} [predicate=_.identity] The function invoked per iteration.
35669      * @param {number} [fromIndex=collection.length-1] The index to search from.
35670      * @returns {*} Returns the matched element, else `undefined`.
35671      * @example
35672      *
35673      * _.findLast([1, 2, 3, 4], function(n) {
35674      *   return n % 2 == 1;
35675      * });
35676      * // => 3
35677      */
35678     var findLast = createFind(findLastIndex);
35679
35680     /**
35681      * Creates a flattened array of values by running each element in `collection`
35682      * thru `iteratee` and flattening the mapped results. The iteratee is invoked
35683      * with three arguments: (value, index|key, collection).
35684      *
35685      * @static
35686      * @memberOf _
35687      * @since 4.0.0
35688      * @category Collection
35689      * @param {Array|Object} collection The collection to iterate over.
35690      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35691      * @returns {Array} Returns the new flattened array.
35692      * @example
35693      *
35694      * function duplicate(n) {
35695      *   return [n, n];
35696      * }
35697      *
35698      * _.flatMap([1, 2], duplicate);
35699      * // => [1, 1, 2, 2]
35700      */
35701     function flatMap(collection, iteratee) {
35702       return baseFlatten(map(collection, iteratee), 1);
35703     }
35704
35705     /**
35706      * This method is like `_.flatMap` except that it recursively flattens the
35707      * mapped results.
35708      *
35709      * @static
35710      * @memberOf _
35711      * @since 4.7.0
35712      * @category Collection
35713      * @param {Array|Object} collection The collection to iterate over.
35714      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35715      * @returns {Array} Returns the new flattened array.
35716      * @example
35717      *
35718      * function duplicate(n) {
35719      *   return [[[n, n]]];
35720      * }
35721      *
35722      * _.flatMapDeep([1, 2], duplicate);
35723      * // => [1, 1, 2, 2]
35724      */
35725     function flatMapDeep(collection, iteratee) {
35726       return baseFlatten(map(collection, iteratee), INFINITY);
35727     }
35728
35729     /**
35730      * This method is like `_.flatMap` except that it recursively flattens the
35731      * mapped results up to `depth` times.
35732      *
35733      * @static
35734      * @memberOf _
35735      * @since 4.7.0
35736      * @category Collection
35737      * @param {Array|Object} collection The collection to iterate over.
35738      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35739      * @param {number} [depth=1] The maximum recursion depth.
35740      * @returns {Array} Returns the new flattened array.
35741      * @example
35742      *
35743      * function duplicate(n) {
35744      *   return [[[n, n]]];
35745      * }
35746      *
35747      * _.flatMapDepth([1, 2], duplicate, 2);
35748      * // => [[1, 1], [2, 2]]
35749      */
35750     function flatMapDepth(collection, iteratee, depth) {
35751       depth = depth === undefined ? 1 : toInteger(depth);
35752       return baseFlatten(map(collection, iteratee), depth);
35753     }
35754
35755     /**
35756      * Iterates over elements of `collection` and invokes `iteratee` for each element.
35757      * The iteratee is invoked with three arguments: (value, index|key, collection).
35758      * Iteratee functions may exit iteration early by explicitly returning `false`.
35759      *
35760      * **Note:** As with other "Collections" methods, objects with a "length"
35761      * property are iterated like arrays. To avoid this behavior use `_.forIn`
35762      * or `_.forOwn` for object iteration.
35763      *
35764      * @static
35765      * @memberOf _
35766      * @since 0.1.0
35767      * @alias each
35768      * @category Collection
35769      * @param {Array|Object} collection The collection to iterate over.
35770      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35771      * @returns {Array|Object} Returns `collection`.
35772      * @see _.forEachRight
35773      * @example
35774      *
35775      * _.forEach([1, 2], function(value) {
35776      *   console.log(value);
35777      * });
35778      * // => Logs `1` then `2`.
35779      *
35780      * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
35781      *   console.log(key);
35782      * });
35783      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
35784      */
35785     function forEach(collection, iteratee) {
35786       var func = isArray(collection) ? arrayEach : baseEach;
35787       return func(collection, getIteratee(iteratee, 3));
35788     }
35789
35790     /**
35791      * This method is like `_.forEach` except that it iterates over elements of
35792      * `collection` from right to left.
35793      *
35794      * @static
35795      * @memberOf _
35796      * @since 2.0.0
35797      * @alias eachRight
35798      * @category Collection
35799      * @param {Array|Object} collection The collection to iterate over.
35800      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35801      * @returns {Array|Object} Returns `collection`.
35802      * @see _.forEach
35803      * @example
35804      *
35805      * _.forEachRight([1, 2], function(value) {
35806      *   console.log(value);
35807      * });
35808      * // => Logs `2` then `1`.
35809      */
35810     function forEachRight(collection, iteratee) {
35811       var func = isArray(collection) ? arrayEachRight : baseEachRight;
35812       return func(collection, getIteratee(iteratee, 3));
35813     }
35814
35815     /**
35816      * Creates an object composed of keys generated from the results of running
35817      * each element of `collection` thru `iteratee`. The order of grouped values
35818      * is determined by the order they occur in `collection`. The corresponding
35819      * value of each key is an array of elements responsible for generating the
35820      * key. The iteratee is invoked with one argument: (value).
35821      *
35822      * @static
35823      * @memberOf _
35824      * @since 0.1.0
35825      * @category Collection
35826      * @param {Array|Object} collection The collection to iterate over.
35827      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
35828      * @returns {Object} Returns the composed aggregate object.
35829      * @example
35830      *
35831      * _.groupBy([6.1, 4.2, 6.3], Math.floor);
35832      * // => { '4': [4.2], '6': [6.1, 6.3] }
35833      *
35834      * // The `_.property` iteratee shorthand.
35835      * _.groupBy(['one', 'two', 'three'], 'length');
35836      * // => { '3': ['one', 'two'], '5': ['three'] }
35837      */
35838     var groupBy = createAggregator(function(result, value, key) {
35839       if (hasOwnProperty.call(result, key)) {
35840         result[key].push(value);
35841       } else {
35842         baseAssignValue(result, key, [value]);
35843       }
35844     });
35845
35846     /**
35847      * Checks if `value` is in `collection`. If `collection` is a string, it's
35848      * checked for a substring of `value`, otherwise
35849      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
35850      * is used for equality comparisons. If `fromIndex` is negative, it's used as
35851      * the offset from the end of `collection`.
35852      *
35853      * @static
35854      * @memberOf _
35855      * @since 0.1.0
35856      * @category Collection
35857      * @param {Array|Object|string} collection The collection to inspect.
35858      * @param {*} value The value to search for.
35859      * @param {number} [fromIndex=0] The index to search from.
35860      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
35861      * @returns {boolean} Returns `true` if `value` is found, else `false`.
35862      * @example
35863      *
35864      * _.includes([1, 2, 3], 1);
35865      * // => true
35866      *
35867      * _.includes([1, 2, 3], 1, 2);
35868      * // => false
35869      *
35870      * _.includes({ 'a': 1, 'b': 2 }, 1);
35871      * // => true
35872      *
35873      * _.includes('abcd', 'bc');
35874      * // => true
35875      */
35876     function includes(collection, value, fromIndex, guard) {
35877       collection = isArrayLike(collection) ? collection : values(collection);
35878       fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
35879
35880       var length = collection.length;
35881       if (fromIndex < 0) {
35882         fromIndex = nativeMax(length + fromIndex, 0);
35883       }
35884       return isString(collection)
35885         ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
35886         : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
35887     }
35888
35889     /**
35890      * Invokes the method at `path` of each element in `collection`, returning
35891      * an array of the results of each invoked method. Any additional arguments
35892      * are provided to each invoked method. If `path` is a function, it's invoked
35893      * for, and `this` bound to, each element in `collection`.
35894      *
35895      * @static
35896      * @memberOf _
35897      * @since 4.0.0
35898      * @category Collection
35899      * @param {Array|Object} collection The collection to iterate over.
35900      * @param {Array|Function|string} path The path of the method to invoke or
35901      *  the function invoked per iteration.
35902      * @param {...*} [args] The arguments to invoke each method with.
35903      * @returns {Array} Returns the array of results.
35904      * @example
35905      *
35906      * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
35907      * // => [[1, 5, 7], [1, 2, 3]]
35908      *
35909      * _.invokeMap([123, 456], String.prototype.split, '');
35910      * // => [['1', '2', '3'], ['4', '5', '6']]
35911      */
35912     var invokeMap = baseRest(function(collection, path, args) {
35913       var index = -1,
35914           isFunc = typeof path == 'function',
35915           result = isArrayLike(collection) ? Array(collection.length) : [];
35916
35917       baseEach(collection, function(value) {
35918         result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
35919       });
35920       return result;
35921     });
35922
35923     /**
35924      * Creates an object composed of keys generated from the results of running
35925      * each element of `collection` thru `iteratee`. The corresponding value of
35926      * each key is the last element responsible for generating the key. The
35927      * iteratee is invoked with one argument: (value).
35928      *
35929      * @static
35930      * @memberOf _
35931      * @since 4.0.0
35932      * @category Collection
35933      * @param {Array|Object} collection The collection to iterate over.
35934      * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
35935      * @returns {Object} Returns the composed aggregate object.
35936      * @example
35937      *
35938      * var array = [
35939      *   { 'dir': 'left', 'code': 97 },
35940      *   { 'dir': 'right', 'code': 100 }
35941      * ];
35942      *
35943      * _.keyBy(array, function(o) {
35944      *   return String.fromCharCode(o.code);
35945      * });
35946      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
35947      *
35948      * _.keyBy(array, 'dir');
35949      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
35950      */
35951     var keyBy = createAggregator(function(result, value, key) {
35952       baseAssignValue(result, key, value);
35953     });
35954
35955     /**
35956      * Creates an array of values by running each element in `collection` thru
35957      * `iteratee`. The iteratee is invoked with three arguments:
35958      * (value, index|key, collection).
35959      *
35960      * Many lodash methods are guarded to work as iteratees for methods like
35961      * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
35962      *
35963      * The guarded methods are:
35964      * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
35965      * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
35966      * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
35967      * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
35968      *
35969      * @static
35970      * @memberOf _
35971      * @since 0.1.0
35972      * @category Collection
35973      * @param {Array|Object} collection The collection to iterate over.
35974      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
35975      * @returns {Array} Returns the new mapped array.
35976      * @example
35977      *
35978      * function square(n) {
35979      *   return n * n;
35980      * }
35981      *
35982      * _.map([4, 8], square);
35983      * // => [16, 64]
35984      *
35985      * _.map({ 'a': 4, 'b': 8 }, square);
35986      * // => [16, 64] (iteration order is not guaranteed)
35987      *
35988      * var users = [
35989      *   { 'user': 'barney' },
35990      *   { 'user': 'fred' }
35991      * ];
35992      *
35993      * // The `_.property` iteratee shorthand.
35994      * _.map(users, 'user');
35995      * // => ['barney', 'fred']
35996      */
35997     function map(collection, iteratee) {
35998       var func = isArray(collection) ? arrayMap : baseMap;
35999       return func(collection, getIteratee(iteratee, 3));
36000     }
36001
36002     /**
36003      * This method is like `_.sortBy` except that it allows specifying the sort
36004      * orders of the iteratees to sort by. If `orders` is unspecified, all values
36005      * are sorted in ascending order. Otherwise, specify an order of "desc" for
36006      * descending or "asc" for ascending sort order of corresponding values.
36007      *
36008      * @static
36009      * @memberOf _
36010      * @since 4.0.0
36011      * @category Collection
36012      * @param {Array|Object} collection The collection to iterate over.
36013      * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
36014      *  The iteratees to sort by.
36015      * @param {string[]} [orders] The sort orders of `iteratees`.
36016      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
36017      * @returns {Array} Returns the new sorted array.
36018      * @example
36019      *
36020      * var users = [
36021      *   { 'user': 'fred',   'age': 48 },
36022      *   { 'user': 'barney', 'age': 34 },
36023      *   { 'user': 'fred',   'age': 40 },
36024      *   { 'user': 'barney', 'age': 36 }
36025      * ];
36026      *
36027      * // Sort by `user` in ascending order and by `age` in descending order.
36028      * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
36029      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
36030      */
36031     function orderBy(collection, iteratees, orders, guard) {
36032       if (collection == null) {
36033         return [];
36034       }
36035       if (!isArray(iteratees)) {
36036         iteratees = iteratees == null ? [] : [iteratees];
36037       }
36038       orders = guard ? undefined : orders;
36039       if (!isArray(orders)) {
36040         orders = orders == null ? [] : [orders];
36041       }
36042       return baseOrderBy(collection, iteratees, orders);
36043     }
36044
36045     /**
36046      * Creates an array of elements split into two groups, the first of which
36047      * contains elements `predicate` returns truthy for, the second of which
36048      * contains elements `predicate` returns falsey for. The predicate is
36049      * invoked with one argument: (value).
36050      *
36051      * @static
36052      * @memberOf _
36053      * @since 3.0.0
36054      * @category Collection
36055      * @param {Array|Object} collection The collection to iterate over.
36056      * @param {Function} [predicate=_.identity] The function invoked per iteration.
36057      * @returns {Array} Returns the array of grouped elements.
36058      * @example
36059      *
36060      * var users = [
36061      *   { 'user': 'barney',  'age': 36, 'active': false },
36062      *   { 'user': 'fred',    'age': 40, 'active': true },
36063      *   { 'user': 'pebbles', 'age': 1,  'active': false }
36064      * ];
36065      *
36066      * _.partition(users, function(o) { return o.active; });
36067      * // => objects for [['fred'], ['barney', 'pebbles']]
36068      *
36069      * // The `_.matches` iteratee shorthand.
36070      * _.partition(users, { 'age': 1, 'active': false });
36071      * // => objects for [['pebbles'], ['barney', 'fred']]
36072      *
36073      * // The `_.matchesProperty` iteratee shorthand.
36074      * _.partition(users, ['active', false]);
36075      * // => objects for [['barney', 'pebbles'], ['fred']]
36076      *
36077      * // The `_.property` iteratee shorthand.
36078      * _.partition(users, 'active');
36079      * // => objects for [['fred'], ['barney', 'pebbles']]
36080      */
36081     var partition = createAggregator(function(result, value, key) {
36082       result[key ? 0 : 1].push(value);
36083     }, function() { return [[], []]; });
36084
36085     /**
36086      * Reduces `collection` to a value which is the accumulated result of running
36087      * each element in `collection` thru `iteratee`, where each successive
36088      * invocation is supplied the return value of the previous. If `accumulator`
36089      * is not given, the first element of `collection` is used as the initial
36090      * value. The iteratee is invoked with four arguments:
36091      * (accumulator, value, index|key, collection).
36092      *
36093      * Many lodash methods are guarded to work as iteratees for methods like
36094      * `_.reduce`, `_.reduceRight`, and `_.transform`.
36095      *
36096      * The guarded methods are:
36097      * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
36098      * and `sortBy`
36099      *
36100      * @static
36101      * @memberOf _
36102      * @since 0.1.0
36103      * @category Collection
36104      * @param {Array|Object} collection The collection to iterate over.
36105      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
36106      * @param {*} [accumulator] The initial value.
36107      * @returns {*} Returns the accumulated value.
36108      * @see _.reduceRight
36109      * @example
36110      *
36111      * _.reduce([1, 2], function(sum, n) {
36112      *   return sum + n;
36113      * }, 0);
36114      * // => 3
36115      *
36116      * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
36117      *   (result[value] || (result[value] = [])).push(key);
36118      *   return result;
36119      * }, {});
36120      * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
36121      */
36122     function reduce(collection, iteratee, accumulator) {
36123       var func = isArray(collection) ? arrayReduce : baseReduce,
36124           initAccum = arguments.length < 3;
36125
36126       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
36127     }
36128
36129     /**
36130      * This method is like `_.reduce` except that it iterates over elements of
36131      * `collection` from right to left.
36132      *
36133      * @static
36134      * @memberOf _
36135      * @since 0.1.0
36136      * @category Collection
36137      * @param {Array|Object} collection The collection to iterate over.
36138      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
36139      * @param {*} [accumulator] The initial value.
36140      * @returns {*} Returns the accumulated value.
36141      * @see _.reduce
36142      * @example
36143      *
36144      * var array = [[0, 1], [2, 3], [4, 5]];
36145      *
36146      * _.reduceRight(array, function(flattened, other) {
36147      *   return flattened.concat(other);
36148      * }, []);
36149      * // => [4, 5, 2, 3, 0, 1]
36150      */
36151     function reduceRight(collection, iteratee, accumulator) {
36152       var func = isArray(collection) ? arrayReduceRight : baseReduce,
36153           initAccum = arguments.length < 3;
36154
36155       return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
36156     }
36157
36158     /**
36159      * The opposite of `_.filter`; this method returns the elements of `collection`
36160      * that `predicate` does **not** return truthy for.
36161      *
36162      * @static
36163      * @memberOf _
36164      * @since 0.1.0
36165      * @category Collection
36166      * @param {Array|Object} collection The collection to iterate over.
36167      * @param {Function} [predicate=_.identity] The function invoked per iteration.
36168      * @returns {Array} Returns the new filtered array.
36169      * @see _.filter
36170      * @example
36171      *
36172      * var users = [
36173      *   { 'user': 'barney', 'age': 36, 'active': false },
36174      *   { 'user': 'fred',   'age': 40, 'active': true }
36175      * ];
36176      *
36177      * _.reject(users, function(o) { return !o.active; });
36178      * // => objects for ['fred']
36179      *
36180      * // The `_.matches` iteratee shorthand.
36181      * _.reject(users, { 'age': 40, 'active': true });
36182      * // => objects for ['barney']
36183      *
36184      * // The `_.matchesProperty` iteratee shorthand.
36185      * _.reject(users, ['active', false]);
36186      * // => objects for ['fred']
36187      *
36188      * // The `_.property` iteratee shorthand.
36189      * _.reject(users, 'active');
36190      * // => objects for ['barney']
36191      */
36192     function reject(collection, predicate) {
36193       var func = isArray(collection) ? arrayFilter : baseFilter;
36194       return func(collection, negate(getIteratee(predicate, 3)));
36195     }
36196
36197     /**
36198      * Gets a random element from `collection`.
36199      *
36200      * @static
36201      * @memberOf _
36202      * @since 2.0.0
36203      * @category Collection
36204      * @param {Array|Object} collection The collection to sample.
36205      * @returns {*} Returns the random element.
36206      * @example
36207      *
36208      * _.sample([1, 2, 3, 4]);
36209      * // => 2
36210      */
36211     function sample(collection) {
36212       var func = isArray(collection) ? arraySample : baseSample;
36213       return func(collection);
36214     }
36215
36216     /**
36217      * Gets `n` random elements at unique keys from `collection` up to the
36218      * size of `collection`.
36219      *
36220      * @static
36221      * @memberOf _
36222      * @since 4.0.0
36223      * @category Collection
36224      * @param {Array|Object} collection The collection to sample.
36225      * @param {number} [n=1] The number of elements to sample.
36226      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36227      * @returns {Array} Returns the random elements.
36228      * @example
36229      *
36230      * _.sampleSize([1, 2, 3], 2);
36231      * // => [3, 1]
36232      *
36233      * _.sampleSize([1, 2, 3], 4);
36234      * // => [2, 3, 1]
36235      */
36236     function sampleSize(collection, n, guard) {
36237       if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
36238         n = 1;
36239       } else {
36240         n = toInteger(n);
36241       }
36242       var func = isArray(collection) ? arraySampleSize : baseSampleSize;
36243       return func(collection, n);
36244     }
36245
36246     /**
36247      * Creates an array of shuffled values, using a version of the
36248      * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
36249      *
36250      * @static
36251      * @memberOf _
36252      * @since 0.1.0
36253      * @category Collection
36254      * @param {Array|Object} collection The collection to shuffle.
36255      * @returns {Array} Returns the new shuffled array.
36256      * @example
36257      *
36258      * _.shuffle([1, 2, 3, 4]);
36259      * // => [4, 1, 3, 2]
36260      */
36261     function shuffle(collection) {
36262       var func = isArray(collection) ? arrayShuffle : baseShuffle;
36263       return func(collection);
36264     }
36265
36266     /**
36267      * Gets the size of `collection` by returning its length for array-like
36268      * values or the number of own enumerable string keyed properties for objects.
36269      *
36270      * @static
36271      * @memberOf _
36272      * @since 0.1.0
36273      * @category Collection
36274      * @param {Array|Object|string} collection The collection to inspect.
36275      * @returns {number} Returns the collection size.
36276      * @example
36277      *
36278      * _.size([1, 2, 3]);
36279      * // => 3
36280      *
36281      * _.size({ 'a': 1, 'b': 2 });
36282      * // => 2
36283      *
36284      * _.size('pebbles');
36285      * // => 7
36286      */
36287     function size(collection) {
36288       if (collection == null) {
36289         return 0;
36290       }
36291       if (isArrayLike(collection)) {
36292         return isString(collection) ? stringSize(collection) : collection.length;
36293       }
36294       var tag = getTag(collection);
36295       if (tag == mapTag || tag == setTag) {
36296         return collection.size;
36297       }
36298       return baseKeys(collection).length;
36299     }
36300
36301     /**
36302      * Checks if `predicate` returns truthy for **any** element of `collection`.
36303      * Iteration is stopped once `predicate` returns truthy. The predicate is
36304      * invoked with three arguments: (value, index|key, collection).
36305      *
36306      * @static
36307      * @memberOf _
36308      * @since 0.1.0
36309      * @category Collection
36310      * @param {Array|Object} collection The collection to iterate over.
36311      * @param {Function} [predicate=_.identity] The function invoked per iteration.
36312      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36313      * @returns {boolean} Returns `true` if any element passes the predicate check,
36314      *  else `false`.
36315      * @example
36316      *
36317      * _.some([null, 0, 'yes', false], Boolean);
36318      * // => true
36319      *
36320      * var users = [
36321      *   { 'user': 'barney', 'active': true },
36322      *   { 'user': 'fred',   'active': false }
36323      * ];
36324      *
36325      * // The `_.matches` iteratee shorthand.
36326      * _.some(users, { 'user': 'barney', 'active': false });
36327      * // => false
36328      *
36329      * // The `_.matchesProperty` iteratee shorthand.
36330      * _.some(users, ['active', false]);
36331      * // => true
36332      *
36333      * // The `_.property` iteratee shorthand.
36334      * _.some(users, 'active');
36335      * // => true
36336      */
36337     function some(collection, predicate, guard) {
36338       var func = isArray(collection) ? arraySome : baseSome;
36339       if (guard && isIterateeCall(collection, predicate, guard)) {
36340         predicate = undefined;
36341       }
36342       return func(collection, getIteratee(predicate, 3));
36343     }
36344
36345     /**
36346      * Creates an array of elements, sorted in ascending order by the results of
36347      * running each element in a collection thru each iteratee. This method
36348      * performs a stable sort, that is, it preserves the original sort order of
36349      * equal elements. The iteratees are invoked with one argument: (value).
36350      *
36351      * @static
36352      * @memberOf _
36353      * @since 0.1.0
36354      * @category Collection
36355      * @param {Array|Object} collection The collection to iterate over.
36356      * @param {...(Function|Function[])} [iteratees=[_.identity]]
36357      *  The iteratees to sort by.
36358      * @returns {Array} Returns the new sorted array.
36359      * @example
36360      *
36361      * var users = [
36362      *   { 'user': 'fred',   'age': 48 },
36363      *   { 'user': 'barney', 'age': 36 },
36364      *   { 'user': 'fred',   'age': 40 },
36365      *   { 'user': 'barney', 'age': 34 }
36366      * ];
36367      *
36368      * _.sortBy(users, [function(o) { return o.user; }]);
36369      * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
36370      *
36371      * _.sortBy(users, ['user', 'age']);
36372      * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
36373      */
36374     var sortBy = baseRest(function(collection, iteratees) {
36375       if (collection == null) {
36376         return [];
36377       }
36378       var length = iteratees.length;
36379       if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
36380         iteratees = [];
36381       } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
36382         iteratees = [iteratees[0]];
36383       }
36384       return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
36385     });
36386
36387     /*------------------------------------------------------------------------*/
36388
36389     /**
36390      * Gets the timestamp of the number of milliseconds that have elapsed since
36391      * the Unix epoch (1 January 1970 00:00:00 UTC).
36392      *
36393      * @static
36394      * @memberOf _
36395      * @since 2.4.0
36396      * @category Date
36397      * @returns {number} Returns the timestamp.
36398      * @example
36399      *
36400      * _.defer(function(stamp) {
36401      *   console.log(_.now() - stamp);
36402      * }, _.now());
36403      * // => Logs the number of milliseconds it took for the deferred invocation.
36404      */
36405     var now = ctxNow || function() {
36406       return root.Date.now();
36407     };
36408
36409     /*------------------------------------------------------------------------*/
36410
36411     /**
36412      * The opposite of `_.before`; this method creates a function that invokes
36413      * `func` once it's called `n` or more times.
36414      *
36415      * @static
36416      * @memberOf _
36417      * @since 0.1.0
36418      * @category Function
36419      * @param {number} n The number of calls before `func` is invoked.
36420      * @param {Function} func The function to restrict.
36421      * @returns {Function} Returns the new restricted function.
36422      * @example
36423      *
36424      * var saves = ['profile', 'settings'];
36425      *
36426      * var done = _.after(saves.length, function() {
36427      *   console.log('done saving!');
36428      * });
36429      *
36430      * _.forEach(saves, function(type) {
36431      *   asyncSave({ 'type': type, 'complete': done });
36432      * });
36433      * // => Logs 'done saving!' after the two async saves have completed.
36434      */
36435     function after(n, func) {
36436       if (typeof func != 'function') {
36437         throw new TypeError(FUNC_ERROR_TEXT);
36438       }
36439       n = toInteger(n);
36440       return function() {
36441         if (--n < 1) {
36442           return func.apply(this, arguments);
36443         }
36444       };
36445     }
36446
36447     /**
36448      * Creates a function that invokes `func`, with up to `n` arguments,
36449      * ignoring any additional arguments.
36450      *
36451      * @static
36452      * @memberOf _
36453      * @since 3.0.0
36454      * @category Function
36455      * @param {Function} func The function to cap arguments for.
36456      * @param {number} [n=func.length] The arity cap.
36457      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36458      * @returns {Function} Returns the new capped function.
36459      * @example
36460      *
36461      * _.map(['6', '8', '10'], _.ary(parseInt, 1));
36462      * // => [6, 8, 10]
36463      */
36464     function ary(func, n, guard) {
36465       n = guard ? undefined : n;
36466       n = (func && n == null) ? func.length : n;
36467       return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
36468     }
36469
36470     /**
36471      * Creates a function that invokes `func`, with the `this` binding and arguments
36472      * of the created function, while it's called less than `n` times. Subsequent
36473      * calls to the created function return the result of the last `func` invocation.
36474      *
36475      * @static
36476      * @memberOf _
36477      * @since 3.0.0
36478      * @category Function
36479      * @param {number} n The number of calls at which `func` is no longer invoked.
36480      * @param {Function} func The function to restrict.
36481      * @returns {Function} Returns the new restricted function.
36482      * @example
36483      *
36484      * jQuery(element).on('click', _.before(5, addContactToList));
36485      * // => Allows adding up to 4 contacts to the list.
36486      */
36487     function before(n, func) {
36488       var result;
36489       if (typeof func != 'function') {
36490         throw new TypeError(FUNC_ERROR_TEXT);
36491       }
36492       n = toInteger(n);
36493       return function() {
36494         if (--n > 0) {
36495           result = func.apply(this, arguments);
36496         }
36497         if (n <= 1) {
36498           func = undefined;
36499         }
36500         return result;
36501       };
36502     }
36503
36504     /**
36505      * Creates a function that invokes `func` with the `this` binding of `thisArg`
36506      * and `partials` prepended to the arguments it receives.
36507      *
36508      * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
36509      * may be used as a placeholder for partially applied arguments.
36510      *
36511      * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
36512      * property of bound functions.
36513      *
36514      * @static
36515      * @memberOf _
36516      * @since 0.1.0
36517      * @category Function
36518      * @param {Function} func The function to bind.
36519      * @param {*} thisArg The `this` binding of `func`.
36520      * @param {...*} [partials] The arguments to be partially applied.
36521      * @returns {Function} Returns the new bound function.
36522      * @example
36523      *
36524      * function greet(greeting, punctuation) {
36525      *   return greeting + ' ' + this.user + punctuation;
36526      * }
36527      *
36528      * var object = { 'user': 'fred' };
36529      *
36530      * var bound = _.bind(greet, object, 'hi');
36531      * bound('!');
36532      * // => 'hi fred!'
36533      *
36534      * // Bound with placeholders.
36535      * var bound = _.bind(greet, object, _, '!');
36536      * bound('hi');
36537      * // => 'hi fred!'
36538      */
36539     var bind = baseRest(function(func, thisArg, partials) {
36540       var bitmask = WRAP_BIND_FLAG;
36541       if (partials.length) {
36542         var holders = replaceHolders(partials, getHolder(bind));
36543         bitmask |= WRAP_PARTIAL_FLAG;
36544       }
36545       return createWrap(func, bitmask, thisArg, partials, holders);
36546     });
36547
36548     /**
36549      * Creates a function that invokes the method at `object[key]` with `partials`
36550      * prepended to the arguments it receives.
36551      *
36552      * This method differs from `_.bind` by allowing bound functions to reference
36553      * methods that may be redefined or don't yet exist. See
36554      * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
36555      * for more details.
36556      *
36557      * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
36558      * builds, may be used as a placeholder for partially applied arguments.
36559      *
36560      * @static
36561      * @memberOf _
36562      * @since 0.10.0
36563      * @category Function
36564      * @param {Object} object The object to invoke the method on.
36565      * @param {string} key The key of the method.
36566      * @param {...*} [partials] The arguments to be partially applied.
36567      * @returns {Function} Returns the new bound function.
36568      * @example
36569      *
36570      * var object = {
36571      *   'user': 'fred',
36572      *   'greet': function(greeting, punctuation) {
36573      *     return greeting + ' ' + this.user + punctuation;
36574      *   }
36575      * };
36576      *
36577      * var bound = _.bindKey(object, 'greet', 'hi');
36578      * bound('!');
36579      * // => 'hi fred!'
36580      *
36581      * object.greet = function(greeting, punctuation) {
36582      *   return greeting + 'ya ' + this.user + punctuation;
36583      * };
36584      *
36585      * bound('!');
36586      * // => 'hiya fred!'
36587      *
36588      * // Bound with placeholders.
36589      * var bound = _.bindKey(object, 'greet', _, '!');
36590      * bound('hi');
36591      * // => 'hiya fred!'
36592      */
36593     var bindKey = baseRest(function(object, key, partials) {
36594       var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
36595       if (partials.length) {
36596         var holders = replaceHolders(partials, getHolder(bindKey));
36597         bitmask |= WRAP_PARTIAL_FLAG;
36598       }
36599       return createWrap(key, bitmask, object, partials, holders);
36600     });
36601
36602     /**
36603      * Creates a function that accepts arguments of `func` and either invokes
36604      * `func` returning its result, if at least `arity` number of arguments have
36605      * been provided, or returns a function that accepts the remaining `func`
36606      * arguments, and so on. The arity of `func` may be specified if `func.length`
36607      * is not sufficient.
36608      *
36609      * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
36610      * may be used as a placeholder for provided arguments.
36611      *
36612      * **Note:** This method doesn't set the "length" property of curried functions.
36613      *
36614      * @static
36615      * @memberOf _
36616      * @since 2.0.0
36617      * @category Function
36618      * @param {Function} func The function to curry.
36619      * @param {number} [arity=func.length] The arity of `func`.
36620      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36621      * @returns {Function} Returns the new curried function.
36622      * @example
36623      *
36624      * var abc = function(a, b, c) {
36625      *   return [a, b, c];
36626      * };
36627      *
36628      * var curried = _.curry(abc);
36629      *
36630      * curried(1)(2)(3);
36631      * // => [1, 2, 3]
36632      *
36633      * curried(1, 2)(3);
36634      * // => [1, 2, 3]
36635      *
36636      * curried(1, 2, 3);
36637      * // => [1, 2, 3]
36638      *
36639      * // Curried with placeholders.
36640      * curried(1)(_, 3)(2);
36641      * // => [1, 2, 3]
36642      */
36643     function curry(func, arity, guard) {
36644       arity = guard ? undefined : arity;
36645       var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
36646       result.placeholder = curry.placeholder;
36647       return result;
36648     }
36649
36650     /**
36651      * This method is like `_.curry` except that arguments are applied to `func`
36652      * in the manner of `_.partialRight` instead of `_.partial`.
36653      *
36654      * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
36655      * builds, may be used as a placeholder for provided arguments.
36656      *
36657      * **Note:** This method doesn't set the "length" property of curried functions.
36658      *
36659      * @static
36660      * @memberOf _
36661      * @since 3.0.0
36662      * @category Function
36663      * @param {Function} func The function to curry.
36664      * @param {number} [arity=func.length] The arity of `func`.
36665      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
36666      * @returns {Function} Returns the new curried function.
36667      * @example
36668      *
36669      * var abc = function(a, b, c) {
36670      *   return [a, b, c];
36671      * };
36672      *
36673      * var curried = _.curryRight(abc);
36674      *
36675      * curried(3)(2)(1);
36676      * // => [1, 2, 3]
36677      *
36678      * curried(2, 3)(1);
36679      * // => [1, 2, 3]
36680      *
36681      * curried(1, 2, 3);
36682      * // => [1, 2, 3]
36683      *
36684      * // Curried with placeholders.
36685      * curried(3)(1, _)(2);
36686      * // => [1, 2, 3]
36687      */
36688     function curryRight(func, arity, guard) {
36689       arity = guard ? undefined : arity;
36690       var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
36691       result.placeholder = curryRight.placeholder;
36692       return result;
36693     }
36694
36695     /**
36696      * Creates a debounced function that delays invoking `func` until after `wait`
36697      * milliseconds have elapsed since the last time the debounced function was
36698      * invoked. The debounced function comes with a `cancel` method to cancel
36699      * delayed `func` invocations and a `flush` method to immediately invoke them.
36700      * Provide `options` to indicate whether `func` should be invoked on the
36701      * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
36702      * with the last arguments provided to the debounced function. Subsequent
36703      * calls to the debounced function return the result of the last `func`
36704      * invocation.
36705      *
36706      * **Note:** If `leading` and `trailing` options are `true`, `func` is
36707      * invoked on the trailing edge of the timeout only if the debounced function
36708      * is invoked more than once during the `wait` timeout.
36709      *
36710      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
36711      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
36712      *
36713      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
36714      * for details over the differences between `_.debounce` and `_.throttle`.
36715      *
36716      * @static
36717      * @memberOf _
36718      * @since 0.1.0
36719      * @category Function
36720      * @param {Function} func The function to debounce.
36721      * @param {number} [wait=0] The number of milliseconds to delay.
36722      * @param {Object} [options={}] The options object.
36723      * @param {boolean} [options.leading=false]
36724      *  Specify invoking on the leading edge of the timeout.
36725      * @param {number} [options.maxWait]
36726      *  The maximum time `func` is allowed to be delayed before it's invoked.
36727      * @param {boolean} [options.trailing=true]
36728      *  Specify invoking on the trailing edge of the timeout.
36729      * @returns {Function} Returns the new debounced function.
36730      * @example
36731      *
36732      * // Avoid costly calculations while the window size is in flux.
36733      * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
36734      *
36735      * // Invoke `sendMail` when clicked, debouncing subsequent calls.
36736      * jQuery(element).on('click', _.debounce(sendMail, 300, {
36737      *   'leading': true,
36738      *   'trailing': false
36739      * }));
36740      *
36741      * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
36742      * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
36743      * var source = new EventSource('/stream');
36744      * jQuery(source).on('message', debounced);
36745      *
36746      * // Cancel the trailing debounced invocation.
36747      * jQuery(window).on('popstate', debounced.cancel);
36748      */
36749     function debounce(func, wait, options) {
36750       var lastArgs,
36751           lastThis,
36752           maxWait,
36753           result,
36754           timerId,
36755           lastCallTime,
36756           lastInvokeTime = 0,
36757           leading = false,
36758           maxing = false,
36759           trailing = true;
36760
36761       if (typeof func != 'function') {
36762         throw new TypeError(FUNC_ERROR_TEXT);
36763       }
36764       wait = toNumber(wait) || 0;
36765       if (isObject(options)) {
36766         leading = !!options.leading;
36767         maxing = 'maxWait' in options;
36768         maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
36769         trailing = 'trailing' in options ? !!options.trailing : trailing;
36770       }
36771
36772       function invokeFunc(time) {
36773         var args = lastArgs,
36774             thisArg = lastThis;
36775
36776         lastArgs = lastThis = undefined;
36777         lastInvokeTime = time;
36778         result = func.apply(thisArg, args);
36779         return result;
36780       }
36781
36782       function leadingEdge(time) {
36783         // Reset any `maxWait` timer.
36784         lastInvokeTime = time;
36785         // Start the timer for the trailing edge.
36786         timerId = setTimeout(timerExpired, wait);
36787         // Invoke the leading edge.
36788         return leading ? invokeFunc(time) : result;
36789       }
36790
36791       function remainingWait(time) {
36792         var timeSinceLastCall = time - lastCallTime,
36793             timeSinceLastInvoke = time - lastInvokeTime,
36794             timeWaiting = wait - timeSinceLastCall;
36795
36796         return maxing
36797           ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
36798           : timeWaiting;
36799       }
36800
36801       function shouldInvoke(time) {
36802         var timeSinceLastCall = time - lastCallTime,
36803             timeSinceLastInvoke = time - lastInvokeTime;
36804
36805         // Either this is the first call, activity has stopped and we're at the
36806         // trailing edge, the system time has gone backwards and we're treating
36807         // it as the trailing edge, or we've hit the `maxWait` limit.
36808         return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
36809           (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
36810       }
36811
36812       function timerExpired() {
36813         var time = now();
36814         if (shouldInvoke(time)) {
36815           return trailingEdge(time);
36816         }
36817         // Restart the timer.
36818         timerId = setTimeout(timerExpired, remainingWait(time));
36819       }
36820
36821       function trailingEdge(time) {
36822         timerId = undefined;
36823
36824         // Only invoke if we have `lastArgs` which means `func` has been
36825         // debounced at least once.
36826         if (trailing && lastArgs) {
36827           return invokeFunc(time);
36828         }
36829         lastArgs = lastThis = undefined;
36830         return result;
36831       }
36832
36833       function cancel() {
36834         if (timerId !== undefined) {
36835           clearTimeout(timerId);
36836         }
36837         lastInvokeTime = 0;
36838         lastArgs = lastCallTime = lastThis = timerId = undefined;
36839       }
36840
36841       function flush() {
36842         return timerId === undefined ? result : trailingEdge(now());
36843       }
36844
36845       function debounced() {
36846         var time = now(),
36847             isInvoking = shouldInvoke(time);
36848
36849         lastArgs = arguments;
36850         lastThis = this;
36851         lastCallTime = time;
36852
36853         if (isInvoking) {
36854           if (timerId === undefined) {
36855             return leadingEdge(lastCallTime);
36856           }
36857           if (maxing) {
36858             // Handle invocations in a tight loop.
36859             clearTimeout(timerId);
36860             timerId = setTimeout(timerExpired, wait);
36861             return invokeFunc(lastCallTime);
36862           }
36863         }
36864         if (timerId === undefined) {
36865           timerId = setTimeout(timerExpired, wait);
36866         }
36867         return result;
36868       }
36869       debounced.cancel = cancel;
36870       debounced.flush = flush;
36871       return debounced;
36872     }
36873
36874     /**
36875      * Defers invoking the `func` until the current call stack has cleared. Any
36876      * additional arguments are provided to `func` when it's invoked.
36877      *
36878      * @static
36879      * @memberOf _
36880      * @since 0.1.0
36881      * @category Function
36882      * @param {Function} func The function to defer.
36883      * @param {...*} [args] The arguments to invoke `func` with.
36884      * @returns {number} Returns the timer id.
36885      * @example
36886      *
36887      * _.defer(function(text) {
36888      *   console.log(text);
36889      * }, 'deferred');
36890      * // => Logs 'deferred' after one millisecond.
36891      */
36892     var defer = baseRest(function(func, args) {
36893       return baseDelay(func, 1, args);
36894     });
36895
36896     /**
36897      * Invokes `func` after `wait` milliseconds. Any additional arguments are
36898      * provided to `func` when it's invoked.
36899      *
36900      * @static
36901      * @memberOf _
36902      * @since 0.1.0
36903      * @category Function
36904      * @param {Function} func The function to delay.
36905      * @param {number} wait The number of milliseconds to delay invocation.
36906      * @param {...*} [args] The arguments to invoke `func` with.
36907      * @returns {number} Returns the timer id.
36908      * @example
36909      *
36910      * _.delay(function(text) {
36911      *   console.log(text);
36912      * }, 1000, 'later');
36913      * // => Logs 'later' after one second.
36914      */
36915     var delay = baseRest(function(func, wait, args) {
36916       return baseDelay(func, toNumber(wait) || 0, args);
36917     });
36918
36919     /**
36920      * Creates a function that invokes `func` with arguments reversed.
36921      *
36922      * @static
36923      * @memberOf _
36924      * @since 4.0.0
36925      * @category Function
36926      * @param {Function} func The function to flip arguments for.
36927      * @returns {Function} Returns the new flipped function.
36928      * @example
36929      *
36930      * var flipped = _.flip(function() {
36931      *   return _.toArray(arguments);
36932      * });
36933      *
36934      * flipped('a', 'b', 'c', 'd');
36935      * // => ['d', 'c', 'b', 'a']
36936      */
36937     function flip(func) {
36938       return createWrap(func, WRAP_FLIP_FLAG);
36939     }
36940
36941     /**
36942      * Creates a function that memoizes the result of `func`. If `resolver` is
36943      * provided, it determines the cache key for storing the result based on the
36944      * arguments provided to the memoized function. By default, the first argument
36945      * provided to the memoized function is used as the map cache key. The `func`
36946      * is invoked with the `this` binding of the memoized function.
36947      *
36948      * **Note:** The cache is exposed as the `cache` property on the memoized
36949      * function. Its creation may be customized by replacing the `_.memoize.Cache`
36950      * constructor with one whose instances implement the
36951      * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
36952      * method interface of `clear`, `delete`, `get`, `has`, and `set`.
36953      *
36954      * @static
36955      * @memberOf _
36956      * @since 0.1.0
36957      * @category Function
36958      * @param {Function} func The function to have its output memoized.
36959      * @param {Function} [resolver] The function to resolve the cache key.
36960      * @returns {Function} Returns the new memoized function.
36961      * @example
36962      *
36963      * var object = { 'a': 1, 'b': 2 };
36964      * var other = { 'c': 3, 'd': 4 };
36965      *
36966      * var values = _.memoize(_.values);
36967      * values(object);
36968      * // => [1, 2]
36969      *
36970      * values(other);
36971      * // => [3, 4]
36972      *
36973      * object.a = 2;
36974      * values(object);
36975      * // => [1, 2]
36976      *
36977      * // Modify the result cache.
36978      * values.cache.set(object, ['a', 'b']);
36979      * values(object);
36980      * // => ['a', 'b']
36981      *
36982      * // Replace `_.memoize.Cache`.
36983      * _.memoize.Cache = WeakMap;
36984      */
36985     function memoize(func, resolver) {
36986       if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
36987         throw new TypeError(FUNC_ERROR_TEXT);
36988       }
36989       var memoized = function() {
36990         var args = arguments,
36991             key = resolver ? resolver.apply(this, args) : args[0],
36992             cache = memoized.cache;
36993
36994         if (cache.has(key)) {
36995           return cache.get(key);
36996         }
36997         var result = func.apply(this, args);
36998         memoized.cache = cache.set(key, result) || cache;
36999         return result;
37000       };
37001       memoized.cache = new (memoize.Cache || MapCache);
37002       return memoized;
37003     }
37004
37005     // Expose `MapCache`.
37006     memoize.Cache = MapCache;
37007
37008     /**
37009      * Creates a function that negates the result of the predicate `func`. The
37010      * `func` predicate is invoked with the `this` binding and arguments of the
37011      * created function.
37012      *
37013      * @static
37014      * @memberOf _
37015      * @since 3.0.0
37016      * @category Function
37017      * @param {Function} predicate The predicate to negate.
37018      * @returns {Function} Returns the new negated function.
37019      * @example
37020      *
37021      * function isEven(n) {
37022      *   return n % 2 == 0;
37023      * }
37024      *
37025      * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
37026      * // => [1, 3, 5]
37027      */
37028     function negate(predicate) {
37029       if (typeof predicate != 'function') {
37030         throw new TypeError(FUNC_ERROR_TEXT);
37031       }
37032       return function() {
37033         var args = arguments;
37034         switch (args.length) {
37035           case 0: return !predicate.call(this);
37036           case 1: return !predicate.call(this, args[0]);
37037           case 2: return !predicate.call(this, args[0], args[1]);
37038           case 3: return !predicate.call(this, args[0], args[1], args[2]);
37039         }
37040         return !predicate.apply(this, args);
37041       };
37042     }
37043
37044     /**
37045      * Creates a function that is restricted to invoking `func` once. Repeat calls
37046      * to the function return the value of the first invocation. The `func` is
37047      * invoked with the `this` binding and arguments of the created function.
37048      *
37049      * @static
37050      * @memberOf _
37051      * @since 0.1.0
37052      * @category Function
37053      * @param {Function} func The function to restrict.
37054      * @returns {Function} Returns the new restricted function.
37055      * @example
37056      *
37057      * var initialize = _.once(createApplication);
37058      * initialize();
37059      * initialize();
37060      * // => `createApplication` is invoked once
37061      */
37062     function once(func) {
37063       return before(2, func);
37064     }
37065
37066     /**
37067      * Creates a function that invokes `func` with its arguments transformed.
37068      *
37069      * @static
37070      * @since 4.0.0
37071      * @memberOf _
37072      * @category Function
37073      * @param {Function} func The function to wrap.
37074      * @param {...(Function|Function[])} [transforms=[_.identity]]
37075      *  The argument transforms.
37076      * @returns {Function} Returns the new function.
37077      * @example
37078      *
37079      * function doubled(n) {
37080      *   return n * 2;
37081      * }
37082      *
37083      * function square(n) {
37084      *   return n * n;
37085      * }
37086      *
37087      * var func = _.overArgs(function(x, y) {
37088      *   return [x, y];
37089      * }, [square, doubled]);
37090      *
37091      * func(9, 3);
37092      * // => [81, 6]
37093      *
37094      * func(10, 5);
37095      * // => [100, 10]
37096      */
37097     var overArgs = castRest(function(func, transforms) {
37098       transforms = (transforms.length == 1 && isArray(transforms[0]))
37099         ? arrayMap(transforms[0], baseUnary(getIteratee()))
37100         : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
37101
37102       var funcsLength = transforms.length;
37103       return baseRest(function(args) {
37104         var index = -1,
37105             length = nativeMin(args.length, funcsLength);
37106
37107         while (++index < length) {
37108           args[index] = transforms[index].call(this, args[index]);
37109         }
37110         return apply(func, this, args);
37111       });
37112     });
37113
37114     /**
37115      * Creates a function that invokes `func` with `partials` prepended to the
37116      * arguments it receives. This method is like `_.bind` except it does **not**
37117      * alter the `this` binding.
37118      *
37119      * The `_.partial.placeholder` value, which defaults to `_` in monolithic
37120      * builds, may be used as a placeholder for partially applied arguments.
37121      *
37122      * **Note:** This method doesn't set the "length" property of partially
37123      * applied functions.
37124      *
37125      * @static
37126      * @memberOf _
37127      * @since 0.2.0
37128      * @category Function
37129      * @param {Function} func The function to partially apply arguments to.
37130      * @param {...*} [partials] The arguments to be partially applied.
37131      * @returns {Function} Returns the new partially applied function.
37132      * @example
37133      *
37134      * function greet(greeting, name) {
37135      *   return greeting + ' ' + name;
37136      * }
37137      *
37138      * var sayHelloTo = _.partial(greet, 'hello');
37139      * sayHelloTo('fred');
37140      * // => 'hello fred'
37141      *
37142      * // Partially applied with placeholders.
37143      * var greetFred = _.partial(greet, _, 'fred');
37144      * greetFred('hi');
37145      * // => 'hi fred'
37146      */
37147     var partial = baseRest(function(func, partials) {
37148       var holders = replaceHolders(partials, getHolder(partial));
37149       return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
37150     });
37151
37152     /**
37153      * This method is like `_.partial` except that partially applied arguments
37154      * are appended to the arguments it receives.
37155      *
37156      * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
37157      * builds, may be used as a placeholder for partially applied arguments.
37158      *
37159      * **Note:** This method doesn't set the "length" property of partially
37160      * applied functions.
37161      *
37162      * @static
37163      * @memberOf _
37164      * @since 1.0.0
37165      * @category Function
37166      * @param {Function} func The function to partially apply arguments to.
37167      * @param {...*} [partials] The arguments to be partially applied.
37168      * @returns {Function} Returns the new partially applied function.
37169      * @example
37170      *
37171      * function greet(greeting, name) {
37172      *   return greeting + ' ' + name;
37173      * }
37174      *
37175      * var greetFred = _.partialRight(greet, 'fred');
37176      * greetFred('hi');
37177      * // => 'hi fred'
37178      *
37179      * // Partially applied with placeholders.
37180      * var sayHelloTo = _.partialRight(greet, 'hello', _);
37181      * sayHelloTo('fred');
37182      * // => 'hello fred'
37183      */
37184     var partialRight = baseRest(function(func, partials) {
37185       var holders = replaceHolders(partials, getHolder(partialRight));
37186       return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
37187     });
37188
37189     /**
37190      * Creates a function that invokes `func` with arguments arranged according
37191      * to the specified `indexes` where the argument value at the first index is
37192      * provided as the first argument, the argument value at the second index is
37193      * provided as the second argument, and so on.
37194      *
37195      * @static
37196      * @memberOf _
37197      * @since 3.0.0
37198      * @category Function
37199      * @param {Function} func The function to rearrange arguments for.
37200      * @param {...(number|number[])} indexes The arranged argument indexes.
37201      * @returns {Function} Returns the new function.
37202      * @example
37203      *
37204      * var rearged = _.rearg(function(a, b, c) {
37205      *   return [a, b, c];
37206      * }, [2, 0, 1]);
37207      *
37208      * rearged('b', 'c', 'a')
37209      * // => ['a', 'b', 'c']
37210      */
37211     var rearg = flatRest(function(func, indexes) {
37212       return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
37213     });
37214
37215     /**
37216      * Creates a function that invokes `func` with the `this` binding of the
37217      * created function and arguments from `start` and beyond provided as
37218      * an array.
37219      *
37220      * **Note:** This method is based on the
37221      * [rest parameter](https://mdn.io/rest_parameters).
37222      *
37223      * @static
37224      * @memberOf _
37225      * @since 4.0.0
37226      * @category Function
37227      * @param {Function} func The function to apply a rest parameter to.
37228      * @param {number} [start=func.length-1] The start position of the rest parameter.
37229      * @returns {Function} Returns the new function.
37230      * @example
37231      *
37232      * var say = _.rest(function(what, names) {
37233      *   return what + ' ' + _.initial(names).join(', ') +
37234      *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
37235      * });
37236      *
37237      * say('hello', 'fred', 'barney', 'pebbles');
37238      * // => 'hello fred, barney, & pebbles'
37239      */
37240     function rest(func, start) {
37241       if (typeof func != 'function') {
37242         throw new TypeError(FUNC_ERROR_TEXT);
37243       }
37244       start = start === undefined ? start : toInteger(start);
37245       return baseRest(func, start);
37246     }
37247
37248     /**
37249      * Creates a function that invokes `func` with the `this` binding of the
37250      * create function and an array of arguments much like
37251      * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
37252      *
37253      * **Note:** This method is based on the
37254      * [spread operator](https://mdn.io/spread_operator).
37255      *
37256      * @static
37257      * @memberOf _
37258      * @since 3.2.0
37259      * @category Function
37260      * @param {Function} func The function to spread arguments over.
37261      * @param {number} [start=0] The start position of the spread.
37262      * @returns {Function} Returns the new function.
37263      * @example
37264      *
37265      * var say = _.spread(function(who, what) {
37266      *   return who + ' says ' + what;
37267      * });
37268      *
37269      * say(['fred', 'hello']);
37270      * // => 'fred says hello'
37271      *
37272      * var numbers = Promise.all([
37273      *   Promise.resolve(40),
37274      *   Promise.resolve(36)
37275      * ]);
37276      *
37277      * numbers.then(_.spread(function(x, y) {
37278      *   return x + y;
37279      * }));
37280      * // => a Promise of 76
37281      */
37282     function spread(func, start) {
37283       if (typeof func != 'function') {
37284         throw new TypeError(FUNC_ERROR_TEXT);
37285       }
37286       start = start == null ? 0 : nativeMax(toInteger(start), 0);
37287       return baseRest(function(args) {
37288         var array = args[start],
37289             otherArgs = castSlice(args, 0, start);
37290
37291         if (array) {
37292           arrayPush(otherArgs, array);
37293         }
37294         return apply(func, this, otherArgs);
37295       });
37296     }
37297
37298     /**
37299      * Creates a throttled function that only invokes `func` at most once per
37300      * every `wait` milliseconds. The throttled function comes with a `cancel`
37301      * method to cancel delayed `func` invocations and a `flush` method to
37302      * immediately invoke them. Provide `options` to indicate whether `func`
37303      * should be invoked on the leading and/or trailing edge of the `wait`
37304      * timeout. The `func` is invoked with the last arguments provided to the
37305      * throttled function. Subsequent calls to the throttled function return the
37306      * result of the last `func` invocation.
37307      *
37308      * **Note:** If `leading` and `trailing` options are `true`, `func` is
37309      * invoked on the trailing edge of the timeout only if the throttled function
37310      * is invoked more than once during the `wait` timeout.
37311      *
37312      * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
37313      * until to the next tick, similar to `setTimeout` with a timeout of `0`.
37314      *
37315      * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
37316      * for details over the differences between `_.throttle` and `_.debounce`.
37317      *
37318      * @static
37319      * @memberOf _
37320      * @since 0.1.0
37321      * @category Function
37322      * @param {Function} func The function to throttle.
37323      * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
37324      * @param {Object} [options={}] The options object.
37325      * @param {boolean} [options.leading=true]
37326      *  Specify invoking on the leading edge of the timeout.
37327      * @param {boolean} [options.trailing=true]
37328      *  Specify invoking on the trailing edge of the timeout.
37329      * @returns {Function} Returns the new throttled function.
37330      * @example
37331      *
37332      * // Avoid excessively updating the position while scrolling.
37333      * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
37334      *
37335      * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
37336      * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
37337      * jQuery(element).on('click', throttled);
37338      *
37339      * // Cancel the trailing throttled invocation.
37340      * jQuery(window).on('popstate', throttled.cancel);
37341      */
37342     function throttle(func, wait, options) {
37343       var leading = true,
37344           trailing = true;
37345
37346       if (typeof func != 'function') {
37347         throw new TypeError(FUNC_ERROR_TEXT);
37348       }
37349       if (isObject(options)) {
37350         leading = 'leading' in options ? !!options.leading : leading;
37351         trailing = 'trailing' in options ? !!options.trailing : trailing;
37352       }
37353       return debounce(func, wait, {
37354         'leading': leading,
37355         'maxWait': wait,
37356         'trailing': trailing
37357       });
37358     }
37359
37360     /**
37361      * Creates a function that accepts up to one argument, ignoring any
37362      * additional arguments.
37363      *
37364      * @static
37365      * @memberOf _
37366      * @since 4.0.0
37367      * @category Function
37368      * @param {Function} func The function to cap arguments for.
37369      * @returns {Function} Returns the new capped function.
37370      * @example
37371      *
37372      * _.map(['6', '8', '10'], _.unary(parseInt));
37373      * // => [6, 8, 10]
37374      */
37375     function unary(func) {
37376       return ary(func, 1);
37377     }
37378
37379     /**
37380      * Creates a function that provides `value` to `wrapper` as its first
37381      * argument. Any additional arguments provided to the function are appended
37382      * to those provided to the `wrapper`. The wrapper is invoked with the `this`
37383      * binding of the created function.
37384      *
37385      * @static
37386      * @memberOf _
37387      * @since 0.1.0
37388      * @category Function
37389      * @param {*} value The value to wrap.
37390      * @param {Function} [wrapper=identity] The wrapper function.
37391      * @returns {Function} Returns the new function.
37392      * @example
37393      *
37394      * var p = _.wrap(_.escape, function(func, text) {
37395      *   return '<p>' + func(text) + '</p>';
37396      * });
37397      *
37398      * p('fred, barney, & pebbles');
37399      * // => '<p>fred, barney, &amp; pebbles</p>'
37400      */
37401     function wrap(value, wrapper) {
37402       return partial(castFunction(wrapper), value);
37403     }
37404
37405     /*------------------------------------------------------------------------*/
37406
37407     /**
37408      * Casts `value` as an array if it's not one.
37409      *
37410      * @static
37411      * @memberOf _
37412      * @since 4.4.0
37413      * @category Lang
37414      * @param {*} value The value to inspect.
37415      * @returns {Array} Returns the cast array.
37416      * @example
37417      *
37418      * _.castArray(1);
37419      * // => [1]
37420      *
37421      * _.castArray({ 'a': 1 });
37422      * // => [{ 'a': 1 }]
37423      *
37424      * _.castArray('abc');
37425      * // => ['abc']
37426      *
37427      * _.castArray(null);
37428      * // => [null]
37429      *
37430      * _.castArray(undefined);
37431      * // => [undefined]
37432      *
37433      * _.castArray();
37434      * // => []
37435      *
37436      * var array = [1, 2, 3];
37437      * console.log(_.castArray(array) === array);
37438      * // => true
37439      */
37440     function castArray() {
37441       if (!arguments.length) {
37442         return [];
37443       }
37444       var value = arguments[0];
37445       return isArray(value) ? value : [value];
37446     }
37447
37448     /**
37449      * Creates a shallow clone of `value`.
37450      *
37451      * **Note:** This method is loosely based on the
37452      * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
37453      * and supports cloning arrays, array buffers, booleans, date objects, maps,
37454      * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
37455      * arrays. The own enumerable properties of `arguments` objects are cloned
37456      * as plain objects. An empty object is returned for uncloneable values such
37457      * as error objects, functions, DOM nodes, and WeakMaps.
37458      *
37459      * @static
37460      * @memberOf _
37461      * @since 0.1.0
37462      * @category Lang
37463      * @param {*} value The value to clone.
37464      * @returns {*} Returns the cloned value.
37465      * @see _.cloneDeep
37466      * @example
37467      *
37468      * var objects = [{ 'a': 1 }, { 'b': 2 }];
37469      *
37470      * var shallow = _.clone(objects);
37471      * console.log(shallow[0] === objects[0]);
37472      * // => true
37473      */
37474     function clone(value) {
37475       return baseClone(value, CLONE_SYMBOLS_FLAG);
37476     }
37477
37478     /**
37479      * This method is like `_.clone` except that it accepts `customizer` which
37480      * is invoked to produce the cloned value. If `customizer` returns `undefined`,
37481      * cloning is handled by the method instead. The `customizer` is invoked with
37482      * up to four arguments; (value [, index|key, object, stack]).
37483      *
37484      * @static
37485      * @memberOf _
37486      * @since 4.0.0
37487      * @category Lang
37488      * @param {*} value The value to clone.
37489      * @param {Function} [customizer] The function to customize cloning.
37490      * @returns {*} Returns the cloned value.
37491      * @see _.cloneDeepWith
37492      * @example
37493      *
37494      * function customizer(value) {
37495      *   if (_.isElement(value)) {
37496      *     return value.cloneNode(false);
37497      *   }
37498      * }
37499      *
37500      * var el = _.cloneWith(document.body, customizer);
37501      *
37502      * console.log(el === document.body);
37503      * // => false
37504      * console.log(el.nodeName);
37505      * // => 'BODY'
37506      * console.log(el.childNodes.length);
37507      * // => 0
37508      */
37509     function cloneWith(value, customizer) {
37510       customizer = typeof customizer == 'function' ? customizer : undefined;
37511       return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
37512     }
37513
37514     /**
37515      * This method is like `_.clone` except that it recursively clones `value`.
37516      *
37517      * @static
37518      * @memberOf _
37519      * @since 1.0.0
37520      * @category Lang
37521      * @param {*} value The value to recursively clone.
37522      * @returns {*} Returns the deep cloned value.
37523      * @see _.clone
37524      * @example
37525      *
37526      * var objects = [{ 'a': 1 }, { 'b': 2 }];
37527      *
37528      * var deep = _.cloneDeep(objects);
37529      * console.log(deep[0] === objects[0]);
37530      * // => false
37531      */
37532     function cloneDeep(value) {
37533       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
37534     }
37535
37536     /**
37537      * This method is like `_.cloneWith` except that it recursively clones `value`.
37538      *
37539      * @static
37540      * @memberOf _
37541      * @since 4.0.0
37542      * @category Lang
37543      * @param {*} value The value to recursively clone.
37544      * @param {Function} [customizer] The function to customize cloning.
37545      * @returns {*} Returns the deep cloned value.
37546      * @see _.cloneWith
37547      * @example
37548      *
37549      * function customizer(value) {
37550      *   if (_.isElement(value)) {
37551      *     return value.cloneNode(true);
37552      *   }
37553      * }
37554      *
37555      * var el = _.cloneDeepWith(document.body, customizer);
37556      *
37557      * console.log(el === document.body);
37558      * // => false
37559      * console.log(el.nodeName);
37560      * // => 'BODY'
37561      * console.log(el.childNodes.length);
37562      * // => 20
37563      */
37564     function cloneDeepWith(value, customizer) {
37565       customizer = typeof customizer == 'function' ? customizer : undefined;
37566       return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
37567     }
37568
37569     /**
37570      * Checks if `object` conforms to `source` by invoking the predicate
37571      * properties of `source` with the corresponding property values of `object`.
37572      *
37573      * **Note:** This method is equivalent to `_.conforms` when `source` is
37574      * partially applied.
37575      *
37576      * @static
37577      * @memberOf _
37578      * @since 4.14.0
37579      * @category Lang
37580      * @param {Object} object The object to inspect.
37581      * @param {Object} source The object of property predicates to conform to.
37582      * @returns {boolean} Returns `true` if `object` conforms, else `false`.
37583      * @example
37584      *
37585      * var object = { 'a': 1, 'b': 2 };
37586      *
37587      * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
37588      * // => true
37589      *
37590      * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
37591      * // => false
37592      */
37593     function conformsTo(object, source) {
37594       return source == null || baseConformsTo(object, source, keys(source));
37595     }
37596
37597     /**
37598      * Performs a
37599      * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
37600      * comparison between two values to determine if they are equivalent.
37601      *
37602      * @static
37603      * @memberOf _
37604      * @since 4.0.0
37605      * @category Lang
37606      * @param {*} value The value to compare.
37607      * @param {*} other The other value to compare.
37608      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
37609      * @example
37610      *
37611      * var object = { 'a': 1 };
37612      * var other = { 'a': 1 };
37613      *
37614      * _.eq(object, object);
37615      * // => true
37616      *
37617      * _.eq(object, other);
37618      * // => false
37619      *
37620      * _.eq('a', 'a');
37621      * // => true
37622      *
37623      * _.eq('a', Object('a'));
37624      * // => false
37625      *
37626      * _.eq(NaN, NaN);
37627      * // => true
37628      */
37629     function eq(value, other) {
37630       return value === other || (value !== value && other !== other);
37631     }
37632
37633     /**
37634      * Checks if `value` is greater than `other`.
37635      *
37636      * @static
37637      * @memberOf _
37638      * @since 3.9.0
37639      * @category Lang
37640      * @param {*} value The value to compare.
37641      * @param {*} other The other value to compare.
37642      * @returns {boolean} Returns `true` if `value` is greater than `other`,
37643      *  else `false`.
37644      * @see _.lt
37645      * @example
37646      *
37647      * _.gt(3, 1);
37648      * // => true
37649      *
37650      * _.gt(3, 3);
37651      * // => false
37652      *
37653      * _.gt(1, 3);
37654      * // => false
37655      */
37656     var gt = createRelationalOperation(baseGt);
37657
37658     /**
37659      * Checks if `value` is greater than or equal to `other`.
37660      *
37661      * @static
37662      * @memberOf _
37663      * @since 3.9.0
37664      * @category Lang
37665      * @param {*} value The value to compare.
37666      * @param {*} other The other value to compare.
37667      * @returns {boolean} Returns `true` if `value` is greater than or equal to
37668      *  `other`, else `false`.
37669      * @see _.lte
37670      * @example
37671      *
37672      * _.gte(3, 1);
37673      * // => true
37674      *
37675      * _.gte(3, 3);
37676      * // => true
37677      *
37678      * _.gte(1, 3);
37679      * // => false
37680      */
37681     var gte = createRelationalOperation(function(value, other) {
37682       return value >= other;
37683     });
37684
37685     /**
37686      * Checks if `value` is likely an `arguments` object.
37687      *
37688      * @static
37689      * @memberOf _
37690      * @since 0.1.0
37691      * @category Lang
37692      * @param {*} value The value to check.
37693      * @returns {boolean} Returns `true` if `value` is an `arguments` object,
37694      *  else `false`.
37695      * @example
37696      *
37697      * _.isArguments(function() { return arguments; }());
37698      * // => true
37699      *
37700      * _.isArguments([1, 2, 3]);
37701      * // => false
37702      */
37703     var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
37704       return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
37705         !propertyIsEnumerable.call(value, 'callee');
37706     };
37707
37708     /**
37709      * Checks if `value` is classified as an `Array` object.
37710      *
37711      * @static
37712      * @memberOf _
37713      * @since 0.1.0
37714      * @category Lang
37715      * @param {*} value The value to check.
37716      * @returns {boolean} Returns `true` if `value` is an array, else `false`.
37717      * @example
37718      *
37719      * _.isArray([1, 2, 3]);
37720      * // => true
37721      *
37722      * _.isArray(document.body.children);
37723      * // => false
37724      *
37725      * _.isArray('abc');
37726      * // => false
37727      *
37728      * _.isArray(_.noop);
37729      * // => false
37730      */
37731     var isArray = Array.isArray;
37732
37733     /**
37734      * Checks if `value` is classified as an `ArrayBuffer` 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 an array buffer, else `false`.
37742      * @example
37743      *
37744      * _.isArrayBuffer(new ArrayBuffer(2));
37745      * // => true
37746      *
37747      * _.isArrayBuffer(new Array(2));
37748      * // => false
37749      */
37750     var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
37751
37752     /**
37753      * Checks if `value` is array-like. A value is considered array-like if it's
37754      * not a function and has a `value.length` that's an integer greater than or
37755      * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
37756      *
37757      * @static
37758      * @memberOf _
37759      * @since 4.0.0
37760      * @category Lang
37761      * @param {*} value The value to check.
37762      * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
37763      * @example
37764      *
37765      * _.isArrayLike([1, 2, 3]);
37766      * // => true
37767      *
37768      * _.isArrayLike(document.body.children);
37769      * // => true
37770      *
37771      * _.isArrayLike('abc');
37772      * // => true
37773      *
37774      * _.isArrayLike(_.noop);
37775      * // => false
37776      */
37777     function isArrayLike(value) {
37778       return value != null && isLength(value.length) && !isFunction(value);
37779     }
37780
37781     /**
37782      * This method is like `_.isArrayLike` except that it also checks if `value`
37783      * is an object.
37784      *
37785      * @static
37786      * @memberOf _
37787      * @since 4.0.0
37788      * @category Lang
37789      * @param {*} value The value to check.
37790      * @returns {boolean} Returns `true` if `value` is an array-like object,
37791      *  else `false`.
37792      * @example
37793      *
37794      * _.isArrayLikeObject([1, 2, 3]);
37795      * // => true
37796      *
37797      * _.isArrayLikeObject(document.body.children);
37798      * // => true
37799      *
37800      * _.isArrayLikeObject('abc');
37801      * // => false
37802      *
37803      * _.isArrayLikeObject(_.noop);
37804      * // => false
37805      */
37806     function isArrayLikeObject(value) {
37807       return isObjectLike(value) && isArrayLike(value);
37808     }
37809
37810     /**
37811      * Checks if `value` is classified as a boolean primitive or object.
37812      *
37813      * @static
37814      * @memberOf _
37815      * @since 0.1.0
37816      * @category Lang
37817      * @param {*} value The value to check.
37818      * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
37819      * @example
37820      *
37821      * _.isBoolean(false);
37822      * // => true
37823      *
37824      * _.isBoolean(null);
37825      * // => false
37826      */
37827     function isBoolean(value) {
37828       return value === true || value === false ||
37829         (isObjectLike(value) && baseGetTag(value) == boolTag);
37830     }
37831
37832     /**
37833      * Checks if `value` is a buffer.
37834      *
37835      * @static
37836      * @memberOf _
37837      * @since 4.3.0
37838      * @category Lang
37839      * @param {*} value The value to check.
37840      * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
37841      * @example
37842      *
37843      * _.isBuffer(new Buffer(2));
37844      * // => true
37845      *
37846      * _.isBuffer(new Uint8Array(2));
37847      * // => false
37848      */
37849     var isBuffer = nativeIsBuffer || stubFalse;
37850
37851     /**
37852      * Checks if `value` is classified as a `Date` object.
37853      *
37854      * @static
37855      * @memberOf _
37856      * @since 0.1.0
37857      * @category Lang
37858      * @param {*} value The value to check.
37859      * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
37860      * @example
37861      *
37862      * _.isDate(new Date);
37863      * // => true
37864      *
37865      * _.isDate('Mon April 23 2012');
37866      * // => false
37867      */
37868     var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
37869
37870     /**
37871      * Checks if `value` is likely a DOM element.
37872      *
37873      * @static
37874      * @memberOf _
37875      * @since 0.1.0
37876      * @category Lang
37877      * @param {*} value The value to check.
37878      * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
37879      * @example
37880      *
37881      * _.isElement(document.body);
37882      * // => true
37883      *
37884      * _.isElement('<body>');
37885      * // => false
37886      */
37887     function isElement(value) {
37888       return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
37889     }
37890
37891     /**
37892      * Checks if `value` is an empty object, collection, map, or set.
37893      *
37894      * Objects are considered empty if they have no own enumerable string keyed
37895      * properties.
37896      *
37897      * Array-like values such as `arguments` objects, arrays, buffers, strings, or
37898      * jQuery-like collections are considered empty if they have a `length` of `0`.
37899      * Similarly, maps and sets are considered empty if they have a `size` of `0`.
37900      *
37901      * @static
37902      * @memberOf _
37903      * @since 0.1.0
37904      * @category Lang
37905      * @param {*} value The value to check.
37906      * @returns {boolean} Returns `true` if `value` is empty, else `false`.
37907      * @example
37908      *
37909      * _.isEmpty(null);
37910      * // => true
37911      *
37912      * _.isEmpty(true);
37913      * // => true
37914      *
37915      * _.isEmpty(1);
37916      * // => true
37917      *
37918      * _.isEmpty([1, 2, 3]);
37919      * // => false
37920      *
37921      * _.isEmpty({ 'a': 1 });
37922      * // => false
37923      */
37924     function isEmpty(value) {
37925       if (value == null) {
37926         return true;
37927       }
37928       if (isArrayLike(value) &&
37929           (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
37930             isBuffer(value) || isTypedArray(value) || isArguments(value))) {
37931         return !value.length;
37932       }
37933       var tag = getTag(value);
37934       if (tag == mapTag || tag == setTag) {
37935         return !value.size;
37936       }
37937       if (isPrototype(value)) {
37938         return !baseKeys(value).length;
37939       }
37940       for (var key in value) {
37941         if (hasOwnProperty.call(value, key)) {
37942           return false;
37943         }
37944       }
37945       return true;
37946     }
37947
37948     /**
37949      * Performs a deep comparison between two values to determine if they are
37950      * equivalent.
37951      *
37952      * **Note:** This method supports comparing arrays, array buffers, booleans,
37953      * date objects, error objects, maps, numbers, `Object` objects, regexes,
37954      * sets, strings, symbols, and typed arrays. `Object` objects are compared
37955      * by their own, not inherited, enumerable properties. Functions and DOM
37956      * nodes are compared by strict equality, i.e. `===`.
37957      *
37958      * @static
37959      * @memberOf _
37960      * @since 0.1.0
37961      * @category Lang
37962      * @param {*} value The value to compare.
37963      * @param {*} other The other value to compare.
37964      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
37965      * @example
37966      *
37967      * var object = { 'a': 1 };
37968      * var other = { 'a': 1 };
37969      *
37970      * _.isEqual(object, other);
37971      * // => true
37972      *
37973      * object === other;
37974      * // => false
37975      */
37976     function isEqual(value, other) {
37977       return baseIsEqual(value, other);
37978     }
37979
37980     /**
37981      * This method is like `_.isEqual` except that it accepts `customizer` which
37982      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
37983      * are handled by the method instead. The `customizer` is invoked with up to
37984      * six arguments: (objValue, othValue [, index|key, object, other, stack]).
37985      *
37986      * @static
37987      * @memberOf _
37988      * @since 4.0.0
37989      * @category Lang
37990      * @param {*} value The value to compare.
37991      * @param {*} other The other value to compare.
37992      * @param {Function} [customizer] The function to customize comparisons.
37993      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
37994      * @example
37995      *
37996      * function isGreeting(value) {
37997      *   return /^h(?:i|ello)$/.test(value);
37998      * }
37999      *
38000      * function customizer(objValue, othValue) {
38001      *   if (isGreeting(objValue) && isGreeting(othValue)) {
38002      *     return true;
38003      *   }
38004      * }
38005      *
38006      * var array = ['hello', 'goodbye'];
38007      * var other = ['hi', 'goodbye'];
38008      *
38009      * _.isEqualWith(array, other, customizer);
38010      * // => true
38011      */
38012     function isEqualWith(value, other, customizer) {
38013       customizer = typeof customizer == 'function' ? customizer : undefined;
38014       var result = customizer ? customizer(value, other) : undefined;
38015       return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
38016     }
38017
38018     /**
38019      * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
38020      * `SyntaxError`, `TypeError`, or `URIError` object.
38021      *
38022      * @static
38023      * @memberOf _
38024      * @since 3.0.0
38025      * @category Lang
38026      * @param {*} value The value to check.
38027      * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
38028      * @example
38029      *
38030      * _.isError(new Error);
38031      * // => true
38032      *
38033      * _.isError(Error);
38034      * // => false
38035      */
38036     function isError(value) {
38037       if (!isObjectLike(value)) {
38038         return false;
38039       }
38040       var tag = baseGetTag(value);
38041       return tag == errorTag || tag == domExcTag ||
38042         (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
38043     }
38044
38045     /**
38046      * Checks if `value` is a finite primitive number.
38047      *
38048      * **Note:** This method is based on
38049      * [`Number.isFinite`](https://mdn.io/Number/isFinite).
38050      *
38051      * @static
38052      * @memberOf _
38053      * @since 0.1.0
38054      * @category Lang
38055      * @param {*} value The value to check.
38056      * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
38057      * @example
38058      *
38059      * _.isFinite(3);
38060      * // => true
38061      *
38062      * _.isFinite(Number.MIN_VALUE);
38063      * // => true
38064      *
38065      * _.isFinite(Infinity);
38066      * // => false
38067      *
38068      * _.isFinite('3');
38069      * // => false
38070      */
38071     function isFinite(value) {
38072       return typeof value == 'number' && nativeIsFinite(value);
38073     }
38074
38075     /**
38076      * Checks if `value` is classified as a `Function` object.
38077      *
38078      * @static
38079      * @memberOf _
38080      * @since 0.1.0
38081      * @category Lang
38082      * @param {*} value The value to check.
38083      * @returns {boolean} Returns `true` if `value` is a function, else `false`.
38084      * @example
38085      *
38086      * _.isFunction(_);
38087      * // => true
38088      *
38089      * _.isFunction(/abc/);
38090      * // => false
38091      */
38092     function isFunction(value) {
38093       if (!isObject(value)) {
38094         return false;
38095       }
38096       // The use of `Object#toString` avoids issues with the `typeof` operator
38097       // in Safari 9 which returns 'object' for typed arrays and other constructors.
38098       var tag = baseGetTag(value);
38099       return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
38100     }
38101
38102     /**
38103      * Checks if `value` is an integer.
38104      *
38105      * **Note:** This method is based on
38106      * [`Number.isInteger`](https://mdn.io/Number/isInteger).
38107      *
38108      * @static
38109      * @memberOf _
38110      * @since 4.0.0
38111      * @category Lang
38112      * @param {*} value The value to check.
38113      * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
38114      * @example
38115      *
38116      * _.isInteger(3);
38117      * // => true
38118      *
38119      * _.isInteger(Number.MIN_VALUE);
38120      * // => false
38121      *
38122      * _.isInteger(Infinity);
38123      * // => false
38124      *
38125      * _.isInteger('3');
38126      * // => false
38127      */
38128     function isInteger(value) {
38129       return typeof value == 'number' && value == toInteger(value);
38130     }
38131
38132     /**
38133      * Checks if `value` is a valid array-like length.
38134      *
38135      * **Note:** This method is loosely based on
38136      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
38137      *
38138      * @static
38139      * @memberOf _
38140      * @since 4.0.0
38141      * @category Lang
38142      * @param {*} value The value to check.
38143      * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
38144      * @example
38145      *
38146      * _.isLength(3);
38147      * // => true
38148      *
38149      * _.isLength(Number.MIN_VALUE);
38150      * // => false
38151      *
38152      * _.isLength(Infinity);
38153      * // => false
38154      *
38155      * _.isLength('3');
38156      * // => false
38157      */
38158     function isLength(value) {
38159       return typeof value == 'number' &&
38160         value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
38161     }
38162
38163     /**
38164      * Checks if `value` is the
38165      * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
38166      * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
38167      *
38168      * @static
38169      * @memberOf _
38170      * @since 0.1.0
38171      * @category Lang
38172      * @param {*} value The value to check.
38173      * @returns {boolean} Returns `true` if `value` is an object, else `false`.
38174      * @example
38175      *
38176      * _.isObject({});
38177      * // => true
38178      *
38179      * _.isObject([1, 2, 3]);
38180      * // => true
38181      *
38182      * _.isObject(_.noop);
38183      * // => true
38184      *
38185      * _.isObject(null);
38186      * // => false
38187      */
38188     function isObject(value) {
38189       var type = typeof value;
38190       return value != null && (type == 'object' || type == 'function');
38191     }
38192
38193     /**
38194      * Checks if `value` is object-like. A value is object-like if it's not `null`
38195      * and has a `typeof` result of "object".
38196      *
38197      * @static
38198      * @memberOf _
38199      * @since 4.0.0
38200      * @category Lang
38201      * @param {*} value The value to check.
38202      * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
38203      * @example
38204      *
38205      * _.isObjectLike({});
38206      * // => true
38207      *
38208      * _.isObjectLike([1, 2, 3]);
38209      * // => true
38210      *
38211      * _.isObjectLike(_.noop);
38212      * // => false
38213      *
38214      * _.isObjectLike(null);
38215      * // => false
38216      */
38217     function isObjectLike(value) {
38218       return value != null && typeof value == 'object';
38219     }
38220
38221     /**
38222      * Checks if `value` is classified as a `Map` object.
38223      *
38224      * @static
38225      * @memberOf _
38226      * @since 4.3.0
38227      * @category Lang
38228      * @param {*} value The value to check.
38229      * @returns {boolean} Returns `true` if `value` is a map, else `false`.
38230      * @example
38231      *
38232      * _.isMap(new Map);
38233      * // => true
38234      *
38235      * _.isMap(new WeakMap);
38236      * // => false
38237      */
38238     var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
38239
38240     /**
38241      * Performs a partial deep comparison between `object` and `source` to
38242      * determine if `object` contains equivalent property values.
38243      *
38244      * **Note:** This method is equivalent to `_.matches` when `source` is
38245      * partially applied.
38246      *
38247      * Partial comparisons will match empty array and empty object `source`
38248      * values against any array or object value, respectively. See `_.isEqual`
38249      * for a list of supported value comparisons.
38250      *
38251      * @static
38252      * @memberOf _
38253      * @since 3.0.0
38254      * @category Lang
38255      * @param {Object} object The object to inspect.
38256      * @param {Object} source The object of property values to match.
38257      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
38258      * @example
38259      *
38260      * var object = { 'a': 1, 'b': 2 };
38261      *
38262      * _.isMatch(object, { 'b': 2 });
38263      * // => true
38264      *
38265      * _.isMatch(object, { 'b': 1 });
38266      * // => false
38267      */
38268     function isMatch(object, source) {
38269       return object === source || baseIsMatch(object, source, getMatchData(source));
38270     }
38271
38272     /**
38273      * This method is like `_.isMatch` except that it accepts `customizer` which
38274      * is invoked to compare values. If `customizer` returns `undefined`, comparisons
38275      * are handled by the method instead. The `customizer` is invoked with five
38276      * arguments: (objValue, srcValue, index|key, object, source).
38277      *
38278      * @static
38279      * @memberOf _
38280      * @since 4.0.0
38281      * @category Lang
38282      * @param {Object} object The object to inspect.
38283      * @param {Object} source The object of property values to match.
38284      * @param {Function} [customizer] The function to customize comparisons.
38285      * @returns {boolean} Returns `true` if `object` is a match, else `false`.
38286      * @example
38287      *
38288      * function isGreeting(value) {
38289      *   return /^h(?:i|ello)$/.test(value);
38290      * }
38291      *
38292      * function customizer(objValue, srcValue) {
38293      *   if (isGreeting(objValue) && isGreeting(srcValue)) {
38294      *     return true;
38295      *   }
38296      * }
38297      *
38298      * var object = { 'greeting': 'hello' };
38299      * var source = { 'greeting': 'hi' };
38300      *
38301      * _.isMatchWith(object, source, customizer);
38302      * // => true
38303      */
38304     function isMatchWith(object, source, customizer) {
38305       customizer = typeof customizer == 'function' ? customizer : undefined;
38306       return baseIsMatch(object, source, getMatchData(source), customizer);
38307     }
38308
38309     /**
38310      * Checks if `value` is `NaN`.
38311      *
38312      * **Note:** This method is based on
38313      * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
38314      * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
38315      * `undefined` and other non-number values.
38316      *
38317      * @static
38318      * @memberOf _
38319      * @since 0.1.0
38320      * @category Lang
38321      * @param {*} value The value to check.
38322      * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
38323      * @example
38324      *
38325      * _.isNaN(NaN);
38326      * // => true
38327      *
38328      * _.isNaN(new Number(NaN));
38329      * // => true
38330      *
38331      * isNaN(undefined);
38332      * // => true
38333      *
38334      * _.isNaN(undefined);
38335      * // => false
38336      */
38337     function isNaN(value) {
38338       // An `NaN` primitive is the only value that is not equal to itself.
38339       // Perform the `toStringTag` check first to avoid errors with some
38340       // ActiveX objects in IE.
38341       return isNumber(value) && value != +value;
38342     }
38343
38344     /**
38345      * Checks if `value` is a pristine native function.
38346      *
38347      * **Note:** This method can't reliably detect native functions in the presence
38348      * of the core-js package because core-js circumvents this kind of detection.
38349      * Despite multiple requests, the core-js maintainer has made it clear: any
38350      * attempt to fix the detection will be obstructed. As a result, we're left
38351      * with little choice but to throw an error. Unfortunately, this also affects
38352      * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
38353      * which rely on core-js.
38354      *
38355      * @static
38356      * @memberOf _
38357      * @since 3.0.0
38358      * @category Lang
38359      * @param {*} value The value to check.
38360      * @returns {boolean} Returns `true` if `value` is a native function,
38361      *  else `false`.
38362      * @example
38363      *
38364      * _.isNative(Array.prototype.push);
38365      * // => true
38366      *
38367      * _.isNative(_);
38368      * // => false
38369      */
38370     function isNative(value) {
38371       if (isMaskable(value)) {
38372         throw new Error(CORE_ERROR_TEXT);
38373       }
38374       return baseIsNative(value);
38375     }
38376
38377     /**
38378      * Checks if `value` is `null`.
38379      *
38380      * @static
38381      * @memberOf _
38382      * @since 0.1.0
38383      * @category Lang
38384      * @param {*} value The value to check.
38385      * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
38386      * @example
38387      *
38388      * _.isNull(null);
38389      * // => true
38390      *
38391      * _.isNull(void 0);
38392      * // => false
38393      */
38394     function isNull(value) {
38395       return value === null;
38396     }
38397
38398     /**
38399      * Checks if `value` is `null` or `undefined`.
38400      *
38401      * @static
38402      * @memberOf _
38403      * @since 4.0.0
38404      * @category Lang
38405      * @param {*} value The value to check.
38406      * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
38407      * @example
38408      *
38409      * _.isNil(null);
38410      * // => true
38411      *
38412      * _.isNil(void 0);
38413      * // => true
38414      *
38415      * _.isNil(NaN);
38416      * // => false
38417      */
38418     function isNil(value) {
38419       return value == null;
38420     }
38421
38422     /**
38423      * Checks if `value` is classified as a `Number` primitive or object.
38424      *
38425      * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
38426      * classified as numbers, use the `_.isFinite` method.
38427      *
38428      * @static
38429      * @memberOf _
38430      * @since 0.1.0
38431      * @category Lang
38432      * @param {*} value The value to check.
38433      * @returns {boolean} Returns `true` if `value` is a number, else `false`.
38434      * @example
38435      *
38436      * _.isNumber(3);
38437      * // => true
38438      *
38439      * _.isNumber(Number.MIN_VALUE);
38440      * // => true
38441      *
38442      * _.isNumber(Infinity);
38443      * // => true
38444      *
38445      * _.isNumber('3');
38446      * // => false
38447      */
38448     function isNumber(value) {
38449       return typeof value == 'number' ||
38450         (isObjectLike(value) && baseGetTag(value) == numberTag);
38451     }
38452
38453     /**
38454      * Checks if `value` is a plain object, that is, an object created by the
38455      * `Object` constructor or one with a `[[Prototype]]` of `null`.
38456      *
38457      * @static
38458      * @memberOf _
38459      * @since 0.8.0
38460      * @category Lang
38461      * @param {*} value The value to check.
38462      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
38463      * @example
38464      *
38465      * function Foo() {
38466      *   this.a = 1;
38467      * }
38468      *
38469      * _.isPlainObject(new Foo);
38470      * // => false
38471      *
38472      * _.isPlainObject([1, 2, 3]);
38473      * // => false
38474      *
38475      * _.isPlainObject({ 'x': 0, 'y': 0 });
38476      * // => true
38477      *
38478      * _.isPlainObject(Object.create(null));
38479      * // => true
38480      */
38481     function isPlainObject(value) {
38482       if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
38483         return false;
38484       }
38485       var proto = getPrototype(value);
38486       if (proto === null) {
38487         return true;
38488       }
38489       var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
38490       return typeof Ctor == 'function' && Ctor instanceof Ctor &&
38491         funcToString.call(Ctor) == objectCtorString;
38492     }
38493
38494     /**
38495      * Checks if `value` is classified as a `RegExp` object.
38496      *
38497      * @static
38498      * @memberOf _
38499      * @since 0.1.0
38500      * @category Lang
38501      * @param {*} value The value to check.
38502      * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
38503      * @example
38504      *
38505      * _.isRegExp(/abc/);
38506      * // => true
38507      *
38508      * _.isRegExp('/abc/');
38509      * // => false
38510      */
38511     var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
38512
38513     /**
38514      * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
38515      * double precision number which isn't the result of a rounded unsafe integer.
38516      *
38517      * **Note:** This method is based on
38518      * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
38519      *
38520      * @static
38521      * @memberOf _
38522      * @since 4.0.0
38523      * @category Lang
38524      * @param {*} value The value to check.
38525      * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
38526      * @example
38527      *
38528      * _.isSafeInteger(3);
38529      * // => true
38530      *
38531      * _.isSafeInteger(Number.MIN_VALUE);
38532      * // => false
38533      *
38534      * _.isSafeInteger(Infinity);
38535      * // => false
38536      *
38537      * _.isSafeInteger('3');
38538      * // => false
38539      */
38540     function isSafeInteger(value) {
38541       return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
38542     }
38543
38544     /**
38545      * Checks if `value` is classified as a `Set` object.
38546      *
38547      * @static
38548      * @memberOf _
38549      * @since 4.3.0
38550      * @category Lang
38551      * @param {*} value The value to check.
38552      * @returns {boolean} Returns `true` if `value` is a set, else `false`.
38553      * @example
38554      *
38555      * _.isSet(new Set);
38556      * // => true
38557      *
38558      * _.isSet(new WeakSet);
38559      * // => false
38560      */
38561     var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
38562
38563     /**
38564      * Checks if `value` is classified as a `String` primitive or object.
38565      *
38566      * @static
38567      * @since 0.1.0
38568      * @memberOf _
38569      * @category Lang
38570      * @param {*} value The value to check.
38571      * @returns {boolean} Returns `true` if `value` is a string, else `false`.
38572      * @example
38573      *
38574      * _.isString('abc');
38575      * // => true
38576      *
38577      * _.isString(1);
38578      * // => false
38579      */
38580     function isString(value) {
38581       return typeof value == 'string' ||
38582         (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
38583     }
38584
38585     /**
38586      * Checks if `value` is classified as a `Symbol` primitive or object.
38587      *
38588      * @static
38589      * @memberOf _
38590      * @since 4.0.0
38591      * @category Lang
38592      * @param {*} value The value to check.
38593      * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
38594      * @example
38595      *
38596      * _.isSymbol(Symbol.iterator);
38597      * // => true
38598      *
38599      * _.isSymbol('abc');
38600      * // => false
38601      */
38602     function isSymbol(value) {
38603       return typeof value == 'symbol' ||
38604         (isObjectLike(value) && baseGetTag(value) == symbolTag);
38605     }
38606
38607     /**
38608      * Checks if `value` is classified as a typed array.
38609      *
38610      * @static
38611      * @memberOf _
38612      * @since 3.0.0
38613      * @category Lang
38614      * @param {*} value The value to check.
38615      * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
38616      * @example
38617      *
38618      * _.isTypedArray(new Uint8Array);
38619      * // => true
38620      *
38621      * _.isTypedArray([]);
38622      * // => false
38623      */
38624     var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
38625
38626     /**
38627      * Checks if `value` is `undefined`.
38628      *
38629      * @static
38630      * @since 0.1.0
38631      * @memberOf _
38632      * @category Lang
38633      * @param {*} value The value to check.
38634      * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
38635      * @example
38636      *
38637      * _.isUndefined(void 0);
38638      * // => true
38639      *
38640      * _.isUndefined(null);
38641      * // => false
38642      */
38643     function isUndefined(value) {
38644       return value === undefined;
38645     }
38646
38647     /**
38648      * Checks if `value` is classified as a `WeakMap` object.
38649      *
38650      * @static
38651      * @memberOf _
38652      * @since 4.3.0
38653      * @category Lang
38654      * @param {*} value The value to check.
38655      * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
38656      * @example
38657      *
38658      * _.isWeakMap(new WeakMap);
38659      * // => true
38660      *
38661      * _.isWeakMap(new Map);
38662      * // => false
38663      */
38664     function isWeakMap(value) {
38665       return isObjectLike(value) && getTag(value) == weakMapTag;
38666     }
38667
38668     /**
38669      * Checks if `value` is classified as a `WeakSet` object.
38670      *
38671      * @static
38672      * @memberOf _
38673      * @since 4.3.0
38674      * @category Lang
38675      * @param {*} value The value to check.
38676      * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
38677      * @example
38678      *
38679      * _.isWeakSet(new WeakSet);
38680      * // => true
38681      *
38682      * _.isWeakSet(new Set);
38683      * // => false
38684      */
38685     function isWeakSet(value) {
38686       return isObjectLike(value) && baseGetTag(value) == weakSetTag;
38687     }
38688
38689     /**
38690      * Checks if `value` is less than `other`.
38691      *
38692      * @static
38693      * @memberOf _
38694      * @since 3.9.0
38695      * @category Lang
38696      * @param {*} value The value to compare.
38697      * @param {*} other The other value to compare.
38698      * @returns {boolean} Returns `true` if `value` is less than `other`,
38699      *  else `false`.
38700      * @see _.gt
38701      * @example
38702      *
38703      * _.lt(1, 3);
38704      * // => true
38705      *
38706      * _.lt(3, 3);
38707      * // => false
38708      *
38709      * _.lt(3, 1);
38710      * // => false
38711      */
38712     var lt = createRelationalOperation(baseLt);
38713
38714     /**
38715      * Checks if `value` is less than or equal to `other`.
38716      *
38717      * @static
38718      * @memberOf _
38719      * @since 3.9.0
38720      * @category Lang
38721      * @param {*} value The value to compare.
38722      * @param {*} other The other value to compare.
38723      * @returns {boolean} Returns `true` if `value` is less than or equal to
38724      *  `other`, else `false`.
38725      * @see _.gte
38726      * @example
38727      *
38728      * _.lte(1, 3);
38729      * // => true
38730      *
38731      * _.lte(3, 3);
38732      * // => true
38733      *
38734      * _.lte(3, 1);
38735      * // => false
38736      */
38737     var lte = createRelationalOperation(function(value, other) {
38738       return value <= other;
38739     });
38740
38741     /**
38742      * Converts `value` to an array.
38743      *
38744      * @static
38745      * @since 0.1.0
38746      * @memberOf _
38747      * @category Lang
38748      * @param {*} value The value to convert.
38749      * @returns {Array} Returns the converted array.
38750      * @example
38751      *
38752      * _.toArray({ 'a': 1, 'b': 2 });
38753      * // => [1, 2]
38754      *
38755      * _.toArray('abc');
38756      * // => ['a', 'b', 'c']
38757      *
38758      * _.toArray(1);
38759      * // => []
38760      *
38761      * _.toArray(null);
38762      * // => []
38763      */
38764     function toArray(value) {
38765       if (!value) {
38766         return [];
38767       }
38768       if (isArrayLike(value)) {
38769         return isString(value) ? stringToArray(value) : copyArray(value);
38770       }
38771       if (symIterator && value[symIterator]) {
38772         return iteratorToArray(value[symIterator]());
38773       }
38774       var tag = getTag(value),
38775           func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
38776
38777       return func(value);
38778     }
38779
38780     /**
38781      * Converts `value` to a finite number.
38782      *
38783      * @static
38784      * @memberOf _
38785      * @since 4.12.0
38786      * @category Lang
38787      * @param {*} value The value to convert.
38788      * @returns {number} Returns the converted number.
38789      * @example
38790      *
38791      * _.toFinite(3.2);
38792      * // => 3.2
38793      *
38794      * _.toFinite(Number.MIN_VALUE);
38795      * // => 5e-324
38796      *
38797      * _.toFinite(Infinity);
38798      * // => 1.7976931348623157e+308
38799      *
38800      * _.toFinite('3.2');
38801      * // => 3.2
38802      */
38803     function toFinite(value) {
38804       if (!value) {
38805         return value === 0 ? value : 0;
38806       }
38807       value = toNumber(value);
38808       if (value === INFINITY || value === -INFINITY) {
38809         var sign = (value < 0 ? -1 : 1);
38810         return sign * MAX_INTEGER;
38811       }
38812       return value === value ? value : 0;
38813     }
38814
38815     /**
38816      * Converts `value` to an integer.
38817      *
38818      * **Note:** This method is loosely based on
38819      * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
38820      *
38821      * @static
38822      * @memberOf _
38823      * @since 4.0.0
38824      * @category Lang
38825      * @param {*} value The value to convert.
38826      * @returns {number} Returns the converted integer.
38827      * @example
38828      *
38829      * _.toInteger(3.2);
38830      * // => 3
38831      *
38832      * _.toInteger(Number.MIN_VALUE);
38833      * // => 0
38834      *
38835      * _.toInteger(Infinity);
38836      * // => 1.7976931348623157e+308
38837      *
38838      * _.toInteger('3.2');
38839      * // => 3
38840      */
38841     function toInteger(value) {
38842       var result = toFinite(value),
38843           remainder = result % 1;
38844
38845       return result === result ? (remainder ? result - remainder : result) : 0;
38846     }
38847
38848     /**
38849      * Converts `value` to an integer suitable for use as the length of an
38850      * array-like object.
38851      *
38852      * **Note:** This method is based on
38853      * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
38854      *
38855      * @static
38856      * @memberOf _
38857      * @since 4.0.0
38858      * @category Lang
38859      * @param {*} value The value to convert.
38860      * @returns {number} Returns the converted integer.
38861      * @example
38862      *
38863      * _.toLength(3.2);
38864      * // => 3
38865      *
38866      * _.toLength(Number.MIN_VALUE);
38867      * // => 0
38868      *
38869      * _.toLength(Infinity);
38870      * // => 4294967295
38871      *
38872      * _.toLength('3.2');
38873      * // => 3
38874      */
38875     function toLength(value) {
38876       return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
38877     }
38878
38879     /**
38880      * Converts `value` to a number.
38881      *
38882      * @static
38883      * @memberOf _
38884      * @since 4.0.0
38885      * @category Lang
38886      * @param {*} value The value to process.
38887      * @returns {number} Returns the number.
38888      * @example
38889      *
38890      * _.toNumber(3.2);
38891      * // => 3.2
38892      *
38893      * _.toNumber(Number.MIN_VALUE);
38894      * // => 5e-324
38895      *
38896      * _.toNumber(Infinity);
38897      * // => Infinity
38898      *
38899      * _.toNumber('3.2');
38900      * // => 3.2
38901      */
38902     function toNumber(value) {
38903       if (typeof value == 'number') {
38904         return value;
38905       }
38906       if (isSymbol(value)) {
38907         return NAN;
38908       }
38909       if (isObject(value)) {
38910         var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
38911         value = isObject(other) ? (other + '') : other;
38912       }
38913       if (typeof value != 'string') {
38914         return value === 0 ? value : +value;
38915       }
38916       value = value.replace(reTrim, '');
38917       var isBinary = reIsBinary.test(value);
38918       return (isBinary || reIsOctal.test(value))
38919         ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
38920         : (reIsBadHex.test(value) ? NAN : +value);
38921     }
38922
38923     /**
38924      * Converts `value` to a plain object flattening inherited enumerable string
38925      * keyed properties of `value` to own properties of the plain object.
38926      *
38927      * @static
38928      * @memberOf _
38929      * @since 3.0.0
38930      * @category Lang
38931      * @param {*} value The value to convert.
38932      * @returns {Object} Returns the converted plain object.
38933      * @example
38934      *
38935      * function Foo() {
38936      *   this.b = 2;
38937      * }
38938      *
38939      * Foo.prototype.c = 3;
38940      *
38941      * _.assign({ 'a': 1 }, new Foo);
38942      * // => { 'a': 1, 'b': 2 }
38943      *
38944      * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
38945      * // => { 'a': 1, 'b': 2, 'c': 3 }
38946      */
38947     function toPlainObject(value) {
38948       return copyObject(value, keysIn(value));
38949     }
38950
38951     /**
38952      * Converts `value` to a safe integer. A safe integer can be compared and
38953      * represented correctly.
38954      *
38955      * @static
38956      * @memberOf _
38957      * @since 4.0.0
38958      * @category Lang
38959      * @param {*} value The value to convert.
38960      * @returns {number} Returns the converted integer.
38961      * @example
38962      *
38963      * _.toSafeInteger(3.2);
38964      * // => 3
38965      *
38966      * _.toSafeInteger(Number.MIN_VALUE);
38967      * // => 0
38968      *
38969      * _.toSafeInteger(Infinity);
38970      * // => 9007199254740991
38971      *
38972      * _.toSafeInteger('3.2');
38973      * // => 3
38974      */
38975     function toSafeInteger(value) {
38976       return value
38977         ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
38978         : (value === 0 ? value : 0);
38979     }
38980
38981     /**
38982      * Converts `value` to a string. An empty string is returned for `null`
38983      * and `undefined` values. The sign of `-0` is preserved.
38984      *
38985      * @static
38986      * @memberOf _
38987      * @since 4.0.0
38988      * @category Lang
38989      * @param {*} value The value to convert.
38990      * @returns {string} Returns the converted string.
38991      * @example
38992      *
38993      * _.toString(null);
38994      * // => ''
38995      *
38996      * _.toString(-0);
38997      * // => '-0'
38998      *
38999      * _.toString([1, 2, 3]);
39000      * // => '1,2,3'
39001      */
39002     function toString(value) {
39003       return value == null ? '' : baseToString(value);
39004     }
39005
39006     /*------------------------------------------------------------------------*/
39007
39008     /**
39009      * Assigns own enumerable string keyed properties of source objects to the
39010      * destination object. Source objects are applied from left to right.
39011      * Subsequent sources overwrite property assignments of previous sources.
39012      *
39013      * **Note:** This method mutates `object` and is loosely based on
39014      * [`Object.assign`](https://mdn.io/Object/assign).
39015      *
39016      * @static
39017      * @memberOf _
39018      * @since 0.10.0
39019      * @category Object
39020      * @param {Object} object The destination object.
39021      * @param {...Object} [sources] The source objects.
39022      * @returns {Object} Returns `object`.
39023      * @see _.assignIn
39024      * @example
39025      *
39026      * function Foo() {
39027      *   this.a = 1;
39028      * }
39029      *
39030      * function Bar() {
39031      *   this.c = 3;
39032      * }
39033      *
39034      * Foo.prototype.b = 2;
39035      * Bar.prototype.d = 4;
39036      *
39037      * _.assign({ 'a': 0 }, new Foo, new Bar);
39038      * // => { 'a': 1, 'c': 3 }
39039      */
39040     var assign = createAssigner(function(object, source) {
39041       if (isPrototype(source) || isArrayLike(source)) {
39042         copyObject(source, keys(source), object);
39043         return;
39044       }
39045       for (var key in source) {
39046         if (hasOwnProperty.call(source, key)) {
39047           assignValue(object, key, source[key]);
39048         }
39049       }
39050     });
39051
39052     /**
39053      * This method is like `_.assign` except that it iterates over own and
39054      * inherited source properties.
39055      *
39056      * **Note:** This method mutates `object`.
39057      *
39058      * @static
39059      * @memberOf _
39060      * @since 4.0.0
39061      * @alias extend
39062      * @category Object
39063      * @param {Object} object The destination object.
39064      * @param {...Object} [sources] The source objects.
39065      * @returns {Object} Returns `object`.
39066      * @see _.assign
39067      * @example
39068      *
39069      * function Foo() {
39070      *   this.a = 1;
39071      * }
39072      *
39073      * function Bar() {
39074      *   this.c = 3;
39075      * }
39076      *
39077      * Foo.prototype.b = 2;
39078      * Bar.prototype.d = 4;
39079      *
39080      * _.assignIn({ 'a': 0 }, new Foo, new Bar);
39081      * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
39082      */
39083     var assignIn = createAssigner(function(object, source) {
39084       copyObject(source, keysIn(source), object);
39085     });
39086
39087     /**
39088      * This method is like `_.assignIn` except that it accepts `customizer`
39089      * which is invoked to produce the assigned values. If `customizer` returns
39090      * `undefined`, assignment is handled by the method instead. The `customizer`
39091      * is invoked with five arguments: (objValue, srcValue, key, object, source).
39092      *
39093      * **Note:** This method mutates `object`.
39094      *
39095      * @static
39096      * @memberOf _
39097      * @since 4.0.0
39098      * @alias extendWith
39099      * @category Object
39100      * @param {Object} object The destination object.
39101      * @param {...Object} sources The source objects.
39102      * @param {Function} [customizer] The function to customize assigned values.
39103      * @returns {Object} Returns `object`.
39104      * @see _.assignWith
39105      * @example
39106      *
39107      * function customizer(objValue, srcValue) {
39108      *   return _.isUndefined(objValue) ? srcValue : objValue;
39109      * }
39110      *
39111      * var defaults = _.partialRight(_.assignInWith, customizer);
39112      *
39113      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
39114      * // => { 'a': 1, 'b': 2 }
39115      */
39116     var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
39117       copyObject(source, keysIn(source), object, customizer);
39118     });
39119
39120     /**
39121      * This method is like `_.assign` except that it accepts `customizer`
39122      * which is invoked to produce the assigned values. If `customizer` returns
39123      * `undefined`, assignment is handled by the method instead. The `customizer`
39124      * is invoked with five arguments: (objValue, srcValue, key, object, source).
39125      *
39126      * **Note:** This method mutates `object`.
39127      *
39128      * @static
39129      * @memberOf _
39130      * @since 4.0.0
39131      * @category Object
39132      * @param {Object} object The destination object.
39133      * @param {...Object} sources The source objects.
39134      * @param {Function} [customizer] The function to customize assigned values.
39135      * @returns {Object} Returns `object`.
39136      * @see _.assignInWith
39137      * @example
39138      *
39139      * function customizer(objValue, srcValue) {
39140      *   return _.isUndefined(objValue) ? srcValue : objValue;
39141      * }
39142      *
39143      * var defaults = _.partialRight(_.assignWith, customizer);
39144      *
39145      * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
39146      * // => { 'a': 1, 'b': 2 }
39147      */
39148     var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
39149       copyObject(source, keys(source), object, customizer);
39150     });
39151
39152     /**
39153      * Creates an array of values corresponding to `paths` of `object`.
39154      *
39155      * @static
39156      * @memberOf _
39157      * @since 1.0.0
39158      * @category Object
39159      * @param {Object} object The object to iterate over.
39160      * @param {...(string|string[])} [paths] The property paths to pick.
39161      * @returns {Array} Returns the picked values.
39162      * @example
39163      *
39164      * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
39165      *
39166      * _.at(object, ['a[0].b.c', 'a[1]']);
39167      * // => [3, 4]
39168      */
39169     var at = flatRest(baseAt);
39170
39171     /**
39172      * Creates an object that inherits from the `prototype` object. If a
39173      * `properties` object is given, its own enumerable string keyed properties
39174      * are assigned to the created object.
39175      *
39176      * @static
39177      * @memberOf _
39178      * @since 2.3.0
39179      * @category Object
39180      * @param {Object} prototype The object to inherit from.
39181      * @param {Object} [properties] The properties to assign to the object.
39182      * @returns {Object} Returns the new object.
39183      * @example
39184      *
39185      * function Shape() {
39186      *   this.x = 0;
39187      *   this.y = 0;
39188      * }
39189      *
39190      * function Circle() {
39191      *   Shape.call(this);
39192      * }
39193      *
39194      * Circle.prototype = _.create(Shape.prototype, {
39195      *   'constructor': Circle
39196      * });
39197      *
39198      * var circle = new Circle;
39199      * circle instanceof Circle;
39200      * // => true
39201      *
39202      * circle instanceof Shape;
39203      * // => true
39204      */
39205     function create(prototype, properties) {
39206       var result = baseCreate(prototype);
39207       return properties == null ? result : baseAssign(result, properties);
39208     }
39209
39210     /**
39211      * Assigns own and inherited enumerable string keyed properties of source
39212      * objects to the destination object for all destination properties that
39213      * resolve to `undefined`. Source objects are applied from left to right.
39214      * Once a property is set, additional values of the same property are ignored.
39215      *
39216      * **Note:** This method mutates `object`.
39217      *
39218      * @static
39219      * @since 0.1.0
39220      * @memberOf _
39221      * @category Object
39222      * @param {Object} object The destination object.
39223      * @param {...Object} [sources] The source objects.
39224      * @returns {Object} Returns `object`.
39225      * @see _.defaultsDeep
39226      * @example
39227      *
39228      * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
39229      * // => { 'a': 1, 'b': 2 }
39230      */
39231     var defaults = baseRest(function(object, sources) {
39232       object = Object(object);
39233
39234       var index = -1;
39235       var length = sources.length;
39236       var guard = length > 2 ? sources[2] : undefined;
39237
39238       if (guard && isIterateeCall(sources[0], sources[1], guard)) {
39239         length = 1;
39240       }
39241
39242       while (++index < length) {
39243         var source = sources[index];
39244         var props = keysIn(source);
39245         var propsIndex = -1;
39246         var propsLength = props.length;
39247
39248         while (++propsIndex < propsLength) {
39249           var key = props[propsIndex];
39250           var value = object[key];
39251
39252           if (value === undefined ||
39253               (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
39254             object[key] = source[key];
39255           }
39256         }
39257       }
39258
39259       return object;
39260     });
39261
39262     /**
39263      * This method is like `_.defaults` except that it recursively assigns
39264      * default properties.
39265      *
39266      * **Note:** This method mutates `object`.
39267      *
39268      * @static
39269      * @memberOf _
39270      * @since 3.10.0
39271      * @category Object
39272      * @param {Object} object The destination object.
39273      * @param {...Object} [sources] The source objects.
39274      * @returns {Object} Returns `object`.
39275      * @see _.defaults
39276      * @example
39277      *
39278      * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
39279      * // => { 'a': { 'b': 2, 'c': 3 } }
39280      */
39281     var defaultsDeep = baseRest(function(args) {
39282       args.push(undefined, customDefaultsMerge);
39283       return apply(mergeWith, undefined, args);
39284     });
39285
39286     /**
39287      * This method is like `_.find` except that it returns the key of the first
39288      * element `predicate` returns truthy for instead of the element itself.
39289      *
39290      * @static
39291      * @memberOf _
39292      * @since 1.1.0
39293      * @category Object
39294      * @param {Object} object The object to inspect.
39295      * @param {Function} [predicate=_.identity] The function invoked per iteration.
39296      * @returns {string|undefined} Returns the key of the matched element,
39297      *  else `undefined`.
39298      * @example
39299      *
39300      * var users = {
39301      *   'barney':  { 'age': 36, 'active': true },
39302      *   'fred':    { 'age': 40, 'active': false },
39303      *   'pebbles': { 'age': 1,  'active': true }
39304      * };
39305      *
39306      * _.findKey(users, function(o) { return o.age < 40; });
39307      * // => 'barney' (iteration order is not guaranteed)
39308      *
39309      * // The `_.matches` iteratee shorthand.
39310      * _.findKey(users, { 'age': 1, 'active': true });
39311      * // => 'pebbles'
39312      *
39313      * // The `_.matchesProperty` iteratee shorthand.
39314      * _.findKey(users, ['active', false]);
39315      * // => 'fred'
39316      *
39317      * // The `_.property` iteratee shorthand.
39318      * _.findKey(users, 'active');
39319      * // => 'barney'
39320      */
39321     function findKey(object, predicate) {
39322       return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
39323     }
39324
39325     /**
39326      * This method is like `_.findKey` except that it iterates over elements of
39327      * a collection in the opposite order.
39328      *
39329      * @static
39330      * @memberOf _
39331      * @since 2.0.0
39332      * @category Object
39333      * @param {Object} object The object to inspect.
39334      * @param {Function} [predicate=_.identity] The function invoked per iteration.
39335      * @returns {string|undefined} Returns the key of the matched element,
39336      *  else `undefined`.
39337      * @example
39338      *
39339      * var users = {
39340      *   'barney':  { 'age': 36, 'active': true },
39341      *   'fred':    { 'age': 40, 'active': false },
39342      *   'pebbles': { 'age': 1,  'active': true }
39343      * };
39344      *
39345      * _.findLastKey(users, function(o) { return o.age < 40; });
39346      * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
39347      *
39348      * // The `_.matches` iteratee shorthand.
39349      * _.findLastKey(users, { 'age': 36, 'active': true });
39350      * // => 'barney'
39351      *
39352      * // The `_.matchesProperty` iteratee shorthand.
39353      * _.findLastKey(users, ['active', false]);
39354      * // => 'fred'
39355      *
39356      * // The `_.property` iteratee shorthand.
39357      * _.findLastKey(users, 'active');
39358      * // => 'pebbles'
39359      */
39360     function findLastKey(object, predicate) {
39361       return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
39362     }
39363
39364     /**
39365      * Iterates over own and inherited enumerable string keyed properties of an
39366      * object and invokes `iteratee` for each property. The iteratee is invoked
39367      * with three arguments: (value, key, object). Iteratee functions may exit
39368      * iteration early by explicitly returning `false`.
39369      *
39370      * @static
39371      * @memberOf _
39372      * @since 0.3.0
39373      * @category Object
39374      * @param {Object} object The object to iterate over.
39375      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39376      * @returns {Object} Returns `object`.
39377      * @see _.forInRight
39378      * @example
39379      *
39380      * function Foo() {
39381      *   this.a = 1;
39382      *   this.b = 2;
39383      * }
39384      *
39385      * Foo.prototype.c = 3;
39386      *
39387      * _.forIn(new Foo, function(value, key) {
39388      *   console.log(key);
39389      * });
39390      * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
39391      */
39392     function forIn(object, iteratee) {
39393       return object == null
39394         ? object
39395         : baseFor(object, getIteratee(iteratee, 3), keysIn);
39396     }
39397
39398     /**
39399      * This method is like `_.forIn` except that it iterates over properties of
39400      * `object` in the opposite order.
39401      *
39402      * @static
39403      * @memberOf _
39404      * @since 2.0.0
39405      * @category Object
39406      * @param {Object} object The object to iterate over.
39407      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39408      * @returns {Object} Returns `object`.
39409      * @see _.forIn
39410      * @example
39411      *
39412      * function Foo() {
39413      *   this.a = 1;
39414      *   this.b = 2;
39415      * }
39416      *
39417      * Foo.prototype.c = 3;
39418      *
39419      * _.forInRight(new Foo, function(value, key) {
39420      *   console.log(key);
39421      * });
39422      * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
39423      */
39424     function forInRight(object, iteratee) {
39425       return object == null
39426         ? object
39427         : baseForRight(object, getIteratee(iteratee, 3), keysIn);
39428     }
39429
39430     /**
39431      * Iterates over own enumerable string keyed properties of an object and
39432      * invokes `iteratee` for each property. The iteratee is invoked with three
39433      * arguments: (value, key, object). Iteratee functions may exit iteration
39434      * early by explicitly returning `false`.
39435      *
39436      * @static
39437      * @memberOf _
39438      * @since 0.3.0
39439      * @category Object
39440      * @param {Object} object The object to iterate over.
39441      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39442      * @returns {Object} Returns `object`.
39443      * @see _.forOwnRight
39444      * @example
39445      *
39446      * function Foo() {
39447      *   this.a = 1;
39448      *   this.b = 2;
39449      * }
39450      *
39451      * Foo.prototype.c = 3;
39452      *
39453      * _.forOwn(new Foo, function(value, key) {
39454      *   console.log(key);
39455      * });
39456      * // => Logs 'a' then 'b' (iteration order is not guaranteed).
39457      */
39458     function forOwn(object, iteratee) {
39459       return object && baseForOwn(object, getIteratee(iteratee, 3));
39460     }
39461
39462     /**
39463      * This method is like `_.forOwn` except that it iterates over properties of
39464      * `object` in the opposite order.
39465      *
39466      * @static
39467      * @memberOf _
39468      * @since 2.0.0
39469      * @category Object
39470      * @param {Object} object The object to iterate over.
39471      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39472      * @returns {Object} Returns `object`.
39473      * @see _.forOwn
39474      * @example
39475      *
39476      * function Foo() {
39477      *   this.a = 1;
39478      *   this.b = 2;
39479      * }
39480      *
39481      * Foo.prototype.c = 3;
39482      *
39483      * _.forOwnRight(new Foo, function(value, key) {
39484      *   console.log(key);
39485      * });
39486      * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
39487      */
39488     function forOwnRight(object, iteratee) {
39489       return object && baseForOwnRight(object, getIteratee(iteratee, 3));
39490     }
39491
39492     /**
39493      * Creates an array of function property names from own enumerable properties
39494      * of `object`.
39495      *
39496      * @static
39497      * @since 0.1.0
39498      * @memberOf _
39499      * @category Object
39500      * @param {Object} object The object to inspect.
39501      * @returns {Array} Returns the function names.
39502      * @see _.functionsIn
39503      * @example
39504      *
39505      * function Foo() {
39506      *   this.a = _.constant('a');
39507      *   this.b = _.constant('b');
39508      * }
39509      *
39510      * Foo.prototype.c = _.constant('c');
39511      *
39512      * _.functions(new Foo);
39513      * // => ['a', 'b']
39514      */
39515     function functions(object) {
39516       return object == null ? [] : baseFunctions(object, keys(object));
39517     }
39518
39519     /**
39520      * Creates an array of function property names from own and inherited
39521      * enumerable properties of `object`.
39522      *
39523      * @static
39524      * @memberOf _
39525      * @since 4.0.0
39526      * @category Object
39527      * @param {Object} object The object to inspect.
39528      * @returns {Array} Returns the function names.
39529      * @see _.functions
39530      * @example
39531      *
39532      * function Foo() {
39533      *   this.a = _.constant('a');
39534      *   this.b = _.constant('b');
39535      * }
39536      *
39537      * Foo.prototype.c = _.constant('c');
39538      *
39539      * _.functionsIn(new Foo);
39540      * // => ['a', 'b', 'c']
39541      */
39542     function functionsIn(object) {
39543       return object == null ? [] : baseFunctions(object, keysIn(object));
39544     }
39545
39546     /**
39547      * Gets the value at `path` of `object`. If the resolved value is
39548      * `undefined`, the `defaultValue` is returned in its place.
39549      *
39550      * @static
39551      * @memberOf _
39552      * @since 3.7.0
39553      * @category Object
39554      * @param {Object} object The object to query.
39555      * @param {Array|string} path The path of the property to get.
39556      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
39557      * @returns {*} Returns the resolved value.
39558      * @example
39559      *
39560      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
39561      *
39562      * _.get(object, 'a[0].b.c');
39563      * // => 3
39564      *
39565      * _.get(object, ['a', '0', 'b', 'c']);
39566      * // => 3
39567      *
39568      * _.get(object, 'a.b.c', 'default');
39569      * // => 'default'
39570      */
39571     function get(object, path, defaultValue) {
39572       var result = object == null ? undefined : baseGet(object, path);
39573       return result === undefined ? defaultValue : result;
39574     }
39575
39576     /**
39577      * Checks if `path` is a direct property of `object`.
39578      *
39579      * @static
39580      * @since 0.1.0
39581      * @memberOf _
39582      * @category Object
39583      * @param {Object} object The object to query.
39584      * @param {Array|string} path The path to check.
39585      * @returns {boolean} Returns `true` if `path` exists, else `false`.
39586      * @example
39587      *
39588      * var object = { 'a': { 'b': 2 } };
39589      * var other = _.create({ 'a': _.create({ 'b': 2 }) });
39590      *
39591      * _.has(object, 'a');
39592      * // => true
39593      *
39594      * _.has(object, 'a.b');
39595      * // => true
39596      *
39597      * _.has(object, ['a', 'b']);
39598      * // => true
39599      *
39600      * _.has(other, 'a');
39601      * // => false
39602      */
39603     function has(object, path) {
39604       return object != null && hasPath(object, path, baseHas);
39605     }
39606
39607     /**
39608      * Checks if `path` is a direct or inherited property of `object`.
39609      *
39610      * @static
39611      * @memberOf _
39612      * @since 4.0.0
39613      * @category Object
39614      * @param {Object} object The object to query.
39615      * @param {Array|string} path The path to check.
39616      * @returns {boolean} Returns `true` if `path` exists, else `false`.
39617      * @example
39618      *
39619      * var object = _.create({ 'a': _.create({ 'b': 2 }) });
39620      *
39621      * _.hasIn(object, 'a');
39622      * // => true
39623      *
39624      * _.hasIn(object, 'a.b');
39625      * // => true
39626      *
39627      * _.hasIn(object, ['a', 'b']);
39628      * // => true
39629      *
39630      * _.hasIn(object, 'b');
39631      * // => false
39632      */
39633     function hasIn(object, path) {
39634       return object != null && hasPath(object, path, baseHasIn);
39635     }
39636
39637     /**
39638      * Creates an object composed of the inverted keys and values of `object`.
39639      * If `object` contains duplicate values, subsequent values overwrite
39640      * property assignments of previous values.
39641      *
39642      * @static
39643      * @memberOf _
39644      * @since 0.7.0
39645      * @category Object
39646      * @param {Object} object The object to invert.
39647      * @returns {Object} Returns the new inverted object.
39648      * @example
39649      *
39650      * var object = { 'a': 1, 'b': 2, 'c': 1 };
39651      *
39652      * _.invert(object);
39653      * // => { '1': 'c', '2': 'b' }
39654      */
39655     var invert = createInverter(function(result, value, key) {
39656       if (value != null &&
39657           typeof value.toString != 'function') {
39658         value = nativeObjectToString.call(value);
39659       }
39660
39661       result[value] = key;
39662     }, constant(identity));
39663
39664     /**
39665      * This method is like `_.invert` except that the inverted object is generated
39666      * from the results of running each element of `object` thru `iteratee`. The
39667      * corresponding inverted value of each inverted key is an array of keys
39668      * responsible for generating the inverted value. The iteratee is invoked
39669      * with one argument: (value).
39670      *
39671      * @static
39672      * @memberOf _
39673      * @since 4.1.0
39674      * @category Object
39675      * @param {Object} object The object to invert.
39676      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
39677      * @returns {Object} Returns the new inverted object.
39678      * @example
39679      *
39680      * var object = { 'a': 1, 'b': 2, 'c': 1 };
39681      *
39682      * _.invertBy(object);
39683      * // => { '1': ['a', 'c'], '2': ['b'] }
39684      *
39685      * _.invertBy(object, function(value) {
39686      *   return 'group' + value;
39687      * });
39688      * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
39689      */
39690     var invertBy = createInverter(function(result, value, key) {
39691       if (value != null &&
39692           typeof value.toString != 'function') {
39693         value = nativeObjectToString.call(value);
39694       }
39695
39696       if (hasOwnProperty.call(result, value)) {
39697         result[value].push(key);
39698       } else {
39699         result[value] = [key];
39700       }
39701     }, getIteratee);
39702
39703     /**
39704      * Invokes the method at `path` of `object`.
39705      *
39706      * @static
39707      * @memberOf _
39708      * @since 4.0.0
39709      * @category Object
39710      * @param {Object} object The object to query.
39711      * @param {Array|string} path The path of the method to invoke.
39712      * @param {...*} [args] The arguments to invoke the method with.
39713      * @returns {*} Returns the result of the invoked method.
39714      * @example
39715      *
39716      * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
39717      *
39718      * _.invoke(object, 'a[0].b.c.slice', 1, 3);
39719      * // => [2, 3]
39720      */
39721     var invoke = baseRest(baseInvoke);
39722
39723     /**
39724      * Creates an array of the own enumerable property names of `object`.
39725      *
39726      * **Note:** Non-object values are coerced to objects. See the
39727      * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
39728      * for more details.
39729      *
39730      * @static
39731      * @since 0.1.0
39732      * @memberOf _
39733      * @category Object
39734      * @param {Object} object The object to query.
39735      * @returns {Array} Returns the array of property names.
39736      * @example
39737      *
39738      * function Foo() {
39739      *   this.a = 1;
39740      *   this.b = 2;
39741      * }
39742      *
39743      * Foo.prototype.c = 3;
39744      *
39745      * _.keys(new Foo);
39746      * // => ['a', 'b'] (iteration order is not guaranteed)
39747      *
39748      * _.keys('hi');
39749      * // => ['0', '1']
39750      */
39751     function keys(object) {
39752       return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
39753     }
39754
39755     /**
39756      * Creates an array of the own and inherited enumerable property names of `object`.
39757      *
39758      * **Note:** Non-object values are coerced to objects.
39759      *
39760      * @static
39761      * @memberOf _
39762      * @since 3.0.0
39763      * @category Object
39764      * @param {Object} object The object to query.
39765      * @returns {Array} Returns the array of property names.
39766      * @example
39767      *
39768      * function Foo() {
39769      *   this.a = 1;
39770      *   this.b = 2;
39771      * }
39772      *
39773      * Foo.prototype.c = 3;
39774      *
39775      * _.keysIn(new Foo);
39776      * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
39777      */
39778     function keysIn(object) {
39779       return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
39780     }
39781
39782     /**
39783      * The opposite of `_.mapValues`; this method creates an object with the
39784      * same values as `object` and keys generated by running each own enumerable
39785      * string keyed property of `object` thru `iteratee`. The iteratee is invoked
39786      * with three arguments: (value, key, object).
39787      *
39788      * @static
39789      * @memberOf _
39790      * @since 3.8.0
39791      * @category Object
39792      * @param {Object} object The object to iterate over.
39793      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39794      * @returns {Object} Returns the new mapped object.
39795      * @see _.mapValues
39796      * @example
39797      *
39798      * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
39799      *   return key + value;
39800      * });
39801      * // => { 'a1': 1, 'b2': 2 }
39802      */
39803     function mapKeys(object, iteratee) {
39804       var result = {};
39805       iteratee = getIteratee(iteratee, 3);
39806
39807       baseForOwn(object, function(value, key, object) {
39808         baseAssignValue(result, iteratee(value, key, object), value);
39809       });
39810       return result;
39811     }
39812
39813     /**
39814      * Creates an object with the same keys as `object` and values generated
39815      * by running each own enumerable string keyed property of `object` thru
39816      * `iteratee`. The iteratee is invoked with three arguments:
39817      * (value, key, object).
39818      *
39819      * @static
39820      * @memberOf _
39821      * @since 2.4.0
39822      * @category Object
39823      * @param {Object} object The object to iterate over.
39824      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
39825      * @returns {Object} Returns the new mapped object.
39826      * @see _.mapKeys
39827      * @example
39828      *
39829      * var users = {
39830      *   'fred':    { 'user': 'fred',    'age': 40 },
39831      *   'pebbles': { 'user': 'pebbles', 'age': 1 }
39832      * };
39833      *
39834      * _.mapValues(users, function(o) { return o.age; });
39835      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
39836      *
39837      * // The `_.property` iteratee shorthand.
39838      * _.mapValues(users, 'age');
39839      * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
39840      */
39841     function mapValues(object, iteratee) {
39842       var result = {};
39843       iteratee = getIteratee(iteratee, 3);
39844
39845       baseForOwn(object, function(value, key, object) {
39846         baseAssignValue(result, key, iteratee(value, key, object));
39847       });
39848       return result;
39849     }
39850
39851     /**
39852      * This method is like `_.assign` except that it recursively merges own and
39853      * inherited enumerable string keyed properties of source objects into the
39854      * destination object. Source properties that resolve to `undefined` are
39855      * skipped if a destination value exists. Array and plain object properties
39856      * are merged recursively. Other objects and value types are overridden by
39857      * assignment. Source objects are applied from left to right. Subsequent
39858      * sources overwrite property assignments of previous sources.
39859      *
39860      * **Note:** This method mutates `object`.
39861      *
39862      * @static
39863      * @memberOf _
39864      * @since 0.5.0
39865      * @category Object
39866      * @param {Object} object The destination object.
39867      * @param {...Object} [sources] The source objects.
39868      * @returns {Object} Returns `object`.
39869      * @example
39870      *
39871      * var object = {
39872      *   'a': [{ 'b': 2 }, { 'd': 4 }]
39873      * };
39874      *
39875      * var other = {
39876      *   'a': [{ 'c': 3 }, { 'e': 5 }]
39877      * };
39878      *
39879      * _.merge(object, other);
39880      * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
39881      */
39882     var merge = createAssigner(function(object, source, srcIndex) {
39883       baseMerge(object, source, srcIndex);
39884     });
39885
39886     /**
39887      * This method is like `_.merge` except that it accepts `customizer` which
39888      * is invoked to produce the merged values of the destination and source
39889      * properties. If `customizer` returns `undefined`, merging is handled by the
39890      * method instead. The `customizer` is invoked with six arguments:
39891      * (objValue, srcValue, key, object, source, stack).
39892      *
39893      * **Note:** This method mutates `object`.
39894      *
39895      * @static
39896      * @memberOf _
39897      * @since 4.0.0
39898      * @category Object
39899      * @param {Object} object The destination object.
39900      * @param {...Object} sources The source objects.
39901      * @param {Function} customizer The function to customize assigned values.
39902      * @returns {Object} Returns `object`.
39903      * @example
39904      *
39905      * function customizer(objValue, srcValue) {
39906      *   if (_.isArray(objValue)) {
39907      *     return objValue.concat(srcValue);
39908      *   }
39909      * }
39910      *
39911      * var object = { 'a': [1], 'b': [2] };
39912      * var other = { 'a': [3], 'b': [4] };
39913      *
39914      * _.mergeWith(object, other, customizer);
39915      * // => { 'a': [1, 3], 'b': [2, 4] }
39916      */
39917     var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
39918       baseMerge(object, source, srcIndex, customizer);
39919     });
39920
39921     /**
39922      * The opposite of `_.pick`; this method creates an object composed of the
39923      * own and inherited enumerable property paths of `object` that are not omitted.
39924      *
39925      * **Note:** This method is considerably slower than `_.pick`.
39926      *
39927      * @static
39928      * @since 0.1.0
39929      * @memberOf _
39930      * @category Object
39931      * @param {Object} object The source object.
39932      * @param {...(string|string[])} [paths] The property paths to omit.
39933      * @returns {Object} Returns the new object.
39934      * @example
39935      *
39936      * var object = { 'a': 1, 'b': '2', 'c': 3 };
39937      *
39938      * _.omit(object, ['a', 'c']);
39939      * // => { 'b': '2' }
39940      */
39941     var omit = flatRest(function(object, paths) {
39942       var result = {};
39943       if (object == null) {
39944         return result;
39945       }
39946       var isDeep = false;
39947       paths = arrayMap(paths, function(path) {
39948         path = castPath(path, object);
39949         isDeep || (isDeep = path.length > 1);
39950         return path;
39951       });
39952       copyObject(object, getAllKeysIn(object), result);
39953       if (isDeep) {
39954         result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
39955       }
39956       var length = paths.length;
39957       while (length--) {
39958         baseUnset(result, paths[length]);
39959       }
39960       return result;
39961     });
39962
39963     /**
39964      * The opposite of `_.pickBy`; this method creates an object composed of
39965      * the own and inherited enumerable string keyed properties of `object` that
39966      * `predicate` doesn't return truthy for. The predicate is invoked with two
39967      * arguments: (value, key).
39968      *
39969      * @static
39970      * @memberOf _
39971      * @since 4.0.0
39972      * @category Object
39973      * @param {Object} object The source object.
39974      * @param {Function} [predicate=_.identity] The function invoked per property.
39975      * @returns {Object} Returns the new object.
39976      * @example
39977      *
39978      * var object = { 'a': 1, 'b': '2', 'c': 3 };
39979      *
39980      * _.omitBy(object, _.isNumber);
39981      * // => { 'b': '2' }
39982      */
39983     function omitBy(object, predicate) {
39984       return pickBy(object, negate(getIteratee(predicate)));
39985     }
39986
39987     /**
39988      * Creates an object composed of the picked `object` properties.
39989      *
39990      * @static
39991      * @since 0.1.0
39992      * @memberOf _
39993      * @category Object
39994      * @param {Object} object The source object.
39995      * @param {...(string|string[])} [paths] The property paths to pick.
39996      * @returns {Object} Returns the new object.
39997      * @example
39998      *
39999      * var object = { 'a': 1, 'b': '2', 'c': 3 };
40000      *
40001      * _.pick(object, ['a', 'c']);
40002      * // => { 'a': 1, 'c': 3 }
40003      */
40004     var pick = flatRest(function(object, paths) {
40005       return object == null ? {} : basePick(object, paths);
40006     });
40007
40008     /**
40009      * Creates an object composed of the `object` properties `predicate` returns
40010      * truthy for. The predicate is invoked with two arguments: (value, key).
40011      *
40012      * @static
40013      * @memberOf _
40014      * @since 4.0.0
40015      * @category Object
40016      * @param {Object} object The source object.
40017      * @param {Function} [predicate=_.identity] The function invoked per property.
40018      * @returns {Object} Returns the new object.
40019      * @example
40020      *
40021      * var object = { 'a': 1, 'b': '2', 'c': 3 };
40022      *
40023      * _.pickBy(object, _.isNumber);
40024      * // => { 'a': 1, 'c': 3 }
40025      */
40026     function pickBy(object, predicate) {
40027       if (object == null) {
40028         return {};
40029       }
40030       var props = arrayMap(getAllKeysIn(object), function(prop) {
40031         return [prop];
40032       });
40033       predicate = getIteratee(predicate);
40034       return basePickBy(object, props, function(value, path) {
40035         return predicate(value, path[0]);
40036       });
40037     }
40038
40039     /**
40040      * This method is like `_.get` except that if the resolved value is a
40041      * function it's invoked with the `this` binding of its parent object and
40042      * its result is returned.
40043      *
40044      * @static
40045      * @since 0.1.0
40046      * @memberOf _
40047      * @category Object
40048      * @param {Object} object The object to query.
40049      * @param {Array|string} path The path of the property to resolve.
40050      * @param {*} [defaultValue] The value returned for `undefined` resolved values.
40051      * @returns {*} Returns the resolved value.
40052      * @example
40053      *
40054      * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
40055      *
40056      * _.result(object, 'a[0].b.c1');
40057      * // => 3
40058      *
40059      * _.result(object, 'a[0].b.c2');
40060      * // => 4
40061      *
40062      * _.result(object, 'a[0].b.c3', 'default');
40063      * // => 'default'
40064      *
40065      * _.result(object, 'a[0].b.c3', _.constant('default'));
40066      * // => 'default'
40067      */
40068     function result(object, path, defaultValue) {
40069       path = castPath(path, object);
40070
40071       var index = -1,
40072           length = path.length;
40073
40074       // Ensure the loop is entered when path is empty.
40075       if (!length) {
40076         length = 1;
40077         object = undefined;
40078       }
40079       while (++index < length) {
40080         var value = object == null ? undefined : object[toKey(path[index])];
40081         if (value === undefined) {
40082           index = length;
40083           value = defaultValue;
40084         }
40085         object = isFunction(value) ? value.call(object) : value;
40086       }
40087       return object;
40088     }
40089
40090     /**
40091      * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
40092      * it's created. Arrays are created for missing index properties while objects
40093      * are created for all other missing properties. Use `_.setWith` to customize
40094      * `path` creation.
40095      *
40096      * **Note:** This method mutates `object`.
40097      *
40098      * @static
40099      * @memberOf _
40100      * @since 3.7.0
40101      * @category Object
40102      * @param {Object} object The object to modify.
40103      * @param {Array|string} path The path of the property to set.
40104      * @param {*} value The value to set.
40105      * @returns {Object} Returns `object`.
40106      * @example
40107      *
40108      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
40109      *
40110      * _.set(object, 'a[0].b.c', 4);
40111      * console.log(object.a[0].b.c);
40112      * // => 4
40113      *
40114      * _.set(object, ['x', '0', 'y', 'z'], 5);
40115      * console.log(object.x[0].y.z);
40116      * // => 5
40117      */
40118     function set(object, path, value) {
40119       return object == null ? object : baseSet(object, path, value);
40120     }
40121
40122     /**
40123      * This method is like `_.set` except that it accepts `customizer` which is
40124      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
40125      * path creation is handled by the method instead. The `customizer` is invoked
40126      * with three arguments: (nsValue, key, nsObject).
40127      *
40128      * **Note:** This method mutates `object`.
40129      *
40130      * @static
40131      * @memberOf _
40132      * @since 4.0.0
40133      * @category Object
40134      * @param {Object} object The object to modify.
40135      * @param {Array|string} path The path of the property to set.
40136      * @param {*} value The value to set.
40137      * @param {Function} [customizer] The function to customize assigned values.
40138      * @returns {Object} Returns `object`.
40139      * @example
40140      *
40141      * var object = {};
40142      *
40143      * _.setWith(object, '[0][1]', 'a', Object);
40144      * // => { '0': { '1': 'a' } }
40145      */
40146     function setWith(object, path, value, customizer) {
40147       customizer = typeof customizer == 'function' ? customizer : undefined;
40148       return object == null ? object : baseSet(object, path, value, customizer);
40149     }
40150
40151     /**
40152      * Creates an array of own enumerable string keyed-value pairs for `object`
40153      * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
40154      * entries are returned.
40155      *
40156      * @static
40157      * @memberOf _
40158      * @since 4.0.0
40159      * @alias entries
40160      * @category Object
40161      * @param {Object} object The object to query.
40162      * @returns {Array} Returns the key-value pairs.
40163      * @example
40164      *
40165      * function Foo() {
40166      *   this.a = 1;
40167      *   this.b = 2;
40168      * }
40169      *
40170      * Foo.prototype.c = 3;
40171      *
40172      * _.toPairs(new Foo);
40173      * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
40174      */
40175     var toPairs = createToPairs(keys);
40176
40177     /**
40178      * Creates an array of own and inherited enumerable string keyed-value pairs
40179      * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
40180      * or set, its entries are returned.
40181      *
40182      * @static
40183      * @memberOf _
40184      * @since 4.0.0
40185      * @alias entriesIn
40186      * @category Object
40187      * @param {Object} object The object to query.
40188      * @returns {Array} Returns the key-value pairs.
40189      * @example
40190      *
40191      * function Foo() {
40192      *   this.a = 1;
40193      *   this.b = 2;
40194      * }
40195      *
40196      * Foo.prototype.c = 3;
40197      *
40198      * _.toPairsIn(new Foo);
40199      * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
40200      */
40201     var toPairsIn = createToPairs(keysIn);
40202
40203     /**
40204      * An alternative to `_.reduce`; this method transforms `object` to a new
40205      * `accumulator` object which is the result of running each of its own
40206      * enumerable string keyed properties thru `iteratee`, with each invocation
40207      * potentially mutating the `accumulator` object. If `accumulator` is not
40208      * provided, a new object with the same `[[Prototype]]` will be used. The
40209      * iteratee is invoked with four arguments: (accumulator, value, key, object).
40210      * Iteratee functions may exit iteration early by explicitly returning `false`.
40211      *
40212      * @static
40213      * @memberOf _
40214      * @since 1.3.0
40215      * @category Object
40216      * @param {Object} object The object to iterate over.
40217      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
40218      * @param {*} [accumulator] The custom accumulator value.
40219      * @returns {*} Returns the accumulated value.
40220      * @example
40221      *
40222      * _.transform([2, 3, 4], function(result, n) {
40223      *   result.push(n *= n);
40224      *   return n % 2 == 0;
40225      * }, []);
40226      * // => [4, 9]
40227      *
40228      * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
40229      *   (result[value] || (result[value] = [])).push(key);
40230      * }, {});
40231      * // => { '1': ['a', 'c'], '2': ['b'] }
40232      */
40233     function transform(object, iteratee, accumulator) {
40234       var isArr = isArray(object),
40235           isArrLike = isArr || isBuffer(object) || isTypedArray(object);
40236
40237       iteratee = getIteratee(iteratee, 4);
40238       if (accumulator == null) {
40239         var Ctor = object && object.constructor;
40240         if (isArrLike) {
40241           accumulator = isArr ? new Ctor : [];
40242         }
40243         else if (isObject(object)) {
40244           accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
40245         }
40246         else {
40247           accumulator = {};
40248         }
40249       }
40250       (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
40251         return iteratee(accumulator, value, index, object);
40252       });
40253       return accumulator;
40254     }
40255
40256     /**
40257      * Removes the property at `path` of `object`.
40258      *
40259      * **Note:** This method mutates `object`.
40260      *
40261      * @static
40262      * @memberOf _
40263      * @since 4.0.0
40264      * @category Object
40265      * @param {Object} object The object to modify.
40266      * @param {Array|string} path The path of the property to unset.
40267      * @returns {boolean} Returns `true` if the property is deleted, else `false`.
40268      * @example
40269      *
40270      * var object = { 'a': [{ 'b': { 'c': 7 } }] };
40271      * _.unset(object, 'a[0].b.c');
40272      * // => true
40273      *
40274      * console.log(object);
40275      * // => { 'a': [{ 'b': {} }] };
40276      *
40277      * _.unset(object, ['a', '0', 'b', 'c']);
40278      * // => true
40279      *
40280      * console.log(object);
40281      * // => { 'a': [{ 'b': {} }] };
40282      */
40283     function unset(object, path) {
40284       return object == null ? true : baseUnset(object, path);
40285     }
40286
40287     /**
40288      * This method is like `_.set` except that accepts `updater` to produce the
40289      * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
40290      * is invoked with one argument: (value).
40291      *
40292      * **Note:** This method mutates `object`.
40293      *
40294      * @static
40295      * @memberOf _
40296      * @since 4.6.0
40297      * @category Object
40298      * @param {Object} object The object to modify.
40299      * @param {Array|string} path The path of the property to set.
40300      * @param {Function} updater The function to produce the updated value.
40301      * @returns {Object} Returns `object`.
40302      * @example
40303      *
40304      * var object = { 'a': [{ 'b': { 'c': 3 } }] };
40305      *
40306      * _.update(object, 'a[0].b.c', function(n) { return n * n; });
40307      * console.log(object.a[0].b.c);
40308      * // => 9
40309      *
40310      * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
40311      * console.log(object.x[0].y.z);
40312      * // => 0
40313      */
40314     function update(object, path, updater) {
40315       return object == null ? object : baseUpdate(object, path, castFunction(updater));
40316     }
40317
40318     /**
40319      * This method is like `_.update` except that it accepts `customizer` which is
40320      * invoked to produce the objects of `path`.  If `customizer` returns `undefined`
40321      * path creation is handled by the method instead. The `customizer` is invoked
40322      * with three arguments: (nsValue, key, nsObject).
40323      *
40324      * **Note:** This method mutates `object`.
40325      *
40326      * @static
40327      * @memberOf _
40328      * @since 4.6.0
40329      * @category Object
40330      * @param {Object} object The object to modify.
40331      * @param {Array|string} path The path of the property to set.
40332      * @param {Function} updater The function to produce the updated value.
40333      * @param {Function} [customizer] The function to customize assigned values.
40334      * @returns {Object} Returns `object`.
40335      * @example
40336      *
40337      * var object = {};
40338      *
40339      * _.updateWith(object, '[0][1]', _.constant('a'), Object);
40340      * // => { '0': { '1': 'a' } }
40341      */
40342     function updateWith(object, path, updater, customizer) {
40343       customizer = typeof customizer == 'function' ? customizer : undefined;
40344       return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
40345     }
40346
40347     /**
40348      * Creates an array of the own enumerable string keyed property values of `object`.
40349      *
40350      * **Note:** Non-object values are coerced to objects.
40351      *
40352      * @static
40353      * @since 0.1.0
40354      * @memberOf _
40355      * @category Object
40356      * @param {Object} object The object to query.
40357      * @returns {Array} Returns the array of property values.
40358      * @example
40359      *
40360      * function Foo() {
40361      *   this.a = 1;
40362      *   this.b = 2;
40363      * }
40364      *
40365      * Foo.prototype.c = 3;
40366      *
40367      * _.values(new Foo);
40368      * // => [1, 2] (iteration order is not guaranteed)
40369      *
40370      * _.values('hi');
40371      * // => ['h', 'i']
40372      */
40373     function values(object) {
40374       return object == null ? [] : baseValues(object, keys(object));
40375     }
40376
40377     /**
40378      * Creates an array of the own and inherited enumerable string keyed property
40379      * values of `object`.
40380      *
40381      * **Note:** Non-object values are coerced to objects.
40382      *
40383      * @static
40384      * @memberOf _
40385      * @since 3.0.0
40386      * @category Object
40387      * @param {Object} object The object to query.
40388      * @returns {Array} Returns the array of property values.
40389      * @example
40390      *
40391      * function Foo() {
40392      *   this.a = 1;
40393      *   this.b = 2;
40394      * }
40395      *
40396      * Foo.prototype.c = 3;
40397      *
40398      * _.valuesIn(new Foo);
40399      * // => [1, 2, 3] (iteration order is not guaranteed)
40400      */
40401     function valuesIn(object) {
40402       return object == null ? [] : baseValues(object, keysIn(object));
40403     }
40404
40405     /*------------------------------------------------------------------------*/
40406
40407     /**
40408      * Clamps `number` within the inclusive `lower` and `upper` bounds.
40409      *
40410      * @static
40411      * @memberOf _
40412      * @since 4.0.0
40413      * @category Number
40414      * @param {number} number The number to clamp.
40415      * @param {number} [lower] The lower bound.
40416      * @param {number} upper The upper bound.
40417      * @returns {number} Returns the clamped number.
40418      * @example
40419      *
40420      * _.clamp(-10, -5, 5);
40421      * // => -5
40422      *
40423      * _.clamp(10, -5, 5);
40424      * // => 5
40425      */
40426     function clamp(number, lower, upper) {
40427       if (upper === undefined) {
40428         upper = lower;
40429         lower = undefined;
40430       }
40431       if (upper !== undefined) {
40432         upper = toNumber(upper);
40433         upper = upper === upper ? upper : 0;
40434       }
40435       if (lower !== undefined) {
40436         lower = toNumber(lower);
40437         lower = lower === lower ? lower : 0;
40438       }
40439       return baseClamp(toNumber(number), lower, upper);
40440     }
40441
40442     /**
40443      * Checks if `n` is between `start` and up to, but not including, `end`. If
40444      * `end` is not specified, it's set to `start` with `start` then set to `0`.
40445      * If `start` is greater than `end` the params are swapped to support
40446      * negative ranges.
40447      *
40448      * @static
40449      * @memberOf _
40450      * @since 3.3.0
40451      * @category Number
40452      * @param {number} number The number to check.
40453      * @param {number} [start=0] The start of the range.
40454      * @param {number} end The end of the range.
40455      * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
40456      * @see _.range, _.rangeRight
40457      * @example
40458      *
40459      * _.inRange(3, 2, 4);
40460      * // => true
40461      *
40462      * _.inRange(4, 8);
40463      * // => true
40464      *
40465      * _.inRange(4, 2);
40466      * // => false
40467      *
40468      * _.inRange(2, 2);
40469      * // => false
40470      *
40471      * _.inRange(1.2, 2);
40472      * // => true
40473      *
40474      * _.inRange(5.2, 4);
40475      * // => false
40476      *
40477      * _.inRange(-3, -2, -6);
40478      * // => true
40479      */
40480     function inRange(number, start, end) {
40481       start = toFinite(start);
40482       if (end === undefined) {
40483         end = start;
40484         start = 0;
40485       } else {
40486         end = toFinite(end);
40487       }
40488       number = toNumber(number);
40489       return baseInRange(number, start, end);
40490     }
40491
40492     /**
40493      * Produces a random number between the inclusive `lower` and `upper` bounds.
40494      * If only one argument is provided a number between `0` and the given number
40495      * is returned. If `floating` is `true`, or either `lower` or `upper` are
40496      * floats, a floating-point number is returned instead of an integer.
40497      *
40498      * **Note:** JavaScript follows the IEEE-754 standard for resolving
40499      * floating-point values which can produce unexpected results.
40500      *
40501      * @static
40502      * @memberOf _
40503      * @since 0.7.0
40504      * @category Number
40505      * @param {number} [lower=0] The lower bound.
40506      * @param {number} [upper=1] The upper bound.
40507      * @param {boolean} [floating] Specify returning a floating-point number.
40508      * @returns {number} Returns the random number.
40509      * @example
40510      *
40511      * _.random(0, 5);
40512      * // => an integer between 0 and 5
40513      *
40514      * _.random(5);
40515      * // => also an integer between 0 and 5
40516      *
40517      * _.random(5, true);
40518      * // => a floating-point number between 0 and 5
40519      *
40520      * _.random(1.2, 5.2);
40521      * // => a floating-point number between 1.2 and 5.2
40522      */
40523     function random(lower, upper, floating) {
40524       if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
40525         upper = floating = undefined;
40526       }
40527       if (floating === undefined) {
40528         if (typeof upper == 'boolean') {
40529           floating = upper;
40530           upper = undefined;
40531         }
40532         else if (typeof lower == 'boolean') {
40533           floating = lower;
40534           lower = undefined;
40535         }
40536       }
40537       if (lower === undefined && upper === undefined) {
40538         lower = 0;
40539         upper = 1;
40540       }
40541       else {
40542         lower = toFinite(lower);
40543         if (upper === undefined) {
40544           upper = lower;
40545           lower = 0;
40546         } else {
40547           upper = toFinite(upper);
40548         }
40549       }
40550       if (lower > upper) {
40551         var temp = lower;
40552         lower = upper;
40553         upper = temp;
40554       }
40555       if (floating || lower % 1 || upper % 1) {
40556         var rand = nativeRandom();
40557         return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
40558       }
40559       return baseRandom(lower, upper);
40560     }
40561
40562     /*------------------------------------------------------------------------*/
40563
40564     /**
40565      * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
40566      *
40567      * @static
40568      * @memberOf _
40569      * @since 3.0.0
40570      * @category String
40571      * @param {string} [string=''] The string to convert.
40572      * @returns {string} Returns the camel cased string.
40573      * @example
40574      *
40575      * _.camelCase('Foo Bar');
40576      * // => 'fooBar'
40577      *
40578      * _.camelCase('--foo-bar--');
40579      * // => 'fooBar'
40580      *
40581      * _.camelCase('__FOO_BAR__');
40582      * // => 'fooBar'
40583      */
40584     var camelCase = createCompounder(function(result, word, index) {
40585       word = word.toLowerCase();
40586       return result + (index ? capitalize(word) : word);
40587     });
40588
40589     /**
40590      * Converts the first character of `string` to upper case and the remaining
40591      * to lower case.
40592      *
40593      * @static
40594      * @memberOf _
40595      * @since 3.0.0
40596      * @category String
40597      * @param {string} [string=''] The string to capitalize.
40598      * @returns {string} Returns the capitalized string.
40599      * @example
40600      *
40601      * _.capitalize('FRED');
40602      * // => 'Fred'
40603      */
40604     function capitalize(string) {
40605       return upperFirst(toString(string).toLowerCase());
40606     }
40607
40608     /**
40609      * Deburrs `string` by converting
40610      * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
40611      * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
40612      * letters to basic Latin letters and removing
40613      * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
40614      *
40615      * @static
40616      * @memberOf _
40617      * @since 3.0.0
40618      * @category String
40619      * @param {string} [string=''] The string to deburr.
40620      * @returns {string} Returns the deburred string.
40621      * @example
40622      *
40623      * _.deburr('déjà vu');
40624      * // => 'deja vu'
40625      */
40626     function deburr(string) {
40627       string = toString(string);
40628       return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
40629     }
40630
40631     /**
40632      * Checks if `string` ends with the given target string.
40633      *
40634      * @static
40635      * @memberOf _
40636      * @since 3.0.0
40637      * @category String
40638      * @param {string} [string=''] The string to inspect.
40639      * @param {string} [target] The string to search for.
40640      * @param {number} [position=string.length] The position to search up to.
40641      * @returns {boolean} Returns `true` if `string` ends with `target`,
40642      *  else `false`.
40643      * @example
40644      *
40645      * _.endsWith('abc', 'c');
40646      * // => true
40647      *
40648      * _.endsWith('abc', 'b');
40649      * // => false
40650      *
40651      * _.endsWith('abc', 'b', 2);
40652      * // => true
40653      */
40654     function endsWith(string, target, position) {
40655       string = toString(string);
40656       target = baseToString(target);
40657
40658       var length = string.length;
40659       position = position === undefined
40660         ? length
40661         : baseClamp(toInteger(position), 0, length);
40662
40663       var end = position;
40664       position -= target.length;
40665       return position >= 0 && string.slice(position, end) == target;
40666     }
40667
40668     /**
40669      * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
40670      * corresponding HTML entities.
40671      *
40672      * **Note:** No other characters are escaped. To escape additional
40673      * characters use a third-party library like [_he_](https://mths.be/he).
40674      *
40675      * Though the ">" character is escaped for symmetry, characters like
40676      * ">" and "/" don't need escaping in HTML and have no special meaning
40677      * unless they're part of a tag or unquoted attribute value. See
40678      * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
40679      * (under "semi-related fun fact") for more details.
40680      *
40681      * When working with HTML you should always
40682      * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
40683      * XSS vectors.
40684      *
40685      * @static
40686      * @since 0.1.0
40687      * @memberOf _
40688      * @category String
40689      * @param {string} [string=''] The string to escape.
40690      * @returns {string} Returns the escaped string.
40691      * @example
40692      *
40693      * _.escape('fred, barney, & pebbles');
40694      * // => 'fred, barney, &amp; pebbles'
40695      */
40696     function escape(string) {
40697       string = toString(string);
40698       return (string && reHasUnescapedHtml.test(string))
40699         ? string.replace(reUnescapedHtml, escapeHtmlChar)
40700         : string;
40701     }
40702
40703     /**
40704      * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
40705      * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
40706      *
40707      * @static
40708      * @memberOf _
40709      * @since 3.0.0
40710      * @category String
40711      * @param {string} [string=''] The string to escape.
40712      * @returns {string} Returns the escaped string.
40713      * @example
40714      *
40715      * _.escapeRegExp('[lodash](https://lodash.com/)');
40716      * // => '\[lodash\]\(https://lodash\.com/\)'
40717      */
40718     function escapeRegExp(string) {
40719       string = toString(string);
40720       return (string && reHasRegExpChar.test(string))
40721         ? string.replace(reRegExpChar, '\\$&')
40722         : string;
40723     }
40724
40725     /**
40726      * Converts `string` to
40727      * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
40728      *
40729      * @static
40730      * @memberOf _
40731      * @since 3.0.0
40732      * @category String
40733      * @param {string} [string=''] The string to convert.
40734      * @returns {string} Returns the kebab cased string.
40735      * @example
40736      *
40737      * _.kebabCase('Foo Bar');
40738      * // => 'foo-bar'
40739      *
40740      * _.kebabCase('fooBar');
40741      * // => 'foo-bar'
40742      *
40743      * _.kebabCase('__FOO_BAR__');
40744      * // => 'foo-bar'
40745      */
40746     var kebabCase = createCompounder(function(result, word, index) {
40747       return result + (index ? '-' : '') + word.toLowerCase();
40748     });
40749
40750     /**
40751      * Converts `string`, as space separated words, to lower case.
40752      *
40753      * @static
40754      * @memberOf _
40755      * @since 4.0.0
40756      * @category String
40757      * @param {string} [string=''] The string to convert.
40758      * @returns {string} Returns the lower cased string.
40759      * @example
40760      *
40761      * _.lowerCase('--Foo-Bar--');
40762      * // => 'foo bar'
40763      *
40764      * _.lowerCase('fooBar');
40765      * // => 'foo bar'
40766      *
40767      * _.lowerCase('__FOO_BAR__');
40768      * // => 'foo bar'
40769      */
40770     var lowerCase = createCompounder(function(result, word, index) {
40771       return result + (index ? ' ' : '') + word.toLowerCase();
40772     });
40773
40774     /**
40775      * Converts the first character of `string` to lower case.
40776      *
40777      * @static
40778      * @memberOf _
40779      * @since 4.0.0
40780      * @category String
40781      * @param {string} [string=''] The string to convert.
40782      * @returns {string} Returns the converted string.
40783      * @example
40784      *
40785      * _.lowerFirst('Fred');
40786      * // => 'fred'
40787      *
40788      * _.lowerFirst('FRED');
40789      * // => 'fRED'
40790      */
40791     var lowerFirst = createCaseFirst('toLowerCase');
40792
40793     /**
40794      * Pads `string` on the left and right sides if it's shorter than `length`.
40795      * Padding characters are truncated if they can't be evenly divided by `length`.
40796      *
40797      * @static
40798      * @memberOf _
40799      * @since 3.0.0
40800      * @category String
40801      * @param {string} [string=''] The string to pad.
40802      * @param {number} [length=0] The padding length.
40803      * @param {string} [chars=' '] The string used as padding.
40804      * @returns {string} Returns the padded string.
40805      * @example
40806      *
40807      * _.pad('abc', 8);
40808      * // => '  abc   '
40809      *
40810      * _.pad('abc', 8, '_-');
40811      * // => '_-abc_-_'
40812      *
40813      * _.pad('abc', 3);
40814      * // => 'abc'
40815      */
40816     function pad(string, length, chars) {
40817       string = toString(string);
40818       length = toInteger(length);
40819
40820       var strLength = length ? stringSize(string) : 0;
40821       if (!length || strLength >= length) {
40822         return string;
40823       }
40824       var mid = (length - strLength) / 2;
40825       return (
40826         createPadding(nativeFloor(mid), chars) +
40827         string +
40828         createPadding(nativeCeil(mid), chars)
40829       );
40830     }
40831
40832     /**
40833      * Pads `string` on the right side if it's shorter than `length`. Padding
40834      * characters are truncated if they exceed `length`.
40835      *
40836      * @static
40837      * @memberOf _
40838      * @since 4.0.0
40839      * @category String
40840      * @param {string} [string=''] The string to pad.
40841      * @param {number} [length=0] The padding length.
40842      * @param {string} [chars=' '] The string used as padding.
40843      * @returns {string} Returns the padded string.
40844      * @example
40845      *
40846      * _.padEnd('abc', 6);
40847      * // => 'abc   '
40848      *
40849      * _.padEnd('abc', 6, '_-');
40850      * // => 'abc_-_'
40851      *
40852      * _.padEnd('abc', 3);
40853      * // => 'abc'
40854      */
40855     function padEnd(string, length, chars) {
40856       string = toString(string);
40857       length = toInteger(length);
40858
40859       var strLength = length ? stringSize(string) : 0;
40860       return (length && strLength < length)
40861         ? (string + createPadding(length - strLength, chars))
40862         : string;
40863     }
40864
40865     /**
40866      * Pads `string` on the left side if it's shorter than `length`. Padding
40867      * characters are truncated if they exceed `length`.
40868      *
40869      * @static
40870      * @memberOf _
40871      * @since 4.0.0
40872      * @category String
40873      * @param {string} [string=''] The string to pad.
40874      * @param {number} [length=0] The padding length.
40875      * @param {string} [chars=' '] The string used as padding.
40876      * @returns {string} Returns the padded string.
40877      * @example
40878      *
40879      * _.padStart('abc', 6);
40880      * // => '   abc'
40881      *
40882      * _.padStart('abc', 6, '_-');
40883      * // => '_-_abc'
40884      *
40885      * _.padStart('abc', 3);
40886      * // => 'abc'
40887      */
40888     function padStart(string, length, chars) {
40889       string = toString(string);
40890       length = toInteger(length);
40891
40892       var strLength = length ? stringSize(string) : 0;
40893       return (length && strLength < length)
40894         ? (createPadding(length - strLength, chars) + string)
40895         : string;
40896     }
40897
40898     /**
40899      * Converts `string` to an integer of the specified radix. If `radix` is
40900      * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
40901      * hexadecimal, in which case a `radix` of `16` is used.
40902      *
40903      * **Note:** This method aligns with the
40904      * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
40905      *
40906      * @static
40907      * @memberOf _
40908      * @since 1.1.0
40909      * @category String
40910      * @param {string} string The string to convert.
40911      * @param {number} [radix=10] The radix to interpret `value` by.
40912      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40913      * @returns {number} Returns the converted integer.
40914      * @example
40915      *
40916      * _.parseInt('08');
40917      * // => 8
40918      *
40919      * _.map(['6', '08', '10'], _.parseInt);
40920      * // => [6, 8, 10]
40921      */
40922     function parseInt(string, radix, guard) {
40923       if (guard || radix == null) {
40924         radix = 0;
40925       } else if (radix) {
40926         radix = +radix;
40927       }
40928       return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
40929     }
40930
40931     /**
40932      * Repeats the given string `n` times.
40933      *
40934      * @static
40935      * @memberOf _
40936      * @since 3.0.0
40937      * @category String
40938      * @param {string} [string=''] The string to repeat.
40939      * @param {number} [n=1] The number of times to repeat the string.
40940      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
40941      * @returns {string} Returns the repeated string.
40942      * @example
40943      *
40944      * _.repeat('*', 3);
40945      * // => '***'
40946      *
40947      * _.repeat('abc', 2);
40948      * // => 'abcabc'
40949      *
40950      * _.repeat('abc', 0);
40951      * // => ''
40952      */
40953     function repeat(string, n, guard) {
40954       if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
40955         n = 1;
40956       } else {
40957         n = toInteger(n);
40958       }
40959       return baseRepeat(toString(string), n);
40960     }
40961
40962     /**
40963      * Replaces matches for `pattern` in `string` with `replacement`.
40964      *
40965      * **Note:** This method is based on
40966      * [`String#replace`](https://mdn.io/String/replace).
40967      *
40968      * @static
40969      * @memberOf _
40970      * @since 4.0.0
40971      * @category String
40972      * @param {string} [string=''] The string to modify.
40973      * @param {RegExp|string} pattern The pattern to replace.
40974      * @param {Function|string} replacement The match replacement.
40975      * @returns {string} Returns the modified string.
40976      * @example
40977      *
40978      * _.replace('Hi Fred', 'Fred', 'Barney');
40979      * // => 'Hi Barney'
40980      */
40981     function replace() {
40982       var args = arguments,
40983           string = toString(args[0]);
40984
40985       return args.length < 3 ? string : string.replace(args[1], args[2]);
40986     }
40987
40988     /**
40989      * Converts `string` to
40990      * [snake case](https://en.wikipedia.org/wiki/Snake_case).
40991      *
40992      * @static
40993      * @memberOf _
40994      * @since 3.0.0
40995      * @category String
40996      * @param {string} [string=''] The string to convert.
40997      * @returns {string} Returns the snake cased string.
40998      * @example
40999      *
41000      * _.snakeCase('Foo Bar');
41001      * // => 'foo_bar'
41002      *
41003      * _.snakeCase('fooBar');
41004      * // => 'foo_bar'
41005      *
41006      * _.snakeCase('--FOO-BAR--');
41007      * // => 'foo_bar'
41008      */
41009     var snakeCase = createCompounder(function(result, word, index) {
41010       return result + (index ? '_' : '') + word.toLowerCase();
41011     });
41012
41013     /**
41014      * Splits `string` by `separator`.
41015      *
41016      * **Note:** This method is based on
41017      * [`String#split`](https://mdn.io/String/split).
41018      *
41019      * @static
41020      * @memberOf _
41021      * @since 4.0.0
41022      * @category String
41023      * @param {string} [string=''] The string to split.
41024      * @param {RegExp|string} separator The separator pattern to split by.
41025      * @param {number} [limit] The length to truncate results to.
41026      * @returns {Array} Returns the string segments.
41027      * @example
41028      *
41029      * _.split('a-b-c', '-', 2);
41030      * // => ['a', 'b']
41031      */
41032     function split(string, separator, limit) {
41033       if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
41034         separator = limit = undefined;
41035       }
41036       limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
41037       if (!limit) {
41038         return [];
41039       }
41040       string = toString(string);
41041       if (string && (
41042             typeof separator == 'string' ||
41043             (separator != null && !isRegExp(separator))
41044           )) {
41045         separator = baseToString(separator);
41046         if (!separator && hasUnicode(string)) {
41047           return castSlice(stringToArray(string), 0, limit);
41048         }
41049       }
41050       return string.split(separator, limit);
41051     }
41052
41053     /**
41054      * Converts `string` to
41055      * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
41056      *
41057      * @static
41058      * @memberOf _
41059      * @since 3.1.0
41060      * @category String
41061      * @param {string} [string=''] The string to convert.
41062      * @returns {string} Returns the start cased string.
41063      * @example
41064      *
41065      * _.startCase('--foo-bar--');
41066      * // => 'Foo Bar'
41067      *
41068      * _.startCase('fooBar');
41069      * // => 'Foo Bar'
41070      *
41071      * _.startCase('__FOO_BAR__');
41072      * // => 'FOO BAR'
41073      */
41074     var startCase = createCompounder(function(result, word, index) {
41075       return result + (index ? ' ' : '') + upperFirst(word);
41076     });
41077
41078     /**
41079      * Checks if `string` starts with the given target string.
41080      *
41081      * @static
41082      * @memberOf _
41083      * @since 3.0.0
41084      * @category String
41085      * @param {string} [string=''] The string to inspect.
41086      * @param {string} [target] The string to search for.
41087      * @param {number} [position=0] The position to search from.
41088      * @returns {boolean} Returns `true` if `string` starts with `target`,
41089      *  else `false`.
41090      * @example
41091      *
41092      * _.startsWith('abc', 'a');
41093      * // => true
41094      *
41095      * _.startsWith('abc', 'b');
41096      * // => false
41097      *
41098      * _.startsWith('abc', 'b', 1);
41099      * // => true
41100      */
41101     function startsWith(string, target, position) {
41102       string = toString(string);
41103       position = position == null
41104         ? 0
41105         : baseClamp(toInteger(position), 0, string.length);
41106
41107       target = baseToString(target);
41108       return string.slice(position, position + target.length) == target;
41109     }
41110
41111     /**
41112      * Creates a compiled template function that can interpolate data properties
41113      * in "interpolate" delimiters, HTML-escape interpolated data properties in
41114      * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
41115      * properties may be accessed as free variables in the template. If a setting
41116      * object is given, it takes precedence over `_.templateSettings` values.
41117      *
41118      * **Note:** In the development build `_.template` utilizes
41119      * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
41120      * for easier debugging.
41121      *
41122      * For more information on precompiling templates see
41123      * [lodash's custom builds documentation](https://lodash.com/custom-builds).
41124      *
41125      * For more information on Chrome extension sandboxes see
41126      * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
41127      *
41128      * @static
41129      * @since 0.1.0
41130      * @memberOf _
41131      * @category String
41132      * @param {string} [string=''] The template string.
41133      * @param {Object} [options={}] The options object.
41134      * @param {RegExp} [options.escape=_.templateSettings.escape]
41135      *  The HTML "escape" delimiter.
41136      * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
41137      *  The "evaluate" delimiter.
41138      * @param {Object} [options.imports=_.templateSettings.imports]
41139      *  An object to import into the template as free variables.
41140      * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
41141      *  The "interpolate" delimiter.
41142      * @param {string} [options.sourceURL='lodash.templateSources[n]']
41143      *  The sourceURL of the compiled template.
41144      * @param {string} [options.variable='obj']
41145      *  The data object variable name.
41146      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
41147      * @returns {Function} Returns the compiled template function.
41148      * @example
41149      *
41150      * // Use the "interpolate" delimiter to create a compiled template.
41151      * var compiled = _.template('hello <%= user %>!');
41152      * compiled({ 'user': 'fred' });
41153      * // => 'hello fred!'
41154      *
41155      * // Use the HTML "escape" delimiter to escape data property values.
41156      * var compiled = _.template('<b><%- value %></b>');
41157      * compiled({ 'value': '<script>' });
41158      * // => '<b>&lt;script&gt;</b>'
41159      *
41160      * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
41161      * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
41162      * compiled({ 'users': ['fred', 'barney'] });
41163      * // => '<li>fred</li><li>barney</li>'
41164      *
41165      * // Use the internal `print` function in "evaluate" delimiters.
41166      * var compiled = _.template('<% print("hello " + user); %>!');
41167      * compiled({ 'user': 'barney' });
41168      * // => 'hello barney!'
41169      *
41170      * // Use the ES template literal delimiter as an "interpolate" delimiter.
41171      * // Disable support by replacing the "interpolate" delimiter.
41172      * var compiled = _.template('hello ${ user }!');
41173      * compiled({ 'user': 'pebbles' });
41174      * // => 'hello pebbles!'
41175      *
41176      * // Use backslashes to treat delimiters as plain text.
41177      * var compiled = _.template('<%= "\\<%- value %\\>" %>');
41178      * compiled({ 'value': 'ignored' });
41179      * // => '<%- value %>'
41180      *
41181      * // Use the `imports` option to import `jQuery` as `jq`.
41182      * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
41183      * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
41184      * compiled({ 'users': ['fred', 'barney'] });
41185      * // => '<li>fred</li><li>barney</li>'
41186      *
41187      * // Use the `sourceURL` option to specify a custom sourceURL for the template.
41188      * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
41189      * compiled(data);
41190      * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
41191      *
41192      * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
41193      * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
41194      * compiled.source;
41195      * // => function(data) {
41196      * //   var __t, __p = '';
41197      * //   __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
41198      * //   return __p;
41199      * // }
41200      *
41201      * // Use custom template delimiters.
41202      * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
41203      * var compiled = _.template('hello {{ user }}!');
41204      * compiled({ 'user': 'mustache' });
41205      * // => 'hello mustache!'
41206      *
41207      * // Use the `source` property to inline compiled templates for meaningful
41208      * // line numbers in error messages and stack traces.
41209      * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
41210      *   var JST = {\
41211      *     "main": ' + _.template(mainText).source + '\
41212      *   };\
41213      * ');
41214      */
41215     function template(string, options, guard) {
41216       // Based on John Resig's `tmpl` implementation
41217       // (http://ejohn.org/blog/javascript-micro-templating/)
41218       // and Laura Doktorova's doT.js (https://github.com/olado/doT).
41219       var settings = lodash.templateSettings;
41220
41221       if (guard && isIterateeCall(string, options, guard)) {
41222         options = undefined;
41223       }
41224       string = toString(string);
41225       options = assignInWith({}, options, settings, customDefaultsAssignIn);
41226
41227       var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
41228           importsKeys = keys(imports),
41229           importsValues = baseValues(imports, importsKeys);
41230
41231       var isEscaping,
41232           isEvaluating,
41233           index = 0,
41234           interpolate = options.interpolate || reNoMatch,
41235           source = "__p += '";
41236
41237       // Compile the regexp to match each delimiter.
41238       var reDelimiters = RegExp(
41239         (options.escape || reNoMatch).source + '|' +
41240         interpolate.source + '|' +
41241         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
41242         (options.evaluate || reNoMatch).source + '|$'
41243       , 'g');
41244
41245       // Use a sourceURL for easier debugging.
41246       // The sourceURL gets injected into the source that's eval-ed, so be careful
41247       // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
41248       // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
41249       var sourceURL = '//# sourceURL=' +
41250         (hasOwnProperty.call(options, 'sourceURL')
41251           ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
41252           : ('lodash.templateSources[' + (++templateCounter) + ']')
41253         ) + '\n';
41254
41255       string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
41256         interpolateValue || (interpolateValue = esTemplateValue);
41257
41258         // Escape characters that can't be included in string literals.
41259         source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
41260
41261         // Replace delimiters with snippets.
41262         if (escapeValue) {
41263           isEscaping = true;
41264           source += "' +\n__e(" + escapeValue + ") +\n'";
41265         }
41266         if (evaluateValue) {
41267           isEvaluating = true;
41268           source += "';\n" + evaluateValue + ";\n__p += '";
41269         }
41270         if (interpolateValue) {
41271           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
41272         }
41273         index = offset + match.length;
41274
41275         // The JS engine embedded in Adobe products needs `match` returned in
41276         // order to produce the correct `offset` value.
41277         return match;
41278       });
41279
41280       source += "';\n";
41281
41282       // If `variable` is not specified wrap a with-statement around the generated
41283       // code to add the data object to the top of the scope chain.
41284       // Like with sourceURL, we take care to not check the option's prototype,
41285       // as this configuration is a code injection vector.
41286       var variable = hasOwnProperty.call(options, 'variable') && options.variable;
41287       if (!variable) {
41288         source = 'with (obj) {\n' + source + '\n}\n';
41289       }
41290       // Cleanup code by stripping empty strings.
41291       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
41292         .replace(reEmptyStringMiddle, '$1')
41293         .replace(reEmptyStringTrailing, '$1;');
41294
41295       // Frame code as the function body.
41296       source = 'function(' + (variable || 'obj') + ') {\n' +
41297         (variable
41298           ? ''
41299           : 'obj || (obj = {});\n'
41300         ) +
41301         "var __t, __p = ''" +
41302         (isEscaping
41303            ? ', __e = _.escape'
41304            : ''
41305         ) +
41306         (isEvaluating
41307           ? ', __j = Array.prototype.join;\n' +
41308             "function print() { __p += __j.call(arguments, '') }\n"
41309           : ';\n'
41310         ) +
41311         source +
41312         'return __p\n}';
41313
41314       var result = attempt(function() {
41315         return Function(importsKeys, sourceURL + 'return ' + source)
41316           .apply(undefined, importsValues);
41317       });
41318
41319       // Provide the compiled function's source by its `toString` method or
41320       // the `source` property as a convenience for inlining compiled templates.
41321       result.source = source;
41322       if (isError(result)) {
41323         throw result;
41324       }
41325       return result;
41326     }
41327
41328     /**
41329      * Converts `string`, as a whole, to lower case just like
41330      * [String#toLowerCase](https://mdn.io/toLowerCase).
41331      *
41332      * @static
41333      * @memberOf _
41334      * @since 4.0.0
41335      * @category String
41336      * @param {string} [string=''] The string to convert.
41337      * @returns {string} Returns the lower cased string.
41338      * @example
41339      *
41340      * _.toLower('--Foo-Bar--');
41341      * // => '--foo-bar--'
41342      *
41343      * _.toLower('fooBar');
41344      * // => 'foobar'
41345      *
41346      * _.toLower('__FOO_BAR__');
41347      * // => '__foo_bar__'
41348      */
41349     function toLower(value) {
41350       return toString(value).toLowerCase();
41351     }
41352
41353     /**
41354      * Converts `string`, as a whole, to upper case just like
41355      * [String#toUpperCase](https://mdn.io/toUpperCase).
41356      *
41357      * @static
41358      * @memberOf _
41359      * @since 4.0.0
41360      * @category String
41361      * @param {string} [string=''] The string to convert.
41362      * @returns {string} Returns the upper cased string.
41363      * @example
41364      *
41365      * _.toUpper('--foo-bar--');
41366      * // => '--FOO-BAR--'
41367      *
41368      * _.toUpper('fooBar');
41369      * // => 'FOOBAR'
41370      *
41371      * _.toUpper('__foo_bar__');
41372      * // => '__FOO_BAR__'
41373      */
41374     function toUpper(value) {
41375       return toString(value).toUpperCase();
41376     }
41377
41378     /**
41379      * Removes leading and trailing whitespace or specified characters from `string`.
41380      *
41381      * @static
41382      * @memberOf _
41383      * @since 3.0.0
41384      * @category String
41385      * @param {string} [string=''] The string to trim.
41386      * @param {string} [chars=whitespace] The characters to trim.
41387      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
41388      * @returns {string} Returns the trimmed string.
41389      * @example
41390      *
41391      * _.trim('  abc  ');
41392      * // => 'abc'
41393      *
41394      * _.trim('-_-abc-_-', '_-');
41395      * // => 'abc'
41396      *
41397      * _.map(['  foo  ', '  bar  '], _.trim);
41398      * // => ['foo', 'bar']
41399      */
41400     function trim(string, chars, guard) {
41401       string = toString(string);
41402       if (string && (guard || chars === undefined)) {
41403         return string.replace(reTrim, '');
41404       }
41405       if (!string || !(chars = baseToString(chars))) {
41406         return string;
41407       }
41408       var strSymbols = stringToArray(string),
41409           chrSymbols = stringToArray(chars),
41410           start = charsStartIndex(strSymbols, chrSymbols),
41411           end = charsEndIndex(strSymbols, chrSymbols) + 1;
41412
41413       return castSlice(strSymbols, start, end).join('');
41414     }
41415
41416     /**
41417      * Removes trailing whitespace or specified characters from `string`.
41418      *
41419      * @static
41420      * @memberOf _
41421      * @since 4.0.0
41422      * @category String
41423      * @param {string} [string=''] The string to trim.
41424      * @param {string} [chars=whitespace] The characters to trim.
41425      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
41426      * @returns {string} Returns the trimmed string.
41427      * @example
41428      *
41429      * _.trimEnd('  abc  ');
41430      * // => '  abc'
41431      *
41432      * _.trimEnd('-_-abc-_-', '_-');
41433      * // => '-_-abc'
41434      */
41435     function trimEnd(string, chars, guard) {
41436       string = toString(string);
41437       if (string && (guard || chars === undefined)) {
41438         return string.replace(reTrimEnd, '');
41439       }
41440       if (!string || !(chars = baseToString(chars))) {
41441         return string;
41442       }
41443       var strSymbols = stringToArray(string),
41444           end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
41445
41446       return castSlice(strSymbols, 0, end).join('');
41447     }
41448
41449     /**
41450      * Removes leading whitespace or specified characters from `string`.
41451      *
41452      * @static
41453      * @memberOf _
41454      * @since 4.0.0
41455      * @category String
41456      * @param {string} [string=''] The string to trim.
41457      * @param {string} [chars=whitespace] The characters to trim.
41458      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
41459      * @returns {string} Returns the trimmed string.
41460      * @example
41461      *
41462      * _.trimStart('  abc  ');
41463      * // => 'abc  '
41464      *
41465      * _.trimStart('-_-abc-_-', '_-');
41466      * // => 'abc-_-'
41467      */
41468     function trimStart(string, chars, guard) {
41469       string = toString(string);
41470       if (string && (guard || chars === undefined)) {
41471         return string.replace(reTrimStart, '');
41472       }
41473       if (!string || !(chars = baseToString(chars))) {
41474         return string;
41475       }
41476       var strSymbols = stringToArray(string),
41477           start = charsStartIndex(strSymbols, stringToArray(chars));
41478
41479       return castSlice(strSymbols, start).join('');
41480     }
41481
41482     /**
41483      * Truncates `string` if it's longer than the given maximum string length.
41484      * The last characters of the truncated string are replaced with the omission
41485      * string which defaults to "...".
41486      *
41487      * @static
41488      * @memberOf _
41489      * @since 4.0.0
41490      * @category String
41491      * @param {string} [string=''] The string to truncate.
41492      * @param {Object} [options={}] The options object.
41493      * @param {number} [options.length=30] The maximum string length.
41494      * @param {string} [options.omission='...'] The string to indicate text is omitted.
41495      * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
41496      * @returns {string} Returns the truncated string.
41497      * @example
41498      *
41499      * _.truncate('hi-diddly-ho there, neighborino');
41500      * // => 'hi-diddly-ho there, neighbo...'
41501      *
41502      * _.truncate('hi-diddly-ho there, neighborino', {
41503      *   'length': 24,
41504      *   'separator': ' '
41505      * });
41506      * // => 'hi-diddly-ho there,...'
41507      *
41508      * _.truncate('hi-diddly-ho there, neighborino', {
41509      *   'length': 24,
41510      *   'separator': /,? +/
41511      * });
41512      * // => 'hi-diddly-ho there...'
41513      *
41514      * _.truncate('hi-diddly-ho there, neighborino', {
41515      *   'omission': ' [...]'
41516      * });
41517      * // => 'hi-diddly-ho there, neig [...]'
41518      */
41519     function truncate(string, options) {
41520       var length = DEFAULT_TRUNC_LENGTH,
41521           omission = DEFAULT_TRUNC_OMISSION;
41522
41523       if (isObject(options)) {
41524         var separator = 'separator' in options ? options.separator : separator;
41525         length = 'length' in options ? toInteger(options.length) : length;
41526         omission = 'omission' in options ? baseToString(options.omission) : omission;
41527       }
41528       string = toString(string);
41529
41530       var strLength = string.length;
41531       if (hasUnicode(string)) {
41532         var strSymbols = stringToArray(string);
41533         strLength = strSymbols.length;
41534       }
41535       if (length >= strLength) {
41536         return string;
41537       }
41538       var end = length - stringSize(omission);
41539       if (end < 1) {
41540         return omission;
41541       }
41542       var result = strSymbols
41543         ? castSlice(strSymbols, 0, end).join('')
41544         : string.slice(0, end);
41545
41546       if (separator === undefined) {
41547         return result + omission;
41548       }
41549       if (strSymbols) {
41550         end += (result.length - end);
41551       }
41552       if (isRegExp(separator)) {
41553         if (string.slice(end).search(separator)) {
41554           var match,
41555               substring = result;
41556
41557           if (!separator.global) {
41558             separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
41559           }
41560           separator.lastIndex = 0;
41561           while ((match = separator.exec(substring))) {
41562             var newEnd = match.index;
41563           }
41564           result = result.slice(0, newEnd === undefined ? end : newEnd);
41565         }
41566       } else if (string.indexOf(baseToString(separator), end) != end) {
41567         var index = result.lastIndexOf(separator);
41568         if (index > -1) {
41569           result = result.slice(0, index);
41570         }
41571       }
41572       return result + omission;
41573     }
41574
41575     /**
41576      * The inverse of `_.escape`; this method converts the HTML entities
41577      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
41578      * their corresponding characters.
41579      *
41580      * **Note:** No other HTML entities are unescaped. To unescape additional
41581      * HTML entities use a third-party library like [_he_](https://mths.be/he).
41582      *
41583      * @static
41584      * @memberOf _
41585      * @since 0.6.0
41586      * @category String
41587      * @param {string} [string=''] The string to unescape.
41588      * @returns {string} Returns the unescaped string.
41589      * @example
41590      *
41591      * _.unescape('fred, barney, &amp; pebbles');
41592      * // => 'fred, barney, & pebbles'
41593      */
41594     function unescape(string) {
41595       string = toString(string);
41596       return (string && reHasEscapedHtml.test(string))
41597         ? string.replace(reEscapedHtml, unescapeHtmlChar)
41598         : string;
41599     }
41600
41601     /**
41602      * Converts `string`, as space separated words, to upper case.
41603      *
41604      * @static
41605      * @memberOf _
41606      * @since 4.0.0
41607      * @category String
41608      * @param {string} [string=''] The string to convert.
41609      * @returns {string} Returns the upper cased string.
41610      * @example
41611      *
41612      * _.upperCase('--foo-bar');
41613      * // => 'FOO BAR'
41614      *
41615      * _.upperCase('fooBar');
41616      * // => 'FOO BAR'
41617      *
41618      * _.upperCase('__foo_bar__');
41619      * // => 'FOO BAR'
41620      */
41621     var upperCase = createCompounder(function(result, word, index) {
41622       return result + (index ? ' ' : '') + word.toUpperCase();
41623     });
41624
41625     /**
41626      * Converts the first character of `string` to upper case.
41627      *
41628      * @static
41629      * @memberOf _
41630      * @since 4.0.0
41631      * @category String
41632      * @param {string} [string=''] The string to convert.
41633      * @returns {string} Returns the converted string.
41634      * @example
41635      *
41636      * _.upperFirst('fred');
41637      * // => 'Fred'
41638      *
41639      * _.upperFirst('FRED');
41640      * // => 'FRED'
41641      */
41642     var upperFirst = createCaseFirst('toUpperCase');
41643
41644     /**
41645      * Splits `string` into an array of its words.
41646      *
41647      * @static
41648      * @memberOf _
41649      * @since 3.0.0
41650      * @category String
41651      * @param {string} [string=''] The string to inspect.
41652      * @param {RegExp|string} [pattern] The pattern to match words.
41653      * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
41654      * @returns {Array} Returns the words of `string`.
41655      * @example
41656      *
41657      * _.words('fred, barney, & pebbles');
41658      * // => ['fred', 'barney', 'pebbles']
41659      *
41660      * _.words('fred, barney, & pebbles', /[^, ]+/g);
41661      * // => ['fred', 'barney', '&', 'pebbles']
41662      */
41663     function words(string, pattern, guard) {
41664       string = toString(string);
41665       pattern = guard ? undefined : pattern;
41666
41667       if (pattern === undefined) {
41668         return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
41669       }
41670       return string.match(pattern) || [];
41671     }
41672
41673     /*------------------------------------------------------------------------*/
41674
41675     /**
41676      * Attempts to invoke `func`, returning either the result or the caught error
41677      * object. Any additional arguments are provided to `func` when it's invoked.
41678      *
41679      * @static
41680      * @memberOf _
41681      * @since 3.0.0
41682      * @category Util
41683      * @param {Function} func The function to attempt.
41684      * @param {...*} [args] The arguments to invoke `func` with.
41685      * @returns {*} Returns the `func` result or error object.
41686      * @example
41687      *
41688      * // Avoid throwing errors for invalid selectors.
41689      * var elements = _.attempt(function(selector) {
41690      *   return document.querySelectorAll(selector);
41691      * }, '>_>');
41692      *
41693      * if (_.isError(elements)) {
41694      *   elements = [];
41695      * }
41696      */
41697     var attempt = baseRest(function(func, args) {
41698       try {
41699         return apply(func, undefined, args);
41700       } catch (e) {
41701         return isError(e) ? e : new Error(e);
41702       }
41703     });
41704
41705     /**
41706      * Binds methods of an object to the object itself, overwriting the existing
41707      * method.
41708      *
41709      * **Note:** This method doesn't set the "length" property of bound functions.
41710      *
41711      * @static
41712      * @since 0.1.0
41713      * @memberOf _
41714      * @category Util
41715      * @param {Object} object The object to bind and assign the bound methods to.
41716      * @param {...(string|string[])} methodNames The object method names to bind.
41717      * @returns {Object} Returns `object`.
41718      * @example
41719      *
41720      * var view = {
41721      *   'label': 'docs',
41722      *   'click': function() {
41723      *     console.log('clicked ' + this.label);
41724      *   }
41725      * };
41726      *
41727      * _.bindAll(view, ['click']);
41728      * jQuery(element).on('click', view.click);
41729      * // => Logs 'clicked docs' when clicked.
41730      */
41731     var bindAll = flatRest(function(object, methodNames) {
41732       arrayEach(methodNames, function(key) {
41733         key = toKey(key);
41734         baseAssignValue(object, key, bind(object[key], object));
41735       });
41736       return object;
41737     });
41738
41739     /**
41740      * Creates a function that iterates over `pairs` and invokes the corresponding
41741      * function of the first predicate to return truthy. The predicate-function
41742      * pairs are invoked with the `this` binding and arguments of the created
41743      * function.
41744      *
41745      * @static
41746      * @memberOf _
41747      * @since 4.0.0
41748      * @category Util
41749      * @param {Array} pairs The predicate-function pairs.
41750      * @returns {Function} Returns the new composite function.
41751      * @example
41752      *
41753      * var func = _.cond([
41754      *   [_.matches({ 'a': 1 }),           _.constant('matches A')],
41755      *   [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
41756      *   [_.stubTrue,                      _.constant('no match')]
41757      * ]);
41758      *
41759      * func({ 'a': 1, 'b': 2 });
41760      * // => 'matches A'
41761      *
41762      * func({ 'a': 0, 'b': 1 });
41763      * // => 'matches B'
41764      *
41765      * func({ 'a': '1', 'b': '2' });
41766      * // => 'no match'
41767      */
41768     function cond(pairs) {
41769       var length = pairs == null ? 0 : pairs.length,
41770           toIteratee = getIteratee();
41771
41772       pairs = !length ? [] : arrayMap(pairs, function(pair) {
41773         if (typeof pair[1] != 'function') {
41774           throw new TypeError(FUNC_ERROR_TEXT);
41775         }
41776         return [toIteratee(pair[0]), pair[1]];
41777       });
41778
41779       return baseRest(function(args) {
41780         var index = -1;
41781         while (++index < length) {
41782           var pair = pairs[index];
41783           if (apply(pair[0], this, args)) {
41784             return apply(pair[1], this, args);
41785           }
41786         }
41787       });
41788     }
41789
41790     /**
41791      * Creates a function that invokes the predicate properties of `source` with
41792      * the corresponding property values of a given object, returning `true` if
41793      * all predicates return truthy, else `false`.
41794      *
41795      * **Note:** The created function is equivalent to `_.conformsTo` with
41796      * `source` partially applied.
41797      *
41798      * @static
41799      * @memberOf _
41800      * @since 4.0.0
41801      * @category Util
41802      * @param {Object} source The object of property predicates to conform to.
41803      * @returns {Function} Returns the new spec function.
41804      * @example
41805      *
41806      * var objects = [
41807      *   { 'a': 2, 'b': 1 },
41808      *   { 'a': 1, 'b': 2 }
41809      * ];
41810      *
41811      * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
41812      * // => [{ 'a': 1, 'b': 2 }]
41813      */
41814     function conforms(source) {
41815       return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
41816     }
41817
41818     /**
41819      * Creates a function that returns `value`.
41820      *
41821      * @static
41822      * @memberOf _
41823      * @since 2.4.0
41824      * @category Util
41825      * @param {*} value The value to return from the new function.
41826      * @returns {Function} Returns the new constant function.
41827      * @example
41828      *
41829      * var objects = _.times(2, _.constant({ 'a': 1 }));
41830      *
41831      * console.log(objects);
41832      * // => [{ 'a': 1 }, { 'a': 1 }]
41833      *
41834      * console.log(objects[0] === objects[1]);
41835      * // => true
41836      */
41837     function constant(value) {
41838       return function() {
41839         return value;
41840       };
41841     }
41842
41843     /**
41844      * Checks `value` to determine whether a default value should be returned in
41845      * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
41846      * or `undefined`.
41847      *
41848      * @static
41849      * @memberOf _
41850      * @since 4.14.0
41851      * @category Util
41852      * @param {*} value The value to check.
41853      * @param {*} defaultValue The default value.
41854      * @returns {*} Returns the resolved value.
41855      * @example
41856      *
41857      * _.defaultTo(1, 10);
41858      * // => 1
41859      *
41860      * _.defaultTo(undefined, 10);
41861      * // => 10
41862      */
41863     function defaultTo(value, defaultValue) {
41864       return (value == null || value !== value) ? defaultValue : value;
41865     }
41866
41867     /**
41868      * Creates a function that returns the result of invoking the given functions
41869      * with the `this` binding of the created function, where each successive
41870      * invocation is supplied the return value of the previous.
41871      *
41872      * @static
41873      * @memberOf _
41874      * @since 3.0.0
41875      * @category Util
41876      * @param {...(Function|Function[])} [funcs] The functions to invoke.
41877      * @returns {Function} Returns the new composite function.
41878      * @see _.flowRight
41879      * @example
41880      *
41881      * function square(n) {
41882      *   return n * n;
41883      * }
41884      *
41885      * var addSquare = _.flow([_.add, square]);
41886      * addSquare(1, 2);
41887      * // => 9
41888      */
41889     var flow = createFlow();
41890
41891     /**
41892      * This method is like `_.flow` except that it creates a function that
41893      * invokes the given functions from right to left.
41894      *
41895      * @static
41896      * @since 3.0.0
41897      * @memberOf _
41898      * @category Util
41899      * @param {...(Function|Function[])} [funcs] The functions to invoke.
41900      * @returns {Function} Returns the new composite function.
41901      * @see _.flow
41902      * @example
41903      *
41904      * function square(n) {
41905      *   return n * n;
41906      * }
41907      *
41908      * var addSquare = _.flowRight([square, _.add]);
41909      * addSquare(1, 2);
41910      * // => 9
41911      */
41912     var flowRight = createFlow(true);
41913
41914     /**
41915      * This method returns the first argument it receives.
41916      *
41917      * @static
41918      * @since 0.1.0
41919      * @memberOf _
41920      * @category Util
41921      * @param {*} value Any value.
41922      * @returns {*} Returns `value`.
41923      * @example
41924      *
41925      * var object = { 'a': 1 };
41926      *
41927      * console.log(_.identity(object) === object);
41928      * // => true
41929      */
41930     function identity(value) {
41931       return value;
41932     }
41933
41934     /**
41935      * Creates a function that invokes `func` with the arguments of the created
41936      * function. If `func` is a property name, the created function returns the
41937      * property value for a given element. If `func` is an array or object, the
41938      * created function returns `true` for elements that contain the equivalent
41939      * source properties, otherwise it returns `false`.
41940      *
41941      * @static
41942      * @since 4.0.0
41943      * @memberOf _
41944      * @category Util
41945      * @param {*} [func=_.identity] The value to convert to a callback.
41946      * @returns {Function} Returns the callback.
41947      * @example
41948      *
41949      * var users = [
41950      *   { 'user': 'barney', 'age': 36, 'active': true },
41951      *   { 'user': 'fred',   'age': 40, 'active': false }
41952      * ];
41953      *
41954      * // The `_.matches` iteratee shorthand.
41955      * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
41956      * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
41957      *
41958      * // The `_.matchesProperty` iteratee shorthand.
41959      * _.filter(users, _.iteratee(['user', 'fred']));
41960      * // => [{ 'user': 'fred', 'age': 40 }]
41961      *
41962      * // The `_.property` iteratee shorthand.
41963      * _.map(users, _.iteratee('user'));
41964      * // => ['barney', 'fred']
41965      *
41966      * // Create custom iteratee shorthands.
41967      * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
41968      *   return !_.isRegExp(func) ? iteratee(func) : function(string) {
41969      *     return func.test(string);
41970      *   };
41971      * });
41972      *
41973      * _.filter(['abc', 'def'], /ef/);
41974      * // => ['def']
41975      */
41976     function iteratee(func) {
41977       return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
41978     }
41979
41980     /**
41981      * Creates a function that performs a partial deep comparison between a given
41982      * object and `source`, returning `true` if the given object has equivalent
41983      * property values, else `false`.
41984      *
41985      * **Note:** The created function is equivalent to `_.isMatch` with `source`
41986      * partially applied.
41987      *
41988      * Partial comparisons will match empty array and empty object `source`
41989      * values against any array or object value, respectively. See `_.isEqual`
41990      * for a list of supported value comparisons.
41991      *
41992      * @static
41993      * @memberOf _
41994      * @since 3.0.0
41995      * @category Util
41996      * @param {Object} source The object of property values to match.
41997      * @returns {Function} Returns the new spec function.
41998      * @example
41999      *
42000      * var objects = [
42001      *   { 'a': 1, 'b': 2, 'c': 3 },
42002      *   { 'a': 4, 'b': 5, 'c': 6 }
42003      * ];
42004      *
42005      * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
42006      * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
42007      */
42008     function matches(source) {
42009       return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
42010     }
42011
42012     /**
42013      * Creates a function that performs a partial deep comparison between the
42014      * value at `path` of a given object to `srcValue`, returning `true` if the
42015      * object value is equivalent, else `false`.
42016      *
42017      * **Note:** Partial comparisons will match empty array and empty object
42018      * `srcValue` values against any array or object value, respectively. See
42019      * `_.isEqual` for a list of supported value comparisons.
42020      *
42021      * @static
42022      * @memberOf _
42023      * @since 3.2.0
42024      * @category Util
42025      * @param {Array|string} path The path of the property to get.
42026      * @param {*} srcValue The value to match.
42027      * @returns {Function} Returns the new spec function.
42028      * @example
42029      *
42030      * var objects = [
42031      *   { 'a': 1, 'b': 2, 'c': 3 },
42032      *   { 'a': 4, 'b': 5, 'c': 6 }
42033      * ];
42034      *
42035      * _.find(objects, _.matchesProperty('a', 4));
42036      * // => { 'a': 4, 'b': 5, 'c': 6 }
42037      */
42038     function matchesProperty(path, srcValue) {
42039       return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
42040     }
42041
42042     /**
42043      * Creates a function that invokes the method at `path` of a given object.
42044      * Any additional arguments are provided to the invoked method.
42045      *
42046      * @static
42047      * @memberOf _
42048      * @since 3.7.0
42049      * @category Util
42050      * @param {Array|string} path The path of the method to invoke.
42051      * @param {...*} [args] The arguments to invoke the method with.
42052      * @returns {Function} Returns the new invoker function.
42053      * @example
42054      *
42055      * var objects = [
42056      *   { 'a': { 'b': _.constant(2) } },
42057      *   { 'a': { 'b': _.constant(1) } }
42058      * ];
42059      *
42060      * _.map(objects, _.method('a.b'));
42061      * // => [2, 1]
42062      *
42063      * _.map(objects, _.method(['a', 'b']));
42064      * // => [2, 1]
42065      */
42066     var method = baseRest(function(path, args) {
42067       return function(object) {
42068         return baseInvoke(object, path, args);
42069       };
42070     });
42071
42072     /**
42073      * The opposite of `_.method`; this method creates a function that invokes
42074      * the method at a given path of `object`. Any additional arguments are
42075      * provided to the invoked method.
42076      *
42077      * @static
42078      * @memberOf _
42079      * @since 3.7.0
42080      * @category Util
42081      * @param {Object} object The object to query.
42082      * @param {...*} [args] The arguments to invoke the method with.
42083      * @returns {Function} Returns the new invoker function.
42084      * @example
42085      *
42086      * var array = _.times(3, _.constant),
42087      *     object = { 'a': array, 'b': array, 'c': array };
42088      *
42089      * _.map(['a[2]', 'c[0]'], _.methodOf(object));
42090      * // => [2, 0]
42091      *
42092      * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
42093      * // => [2, 0]
42094      */
42095     var methodOf = baseRest(function(object, args) {
42096       return function(path) {
42097         return baseInvoke(object, path, args);
42098       };
42099     });
42100
42101     /**
42102      * Adds all own enumerable string keyed function properties of a source
42103      * object to the destination object. If `object` is a function, then methods
42104      * are added to its prototype as well.
42105      *
42106      * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
42107      * avoid conflicts caused by modifying the original.
42108      *
42109      * @static
42110      * @since 0.1.0
42111      * @memberOf _
42112      * @category Util
42113      * @param {Function|Object} [object=lodash] The destination object.
42114      * @param {Object} source The object of functions to add.
42115      * @param {Object} [options={}] The options object.
42116      * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
42117      * @returns {Function|Object} Returns `object`.
42118      * @example
42119      *
42120      * function vowels(string) {
42121      *   return _.filter(string, function(v) {
42122      *     return /[aeiou]/i.test(v);
42123      *   });
42124      * }
42125      *
42126      * _.mixin({ 'vowels': vowels });
42127      * _.vowels('fred');
42128      * // => ['e']
42129      *
42130      * _('fred').vowels().value();
42131      * // => ['e']
42132      *
42133      * _.mixin({ 'vowels': vowels }, { 'chain': false });
42134      * _('fred').vowels();
42135      * // => ['e']
42136      */
42137     function mixin(object, source, options) {
42138       var props = keys(source),
42139           methodNames = baseFunctions(source, props);
42140
42141       if (options == null &&
42142           !(isObject(source) && (methodNames.length || !props.length))) {
42143         options = source;
42144         source = object;
42145         object = this;
42146         methodNames = baseFunctions(source, keys(source));
42147       }
42148       var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
42149           isFunc = isFunction(object);
42150
42151       arrayEach(methodNames, function(methodName) {
42152         var func = source[methodName];
42153         object[methodName] = func;
42154         if (isFunc) {
42155           object.prototype[methodName] = function() {
42156             var chainAll = this.__chain__;
42157             if (chain || chainAll) {
42158               var result = object(this.__wrapped__),
42159                   actions = result.__actions__ = copyArray(this.__actions__);
42160
42161               actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
42162               result.__chain__ = chainAll;
42163               return result;
42164             }
42165             return func.apply(object, arrayPush([this.value()], arguments));
42166           };
42167         }
42168       });
42169
42170       return object;
42171     }
42172
42173     /**
42174      * Reverts the `_` variable to its previous value and returns a reference to
42175      * the `lodash` function.
42176      *
42177      * @static
42178      * @since 0.1.0
42179      * @memberOf _
42180      * @category Util
42181      * @returns {Function} Returns the `lodash` function.
42182      * @example
42183      *
42184      * var lodash = _.noConflict();
42185      */
42186     function noConflict() {
42187       if (root._ === this) {
42188         root._ = oldDash;
42189       }
42190       return this;
42191     }
42192
42193     /**
42194      * This method returns `undefined`.
42195      *
42196      * @static
42197      * @memberOf _
42198      * @since 2.3.0
42199      * @category Util
42200      * @example
42201      *
42202      * _.times(2, _.noop);
42203      * // => [undefined, undefined]
42204      */
42205     function noop() {
42206       // No operation performed.
42207     }
42208
42209     /**
42210      * Creates a function that gets the argument at index `n`. If `n` is negative,
42211      * the nth argument from the end is returned.
42212      *
42213      * @static
42214      * @memberOf _
42215      * @since 4.0.0
42216      * @category Util
42217      * @param {number} [n=0] The index of the argument to return.
42218      * @returns {Function} Returns the new pass-thru function.
42219      * @example
42220      *
42221      * var func = _.nthArg(1);
42222      * func('a', 'b', 'c', 'd');
42223      * // => 'b'
42224      *
42225      * var func = _.nthArg(-2);
42226      * func('a', 'b', 'c', 'd');
42227      * // => 'c'
42228      */
42229     function nthArg(n) {
42230       n = toInteger(n);
42231       return baseRest(function(args) {
42232         return baseNth(args, n);
42233       });
42234     }
42235
42236     /**
42237      * Creates a function that invokes `iteratees` with the arguments it receives
42238      * and returns their results.
42239      *
42240      * @static
42241      * @memberOf _
42242      * @since 4.0.0
42243      * @category Util
42244      * @param {...(Function|Function[])} [iteratees=[_.identity]]
42245      *  The iteratees to invoke.
42246      * @returns {Function} Returns the new function.
42247      * @example
42248      *
42249      * var func = _.over([Math.max, Math.min]);
42250      *
42251      * func(1, 2, 3, 4);
42252      * // => [4, 1]
42253      */
42254     var over = createOver(arrayMap);
42255
42256     /**
42257      * Creates a function that checks if **all** of the `predicates` return
42258      * truthy when invoked with the arguments it receives.
42259      *
42260      * @static
42261      * @memberOf _
42262      * @since 4.0.0
42263      * @category Util
42264      * @param {...(Function|Function[])} [predicates=[_.identity]]
42265      *  The predicates to check.
42266      * @returns {Function} Returns the new function.
42267      * @example
42268      *
42269      * var func = _.overEvery([Boolean, isFinite]);
42270      *
42271      * func('1');
42272      * // => true
42273      *
42274      * func(null);
42275      * // => false
42276      *
42277      * func(NaN);
42278      * // => false
42279      */
42280     var overEvery = createOver(arrayEvery);
42281
42282     /**
42283      * Creates a function that checks if **any** of the `predicates` return
42284      * truthy when invoked with the arguments it receives.
42285      *
42286      * @static
42287      * @memberOf _
42288      * @since 4.0.0
42289      * @category Util
42290      * @param {...(Function|Function[])} [predicates=[_.identity]]
42291      *  The predicates to check.
42292      * @returns {Function} Returns the new function.
42293      * @example
42294      *
42295      * var func = _.overSome([Boolean, isFinite]);
42296      *
42297      * func('1');
42298      * // => true
42299      *
42300      * func(null);
42301      * // => true
42302      *
42303      * func(NaN);
42304      * // => false
42305      */
42306     var overSome = createOver(arraySome);
42307
42308     /**
42309      * Creates a function that returns the value at `path` of a given object.
42310      *
42311      * @static
42312      * @memberOf _
42313      * @since 2.4.0
42314      * @category Util
42315      * @param {Array|string} path The path of the property to get.
42316      * @returns {Function} Returns the new accessor function.
42317      * @example
42318      *
42319      * var objects = [
42320      *   { 'a': { 'b': 2 } },
42321      *   { 'a': { 'b': 1 } }
42322      * ];
42323      *
42324      * _.map(objects, _.property('a.b'));
42325      * // => [2, 1]
42326      *
42327      * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
42328      * // => [1, 2]
42329      */
42330     function property(path) {
42331       return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
42332     }
42333
42334     /**
42335      * The opposite of `_.property`; this method creates a function that returns
42336      * the value at a given path of `object`.
42337      *
42338      * @static
42339      * @memberOf _
42340      * @since 3.0.0
42341      * @category Util
42342      * @param {Object} object The object to query.
42343      * @returns {Function} Returns the new accessor function.
42344      * @example
42345      *
42346      * var array = [0, 1, 2],
42347      *     object = { 'a': array, 'b': array, 'c': array };
42348      *
42349      * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
42350      * // => [2, 0]
42351      *
42352      * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
42353      * // => [2, 0]
42354      */
42355     function propertyOf(object) {
42356       return function(path) {
42357         return object == null ? undefined : baseGet(object, path);
42358       };
42359     }
42360
42361     /**
42362      * Creates an array of numbers (positive and/or negative) progressing from
42363      * `start` up to, but not including, `end`. A step of `-1` is used if a negative
42364      * `start` is specified without an `end` or `step`. If `end` is not specified,
42365      * it's set to `start` with `start` then set to `0`.
42366      *
42367      * **Note:** JavaScript follows the IEEE-754 standard for resolving
42368      * floating-point values which can produce unexpected results.
42369      *
42370      * @static
42371      * @since 0.1.0
42372      * @memberOf _
42373      * @category Util
42374      * @param {number} [start=0] The start of the range.
42375      * @param {number} end The end of the range.
42376      * @param {number} [step=1] The value to increment or decrement by.
42377      * @returns {Array} Returns the range of numbers.
42378      * @see _.inRange, _.rangeRight
42379      * @example
42380      *
42381      * _.range(4);
42382      * // => [0, 1, 2, 3]
42383      *
42384      * _.range(-4);
42385      * // => [0, -1, -2, -3]
42386      *
42387      * _.range(1, 5);
42388      * // => [1, 2, 3, 4]
42389      *
42390      * _.range(0, 20, 5);
42391      * // => [0, 5, 10, 15]
42392      *
42393      * _.range(0, -4, -1);
42394      * // => [0, -1, -2, -3]
42395      *
42396      * _.range(1, 4, 0);
42397      * // => [1, 1, 1]
42398      *
42399      * _.range(0);
42400      * // => []
42401      */
42402     var range = createRange();
42403
42404     /**
42405      * This method is like `_.range` except that it populates values in
42406      * descending order.
42407      *
42408      * @static
42409      * @memberOf _
42410      * @since 4.0.0
42411      * @category Util
42412      * @param {number} [start=0] The start of the range.
42413      * @param {number} end The end of the range.
42414      * @param {number} [step=1] The value to increment or decrement by.
42415      * @returns {Array} Returns the range of numbers.
42416      * @see _.inRange, _.range
42417      * @example
42418      *
42419      * _.rangeRight(4);
42420      * // => [3, 2, 1, 0]
42421      *
42422      * _.rangeRight(-4);
42423      * // => [-3, -2, -1, 0]
42424      *
42425      * _.rangeRight(1, 5);
42426      * // => [4, 3, 2, 1]
42427      *
42428      * _.rangeRight(0, 20, 5);
42429      * // => [15, 10, 5, 0]
42430      *
42431      * _.rangeRight(0, -4, -1);
42432      * // => [-3, -2, -1, 0]
42433      *
42434      * _.rangeRight(1, 4, 0);
42435      * // => [1, 1, 1]
42436      *
42437      * _.rangeRight(0);
42438      * // => []
42439      */
42440     var rangeRight = createRange(true);
42441
42442     /**
42443      * This method returns a new empty array.
42444      *
42445      * @static
42446      * @memberOf _
42447      * @since 4.13.0
42448      * @category Util
42449      * @returns {Array} Returns the new empty array.
42450      * @example
42451      *
42452      * var arrays = _.times(2, _.stubArray);
42453      *
42454      * console.log(arrays);
42455      * // => [[], []]
42456      *
42457      * console.log(arrays[0] === arrays[1]);
42458      * // => false
42459      */
42460     function stubArray() {
42461       return [];
42462     }
42463
42464     /**
42465      * This method returns `false`.
42466      *
42467      * @static
42468      * @memberOf _
42469      * @since 4.13.0
42470      * @category Util
42471      * @returns {boolean} Returns `false`.
42472      * @example
42473      *
42474      * _.times(2, _.stubFalse);
42475      * // => [false, false]
42476      */
42477     function stubFalse() {
42478       return false;
42479     }
42480
42481     /**
42482      * This method returns a new empty object.
42483      *
42484      * @static
42485      * @memberOf _
42486      * @since 4.13.0
42487      * @category Util
42488      * @returns {Object} Returns the new empty object.
42489      * @example
42490      *
42491      * var objects = _.times(2, _.stubObject);
42492      *
42493      * console.log(objects);
42494      * // => [{}, {}]
42495      *
42496      * console.log(objects[0] === objects[1]);
42497      * // => false
42498      */
42499     function stubObject() {
42500       return {};
42501     }
42502
42503     /**
42504      * This method returns an empty string.
42505      *
42506      * @static
42507      * @memberOf _
42508      * @since 4.13.0
42509      * @category Util
42510      * @returns {string} Returns the empty string.
42511      * @example
42512      *
42513      * _.times(2, _.stubString);
42514      * // => ['', '']
42515      */
42516     function stubString() {
42517       return '';
42518     }
42519
42520     /**
42521      * This method returns `true`.
42522      *
42523      * @static
42524      * @memberOf _
42525      * @since 4.13.0
42526      * @category Util
42527      * @returns {boolean} Returns `true`.
42528      * @example
42529      *
42530      * _.times(2, _.stubTrue);
42531      * // => [true, true]
42532      */
42533     function stubTrue() {
42534       return true;
42535     }
42536
42537     /**
42538      * Invokes the iteratee `n` times, returning an array of the results of
42539      * each invocation. The iteratee is invoked with one argument; (index).
42540      *
42541      * @static
42542      * @since 0.1.0
42543      * @memberOf _
42544      * @category Util
42545      * @param {number} n The number of times to invoke `iteratee`.
42546      * @param {Function} [iteratee=_.identity] The function invoked per iteration.
42547      * @returns {Array} Returns the array of results.
42548      * @example
42549      *
42550      * _.times(3, String);
42551      * // => ['0', '1', '2']
42552      *
42553      *  _.times(4, _.constant(0));
42554      * // => [0, 0, 0, 0]
42555      */
42556     function times(n, iteratee) {
42557       n = toInteger(n);
42558       if (n < 1 || n > MAX_SAFE_INTEGER) {
42559         return [];
42560       }
42561       var index = MAX_ARRAY_LENGTH,
42562           length = nativeMin(n, MAX_ARRAY_LENGTH);
42563
42564       iteratee = getIteratee(iteratee);
42565       n -= MAX_ARRAY_LENGTH;
42566
42567       var result = baseTimes(length, iteratee);
42568       while (++index < n) {
42569         iteratee(index);
42570       }
42571       return result;
42572     }
42573
42574     /**
42575      * Converts `value` to a property path array.
42576      *
42577      * @static
42578      * @memberOf _
42579      * @since 4.0.0
42580      * @category Util
42581      * @param {*} value The value to convert.
42582      * @returns {Array} Returns the new property path array.
42583      * @example
42584      *
42585      * _.toPath('a.b.c');
42586      * // => ['a', 'b', 'c']
42587      *
42588      * _.toPath('a[0].b.c');
42589      * // => ['a', '0', 'b', 'c']
42590      */
42591     function toPath(value) {
42592       if (isArray(value)) {
42593         return arrayMap(value, toKey);
42594       }
42595       return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
42596     }
42597
42598     /**
42599      * Generates a unique ID. If `prefix` is given, the ID is appended to it.
42600      *
42601      * @static
42602      * @since 0.1.0
42603      * @memberOf _
42604      * @category Util
42605      * @param {string} [prefix=''] The value to prefix the ID with.
42606      * @returns {string} Returns the unique ID.
42607      * @example
42608      *
42609      * _.uniqueId('contact_');
42610      * // => 'contact_104'
42611      *
42612      * _.uniqueId();
42613      * // => '105'
42614      */
42615     function uniqueId(prefix) {
42616       var id = ++idCounter;
42617       return toString(prefix) + id;
42618     }
42619
42620     /*------------------------------------------------------------------------*/
42621
42622     /**
42623      * Adds two numbers.
42624      *
42625      * @static
42626      * @memberOf _
42627      * @since 3.4.0
42628      * @category Math
42629      * @param {number} augend The first number in an addition.
42630      * @param {number} addend The second number in an addition.
42631      * @returns {number} Returns the total.
42632      * @example
42633      *
42634      * _.add(6, 4);
42635      * // => 10
42636      */
42637     var add = createMathOperation(function(augend, addend) {
42638       return augend + addend;
42639     }, 0);
42640
42641     /**
42642      * Computes `number` rounded up to `precision`.
42643      *
42644      * @static
42645      * @memberOf _
42646      * @since 3.10.0
42647      * @category Math
42648      * @param {number} number The number to round up.
42649      * @param {number} [precision=0] The precision to round up to.
42650      * @returns {number} Returns the rounded up number.
42651      * @example
42652      *
42653      * _.ceil(4.006);
42654      * // => 5
42655      *
42656      * _.ceil(6.004, 2);
42657      * // => 6.01
42658      *
42659      * _.ceil(6040, -2);
42660      * // => 6100
42661      */
42662     var ceil = createRound('ceil');
42663
42664     /**
42665      * Divide two numbers.
42666      *
42667      * @static
42668      * @memberOf _
42669      * @since 4.7.0
42670      * @category Math
42671      * @param {number} dividend The first number in a division.
42672      * @param {number} divisor The second number in a division.
42673      * @returns {number} Returns the quotient.
42674      * @example
42675      *
42676      * _.divide(6, 4);
42677      * // => 1.5
42678      */
42679     var divide = createMathOperation(function(dividend, divisor) {
42680       return dividend / divisor;
42681     }, 1);
42682
42683     /**
42684      * Computes `number` rounded down to `precision`.
42685      *
42686      * @static
42687      * @memberOf _
42688      * @since 3.10.0
42689      * @category Math
42690      * @param {number} number The number to round down.
42691      * @param {number} [precision=0] The precision to round down to.
42692      * @returns {number} Returns the rounded down number.
42693      * @example
42694      *
42695      * _.floor(4.006);
42696      * // => 4
42697      *
42698      * _.floor(0.046, 2);
42699      * // => 0.04
42700      *
42701      * _.floor(4060, -2);
42702      * // => 4000
42703      */
42704     var floor = createRound('floor');
42705
42706     /**
42707      * Computes the maximum value of `array`. If `array` is empty or falsey,
42708      * `undefined` is returned.
42709      *
42710      * @static
42711      * @since 0.1.0
42712      * @memberOf _
42713      * @category Math
42714      * @param {Array} array The array to iterate over.
42715      * @returns {*} Returns the maximum value.
42716      * @example
42717      *
42718      * _.max([4, 2, 8, 6]);
42719      * // => 8
42720      *
42721      * _.max([]);
42722      * // => undefined
42723      */
42724     function max(array) {
42725       return (array && array.length)
42726         ? baseExtremum(array, identity, baseGt)
42727         : undefined;
42728     }
42729
42730     /**
42731      * This method is like `_.max` except that it accepts `iteratee` which is
42732      * invoked for each element in `array` to generate the criterion by which
42733      * the value is ranked. The iteratee is invoked with one argument: (value).
42734      *
42735      * @static
42736      * @memberOf _
42737      * @since 4.0.0
42738      * @category Math
42739      * @param {Array} array The array to iterate over.
42740      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42741      * @returns {*} Returns the maximum value.
42742      * @example
42743      *
42744      * var objects = [{ 'n': 1 }, { 'n': 2 }];
42745      *
42746      * _.maxBy(objects, function(o) { return o.n; });
42747      * // => { 'n': 2 }
42748      *
42749      * // The `_.property` iteratee shorthand.
42750      * _.maxBy(objects, 'n');
42751      * // => { 'n': 2 }
42752      */
42753     function maxBy(array, iteratee) {
42754       return (array && array.length)
42755         ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
42756         : undefined;
42757     }
42758
42759     /**
42760      * Computes the mean of the values in `array`.
42761      *
42762      * @static
42763      * @memberOf _
42764      * @since 4.0.0
42765      * @category Math
42766      * @param {Array} array The array to iterate over.
42767      * @returns {number} Returns the mean.
42768      * @example
42769      *
42770      * _.mean([4, 2, 8, 6]);
42771      * // => 5
42772      */
42773     function mean(array) {
42774       return baseMean(array, identity);
42775     }
42776
42777     /**
42778      * This method is like `_.mean` except that it accepts `iteratee` which is
42779      * invoked for each element in `array` to generate the value to be averaged.
42780      * The iteratee is invoked with one argument: (value).
42781      *
42782      * @static
42783      * @memberOf _
42784      * @since 4.7.0
42785      * @category Math
42786      * @param {Array} array The array to iterate over.
42787      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42788      * @returns {number} Returns the mean.
42789      * @example
42790      *
42791      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
42792      *
42793      * _.meanBy(objects, function(o) { return o.n; });
42794      * // => 5
42795      *
42796      * // The `_.property` iteratee shorthand.
42797      * _.meanBy(objects, 'n');
42798      * // => 5
42799      */
42800     function meanBy(array, iteratee) {
42801       return baseMean(array, getIteratee(iteratee, 2));
42802     }
42803
42804     /**
42805      * Computes the minimum value of `array`. If `array` is empty or falsey,
42806      * `undefined` is returned.
42807      *
42808      * @static
42809      * @since 0.1.0
42810      * @memberOf _
42811      * @category Math
42812      * @param {Array} array The array to iterate over.
42813      * @returns {*} Returns the minimum value.
42814      * @example
42815      *
42816      * _.min([4, 2, 8, 6]);
42817      * // => 2
42818      *
42819      * _.min([]);
42820      * // => undefined
42821      */
42822     function min(array) {
42823       return (array && array.length)
42824         ? baseExtremum(array, identity, baseLt)
42825         : undefined;
42826     }
42827
42828     /**
42829      * This method is like `_.min` except that it accepts `iteratee` which is
42830      * invoked for each element in `array` to generate the criterion by which
42831      * the value is ranked. The iteratee is invoked with one argument: (value).
42832      *
42833      * @static
42834      * @memberOf _
42835      * @since 4.0.0
42836      * @category Math
42837      * @param {Array} array The array to iterate over.
42838      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42839      * @returns {*} Returns the minimum value.
42840      * @example
42841      *
42842      * var objects = [{ 'n': 1 }, { 'n': 2 }];
42843      *
42844      * _.minBy(objects, function(o) { return o.n; });
42845      * // => { 'n': 1 }
42846      *
42847      * // The `_.property` iteratee shorthand.
42848      * _.minBy(objects, 'n');
42849      * // => { 'n': 1 }
42850      */
42851     function minBy(array, iteratee) {
42852       return (array && array.length)
42853         ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
42854         : undefined;
42855     }
42856
42857     /**
42858      * Multiply two numbers.
42859      *
42860      * @static
42861      * @memberOf _
42862      * @since 4.7.0
42863      * @category Math
42864      * @param {number} multiplier The first number in a multiplication.
42865      * @param {number} multiplicand The second number in a multiplication.
42866      * @returns {number} Returns the product.
42867      * @example
42868      *
42869      * _.multiply(6, 4);
42870      * // => 24
42871      */
42872     var multiply = createMathOperation(function(multiplier, multiplicand) {
42873       return multiplier * multiplicand;
42874     }, 1);
42875
42876     /**
42877      * Computes `number` rounded to `precision`.
42878      *
42879      * @static
42880      * @memberOf _
42881      * @since 3.10.0
42882      * @category Math
42883      * @param {number} number The number to round.
42884      * @param {number} [precision=0] The precision to round to.
42885      * @returns {number} Returns the rounded number.
42886      * @example
42887      *
42888      * _.round(4.006);
42889      * // => 4
42890      *
42891      * _.round(4.006, 2);
42892      * // => 4.01
42893      *
42894      * _.round(4060, -2);
42895      * // => 4100
42896      */
42897     var round = createRound('round');
42898
42899     /**
42900      * Subtract two numbers.
42901      *
42902      * @static
42903      * @memberOf _
42904      * @since 4.0.0
42905      * @category Math
42906      * @param {number} minuend The first number in a subtraction.
42907      * @param {number} subtrahend The second number in a subtraction.
42908      * @returns {number} Returns the difference.
42909      * @example
42910      *
42911      * _.subtract(6, 4);
42912      * // => 2
42913      */
42914     var subtract = createMathOperation(function(minuend, subtrahend) {
42915       return minuend - subtrahend;
42916     }, 0);
42917
42918     /**
42919      * Computes the sum of the values in `array`.
42920      *
42921      * @static
42922      * @memberOf _
42923      * @since 3.4.0
42924      * @category Math
42925      * @param {Array} array The array to iterate over.
42926      * @returns {number} Returns the sum.
42927      * @example
42928      *
42929      * _.sum([4, 2, 8, 6]);
42930      * // => 20
42931      */
42932     function sum(array) {
42933       return (array && array.length)
42934         ? baseSum(array, identity)
42935         : 0;
42936     }
42937
42938     /**
42939      * This method is like `_.sum` except that it accepts `iteratee` which is
42940      * invoked for each element in `array` to generate the value to be summed.
42941      * The iteratee is invoked with one argument: (value).
42942      *
42943      * @static
42944      * @memberOf _
42945      * @since 4.0.0
42946      * @category Math
42947      * @param {Array} array The array to iterate over.
42948      * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
42949      * @returns {number} Returns the sum.
42950      * @example
42951      *
42952      * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
42953      *
42954      * _.sumBy(objects, function(o) { return o.n; });
42955      * // => 20
42956      *
42957      * // The `_.property` iteratee shorthand.
42958      * _.sumBy(objects, 'n');
42959      * // => 20
42960      */
42961     function sumBy(array, iteratee) {
42962       return (array && array.length)
42963         ? baseSum(array, getIteratee(iteratee, 2))
42964         : 0;
42965     }
42966
42967     /*------------------------------------------------------------------------*/
42968
42969     // Add methods that return wrapped values in chain sequences.
42970     lodash.after = after;
42971     lodash.ary = ary;
42972     lodash.assign = assign;
42973     lodash.assignIn = assignIn;
42974     lodash.assignInWith = assignInWith;
42975     lodash.assignWith = assignWith;
42976     lodash.at = at;
42977     lodash.before = before;
42978     lodash.bind = bind;
42979     lodash.bindAll = bindAll;
42980     lodash.bindKey = bindKey;
42981     lodash.castArray = castArray;
42982     lodash.chain = chain;
42983     lodash.chunk = chunk;
42984     lodash.compact = compact;
42985     lodash.concat = concat;
42986     lodash.cond = cond;
42987     lodash.conforms = conforms;
42988     lodash.constant = constant;
42989     lodash.countBy = countBy;
42990     lodash.create = create;
42991     lodash.curry = curry;
42992     lodash.curryRight = curryRight;
42993     lodash.debounce = debounce;
42994     lodash.defaults = defaults;
42995     lodash.defaultsDeep = defaultsDeep;
42996     lodash.defer = defer;
42997     lodash.delay = delay;
42998     lodash.difference = difference;
42999     lodash.differenceBy = differenceBy;
43000     lodash.differenceWith = differenceWith;
43001     lodash.drop = drop;
43002     lodash.dropRight = dropRight;
43003     lodash.dropRightWhile = dropRightWhile;
43004     lodash.dropWhile = dropWhile;
43005     lodash.fill = fill;
43006     lodash.filter = filter;
43007     lodash.flatMap = flatMap;
43008     lodash.flatMapDeep = flatMapDeep;
43009     lodash.flatMapDepth = flatMapDepth;
43010     lodash.flatten = flatten;
43011     lodash.flattenDeep = flattenDeep;
43012     lodash.flattenDepth = flattenDepth;
43013     lodash.flip = flip;
43014     lodash.flow = flow;
43015     lodash.flowRight = flowRight;
43016     lodash.fromPairs = fromPairs;
43017     lodash.functions = functions;
43018     lodash.functionsIn = functionsIn;
43019     lodash.groupBy = groupBy;
43020     lodash.initial = initial;
43021     lodash.intersection = intersection;
43022     lodash.intersectionBy = intersectionBy;
43023     lodash.intersectionWith = intersectionWith;
43024     lodash.invert = invert;
43025     lodash.invertBy = invertBy;
43026     lodash.invokeMap = invokeMap;
43027     lodash.iteratee = iteratee;
43028     lodash.keyBy = keyBy;
43029     lodash.keys = keys;
43030     lodash.keysIn = keysIn;
43031     lodash.map = map;
43032     lodash.mapKeys = mapKeys;
43033     lodash.mapValues = mapValues;
43034     lodash.matches = matches;
43035     lodash.matchesProperty = matchesProperty;
43036     lodash.memoize = memoize;
43037     lodash.merge = merge;
43038     lodash.mergeWith = mergeWith;
43039     lodash.method = method;
43040     lodash.methodOf = methodOf;
43041     lodash.mixin = mixin;
43042     lodash.negate = negate;
43043     lodash.nthArg = nthArg;
43044     lodash.omit = omit;
43045     lodash.omitBy = omitBy;
43046     lodash.once = once;
43047     lodash.orderBy = orderBy;
43048     lodash.over = over;
43049     lodash.overArgs = overArgs;
43050     lodash.overEvery = overEvery;
43051     lodash.overSome = overSome;
43052     lodash.partial = partial;
43053     lodash.partialRight = partialRight;
43054     lodash.partition = partition;
43055     lodash.pick = pick;
43056     lodash.pickBy = pickBy;
43057     lodash.property = property;
43058     lodash.propertyOf = propertyOf;
43059     lodash.pull = pull;
43060     lodash.pullAll = pullAll;
43061     lodash.pullAllBy = pullAllBy;
43062     lodash.pullAllWith = pullAllWith;
43063     lodash.pullAt = pullAt;
43064     lodash.range = range;
43065     lodash.rangeRight = rangeRight;
43066     lodash.rearg = rearg;
43067     lodash.reject = reject;
43068     lodash.remove = remove;
43069     lodash.rest = rest;
43070     lodash.reverse = reverse;
43071     lodash.sampleSize = sampleSize;
43072     lodash.set = set;
43073     lodash.setWith = setWith;
43074     lodash.shuffle = shuffle;
43075     lodash.slice = slice;
43076     lodash.sortBy = sortBy;
43077     lodash.sortedUniq = sortedUniq;
43078     lodash.sortedUniqBy = sortedUniqBy;
43079     lodash.split = split;
43080     lodash.spread = spread;
43081     lodash.tail = tail;
43082     lodash.take = take;
43083     lodash.takeRight = takeRight;
43084     lodash.takeRightWhile = takeRightWhile;
43085     lodash.takeWhile = takeWhile;
43086     lodash.tap = tap;
43087     lodash.throttle = throttle;
43088     lodash.thru = thru;
43089     lodash.toArray = toArray;
43090     lodash.toPairs = toPairs;
43091     lodash.toPairsIn = toPairsIn;
43092     lodash.toPath = toPath;
43093     lodash.toPlainObject = toPlainObject;
43094     lodash.transform = transform;
43095     lodash.unary = unary;
43096     lodash.union = union;
43097     lodash.unionBy = unionBy;
43098     lodash.unionWith = unionWith;
43099     lodash.uniq = uniq;
43100     lodash.uniqBy = uniqBy;
43101     lodash.uniqWith = uniqWith;
43102     lodash.unset = unset;
43103     lodash.unzip = unzip;
43104     lodash.unzipWith = unzipWith;
43105     lodash.update = update;
43106     lodash.updateWith = updateWith;
43107     lodash.values = values;
43108     lodash.valuesIn = valuesIn;
43109     lodash.without = without;
43110     lodash.words = words;
43111     lodash.wrap = wrap;
43112     lodash.xor = xor;
43113     lodash.xorBy = xorBy;
43114     lodash.xorWith = xorWith;
43115     lodash.zip = zip;
43116     lodash.zipObject = zipObject;
43117     lodash.zipObjectDeep = zipObjectDeep;
43118     lodash.zipWith = zipWith;
43119
43120     // Add aliases.
43121     lodash.entries = toPairs;
43122     lodash.entriesIn = toPairsIn;
43123     lodash.extend = assignIn;
43124     lodash.extendWith = assignInWith;
43125
43126     // Add methods to `lodash.prototype`.
43127     mixin(lodash, lodash);
43128
43129     /*------------------------------------------------------------------------*/
43130
43131     // Add methods that return unwrapped values in chain sequences.
43132     lodash.add = add;
43133     lodash.attempt = attempt;
43134     lodash.camelCase = camelCase;
43135     lodash.capitalize = capitalize;
43136     lodash.ceil = ceil;
43137     lodash.clamp = clamp;
43138     lodash.clone = clone;
43139     lodash.cloneDeep = cloneDeep;
43140     lodash.cloneDeepWith = cloneDeepWith;
43141     lodash.cloneWith = cloneWith;
43142     lodash.conformsTo = conformsTo;
43143     lodash.deburr = deburr;
43144     lodash.defaultTo = defaultTo;
43145     lodash.divide = divide;
43146     lodash.endsWith = endsWith;
43147     lodash.eq = eq;
43148     lodash.escape = escape;
43149     lodash.escapeRegExp = escapeRegExp;
43150     lodash.every = every;
43151     lodash.find = find;
43152     lodash.findIndex = findIndex;
43153     lodash.findKey = findKey;
43154     lodash.findLast = findLast;
43155     lodash.findLastIndex = findLastIndex;
43156     lodash.findLastKey = findLastKey;
43157     lodash.floor = floor;
43158     lodash.forEach = forEach;
43159     lodash.forEachRight = forEachRight;
43160     lodash.forIn = forIn;
43161     lodash.forInRight = forInRight;
43162     lodash.forOwn = forOwn;
43163     lodash.forOwnRight = forOwnRight;
43164     lodash.get = get;
43165     lodash.gt = gt;
43166     lodash.gte = gte;
43167     lodash.has = has;
43168     lodash.hasIn = hasIn;
43169     lodash.head = head;
43170     lodash.identity = identity;
43171     lodash.includes = includes;
43172     lodash.indexOf = indexOf;
43173     lodash.inRange = inRange;
43174     lodash.invoke = invoke;
43175     lodash.isArguments = isArguments;
43176     lodash.isArray = isArray;
43177     lodash.isArrayBuffer = isArrayBuffer;
43178     lodash.isArrayLike = isArrayLike;
43179     lodash.isArrayLikeObject = isArrayLikeObject;
43180     lodash.isBoolean = isBoolean;
43181     lodash.isBuffer = isBuffer;
43182     lodash.isDate = isDate;
43183     lodash.isElement = isElement;
43184     lodash.isEmpty = isEmpty;
43185     lodash.isEqual = isEqual;
43186     lodash.isEqualWith = isEqualWith;
43187     lodash.isError = isError;
43188     lodash.isFinite = isFinite;
43189     lodash.isFunction = isFunction;
43190     lodash.isInteger = isInteger;
43191     lodash.isLength = isLength;
43192     lodash.isMap = isMap;
43193     lodash.isMatch = isMatch;
43194     lodash.isMatchWith = isMatchWith;
43195     lodash.isNaN = isNaN;
43196     lodash.isNative = isNative;
43197     lodash.isNil = isNil;
43198     lodash.isNull = isNull;
43199     lodash.isNumber = isNumber;
43200     lodash.isObject = isObject;
43201     lodash.isObjectLike = isObjectLike;
43202     lodash.isPlainObject = isPlainObject;
43203     lodash.isRegExp = isRegExp;
43204     lodash.isSafeInteger = isSafeInteger;
43205     lodash.isSet = isSet;
43206     lodash.isString = isString;
43207     lodash.isSymbol = isSymbol;
43208     lodash.isTypedArray = isTypedArray;
43209     lodash.isUndefined = isUndefined;
43210     lodash.isWeakMap = isWeakMap;
43211     lodash.isWeakSet = isWeakSet;
43212     lodash.join = join;
43213     lodash.kebabCase = kebabCase;
43214     lodash.last = last;
43215     lodash.lastIndexOf = lastIndexOf;
43216     lodash.lowerCase = lowerCase;
43217     lodash.lowerFirst = lowerFirst;
43218     lodash.lt = lt;
43219     lodash.lte = lte;
43220     lodash.max = max;
43221     lodash.maxBy = maxBy;
43222     lodash.mean = mean;
43223     lodash.meanBy = meanBy;
43224     lodash.min = min;
43225     lodash.minBy = minBy;
43226     lodash.stubArray = stubArray;
43227     lodash.stubFalse = stubFalse;
43228     lodash.stubObject = stubObject;
43229     lodash.stubString = stubString;
43230     lodash.stubTrue = stubTrue;
43231     lodash.multiply = multiply;
43232     lodash.nth = nth;
43233     lodash.noConflict = noConflict;
43234     lodash.noop = noop;
43235     lodash.now = now;
43236     lodash.pad = pad;
43237     lodash.padEnd = padEnd;
43238     lodash.padStart = padStart;
43239     lodash.parseInt = parseInt;
43240     lodash.random = random;
43241     lodash.reduce = reduce;
43242     lodash.reduceRight = reduceRight;
43243     lodash.repeat = repeat;
43244     lodash.replace = replace;
43245     lodash.result = result;
43246     lodash.round = round;
43247     lodash.runInContext = runInContext;
43248     lodash.sample = sample;
43249     lodash.size = size;
43250     lodash.snakeCase = snakeCase;
43251     lodash.some = some;
43252     lodash.sortedIndex = sortedIndex;
43253     lodash.sortedIndexBy = sortedIndexBy;
43254     lodash.sortedIndexOf = sortedIndexOf;
43255     lodash.sortedLastIndex = sortedLastIndex;
43256     lodash.sortedLastIndexBy = sortedLastIndexBy;
43257     lodash.sortedLastIndexOf = sortedLastIndexOf;
43258     lodash.startCase = startCase;
43259     lodash.startsWith = startsWith;
43260     lodash.subtract = subtract;
43261     lodash.sum = sum;
43262     lodash.sumBy = sumBy;
43263     lodash.template = template;
43264     lodash.times = times;
43265     lodash.toFinite = toFinite;
43266     lodash.toInteger = toInteger;
43267     lodash.toLength = toLength;
43268     lodash.toLower = toLower;
43269     lodash.toNumber = toNumber;
43270     lodash.toSafeInteger = toSafeInteger;
43271     lodash.toString = toString;
43272     lodash.toUpper = toUpper;
43273     lodash.trim = trim;
43274     lodash.trimEnd = trimEnd;
43275     lodash.trimStart = trimStart;
43276     lodash.truncate = truncate;
43277     lodash.unescape = unescape;
43278     lodash.uniqueId = uniqueId;
43279     lodash.upperCase = upperCase;
43280     lodash.upperFirst = upperFirst;
43281
43282     // Add aliases.
43283     lodash.each = forEach;
43284     lodash.eachRight = forEachRight;
43285     lodash.first = head;
43286
43287     mixin(lodash, (function() {
43288       var source = {};
43289       baseForOwn(lodash, function(func, methodName) {
43290         if (!hasOwnProperty.call(lodash.prototype, methodName)) {
43291           source[methodName] = func;
43292         }
43293       });
43294       return source;
43295     }()), { 'chain': false });
43296
43297     /*------------------------------------------------------------------------*/
43298
43299     /**
43300      * The semantic version number.
43301      *
43302      * @static
43303      * @memberOf _
43304      * @type {string}
43305      */
43306     lodash.VERSION = VERSION;
43307
43308     // Assign default placeholders.
43309     arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
43310       lodash[methodName].placeholder = lodash;
43311     });
43312
43313     // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
43314     arrayEach(['drop', 'take'], function(methodName, index) {
43315       LazyWrapper.prototype[methodName] = function(n) {
43316         n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
43317
43318         var result = (this.__filtered__ && !index)
43319           ? new LazyWrapper(this)
43320           : this.clone();
43321
43322         if (result.__filtered__) {
43323           result.__takeCount__ = nativeMin(n, result.__takeCount__);
43324         } else {
43325           result.__views__.push({
43326             'size': nativeMin(n, MAX_ARRAY_LENGTH),
43327             'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
43328           });
43329         }
43330         return result;
43331       };
43332
43333       LazyWrapper.prototype[methodName + 'Right'] = function(n) {
43334         return this.reverse()[methodName](n).reverse();
43335       };
43336     });
43337
43338     // Add `LazyWrapper` methods that accept an `iteratee` value.
43339     arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
43340       var type = index + 1,
43341           isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
43342
43343       LazyWrapper.prototype[methodName] = function(iteratee) {
43344         var result = this.clone();
43345         result.__iteratees__.push({
43346           'iteratee': getIteratee(iteratee, 3),
43347           'type': type
43348         });
43349         result.__filtered__ = result.__filtered__ || isFilter;
43350         return result;
43351       };
43352     });
43353
43354     // Add `LazyWrapper` methods for `_.head` and `_.last`.
43355     arrayEach(['head', 'last'], function(methodName, index) {
43356       var takeName = 'take' + (index ? 'Right' : '');
43357
43358       LazyWrapper.prototype[methodName] = function() {
43359         return this[takeName](1).value()[0];
43360       };
43361     });
43362
43363     // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
43364     arrayEach(['initial', 'tail'], function(methodName, index) {
43365       var dropName = 'drop' + (index ? '' : 'Right');
43366
43367       LazyWrapper.prototype[methodName] = function() {
43368         return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
43369       };
43370     });
43371
43372     LazyWrapper.prototype.compact = function() {
43373       return this.filter(identity);
43374     };
43375
43376     LazyWrapper.prototype.find = function(predicate) {
43377       return this.filter(predicate).head();
43378     };
43379
43380     LazyWrapper.prototype.findLast = function(predicate) {
43381       return this.reverse().find(predicate);
43382     };
43383
43384     LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
43385       if (typeof path == 'function') {
43386         return new LazyWrapper(this);
43387       }
43388       return this.map(function(value) {
43389         return baseInvoke(value, path, args);
43390       });
43391     });
43392
43393     LazyWrapper.prototype.reject = function(predicate) {
43394       return this.filter(negate(getIteratee(predicate)));
43395     };
43396
43397     LazyWrapper.prototype.slice = function(start, end) {
43398       start = toInteger(start);
43399
43400       var result = this;
43401       if (result.__filtered__ && (start > 0 || end < 0)) {
43402         return new LazyWrapper(result);
43403       }
43404       if (start < 0) {
43405         result = result.takeRight(-start);
43406       } else if (start) {
43407         result = result.drop(start);
43408       }
43409       if (end !== undefined) {
43410         end = toInteger(end);
43411         result = end < 0 ? result.dropRight(-end) : result.take(end - start);
43412       }
43413       return result;
43414     };
43415
43416     LazyWrapper.prototype.takeRightWhile = function(predicate) {
43417       return this.reverse().takeWhile(predicate).reverse();
43418     };
43419
43420     LazyWrapper.prototype.toArray = function() {
43421       return this.take(MAX_ARRAY_LENGTH);
43422     };
43423
43424     // Add `LazyWrapper` methods to `lodash.prototype`.
43425     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
43426       var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
43427           isTaker = /^(?:head|last)$/.test(methodName),
43428           lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
43429           retUnwrapped = isTaker || /^find/.test(methodName);
43430
43431       if (!lodashFunc) {
43432         return;
43433       }
43434       lodash.prototype[methodName] = function() {
43435         var value = this.__wrapped__,
43436             args = isTaker ? [1] : arguments,
43437             isLazy = value instanceof LazyWrapper,
43438             iteratee = args[0],
43439             useLazy = isLazy || isArray(value);
43440
43441         var interceptor = function(value) {
43442           var result = lodashFunc.apply(lodash, arrayPush([value], args));
43443           return (isTaker && chainAll) ? result[0] : result;
43444         };
43445
43446         if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
43447           // Avoid lazy use if the iteratee has a "length" value other than `1`.
43448           isLazy = useLazy = false;
43449         }
43450         var chainAll = this.__chain__,
43451             isHybrid = !!this.__actions__.length,
43452             isUnwrapped = retUnwrapped && !chainAll,
43453             onlyLazy = isLazy && !isHybrid;
43454
43455         if (!retUnwrapped && useLazy) {
43456           value = onlyLazy ? value : new LazyWrapper(this);
43457           var result = func.apply(value, args);
43458           result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
43459           return new LodashWrapper(result, chainAll);
43460         }
43461         if (isUnwrapped && onlyLazy) {
43462           return func.apply(this, args);
43463         }
43464         result = this.thru(interceptor);
43465         return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
43466       };
43467     });
43468
43469     // Add `Array` methods to `lodash.prototype`.
43470     arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
43471       var func = arrayProto[methodName],
43472           chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
43473           retUnwrapped = /^(?:pop|shift)$/.test(methodName);
43474
43475       lodash.prototype[methodName] = function() {
43476         var args = arguments;
43477         if (retUnwrapped && !this.__chain__) {
43478           var value = this.value();
43479           return func.apply(isArray(value) ? value : [], args);
43480         }
43481         return this[chainName](function(value) {
43482           return func.apply(isArray(value) ? value : [], args);
43483         });
43484       };
43485     });
43486
43487     // Map minified method names to their real names.
43488     baseForOwn(LazyWrapper.prototype, function(func, methodName) {
43489       var lodashFunc = lodash[methodName];
43490       if (lodashFunc) {
43491         var key = lodashFunc.name + '';
43492         if (!hasOwnProperty.call(realNames, key)) {
43493           realNames[key] = [];
43494         }
43495         realNames[key].push({ 'name': methodName, 'func': lodashFunc });
43496       }
43497     });
43498
43499     realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
43500       'name': 'wrapper',
43501       'func': undefined
43502     }];
43503
43504     // Add methods to `LazyWrapper`.
43505     LazyWrapper.prototype.clone = lazyClone;
43506     LazyWrapper.prototype.reverse = lazyReverse;
43507     LazyWrapper.prototype.value = lazyValue;
43508
43509     // Add chain sequence methods to the `lodash` wrapper.
43510     lodash.prototype.at = wrapperAt;
43511     lodash.prototype.chain = wrapperChain;
43512     lodash.prototype.commit = wrapperCommit;
43513     lodash.prototype.next = wrapperNext;
43514     lodash.prototype.plant = wrapperPlant;
43515     lodash.prototype.reverse = wrapperReverse;
43516     lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
43517
43518     // Add lazy aliases.
43519     lodash.prototype.first = lodash.prototype.head;
43520
43521     if (symIterator) {
43522       lodash.prototype[symIterator] = wrapperToIterator;
43523     }
43524     return lodash;
43525   });
43526
43527   /*--------------------------------------------------------------------------*/
43528
43529   // Export lodash.
43530   var _ = runInContext();
43531
43532   // Some AMD build optimizers, like r.js, check for condition patterns like:
43533   if (true) {
43534     // Expose Lodash on the global object to prevent errors when Lodash is
43535     // loaded by a script tag in the presence of an AMD loader.
43536     // See http://requirejs.org/docs/errors.html#mismatch for more details.
43537     // Use `_.noConflict` to remove Lodash from the global object.
43538     root._ = _;
43539
43540     // Define as an anonymous module so, through path mapping, it can be
43541     // referenced as the "underscore" module.
43542     !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
43543       return _;
43544     }).call(exports, __webpack_require__, exports, module),
43545                                 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
43546   }
43547   // Check for `exports` after `define` in case a build optimizer adds it.
43548   else if (freeModule) {
43549     // Export for Node.js.
43550     (freeModule.exports = _)._ = _;
43551     // Export for CommonJS support.
43552     freeExports._ = _;
43553   }
43554   else {
43555     // Export to the global object.
43556     root._ = _;
43557   }
43558 }.call(this));
43559
43560 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10), __webpack_require__(128)(module)))
43561
43562 /***/ }),
43563 /* 435 */,
43564 /* 436 */,
43565 /* 437 */,
43566 /* 438 */,
43567 /* 439 */,
43568 /* 440 */,
43569 /* 441 */,
43570 /* 442 */,
43571 /* 443 */,
43572 /* 444 */,
43573 /* 445 */,
43574 /* 446 */,
43575 /* 447 */,
43576 /* 448 */,
43577 /* 449 */,
43578 /* 450 */,
43579 /* 451 */,
43580 /* 452 */,
43581 /* 453 */,
43582 /* 454 */,
43583 /* 455 */,
43584 /* 456 */,
43585 /* 457 */,
43586 /* 458 */,
43587 /* 459 */,
43588 /* 460 */,
43589 /* 461 */,
43590 /* 462 */,
43591 /* 463 */,
43592 /* 464 */,
43593 /* 465 */,
43594 /* 466 */,
43595 /* 467 */,
43596 /* 468 */,
43597 /* 469 */,
43598 /* 470 */,
43599 /* 471 */,
43600 /* 472 */,
43601 /* 473 */,
43602 /* 474 */,
43603 /* 475 */,
43604 /* 476 */,
43605 /* 477 */,
43606 /* 478 */,
43607 /* 479 */,
43608 /* 480 */,
43609 /* 481 */,
43610 /* 482 */,
43611 /* 483 */,
43612 /* 484 */,
43613 /* 485 */,
43614 /* 486 */,
43615 /* 487 */,
43616 /* 488 */,
43617 /* 489 */,
43618 /* 490 */,
43619 /* 491 */,
43620 /* 492 */,
43621 /* 493 */,
43622 /* 494 */,
43623 /* 495 */,
43624 /* 496 */,
43625 /* 497 */,
43626 /* 498 */,
43627 /* 499 */,
43628 /* 500 */,
43629 /* 501 */,
43630 /* 502 */,
43631 /* 503 */,
43632 /* 504 */,
43633 /* 505 */,
43634 /* 506 */,
43635 /* 507 */,
43636 /* 508 */,
43637 /* 509 */,
43638 /* 510 */,
43639 /* 511 */,
43640 /* 512 */,
43641 /* 513 */,
43642 /* 514 */,
43643 /* 515 */,
43644 /* 516 */,
43645 /* 517 */,
43646 /* 518 */,
43647 /* 519 */,
43648 /* 520 */,
43649 /* 521 */,
43650 /* 522 */,
43651 /* 523 */,
43652 /* 524 */,
43653 /* 525 */,
43654 /* 526 */,
43655 /* 527 */,
43656 /* 528 */,
43657 /* 529 */
43658 /***/ (function(module, __webpack_exports__, __webpack_require__) {
43659
43660 "use strict";
43661 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return apis; });
43662 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
43663 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
43664
43665
43666 var swallow = function swallow(fn) {
43667     try {
43668         fn();
43669     } catch (e) {}
43670 };
43671
43672 var ApiGenerator = function ApiGenerator() {
43673     var _this = this;
43674
43675     __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, ApiGenerator);
43676
43677     ['app', 'storage', 'extension', 'runtime', 'windows'].map(function (api) {
43678         if (typeof chrome !== 'undefined') swallow(function () {
43679             if (chrome[api]) _this[api] = chrome[api];
43680         });
43681         if (typeof browser !== 'undefined') swallow(function () {
43682             if (browser[api]) _this[api] = browser[api];
43683         });
43684     });
43685
43686     if (typeof browser !== 'undefined') swallow(function () {
43687         if (browser && browser.runtime) _this.runtime = browser.runtime;
43688     });
43689 };
43690
43691 var apis = new ApiGenerator();
43692
43693 /***/ }),
43694 /* 530 */
43695 /***/ (function(module, __webpack_exports__, __webpack_require__) {
43696
43697 "use strict";
43698 /* unused harmony export ErrorCodes */
43699 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
43700 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
43701 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(36);
43702 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
43703 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ErrorTypes__ = __webpack_require__(535);
43704
43705
43706
43707
43708 var ErrorCodes = {
43709   NO_SIGNATURE: 402,
43710   FORBIDDEN: 403,
43711   TIMED_OUT: 408,
43712   LOCKED: 423,
43713   TOO_MANY_REQUESTS: 429,
43714   TYPE_MISSED: 411,
43715   TYPE_DUPLICATE: 405
43716 };
43717
43718 var Error = function () {
43719   function Error(_type, _message) {
43720     var _code = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ErrorCodes.LOCKED;
43721
43722     __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Error);
43723
43724     this.type = _type;
43725     this.message = _message;
43726     this.code = _code;
43727     this.isError = true;
43728   }
43729
43730   __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(Error, null, [{
43731     key: "locked",
43732     value: function locked() {
43733       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["a" /* LOCKED */], "The user's Bytom is locked. They have been notified and should unlock before continuing.");
43734     }
43735   }, {
43736     key: "duplicate",
43737     value: function duplicate(_type) {
43738       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["d" /* TYPE_DUPLICATED */], "The current value has been set to '" + _type + "', please select another parameter.", ErrorCodes.TYPE_DUPLICATE);
43739     }
43740   }, {
43741     key: "promptClosedWithoutAction",
43742     value: function promptClosedWithoutAction() {
43743       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["c" /* PROMPT_CLOSED */], "The user closed the prompt without any action.", ErrorCodes.TIMED_OUT);
43744     }
43745   }, {
43746     key: "signatureError",
43747     value: function signatureError(_type, _message) {
43748       return new Error(_type, _message, ErrorCodes.NO_SIGNATURE);
43749     }
43750   }, {
43751     key: "typeMissed",
43752     value: function typeMissed(_type) {
43753       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["e" /* TYPE_MISSED */], "Parameter '" + _type + "' is missing, please add the Parameter '" + _type + "'.");
43754     }
43755   }, {
43756     key: "identityMissing",
43757     value: function identityMissing() {
43758       return this.signatureError("identity_missing", "Identity no longer exists on the user's keychain");
43759     }
43760   }, {
43761     key: "signatureAccountMissing",
43762     value: function signatureAccountMissing() {
43763       return this.signatureError("account_missing", "Missing required accounts, repull the identity");
43764     }
43765   }, {
43766     key: "malformedRequiredFields",
43767     value: function malformedRequiredFields() {
43768       return this.signatureError("malformed_requirements", "The requiredFields you passed in were malformed");
43769     }
43770   }, {
43771     key: "usedKeyProvider",
43772     value: function usedKeyProvider() {
43773       return new Error(__WEBPACK_IMPORTED_MODULE_2__ErrorTypes__["b" /* MALICIOUS */], "Do not use a `keyProvider` with a Bytom. Use a `signProvider` and return only signatures to this object. A malicious person could retrieve your keys otherwise.", ErrorCodes.NO_SIGNATURE);
43774     }
43775   }]);
43776
43777   return Error;
43778 }();
43779
43780 /* harmony default export */ __webpack_exports__["a"] = (Error);
43781
43782 /***/ }),
43783 /* 531 */,
43784 /* 532 */
43785 /***/ (function(module, exports, __webpack_require__) {
43786
43787 "use strict";
43788
43789
43790 exports.__esModule = true;
43791
43792 var _assign = __webpack_require__(69);
43793
43794 var _assign2 = _interopRequireDefault(_assign);
43795
43796 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43797
43798 exports.default = _assign2.default || function (target) {
43799   for (var i = 1; i < arguments.length; i++) {
43800     var source = arguments[i];
43801
43802     for (var key in source) {
43803       if (Object.prototype.hasOwnProperty.call(source, key)) {
43804         target[key] = source[key];
43805       }
43806     }
43807   }
43808
43809   return target;
43810 };
43811
43812 /***/ }),
43813 /* 533 */,
43814 /* 534 */
43815 /***/ (function(module, __webpack_exports__, __webpack_require__) {
43816
43817 "use strict";
43818 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
43819 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__);
43820 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__ = __webpack_require__(138);
43821 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__);
43822 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(139);
43823 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__);
43824 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
43825 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck__);
43826 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass__ = __webpack_require__(36);
43827 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass__);
43828 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_errors_Error__ = __webpack_require__(530);
43829 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__ = __webpack_require__(529);
43830 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__messages_internal__ = __webpack_require__(267);
43831 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__messages_types__ = __webpack_require__(129);
43832
43833
43834
43835
43836
43837
43838
43839
43840
43841
43842 var openWindow = null;
43843
43844 var NotificationService = function () {
43845     function NotificationService() {
43846         __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_classCallCheck___default()(this, NotificationService);
43847     }
43848
43849     __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_createClass___default()(NotificationService, null, [{
43850         key: 'open',
43851
43852
43853         /***
43854          * Opens a prompt window outside of the extension
43855          * @param notification
43856          */
43857         value: function () {
43858             var _ref = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee2(notification) {
43859                 var _this = this;
43860
43861                 var height, width, middleX, middleY, getPopup, popup;
43862                 return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee2$(_context2) {
43863                     while (1) {
43864                         switch (_context2.prev = _context2.next) {
43865                             case 0:
43866                                 if (openWindow) {
43867                                     // For now we're just going to close the window to get rid of the error
43868                                     // that is caused by already open windows swallowing all further requests
43869                                     openWindow.close();
43870                                     openWindow = null;
43871
43872                                     // Alternatively we could focus the old window, but this would cause
43873                                     // urgent 1-time messages to be lost, such as after dying in a game and
43874                                     // uploading a high-score. That message will be lost.
43875                                     // openWindow.focus();
43876                                     // return false;
43877
43878                                     // A third option would be to add a queue, but this could cause
43879                                     // virus-like behavior as apps overflow the queue causing the user
43880                                     // to have to quit the browser to regain control.
43881                                 }
43882
43883                                 height = 623;
43884                                 width = 360;
43885                                 middleX = window.screen.availWidth / 2 - width / 2;
43886                                 middleY = window.screen.availHeight / 2 - height / 2;
43887
43888                                 getPopup = function () {
43889                                     var _ref2 = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee() {
43890                                         var url, win;
43891                                         return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
43892                                             while (1) {
43893                                                 switch (_context.prev = _context.next) {
43894                                                     case 0:
43895                                                         _context.prev = 0;
43896                                                         url = __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].runtime.getURL('pages/prompt.html') + '#' + notification.routeName();
43897
43898                                                         // Notifications get bound differently depending on browser
43899                                                         // as Firefox does not support opening windows from background.
43900
43901                                                         if (!(typeof chrome !== 'undefined')) {
43902                                                             _context.next = 7;
43903                                                             break;
43904                                                         }
43905
43906                                                         window.notification = notification;
43907                                                         __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.create({
43908                                                             url: url,
43909                                                             height: height,
43910                                                             width: width,
43911                                                             type: 'popup'
43912                                                         }, function (_window) {
43913                                                             __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.onRemoved.addListener(function (windowId) {
43914                                                                 if (windowId === _window.id) {
43915                                                                     notification.responder(__WEBPACK_IMPORTED_MODULE_5__utils_errors_Error__["a" /* default */].promptClosedWithoutAction());
43916                                                                     return false;
43917                                                                 }
43918                                                             });
43919                                                             return _window;
43920                                                         });
43921                                                         _context.next = 11;
43922                                                         break;
43923
43924                                                     case 7:
43925                                                         win = window.open(url, 'BytomPrompt', 'width=' + width + ',height=' + height + ',resizable=0,top=' + middleY + ',left=' + middleX + ',titlebar=0');
43926
43927                                                         win.data = notification;
43928                                                         openWindow = win;
43929                                                         return _context.abrupt('return', win);
43930
43931                                                     case 11:
43932                                                         _context.next = 17;
43933                                                         break;
43934
43935                                                     case 13:
43936                                                         _context.prev = 13;
43937                                                         _context.t0 = _context['catch'](0);
43938
43939                                                         console.log('notification error', _context.t0);
43940                                                         return _context.abrupt('return', null);
43941
43942                                                     case 17:
43943                                                     case 'end':
43944                                                         return _context.stop();
43945                                                 }
43946                                             }
43947                                         }, _callee, _this, [[0, 13]]);
43948                                     }));
43949
43950                                     return function getPopup() {
43951                                         return _ref2.apply(this, arguments);
43952                                     };
43953                                 }();
43954
43955                                 _context2.next = 8;
43956                                 return __WEBPACK_IMPORTED_MODULE_7__messages_internal__["a" /* default */].payload(__WEBPACK_IMPORTED_MODULE_8__messages_types__["l" /* SET_PROMPT */], __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(notification)).send();
43957
43958                             case 8:
43959                                 _context2.next = 10;
43960                                 return getPopup();
43961
43962                             case 10:
43963                                 popup = _context2.sent;
43964
43965
43966                                 if (popup) {
43967                                     popup.onbeforeunload = function () {
43968                                         notification.responder(__WEBPACK_IMPORTED_MODULE_5__utils_errors_Error__["a" /* default */].promptClosedWithoutAction());
43969
43970                                         // https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
43971                                         // Must return undefined to bypass form protection
43972                                         openWindow = null;
43973                                         return undefined;
43974                                     };
43975                                 }
43976
43977                             case 12:
43978                             case 'end':
43979                                 return _context2.stop();
43980                         }
43981                     }
43982                 }, _callee2, this);
43983             }));
43984
43985             function open(_x) {
43986                 return _ref.apply(this, arguments);
43987             }
43988
43989             return open;
43990         }()
43991
43992         /***
43993          * Always use this method for closing notification popups.
43994          * Otherwise you will double send responses and one will always be null.
43995          */
43996
43997     }, {
43998         key: 'close',
43999         value: function () {
44000             var _ref3 = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()( /*#__PURE__*/__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee3() {
44001                 var _ref4, windowId;
44002
44003                 return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee3$(_context3) {
44004                     while (1) {
44005                         switch (_context3.prev = _context3.next) {
44006                             case 0:
44007                                 if (!(typeof browser !== 'undefined')) {
44008                                     _context3.next = 8;
44009                                     break;
44010                                 }
44011
44012                                 _context3.next = 3;
44013                                 return __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.getCurrent();
44014
44015                             case 3:
44016                                 _ref4 = _context3.sent;
44017                                 windowId = _ref4.id;
44018
44019                                 __WEBPACK_IMPORTED_MODULE_6__utils_BrowserApis__["a" /* apis */].windows.remove(windowId);
44020                                 _context3.next = 10;
44021                                 break;
44022
44023                             case 8:
44024                                 window.onbeforeunload = function () {};
44025                                 window.close();
44026
44027                             case 10:
44028                             case 'end':
44029                                 return _context3.stop();
44030                         }
44031                     }
44032                 }, _callee3, this);
44033             }));
44034
44035             function close() {
44036                 return _ref3.apply(this, arguments);
44037             }
44038
44039             return close;
44040         }()
44041     }]);
44042
44043     return NotificationService;
44044 }();
44045
44046 /* harmony default export */ __webpack_exports__["a"] = (NotificationService);
44047
44048 /***/ }),
44049 /* 535 */
44050 /***/ (function(module, __webpack_exports__, __webpack_require__) {
44051
44052 "use strict";
44053 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return MALICIOUS; });
44054 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LOCKED; });
44055 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return PROMPT_CLOSED; });
44056 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return TYPE_MISSED; });
44057 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return TYPE_DUPLICATED; });
44058 var MALICIOUS = 'malicious';
44059 var LOCKED = 'locked';
44060 var PROMPT_CLOSED = 'prompt_closed';
44061 var TYPE_MISSED = 'type_missed';
44062 var TYPE_DUPLICATED = 'type_duplicated';
44063
44064 /***/ }),
44065 /* 536 */,
44066 /* 537 */,
44067 /* 538 */,
44068 /* 539 */,
44069 /* 540 */,
44070 /* 541 */,
44071 /* 542 */,
44072 /* 543 */,
44073 /* 544 */,
44074 /* 545 */,
44075 /* 546 */,
44076 /* 547 */,
44077 /* 548 */,
44078 /* 549 */,
44079 /* 550 */,
44080 /* 551 */,
44081 /* 552 */,
44082 /* 553 */,
44083 /* 554 */,
44084 /* 555 */,
44085 /* 556 */,
44086 /* 557 */,
44087 /* 558 */,
44088 /* 559 */,
44089 /* 560 */,
44090 /* 561 */,
44091 /* 562 */,
44092 /* 563 */,
44093 /* 564 */,
44094 /* 565 */,
44095 /* 566 */,
44096 /* 567 */,
44097 /* 568 */,
44098 /* 569 */,
44099 /* 570 */,
44100 /* 571 */
44101 /***/ (function(module, __webpack_exports__, __webpack_require__) {
44102
44103 "use strict";
44104 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
44105 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(532);
44106 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
44107 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_objectWithoutProperties__ = __webpack_require__(572);
44108 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_objectWithoutProperties___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_objectWithoutProperties__);
44109 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
44110 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck__);
44111 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__ = __webpack_require__(36);
44112 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass__);
44113 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_extension_streams__ = __webpack_require__(137);
44114 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_extension_streams___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_extension_streams__);
44115 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__messages_internal__ = __webpack_require__(267);
44116 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__messages_types__ = __webpack_require__(129);
44117 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__services_NotificationService__ = __webpack_require__(534);
44118 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__services_StorageService__ = __webpack_require__(573);
44119 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__prompts_Prompt__ = __webpack_require__(574);
44120 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__prompts_PromptTypes__ = __webpack_require__(575);
44121 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_lodash__ = __webpack_require__(434);
44122 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_11_lodash__);
44123 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__ = __webpack_require__(530);
44124 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_constants__ = __webpack_require__(268);
44125
44126
44127
44128
44129
44130
44131
44132
44133
44134
44135
44136
44137
44138
44139
44140
44141 var prompt = null;
44142
44143 var Background = function () {
44144   function Background() {
44145     __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default()(this, Background);
44146
44147     this.setupInternalMessaging();
44148   }
44149
44150   __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default()(Background, [{
44151     key: 'setupInternalMessaging',
44152     value: function setupInternalMessaging() {
44153       var _this = this;
44154
44155       __WEBPACK_IMPORTED_MODULE_4_extension_streams__["LocalStream"].watch(function (request, sendResponse) {
44156         console.log(request);
44157         var message = __WEBPACK_IMPORTED_MODULE_5__messages_internal__["a" /* default */].fromJson(request);
44158         _this.dispatchMessage(sendResponse, message);
44159       });
44160     }
44161   }, {
44162     key: 'dispatchMessage',
44163     value: function dispatchMessage(sendResponse, message) {
44164       switch (message.type) {
44165         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["k" /* SETCHAIN */]:
44166           Background.setChain(sendResponse, message.payload);
44167           break;
44168         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["o" /* TRANSFER */]:
44169           this.transfer(sendResponse, message.payload);
44170           break;
44171         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["a" /* ADVTRANSFER */]:
44172           this.advancedTransfer(sendResponse, message.payload);
44173           break;
44174         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["j" /* SEND */]:
44175           this.send(sendResponse, message.payload);
44176           break;
44177         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["n" /* SIGNTRANSACTION */]:
44178           this.signTransaction(sendResponse, message.payload);
44179           break;
44180         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["m" /* SIGNMESSAGE */]:
44181           this.signMessage(sendResponse, message.payload);
44182           break;
44183         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["g" /* REQUEST_CURRENT_ACCOUNT */]:
44184           this.requestCurrentAccount(sendResponse, message.payload);
44185           break;
44186         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["i" /* REQUEST_CURRENT_NETWORK */]:
44187           this.requestCurrentNetwork(sendResponse);
44188           break;
44189         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["h" /* REQUEST_CURRENT_CHAIN_TYPE */]:
44190           this.requestCurrentChain(sendResponse);
44191           break;
44192         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["b" /* ENABLE */]:
44193           Background.authenticate(sendResponse, message.payload);
44194           break;
44195         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["l" /* SET_PROMPT */]:
44196           Background.setPrompt(sendResponse, message.payload);
44197           break;
44198         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["d" /* GET_PROMPT */]:
44199           Background.getPrompt(sendResponse);
44200           break;
44201         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["e" /* LOAD */]:
44202           Background.load(sendResponse);
44203           break;
44204         case __WEBPACK_IMPORTED_MODULE_6__messages_types__["p" /* UPDATE */]:
44205           Background.update(sendResponse, message.payload);
44206           break;
44207       }
44208     }
44209   }, {
44210     key: 'signMessage',
44211     value: function signMessage(sendResponse, payload) {
44212       if (payload.address === undefined) {
44213         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('address'));
44214         return false;
44215       }
44216       if (payload.message === undefined) {
44217         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('message'));
44218         return false;
44219       }
44220
44221       __WEBPACK_IMPORTED_MODULE_7__services_NotificationService__["a" /* default */].open(new __WEBPACK_IMPORTED_MODULE_9__prompts_Prompt__["a" /* default */](__WEBPACK_IMPORTED_MODULE_10__prompts_PromptTypes__["c" /* REQUEST_SIGN */], '', payload, function (approved) {
44222         sendResponse(Object(__WEBPACK_IMPORTED_MODULE_13__utils_constants__["b" /* camelize */])(approved));
44223       }));
44224     }
44225   }, {
44226     key: 'transfer',
44227     value: function transfer(sendResponse, payload) {
44228       var promptURL = chrome.extension.getURL('pages/prompt.html');
44229       var requestBody = payload;
44230       requestBody.type = "popup";
44231       var queryString = new URLSearchParams(requestBody).toString();
44232       console.log(promptURL, queryString);
44233
44234       if (requestBody.from === undefined) {
44235         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('from'));
44236         return false;
44237       }
44238       if (requestBody.to === undefined) {
44239         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('to'));
44240         return false;
44241       }
44242       if (requestBody.asset === undefined) {
44243         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('asset'));
44244         return false;
44245       }
44246       if (requestBody.amount === undefined) {
44247         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('amount'));
44248         return false;
44249       }
44250
44251       // NotificationService.open(new Prompt(PromptTypes.REQUEST_TRANSFER, '', payload ,approved => {
44252       //   sendResponse(approved);
44253       // }));
44254
44255       chrome.windows.create({
44256         url: promptURL + '#transfer?' + queryString,
44257         type: 'popup',
44258         width: 360,
44259         height: 623,
44260         top: 0,
44261         left: 0
44262       }, function (window) {
44263         chrome.runtime.onMessage.addListener(function (request, sender) {
44264           if (sender.tab.windowId === window.id) {
44265             switch (request.method) {
44266               case 'transfer':
44267                 if (request.action === 'success') {
44268                   sendResponse(Object(__WEBPACK_IMPORTED_MODULE_13__utils_constants__["b" /* camelize */])(request.message));
44269                   return true;
44270                 } else if (request.action === 'reject') {
44271                   sendResponse(request.message);
44272                   return false;
44273                 }
44274             }
44275           }
44276         });
44277
44278         chrome.windows.onRemoved.addListener(function (windowId) {
44279           if (windowId === window.id) {
44280             sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].promptClosedWithoutAction());
44281             return false;
44282           }
44283         });
44284       });
44285     }
44286   }, {
44287     key: 'advancedTransfer',
44288     value: function advancedTransfer(sendResponse, payload) {
44289
44290       if (payload.input === undefined) {
44291         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('input'));
44292         return false;
44293       }
44294       if (payload.output === undefined) {
44295         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('output'));
44296         return false;
44297       }
44298       if (payload.gas === undefined) {
44299         sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].typeMissed('gas'));
44300         return false;
44301       }
44302
44303       __WEBPACK_IMPORTED_MODULE_7__services_NotificationService__["a" /* default */].open(new __WEBPACK_IMPORTED_MODULE_9__prompts_Prompt__["a" /* default */](__WEBPACK_IMPORTED_MODULE_10__prompts_PromptTypes__["a" /* REQUEST_ADVANCED_TRANSFER */], '', payload, function (approved) {
44304         sendResponse(Object(__WEBPACK_IMPORTED_MODULE_13__utils_constants__["b" /* camelize */])(approved));
44305       }));
44306     }
44307   }, {
44308     key: 'signTransaction',
44309     value: function signTransaction(sendResponse, payload) {
44310       __WEBPACK_IMPORTED_MODULE_7__services_NotificationService__["a" /* default */].open(new __WEBPACK_IMPORTED_MODULE_9__prompts_Prompt__["a" /* default */](__WEBPACK_IMPORTED_MODULE_10__prompts_PromptTypes__["d" /* REQUEST_SIGN_TRANSACTION */], '', payload, function (approved) {
44311         sendResponse(Object(__WEBPACK_IMPORTED_MODULE_13__utils_constants__["b" /* camelize */])(approved));
44312       }));
44313     }
44314   }, {
44315     key: 'requestCurrentAccount',
44316     value: function requestCurrentAccount(sendResponse, payload) {
44317       Background.load(function (bytom) {
44318         var domain = payload.domain;
44319         if (bytom.settings.domains.find(function (_domain) {
44320           return _domain === domain;
44321         })) {
44322           var currentAccount = bytom.currentAccount;
44323           var account = void 0;
44324           if (bytom.settings.netType === 'vapor') {
44325             account = {
44326               address: currentAccount.vpAddress
44327             };
44328           } else {
44329             account = {
44330               address: currentAccount.address
44331             };
44332           }
44333
44334           sendResponse(account);
44335         } else {
44336           sendResponse(null);
44337           return false;
44338         }
44339       });
44340     }
44341   }, {
44342     key: 'requestCurrentNetwork',
44343     value: function requestCurrentNetwork(sendResponse) {
44344       Background.load(function (bytom) {
44345         sendResponse(bytom.settings.network);
44346       });
44347     }
44348   }, {
44349     key: 'requestCurrentChain',
44350     value: function requestCurrentChain(sendResponse) {
44351       Background.load(function (bytom) {
44352         var chain = bytom.settings.netType === 'vapor' ? 'vapor' : 'bytom';
44353         sendResponse(chain);
44354       });
44355     }
44356   }, {
44357     key: 'send',
44358     value: function send(sendResponse, payload) {
44359       var action = payload.action;
44360       if (action) {
44361         var promise = void 0;
44362         switch (action) {
44363           case 'listAllAccount':
44364             promise = accountAction.list();
44365             break;
44366         }
44367         if (promise) {
44368           promise.then(function (resp) {
44369             sendResponse(resp);
44370           });
44371         }
44372       }
44373     }
44374
44375     /***
44376      * Returns the saved instance of Bytom from the storage
44377      * @param sendResponse - Delegating response handler
44378      * @returns {Bytom}
44379      */
44380
44381   }], [{
44382     key: 'setPrompt',
44383     value: function setPrompt(sendResponse, notification) {
44384       prompt = notification;
44385       sendResponse(true);
44386     }
44387   }, {
44388     key: 'getPrompt',
44389     value: function getPrompt(sendResponse) {
44390       sendResponse(prompt);
44391     }
44392   }, {
44393     key: 'load',
44394     value: function load(sendResponse) {
44395       __WEBPACK_IMPORTED_MODULE_8__services_StorageService__["a" /* default */].get().then(function (bytom) {
44396         sendResponse(bytom);
44397       });
44398     }
44399
44400     /***
44401      * Updates the Scatter instance inside persistent storage
44402      * @param sendResponse - Delegating response handler
44403      * @param bytom - The updated cleartext Scatter instance
44404      * @returns {boolean}
44405      */
44406
44407   }, {
44408     key: 'update',
44409     value: function update(sendResponse, bytom) {
44410       __WEBPACK_IMPORTED_MODULE_8__services_StorageService__["a" /* default */].save(bytom).then(function (saved) {
44411         sendResponse(bytom);
44412       });
44413     }
44414   }, {
44415     key: 'setChain',
44416     value: function setChain(sendResponse, newNetType) {
44417       var _this2 = this;
44418
44419       Background.load(function (bytom) {
44420         var currentNet = bytom.settings.netType;
44421
44422         if (newNetType !== currentNet) {
44423           bytom.settings.netType = newNetType;
44424           _this2.update(function () {
44425             return sendResponse({ status: 'success' });
44426           }, bytom);
44427         } else {
44428           sendResponse(__WEBPACK_IMPORTED_MODULE_12__utils_errors_Error__["a" /* default */].duplicate(newNetType));
44429         }
44430       });
44431     }
44432   }, {
44433     key: 'authenticate',
44434     value: function authenticate(sendResponse, payload) {
44435       var _this3 = this;
44436
44437       Background.load(function (bytom) {
44438         var domain = payload.domain;
44439         var currentAccount = bytom.currentAccount;
44440
44441         var account = void 0;
44442         if (bytom.settings.netType === 'vapor') {
44443           var vote = 0;
44444           var votes = currentAccount.votes;
44445           if (votes && votes.length > 0) {
44446             vote = __WEBPACK_IMPORTED_MODULE_11_lodash___default.a.sumBy(votes, 'total');
44447           }
44448
44449           var balances = currentAccount.vpBalances || [];
44450           balances = balances.map(function (_ref) {
44451             var inBtc = _ref.inBtc,
44452                 inCny = _ref.inCny,
44453                 inUsd = _ref.inUsd,
44454                 name = _ref.name,
44455                 keepAttrs = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_objectWithoutProperties___default()(_ref, ['inBtc', 'inCny', 'inUsd', 'name']);
44456
44457             if (keepAttrs.asset === __WEBPACK_IMPORTED_MODULE_13__utils_constants__["a" /* BTM */]) return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({ availableBalance: keepAttrs.balance - vote }, keepAttrs);else return keepAttrs;
44458           });
44459
44460           account = {
44461             address: currentAccount.vpAddress,
44462             alias: currentAccount.alias,
44463             balances: balances || [],
44464             accountId: currentAccount.guid,
44465             rootXPub: currentAccount.rootXPub
44466           };
44467         } else {
44468           var _balances = currentAccount.balances || [];
44469           _balances = _balances.map(function (_ref2) {
44470             var inBtc = _ref2.inBtc,
44471                 inCny = _ref2.inCny,
44472                 inUsd = _ref2.inUsd,
44473                 name = _ref2.name,
44474                 keepAttrs = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_objectWithoutProperties___default()(_ref2, ['inBtc', 'inCny', 'inUsd', 'name']);
44475
44476             return keepAttrs;
44477           });
44478
44479           account = {
44480             address: currentAccount.address,
44481             alias: currentAccount.alias,
44482             balances: _balances || [],
44483             accountId: currentAccount.guid,
44484             rootXPub: currentAccount.rootXPub
44485           };
44486         }
44487
44488         if (bytom.settings.domains.find(function (_domain) {
44489           return _domain === domain;
44490         })) {
44491           sendResponse(account);
44492         } else {
44493           __WEBPACK_IMPORTED_MODULE_7__services_NotificationService__["a" /* default */].open(new __WEBPACK_IMPORTED_MODULE_9__prompts_Prompt__["a" /* default */](__WEBPACK_IMPORTED_MODULE_10__prompts_PromptTypes__["b" /* REQUEST_AUTH */], payload.domain, {}, function (approved) {
44494             if (approved === false || approved.hasOwnProperty('isError')) sendResponse(approved);else {
44495               bytom.settings.domains.unshift(domain);
44496               if (approved === true) {
44497                 _this3.update(function () {
44498                   return sendResponse(account);
44499                 }, bytom);
44500               } else {
44501                 _this3.update(function () {
44502                   return sendResponse(approved);
44503                 }, bytom);
44504               }
44505             }
44506           }));
44507         }
44508       });
44509     }
44510   }]);
44511
44512   return Background;
44513 }();
44514
44515 /* harmony default export */ __webpack_exports__["default"] = (Background);
44516
44517
44518 new Background();
44519
44520 /***/ }),
44521 /* 572 */
44522 /***/ (function(module, exports, __webpack_require__) {
44523
44524 "use strict";
44525
44526
44527 exports.__esModule = true;
44528
44529 exports.default = function (obj, keys) {
44530   var target = {};
44531
44532   for (var i in obj) {
44533     if (keys.indexOf(i) >= 0) continue;
44534     if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
44535     target[i] = obj[i];
44536   }
44537
44538   return target;
44539 };
44540
44541 /***/ }),
44542 /* 573 */
44543 /***/ (function(module, __webpack_exports__, __webpack_require__) {
44544
44545 "use strict";
44546 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__ = __webpack_require__(144);
44547 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify__);
44548 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty__ = __webpack_require__(265);
44549 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty__);
44550 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_core_js_object_keys__ = __webpack_require__(420);
44551 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_core_js_object_keys___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_core_js_object_keys__);
44552 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise__ = __webpack_require__(76);
44553 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise__);
44554 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
44555 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_classCallCheck__);
44556 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_createClass__ = __webpack_require__(36);
44557 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_createClass__);
44558 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_Bytom__ = __webpack_require__(428);
44559 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__ = __webpack_require__(529);
44560
44561
44562
44563
44564
44565
44566
44567
44568
44569 var StorageService = function () {
44570     function StorageService() {
44571         __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_classCallCheck___default()(this, StorageService);
44572     }
44573
44574     /***
44575      * Saves an instance of Bytom in the extension's local storage
44576      * The keychain will always be encrypted when in storage
44577      * @param bytom
44578      * @returns {Promise}
44579      */
44580
44581
44582     __WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_createClass___default()(StorageService, null, [{
44583         key: 'save',
44584         value: function save(_bytom) {
44585             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44586                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.set({ bytom: _bytom }, function () {
44587                     resolve(_bytom);
44588                 });
44589             });
44590         }
44591     }, {
44592         key: 'get',
44593
44594
44595         /***
44596          * Gets an instance of Bytom from the extension's local storage
44597          * Will return a new Bytom instance if not found.
44598          * @returns {Promise}
44599          */
44600         value: function get() {
44601             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44602                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.get('bytom', function (possible) {
44603                     possible && __WEBPACK_IMPORTED_MODULE_2_babel_runtime_core_js_object_keys___default()(possible).length && possible.hasOwnProperty('bytom') ? resolve(__WEBPACK_IMPORTED_MODULE_6__utils_Bytom__["a" /* default */].fromJson(possible.bytom)) : resolve(__WEBPACK_IMPORTED_MODULE_6__utils_Bytom__["a" /* default */].placeholder());
44604                 });
44605             });
44606         }
44607
44608         /***
44609          * Removes the instance of Bytom.
44610          * This will delete all user data.
44611          * @returns {Promise}
44612          */
44613
44614     }, {
44615         key: 'remove',
44616         value: function remove() {
44617             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44618                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.remove('bytom', function () {
44619                     resolve();
44620                 });
44621             });
44622         }
44623
44624         /***
44625          * Caches an ABI
44626          * @param contractName
44627          * @param chainId
44628          * @param abi
44629          * @returns {Promise}
44630          */
44631
44632     }, {
44633         key: 'cacheABI',
44634         value: function cacheABI(contractName, chainId, abi) {
44635             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44636                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.set(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_defineProperty___default()({}, 'abi:' + contractName + ':' + chainId, abi), function () {
44637                     resolve(abi);
44638                 });
44639             });
44640         }
44641
44642         /***
44643          * Fetches an ABI from cache
44644          * @param contractName
44645          * @param chainId
44646          * @returns {Promise}
44647          */
44648
44649     }, {
44650         key: 'getABI',
44651         value: function getABI(contractName, chainId) {
44652             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44653                 var prop = 'abi:' + contractName + ':' + chainId;
44654                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.get(prop, function (possible) {
44655                     if (__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(possible) !== '{}') resolve(possible[prop]);else resolve('no cache');
44656                 });
44657             });
44658         }
44659     }, {
44660         key: 'getSalt',
44661         value: function getSalt() {
44662             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44663                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.get('salt', function (possible) {
44664                     if (__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_json_stringify___default()(possible) !== '{}') resolve(possible.salt);else resolve('SALT_ME');
44665                 });
44666             });
44667         }
44668     }, {
44669         key: 'setSalt',
44670         value: function setSalt(salt) {
44671             return new __WEBPACK_IMPORTED_MODULE_3_babel_runtime_core_js_promise___default.a(function (resolve) {
44672                 __WEBPACK_IMPORTED_MODULE_7__utils_BrowserApis__["a" /* apis */].storage.local.set({ salt: salt }, function () {
44673                     resolve(salt);
44674                 });
44675             });
44676         }
44677     }]);
44678
44679     return StorageService;
44680 }();
44681
44682 /* harmony default export */ __webpack_exports__["a"] = (StorageService);
44683
44684 /***/ }),
44685 /* 574 */
44686 /***/ (function(module, __webpack_exports__, __webpack_require__) {
44687
44688 "use strict";
44689 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign__ = __webpack_require__(69);
44690 /* 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__);
44691 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(26);
44692 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
44693 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__ = __webpack_require__(36);
44694 /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__);
44695
44696
44697
44698
44699 var Prompt = function () {
44700     function Prompt() {
44701         var _type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
44702
44703         var _domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
44704
44705         var _data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
44706
44707         var _responder = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
44708
44709         __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, Prompt);
44710
44711         this.type = _type;
44712         this.domain = _domain;
44713         this.data = _data;
44714         this.responder = _responder;
44715     }
44716
44717     __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(Prompt, [{
44718         key: 'routeName',
44719         value: function routeName() {
44720             return '' + this.type;
44721         }
44722     }], [{
44723         key: 'placeholder',
44724         value: function placeholder() {
44725             return new Prompt();
44726         }
44727     }, {
44728         key: 'fromJson',
44729         value: function fromJson(json) {
44730             return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_assign___default()(this.placeholder(), json);
44731         }
44732     }]);
44733
44734     return Prompt;
44735 }();
44736
44737 /* harmony default export */ __webpack_exports__["a"] = (Prompt);
44738
44739 /***/ }),
44740 /* 575 */
44741 /***/ (function(module, __webpack_exports__, __webpack_require__) {
44742
44743 "use strict";
44744 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return REQUEST_AUTH; });
44745 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return REQUEST_SIGN; });
44746 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return REQUEST_SIGN_TRANSACTION; });
44747 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return REQUEST_ADVANCED_TRANSFER; });
44748 /* unused harmony export REQUEST_TRANSFER */
44749 /* unused harmony export REQUEST_ADD_NETWORK */
44750 /* unused harmony export REQUEST_UNLOCK */
44751 /* unused harmony export UPDATE_VERSION */
44752 var REQUEST_AUTH = 'enable';
44753 var REQUEST_SIGN = 'signMessage';
44754 var REQUEST_SIGN_TRANSACTION = 'signTransaction';
44755 var REQUEST_ADVANCED_TRANSFER = 'advancedTransfer';
44756 var REQUEST_TRANSFER = 'transfer';
44757 var REQUEST_ADD_NETWORK = 'requestAddNetwork';
44758 var REQUEST_UNLOCK = 'requestUnlock';
44759 var UPDATE_VERSION = 'updateVersion';
44760
44761 /***/ })
44762 /******/ ]);
44763 //# sourceMappingURL=background.js.map