@gitlab/frontend-tests 0.0.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +112 -1
  2. package/dist/index.cjs +38 -0
  3. package/dist/index.d.cts +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +5 -0
  6. package/dist/integration/constants.d.cts +3 -0
  7. package/dist/integration/constants.d.ts +3 -0
  8. package/dist/integration/fixture_utils.d.cts +107 -0
  9. package/dist/integration/fixture_utils.d.ts +107 -0
  10. package/dist/integration/fixture_variant_schema.d.cts +74 -0
  11. package/dist/integration/fixture_variant_schema.d.ts +74 -0
  12. package/dist/integration/handlers.d.cts +10 -0
  13. package/dist/integration/handlers.d.ts +10 -0
  14. package/dist/integration/index.d.cts +7 -0
  15. package/dist/integration/index.d.ts +7 -0
  16. package/dist/integration/jest_config.cjs +31 -0
  17. package/dist/integration/jest_config.d.cts +11 -0
  18. package/dist/integration/jest_config.d.ts +11 -0
  19. package/dist/integration/jest_config.js +27 -0
  20. package/dist/integration/operation_helpers.d.cts +70 -0
  21. package/dist/integration/operation_helpers.d.ts +70 -0
  22. package/dist/integration/polyfills.cjs +21 -0
  23. package/dist/integration/polyfills.d.cts +1 -0
  24. package/dist/integration/polyfills.d.ts +1 -0
  25. package/dist/integration/polyfills.js +19 -0
  26. package/dist/integration/polyfills_text_encoding.cjs +8 -0
  27. package/dist/integration/polyfills_text_encoding.d.cts +1 -0
  28. package/dist/integration/polyfills_text_encoding.d.ts +1 -0
  29. package/dist/integration/polyfills_text_encoding.js +6 -0
  30. package/dist/integration/server.d.cts +3 -0
  31. package/dist/integration/server.d.ts +3 -0
  32. package/dist/integration/types.d.cts +82 -0
  33. package/dist/integration/types.d.ts +82 -0
  34. package/dist/integration.cjs +38 -0
  35. package/dist/integration.js +5 -0
  36. package/dist/server-C2Drh977.js +3970 -0
  37. package/dist/server-hzT7AwDi.cjs +3999 -0
  38. package/integration/jest-config.js +2 -0
  39. package/integration/polyfills/text-encoding.js +2 -0
  40. package/integration/polyfills.js +2 -0
  41. package/integration.js +2 -0
  42. package/package.json +138 -5
@@ -0,0 +1,3970 @@
1
+ import { setupServer } from 'msw/node';
2
+ import { http, HttpResponse, graphql } from 'msw';
3
+ import { readdirSync, readFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+
6
+ const baseMetadata = { router: null };
7
+
8
+ /** Detect free variable `global` from Node.js. */
9
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
10
+
11
+ /** Detect free variable `self`. */
12
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
13
+
14
+ /** Used as a reference to the global object. */
15
+ var root = freeGlobal || freeSelf || Function('return this')();
16
+
17
+ /** Built-in value references. */
18
+ var Symbol = root.Symbol;
19
+
20
+ /** Used for built-in method references. */
21
+ var objectProto$b = Object.prototype;
22
+
23
+ /** Used to check objects for own properties. */
24
+ var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
25
+
26
+ /**
27
+ * Used to resolve the
28
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
29
+ * of values.
30
+ */
31
+ var nativeObjectToString$1 = objectProto$b.toString;
32
+
33
+ /** Built-in value references. */
34
+ var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
35
+
36
+ /**
37
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
38
+ *
39
+ * @private
40
+ * @param {*} value The value to query.
41
+ * @returns {string} Returns the raw `toStringTag`.
42
+ */
43
+ function getRawTag(value) {
44
+ var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
45
+ tag = value[symToStringTag$1];
46
+
47
+ try {
48
+ value[symToStringTag$1] = undefined;
49
+ var unmasked = true;
50
+ } catch (e) {}
51
+
52
+ var result = nativeObjectToString$1.call(value);
53
+ if (unmasked) {
54
+ if (isOwn) {
55
+ value[symToStringTag$1] = tag;
56
+ } else {
57
+ delete value[symToStringTag$1];
58
+ }
59
+ }
60
+ return result;
61
+ }
62
+
63
+ /** Used for built-in method references. */
64
+ var objectProto$a = Object.prototype;
65
+
66
+ /**
67
+ * Used to resolve the
68
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
69
+ * of values.
70
+ */
71
+ var nativeObjectToString = objectProto$a.toString;
72
+
73
+ /**
74
+ * Converts `value` to a string using `Object.prototype.toString`.
75
+ *
76
+ * @private
77
+ * @param {*} value The value to convert.
78
+ * @returns {string} Returns the converted string.
79
+ */
80
+ function objectToString(value) {
81
+ return nativeObjectToString.call(value);
82
+ }
83
+
84
+ /** `Object#toString` result references. */
85
+ var nullTag = '[object Null]',
86
+ undefinedTag = '[object Undefined]';
87
+
88
+ /** Built-in value references. */
89
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
90
+
91
+ /**
92
+ * The base implementation of `getTag` without fallbacks for buggy environments.
93
+ *
94
+ * @private
95
+ * @param {*} value The value to query.
96
+ * @returns {string} Returns the `toStringTag`.
97
+ */
98
+ function baseGetTag(value) {
99
+ if (value == null) {
100
+ return value === undefined ? undefinedTag : nullTag;
101
+ }
102
+ return (symToStringTag && symToStringTag in Object(value))
103
+ ? getRawTag(value)
104
+ : objectToString(value);
105
+ }
106
+
107
+ /**
108
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
109
+ * and has a `typeof` result of "object".
110
+ *
111
+ * @static
112
+ * @memberOf _
113
+ * @since 4.0.0
114
+ * @category Lang
115
+ * @param {*} value The value to check.
116
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
117
+ * @example
118
+ *
119
+ * _.isObjectLike({});
120
+ * // => true
121
+ *
122
+ * _.isObjectLike([1, 2, 3]);
123
+ * // => true
124
+ *
125
+ * _.isObjectLike(_.noop);
126
+ * // => false
127
+ *
128
+ * _.isObjectLike(null);
129
+ * // => false
130
+ */
131
+ function isObjectLike(value) {
132
+ return value != null && typeof value == 'object';
133
+ }
134
+
135
+ /** `Object#toString` result references. */
136
+ var symbolTag$2 = '[object Symbol]';
137
+
138
+ /**
139
+ * Checks if `value` is classified as a `Symbol` primitive or object.
140
+ *
141
+ * @static
142
+ * @memberOf _
143
+ * @since 4.0.0
144
+ * @category Lang
145
+ * @param {*} value The value to check.
146
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
147
+ * @example
148
+ *
149
+ * _.isSymbol(Symbol.iterator);
150
+ * // => true
151
+ *
152
+ * _.isSymbol('abc');
153
+ * // => false
154
+ */
155
+ function isSymbol(value) {
156
+ return typeof value == 'symbol' ||
157
+ (isObjectLike(value) && baseGetTag(value) == symbolTag$2);
158
+ }
159
+
160
+ /**
161
+ * A specialized version of `_.map` for arrays without support for iteratee
162
+ * shorthands.
163
+ *
164
+ * @private
165
+ * @param {Array} [array] The array to iterate over.
166
+ * @param {Function} iteratee The function invoked per iteration.
167
+ * @returns {Array} Returns the new mapped array.
168
+ */
169
+ function arrayMap(array, iteratee) {
170
+ var index = -1,
171
+ length = array == null ? 0 : array.length,
172
+ result = Array(length);
173
+
174
+ while (++index < length) {
175
+ result[index] = iteratee(array[index], index, array);
176
+ }
177
+ return result;
178
+ }
179
+
180
+ /**
181
+ * Checks if `value` is classified as an `Array` object.
182
+ *
183
+ * @static
184
+ * @memberOf _
185
+ * @since 0.1.0
186
+ * @category Lang
187
+ * @param {*} value The value to check.
188
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
189
+ * @example
190
+ *
191
+ * _.isArray([1, 2, 3]);
192
+ * // => true
193
+ *
194
+ * _.isArray(document.body.children);
195
+ * // => false
196
+ *
197
+ * _.isArray('abc');
198
+ * // => false
199
+ *
200
+ * _.isArray(_.noop);
201
+ * // => false
202
+ */
203
+ var isArray = Array.isArray;
204
+
205
+ /** Used to convert symbols to primitives and strings. */
206
+ var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
207
+ symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
208
+
209
+ /**
210
+ * The base implementation of `_.toString` which doesn't convert nullish
211
+ * values to empty strings.
212
+ *
213
+ * @private
214
+ * @param {*} value The value to process.
215
+ * @returns {string} Returns the string.
216
+ */
217
+ function baseToString(value) {
218
+ // Exit early for strings to avoid a performance hit in some environments.
219
+ if (typeof value == 'string') {
220
+ return value;
221
+ }
222
+ if (isArray(value)) {
223
+ // Recursively convert values (susceptible to call stack limits).
224
+ return arrayMap(value, baseToString) + '';
225
+ }
226
+ if (isSymbol(value)) {
227
+ return symbolToString ? symbolToString.call(value) : '';
228
+ }
229
+ var result = (value + '');
230
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
231
+ }
232
+
233
+ /**
234
+ * Checks if `value` is the
235
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
236
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
237
+ *
238
+ * @static
239
+ * @memberOf _
240
+ * @since 0.1.0
241
+ * @category Lang
242
+ * @param {*} value The value to check.
243
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
244
+ * @example
245
+ *
246
+ * _.isObject({});
247
+ * // => true
248
+ *
249
+ * _.isObject([1, 2, 3]);
250
+ * // => true
251
+ *
252
+ * _.isObject(_.noop);
253
+ * // => true
254
+ *
255
+ * _.isObject(null);
256
+ * // => false
257
+ */
258
+ function isObject(value) {
259
+ var type = typeof value;
260
+ return value != null && (type == 'object' || type == 'function');
261
+ }
262
+
263
+ /**
264
+ * This method returns the first argument it receives.
265
+ *
266
+ * @static
267
+ * @since 0.1.0
268
+ * @memberOf _
269
+ * @category Util
270
+ * @param {*} value Any value.
271
+ * @returns {*} Returns `value`.
272
+ * @example
273
+ *
274
+ * var object = { 'a': 1 };
275
+ *
276
+ * console.log(_.identity(object) === object);
277
+ * // => true
278
+ */
279
+ function identity(value) {
280
+ return value;
281
+ }
282
+
283
+ /** `Object#toString` result references. */
284
+ var asyncTag = '[object AsyncFunction]',
285
+ funcTag$2 = '[object Function]',
286
+ genTag$1 = '[object GeneratorFunction]',
287
+ proxyTag = '[object Proxy]';
288
+
289
+ /**
290
+ * Checks if `value` is classified as a `Function` object.
291
+ *
292
+ * @static
293
+ * @memberOf _
294
+ * @since 0.1.0
295
+ * @category Lang
296
+ * @param {*} value The value to check.
297
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
298
+ * @example
299
+ *
300
+ * _.isFunction(_);
301
+ * // => true
302
+ *
303
+ * _.isFunction(/abc/);
304
+ * // => false
305
+ */
306
+ function isFunction(value) {
307
+ if (!isObject(value)) {
308
+ return false;
309
+ }
310
+ // The use of `Object#toString` avoids issues with the `typeof` operator
311
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
312
+ var tag = baseGetTag(value);
313
+ return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
314
+ }
315
+
316
+ /** Used to detect overreaching core-js shims. */
317
+ var coreJsData = root['__core-js_shared__'];
318
+
319
+ /** Used to detect methods masquerading as native. */
320
+ var maskSrcKey = (function() {
321
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
322
+ return uid ? ('Symbol(src)_1.' + uid) : '';
323
+ }());
324
+
325
+ /**
326
+ * Checks if `func` has its source masked.
327
+ *
328
+ * @private
329
+ * @param {Function} func The function to check.
330
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
331
+ */
332
+ function isMasked(func) {
333
+ return !!maskSrcKey && (maskSrcKey in func);
334
+ }
335
+
336
+ /** Used for built-in method references. */
337
+ var funcProto$1 = Function.prototype;
338
+
339
+ /** Used to resolve the decompiled source of functions. */
340
+ var funcToString$1 = funcProto$1.toString;
341
+
342
+ /**
343
+ * Converts `func` to its source code.
344
+ *
345
+ * @private
346
+ * @param {Function} func The function to convert.
347
+ * @returns {string} Returns the source code.
348
+ */
349
+ function toSource(func) {
350
+ if (func != null) {
351
+ try {
352
+ return funcToString$1.call(func);
353
+ } catch (e) {}
354
+ try {
355
+ return (func + '');
356
+ } catch (e) {}
357
+ }
358
+ return '';
359
+ }
360
+
361
+ /**
362
+ * Used to match `RegExp`
363
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
364
+ */
365
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
366
+
367
+ /** Used to detect host constructors (Safari). */
368
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
369
+
370
+ /** Used for built-in method references. */
371
+ var funcProto = Function.prototype,
372
+ objectProto$9 = Object.prototype;
373
+
374
+ /** Used to resolve the decompiled source of functions. */
375
+ var funcToString = funcProto.toString;
376
+
377
+ /** Used to check objects for own properties. */
378
+ var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
379
+
380
+ /** Used to detect if a method is native. */
381
+ var reIsNative = RegExp('^' +
382
+ funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
383
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
384
+ );
385
+
386
+ /**
387
+ * The base implementation of `_.isNative` without bad shim checks.
388
+ *
389
+ * @private
390
+ * @param {*} value The value to check.
391
+ * @returns {boolean} Returns `true` if `value` is a native function,
392
+ * else `false`.
393
+ */
394
+ function baseIsNative(value) {
395
+ if (!isObject(value) || isMasked(value)) {
396
+ return false;
397
+ }
398
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
399
+ return pattern.test(toSource(value));
400
+ }
401
+
402
+ /**
403
+ * Gets the value at `key` of `object`.
404
+ *
405
+ * @private
406
+ * @param {Object} [object] The object to query.
407
+ * @param {string} key The key of the property to get.
408
+ * @returns {*} Returns the property value.
409
+ */
410
+ function getValue(object, key) {
411
+ return object == null ? undefined : object[key];
412
+ }
413
+
414
+ /**
415
+ * Gets the native function at `key` of `object`.
416
+ *
417
+ * @private
418
+ * @param {Object} object The object to query.
419
+ * @param {string} key The key of the method to get.
420
+ * @returns {*} Returns the function if it's native, else `undefined`.
421
+ */
422
+ function getNative(object, key) {
423
+ var value = getValue(object, key);
424
+ return baseIsNative(value) ? value : undefined;
425
+ }
426
+
427
+ /* Built-in method references that are verified to be native. */
428
+ var WeakMap = getNative(root, 'WeakMap');
429
+
430
+ /** Built-in value references. */
431
+ var objectCreate = Object.create;
432
+
433
+ /**
434
+ * The base implementation of `_.create` without support for assigning
435
+ * properties to the created object.
436
+ *
437
+ * @private
438
+ * @param {Object} proto The object to inherit from.
439
+ * @returns {Object} Returns the new object.
440
+ */
441
+ var baseCreate = (function() {
442
+ function object() {}
443
+ return function(proto) {
444
+ if (!isObject(proto)) {
445
+ return {};
446
+ }
447
+ if (objectCreate) {
448
+ return objectCreate(proto);
449
+ }
450
+ object.prototype = proto;
451
+ var result = new object;
452
+ object.prototype = undefined;
453
+ return result;
454
+ };
455
+ }());
456
+
457
+ /**
458
+ * A faster alternative to `Function#apply`, this function invokes `func`
459
+ * with the `this` binding of `thisArg` and the arguments of `args`.
460
+ *
461
+ * @private
462
+ * @param {Function} func The function to invoke.
463
+ * @param {*} thisArg The `this` binding of `func`.
464
+ * @param {Array} args The arguments to invoke `func` with.
465
+ * @returns {*} Returns the result of `func`.
466
+ */
467
+ function apply(func, thisArg, args) {
468
+ switch (args.length) {
469
+ case 0: return func.call(thisArg);
470
+ case 1: return func.call(thisArg, args[0]);
471
+ case 2: return func.call(thisArg, args[0], args[1]);
472
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
473
+ }
474
+ return func.apply(thisArg, args);
475
+ }
476
+
477
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
478
+ var HOT_COUNT = 800,
479
+ HOT_SPAN = 16;
480
+
481
+ /* Built-in method references for those with the same name as other `lodash` methods. */
482
+ var nativeNow = Date.now;
483
+
484
+ /**
485
+ * Creates a function that'll short out and invoke `identity` instead
486
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
487
+ * milliseconds.
488
+ *
489
+ * @private
490
+ * @param {Function} func The function to restrict.
491
+ * @returns {Function} Returns the new shortable function.
492
+ */
493
+ function shortOut(func) {
494
+ var count = 0,
495
+ lastCalled = 0;
496
+
497
+ return function() {
498
+ var stamp = nativeNow(),
499
+ remaining = HOT_SPAN - (stamp - lastCalled);
500
+
501
+ lastCalled = stamp;
502
+ if (remaining > 0) {
503
+ if (++count >= HOT_COUNT) {
504
+ return arguments[0];
505
+ }
506
+ } else {
507
+ count = 0;
508
+ }
509
+ return func.apply(undefined, arguments);
510
+ };
511
+ }
512
+
513
+ /**
514
+ * Creates a function that returns `value`.
515
+ *
516
+ * @static
517
+ * @memberOf _
518
+ * @since 2.4.0
519
+ * @category Util
520
+ * @param {*} value The value to return from the new function.
521
+ * @returns {Function} Returns the new constant function.
522
+ * @example
523
+ *
524
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
525
+ *
526
+ * console.log(objects);
527
+ * // => [{ 'a': 1 }, { 'a': 1 }]
528
+ *
529
+ * console.log(objects[0] === objects[1]);
530
+ * // => true
531
+ */
532
+ function constant(value) {
533
+ return function() {
534
+ return value;
535
+ };
536
+ }
537
+
538
+ var defineProperty = (function() {
539
+ try {
540
+ var func = getNative(Object, 'defineProperty');
541
+ func({}, '', {});
542
+ return func;
543
+ } catch (e) {}
544
+ }());
545
+
546
+ /**
547
+ * The base implementation of `setToString` without support for hot loop shorting.
548
+ *
549
+ * @private
550
+ * @param {Function} func The function to modify.
551
+ * @param {Function} string The `toString` result.
552
+ * @returns {Function} Returns `func`.
553
+ */
554
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
555
+ return defineProperty(func, 'toString', {
556
+ 'configurable': true,
557
+ 'enumerable': false,
558
+ 'value': constant(string),
559
+ 'writable': true
560
+ });
561
+ };
562
+
563
+ /**
564
+ * Sets the `toString` method of `func` to return `string`.
565
+ *
566
+ * @private
567
+ * @param {Function} func The function to modify.
568
+ * @param {Function} string The `toString` result.
569
+ * @returns {Function} Returns `func`.
570
+ */
571
+ var setToString = shortOut(baseSetToString);
572
+
573
+ /**
574
+ * A specialized version of `_.forEach` for arrays without support for
575
+ * iteratee shorthands.
576
+ *
577
+ * @private
578
+ * @param {Array} [array] The array to iterate over.
579
+ * @param {Function} iteratee The function invoked per iteration.
580
+ * @returns {Array} Returns `array`.
581
+ */
582
+ function arrayEach(array, iteratee) {
583
+ var index = -1,
584
+ length = array == null ? 0 : array.length;
585
+
586
+ while (++index < length) {
587
+ if (iteratee(array[index], index, array) === false) {
588
+ break;
589
+ }
590
+ }
591
+ return array;
592
+ }
593
+
594
+ /** Used as references for various `Number` constants. */
595
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
596
+
597
+ /** Used to detect unsigned integer values. */
598
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
599
+
600
+ /**
601
+ * Checks if `value` is a valid array-like index.
602
+ *
603
+ * @private
604
+ * @param {*} value The value to check.
605
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
606
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
607
+ */
608
+ function isIndex(value, length) {
609
+ var type = typeof value;
610
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
611
+
612
+ return !!length &&
613
+ (type == 'number' ||
614
+ (type != 'symbol' && reIsUint.test(value))) &&
615
+ (value > -1 && value % 1 == 0 && value < length);
616
+ }
617
+
618
+ /**
619
+ * The base implementation of `assignValue` and `assignMergeValue` without
620
+ * value checks.
621
+ *
622
+ * @private
623
+ * @param {Object} object The object to modify.
624
+ * @param {string} key The key of the property to assign.
625
+ * @param {*} value The value to assign.
626
+ */
627
+ function baseAssignValue(object, key, value) {
628
+ if (key == '__proto__' && defineProperty) {
629
+ defineProperty(object, key, {
630
+ 'configurable': true,
631
+ 'enumerable': true,
632
+ 'value': value,
633
+ 'writable': true
634
+ });
635
+ } else {
636
+ object[key] = value;
637
+ }
638
+ }
639
+
640
+ /**
641
+ * Performs a
642
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
643
+ * comparison between two values to determine if they are equivalent.
644
+ *
645
+ * @static
646
+ * @memberOf _
647
+ * @since 4.0.0
648
+ * @category Lang
649
+ * @param {*} value The value to compare.
650
+ * @param {*} other The other value to compare.
651
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
652
+ * @example
653
+ *
654
+ * var object = { 'a': 1 };
655
+ * var other = { 'a': 1 };
656
+ *
657
+ * _.eq(object, object);
658
+ * // => true
659
+ *
660
+ * _.eq(object, other);
661
+ * // => false
662
+ *
663
+ * _.eq('a', 'a');
664
+ * // => true
665
+ *
666
+ * _.eq('a', Object('a'));
667
+ * // => false
668
+ *
669
+ * _.eq(NaN, NaN);
670
+ * // => true
671
+ */
672
+ function eq(value, other) {
673
+ return value === other || (value !== value && other !== other);
674
+ }
675
+
676
+ /** Used for built-in method references. */
677
+ var objectProto$8 = Object.prototype;
678
+
679
+ /** Used to check objects for own properties. */
680
+ var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
681
+
682
+ /**
683
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
684
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
685
+ * for equality comparisons.
686
+ *
687
+ * @private
688
+ * @param {Object} object The object to modify.
689
+ * @param {string} key The key of the property to assign.
690
+ * @param {*} value The value to assign.
691
+ */
692
+ function assignValue(object, key, value) {
693
+ var objValue = object[key];
694
+ if (!(hasOwnProperty$6.call(object, key) && eq(objValue, value)) ||
695
+ (value === undefined && !(key in object))) {
696
+ baseAssignValue(object, key, value);
697
+ }
698
+ }
699
+
700
+ /* Built-in method references for those with the same name as other `lodash` methods. */
701
+ var nativeMax = Math.max;
702
+
703
+ /**
704
+ * A specialized version of `baseRest` which transforms the rest array.
705
+ *
706
+ * @private
707
+ * @param {Function} func The function to apply a rest parameter to.
708
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
709
+ * @param {Function} transform The rest array transform.
710
+ * @returns {Function} Returns the new function.
711
+ */
712
+ function overRest(func, start, transform) {
713
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
714
+ return function() {
715
+ var args = arguments,
716
+ index = -1,
717
+ length = nativeMax(args.length - start, 0),
718
+ array = Array(length);
719
+
720
+ while (++index < length) {
721
+ array[index] = args[start + index];
722
+ }
723
+ index = -1;
724
+ var otherArgs = Array(start + 1);
725
+ while (++index < start) {
726
+ otherArgs[index] = args[index];
727
+ }
728
+ otherArgs[start] = transform(array);
729
+ return apply(func, this, otherArgs);
730
+ };
731
+ }
732
+
733
+ /** Used as references for various `Number` constants. */
734
+ var MAX_SAFE_INTEGER = 9007199254740991;
735
+
736
+ /**
737
+ * Checks if `value` is a valid array-like length.
738
+ *
739
+ * **Note:** This method is loosely based on
740
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
741
+ *
742
+ * @static
743
+ * @memberOf _
744
+ * @since 4.0.0
745
+ * @category Lang
746
+ * @param {*} value The value to check.
747
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
748
+ * @example
749
+ *
750
+ * _.isLength(3);
751
+ * // => true
752
+ *
753
+ * _.isLength(Number.MIN_VALUE);
754
+ * // => false
755
+ *
756
+ * _.isLength(Infinity);
757
+ * // => false
758
+ *
759
+ * _.isLength('3');
760
+ * // => false
761
+ */
762
+ function isLength(value) {
763
+ return typeof value == 'number' &&
764
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
765
+ }
766
+
767
+ /**
768
+ * Checks if `value` is array-like. A value is considered array-like if it's
769
+ * not a function and has a `value.length` that's an integer greater than or
770
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
771
+ *
772
+ * @static
773
+ * @memberOf _
774
+ * @since 4.0.0
775
+ * @category Lang
776
+ * @param {*} value The value to check.
777
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
778
+ * @example
779
+ *
780
+ * _.isArrayLike([1, 2, 3]);
781
+ * // => true
782
+ *
783
+ * _.isArrayLike(document.body.children);
784
+ * // => true
785
+ *
786
+ * _.isArrayLike('abc');
787
+ * // => true
788
+ *
789
+ * _.isArrayLike(_.noop);
790
+ * // => false
791
+ */
792
+ function isArrayLike(value) {
793
+ return value != null && isLength(value.length) && !isFunction(value);
794
+ }
795
+
796
+ /** Used for built-in method references. */
797
+ var objectProto$7 = Object.prototype;
798
+
799
+ /**
800
+ * Checks if `value` is likely a prototype object.
801
+ *
802
+ * @private
803
+ * @param {*} value The value to check.
804
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
805
+ */
806
+ function isPrototype(value) {
807
+ var Ctor = value && value.constructor,
808
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
809
+
810
+ return value === proto;
811
+ }
812
+
813
+ /**
814
+ * The base implementation of `_.times` without support for iteratee shorthands
815
+ * or max array length checks.
816
+ *
817
+ * @private
818
+ * @param {number} n The number of times to invoke `iteratee`.
819
+ * @param {Function} iteratee The function invoked per iteration.
820
+ * @returns {Array} Returns the array of results.
821
+ */
822
+ function baseTimes(n, iteratee) {
823
+ var index = -1,
824
+ result = Array(n);
825
+
826
+ while (++index < n) {
827
+ result[index] = iteratee(index);
828
+ }
829
+ return result;
830
+ }
831
+
832
+ /** `Object#toString` result references. */
833
+ var argsTag$2 = '[object Arguments]';
834
+
835
+ /**
836
+ * The base implementation of `_.isArguments`.
837
+ *
838
+ * @private
839
+ * @param {*} value The value to check.
840
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
841
+ */
842
+ function baseIsArguments(value) {
843
+ return isObjectLike(value) && baseGetTag(value) == argsTag$2;
844
+ }
845
+
846
+ /** Used for built-in method references. */
847
+ var objectProto$6 = Object.prototype;
848
+
849
+ /** Used to check objects for own properties. */
850
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
851
+
852
+ /** Built-in value references. */
853
+ var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
854
+
855
+ /**
856
+ * Checks if `value` is likely an `arguments` object.
857
+ *
858
+ * @static
859
+ * @memberOf _
860
+ * @since 0.1.0
861
+ * @category Lang
862
+ * @param {*} value The value to check.
863
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
864
+ * else `false`.
865
+ * @example
866
+ *
867
+ * _.isArguments(function() { return arguments; }());
868
+ * // => true
869
+ *
870
+ * _.isArguments([1, 2, 3]);
871
+ * // => false
872
+ */
873
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
874
+ return isObjectLike(value) && hasOwnProperty$5.call(value, 'callee') &&
875
+ !propertyIsEnumerable$1.call(value, 'callee');
876
+ };
877
+
878
+ /**
879
+ * This method returns `false`.
880
+ *
881
+ * @static
882
+ * @memberOf _
883
+ * @since 4.13.0
884
+ * @category Util
885
+ * @returns {boolean} Returns `false`.
886
+ * @example
887
+ *
888
+ * _.times(2, _.stubFalse);
889
+ * // => [false, false]
890
+ */
891
+ function stubFalse() {
892
+ return false;
893
+ }
894
+
895
+ /** Detect free variable `exports`. */
896
+ var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
897
+
898
+ /** Detect free variable `module`. */
899
+ var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
900
+
901
+ /** Detect the popular CommonJS extension `module.exports`. */
902
+ var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
903
+
904
+ /** Built-in value references. */
905
+ var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
906
+
907
+ /* Built-in method references for those with the same name as other `lodash` methods. */
908
+ var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
909
+
910
+ /**
911
+ * Checks if `value` is a buffer.
912
+ *
913
+ * @static
914
+ * @memberOf _
915
+ * @since 4.3.0
916
+ * @category Lang
917
+ * @param {*} value The value to check.
918
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
919
+ * @example
920
+ *
921
+ * _.isBuffer(new Buffer(2));
922
+ * // => true
923
+ *
924
+ * _.isBuffer(new Uint8Array(2));
925
+ * // => false
926
+ */
927
+ var isBuffer = nativeIsBuffer || stubFalse;
928
+
929
+ /** `Object#toString` result references. */
930
+ var argsTag$1 = '[object Arguments]',
931
+ arrayTag$1 = '[object Array]',
932
+ boolTag$2 = '[object Boolean]',
933
+ dateTag$2 = '[object Date]',
934
+ errorTag$1 = '[object Error]',
935
+ funcTag$1 = '[object Function]',
936
+ mapTag$4 = '[object Map]',
937
+ numberTag$2 = '[object Number]',
938
+ objectTag$2 = '[object Object]',
939
+ regexpTag$2 = '[object RegExp]',
940
+ setTag$4 = '[object Set]',
941
+ stringTag$2 = '[object String]',
942
+ weakMapTag$2 = '[object WeakMap]';
943
+
944
+ var arrayBufferTag$2 = '[object ArrayBuffer]',
945
+ dataViewTag$3 = '[object DataView]',
946
+ float32Tag$2 = '[object Float32Array]',
947
+ float64Tag$2 = '[object Float64Array]',
948
+ int8Tag$2 = '[object Int8Array]',
949
+ int16Tag$2 = '[object Int16Array]',
950
+ int32Tag$2 = '[object Int32Array]',
951
+ uint8Tag$2 = '[object Uint8Array]',
952
+ uint8ClampedTag$2 = '[object Uint8ClampedArray]',
953
+ uint16Tag$2 = '[object Uint16Array]',
954
+ uint32Tag$2 = '[object Uint32Array]';
955
+
956
+ /** Used to identify `toStringTag` values of typed arrays. */
957
+ var typedArrayTags = {};
958
+ typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] =
959
+ typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] =
960
+ typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] =
961
+ typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] =
962
+ typedArrayTags[uint32Tag$2] = true;
963
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
964
+ typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] =
965
+ typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] =
966
+ typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] =
967
+ typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] =
968
+ typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$2] =
969
+ typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] =
970
+ typedArrayTags[weakMapTag$2] = false;
971
+
972
+ /**
973
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
974
+ *
975
+ * @private
976
+ * @param {*} value The value to check.
977
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
978
+ */
979
+ function baseIsTypedArray(value) {
980
+ return isObjectLike(value) &&
981
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
982
+ }
983
+
984
+ /**
985
+ * The base implementation of `_.unary` without support for storing metadata.
986
+ *
987
+ * @private
988
+ * @param {Function} func The function to cap arguments for.
989
+ * @returns {Function} Returns the new capped function.
990
+ */
991
+ function baseUnary(func) {
992
+ return function(value) {
993
+ return func(value);
994
+ };
995
+ }
996
+
997
+ /** Detect free variable `exports`. */
998
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
999
+
1000
+ /** Detect free variable `module`. */
1001
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1002
+
1003
+ /** Detect the popular CommonJS extension `module.exports`. */
1004
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1005
+
1006
+ /** Detect free variable `process` from Node.js. */
1007
+ var freeProcess = moduleExports$1 && freeGlobal.process;
1008
+
1009
+ /** Used to access faster Node.js helpers. */
1010
+ var nodeUtil = (function() {
1011
+ try {
1012
+ // Use `util.types` for Node.js 10+.
1013
+ var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
1014
+
1015
+ if (types) {
1016
+ return types;
1017
+ }
1018
+
1019
+ // Legacy `process.binding('util')` for Node.js < 10.
1020
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
1021
+ } catch (e) {}
1022
+ }());
1023
+
1024
+ /* Node.js helper references. */
1025
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1026
+
1027
+ /**
1028
+ * Checks if `value` is classified as a typed array.
1029
+ *
1030
+ * @static
1031
+ * @memberOf _
1032
+ * @since 3.0.0
1033
+ * @category Lang
1034
+ * @param {*} value The value to check.
1035
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1036
+ * @example
1037
+ *
1038
+ * _.isTypedArray(new Uint8Array);
1039
+ * // => true
1040
+ *
1041
+ * _.isTypedArray([]);
1042
+ * // => false
1043
+ */
1044
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1045
+
1046
+ /** Used for built-in method references. */
1047
+ var objectProto$5 = Object.prototype;
1048
+
1049
+ /** Used to check objects for own properties. */
1050
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
1051
+
1052
+ /**
1053
+ * Creates an array of the enumerable property names of the array-like `value`.
1054
+ *
1055
+ * @private
1056
+ * @param {*} value The value to query.
1057
+ * @param {boolean} inherited Specify returning inherited property names.
1058
+ * @returns {Array} Returns the array of property names.
1059
+ */
1060
+ function arrayLikeKeys(value, inherited) {
1061
+ var isArr = isArray(value),
1062
+ isArg = !isArr && isArguments(value),
1063
+ isBuff = !isArr && !isArg && isBuffer(value),
1064
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1065
+ skipIndexes = isArr || isArg || isBuff || isType,
1066
+ result = skipIndexes ? baseTimes(value.length, String) : [],
1067
+ length = result.length;
1068
+
1069
+ for (var key in value) {
1070
+ if ((hasOwnProperty$4.call(value, key)) &&
1071
+ !(skipIndexes && (
1072
+ // Safari 9 has enumerable `arguments.length` in strict mode.
1073
+ key == 'length' ||
1074
+ // Node.js 0.10 has enumerable non-index properties on buffers.
1075
+ (isBuff && (key == 'offset' || key == 'parent')) ||
1076
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
1077
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1078
+ // Skip index properties.
1079
+ isIndex(key, length)
1080
+ ))) {
1081
+ result.push(key);
1082
+ }
1083
+ }
1084
+ return result;
1085
+ }
1086
+
1087
+ /**
1088
+ * Creates a unary function that invokes `func` with its argument transformed.
1089
+ *
1090
+ * @private
1091
+ * @param {Function} func The function to wrap.
1092
+ * @param {Function} transform The argument transform.
1093
+ * @returns {Function} Returns the new function.
1094
+ */
1095
+ function overArg(func, transform) {
1096
+ return function(arg) {
1097
+ return func(transform(arg));
1098
+ };
1099
+ }
1100
+
1101
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1102
+ var nativeKeys = overArg(Object.keys, Object);
1103
+
1104
+ /** Used for built-in method references. */
1105
+ var objectProto$4 = Object.prototype;
1106
+
1107
+ /** Used to check objects for own properties. */
1108
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
1109
+
1110
+ /**
1111
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1112
+ *
1113
+ * @private
1114
+ * @param {Object} object The object to query.
1115
+ * @returns {Array} Returns the array of property names.
1116
+ */
1117
+ function baseKeys(object) {
1118
+ if (!isPrototype(object)) {
1119
+ return nativeKeys(object);
1120
+ }
1121
+ var result = [];
1122
+ for (var key in Object(object)) {
1123
+ if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
1124
+ result.push(key);
1125
+ }
1126
+ }
1127
+ return result;
1128
+ }
1129
+
1130
+ /**
1131
+ * Creates an array of the own enumerable property names of `object`.
1132
+ *
1133
+ * **Note:** Non-object values are coerced to objects. See the
1134
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1135
+ * for more details.
1136
+ *
1137
+ * @static
1138
+ * @since 0.1.0
1139
+ * @memberOf _
1140
+ * @category Object
1141
+ * @param {Object} object The object to query.
1142
+ * @returns {Array} Returns the array of property names.
1143
+ * @example
1144
+ *
1145
+ * function Foo() {
1146
+ * this.a = 1;
1147
+ * this.b = 2;
1148
+ * }
1149
+ *
1150
+ * Foo.prototype.c = 3;
1151
+ *
1152
+ * _.keys(new Foo);
1153
+ * // => ['a', 'b'] (iteration order is not guaranteed)
1154
+ *
1155
+ * _.keys('hi');
1156
+ * // => ['0', '1']
1157
+ */
1158
+ function keys(object) {
1159
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1160
+ }
1161
+
1162
+ /** Used to match property names within property paths. */
1163
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
1164
+ reIsPlainProp = /^\w*$/;
1165
+
1166
+ /**
1167
+ * Checks if `value` is a property name and not a property path.
1168
+ *
1169
+ * @private
1170
+ * @param {*} value The value to check.
1171
+ * @param {Object} [object] The object to query keys on.
1172
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
1173
+ */
1174
+ function isKey(value, object) {
1175
+ if (isArray(value)) {
1176
+ return false;
1177
+ }
1178
+ var type = typeof value;
1179
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
1180
+ value == null || isSymbol(value)) {
1181
+ return true;
1182
+ }
1183
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
1184
+ (object != null && value in Object(object));
1185
+ }
1186
+
1187
+ /* Built-in method references that are verified to be native. */
1188
+ var nativeCreate = getNative(Object, 'create');
1189
+
1190
+ /**
1191
+ * Removes all key-value entries from the hash.
1192
+ *
1193
+ * @private
1194
+ * @name clear
1195
+ * @memberOf Hash
1196
+ */
1197
+ function hashClear() {
1198
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
1199
+ this.size = 0;
1200
+ }
1201
+
1202
+ /**
1203
+ * Removes `key` and its value from the hash.
1204
+ *
1205
+ * @private
1206
+ * @name delete
1207
+ * @memberOf Hash
1208
+ * @param {Object} hash The hash to modify.
1209
+ * @param {string} key The key of the value to remove.
1210
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1211
+ */
1212
+ function hashDelete(key) {
1213
+ var result = this.has(key) && delete this.__data__[key];
1214
+ this.size -= result ? 1 : 0;
1215
+ return result;
1216
+ }
1217
+
1218
+ /** Used to stand-in for `undefined` hash values. */
1219
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1220
+
1221
+ /** Used for built-in method references. */
1222
+ var objectProto$3 = Object.prototype;
1223
+
1224
+ /** Used to check objects for own properties. */
1225
+ var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
1226
+
1227
+ /**
1228
+ * Gets the hash value for `key`.
1229
+ *
1230
+ * @private
1231
+ * @name get
1232
+ * @memberOf Hash
1233
+ * @param {string} key The key of the value to get.
1234
+ * @returns {*} Returns the entry value.
1235
+ */
1236
+ function hashGet(key) {
1237
+ var data = this.__data__;
1238
+ if (nativeCreate) {
1239
+ var result = data[key];
1240
+ return result === HASH_UNDEFINED$1 ? undefined : result;
1241
+ }
1242
+ return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
1243
+ }
1244
+
1245
+ /** Used for built-in method references. */
1246
+ var objectProto$2 = Object.prototype;
1247
+
1248
+ /** Used to check objects for own properties. */
1249
+ var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
1250
+
1251
+ /**
1252
+ * Checks if a hash value for `key` exists.
1253
+ *
1254
+ * @private
1255
+ * @name has
1256
+ * @memberOf Hash
1257
+ * @param {string} key The key of the entry to check.
1258
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1259
+ */
1260
+ function hashHas(key) {
1261
+ var data = this.__data__;
1262
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key);
1263
+ }
1264
+
1265
+ /** Used to stand-in for `undefined` hash values. */
1266
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1267
+
1268
+ /**
1269
+ * Sets the hash `key` to `value`.
1270
+ *
1271
+ * @private
1272
+ * @name set
1273
+ * @memberOf Hash
1274
+ * @param {string} key The key of the value to set.
1275
+ * @param {*} value The value to set.
1276
+ * @returns {Object} Returns the hash instance.
1277
+ */
1278
+ function hashSet(key, value) {
1279
+ var data = this.__data__;
1280
+ this.size += this.has(key) ? 0 : 1;
1281
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1282
+ return this;
1283
+ }
1284
+
1285
+ /**
1286
+ * Creates a hash object.
1287
+ *
1288
+ * @private
1289
+ * @constructor
1290
+ * @param {Array} [entries] The key-value pairs to cache.
1291
+ */
1292
+ function Hash(entries) {
1293
+ var index = -1,
1294
+ length = entries == null ? 0 : entries.length;
1295
+
1296
+ this.clear();
1297
+ while (++index < length) {
1298
+ var entry = entries[index];
1299
+ this.set(entry[0], entry[1]);
1300
+ }
1301
+ }
1302
+
1303
+ // Add methods to `Hash`.
1304
+ Hash.prototype.clear = hashClear;
1305
+ Hash.prototype['delete'] = hashDelete;
1306
+ Hash.prototype.get = hashGet;
1307
+ Hash.prototype.has = hashHas;
1308
+ Hash.prototype.set = hashSet;
1309
+
1310
+ /**
1311
+ * Removes all key-value entries from the list cache.
1312
+ *
1313
+ * @private
1314
+ * @name clear
1315
+ * @memberOf ListCache
1316
+ */
1317
+ function listCacheClear() {
1318
+ this.__data__ = [];
1319
+ this.size = 0;
1320
+ }
1321
+
1322
+ /**
1323
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
1324
+ *
1325
+ * @private
1326
+ * @param {Array} array The array to inspect.
1327
+ * @param {*} key The key to search for.
1328
+ * @returns {number} Returns the index of the matched value, else `-1`.
1329
+ */
1330
+ function assocIndexOf(array, key) {
1331
+ var length = array.length;
1332
+ while (length--) {
1333
+ if (eq(array[length][0], key)) {
1334
+ return length;
1335
+ }
1336
+ }
1337
+ return -1;
1338
+ }
1339
+
1340
+ /** Used for built-in method references. */
1341
+ var arrayProto = Array.prototype;
1342
+
1343
+ /** Built-in value references. */
1344
+ var splice = arrayProto.splice;
1345
+
1346
+ /**
1347
+ * Removes `key` and its value from the list cache.
1348
+ *
1349
+ * @private
1350
+ * @name delete
1351
+ * @memberOf ListCache
1352
+ * @param {string} key The key of the value to remove.
1353
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1354
+ */
1355
+ function listCacheDelete(key) {
1356
+ var data = this.__data__,
1357
+ index = assocIndexOf(data, key);
1358
+
1359
+ if (index < 0) {
1360
+ return false;
1361
+ }
1362
+ var lastIndex = data.length - 1;
1363
+ if (index == lastIndex) {
1364
+ data.pop();
1365
+ } else {
1366
+ splice.call(data, index, 1);
1367
+ }
1368
+ --this.size;
1369
+ return true;
1370
+ }
1371
+
1372
+ /**
1373
+ * Gets the list cache value for `key`.
1374
+ *
1375
+ * @private
1376
+ * @name get
1377
+ * @memberOf ListCache
1378
+ * @param {string} key The key of the value to get.
1379
+ * @returns {*} Returns the entry value.
1380
+ */
1381
+ function listCacheGet(key) {
1382
+ var data = this.__data__,
1383
+ index = assocIndexOf(data, key);
1384
+
1385
+ return index < 0 ? undefined : data[index][1];
1386
+ }
1387
+
1388
+ /**
1389
+ * Checks if a list cache value for `key` exists.
1390
+ *
1391
+ * @private
1392
+ * @name has
1393
+ * @memberOf ListCache
1394
+ * @param {string} key The key of the entry to check.
1395
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1396
+ */
1397
+ function listCacheHas(key) {
1398
+ return assocIndexOf(this.__data__, key) > -1;
1399
+ }
1400
+
1401
+ /**
1402
+ * Sets the list cache `key` to `value`.
1403
+ *
1404
+ * @private
1405
+ * @name set
1406
+ * @memberOf ListCache
1407
+ * @param {string} key The key of the value to set.
1408
+ * @param {*} value The value to set.
1409
+ * @returns {Object} Returns the list cache instance.
1410
+ */
1411
+ function listCacheSet(key, value) {
1412
+ var data = this.__data__,
1413
+ index = assocIndexOf(data, key);
1414
+
1415
+ if (index < 0) {
1416
+ ++this.size;
1417
+ data.push([key, value]);
1418
+ } else {
1419
+ data[index][1] = value;
1420
+ }
1421
+ return this;
1422
+ }
1423
+
1424
+ /**
1425
+ * Creates an list cache object.
1426
+ *
1427
+ * @private
1428
+ * @constructor
1429
+ * @param {Array} [entries] The key-value pairs to cache.
1430
+ */
1431
+ function ListCache(entries) {
1432
+ var index = -1,
1433
+ length = entries == null ? 0 : entries.length;
1434
+
1435
+ this.clear();
1436
+ while (++index < length) {
1437
+ var entry = entries[index];
1438
+ this.set(entry[0], entry[1]);
1439
+ }
1440
+ }
1441
+
1442
+ // Add methods to `ListCache`.
1443
+ ListCache.prototype.clear = listCacheClear;
1444
+ ListCache.prototype['delete'] = listCacheDelete;
1445
+ ListCache.prototype.get = listCacheGet;
1446
+ ListCache.prototype.has = listCacheHas;
1447
+ ListCache.prototype.set = listCacheSet;
1448
+
1449
+ /* Built-in method references that are verified to be native. */
1450
+ var Map$1 = getNative(root, 'Map');
1451
+
1452
+ /**
1453
+ * Removes all key-value entries from the map.
1454
+ *
1455
+ * @private
1456
+ * @name clear
1457
+ * @memberOf MapCache
1458
+ */
1459
+ function mapCacheClear() {
1460
+ this.size = 0;
1461
+ this.__data__ = {
1462
+ 'hash': new Hash,
1463
+ 'map': new (Map$1 || ListCache),
1464
+ 'string': new Hash
1465
+ };
1466
+ }
1467
+
1468
+ /**
1469
+ * Checks if `value` is suitable for use as unique object key.
1470
+ *
1471
+ * @private
1472
+ * @param {*} value The value to check.
1473
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1474
+ */
1475
+ function isKeyable(value) {
1476
+ var type = typeof value;
1477
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1478
+ ? (value !== '__proto__')
1479
+ : (value === null);
1480
+ }
1481
+
1482
+ /**
1483
+ * Gets the data for `map`.
1484
+ *
1485
+ * @private
1486
+ * @param {Object} map The map to query.
1487
+ * @param {string} key The reference key.
1488
+ * @returns {*} Returns the map data.
1489
+ */
1490
+ function getMapData(map, key) {
1491
+ var data = map.__data__;
1492
+ return isKeyable(key)
1493
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1494
+ : data.map;
1495
+ }
1496
+
1497
+ /**
1498
+ * Removes `key` and its value from the map.
1499
+ *
1500
+ * @private
1501
+ * @name delete
1502
+ * @memberOf MapCache
1503
+ * @param {string} key The key of the value to remove.
1504
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1505
+ */
1506
+ function mapCacheDelete(key) {
1507
+ var result = getMapData(this, key)['delete'](key);
1508
+ this.size -= result ? 1 : 0;
1509
+ return result;
1510
+ }
1511
+
1512
+ /**
1513
+ * Gets the map value for `key`.
1514
+ *
1515
+ * @private
1516
+ * @name get
1517
+ * @memberOf MapCache
1518
+ * @param {string} key The key of the value to get.
1519
+ * @returns {*} Returns the entry value.
1520
+ */
1521
+ function mapCacheGet(key) {
1522
+ return getMapData(this, key).get(key);
1523
+ }
1524
+
1525
+ /**
1526
+ * Checks if a map value for `key` exists.
1527
+ *
1528
+ * @private
1529
+ * @name has
1530
+ * @memberOf MapCache
1531
+ * @param {string} key The key of the entry to check.
1532
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1533
+ */
1534
+ function mapCacheHas(key) {
1535
+ return getMapData(this, key).has(key);
1536
+ }
1537
+
1538
+ /**
1539
+ * Sets the map `key` to `value`.
1540
+ *
1541
+ * @private
1542
+ * @name set
1543
+ * @memberOf MapCache
1544
+ * @param {string} key The key of the value to set.
1545
+ * @param {*} value The value to set.
1546
+ * @returns {Object} Returns the map cache instance.
1547
+ */
1548
+ function mapCacheSet(key, value) {
1549
+ var data = getMapData(this, key),
1550
+ size = data.size;
1551
+
1552
+ data.set(key, value);
1553
+ this.size += data.size == size ? 0 : 1;
1554
+ return this;
1555
+ }
1556
+
1557
+ /**
1558
+ * Creates a map cache object to store key-value pairs.
1559
+ *
1560
+ * @private
1561
+ * @constructor
1562
+ * @param {Array} [entries] The key-value pairs to cache.
1563
+ */
1564
+ function MapCache(entries) {
1565
+ var index = -1,
1566
+ length = entries == null ? 0 : entries.length;
1567
+
1568
+ this.clear();
1569
+ while (++index < length) {
1570
+ var entry = entries[index];
1571
+ this.set(entry[0], entry[1]);
1572
+ }
1573
+ }
1574
+
1575
+ // Add methods to `MapCache`.
1576
+ MapCache.prototype.clear = mapCacheClear;
1577
+ MapCache.prototype['delete'] = mapCacheDelete;
1578
+ MapCache.prototype.get = mapCacheGet;
1579
+ MapCache.prototype.has = mapCacheHas;
1580
+ MapCache.prototype.set = mapCacheSet;
1581
+
1582
+ /** Error message constants. */
1583
+ var FUNC_ERROR_TEXT = 'Expected a function';
1584
+
1585
+ /**
1586
+ * Creates a function that memoizes the result of `func`. If `resolver` is
1587
+ * provided, it determines the cache key for storing the result based on the
1588
+ * arguments provided to the memoized function. By default, the first argument
1589
+ * provided to the memoized function is used as the map cache key. The `func`
1590
+ * is invoked with the `this` binding of the memoized function.
1591
+ *
1592
+ * **Note:** The cache is exposed as the `cache` property on the memoized
1593
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
1594
+ * constructor with one whose instances implement the
1595
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
1596
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
1597
+ *
1598
+ * @static
1599
+ * @memberOf _
1600
+ * @since 0.1.0
1601
+ * @category Function
1602
+ * @param {Function} func The function to have its output memoized.
1603
+ * @param {Function} [resolver] The function to resolve the cache key.
1604
+ * @returns {Function} Returns the new memoized function.
1605
+ * @example
1606
+ *
1607
+ * var object = { 'a': 1, 'b': 2 };
1608
+ * var other = { 'c': 3, 'd': 4 };
1609
+ *
1610
+ * var values = _.memoize(_.values);
1611
+ * values(object);
1612
+ * // => [1, 2]
1613
+ *
1614
+ * values(other);
1615
+ * // => [3, 4]
1616
+ *
1617
+ * object.a = 2;
1618
+ * values(object);
1619
+ * // => [1, 2]
1620
+ *
1621
+ * // Modify the result cache.
1622
+ * values.cache.set(object, ['a', 'b']);
1623
+ * values(object);
1624
+ * // => ['a', 'b']
1625
+ *
1626
+ * // Replace `_.memoize.Cache`.
1627
+ * _.memoize.Cache = WeakMap;
1628
+ */
1629
+ function memoize(func, resolver) {
1630
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
1631
+ throw new TypeError(FUNC_ERROR_TEXT);
1632
+ }
1633
+ var memoized = function() {
1634
+ var args = arguments,
1635
+ key = resolver ? resolver.apply(this, args) : args[0],
1636
+ cache = memoized.cache;
1637
+
1638
+ if (cache.has(key)) {
1639
+ return cache.get(key);
1640
+ }
1641
+ var result = func.apply(this, args);
1642
+ memoized.cache = cache.set(key, result) || cache;
1643
+ return result;
1644
+ };
1645
+ memoized.cache = new (memoize.Cache || MapCache);
1646
+ return memoized;
1647
+ }
1648
+
1649
+ // Expose `MapCache`.
1650
+ memoize.Cache = MapCache;
1651
+
1652
+ /** Used as the maximum memoize cache size. */
1653
+ var MAX_MEMOIZE_SIZE = 500;
1654
+
1655
+ /**
1656
+ * A specialized version of `_.memoize` which clears the memoized function's
1657
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
1658
+ *
1659
+ * @private
1660
+ * @param {Function} func The function to have its output memoized.
1661
+ * @returns {Function} Returns the new memoized function.
1662
+ */
1663
+ function memoizeCapped(func) {
1664
+ var result = memoize(func, function(key) {
1665
+ if (cache.size === MAX_MEMOIZE_SIZE) {
1666
+ cache.clear();
1667
+ }
1668
+ return key;
1669
+ });
1670
+
1671
+ var cache = result.cache;
1672
+ return result;
1673
+ }
1674
+
1675
+ /** Used to match property names within property paths. */
1676
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1677
+
1678
+ /** Used to match backslashes in property paths. */
1679
+ var reEscapeChar = /\\(\\)?/g;
1680
+
1681
+ /**
1682
+ * Converts `string` to a property path array.
1683
+ *
1684
+ * @private
1685
+ * @param {string} string The string to convert.
1686
+ * @returns {Array} Returns the property path array.
1687
+ */
1688
+ var stringToPath = memoizeCapped(function(string) {
1689
+ var result = [];
1690
+ if (string.charCodeAt(0) === 46 /* . */) {
1691
+ result.push('');
1692
+ }
1693
+ string.replace(rePropName, function(match, number, quote, subString) {
1694
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
1695
+ });
1696
+ return result;
1697
+ });
1698
+
1699
+ /**
1700
+ * Converts `value` to a string. An empty string is returned for `null`
1701
+ * and `undefined` values. The sign of `-0` is preserved.
1702
+ *
1703
+ * @static
1704
+ * @memberOf _
1705
+ * @since 4.0.0
1706
+ * @category Lang
1707
+ * @param {*} value The value to convert.
1708
+ * @returns {string} Returns the converted string.
1709
+ * @example
1710
+ *
1711
+ * _.toString(null);
1712
+ * // => ''
1713
+ *
1714
+ * _.toString(-0);
1715
+ * // => '-0'
1716
+ *
1717
+ * _.toString([1, 2, 3]);
1718
+ * // => '1,2,3'
1719
+ */
1720
+ function toString(value) {
1721
+ return value == null ? '' : baseToString(value);
1722
+ }
1723
+
1724
+ /**
1725
+ * Casts `value` to a path array if it's not one.
1726
+ *
1727
+ * @private
1728
+ * @param {*} value The value to inspect.
1729
+ * @param {Object} [object] The object to query keys on.
1730
+ * @returns {Array} Returns the cast property path array.
1731
+ */
1732
+ function castPath(value, object) {
1733
+ if (isArray(value)) {
1734
+ return value;
1735
+ }
1736
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
1737
+ }
1738
+
1739
+ /**
1740
+ * Converts `value` to a string key if it's not a string or symbol.
1741
+ *
1742
+ * @private
1743
+ * @param {*} value The value to inspect.
1744
+ * @returns {string|symbol} Returns the key.
1745
+ */
1746
+ function toKey(value) {
1747
+ if (typeof value == 'string' || isSymbol(value)) {
1748
+ return value;
1749
+ }
1750
+ var result = (value + '');
1751
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
1752
+ }
1753
+
1754
+ /**
1755
+ * The base implementation of `_.get` without support for default values.
1756
+ *
1757
+ * @private
1758
+ * @param {Object} object The object to query.
1759
+ * @param {Array|string} path The path of the property to get.
1760
+ * @returns {*} Returns the resolved value.
1761
+ */
1762
+ function baseGet(object, path) {
1763
+ path = castPath(path, object);
1764
+
1765
+ var index = 0,
1766
+ length = path.length;
1767
+
1768
+ while (object != null && index < length) {
1769
+ object = object[toKey(path[index++])];
1770
+ }
1771
+ return (index && index == length) ? object : undefined;
1772
+ }
1773
+
1774
+ /**
1775
+ * Appends the elements of `values` to `array`.
1776
+ *
1777
+ * @private
1778
+ * @param {Array} array The array to modify.
1779
+ * @param {Array} values The values to append.
1780
+ * @returns {Array} Returns `array`.
1781
+ */
1782
+ function arrayPush(array, values) {
1783
+ var index = -1,
1784
+ length = values.length,
1785
+ offset = array.length;
1786
+
1787
+ while (++index < length) {
1788
+ array[offset + index] = values[index];
1789
+ }
1790
+ return array;
1791
+ }
1792
+
1793
+ /** Built-in value references. */
1794
+ var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
1795
+
1796
+ /**
1797
+ * Checks if `value` is a flattenable `arguments` object or array.
1798
+ *
1799
+ * @private
1800
+ * @param {*} value The value to check.
1801
+ * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1802
+ */
1803
+ function isFlattenable(value) {
1804
+ return isArray(value) || isArguments(value) ||
1805
+ !!(spreadableSymbol && value && value[spreadableSymbol]);
1806
+ }
1807
+
1808
+ /**
1809
+ * The base implementation of `_.flatten` with support for restricting flattening.
1810
+ *
1811
+ * @private
1812
+ * @param {Array} array The array to flatten.
1813
+ * @param {number} depth The maximum recursion depth.
1814
+ * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
1815
+ * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
1816
+ * @param {Array} [result=[]] The initial result value.
1817
+ * @returns {Array} Returns the new flattened array.
1818
+ */
1819
+ function baseFlatten(array, depth, predicate, isStrict, result) {
1820
+ var index = -1,
1821
+ length = array.length;
1822
+
1823
+ predicate || (predicate = isFlattenable);
1824
+ result || (result = []);
1825
+
1826
+ while (++index < length) {
1827
+ var value = array[index];
1828
+ if (predicate(value)) {
1829
+ {
1830
+ arrayPush(result, value);
1831
+ }
1832
+ } else {
1833
+ result[result.length] = value;
1834
+ }
1835
+ }
1836
+ return result;
1837
+ }
1838
+
1839
+ /**
1840
+ * Flattens `array` a single level deep.
1841
+ *
1842
+ * @static
1843
+ * @memberOf _
1844
+ * @since 0.1.0
1845
+ * @category Array
1846
+ * @param {Array} array The array to flatten.
1847
+ * @returns {Array} Returns the new flattened array.
1848
+ * @example
1849
+ *
1850
+ * _.flatten([1, [2, [3, [4]], 5]]);
1851
+ * // => [1, 2, [3, [4]], 5]
1852
+ */
1853
+ function flatten(array) {
1854
+ var length = array == null ? 0 : array.length;
1855
+ return length ? baseFlatten(array) : [];
1856
+ }
1857
+
1858
+ /**
1859
+ * A specialized version of `baseRest` which flattens the rest array.
1860
+ *
1861
+ * @private
1862
+ * @param {Function} func The function to apply a rest parameter to.
1863
+ * @returns {Function} Returns the new function.
1864
+ */
1865
+ function flatRest(func) {
1866
+ return setToString(overRest(func, undefined, flatten), func + '');
1867
+ }
1868
+
1869
+ /** Built-in value references. */
1870
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
1871
+
1872
+ /**
1873
+ * The base implementation of `_.slice` without an iteratee call guard.
1874
+ *
1875
+ * @private
1876
+ * @param {Array} array The array to slice.
1877
+ * @param {number} [start=0] The start position.
1878
+ * @param {number} [end=array.length] The end position.
1879
+ * @returns {Array} Returns the slice of `array`.
1880
+ */
1881
+ function baseSlice(array, start, end) {
1882
+ var index = -1,
1883
+ length = array.length;
1884
+
1885
+ if (start < 0) {
1886
+ start = -start > length ? 0 : (length + start);
1887
+ }
1888
+ end = end > length ? length : end;
1889
+ if (end < 0) {
1890
+ end += length;
1891
+ }
1892
+ length = start > end ? 0 : ((end - start) >>> 0);
1893
+ start >>>= 0;
1894
+
1895
+ var result = Array(length);
1896
+ while (++index < length) {
1897
+ result[index] = array[index + start];
1898
+ }
1899
+ return result;
1900
+ }
1901
+
1902
+ /**
1903
+ * Casts `array` to a slice if it's needed.
1904
+ *
1905
+ * @private
1906
+ * @param {Array} array The array to inspect.
1907
+ * @param {number} start The start position.
1908
+ * @param {number} [end=array.length] The end position.
1909
+ * @returns {Array} Returns the cast slice.
1910
+ */
1911
+ function castSlice(array, start, end) {
1912
+ var length = array.length;
1913
+ end = end === undefined ? length : end;
1914
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
1915
+ }
1916
+
1917
+ /** Used to compose unicode character classes. */
1918
+ var rsAstralRange$2 = '\\ud800-\\udfff',
1919
+ rsComboMarksRange$3 = '\\u0300-\\u036f',
1920
+ reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f',
1921
+ rsComboSymbolsRange$3 = '\\u20d0-\\u20ff',
1922
+ rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3,
1923
+ rsVarRange$2 = '\\ufe0e\\ufe0f';
1924
+
1925
+ /** Used to compose unicode capture groups. */
1926
+ var rsZWJ$2 = '\\u200d';
1927
+
1928
+ /** 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/). */
1929
+ var reHasUnicode = RegExp('[' + rsZWJ$2 + rsAstralRange$2 + rsComboRange$3 + rsVarRange$2 + ']');
1930
+
1931
+ /**
1932
+ * Checks if `string` contains Unicode symbols.
1933
+ *
1934
+ * @private
1935
+ * @param {string} string The string to inspect.
1936
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1937
+ */
1938
+ function hasUnicode(string) {
1939
+ return reHasUnicode.test(string);
1940
+ }
1941
+
1942
+ /**
1943
+ * Converts an ASCII `string` to an array.
1944
+ *
1945
+ * @private
1946
+ * @param {string} string The string to convert.
1947
+ * @returns {Array} Returns the converted array.
1948
+ */
1949
+ function asciiToArray(string) {
1950
+ return string.split('');
1951
+ }
1952
+
1953
+ /** Used to compose unicode character classes. */
1954
+ var rsAstralRange$1 = '\\ud800-\\udfff',
1955
+ rsComboMarksRange$2 = '\\u0300-\\u036f',
1956
+ reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f',
1957
+ rsComboSymbolsRange$2 = '\\u20d0-\\u20ff',
1958
+ rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2,
1959
+ rsVarRange$1 = '\\ufe0e\\ufe0f';
1960
+
1961
+ /** Used to compose unicode capture groups. */
1962
+ var rsAstral = '[' + rsAstralRange$1 + ']',
1963
+ rsCombo$2 = '[' + rsComboRange$2 + ']',
1964
+ rsFitz$1 = '\\ud83c[\\udffb-\\udfff]',
1965
+ rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')',
1966
+ rsNonAstral$1 = '[^' + rsAstralRange$1 + ']',
1967
+ rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}',
1968
+ rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]',
1969
+ rsZWJ$1 = '\\u200d';
1970
+
1971
+ /** Used to compose unicode regexes. */
1972
+ var reOptMod$1 = rsModifier$1 + '?',
1973
+ rsOptVar$1 = '[' + rsVarRange$1 + ']?',
1974
+ rsOptJoin$1 = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*',
1975
+ rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1,
1976
+ rsSymbol = '(?:' + [rsNonAstral$1 + rsCombo$2 + '?', rsCombo$2, rsRegional$1, rsSurrPair$1, rsAstral].join('|') + ')';
1977
+
1978
+ /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
1979
+ var reUnicode = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol + rsSeq$1, 'g');
1980
+
1981
+ /**
1982
+ * Converts a Unicode `string` to an array.
1983
+ *
1984
+ * @private
1985
+ * @param {string} string The string to convert.
1986
+ * @returns {Array} Returns the converted array.
1987
+ */
1988
+ function unicodeToArray(string) {
1989
+ return string.match(reUnicode) || [];
1990
+ }
1991
+
1992
+ /**
1993
+ * Converts `string` to an array.
1994
+ *
1995
+ * @private
1996
+ * @param {string} string The string to convert.
1997
+ * @returns {Array} Returns the converted array.
1998
+ */
1999
+ function stringToArray(string) {
2000
+ return hasUnicode(string)
2001
+ ? unicodeToArray(string)
2002
+ : asciiToArray(string);
2003
+ }
2004
+
2005
+ /**
2006
+ * Creates a function like `_.lowerFirst`.
2007
+ *
2008
+ * @private
2009
+ * @param {string} methodName The name of the `String` case method to use.
2010
+ * @returns {Function} Returns the new case function.
2011
+ */
2012
+ function createCaseFirst(methodName) {
2013
+ return function(string) {
2014
+ string = toString(string);
2015
+
2016
+ var strSymbols = hasUnicode(string)
2017
+ ? stringToArray(string)
2018
+ : undefined;
2019
+
2020
+ var chr = strSymbols
2021
+ ? strSymbols[0]
2022
+ : string.charAt(0);
2023
+
2024
+ var trailing = strSymbols
2025
+ ? castSlice(strSymbols, 1).join('')
2026
+ : string.slice(1);
2027
+
2028
+ return chr[methodName]() + trailing;
2029
+ };
2030
+ }
2031
+
2032
+ /**
2033
+ * Converts the first character of `string` to upper case.
2034
+ *
2035
+ * @static
2036
+ * @memberOf _
2037
+ * @since 4.0.0
2038
+ * @category String
2039
+ * @param {string} [string=''] The string to convert.
2040
+ * @returns {string} Returns the converted string.
2041
+ * @example
2042
+ *
2043
+ * _.upperFirst('fred');
2044
+ * // => 'Fred'
2045
+ *
2046
+ * _.upperFirst('FRED');
2047
+ * // => 'FRED'
2048
+ */
2049
+ var upperFirst = createCaseFirst('toUpperCase');
2050
+
2051
+ /**
2052
+ * Converts the first character of `string` to upper case and the remaining
2053
+ * to lower case.
2054
+ *
2055
+ * @static
2056
+ * @memberOf _
2057
+ * @since 3.0.0
2058
+ * @category String
2059
+ * @param {string} [string=''] The string to capitalize.
2060
+ * @returns {string} Returns the capitalized string.
2061
+ * @example
2062
+ *
2063
+ * _.capitalize('FRED');
2064
+ * // => 'Fred'
2065
+ */
2066
+ function capitalize(string) {
2067
+ return upperFirst(toString(string).toLowerCase());
2068
+ }
2069
+
2070
+ /**
2071
+ * A specialized version of `_.reduce` for arrays without support for
2072
+ * iteratee shorthands.
2073
+ *
2074
+ * @private
2075
+ * @param {Array} [array] The array to iterate over.
2076
+ * @param {Function} iteratee The function invoked per iteration.
2077
+ * @param {*} [accumulator] The initial value.
2078
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
2079
+ * the initial value.
2080
+ * @returns {*} Returns the accumulated value.
2081
+ */
2082
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
2083
+ var index = -1,
2084
+ length = array == null ? 0 : array.length;
2085
+ while (++index < length) {
2086
+ accumulator = iteratee(accumulator, array[index], index, array);
2087
+ }
2088
+ return accumulator;
2089
+ }
2090
+
2091
+ /**
2092
+ * The base implementation of `_.propertyOf` without support for deep paths.
2093
+ *
2094
+ * @private
2095
+ * @param {Object} object The object to query.
2096
+ * @returns {Function} Returns the new accessor function.
2097
+ */
2098
+ function basePropertyOf(object) {
2099
+ return function(key) {
2100
+ return object == null ? undefined : object[key];
2101
+ };
2102
+ }
2103
+
2104
+ /** Used to map Latin Unicode letters to basic Latin letters. */
2105
+ var deburredLetters = {
2106
+ // Latin-1 Supplement block.
2107
+ '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
2108
+ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
2109
+ '\xc7': 'C', '\xe7': 'c',
2110
+ '\xd0': 'D', '\xf0': 'd',
2111
+ '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
2112
+ '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
2113
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
2114
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
2115
+ '\xd1': 'N', '\xf1': 'n',
2116
+ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
2117
+ '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
2118
+ '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
2119
+ '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
2120
+ '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
2121
+ '\xc6': 'Ae', '\xe6': 'ae',
2122
+ '\xde': 'Th', '\xfe': 'th',
2123
+ '\xdf': 'ss',
2124
+ // Latin Extended-A block.
2125
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
2126
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
2127
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
2128
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
2129
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
2130
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
2131
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
2132
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
2133
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
2134
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
2135
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
2136
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
2137
+ '\u0134': 'J', '\u0135': 'j',
2138
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
2139
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
2140
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
2141
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
2142
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
2143
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
2144
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
2145
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
2146
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
2147
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
2148
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
2149
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
2150
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
2151
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
2152
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
2153
+ '\u0174': 'W', '\u0175': 'w',
2154
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
2155
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
2156
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
2157
+ '\u0132': 'IJ', '\u0133': 'ij',
2158
+ '\u0152': 'Oe', '\u0153': 'oe',
2159
+ '\u0149': "'n", '\u017f': 's'
2160
+ };
2161
+
2162
+ /**
2163
+ * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
2164
+ * letters to basic Latin letters.
2165
+ *
2166
+ * @private
2167
+ * @param {string} letter The matched letter to deburr.
2168
+ * @returns {string} Returns the deburred letter.
2169
+ */
2170
+ var deburrLetter = basePropertyOf(deburredLetters);
2171
+
2172
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
2173
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
2174
+
2175
+ /** Used to compose unicode character classes. */
2176
+ var rsComboMarksRange$1 = '\\u0300-\\u036f',
2177
+ reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
2178
+ rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
2179
+ rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
2180
+
2181
+ /** Used to compose unicode capture groups. */
2182
+ var rsCombo$1 = '[' + rsComboRange$1 + ']';
2183
+
2184
+ /**
2185
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
2186
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
2187
+ */
2188
+ var reComboMark = RegExp(rsCombo$1, 'g');
2189
+
2190
+ /**
2191
+ * Deburrs `string` by converting
2192
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
2193
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
2194
+ * letters to basic Latin letters and removing
2195
+ * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
2196
+ *
2197
+ * @static
2198
+ * @memberOf _
2199
+ * @since 3.0.0
2200
+ * @category String
2201
+ * @param {string} [string=''] The string to deburr.
2202
+ * @returns {string} Returns the deburred string.
2203
+ * @example
2204
+ *
2205
+ * _.deburr('déjà vu');
2206
+ * // => 'deja vu'
2207
+ */
2208
+ function deburr(string) {
2209
+ string = toString(string);
2210
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
2211
+ }
2212
+
2213
+ /** Used to match words composed of alphanumeric characters. */
2214
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
2215
+
2216
+ /**
2217
+ * Splits an ASCII `string` into an array of its words.
2218
+ *
2219
+ * @private
2220
+ * @param {string} The string to inspect.
2221
+ * @returns {Array} Returns the words of `string`.
2222
+ */
2223
+ function asciiWords(string) {
2224
+ return string.match(reAsciiWord) || [];
2225
+ }
2226
+
2227
+ /** Used to detect strings that need a more robust regexp to match words. */
2228
+ 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 ]/;
2229
+
2230
+ /**
2231
+ * Checks if `string` contains a word composed of Unicode symbols.
2232
+ *
2233
+ * @private
2234
+ * @param {string} string The string to inspect.
2235
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
2236
+ */
2237
+ function hasUnicodeWord(string) {
2238
+ return reHasUnicodeWord.test(string);
2239
+ }
2240
+
2241
+ /** Used to compose unicode character classes. */
2242
+ var rsAstralRange = '\\ud800-\\udfff',
2243
+ rsComboMarksRange = '\\u0300-\\u036f',
2244
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
2245
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
2246
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
2247
+ rsDingbatRange = '\\u2700-\\u27bf',
2248
+ rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
2249
+ rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
2250
+ rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
2251
+ rsPunctuationRange = '\\u2000-\\u206f',
2252
+ 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',
2253
+ rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
2254
+ rsVarRange = '\\ufe0e\\ufe0f',
2255
+ rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
2256
+
2257
+ /** Used to compose unicode capture groups. */
2258
+ var rsApos$1 = "['\u2019]",
2259
+ rsBreak = '[' + rsBreakRange + ']',
2260
+ rsCombo = '[' + rsComboRange + ']',
2261
+ rsDigits = '\\d+',
2262
+ rsDingbat = '[' + rsDingbatRange + ']',
2263
+ rsLower = '[' + rsLowerRange + ']',
2264
+ rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
2265
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
2266
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
2267
+ rsNonAstral = '[^' + rsAstralRange + ']',
2268
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
2269
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
2270
+ rsUpper = '[' + rsUpperRange + ']',
2271
+ rsZWJ = '\\u200d';
2272
+
2273
+ /** Used to compose unicode regexes. */
2274
+ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
2275
+ rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
2276
+ rsOptContrLower = '(?:' + rsApos$1 + '(?:d|ll|m|re|s|t|ve))?',
2277
+ rsOptContrUpper = '(?:' + rsApos$1 + '(?:D|LL|M|RE|S|T|VE))?',
2278
+ reOptMod = rsModifier + '?',
2279
+ rsOptVar = '[' + rsVarRange + ']?',
2280
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
2281
+ rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
2282
+ rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
2283
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
2284
+ rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
2285
+
2286
+ /** Used to match complex or compound words. */
2287
+ var reUnicodeWord = RegExp([
2288
+ rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
2289
+ rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
2290
+ rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
2291
+ rsUpper + '+' + rsOptContrUpper,
2292
+ rsOrdUpper,
2293
+ rsOrdLower,
2294
+ rsDigits,
2295
+ rsEmoji
2296
+ ].join('|'), 'g');
2297
+
2298
+ /**
2299
+ * Splits a Unicode `string` into an array of its words.
2300
+ *
2301
+ * @private
2302
+ * @param {string} The string to inspect.
2303
+ * @returns {Array} Returns the words of `string`.
2304
+ */
2305
+ function unicodeWords(string) {
2306
+ return string.match(reUnicodeWord) || [];
2307
+ }
2308
+
2309
+ /**
2310
+ * Splits `string` into an array of its words.
2311
+ *
2312
+ * @static
2313
+ * @memberOf _
2314
+ * @since 3.0.0
2315
+ * @category String
2316
+ * @param {string} [string=''] The string to inspect.
2317
+ * @param {RegExp|string} [pattern] The pattern to match words.
2318
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2319
+ * @returns {Array} Returns the words of `string`.
2320
+ * @example
2321
+ *
2322
+ * _.words('fred, barney, & pebbles');
2323
+ * // => ['fred', 'barney', 'pebbles']
2324
+ *
2325
+ * _.words('fred, barney, & pebbles', /[^, ]+/g);
2326
+ * // => ['fred', 'barney', '&', 'pebbles']
2327
+ */
2328
+ function words(string, pattern, guard) {
2329
+ string = toString(string);
2330
+ pattern = pattern;
2331
+
2332
+ if (pattern === undefined) {
2333
+ return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
2334
+ }
2335
+ return string.match(pattern) || [];
2336
+ }
2337
+
2338
+ /** Used to compose unicode capture groups. */
2339
+ var rsApos = "['\u2019]";
2340
+
2341
+ /** Used to match apostrophes. */
2342
+ var reApos = RegExp(rsApos, 'g');
2343
+
2344
+ /**
2345
+ * Creates a function like `_.camelCase`.
2346
+ *
2347
+ * @private
2348
+ * @param {Function} callback The function to combine each word.
2349
+ * @returns {Function} Returns the new compounder function.
2350
+ */
2351
+ function createCompounder(callback) {
2352
+ return function(string) {
2353
+ return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
2354
+ };
2355
+ }
2356
+
2357
+ /**
2358
+ * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
2359
+ *
2360
+ * @static
2361
+ * @memberOf _
2362
+ * @since 3.0.0
2363
+ * @category String
2364
+ * @param {string} [string=''] The string to convert.
2365
+ * @returns {string} Returns the camel cased string.
2366
+ * @example
2367
+ *
2368
+ * _.camelCase('Foo Bar');
2369
+ * // => 'fooBar'
2370
+ *
2371
+ * _.camelCase('--foo-bar--');
2372
+ * // => 'fooBar'
2373
+ *
2374
+ * _.camelCase('__FOO_BAR__');
2375
+ * // => 'fooBar'
2376
+ */
2377
+ var camelCase = createCompounder(function(result, word, index) {
2378
+ word = word.toLowerCase();
2379
+ return result + (index ? capitalize(word) : word);
2380
+ });
2381
+
2382
+ /**
2383
+ * Removes all key-value entries from the stack.
2384
+ *
2385
+ * @private
2386
+ * @name clear
2387
+ * @memberOf Stack
2388
+ */
2389
+ function stackClear() {
2390
+ this.__data__ = new ListCache;
2391
+ this.size = 0;
2392
+ }
2393
+
2394
+ /**
2395
+ * Removes `key` and its value from the stack.
2396
+ *
2397
+ * @private
2398
+ * @name delete
2399
+ * @memberOf Stack
2400
+ * @param {string} key The key of the value to remove.
2401
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2402
+ */
2403
+ function stackDelete(key) {
2404
+ var data = this.__data__,
2405
+ result = data['delete'](key);
2406
+
2407
+ this.size = data.size;
2408
+ return result;
2409
+ }
2410
+
2411
+ /**
2412
+ * Gets the stack value for `key`.
2413
+ *
2414
+ * @private
2415
+ * @name get
2416
+ * @memberOf Stack
2417
+ * @param {string} key The key of the value to get.
2418
+ * @returns {*} Returns the entry value.
2419
+ */
2420
+ function stackGet(key) {
2421
+ return this.__data__.get(key);
2422
+ }
2423
+
2424
+ /**
2425
+ * Checks if a stack value for `key` exists.
2426
+ *
2427
+ * @private
2428
+ * @name has
2429
+ * @memberOf Stack
2430
+ * @param {string} key The key of the entry to check.
2431
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2432
+ */
2433
+ function stackHas(key) {
2434
+ return this.__data__.has(key);
2435
+ }
2436
+
2437
+ /** Used as the size to enable large array optimizations. */
2438
+ var LARGE_ARRAY_SIZE = 200;
2439
+
2440
+ /**
2441
+ * Sets the stack `key` to `value`.
2442
+ *
2443
+ * @private
2444
+ * @name set
2445
+ * @memberOf Stack
2446
+ * @param {string} key The key of the value to set.
2447
+ * @param {*} value The value to set.
2448
+ * @returns {Object} Returns the stack cache instance.
2449
+ */
2450
+ function stackSet(key, value) {
2451
+ var data = this.__data__;
2452
+ if (data instanceof ListCache) {
2453
+ var pairs = data.__data__;
2454
+ if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2455
+ pairs.push([key, value]);
2456
+ this.size = ++data.size;
2457
+ return this;
2458
+ }
2459
+ data = this.__data__ = new MapCache(pairs);
2460
+ }
2461
+ data.set(key, value);
2462
+ this.size = data.size;
2463
+ return this;
2464
+ }
2465
+
2466
+ /**
2467
+ * Creates a stack cache object to store key-value pairs.
2468
+ *
2469
+ * @private
2470
+ * @constructor
2471
+ * @param {Array} [entries] The key-value pairs to cache.
2472
+ */
2473
+ function Stack(entries) {
2474
+ var data = this.__data__ = new ListCache(entries);
2475
+ this.size = data.size;
2476
+ }
2477
+
2478
+ // Add methods to `Stack`.
2479
+ Stack.prototype.clear = stackClear;
2480
+ Stack.prototype['delete'] = stackDelete;
2481
+ Stack.prototype.get = stackGet;
2482
+ Stack.prototype.has = stackHas;
2483
+ Stack.prototype.set = stackSet;
2484
+
2485
+ /** Detect free variable `exports`. */
2486
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
2487
+
2488
+ /** Detect free variable `module`. */
2489
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
2490
+
2491
+ /** Detect the popular CommonJS extension `module.exports`. */
2492
+ var moduleExports = freeModule && freeModule.exports === freeExports;
2493
+
2494
+ /** Built-in value references. */
2495
+ var Buffer = moduleExports ? root.Buffer : undefined;
2496
+ Buffer ? Buffer.allocUnsafe : undefined;
2497
+
2498
+ /**
2499
+ * Creates a clone of `buffer`.
2500
+ *
2501
+ * @private
2502
+ * @param {Buffer} buffer The buffer to clone.
2503
+ * @param {boolean} [isDeep] Specify a deep clone.
2504
+ * @returns {Buffer} Returns the cloned buffer.
2505
+ */
2506
+ function cloneBuffer(buffer, isDeep) {
2507
+ {
2508
+ return buffer.slice();
2509
+ }
2510
+ }
2511
+
2512
+ /**
2513
+ * A specialized version of `_.filter` for arrays without support for
2514
+ * iteratee shorthands.
2515
+ *
2516
+ * @private
2517
+ * @param {Array} [array] The array to iterate over.
2518
+ * @param {Function} predicate The function invoked per iteration.
2519
+ * @returns {Array} Returns the new filtered array.
2520
+ */
2521
+ function arrayFilter(array, predicate) {
2522
+ var index = -1,
2523
+ length = array == null ? 0 : array.length,
2524
+ resIndex = 0,
2525
+ result = [];
2526
+
2527
+ while (++index < length) {
2528
+ var value = array[index];
2529
+ if (predicate(value, index, array)) {
2530
+ result[resIndex++] = value;
2531
+ }
2532
+ }
2533
+ return result;
2534
+ }
2535
+
2536
+ /**
2537
+ * This method returns a new empty array.
2538
+ *
2539
+ * @static
2540
+ * @memberOf _
2541
+ * @since 4.13.0
2542
+ * @category Util
2543
+ * @returns {Array} Returns the new empty array.
2544
+ * @example
2545
+ *
2546
+ * var arrays = _.times(2, _.stubArray);
2547
+ *
2548
+ * console.log(arrays);
2549
+ * // => [[], []]
2550
+ *
2551
+ * console.log(arrays[0] === arrays[1]);
2552
+ * // => false
2553
+ */
2554
+ function stubArray() {
2555
+ return [];
2556
+ }
2557
+
2558
+ /** Used for built-in method references. */
2559
+ var objectProto$1 = Object.prototype;
2560
+
2561
+ /** Built-in value references. */
2562
+ var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
2563
+
2564
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2565
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
2566
+
2567
+ /**
2568
+ * Creates an array of the own enumerable symbols of `object`.
2569
+ *
2570
+ * @private
2571
+ * @param {Object} object The object to query.
2572
+ * @returns {Array} Returns the array of symbols.
2573
+ */
2574
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
2575
+ if (object == null) {
2576
+ return [];
2577
+ }
2578
+ object = Object(object);
2579
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
2580
+ return propertyIsEnumerable.call(object, symbol);
2581
+ });
2582
+ };
2583
+
2584
+ /**
2585
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
2586
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
2587
+ * symbols of `object`.
2588
+ *
2589
+ * @private
2590
+ * @param {Object} object The object to query.
2591
+ * @param {Function} keysFunc The function to get the keys of `object`.
2592
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
2593
+ * @returns {Array} Returns the array of property names and symbols.
2594
+ */
2595
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
2596
+ var result = keysFunc(object);
2597
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
2598
+ }
2599
+
2600
+ /**
2601
+ * Creates an array of own enumerable property names and symbols of `object`.
2602
+ *
2603
+ * @private
2604
+ * @param {Object} object The object to query.
2605
+ * @returns {Array} Returns the array of property names and symbols.
2606
+ */
2607
+ function getAllKeys(object) {
2608
+ return baseGetAllKeys(object, keys, getSymbols);
2609
+ }
2610
+
2611
+ /* Built-in method references that are verified to be native. */
2612
+ var DataView = getNative(root, 'DataView');
2613
+
2614
+ /* Built-in method references that are verified to be native. */
2615
+ var Promise$1 = getNative(root, 'Promise');
2616
+
2617
+ /* Built-in method references that are verified to be native. */
2618
+ var Set$1 = getNative(root, 'Set');
2619
+
2620
+ /** `Object#toString` result references. */
2621
+ var mapTag$3 = '[object Map]',
2622
+ objectTag$1 = '[object Object]',
2623
+ promiseTag = '[object Promise]',
2624
+ setTag$3 = '[object Set]',
2625
+ weakMapTag$1 = '[object WeakMap]';
2626
+
2627
+ var dataViewTag$2 = '[object DataView]';
2628
+
2629
+ /** Used to detect maps, sets, and weakmaps. */
2630
+ var dataViewCtorString = toSource(DataView),
2631
+ mapCtorString = toSource(Map$1),
2632
+ promiseCtorString = toSource(Promise$1),
2633
+ setCtorString = toSource(Set$1),
2634
+ weakMapCtorString = toSource(WeakMap);
2635
+
2636
+ /**
2637
+ * Gets the `toStringTag` of `value`.
2638
+ *
2639
+ * @private
2640
+ * @param {*} value The value to query.
2641
+ * @returns {string} Returns the `toStringTag`.
2642
+ */
2643
+ var getTag = baseGetTag;
2644
+
2645
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
2646
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$2) ||
2647
+ (Map$1 && getTag(new Map$1) != mapTag$3) ||
2648
+ (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
2649
+ (Set$1 && getTag(new Set$1) != setTag$3) ||
2650
+ (WeakMap && getTag(new WeakMap) != weakMapTag$1)) {
2651
+ getTag = function(value) {
2652
+ var result = baseGetTag(value),
2653
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
2654
+ ctorString = Ctor ? toSource(Ctor) : '';
2655
+
2656
+ if (ctorString) {
2657
+ switch (ctorString) {
2658
+ case dataViewCtorString: return dataViewTag$2;
2659
+ case mapCtorString: return mapTag$3;
2660
+ case promiseCtorString: return promiseTag;
2661
+ case setCtorString: return setTag$3;
2662
+ case weakMapCtorString: return weakMapTag$1;
2663
+ }
2664
+ }
2665
+ return result;
2666
+ };
2667
+ }
2668
+
2669
+ /** Used for built-in method references. */
2670
+ var objectProto = Object.prototype;
2671
+
2672
+ /** Used to check objects for own properties. */
2673
+ var hasOwnProperty = objectProto.hasOwnProperty;
2674
+
2675
+ /**
2676
+ * Initializes an array clone.
2677
+ *
2678
+ * @private
2679
+ * @param {Array} array The array to clone.
2680
+ * @returns {Array} Returns the initialized clone.
2681
+ */
2682
+ function initCloneArray(array) {
2683
+ var length = array.length,
2684
+ result = new array.constructor(length);
2685
+
2686
+ // Add properties assigned by `RegExp#exec`.
2687
+ if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
2688
+ result.index = array.index;
2689
+ result.input = array.input;
2690
+ }
2691
+ return result;
2692
+ }
2693
+
2694
+ /** Built-in value references. */
2695
+ var Uint8Array = root.Uint8Array;
2696
+
2697
+ /**
2698
+ * Creates a clone of `arrayBuffer`.
2699
+ *
2700
+ * @private
2701
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2702
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
2703
+ */
2704
+ function cloneArrayBuffer(arrayBuffer) {
2705
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2706
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2707
+ return result;
2708
+ }
2709
+
2710
+ /**
2711
+ * Creates a clone of `dataView`.
2712
+ *
2713
+ * @private
2714
+ * @param {Object} dataView The data view to clone.
2715
+ * @param {boolean} [isDeep] Specify a deep clone.
2716
+ * @returns {Object} Returns the cloned data view.
2717
+ */
2718
+ function cloneDataView(dataView, isDeep) {
2719
+ var buffer = cloneArrayBuffer(dataView.buffer) ;
2720
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2721
+ }
2722
+
2723
+ /** Used to match `RegExp` flags from their coerced string values. */
2724
+ var reFlags = /\w*$/;
2725
+
2726
+ /**
2727
+ * Creates a clone of `regexp`.
2728
+ *
2729
+ * @private
2730
+ * @param {Object} regexp The regexp to clone.
2731
+ * @returns {Object} Returns the cloned regexp.
2732
+ */
2733
+ function cloneRegExp(regexp) {
2734
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2735
+ result.lastIndex = regexp.lastIndex;
2736
+ return result;
2737
+ }
2738
+
2739
+ /** Used to convert symbols to primitives and strings. */
2740
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
2741
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
2742
+
2743
+ /**
2744
+ * Creates a clone of the `symbol` object.
2745
+ *
2746
+ * @private
2747
+ * @param {Object} symbol The symbol object to clone.
2748
+ * @returns {Object} Returns the cloned symbol object.
2749
+ */
2750
+ function cloneSymbol(symbol) {
2751
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2752
+ }
2753
+
2754
+ /**
2755
+ * Creates a clone of `typedArray`.
2756
+ *
2757
+ * @private
2758
+ * @param {Object} typedArray The typed array to clone.
2759
+ * @param {boolean} [isDeep] Specify a deep clone.
2760
+ * @returns {Object} Returns the cloned typed array.
2761
+ */
2762
+ function cloneTypedArray(typedArray, isDeep) {
2763
+ var buffer = cloneArrayBuffer(typedArray.buffer) ;
2764
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2765
+ }
2766
+
2767
+ /** `Object#toString` result references. */
2768
+ var boolTag$1 = '[object Boolean]',
2769
+ dateTag$1 = '[object Date]',
2770
+ mapTag$2 = '[object Map]',
2771
+ numberTag$1 = '[object Number]',
2772
+ regexpTag$1 = '[object RegExp]',
2773
+ setTag$2 = '[object Set]',
2774
+ stringTag$1 = '[object String]',
2775
+ symbolTag$1 = '[object Symbol]';
2776
+
2777
+ var arrayBufferTag$1 = '[object ArrayBuffer]',
2778
+ dataViewTag$1 = '[object DataView]',
2779
+ float32Tag$1 = '[object Float32Array]',
2780
+ float64Tag$1 = '[object Float64Array]',
2781
+ int8Tag$1 = '[object Int8Array]',
2782
+ int16Tag$1 = '[object Int16Array]',
2783
+ int32Tag$1 = '[object Int32Array]',
2784
+ uint8Tag$1 = '[object Uint8Array]',
2785
+ uint8ClampedTag$1 = '[object Uint8ClampedArray]',
2786
+ uint16Tag$1 = '[object Uint16Array]',
2787
+ uint32Tag$1 = '[object Uint32Array]';
2788
+
2789
+ /**
2790
+ * Initializes an object clone based on its `toStringTag`.
2791
+ *
2792
+ * **Note:** This function only supports cloning values with tags of
2793
+ * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
2794
+ *
2795
+ * @private
2796
+ * @param {Object} object The object to clone.
2797
+ * @param {string} tag The `toStringTag` of the object to clone.
2798
+ * @param {boolean} [isDeep] Specify a deep clone.
2799
+ * @returns {Object} Returns the initialized clone.
2800
+ */
2801
+ function initCloneByTag(object, tag, isDeep) {
2802
+ var Ctor = object.constructor;
2803
+ switch (tag) {
2804
+ case arrayBufferTag$1:
2805
+ return cloneArrayBuffer(object);
2806
+
2807
+ case boolTag$1:
2808
+ case dateTag$1:
2809
+ return new Ctor(+object);
2810
+
2811
+ case dataViewTag$1:
2812
+ return cloneDataView(object);
2813
+
2814
+ case float32Tag$1: case float64Tag$1:
2815
+ case int8Tag$1: case int16Tag$1: case int32Tag$1:
2816
+ case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
2817
+ return cloneTypedArray(object);
2818
+
2819
+ case mapTag$2:
2820
+ return new Ctor;
2821
+
2822
+ case numberTag$1:
2823
+ case stringTag$1:
2824
+ return new Ctor(object);
2825
+
2826
+ case regexpTag$1:
2827
+ return cloneRegExp(object);
2828
+
2829
+ case setTag$2:
2830
+ return new Ctor;
2831
+
2832
+ case symbolTag$1:
2833
+ return cloneSymbol(object);
2834
+ }
2835
+ }
2836
+
2837
+ /**
2838
+ * Initializes an object clone.
2839
+ *
2840
+ * @private
2841
+ * @param {Object} object The object to clone.
2842
+ * @returns {Object} Returns the initialized clone.
2843
+ */
2844
+ function initCloneObject(object) {
2845
+ return (typeof object.constructor == 'function' && !isPrototype(object))
2846
+ ? baseCreate(getPrototype(object))
2847
+ : {};
2848
+ }
2849
+
2850
+ /** `Object#toString` result references. */
2851
+ var mapTag$1 = '[object Map]';
2852
+
2853
+ /**
2854
+ * The base implementation of `_.isMap` without Node.js optimizations.
2855
+ *
2856
+ * @private
2857
+ * @param {*} value The value to check.
2858
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
2859
+ */
2860
+ function baseIsMap(value) {
2861
+ return isObjectLike(value) && getTag(value) == mapTag$1;
2862
+ }
2863
+
2864
+ /* Node.js helper references. */
2865
+ var nodeIsMap = nodeUtil && nodeUtil.isMap;
2866
+
2867
+ /**
2868
+ * Checks if `value` is classified as a `Map` object.
2869
+ *
2870
+ * @static
2871
+ * @memberOf _
2872
+ * @since 4.3.0
2873
+ * @category Lang
2874
+ * @param {*} value The value to check.
2875
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
2876
+ * @example
2877
+ *
2878
+ * _.isMap(new Map);
2879
+ * // => true
2880
+ *
2881
+ * _.isMap(new WeakMap);
2882
+ * // => false
2883
+ */
2884
+ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
2885
+
2886
+ /** `Object#toString` result references. */
2887
+ var setTag$1 = '[object Set]';
2888
+
2889
+ /**
2890
+ * The base implementation of `_.isSet` without Node.js optimizations.
2891
+ *
2892
+ * @private
2893
+ * @param {*} value The value to check.
2894
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
2895
+ */
2896
+ function baseIsSet(value) {
2897
+ return isObjectLike(value) && getTag(value) == setTag$1;
2898
+ }
2899
+
2900
+ /* Node.js helper references. */
2901
+ var nodeIsSet = nodeUtil && nodeUtil.isSet;
2902
+
2903
+ /**
2904
+ * Checks if `value` is classified as a `Set` object.
2905
+ *
2906
+ * @static
2907
+ * @memberOf _
2908
+ * @since 4.3.0
2909
+ * @category Lang
2910
+ * @param {*} value The value to check.
2911
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
2912
+ * @example
2913
+ *
2914
+ * _.isSet(new Set);
2915
+ * // => true
2916
+ *
2917
+ * _.isSet(new WeakSet);
2918
+ * // => false
2919
+ */
2920
+ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
2921
+
2922
+ /** `Object#toString` result references. */
2923
+ var argsTag = '[object Arguments]',
2924
+ arrayTag = '[object Array]',
2925
+ boolTag = '[object Boolean]',
2926
+ dateTag = '[object Date]',
2927
+ errorTag = '[object Error]',
2928
+ funcTag = '[object Function]',
2929
+ genTag = '[object GeneratorFunction]',
2930
+ mapTag = '[object Map]',
2931
+ numberTag = '[object Number]',
2932
+ objectTag = '[object Object]',
2933
+ regexpTag = '[object RegExp]',
2934
+ setTag = '[object Set]',
2935
+ stringTag = '[object String]',
2936
+ symbolTag = '[object Symbol]',
2937
+ weakMapTag = '[object WeakMap]';
2938
+
2939
+ var arrayBufferTag = '[object ArrayBuffer]',
2940
+ dataViewTag = '[object DataView]',
2941
+ float32Tag = '[object Float32Array]',
2942
+ float64Tag = '[object Float64Array]',
2943
+ int8Tag = '[object Int8Array]',
2944
+ int16Tag = '[object Int16Array]',
2945
+ int32Tag = '[object Int32Array]',
2946
+ uint8Tag = '[object Uint8Array]',
2947
+ uint8ClampedTag = '[object Uint8ClampedArray]',
2948
+ uint16Tag = '[object Uint16Array]',
2949
+ uint32Tag = '[object Uint32Array]';
2950
+
2951
+ /** Used to identify `toStringTag` values supported by `_.clone`. */
2952
+ var cloneableTags = {};
2953
+ cloneableTags[argsTag] = cloneableTags[arrayTag] =
2954
+ cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
2955
+ cloneableTags[boolTag] = cloneableTags[dateTag] =
2956
+ cloneableTags[float32Tag] = cloneableTags[float64Tag] =
2957
+ cloneableTags[int8Tag] = cloneableTags[int16Tag] =
2958
+ cloneableTags[int32Tag] = cloneableTags[mapTag] =
2959
+ cloneableTags[numberTag] = cloneableTags[objectTag] =
2960
+ cloneableTags[regexpTag] = cloneableTags[setTag] =
2961
+ cloneableTags[stringTag] = cloneableTags[symbolTag] =
2962
+ cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
2963
+ cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
2964
+ cloneableTags[errorTag] = cloneableTags[funcTag] =
2965
+ cloneableTags[weakMapTag] = false;
2966
+
2967
+ /**
2968
+ * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2969
+ * traversed objects.
2970
+ *
2971
+ * @private
2972
+ * @param {*} value The value to clone.
2973
+ * @param {boolean} bitmask The bitmask flags.
2974
+ * 1 - Deep clone
2975
+ * 2 - Flatten inherited properties
2976
+ * 4 - Clone symbols
2977
+ * @param {Function} [customizer] The function to customize cloning.
2978
+ * @param {string} [key] The key of `value`.
2979
+ * @param {Object} [object] The parent object of `value`.
2980
+ * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2981
+ * @returns {*} Returns the cloned value.
2982
+ */
2983
+ function baseClone(value, bitmask, customizer, key, object, stack) {
2984
+ var result;
2985
+ if (result !== undefined) {
2986
+ return result;
2987
+ }
2988
+ if (!isObject(value)) {
2989
+ return value;
2990
+ }
2991
+ var isArr = isArray(value);
2992
+ if (isArr) {
2993
+ result = initCloneArray(value);
2994
+ } else {
2995
+ var tag = getTag(value),
2996
+ isFunc = tag == funcTag || tag == genTag;
2997
+
2998
+ if (isBuffer(value)) {
2999
+ return cloneBuffer(value);
3000
+ }
3001
+ if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
3002
+ result = (isFunc) ? {} : initCloneObject(value);
3003
+ } else {
3004
+ if (!cloneableTags[tag]) {
3005
+ return object ? value : {};
3006
+ }
3007
+ result = initCloneByTag(value, tag);
3008
+ }
3009
+ }
3010
+ // Check for circular references and return its corresponding clone.
3011
+ stack || (stack = new Stack);
3012
+ var stacked = stack.get(value);
3013
+ if (stacked) {
3014
+ return stacked;
3015
+ }
3016
+ stack.set(value, result);
3017
+
3018
+ if (isSet(value)) {
3019
+ value.forEach(function(subValue) {
3020
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
3021
+ });
3022
+ } else if (isMap(value)) {
3023
+ value.forEach(function(subValue, key) {
3024
+ result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
3025
+ });
3026
+ }
3027
+
3028
+ var keysFunc = (getAllKeys)
3029
+ ;
3030
+
3031
+ var props = isArr ? undefined : keysFunc(value);
3032
+ arrayEach(props || value, function(subValue, key) {
3033
+ if (props) {
3034
+ key = subValue;
3035
+ subValue = value[key];
3036
+ }
3037
+ // Recursively populate clone (susceptible to call stack limits).
3038
+ assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
3039
+ });
3040
+ return result;
3041
+ }
3042
+
3043
+ /** Used to compose bitmasks for cloning. */
3044
+ var CLONE_DEEP_FLAG = 1,
3045
+ CLONE_SYMBOLS_FLAG = 4;
3046
+
3047
+ /**
3048
+ * This method is like `_.clone` except that it recursively clones `value`.
3049
+ *
3050
+ * @static
3051
+ * @memberOf _
3052
+ * @since 1.0.0
3053
+ * @category Lang
3054
+ * @param {*} value The value to recursively clone.
3055
+ * @returns {*} Returns the deep cloned value.
3056
+ * @see _.clone
3057
+ * @example
3058
+ *
3059
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
3060
+ *
3061
+ * var deep = _.cloneDeep(objects);
3062
+ * console.log(deep[0] === objects[0]);
3063
+ * // => false
3064
+ */
3065
+ function cloneDeep(value) {
3066
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3067
+ }
3068
+
3069
+ /**
3070
+ * The base implementation of `_.hasIn` without support for deep paths.
3071
+ *
3072
+ * @private
3073
+ * @param {Object} [object] The object to query.
3074
+ * @param {Array|string} key The key to check.
3075
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
3076
+ */
3077
+ function baseHasIn(object, key) {
3078
+ return object != null && key in Object(object);
3079
+ }
3080
+
3081
+ /**
3082
+ * Checks if `path` exists on `object`.
3083
+ *
3084
+ * @private
3085
+ * @param {Object} object The object to query.
3086
+ * @param {Array|string} path The path to check.
3087
+ * @param {Function} hasFunc The function to check properties.
3088
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3089
+ */
3090
+ function hasPath(object, path, hasFunc) {
3091
+ path = castPath(path, object);
3092
+
3093
+ var index = -1,
3094
+ length = path.length,
3095
+ result = false;
3096
+
3097
+ while (++index < length) {
3098
+ var key = toKey(path[index]);
3099
+ if (!(result = object != null && hasFunc(object, key))) {
3100
+ break;
3101
+ }
3102
+ object = object[key];
3103
+ }
3104
+ if (result || ++index != length) {
3105
+ return result;
3106
+ }
3107
+ length = object == null ? 0 : object.length;
3108
+ return !!length && isLength(length) && isIndex(key, length) &&
3109
+ (isArray(object) || isArguments(object));
3110
+ }
3111
+
3112
+ /**
3113
+ * Checks if `path` is a direct or inherited property of `object`.
3114
+ *
3115
+ * @static
3116
+ * @memberOf _
3117
+ * @since 4.0.0
3118
+ * @category Object
3119
+ * @param {Object} object The object to query.
3120
+ * @param {Array|string} path The path to check.
3121
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3122
+ * @example
3123
+ *
3124
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
3125
+ *
3126
+ * _.hasIn(object, 'a');
3127
+ * // => true
3128
+ *
3129
+ * _.hasIn(object, 'a.b');
3130
+ * // => true
3131
+ *
3132
+ * _.hasIn(object, ['a', 'b']);
3133
+ * // => true
3134
+ *
3135
+ * _.hasIn(object, 'b');
3136
+ * // => false
3137
+ */
3138
+ function hasIn(object, path) {
3139
+ return object != null && hasPath(object, path, baseHasIn);
3140
+ }
3141
+
3142
+ /**
3143
+ * The base implementation of `_.set`.
3144
+ *
3145
+ * @private
3146
+ * @param {Object} object The object to modify.
3147
+ * @param {Array|string} path The path of the property to set.
3148
+ * @param {*} value The value to set.
3149
+ * @param {Function} [customizer] The function to customize path creation.
3150
+ * @returns {Object} Returns `object`.
3151
+ */
3152
+ function baseSet(object, path, value, customizer) {
3153
+ if (!isObject(object)) {
3154
+ return object;
3155
+ }
3156
+ path = castPath(path, object);
3157
+
3158
+ var index = -1,
3159
+ length = path.length,
3160
+ lastIndex = length - 1,
3161
+ nested = object;
3162
+
3163
+ while (nested != null && ++index < length) {
3164
+ var key = toKey(path[index]),
3165
+ newValue = value;
3166
+
3167
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
3168
+ return object;
3169
+ }
3170
+
3171
+ if (index != lastIndex) {
3172
+ var objValue = nested[key];
3173
+ newValue = undefined;
3174
+ if (newValue === undefined) {
3175
+ newValue = isObject(objValue)
3176
+ ? objValue
3177
+ : (isIndex(path[index + 1]) ? [] : {});
3178
+ }
3179
+ }
3180
+ assignValue(nested, key, newValue);
3181
+ nested = nested[key];
3182
+ }
3183
+ return object;
3184
+ }
3185
+
3186
+ /**
3187
+ * The base implementation of `_.pickBy` without support for iteratee shorthands.
3188
+ *
3189
+ * @private
3190
+ * @param {Object} object The source object.
3191
+ * @param {string[]} paths The property paths to pick.
3192
+ * @param {Function} predicate The function invoked per property.
3193
+ * @returns {Object} Returns the new object.
3194
+ */
3195
+ function basePickBy(object, paths, predicate) {
3196
+ var index = -1,
3197
+ length = paths.length,
3198
+ result = {};
3199
+
3200
+ while (++index < length) {
3201
+ var path = paths[index],
3202
+ value = baseGet(object, path);
3203
+
3204
+ if (predicate(value, path)) {
3205
+ baseSet(result, castPath(path, object), value);
3206
+ }
3207
+ }
3208
+ return result;
3209
+ }
3210
+
3211
+ /**
3212
+ * The base implementation of `_.pick` without support for individual
3213
+ * property identifiers.
3214
+ *
3215
+ * @private
3216
+ * @param {Object} object The source object.
3217
+ * @param {string[]} paths The property paths to pick.
3218
+ * @returns {Object} Returns the new object.
3219
+ */
3220
+ function basePick(object, paths) {
3221
+ return basePickBy(object, paths, function(value, path) {
3222
+ return hasIn(object, path);
3223
+ });
3224
+ }
3225
+
3226
+ /**
3227
+ * Creates an object composed of the picked `object` properties.
3228
+ *
3229
+ * @static
3230
+ * @since 0.1.0
3231
+ * @memberOf _
3232
+ * @category Object
3233
+ * @param {Object} object The source object.
3234
+ * @param {...(string|string[])} [paths] The property paths to pick.
3235
+ * @returns {Object} Returns the new object.
3236
+ * @example
3237
+ *
3238
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
3239
+ *
3240
+ * _.pick(object, ['a', 'c']);
3241
+ * // => { 'a': 1, 'c': 3 }
3242
+ */
3243
+ var pick = flatRest(function(object, paths) {
3244
+ return object == null ? {} : basePick(object, paths);
3245
+ });
3246
+
3247
+ /**
3248
+ * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
3249
+ * it's created. Arrays are created for missing index properties while objects
3250
+ * are created for all other missing properties. Use `_.setWith` to customize
3251
+ * `path` creation.
3252
+ *
3253
+ * **Note:** This method mutates `object`.
3254
+ *
3255
+ * @static
3256
+ * @memberOf _
3257
+ * @since 3.7.0
3258
+ * @category Object
3259
+ * @param {Object} object The object to modify.
3260
+ * @param {Array|string} path The path of the property to set.
3261
+ * @param {*} value The value to set.
3262
+ * @returns {Object} Returns `object`.
3263
+ * @example
3264
+ *
3265
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
3266
+ *
3267
+ * _.set(object, 'a[0].b.c', 4);
3268
+ * console.log(object.a[0].b.c);
3269
+ * // => 4
3270
+ *
3271
+ * _.set(object, ['x', '0', 'y', 'z'], 5);
3272
+ * console.log(object.x[0].y.z);
3273
+ * // => 5
3274
+ */
3275
+ function set(object, path, value) {
3276
+ return object == null ? object : baseSet(object, path, value);
3277
+ }
3278
+
3279
+ /**
3280
+ * Every GraphQL operation a test triggered that no handler answered, collected across
3281
+ * the run so a new suite shows all the handlers it still needs in one go.
3282
+ */
3283
+ const missingOperations = new Set();
3284
+ /** Records an operation no handler answered, so it shows up in the run's summary of missing handlers. */
3285
+ function captureMissingOperation(name) {
3286
+ missingOperations.add(name);
3287
+ }
3288
+ /** Forgets the recorded missing operations, so one spec's gaps do not bleed into the next. */
3289
+ function clearMissingOperations() {
3290
+ missingOperations.clear();
3291
+ }
3292
+ /**
3293
+ * Request tracking utilities for frontend integration tests.
3294
+ * Allows tests to verify which endpoints were called and with what parameters.
3295
+ */
3296
+ const capturedRequests = {};
3297
+ /** Drops every captured request so the next spec's assertions start from zero. Belongs in the global `afterEach`. */
3298
+ function resetCapturedRequests() {
3299
+ Object.keys(capturedRequests).forEach((key) => delete capturedRequests[key]);
3300
+ }
3301
+ /**
3302
+ * Records that a request reached the mock server, with its URL, params and GraphQL
3303
+ * variables, so a spec can later assert what the app asked for and how often. The
3304
+ * handlers call this. Specs read the results through `snapshotRequests`,
3305
+ * `expectGraphQLCalls` and `lastRequestVariables`.
3306
+ */
3307
+ function captureRequest(name, request, variables) {
3308
+ if (!capturedRequests[name]) {
3309
+ capturedRequests[name] = [];
3310
+ }
3311
+ const url = new URL(request.url);
3312
+ capturedRequests[name].push({
3313
+ url: url.toString(),
3314
+ params: Object.fromEntries(url.searchParams),
3315
+ method: request.method,
3316
+ variables,
3317
+ timestamp: Date.now(),
3318
+ });
3319
+ }
3320
+ /**
3321
+ * Returns what the app sent in its latest call to an operation, for asserting on
3322
+ * the request rather than the response. Two filters can return the same rows, so
3323
+ * checking the rendered result cannot prove which one the app applied. The
3324
+ * variables can.
3325
+ *
3326
+ * @throws {Error} When the operation was never called, or was not a GraphQL
3327
+ * operation and so has no variables.
3328
+ */
3329
+ function lastRequestVariables(operationName) {
3330
+ const calls = capturedRequests[operationName];
3331
+ if (!calls?.length) {
3332
+ const called = Object.keys(capturedRequests).sort().join(', ') || 'none';
3333
+ throw new Error(`No request captured for "${operationName}", so there are no variables to assert on. Operations called: ${called}.`);
3334
+ }
3335
+ const { variables } = calls[calls.length - 1];
3336
+ if (variables === undefined) {
3337
+ throw new Error(`"${operationName}" was captured without variables. Only GraphQL operations record them.`);
3338
+ }
3339
+ return variables;
3340
+ }
3341
+ /** Counts only the calls made between two snapshots, per operation. Operations with no new calls are left out. */
3342
+ function getSnapshotRequestsDiff(baselineRequests, allRequests) {
3343
+ return Object.keys(allRequests).reduce((acc, operationName) => {
3344
+ const baseCount = baselineRequests[operationName] || 0;
3345
+ const currentCount = allRequests[operationName] || 0;
3346
+ const delta = currentCount - baseCount;
3347
+ if (delta > 0) {
3348
+ acc[operationName] = delta;
3349
+ }
3350
+ return acc;
3351
+ }, {});
3352
+ }
3353
+ /** Whether an operation name matches any entry of the forbid list, by exact name or regex. */
3354
+ function isForbiddenOperation(op, forbiddenOperations) {
3355
+ return forbiddenOperations.some((pattern) => {
3356
+ if (pattern instanceof RegExp) {
3357
+ return pattern.test(op);
3358
+ }
3359
+ return op === pattern;
3360
+ });
3361
+ }
3362
+ /**
3363
+ * Captures how many times each operation has been called so far. Take one before
3364
+ * an action and hand it to `expectGraphQLCalls` afterwards to assert on only the
3365
+ * calls that action caused.
3366
+ *
3367
+ * @example
3368
+ * const baselineRequests = snapshotRequests();
3369
+ * // baselineRequests = { getWorkItemsFullEE: 1, projectLabels: 1 }
3370
+ */
3371
+ function snapshotRequests() {
3372
+ return Object.keys(capturedRequests).reduce((acc, operationName) => {
3373
+ acc[operationName] = capturedRequests[operationName].length;
3374
+ return acc;
3375
+ }, {});
3376
+ }
3377
+ /**
3378
+ * Asserts which operations an action triggered since a snapshot: everything in
3379
+ * `expect` must have fired and nothing matching `forbid` may have. Its main use is
3380
+ * proving a mutation updated the Apollo cache in place instead of refetching the
3381
+ * lists around it.
3382
+ *
3383
+ * @throws {Error} Listing everything that fired, when an expected operation is
3384
+ * missing or a forbidden one ran.
3385
+ *
3386
+ * @example
3387
+ * const baselineRequests = snapshotRequests();
3388
+ * clickUpdateButton();
3389
+ * await waitFor(() => {
3390
+ * expectGraphQLCalls(baselineRequests, {
3391
+ * expect: ['workItemUpdate'],
3392
+ * forbid: ['getWorkItemsFullEE', 'projectLabels'],
3393
+ * });
3394
+ * });
3395
+ */
3396
+ function expectGraphQLCalls(baselineRequests, { expect: expectedOperations, forbid: forbiddenOperations }) {
3397
+ const newCalls = getSnapshotRequestsDiff(baselineRequests, snapshotRequests());
3398
+ const actualOperations = Object.keys(newCalls);
3399
+ // First, check that expected operations actually fired
3400
+ const missing = expectedOperations.filter((op) => !actualOperations.includes(op));
3401
+ if (missing.length > 0) {
3402
+ throw new Error(`Expected operations did not fire: [${missing.join(', ')}]\n` +
3403
+ `All operations that fired: [${actualOperations.join(', ')}]`);
3404
+ }
3405
+ // Then, check if any forbidden operations fired (cache misses)
3406
+ const violated = actualOperations.filter((op) => isForbiddenOperation(op, forbiddenOperations));
3407
+ if (violated.length > 0) {
3408
+ // Build a counts map of everything that fired, and the same map with the
3409
+ // forbidden operations removed (what we expected to fire). Comparing them
3410
+ // with a Jest matcher renders a readable red/green diff that highlights the
3411
+ // unexpected calls, instead of dumping the full config and call list.
3412
+ const actualCalls = { ...newCalls };
3413
+ const expectedCalls = Object.fromEntries(Object.entries(newCalls).filter(([op]) => !isForbiddenOperation(op, forbiddenOperations)));
3414
+ const headline = `Unexpected GraphQL call (possible cache miss).\n` +
3415
+ `These operations should have been served from the cache: [${violated.join(', ')}]`;
3416
+ try {
3417
+ expect(actualCalls).toEqual(expectedCalls);
3418
+ }
3419
+ catch (error) {
3420
+ if (error instanceof Error) {
3421
+ error.message = `${headline}\n\n${error.message}`;
3422
+ }
3423
+ throw error;
3424
+ }
3425
+ }
3426
+ }
3427
+
3428
+ const isRecord = (value) => typeof value === 'object' && value !== null;
3429
+ /**
3430
+ * Picks which recorded fixture to serve for a request, based on its variables. An
3431
+ * operation recorded under several filters or pages keeps one row per recording in
3432
+ * a fixture table, and this returns the row that fits the request.
3433
+ *
3434
+ * A request no row fits is a missing fixture: it throws, names the table to add a
3435
+ * row to, and records the miss for the run's summary.
3436
+ *
3437
+ * @param label - How the error message refers to the table, usually the operation name.
3438
+ */
3439
+ function matchFixture(variables, table, label) {
3440
+ const match = table.find((candidate) => candidate.matches(variables));
3441
+ if (!match) {
3442
+ const message = `No ${label} fixture matches ${JSON.stringify(variables)}. Add one to the ${label} fixture table.`;
3443
+ captureMissingOperation(message);
3444
+ throw new Error(message);
3445
+ }
3446
+ return match;
3447
+ }
3448
+ /** `get_commit_list.query.graphql.json` and `rest_work_items_list.json` become `getCommitList` and `restWorkItemsList`. */
3449
+ const operationNameOf = (file) => camelCase(file.replace(/\.(query|mutation)\.graphql\.json$/, '').replace(/\.json$/, ''));
3450
+ /**
3451
+ * Fills in the empty `errors` array a recorded success leaves out, so handlers can
3452
+ * serve the fixture as a complete GraphQL response.
3453
+ */
3454
+ function normaliseGraphqlFixture(input) {
3455
+ return { errors: [], ...input };
3456
+ }
3457
+ /**
3458
+ * Loads a directory of recorded responses so a handler file can refer to each one
3459
+ * by operation name instead of reading JSON by hand. File names become camelCased
3460
+ * keys. GraphQL responses always come back with an `errors` array so handlers can
3461
+ * serve them without checking for it. REST payloads are stored untouched.
3462
+ */
3463
+ function loadFixturesMap(basePath) {
3464
+ const files = readdirSync(basePath).filter((f) => f.endsWith('.json'));
3465
+ const map = {};
3466
+ files.forEach((file) => {
3467
+ const content = JSON.parse(readFileSync(join(basePath, file), 'utf-8'));
3468
+ map[operationNameOf(file)] = isValidGraphqlFixture(content)
3469
+ ? normaliseGraphqlFixture(content)
3470
+ : content;
3471
+ });
3472
+ return map;
3473
+ }
3474
+ /** Whether a value has the shape of a recorded GraphQL response: an object `data` and, if present, an array `errors`. */
3475
+ function isValidGraphqlFixture(fixture) {
3476
+ if (!isRecord(fixture)) {
3477
+ return false;
3478
+ }
3479
+ const hasData = 'data' in fixture;
3480
+ const isValidData = hasData && isRecord(fixture.data);
3481
+ const isValidErrors = !('errors' in fixture) || Array.isArray(fixture.errors);
3482
+ return hasData && isValidData && isValidErrors;
3483
+ }
3484
+ const PAGINATOR_CURSOR_PREFIX = 'fixture-cursor:';
3485
+ const DEFAULT_PAGE_SIZE = 20;
3486
+ const DEFAULT_VARIABLE_NAMES = {
3487
+ after: 'after',
3488
+ before: 'before',
3489
+ first: 'first',
3490
+ last: 'last',
3491
+ };
3492
+ function splitGraphqlId(id) {
3493
+ const match = String(id).match(/^(.*\/)(\d+)$/);
3494
+ return match ? { prefix: match[1], number: Number(match[2]) } : null;
3495
+ }
3496
+ // Opaque ids (e.g. a finding `uuid`) have no number to count up from, so they get a suffix.
3497
+ function idSynthesizer(ids) {
3498
+ const parsed = ids.map(splitGraphqlId);
3499
+ if (parsed.some((entry) => entry === null)) {
3500
+ const templateId = ids[ids.length - 1];
3501
+ return (index) => `${templateId}-${index + 1}`;
3502
+ }
3503
+ const numeric = parsed;
3504
+ const { prefix } = numeric[numeric.length - 1];
3505
+ // Recorded lists are often sorted DESC, so count up from the highest id rather than
3506
+ // the last one, or the new ids collide with recorded nodes.
3507
+ const highestId = Math.max(...numeric.map(({ number }) => number));
3508
+ return (index) => `${prefix}${highestId + index + 1}`;
3509
+ }
3510
+ // A connection lists its items as `nodes`, as Relay-style `edges` wrapping each node, or both.
3511
+ const ITEM_LISTS = [
3512
+ { key: 'nodes', nodeOf: (item) => item },
3513
+ { key: 'edges', nodeOf: (edge) => edge.node },
3514
+ ];
3515
+ function itemListsOf(connection) {
3516
+ if (!isRecord(connection)) {
3517
+ return [];
3518
+ }
3519
+ return ITEM_LISTS.filter(({ key }) => Array.isArray(connection[key]));
3520
+ }
3521
+ function resizeItems(items, itemCount, nodeOf) {
3522
+ if (itemCount <= items.length) {
3523
+ return items.slice(0, itemCount);
3524
+ }
3525
+ const template = items[items.length - 1];
3526
+ const nextId = idSynthesizer(items.map((item) => nodeOf(item).id));
3527
+ const filled = Array.from({ length: itemCount - items.length }, (_, index) => {
3528
+ const clone = cloneDeep(template);
3529
+ const node = nodeOf(clone);
3530
+ node.id = nextId(index);
3531
+ return clone;
3532
+ });
3533
+ return [...items, ...filled];
3534
+ }
3535
+ function validateLookupKey(lookupKey) {
3536
+ if (!lookupKey || typeof lookupKey !== 'string') {
3537
+ throw new Error('Property name must be a non-empty string');
3538
+ }
3539
+ if (lookupKey === 'nodes' || lookupKey === 'edges') {
3540
+ throw new Error(`Property name must be the connection key (e.g. "workItems"), not "${lookupKey}"; its "nodes" or "edges" child is resized`);
3541
+ }
3542
+ }
3543
+ // Calls `callback` with every `lookupKey` value, without descending into a match.
3544
+ function forEachConnection(obj, lookupKey, callback) {
3545
+ if (!isRecord(obj)) {
3546
+ return;
3547
+ }
3548
+ if (lookupKey in obj) {
3549
+ callback(obj[lookupKey]);
3550
+ return;
3551
+ }
3552
+ Object.values(obj).forEach((value) => forEachConnection(value, lookupKey, callback));
3553
+ }
3554
+ // Only writes keys the fixture already selects, so the response shape stays unchanged.
3555
+ function setPageInfo(connection, values) {
3556
+ const { pageInfo } = connection;
3557
+ if (!isRecord(pageInfo)) {
3558
+ return;
3559
+ }
3560
+ Object.assign(pageInfo, pick(values, Object.keys(pageInfo)));
3561
+ }
3562
+ function encodeCursor(index) {
3563
+ return `${PAGINATOR_CURSOR_PREFIX}${index}`;
3564
+ }
3565
+ function decodeCursor(cursor) {
3566
+ const index = String(cursor).startsWith(PAGINATOR_CURSOR_PREFIX)
3567
+ ? Number(String(cursor).slice(PAGINATOR_CURSOR_PREFIX.length))
3568
+ : NaN;
3569
+ if (!Number.isInteger(index)) {
3570
+ const message = `"${cursor}" is not a cursor issued by createFixturePaginator. Serve every page of this connection through the paginator.`;
3571
+ captureMissingOperation(message);
3572
+ throw new Error(message);
3573
+ }
3574
+ return index;
3575
+ }
3576
+ // Reads the operation's own variable names into one `{ after, before, first, last }` request.
3577
+ function readPageRequest(variables, variableNames) {
3578
+ return Object.fromEntries(Object.entries(variableNames).map(([name, variableName]) => [name, variables[variableName]]));
3579
+ }
3580
+ function pageRange({ after, before, first, last }, { totalCount, pageSize }) {
3581
+ if (before) {
3582
+ const endIndex = decodeCursor(before);
3583
+ return { startIndex: Math.max(0, endIndex - (last ?? pageSize)), endIndex };
3584
+ }
3585
+ const startIndex = after ? decodeCursor(after) + 1 : 0;
3586
+ return { startIndex, endIndex: Math.min(totalCount, startIndex + (first ?? pageSize)) };
3587
+ }
3588
+ /* eslint-disable no-param-reassign */
3589
+ function sliceConnection(connection, itemLists, { startIndex, endIndex }) {
3590
+ itemLists.forEach(({ key }) => {
3591
+ connection[key] = connection[key].slice(startIndex, endIndex);
3592
+ });
3593
+ // An edge cursor must match pageInfo, or following it would fail to decode.
3594
+ const { edges } = connection;
3595
+ if (Array.isArray(edges)) {
3596
+ edges.forEach((edge, index) => {
3597
+ if (isRecord(edge) && 'cursor' in edge) {
3598
+ edge.cursor = encodeCursor(startIndex + index);
3599
+ }
3600
+ });
3601
+ }
3602
+ }
3603
+ /* eslint-enable no-param-reassign */
3604
+ function pageInfoFor({ startIndex, endIndex }, totalCount) {
3605
+ const isEmpty = endIndex <= startIndex;
3606
+ return {
3607
+ hasNextPage: endIndex < totalCount,
3608
+ hasPreviousPage: startIndex > 0,
3609
+ startCursor: isEmpty ? null : encodeCursor(startIndex),
3610
+ endCursor: isEmpty ? null : encodeCursor(endIndex - 1),
3611
+ };
3612
+ }
3613
+ // Main consumers are below
3614
+ /**
3615
+ * Turns a recorded success into an error response, for specs that cover how the UI
3616
+ * reacts when the backend rejects a request. The result carries the given messages
3617
+ * and no data. The original fixture is left untouched.
3618
+ *
3619
+ * @throws {Error} If `errors` is not an array of strings.
3620
+ */
3621
+ function setFixtureErrors(fixture, errors) {
3622
+ if (!isValidGraphqlFixture(fixture)) {
3623
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3624
+ }
3625
+ if (!errors || !Array.isArray(errors) || errors.some((e) => typeof e !== 'string')) {
3626
+ throw new Error('Errors must be an array of error messages');
3627
+ }
3628
+ const clone = cloneDeep(fixture);
3629
+ Object.assign(clone, {
3630
+ errors: errors.map((message) => ({ message })),
3631
+ data: {},
3632
+ });
3633
+ return clone;
3634
+ }
3635
+ /**
3636
+ * Produces a copy of a fixture with one value changed, so a spec can describe the
3637
+ * state it needs ("this item is confidential") instead of maintaining a second
3638
+ * recording.
3639
+ *
3640
+ * Name the key to change and the first occurrence in the data is updated. When the
3641
+ * same key appears in more than one place (an `awardEmoji` connection and an
3642
+ * `awardEmoji` permission, say), pass `{ path }` with a lodash path from
3643
+ * `fixture.data` to pick one exactly.
3644
+ *
3645
+ * @throws {Error} If `selector` is not a non-empty string or a `{ path }` object.
3646
+ */
3647
+ function setFixtureData(fixture, selector, data) {
3648
+ if (!isValidGraphqlFixture(fixture)) {
3649
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3650
+ }
3651
+ const path = typeof selector === 'object' && selector !== null ? selector.path : null;
3652
+ const lookupKey = typeof selector === 'string' ? selector : null;
3653
+ if (!path && !lookupKey) {
3654
+ throw new Error('Selector must be a non-empty key name or an object with a "path"');
3655
+ }
3656
+ const clone = cloneDeep(fixture);
3657
+ let found = false;
3658
+ if (path) {
3659
+ set(clone.data, path, data);
3660
+ return clone;
3661
+ }
3662
+ function updateData(obj) {
3663
+ if (isRecord(obj)) {
3664
+ if (lookupKey in obj) {
3665
+ // eslint-disable-next-line no-param-reassign
3666
+ obj[lookupKey] = data;
3667
+ found = true;
3668
+ }
3669
+ else {
3670
+ Object.values(obj).forEach(updateData);
3671
+ }
3672
+ }
3673
+ }
3674
+ updateData(clone.data);
3675
+ if (!found) {
3676
+ throw new Error(`Property "${lookupKey}" was not found in the fixture data; check the key for typos`);
3677
+ }
3678
+ return clone;
3679
+ }
3680
+ /**
3681
+ * Produces a copy of a fixture whose connection holds exactly `itemCount` items, for
3682
+ * specs that need an empty list, a single row or more rows than were recorded.
3683
+ * Extra items are cloned from the existing ones, and a scalar count field such as
3684
+ * `count` is kept in step. Count-only connections just get the new count.
3685
+ *
3686
+ * @throws {Error} If the fixture, key or count is invalid, or the connection has no
3687
+ * item to clone from.
3688
+ */
3689
+ function setFixtureItemsCount({ fixture, lookupKey, itemCount, countKey = 'count', }) {
3690
+ if (!isValidGraphqlFixture(fixture)) {
3691
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3692
+ }
3693
+ validateLookupKey(lookupKey);
3694
+ if (typeof itemCount !== 'number' || itemCount < 0) {
3695
+ throw new Error('Item count must be a non-negative number');
3696
+ }
3697
+ const clone = cloneDeep(fixture);
3698
+ forEachConnection(clone, lookupKey, (connection) => {
3699
+ const itemLists = itemListsOf(connection);
3700
+ const hasCount = isRecord(connection) && countKey in connection;
3701
+ if (!itemLists.length && !hasCount) {
3702
+ throw new Error(`Property "${lookupKey}" must be a connection with a "nodes" or "edges" array or a "${countKey}" field and cannot be resized`);
3703
+ }
3704
+ // Either branch above proves `connection` is an object.
3705
+ const target = connection;
3706
+ itemLists.forEach(({ key, nodeOf }) => {
3707
+ const items = target[key];
3708
+ if (items.length === 0 && itemCount > 0) {
3709
+ throw new Error(`Property "${lookupKey}.${key}" is empty; cannot synthesize items without a template`);
3710
+ }
3711
+ target[key] = resizeItems(items, itemCount, nodeOf);
3712
+ });
3713
+ if (hasCount) {
3714
+ target[countKey] = itemCount;
3715
+ }
3716
+ const emptyCursors = itemCount === 0 ? { startCursor: null, endCursor: null } : {};
3717
+ setPageInfo(target, { hasNextPage: false, hasPreviousPage: false, ...emptyCursors });
3718
+ });
3719
+ return clone;
3720
+ }
3721
+ /**
3722
+ * Lets one recording stand in for every page of a paginated list, so a spec can
3723
+ * exercise "load more" and cursor navigation without recording each page. The
3724
+ * returned function takes the fixture and the request variables and serves the
3725
+ * page the request asked for. Use `setFixtureItemsCount` first to decide how many
3726
+ * items the full list holds.
3727
+ *
3728
+ * Cursors are made up here, so a cursor copied from a real recording is rejected
3729
+ * instead of quietly serving the first page.
3730
+ *
3731
+ * @throws {Error} If `lookupKey` is invalid.
3732
+ *
3733
+ * @example
3734
+ * const paginateWorkItems = createFixturePaginator({ lookupKey: 'workItems' });
3735
+ * paginateWorkItems(getActiveVariant('getWorkItemsFullEE') ?? base, variables);
3736
+ */
3737
+ function createFixturePaginator({ lookupKey, variableNames = {}, pageSize = DEFAULT_PAGE_SIZE, countKey = 'count', }) {
3738
+ validateLookupKey(lookupKey);
3739
+ const names = { ...DEFAULT_VARIABLE_NAMES, ...variableNames };
3740
+ return (fixture, variables = {}) => {
3741
+ if (!isValidGraphqlFixture(fixture)) {
3742
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3743
+ }
3744
+ const response = cloneDeep(fixture);
3745
+ const request = readPageRequest(variables, names);
3746
+ let foundConnection = false;
3747
+ forEachConnection(response.data, lookupKey, (connection) => {
3748
+ const itemLists = itemListsOf(connection);
3749
+ if (!itemLists.length) {
3750
+ throw new Error(`Property "${lookupKey}" must be a connection with a "nodes" or "edges" array`);
3751
+ }
3752
+ foundConnection = true;
3753
+ // A non-empty `itemLists` proves `connection` is an object.
3754
+ const target = connection;
3755
+ const totalCount = target[itemLists[0].key].length;
3756
+ const range = pageRange(request, { totalCount, pageSize });
3757
+ sliceConnection(target, itemLists, range);
3758
+ if (countKey in target) {
3759
+ target[countKey] = totalCount;
3760
+ }
3761
+ setPageInfo(target, pageInfoFor(range, totalCount));
3762
+ });
3763
+ if (!foundConnection) {
3764
+ throw new Error(`Property "${lookupKey}" was not found in the fixture data; check the key for typos`);
3765
+ }
3766
+ return response;
3767
+ };
3768
+ }
3769
+
3770
+ const UPPER_SNAKE_CASE_RE = /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/;
3771
+ const variantRegistry = new Map();
3772
+ /**
3773
+ * Switches an operation to one of its variants by name. Specs should use
3774
+ * `setQueryVariant` instead, which has the names checked by the type system. This
3775
+ * exists for the rare shared helper that receives the variant key as a runtime value.
3776
+ */
3777
+ function activateVariant(query, variantKey) {
3778
+ const entry = variantRegistry.get(query);
3779
+ if (!entry) {
3780
+ throw new Error(`activateVariant: no variants registered for query "${query}". ` +
3781
+ 'Did you forget to import the variant file?');
3782
+ }
3783
+ if (!(variantKey in entry.variants)) {
3784
+ const available = Object.keys(entry.variants).join(', ');
3785
+ throw new Error(`activateVariant: unknown variant "${variantKey}" for query "${query}". Available: ${available}`);
3786
+ }
3787
+ entry.active = variantKey;
3788
+ }
3789
+ function registerVariants({ caller, query, variants, normalise, }) {
3790
+ if (!query || typeof query !== 'string') {
3791
+ throw new Error(`${caller}: "query" must be a non-empty string`);
3792
+ }
3793
+ if (!variants || typeof variants !== 'object' || Array.isArray(variants)) {
3794
+ throw new Error(`${caller}: "variants" must be a plain object`);
3795
+ }
3796
+ if (!('BASE' in variants)) {
3797
+ throw new Error(`${caller}: "variants.BASE" is required for query "${query}". ` +
3798
+ 'BASE is the default fixture served when no variant is active.');
3799
+ }
3800
+ const normalised = {};
3801
+ for (const [key, value] of Object.entries(variants)) {
3802
+ if (!UPPER_SNAKE_CASE_RE.test(key)) {
3803
+ throw new Error(`${caller}: variant key "${key}" must be UPPER_SNAKE_CASE (e.g. BASE, WITH_ERROR, EMPTY_LIST).`);
3804
+ }
3805
+ normalised[key] = normalise(key, value);
3806
+ }
3807
+ if (variantRegistry.has(query)) {
3808
+ throw new Error(`${caller}: variants for query "${query}" are already registered. ` +
3809
+ 'Each query must be registered exactly once; check for a duplicate or copy-pasted variant file.');
3810
+ }
3811
+ // Tag the returned object with its query name (non-enumerable so the object
3812
+ // still iterates as the pure variants map) so setQueryVariant can resolve the
3813
+ // query from the constant a spec passes in.
3814
+ Object.defineProperty(normalised, 'query', { value: query });
3815
+ const frozen = Object.freeze(normalised);
3816
+ variantRegistry.set(query, { variants: frozen, active: 'BASE' });
3817
+ return frozen;
3818
+ }
3819
+ /**
3820
+ * Declares the alternate responses an operation can serve, so a spec can switch
3821
+ * between them with one call instead of wiring a handler per case. Every variant
3822
+ * file calls this and exports the result as its default export. `BASE` is required:
3823
+ * it is what the handler serves until a spec asks for something else, and the
3824
+ * recording the other variants are derived from.
3825
+ *
3826
+ * @returns The validated variants object (frozen).
3827
+ *
3828
+ * @example
3829
+ * export default defineFixtureVariants({
3830
+ * query: 'namespaceWorkItem',
3831
+ * variants: {
3832
+ * BASE: namespaceWorkItemFixture,
3833
+ * WITH_ERROR: setFixtureErrors(cloneDeep(namespaceWorkItemFixture), ['Something went wrong']),
3834
+ * },
3835
+ * });
3836
+ */
3837
+ function defineFixtureVariants({ query, variants, }) {
3838
+ return registerVariants({
3839
+ caller: 'defineFixtureVariants',
3840
+ query,
3841
+ variants,
3842
+ normalise: (key, value) => {
3843
+ const fixture = normaliseGraphqlFixture(value);
3844
+ if (!isValidGraphqlFixture(fixture)) {
3845
+ throw new Error(`defineFixtureVariants: variant "${key}" for query "${query}" is not a valid GraphQL fixture. ` +
3846
+ 'Each variant must be an object with "data" (object) and "errors" (array) fields.');
3847
+ }
3848
+ return fixture;
3849
+ },
3850
+ });
3851
+ }
3852
+ /**
3853
+ * The REST counterpart of `defineFixtureVariants`. Each variant is a raw JSON body
3854
+ * served as is. Attach the result to the endpoint as its `variants` and
3855
+ * `buildHandlers` serves whichever one is active. `query` is only the registry key.
3856
+ * By convention it is the fixture's camelCase name, such as `restWorkItemsList`.
3857
+ *
3858
+ * @returns The validated variants object (frozen).
3859
+ */
3860
+ function defineRestFixtureVariants({ query, variants, }) {
3861
+ return registerVariants({
3862
+ caller: 'defineRestFixtureVariants',
3863
+ query,
3864
+ variants,
3865
+ normalise: (key, value) => {
3866
+ if (!value || typeof value !== 'object') {
3867
+ throw new Error(`defineRestFixtureVariants: variant "${key}" for query "${query}" is not a valid REST fixture. ` +
3868
+ 'Each variant must be a JSON body (an array or an object).');
3869
+ }
3870
+ return value;
3871
+ },
3872
+ });
3873
+ }
3874
+ /**
3875
+ * Puts an operation into one of its states for the rest of the test, written as
3876
+ * `setQueryVariant(namespaceWorkItem).archived()`. Pass the variant file's default
3877
+ * export and you get one method per variant, named after its key, so a typo in a
3878
+ * variant name is a type error and autocomplete lists only this operation's states.
3879
+ */
3880
+ function setQueryVariant(queryConstant) {
3881
+ const query = queryConstant?.query;
3882
+ const entry = query && variantRegistry.get(query);
3883
+ if (!entry) {
3884
+ throw new Error('setQueryVariant: expected a query constant from defineFixtureVariants ' +
3885
+ '(a variant file default export). Did you pass a variant key string by mistake?');
3886
+ }
3887
+ const activators = Object.create(null);
3888
+ for (const key of Object.keys(entry.variants)) {
3889
+ activators[camelCase(key)] = () => activateVariant(query, key);
3890
+ }
3891
+ return activators;
3892
+ }
3893
+ /** Looks up one of an operation's variants by key. Null when nothing is registered under that pair. */
3894
+ function getVariant(query, variantKey) {
3895
+ const entry = variantRegistry.get(query);
3896
+ if (!entry)
3897
+ return null;
3898
+ return entry.variants[variantKey] ?? null;
3899
+ }
3900
+ /**
3901
+ * Tells a handler whether a spec has switched this operation to a variant. Returns
3902
+ * that variant when it has, and null while the operation sits at `BASE`, so the
3903
+ * handler can fall back to its own default, often a fixture table lookup.
3904
+ */
3905
+ function getActiveVariant(query) {
3906
+ const entry = variantRegistry.get(query);
3907
+ if (!entry || entry.active === 'BASE')
3908
+ return null;
3909
+ return entry.variants[entry.active];
3910
+ }
3911
+ /** Returns every operation to `BASE` so one spec's state never leaks into the next. Call it from `afterEach`. */
3912
+ function resetAllVariants() {
3913
+ for (const entry of variantRegistry.values()) {
3914
+ entry.active = 'BASE';
3915
+ }
3916
+ }
3917
+ /**
3918
+ * Lists every registered operation and its variant keys, without the fixtures
3919
+ * themselves. Meant for tooling that generates a manifest of available variants,
3920
+ * not for use inside a test.
3921
+ */
3922
+ function dumpRegistry() {
3923
+ const out = {};
3924
+ for (const [query, entry] of variantRegistry) {
3925
+ out[query] = Object.keys(entry.variants).sort();
3926
+ }
3927
+ return out;
3928
+ }
3929
+
3930
+ /**
3931
+ * Assembles the MSW handlers for a test run from the feature handlers and REST
3932
+ * endpoints a consumer registers. Every answered request is captured for
3933
+ * assertions. A GraphQL operation nobody answers is recorded as missing and fails
3934
+ * with a 400, and an unknown REST URL is logged and fails the same way, so a gap in
3935
+ * the handlers surfaces as a loud test failure instead of a silent empty response.
3936
+ */
3937
+ function buildHandlers(allFeatureHandlers, allRestEndpoints) {
3938
+ const restEndpointsHandlers = allRestEndpoints.map((endpoint) => http[endpoint.method](endpoint.path, ({ request }) => {
3939
+ const operationName = endpoint.name || `REST:${endpoint.method}:${endpoint.path}`;
3940
+ captureRequest(operationName, request);
3941
+ const response = endpoint.variants
3942
+ ? (getActiveVariant(endpoint.variants.query) ?? endpoint.variants.BASE)
3943
+ : endpoint.response;
3944
+ return HttpResponse.json(response, { headers: endpoint.headers });
3945
+ }));
3946
+ return [
3947
+ graphql.operation(({ operationName, variables, request }) => {
3948
+ for (const handler of allFeatureHandlers) {
3949
+ const result = handler({ operationName, variables });
3950
+ if (result) {
3951
+ captureRequest(operationName, request, variables);
3952
+ return result;
3953
+ }
3954
+ }
3955
+ captureMissingOperation(operationName);
3956
+ return new HttpResponse(null, { status: 400 });
3957
+ }),
3958
+ ...restEndpointsHandlers,
3959
+ http.get('*', ({ request }) => {
3960
+ // eslint-disable-next-line no-console
3961
+ console.log(`Unhandled url for REST endpoint: ${request.url}`);
3962
+ return new HttpResponse(null, { status: 400 });
3963
+ }),
3964
+ ];
3965
+ }
3966
+
3967
+ /** Builds the MSW node server for a test run from the consumer's feature handlers and REST endpoints. */
3968
+ const createServer = (featureHandlers, restEndpoints) => setupServer(...buildHandlers(featureHandlers, restEndpoints));
3969
+
3970
+ export { setQueryVariant as A, snapshotRequests as B, activateVariant as a, baseMetadata as b, buildHandlers as c, captureMissingOperation as d, captureRequest as e, capturedRequests as f, clearMissingOperations as g, createFixturePaginator as h, createServer as i, defineFixtureVariants as j, defineRestFixtureVariants as k, dumpRegistry as l, expectGraphQLCalls as m, getActiveVariant as n, getVariant as o, isValidGraphqlFixture as p, lastRequestVariables as q, loadFixturesMap as r, matchFixture as s, missingOperations as t, normaliseGraphqlFixture as u, resetAllVariants as v, resetCapturedRequests as w, setFixtureData as x, setFixtureErrors as y, setFixtureItemsCount as z };