@pie-element/multiple-choice 12.2.0-next.6 → 12.2.0-next.7

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.
@@ -0,0 +1,3045 @@
1
+ /** Detect free variable `global` from Node.js. */
2
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
3
+
4
+ var freeGlobal$1 = freeGlobal;
5
+
6
+ /** Detect free variable `self`. */
7
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
8
+
9
+ /** Used as a reference to the global object. */
10
+ var root = freeGlobal$1 || freeSelf || Function('return this')();
11
+
12
+ var root$1 = root;
13
+
14
+ /** Built-in value references. */
15
+ var Symbol = root$1.Symbol;
16
+
17
+ var Symbol$1 = Symbol;
18
+
19
+ /** Used for built-in method references. */
20
+ var objectProto$c = Object.prototype;
21
+
22
+ /** Used to check objects for own properties. */
23
+ var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
24
+
25
+ /**
26
+ * Used to resolve the
27
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
28
+ * of values.
29
+ */
30
+ var nativeObjectToString$1 = objectProto$c.toString;
31
+
32
+ /** Built-in value references. */
33
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
34
+
35
+ /**
36
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
37
+ *
38
+ * @private
39
+ * @param {*} value The value to query.
40
+ * @returns {string} Returns the raw `toStringTag`.
41
+ */
42
+ function getRawTag(value) {
43
+ var isOwn = hasOwnProperty$9.call(value, symToStringTag$1),
44
+ tag = value[symToStringTag$1];
45
+
46
+ try {
47
+ value[symToStringTag$1] = undefined;
48
+ var unmasked = true;
49
+ } catch (e) {}
50
+
51
+ var result = nativeObjectToString$1.call(value);
52
+ if (unmasked) {
53
+ if (isOwn) {
54
+ value[symToStringTag$1] = tag;
55
+ } else {
56
+ delete value[symToStringTag$1];
57
+ }
58
+ }
59
+ return result;
60
+ }
61
+
62
+ /** Used for built-in method references. */
63
+ var objectProto$b = Object.prototype;
64
+
65
+ /**
66
+ * Used to resolve the
67
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
68
+ * of values.
69
+ */
70
+ var nativeObjectToString = objectProto$b.toString;
71
+
72
+ /**
73
+ * Converts `value` to a string using `Object.prototype.toString`.
74
+ *
75
+ * @private
76
+ * @param {*} value The value to convert.
77
+ * @returns {string} Returns the converted string.
78
+ */
79
+ function objectToString(value) {
80
+ return nativeObjectToString.call(value);
81
+ }
82
+
83
+ /** `Object#toString` result references. */
84
+ var nullTag = '[object Null]',
85
+ undefinedTag = '[object Undefined]';
86
+
87
+ /** Built-in value references. */
88
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
89
+
90
+ /**
91
+ * The base implementation of `getTag` without fallbacks for buggy environments.
92
+ *
93
+ * @private
94
+ * @param {*} value The value to query.
95
+ * @returns {string} Returns the `toStringTag`.
96
+ */
97
+ function baseGetTag(value) {
98
+ if (value == null) {
99
+ return value === undefined ? undefinedTag : nullTag;
100
+ }
101
+ return (symToStringTag && symToStringTag in Object(value))
102
+ ? getRawTag(value)
103
+ : objectToString(value);
104
+ }
105
+
106
+ /**
107
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
108
+ * and has a `typeof` result of "object".
109
+ *
110
+ * @static
111
+ * @memberOf _
112
+ * @since 4.0.0
113
+ * @category Lang
114
+ * @param {*} value The value to check.
115
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
116
+ * @example
117
+ *
118
+ * _.isObjectLike({});
119
+ * // => true
120
+ *
121
+ * _.isObjectLike([1, 2, 3]);
122
+ * // => true
123
+ *
124
+ * _.isObjectLike(_.noop);
125
+ * // => false
126
+ *
127
+ * _.isObjectLike(null);
128
+ * // => false
129
+ */
130
+ function isObjectLike(value) {
131
+ return value != null && typeof value == 'object';
132
+ }
133
+
134
+ /** `Object#toString` result references. */
135
+ var symbolTag$1 = '[object Symbol]';
136
+
137
+ /**
138
+ * Checks if `value` is classified as a `Symbol` primitive or object.
139
+ *
140
+ * @static
141
+ * @memberOf _
142
+ * @since 4.0.0
143
+ * @category Lang
144
+ * @param {*} value The value to check.
145
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
146
+ * @example
147
+ *
148
+ * _.isSymbol(Symbol.iterator);
149
+ * // => true
150
+ *
151
+ * _.isSymbol('abc');
152
+ * // => false
153
+ */
154
+ function isSymbol(value) {
155
+ return typeof value == 'symbol' ||
156
+ (isObjectLike(value) && baseGetTag(value) == symbolTag$1);
157
+ }
158
+
159
+ /**
160
+ * A specialized version of `_.map` for arrays without support for iteratee
161
+ * shorthands.
162
+ *
163
+ * @private
164
+ * @param {Array} [array] The array to iterate over.
165
+ * @param {Function} iteratee The function invoked per iteration.
166
+ * @returns {Array} Returns the new mapped array.
167
+ */
168
+ function arrayMap(array, iteratee) {
169
+ var index = -1,
170
+ length = array == null ? 0 : array.length,
171
+ result = Array(length);
172
+
173
+ while (++index < length) {
174
+ result[index] = iteratee(array[index], index, array);
175
+ }
176
+ return result;
177
+ }
178
+
179
+ /**
180
+ * Checks if `value` is classified as an `Array` object.
181
+ *
182
+ * @static
183
+ * @memberOf _
184
+ * @since 0.1.0
185
+ * @category Lang
186
+ * @param {*} value The value to check.
187
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
188
+ * @example
189
+ *
190
+ * _.isArray([1, 2, 3]);
191
+ * // => true
192
+ *
193
+ * _.isArray(document.body.children);
194
+ * // => false
195
+ *
196
+ * _.isArray('abc');
197
+ * // => false
198
+ *
199
+ * _.isArray(_.noop);
200
+ * // => false
201
+ */
202
+ var isArray = Array.isArray;
203
+
204
+ var isArray$1 = isArray;
205
+
206
+ /** Used as references for various `Number` constants. */
207
+ var INFINITY$1 = 1 / 0;
208
+
209
+ /** Used to convert symbols to primitives and strings. */
210
+ var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined,
211
+ symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
212
+
213
+ /**
214
+ * The base implementation of `_.toString` which doesn't convert nullish
215
+ * values to empty strings.
216
+ *
217
+ * @private
218
+ * @param {*} value The value to process.
219
+ * @returns {string} Returns the string.
220
+ */
221
+ function baseToString(value) {
222
+ // Exit early for strings to avoid a performance hit in some environments.
223
+ if (typeof value == 'string') {
224
+ return value;
225
+ }
226
+ if (isArray$1(value)) {
227
+ // Recursively convert values (susceptible to call stack limits).
228
+ return arrayMap(value, baseToString) + '';
229
+ }
230
+ if (isSymbol(value)) {
231
+ return symbolToString ? symbolToString.call(value) : '';
232
+ }
233
+ var result = (value + '');
234
+ return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
235
+ }
236
+
237
+ /**
238
+ * Checks if `value` is the
239
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
240
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
241
+ *
242
+ * @static
243
+ * @memberOf _
244
+ * @since 0.1.0
245
+ * @category Lang
246
+ * @param {*} value The value to check.
247
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
248
+ * @example
249
+ *
250
+ * _.isObject({});
251
+ * // => true
252
+ *
253
+ * _.isObject([1, 2, 3]);
254
+ * // => true
255
+ *
256
+ * _.isObject(_.noop);
257
+ * // => true
258
+ *
259
+ * _.isObject(null);
260
+ * // => false
261
+ */
262
+ function isObject(value) {
263
+ var type = typeof value;
264
+ return value != null && (type == 'object' || type == 'function');
265
+ }
266
+
267
+ /** `Object#toString` result references. */
268
+ var asyncTag = '[object AsyncFunction]',
269
+ funcTag$1 = '[object Function]',
270
+ genTag = '[object GeneratorFunction]',
271
+ proxyTag = '[object Proxy]';
272
+
273
+ /**
274
+ * Checks if `value` is classified as a `Function` object.
275
+ *
276
+ * @static
277
+ * @memberOf _
278
+ * @since 0.1.0
279
+ * @category Lang
280
+ * @param {*} value The value to check.
281
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
282
+ * @example
283
+ *
284
+ * _.isFunction(_);
285
+ * // => true
286
+ *
287
+ * _.isFunction(/abc/);
288
+ * // => false
289
+ */
290
+ function isFunction(value) {
291
+ if (!isObject(value)) {
292
+ return false;
293
+ }
294
+ // The use of `Object#toString` avoids issues with the `typeof` operator
295
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
296
+ var tag = baseGetTag(value);
297
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
298
+ }
299
+
300
+ /** Used to detect overreaching core-js shims. */
301
+ var coreJsData = root$1['__core-js_shared__'];
302
+
303
+ var coreJsData$1 = coreJsData;
304
+
305
+ /** Used to detect methods masquerading as native. */
306
+ var maskSrcKey = (function() {
307
+ var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
308
+ return uid ? ('Symbol(src)_1.' + uid) : '';
309
+ }());
310
+
311
+ /**
312
+ * Checks if `func` has its source masked.
313
+ *
314
+ * @private
315
+ * @param {Function} func The function to check.
316
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
317
+ */
318
+ function isMasked(func) {
319
+ return !!maskSrcKey && (maskSrcKey in func);
320
+ }
321
+
322
+ /** Used for built-in method references. */
323
+ var funcProto$1 = Function.prototype;
324
+
325
+ /** Used to resolve the decompiled source of functions. */
326
+ var funcToString$1 = funcProto$1.toString;
327
+
328
+ /**
329
+ * Converts `func` to its source code.
330
+ *
331
+ * @private
332
+ * @param {Function} func The function to convert.
333
+ * @returns {string} Returns the source code.
334
+ */
335
+ function toSource(func) {
336
+ if (func != null) {
337
+ try {
338
+ return funcToString$1.call(func);
339
+ } catch (e) {}
340
+ try {
341
+ return (func + '');
342
+ } catch (e) {}
343
+ }
344
+ return '';
345
+ }
346
+
347
+ /**
348
+ * Used to match `RegExp`
349
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
350
+ */
351
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
352
+
353
+ /** Used to detect host constructors (Safari). */
354
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
355
+
356
+ /** Used for built-in method references. */
357
+ var funcProto = Function.prototype,
358
+ objectProto$a = Object.prototype;
359
+
360
+ /** Used to resolve the decompiled source of functions. */
361
+ var funcToString = funcProto.toString;
362
+
363
+ /** Used to check objects for own properties. */
364
+ var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
365
+
366
+ /** Used to detect if a method is native. */
367
+ var reIsNative = RegExp('^' +
368
+ funcToString.call(hasOwnProperty$8).replace(reRegExpChar, '\\$&')
369
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
370
+ );
371
+
372
+ /**
373
+ * The base implementation of `_.isNative` without bad shim checks.
374
+ *
375
+ * @private
376
+ * @param {*} value The value to check.
377
+ * @returns {boolean} Returns `true` if `value` is a native function,
378
+ * else `false`.
379
+ */
380
+ function baseIsNative(value) {
381
+ if (!isObject(value) || isMasked(value)) {
382
+ return false;
383
+ }
384
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
385
+ return pattern.test(toSource(value));
386
+ }
387
+
388
+ /**
389
+ * Gets the value at `key` of `object`.
390
+ *
391
+ * @private
392
+ * @param {Object} [object] The object to query.
393
+ * @param {string} key The key of the property to get.
394
+ * @returns {*} Returns the property value.
395
+ */
396
+ function getValue(object, key) {
397
+ return object == null ? undefined : object[key];
398
+ }
399
+
400
+ /**
401
+ * Gets the native function at `key` of `object`.
402
+ *
403
+ * @private
404
+ * @param {Object} object The object to query.
405
+ * @param {string} key The key of the method to get.
406
+ * @returns {*} Returns the function if it's native, else `undefined`.
407
+ */
408
+ function getNative(object, key) {
409
+ var value = getValue(object, key);
410
+ return baseIsNative(value) ? value : undefined;
411
+ }
412
+
413
+ /* Built-in method references that are verified to be native. */
414
+ var WeakMap = getNative(root$1, 'WeakMap');
415
+
416
+ var WeakMap$1 = WeakMap;
417
+
418
+ /**
419
+ * Copies the values of `source` to `array`.
420
+ *
421
+ * @private
422
+ * @param {Array} source The array to copy values from.
423
+ * @param {Array} [array=[]] The array to copy values to.
424
+ * @returns {Array} Returns `array`.
425
+ */
426
+ function copyArray(source, array) {
427
+ var index = -1,
428
+ length = source.length;
429
+
430
+ array || (array = Array(length));
431
+ while (++index < length) {
432
+ array[index] = source[index];
433
+ }
434
+ return array;
435
+ }
436
+
437
+ /** Used as references for various `Number` constants. */
438
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
439
+
440
+ /** Used to detect unsigned integer values. */
441
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
442
+
443
+ /**
444
+ * Checks if `value` is a valid array-like index.
445
+ *
446
+ * @private
447
+ * @param {*} value The value to check.
448
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
449
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
450
+ */
451
+ function isIndex(value, length) {
452
+ var type = typeof value;
453
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
454
+
455
+ return !!length &&
456
+ (type == 'number' ||
457
+ (type != 'symbol' && reIsUint.test(value))) &&
458
+ (value > -1 && value % 1 == 0 && value < length);
459
+ }
460
+
461
+ /**
462
+ * Performs a
463
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
464
+ * comparison between two values to determine if they are equivalent.
465
+ *
466
+ * @static
467
+ * @memberOf _
468
+ * @since 4.0.0
469
+ * @category Lang
470
+ * @param {*} value The value to compare.
471
+ * @param {*} other The other value to compare.
472
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
473
+ * @example
474
+ *
475
+ * var object = { 'a': 1 };
476
+ * var other = { 'a': 1 };
477
+ *
478
+ * _.eq(object, object);
479
+ * // => true
480
+ *
481
+ * _.eq(object, other);
482
+ * // => false
483
+ *
484
+ * _.eq('a', 'a');
485
+ * // => true
486
+ *
487
+ * _.eq('a', Object('a'));
488
+ * // => false
489
+ *
490
+ * _.eq(NaN, NaN);
491
+ * // => true
492
+ */
493
+ function eq(value, other) {
494
+ return value === other || (value !== value && other !== other);
495
+ }
496
+
497
+ /** Used as references for various `Number` constants. */
498
+ var MAX_SAFE_INTEGER = 9007199254740991;
499
+
500
+ /**
501
+ * Checks if `value` is a valid array-like length.
502
+ *
503
+ * **Note:** This method is loosely based on
504
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
505
+ *
506
+ * @static
507
+ * @memberOf _
508
+ * @since 4.0.0
509
+ * @category Lang
510
+ * @param {*} value The value to check.
511
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
512
+ * @example
513
+ *
514
+ * _.isLength(3);
515
+ * // => true
516
+ *
517
+ * _.isLength(Number.MIN_VALUE);
518
+ * // => false
519
+ *
520
+ * _.isLength(Infinity);
521
+ * // => false
522
+ *
523
+ * _.isLength('3');
524
+ * // => false
525
+ */
526
+ function isLength(value) {
527
+ return typeof value == 'number' &&
528
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
529
+ }
530
+
531
+ /**
532
+ * Checks if `value` is array-like. A value is considered array-like if it's
533
+ * not a function and has a `value.length` that's an integer greater than or
534
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
535
+ *
536
+ * @static
537
+ * @memberOf _
538
+ * @since 4.0.0
539
+ * @category Lang
540
+ * @param {*} value The value to check.
541
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
542
+ * @example
543
+ *
544
+ * _.isArrayLike([1, 2, 3]);
545
+ * // => true
546
+ *
547
+ * _.isArrayLike(document.body.children);
548
+ * // => true
549
+ *
550
+ * _.isArrayLike('abc');
551
+ * // => true
552
+ *
553
+ * _.isArrayLike(_.noop);
554
+ * // => false
555
+ */
556
+ function isArrayLike(value) {
557
+ return value != null && isLength(value.length) && !isFunction(value);
558
+ }
559
+
560
+ /** Used for built-in method references. */
561
+ var objectProto$9 = Object.prototype;
562
+
563
+ /**
564
+ * Checks if `value` is likely a prototype object.
565
+ *
566
+ * @private
567
+ * @param {*} value The value to check.
568
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
569
+ */
570
+ function isPrototype(value) {
571
+ var Ctor = value && value.constructor,
572
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$9;
573
+
574
+ return value === proto;
575
+ }
576
+
577
+ /**
578
+ * The base implementation of `_.times` without support for iteratee shorthands
579
+ * or max array length checks.
580
+ *
581
+ * @private
582
+ * @param {number} n The number of times to invoke `iteratee`.
583
+ * @param {Function} iteratee The function invoked per iteration.
584
+ * @returns {Array} Returns the array of results.
585
+ */
586
+ function baseTimes(n, iteratee) {
587
+ var index = -1,
588
+ result = Array(n);
589
+
590
+ while (++index < n) {
591
+ result[index] = iteratee(index);
592
+ }
593
+ return result;
594
+ }
595
+
596
+ /** `Object#toString` result references. */
597
+ var argsTag$2 = '[object Arguments]';
598
+
599
+ /**
600
+ * The base implementation of `_.isArguments`.
601
+ *
602
+ * @private
603
+ * @param {*} value The value to check.
604
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
605
+ */
606
+ function baseIsArguments(value) {
607
+ return isObjectLike(value) && baseGetTag(value) == argsTag$2;
608
+ }
609
+
610
+ /** Used for built-in method references. */
611
+ var objectProto$8 = Object.prototype;
612
+
613
+ /** Used to check objects for own properties. */
614
+ var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
615
+
616
+ /** Built-in value references. */
617
+ var propertyIsEnumerable$1 = objectProto$8.propertyIsEnumerable;
618
+
619
+ /**
620
+ * Checks if `value` is likely an `arguments` object.
621
+ *
622
+ * @static
623
+ * @memberOf _
624
+ * @since 0.1.0
625
+ * @category Lang
626
+ * @param {*} value The value to check.
627
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
628
+ * else `false`.
629
+ * @example
630
+ *
631
+ * _.isArguments(function() { return arguments; }());
632
+ * // => true
633
+ *
634
+ * _.isArguments([1, 2, 3]);
635
+ * // => false
636
+ */
637
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
638
+ return isObjectLike(value) && hasOwnProperty$7.call(value, 'callee') &&
639
+ !propertyIsEnumerable$1.call(value, 'callee');
640
+ };
641
+
642
+ var isArguments$1 = isArguments;
643
+
644
+ /**
645
+ * This method returns `false`.
646
+ *
647
+ * @static
648
+ * @memberOf _
649
+ * @since 4.13.0
650
+ * @category Util
651
+ * @returns {boolean} Returns `false`.
652
+ * @example
653
+ *
654
+ * _.times(2, _.stubFalse);
655
+ * // => [false, false]
656
+ */
657
+ function stubFalse() {
658
+ return false;
659
+ }
660
+
661
+ /** Detect free variable `exports`. */
662
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
663
+
664
+ /** Detect free variable `module`. */
665
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
666
+
667
+ /** Detect the popular CommonJS extension `module.exports`. */
668
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
669
+
670
+ /** Built-in value references. */
671
+ var Buffer = moduleExports$1 ? root$1.Buffer : undefined;
672
+
673
+ /* Built-in method references for those with the same name as other `lodash` methods. */
674
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
675
+
676
+ /**
677
+ * Checks if `value` is a buffer.
678
+ *
679
+ * @static
680
+ * @memberOf _
681
+ * @since 4.3.0
682
+ * @category Lang
683
+ * @param {*} value The value to check.
684
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
685
+ * @example
686
+ *
687
+ * _.isBuffer(new Buffer(2));
688
+ * // => true
689
+ *
690
+ * _.isBuffer(new Uint8Array(2));
691
+ * // => false
692
+ */
693
+ var isBuffer = nativeIsBuffer || stubFalse;
694
+
695
+ var isBuffer$1 = isBuffer;
696
+
697
+ /** `Object#toString` result references. */
698
+ var argsTag$1 = '[object Arguments]',
699
+ arrayTag$1 = '[object Array]',
700
+ boolTag$1 = '[object Boolean]',
701
+ dateTag$1 = '[object Date]',
702
+ errorTag$1 = '[object Error]',
703
+ funcTag = '[object Function]',
704
+ mapTag$3 = '[object Map]',
705
+ numberTag$1 = '[object Number]',
706
+ objectTag$2 = '[object Object]',
707
+ regexpTag$1 = '[object RegExp]',
708
+ setTag$3 = '[object Set]',
709
+ stringTag$1 = '[object String]',
710
+ weakMapTag$1 = '[object WeakMap]';
711
+
712
+ var arrayBufferTag$1 = '[object ArrayBuffer]',
713
+ dataViewTag$2 = '[object DataView]',
714
+ float32Tag = '[object Float32Array]',
715
+ float64Tag = '[object Float64Array]',
716
+ int8Tag = '[object Int8Array]',
717
+ int16Tag = '[object Int16Array]',
718
+ int32Tag = '[object Int32Array]',
719
+ uint8Tag = '[object Uint8Array]',
720
+ uint8ClampedTag = '[object Uint8ClampedArray]',
721
+ uint16Tag = '[object Uint16Array]',
722
+ uint32Tag = '[object Uint32Array]';
723
+
724
+ /** Used to identify `toStringTag` values of typed arrays. */
725
+ var typedArrayTags = {};
726
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
727
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
728
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
729
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
730
+ typedArrayTags[uint32Tag] = true;
731
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
732
+ typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
733
+ typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
734
+ typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
735
+ typedArrayTags[mapTag$3] = typedArrayTags[numberTag$1] =
736
+ typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
737
+ typedArrayTags[setTag$3] = typedArrayTags[stringTag$1] =
738
+ typedArrayTags[weakMapTag$1] = false;
739
+
740
+ /**
741
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
742
+ *
743
+ * @private
744
+ * @param {*} value The value to check.
745
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
746
+ */
747
+ function baseIsTypedArray(value) {
748
+ return isObjectLike(value) &&
749
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
750
+ }
751
+
752
+ /**
753
+ * The base implementation of `_.unary` without support for storing metadata.
754
+ *
755
+ * @private
756
+ * @param {Function} func The function to cap arguments for.
757
+ * @returns {Function} Returns the new capped function.
758
+ */
759
+ function baseUnary(func) {
760
+ return function(value) {
761
+ return func(value);
762
+ };
763
+ }
764
+
765
+ /** Detect free variable `exports`. */
766
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
767
+
768
+ /** Detect free variable `module`. */
769
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
770
+
771
+ /** Detect the popular CommonJS extension `module.exports`. */
772
+ var moduleExports = freeModule && freeModule.exports === freeExports;
773
+
774
+ /** Detect free variable `process` from Node.js. */
775
+ var freeProcess = moduleExports && freeGlobal$1.process;
776
+
777
+ /** Used to access faster Node.js helpers. */
778
+ var nodeUtil = (function() {
779
+ try {
780
+ // Use `util.types` for Node.js 10+.
781
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
782
+
783
+ if (types) {
784
+ return types;
785
+ }
786
+
787
+ // Legacy `process.binding('util')` for Node.js < 10.
788
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
789
+ } catch (e) {}
790
+ }());
791
+
792
+ var nodeUtil$1 = nodeUtil;
793
+
794
+ /* Node.js helper references. */
795
+ var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
796
+
797
+ /**
798
+ * Checks if `value` is classified as a typed array.
799
+ *
800
+ * @static
801
+ * @memberOf _
802
+ * @since 3.0.0
803
+ * @category Lang
804
+ * @param {*} value The value to check.
805
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
806
+ * @example
807
+ *
808
+ * _.isTypedArray(new Uint8Array);
809
+ * // => true
810
+ *
811
+ * _.isTypedArray([]);
812
+ * // => false
813
+ */
814
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
815
+
816
+ var isTypedArray$1 = isTypedArray;
817
+
818
+ /** Used for built-in method references. */
819
+ var objectProto$7 = Object.prototype;
820
+
821
+ /** Used to check objects for own properties. */
822
+ var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
823
+
824
+ /**
825
+ * Creates an array of the enumerable property names of the array-like `value`.
826
+ *
827
+ * @private
828
+ * @param {*} value The value to query.
829
+ * @param {boolean} inherited Specify returning inherited property names.
830
+ * @returns {Array} Returns the array of property names.
831
+ */
832
+ function arrayLikeKeys(value, inherited) {
833
+ var isArr = isArray$1(value),
834
+ isArg = !isArr && isArguments$1(value),
835
+ isBuff = !isArr && !isArg && isBuffer$1(value),
836
+ isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
837
+ skipIndexes = isArr || isArg || isBuff || isType,
838
+ result = skipIndexes ? baseTimes(value.length, String) : [],
839
+ length = result.length;
840
+
841
+ for (var key in value) {
842
+ if ((inherited || hasOwnProperty$6.call(value, key)) &&
843
+ !(skipIndexes && (
844
+ // Safari 9 has enumerable `arguments.length` in strict mode.
845
+ key == 'length' ||
846
+ // Node.js 0.10 has enumerable non-index properties on buffers.
847
+ (isBuff && (key == 'offset' || key == 'parent')) ||
848
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
849
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
850
+ // Skip index properties.
851
+ isIndex(key, length)
852
+ ))) {
853
+ result.push(key);
854
+ }
855
+ }
856
+ return result;
857
+ }
858
+
859
+ /**
860
+ * Creates a unary function that invokes `func` with its argument transformed.
861
+ *
862
+ * @private
863
+ * @param {Function} func The function to wrap.
864
+ * @param {Function} transform The argument transform.
865
+ * @returns {Function} Returns the new function.
866
+ */
867
+ function overArg(func, transform) {
868
+ return function(arg) {
869
+ return func(transform(arg));
870
+ };
871
+ }
872
+
873
+ /* Built-in method references for those with the same name as other `lodash` methods. */
874
+ var nativeKeys = overArg(Object.keys, Object);
875
+
876
+ var nativeKeys$1 = nativeKeys;
877
+
878
+ /** Used for built-in method references. */
879
+ var objectProto$6 = Object.prototype;
880
+
881
+ /** Used to check objects for own properties. */
882
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
883
+
884
+ /**
885
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
886
+ *
887
+ * @private
888
+ * @param {Object} object The object to query.
889
+ * @returns {Array} Returns the array of property names.
890
+ */
891
+ function baseKeys(object) {
892
+ if (!isPrototype(object)) {
893
+ return nativeKeys$1(object);
894
+ }
895
+ var result = [];
896
+ for (var key in Object(object)) {
897
+ if (hasOwnProperty$5.call(object, key) && key != 'constructor') {
898
+ result.push(key);
899
+ }
900
+ }
901
+ return result;
902
+ }
903
+
904
+ /**
905
+ * Creates an array of the own enumerable property names of `object`.
906
+ *
907
+ * **Note:** Non-object values are coerced to objects. See the
908
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
909
+ * for more details.
910
+ *
911
+ * @static
912
+ * @since 0.1.0
913
+ * @memberOf _
914
+ * @category Object
915
+ * @param {Object} object The object to query.
916
+ * @returns {Array} Returns the array of property names.
917
+ * @example
918
+ *
919
+ * function Foo() {
920
+ * this.a = 1;
921
+ * this.b = 2;
922
+ * }
923
+ *
924
+ * Foo.prototype.c = 3;
925
+ *
926
+ * _.keys(new Foo);
927
+ * // => ['a', 'b'] (iteration order is not guaranteed)
928
+ *
929
+ * _.keys('hi');
930
+ * // => ['0', '1']
931
+ */
932
+ function keys(object) {
933
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
934
+ }
935
+
936
+ /** Used to match property names within property paths. */
937
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
938
+ reIsPlainProp = /^\w*$/;
939
+
940
+ /**
941
+ * Checks if `value` is a property name and not a property path.
942
+ *
943
+ * @private
944
+ * @param {*} value The value to check.
945
+ * @param {Object} [object] The object to query keys on.
946
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
947
+ */
948
+ function isKey(value, object) {
949
+ if (isArray$1(value)) {
950
+ return false;
951
+ }
952
+ var type = typeof value;
953
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
954
+ value == null || isSymbol(value)) {
955
+ return true;
956
+ }
957
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
958
+ (object != null && value in Object(object));
959
+ }
960
+
961
+ /* Built-in method references that are verified to be native. */
962
+ var nativeCreate = getNative(Object, 'create');
963
+
964
+ var nativeCreate$1 = nativeCreate;
965
+
966
+ /**
967
+ * Removes all key-value entries from the hash.
968
+ *
969
+ * @private
970
+ * @name clear
971
+ * @memberOf Hash
972
+ */
973
+ function hashClear() {
974
+ this.__data__ = nativeCreate$1 ? nativeCreate$1(null) : {};
975
+ this.size = 0;
976
+ }
977
+
978
+ /**
979
+ * Removes `key` and its value from the hash.
980
+ *
981
+ * @private
982
+ * @name delete
983
+ * @memberOf Hash
984
+ * @param {Object} hash The hash to modify.
985
+ * @param {string} key The key of the value to remove.
986
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
987
+ */
988
+ function hashDelete(key) {
989
+ var result = this.has(key) && delete this.__data__[key];
990
+ this.size -= result ? 1 : 0;
991
+ return result;
992
+ }
993
+
994
+ /** Used to stand-in for `undefined` hash values. */
995
+ var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
996
+
997
+ /** Used for built-in method references. */
998
+ var objectProto$5 = Object.prototype;
999
+
1000
+ /** Used to check objects for own properties. */
1001
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
1002
+
1003
+ /**
1004
+ * Gets the hash value for `key`.
1005
+ *
1006
+ * @private
1007
+ * @name get
1008
+ * @memberOf Hash
1009
+ * @param {string} key The key of the value to get.
1010
+ * @returns {*} Returns the entry value.
1011
+ */
1012
+ function hashGet(key) {
1013
+ var data = this.__data__;
1014
+ if (nativeCreate$1) {
1015
+ var result = data[key];
1016
+ return result === HASH_UNDEFINED$2 ? undefined : result;
1017
+ }
1018
+ return hasOwnProperty$4.call(data, key) ? data[key] : undefined;
1019
+ }
1020
+
1021
+ /** Used for built-in method references. */
1022
+ var objectProto$4 = Object.prototype;
1023
+
1024
+ /** Used to check objects for own properties. */
1025
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
1026
+
1027
+ /**
1028
+ * Checks if a hash value for `key` exists.
1029
+ *
1030
+ * @private
1031
+ * @name has
1032
+ * @memberOf Hash
1033
+ * @param {string} key The key of the entry to check.
1034
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1035
+ */
1036
+ function hashHas(key) {
1037
+ var data = this.__data__;
1038
+ return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
1039
+ }
1040
+
1041
+ /** Used to stand-in for `undefined` hash values. */
1042
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1043
+
1044
+ /**
1045
+ * Sets the hash `key` to `value`.
1046
+ *
1047
+ * @private
1048
+ * @name set
1049
+ * @memberOf Hash
1050
+ * @param {string} key The key of the value to set.
1051
+ * @param {*} value The value to set.
1052
+ * @returns {Object} Returns the hash instance.
1053
+ */
1054
+ function hashSet(key, value) {
1055
+ var data = this.__data__;
1056
+ this.size += this.has(key) ? 0 : 1;
1057
+ data[key] = (nativeCreate$1 && value === undefined) ? HASH_UNDEFINED$1 : value;
1058
+ return this;
1059
+ }
1060
+
1061
+ /**
1062
+ * Creates a hash object.
1063
+ *
1064
+ * @private
1065
+ * @constructor
1066
+ * @param {Array} [entries] The key-value pairs to cache.
1067
+ */
1068
+ function Hash(entries) {
1069
+ var index = -1,
1070
+ length = entries == null ? 0 : entries.length;
1071
+
1072
+ this.clear();
1073
+ while (++index < length) {
1074
+ var entry = entries[index];
1075
+ this.set(entry[0], entry[1]);
1076
+ }
1077
+ }
1078
+
1079
+ // Add methods to `Hash`.
1080
+ Hash.prototype.clear = hashClear;
1081
+ Hash.prototype['delete'] = hashDelete;
1082
+ Hash.prototype.get = hashGet;
1083
+ Hash.prototype.has = hashHas;
1084
+ Hash.prototype.set = hashSet;
1085
+
1086
+ /**
1087
+ * Removes all key-value entries from the list cache.
1088
+ *
1089
+ * @private
1090
+ * @name clear
1091
+ * @memberOf ListCache
1092
+ */
1093
+ function listCacheClear() {
1094
+ this.__data__ = [];
1095
+ this.size = 0;
1096
+ }
1097
+
1098
+ /**
1099
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
1100
+ *
1101
+ * @private
1102
+ * @param {Array} array The array to inspect.
1103
+ * @param {*} key The key to search for.
1104
+ * @returns {number} Returns the index of the matched value, else `-1`.
1105
+ */
1106
+ function assocIndexOf(array, key) {
1107
+ var length = array.length;
1108
+ while (length--) {
1109
+ if (eq(array[length][0], key)) {
1110
+ return length;
1111
+ }
1112
+ }
1113
+ return -1;
1114
+ }
1115
+
1116
+ /** Used for built-in method references. */
1117
+ var arrayProto = Array.prototype;
1118
+
1119
+ /** Built-in value references. */
1120
+ var splice = arrayProto.splice;
1121
+
1122
+ /**
1123
+ * Removes `key` and its value from the list cache.
1124
+ *
1125
+ * @private
1126
+ * @name delete
1127
+ * @memberOf ListCache
1128
+ * @param {string} key The key of the value to remove.
1129
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1130
+ */
1131
+ function listCacheDelete(key) {
1132
+ var data = this.__data__,
1133
+ index = assocIndexOf(data, key);
1134
+
1135
+ if (index < 0) {
1136
+ return false;
1137
+ }
1138
+ var lastIndex = data.length - 1;
1139
+ if (index == lastIndex) {
1140
+ data.pop();
1141
+ } else {
1142
+ splice.call(data, index, 1);
1143
+ }
1144
+ --this.size;
1145
+ return true;
1146
+ }
1147
+
1148
+ /**
1149
+ * Gets the list cache value for `key`.
1150
+ *
1151
+ * @private
1152
+ * @name get
1153
+ * @memberOf ListCache
1154
+ * @param {string} key The key of the value to get.
1155
+ * @returns {*} Returns the entry value.
1156
+ */
1157
+ function listCacheGet(key) {
1158
+ var data = this.__data__,
1159
+ index = assocIndexOf(data, key);
1160
+
1161
+ return index < 0 ? undefined : data[index][1];
1162
+ }
1163
+
1164
+ /**
1165
+ * Checks if a list cache value for `key` exists.
1166
+ *
1167
+ * @private
1168
+ * @name has
1169
+ * @memberOf ListCache
1170
+ * @param {string} key The key of the entry to check.
1171
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1172
+ */
1173
+ function listCacheHas(key) {
1174
+ return assocIndexOf(this.__data__, key) > -1;
1175
+ }
1176
+
1177
+ /**
1178
+ * Sets the list cache `key` to `value`.
1179
+ *
1180
+ * @private
1181
+ * @name set
1182
+ * @memberOf ListCache
1183
+ * @param {string} key The key of the value to set.
1184
+ * @param {*} value The value to set.
1185
+ * @returns {Object} Returns the list cache instance.
1186
+ */
1187
+ function listCacheSet(key, value) {
1188
+ var data = this.__data__,
1189
+ index = assocIndexOf(data, key);
1190
+
1191
+ if (index < 0) {
1192
+ ++this.size;
1193
+ data.push([key, value]);
1194
+ } else {
1195
+ data[index][1] = value;
1196
+ }
1197
+ return this;
1198
+ }
1199
+
1200
+ /**
1201
+ * Creates an list cache object.
1202
+ *
1203
+ * @private
1204
+ * @constructor
1205
+ * @param {Array} [entries] The key-value pairs to cache.
1206
+ */
1207
+ function ListCache(entries) {
1208
+ var index = -1,
1209
+ length = entries == null ? 0 : entries.length;
1210
+
1211
+ this.clear();
1212
+ while (++index < length) {
1213
+ var entry = entries[index];
1214
+ this.set(entry[0], entry[1]);
1215
+ }
1216
+ }
1217
+
1218
+ // Add methods to `ListCache`.
1219
+ ListCache.prototype.clear = listCacheClear;
1220
+ ListCache.prototype['delete'] = listCacheDelete;
1221
+ ListCache.prototype.get = listCacheGet;
1222
+ ListCache.prototype.has = listCacheHas;
1223
+ ListCache.prototype.set = listCacheSet;
1224
+
1225
+ /* Built-in method references that are verified to be native. */
1226
+ var Map = getNative(root$1, 'Map');
1227
+
1228
+ var Map$1 = Map;
1229
+
1230
+ /**
1231
+ * Removes all key-value entries from the map.
1232
+ *
1233
+ * @private
1234
+ * @name clear
1235
+ * @memberOf MapCache
1236
+ */
1237
+ function mapCacheClear() {
1238
+ this.size = 0;
1239
+ this.__data__ = {
1240
+ 'hash': new Hash,
1241
+ 'map': new (Map$1 || ListCache),
1242
+ 'string': new Hash
1243
+ };
1244
+ }
1245
+
1246
+ /**
1247
+ * Checks if `value` is suitable for use as unique object key.
1248
+ *
1249
+ * @private
1250
+ * @param {*} value The value to check.
1251
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1252
+ */
1253
+ function isKeyable(value) {
1254
+ var type = typeof value;
1255
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1256
+ ? (value !== '__proto__')
1257
+ : (value === null);
1258
+ }
1259
+
1260
+ /**
1261
+ * Gets the data for `map`.
1262
+ *
1263
+ * @private
1264
+ * @param {Object} map The map to query.
1265
+ * @param {string} key The reference key.
1266
+ * @returns {*} Returns the map data.
1267
+ */
1268
+ function getMapData(map, key) {
1269
+ var data = map.__data__;
1270
+ return isKeyable(key)
1271
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1272
+ : data.map;
1273
+ }
1274
+
1275
+ /**
1276
+ * Removes `key` and its value from the map.
1277
+ *
1278
+ * @private
1279
+ * @name delete
1280
+ * @memberOf MapCache
1281
+ * @param {string} key The key of the value to remove.
1282
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1283
+ */
1284
+ function mapCacheDelete(key) {
1285
+ var result = getMapData(this, key)['delete'](key);
1286
+ this.size -= result ? 1 : 0;
1287
+ return result;
1288
+ }
1289
+
1290
+ /**
1291
+ * Gets the map value for `key`.
1292
+ *
1293
+ * @private
1294
+ * @name get
1295
+ * @memberOf MapCache
1296
+ * @param {string} key The key of the value to get.
1297
+ * @returns {*} Returns the entry value.
1298
+ */
1299
+ function mapCacheGet(key) {
1300
+ return getMapData(this, key).get(key);
1301
+ }
1302
+
1303
+ /**
1304
+ * Checks if a map value for `key` exists.
1305
+ *
1306
+ * @private
1307
+ * @name has
1308
+ * @memberOf MapCache
1309
+ * @param {string} key The key of the entry to check.
1310
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1311
+ */
1312
+ function mapCacheHas(key) {
1313
+ return getMapData(this, key).has(key);
1314
+ }
1315
+
1316
+ /**
1317
+ * Sets the map `key` to `value`.
1318
+ *
1319
+ * @private
1320
+ * @name set
1321
+ * @memberOf MapCache
1322
+ * @param {string} key The key of the value to set.
1323
+ * @param {*} value The value to set.
1324
+ * @returns {Object} Returns the map cache instance.
1325
+ */
1326
+ function mapCacheSet(key, value) {
1327
+ var data = getMapData(this, key),
1328
+ size = data.size;
1329
+
1330
+ data.set(key, value);
1331
+ this.size += data.size == size ? 0 : 1;
1332
+ return this;
1333
+ }
1334
+
1335
+ /**
1336
+ * Creates a map cache object to store key-value pairs.
1337
+ *
1338
+ * @private
1339
+ * @constructor
1340
+ * @param {Array} [entries] The key-value pairs to cache.
1341
+ */
1342
+ function MapCache(entries) {
1343
+ var index = -1,
1344
+ length = entries == null ? 0 : entries.length;
1345
+
1346
+ this.clear();
1347
+ while (++index < length) {
1348
+ var entry = entries[index];
1349
+ this.set(entry[0], entry[1]);
1350
+ }
1351
+ }
1352
+
1353
+ // Add methods to `MapCache`.
1354
+ MapCache.prototype.clear = mapCacheClear;
1355
+ MapCache.prototype['delete'] = mapCacheDelete;
1356
+ MapCache.prototype.get = mapCacheGet;
1357
+ MapCache.prototype.has = mapCacheHas;
1358
+ MapCache.prototype.set = mapCacheSet;
1359
+
1360
+ /** Error message constants. */
1361
+ var FUNC_ERROR_TEXT = 'Expected a function';
1362
+
1363
+ /**
1364
+ * Creates a function that memoizes the result of `func`. If `resolver` is
1365
+ * provided, it determines the cache key for storing the result based on the
1366
+ * arguments provided to the memoized function. By default, the first argument
1367
+ * provided to the memoized function is used as the map cache key. The `func`
1368
+ * is invoked with the `this` binding of the memoized function.
1369
+ *
1370
+ * **Note:** The cache is exposed as the `cache` property on the memoized
1371
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
1372
+ * constructor with one whose instances implement the
1373
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
1374
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
1375
+ *
1376
+ * @static
1377
+ * @memberOf _
1378
+ * @since 0.1.0
1379
+ * @category Function
1380
+ * @param {Function} func The function to have its output memoized.
1381
+ * @param {Function} [resolver] The function to resolve the cache key.
1382
+ * @returns {Function} Returns the new memoized function.
1383
+ * @example
1384
+ *
1385
+ * var object = { 'a': 1, 'b': 2 };
1386
+ * var other = { 'c': 3, 'd': 4 };
1387
+ *
1388
+ * var values = _.memoize(_.values);
1389
+ * values(object);
1390
+ * // => [1, 2]
1391
+ *
1392
+ * values(other);
1393
+ * // => [3, 4]
1394
+ *
1395
+ * object.a = 2;
1396
+ * values(object);
1397
+ * // => [1, 2]
1398
+ *
1399
+ * // Modify the result cache.
1400
+ * values.cache.set(object, ['a', 'b']);
1401
+ * values(object);
1402
+ * // => ['a', 'b']
1403
+ *
1404
+ * // Replace `_.memoize.Cache`.
1405
+ * _.memoize.Cache = WeakMap;
1406
+ */
1407
+ function memoize(func, resolver) {
1408
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
1409
+ throw new TypeError(FUNC_ERROR_TEXT);
1410
+ }
1411
+ var memoized = function() {
1412
+ var args = arguments,
1413
+ key = resolver ? resolver.apply(this, args) : args[0],
1414
+ cache = memoized.cache;
1415
+
1416
+ if (cache.has(key)) {
1417
+ return cache.get(key);
1418
+ }
1419
+ var result = func.apply(this, args);
1420
+ memoized.cache = cache.set(key, result) || cache;
1421
+ return result;
1422
+ };
1423
+ memoized.cache = new (memoize.Cache || MapCache);
1424
+ return memoized;
1425
+ }
1426
+
1427
+ // Expose `MapCache`.
1428
+ memoize.Cache = MapCache;
1429
+
1430
+ /** Used as the maximum memoize cache size. */
1431
+ var MAX_MEMOIZE_SIZE = 500;
1432
+
1433
+ /**
1434
+ * A specialized version of `_.memoize` which clears the memoized function's
1435
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
1436
+ *
1437
+ * @private
1438
+ * @param {Function} func The function to have its output memoized.
1439
+ * @returns {Function} Returns the new memoized function.
1440
+ */
1441
+ function memoizeCapped(func) {
1442
+ var result = memoize(func, function(key) {
1443
+ if (cache.size === MAX_MEMOIZE_SIZE) {
1444
+ cache.clear();
1445
+ }
1446
+ return key;
1447
+ });
1448
+
1449
+ var cache = result.cache;
1450
+ return result;
1451
+ }
1452
+
1453
+ /** Used to match property names within property paths. */
1454
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1455
+
1456
+ /** Used to match backslashes in property paths. */
1457
+ var reEscapeChar = /\\(\\)?/g;
1458
+
1459
+ /**
1460
+ * Converts `string` to a property path array.
1461
+ *
1462
+ * @private
1463
+ * @param {string} string The string to convert.
1464
+ * @returns {Array} Returns the property path array.
1465
+ */
1466
+ var stringToPath = memoizeCapped(function(string) {
1467
+ var result = [];
1468
+ if (string.charCodeAt(0) === 46 /* . */) {
1469
+ result.push('');
1470
+ }
1471
+ string.replace(rePropName, function(match, number, quote, subString) {
1472
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
1473
+ });
1474
+ return result;
1475
+ });
1476
+
1477
+ var stringToPath$1 = stringToPath;
1478
+
1479
+ /**
1480
+ * Converts `value` to a string. An empty string is returned for `null`
1481
+ * and `undefined` values. The sign of `-0` is preserved.
1482
+ *
1483
+ * @static
1484
+ * @memberOf _
1485
+ * @since 4.0.0
1486
+ * @category Lang
1487
+ * @param {*} value The value to convert.
1488
+ * @returns {string} Returns the converted string.
1489
+ * @example
1490
+ *
1491
+ * _.toString(null);
1492
+ * // => ''
1493
+ *
1494
+ * _.toString(-0);
1495
+ * // => '-0'
1496
+ *
1497
+ * _.toString([1, 2, 3]);
1498
+ * // => '1,2,3'
1499
+ */
1500
+ function toString(value) {
1501
+ return value == null ? '' : baseToString(value);
1502
+ }
1503
+
1504
+ /**
1505
+ * Casts `value` to a path array if it's not one.
1506
+ *
1507
+ * @private
1508
+ * @param {*} value The value to inspect.
1509
+ * @param {Object} [object] The object to query keys on.
1510
+ * @returns {Array} Returns the cast property path array.
1511
+ */
1512
+ function castPath(value, object) {
1513
+ if (isArray$1(value)) {
1514
+ return value;
1515
+ }
1516
+ return isKey(value, object) ? [value] : stringToPath$1(toString(value));
1517
+ }
1518
+
1519
+ /** Used as references for various `Number` constants. */
1520
+ var INFINITY = 1 / 0;
1521
+
1522
+ /**
1523
+ * Converts `value` to a string key if it's not a string or symbol.
1524
+ *
1525
+ * @private
1526
+ * @param {*} value The value to inspect.
1527
+ * @returns {string|symbol} Returns the key.
1528
+ */
1529
+ function toKey(value) {
1530
+ if (typeof value == 'string' || isSymbol(value)) {
1531
+ return value;
1532
+ }
1533
+ var result = (value + '');
1534
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
1535
+ }
1536
+
1537
+ /**
1538
+ * The base implementation of `_.get` without support for default values.
1539
+ *
1540
+ * @private
1541
+ * @param {Object} object The object to query.
1542
+ * @param {Array|string} path The path of the property to get.
1543
+ * @returns {*} Returns the resolved value.
1544
+ */
1545
+ function baseGet(object, path) {
1546
+ path = castPath(path, object);
1547
+
1548
+ var index = 0,
1549
+ length = path.length;
1550
+
1551
+ while (object != null && index < length) {
1552
+ object = object[toKey(path[index++])];
1553
+ }
1554
+ return (index && index == length) ? object : undefined;
1555
+ }
1556
+
1557
+ /**
1558
+ * Gets the value at `path` of `object`. If the resolved value is
1559
+ * `undefined`, the `defaultValue` is returned in its place.
1560
+ *
1561
+ * @static
1562
+ * @memberOf _
1563
+ * @since 3.7.0
1564
+ * @category Object
1565
+ * @param {Object} object The object to query.
1566
+ * @param {Array|string} path The path of the property to get.
1567
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
1568
+ * @returns {*} Returns the resolved value.
1569
+ * @example
1570
+ *
1571
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
1572
+ *
1573
+ * _.get(object, 'a[0].b.c');
1574
+ * // => 3
1575
+ *
1576
+ * _.get(object, ['a', '0', 'b', 'c']);
1577
+ * // => 3
1578
+ *
1579
+ * _.get(object, 'a.b.c', 'default');
1580
+ * // => 'default'
1581
+ */
1582
+ function get(object, path, defaultValue) {
1583
+ var result = object == null ? undefined : baseGet(object, path);
1584
+ return result === undefined ? defaultValue : result;
1585
+ }
1586
+
1587
+ /**
1588
+ * Appends the elements of `values` to `array`.
1589
+ *
1590
+ * @private
1591
+ * @param {Array} array The array to modify.
1592
+ * @param {Array} values The values to append.
1593
+ * @returns {Array} Returns `array`.
1594
+ */
1595
+ function arrayPush(array, values) {
1596
+ var index = -1,
1597
+ length = values.length,
1598
+ offset = array.length;
1599
+
1600
+ while (++index < length) {
1601
+ array[offset + index] = values[index];
1602
+ }
1603
+ return array;
1604
+ }
1605
+
1606
+ /**
1607
+ * Removes all key-value entries from the stack.
1608
+ *
1609
+ * @private
1610
+ * @name clear
1611
+ * @memberOf Stack
1612
+ */
1613
+ function stackClear() {
1614
+ this.__data__ = new ListCache;
1615
+ this.size = 0;
1616
+ }
1617
+
1618
+ /**
1619
+ * Removes `key` and its value from the stack.
1620
+ *
1621
+ * @private
1622
+ * @name delete
1623
+ * @memberOf Stack
1624
+ * @param {string} key The key of the value to remove.
1625
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1626
+ */
1627
+ function stackDelete(key) {
1628
+ var data = this.__data__,
1629
+ result = data['delete'](key);
1630
+
1631
+ this.size = data.size;
1632
+ return result;
1633
+ }
1634
+
1635
+ /**
1636
+ * Gets the stack value for `key`.
1637
+ *
1638
+ * @private
1639
+ * @name get
1640
+ * @memberOf Stack
1641
+ * @param {string} key The key of the value to get.
1642
+ * @returns {*} Returns the entry value.
1643
+ */
1644
+ function stackGet(key) {
1645
+ return this.__data__.get(key);
1646
+ }
1647
+
1648
+ /**
1649
+ * Checks if a stack value for `key` exists.
1650
+ *
1651
+ * @private
1652
+ * @name has
1653
+ * @memberOf Stack
1654
+ * @param {string} key The key of the entry to check.
1655
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1656
+ */
1657
+ function stackHas(key) {
1658
+ return this.__data__.has(key);
1659
+ }
1660
+
1661
+ /** Used as the size to enable large array optimizations. */
1662
+ var LARGE_ARRAY_SIZE = 200;
1663
+
1664
+ /**
1665
+ * Sets the stack `key` to `value`.
1666
+ *
1667
+ * @private
1668
+ * @name set
1669
+ * @memberOf Stack
1670
+ * @param {string} key The key of the value to set.
1671
+ * @param {*} value The value to set.
1672
+ * @returns {Object} Returns the stack cache instance.
1673
+ */
1674
+ function stackSet(key, value) {
1675
+ var data = this.__data__;
1676
+ if (data instanceof ListCache) {
1677
+ var pairs = data.__data__;
1678
+ if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1679
+ pairs.push([key, value]);
1680
+ this.size = ++data.size;
1681
+ return this;
1682
+ }
1683
+ data = this.__data__ = new MapCache(pairs);
1684
+ }
1685
+ data.set(key, value);
1686
+ this.size = data.size;
1687
+ return this;
1688
+ }
1689
+
1690
+ /**
1691
+ * Creates a stack cache object to store key-value pairs.
1692
+ *
1693
+ * @private
1694
+ * @constructor
1695
+ * @param {Array} [entries] The key-value pairs to cache.
1696
+ */
1697
+ function Stack(entries) {
1698
+ var data = this.__data__ = new ListCache(entries);
1699
+ this.size = data.size;
1700
+ }
1701
+
1702
+ // Add methods to `Stack`.
1703
+ Stack.prototype.clear = stackClear;
1704
+ Stack.prototype['delete'] = stackDelete;
1705
+ Stack.prototype.get = stackGet;
1706
+ Stack.prototype.has = stackHas;
1707
+ Stack.prototype.set = stackSet;
1708
+
1709
+ /**
1710
+ * A specialized version of `_.filter` for arrays without support for
1711
+ * iteratee shorthands.
1712
+ *
1713
+ * @private
1714
+ * @param {Array} [array] The array to iterate over.
1715
+ * @param {Function} predicate The function invoked per iteration.
1716
+ * @returns {Array} Returns the new filtered array.
1717
+ */
1718
+ function arrayFilter(array, predicate) {
1719
+ var index = -1,
1720
+ length = array == null ? 0 : array.length,
1721
+ resIndex = 0,
1722
+ result = [];
1723
+
1724
+ while (++index < length) {
1725
+ var value = array[index];
1726
+ if (predicate(value, index, array)) {
1727
+ result[resIndex++] = value;
1728
+ }
1729
+ }
1730
+ return result;
1731
+ }
1732
+
1733
+ /**
1734
+ * This method returns a new empty array.
1735
+ *
1736
+ * @static
1737
+ * @memberOf _
1738
+ * @since 4.13.0
1739
+ * @category Util
1740
+ * @returns {Array} Returns the new empty array.
1741
+ * @example
1742
+ *
1743
+ * var arrays = _.times(2, _.stubArray);
1744
+ *
1745
+ * console.log(arrays);
1746
+ * // => [[], []]
1747
+ *
1748
+ * console.log(arrays[0] === arrays[1]);
1749
+ * // => false
1750
+ */
1751
+ function stubArray() {
1752
+ return [];
1753
+ }
1754
+
1755
+ /** Used for built-in method references. */
1756
+ var objectProto$3 = Object.prototype;
1757
+
1758
+ /** Built-in value references. */
1759
+ var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
1760
+
1761
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1762
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1763
+
1764
+ /**
1765
+ * Creates an array of the own enumerable symbols of `object`.
1766
+ *
1767
+ * @private
1768
+ * @param {Object} object The object to query.
1769
+ * @returns {Array} Returns the array of symbols.
1770
+ */
1771
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1772
+ if (object == null) {
1773
+ return [];
1774
+ }
1775
+ object = Object(object);
1776
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
1777
+ return propertyIsEnumerable.call(object, symbol);
1778
+ });
1779
+ };
1780
+
1781
+ var getSymbols$1 = getSymbols;
1782
+
1783
+ /**
1784
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1785
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1786
+ * symbols of `object`.
1787
+ *
1788
+ * @private
1789
+ * @param {Object} object The object to query.
1790
+ * @param {Function} keysFunc The function to get the keys of `object`.
1791
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
1792
+ * @returns {Array} Returns the array of property names and symbols.
1793
+ */
1794
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1795
+ var result = keysFunc(object);
1796
+ return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
1797
+ }
1798
+
1799
+ /**
1800
+ * Creates an array of own enumerable property names and symbols of `object`.
1801
+ *
1802
+ * @private
1803
+ * @param {Object} object The object to query.
1804
+ * @returns {Array} Returns the array of property names and symbols.
1805
+ */
1806
+ function getAllKeys(object) {
1807
+ return baseGetAllKeys(object, keys, getSymbols$1);
1808
+ }
1809
+
1810
+ /* Built-in method references that are verified to be native. */
1811
+ var DataView = getNative(root$1, 'DataView');
1812
+
1813
+ var DataView$1 = DataView;
1814
+
1815
+ /* Built-in method references that are verified to be native. */
1816
+ var Promise$1 = getNative(root$1, 'Promise');
1817
+
1818
+ var Promise$2 = Promise$1;
1819
+
1820
+ /* Built-in method references that are verified to be native. */
1821
+ var Set = getNative(root$1, 'Set');
1822
+
1823
+ var Set$1 = Set;
1824
+
1825
+ /** `Object#toString` result references. */
1826
+ var mapTag$2 = '[object Map]',
1827
+ objectTag$1 = '[object Object]',
1828
+ promiseTag = '[object Promise]',
1829
+ setTag$2 = '[object Set]',
1830
+ weakMapTag = '[object WeakMap]';
1831
+
1832
+ var dataViewTag$1 = '[object DataView]';
1833
+
1834
+ /** Used to detect maps, sets, and weakmaps. */
1835
+ var dataViewCtorString = toSource(DataView$1),
1836
+ mapCtorString = toSource(Map$1),
1837
+ promiseCtorString = toSource(Promise$2),
1838
+ setCtorString = toSource(Set$1),
1839
+ weakMapCtorString = toSource(WeakMap$1);
1840
+
1841
+ /**
1842
+ * Gets the `toStringTag` of `value`.
1843
+ *
1844
+ * @private
1845
+ * @param {*} value The value to query.
1846
+ * @returns {string} Returns the `toStringTag`.
1847
+ */
1848
+ var getTag = baseGetTag;
1849
+
1850
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1851
+ if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$1) ||
1852
+ (Map$1 && getTag(new Map$1) != mapTag$2) ||
1853
+ (Promise$2 && getTag(Promise$2.resolve()) != promiseTag) ||
1854
+ (Set$1 && getTag(new Set$1) != setTag$2) ||
1855
+ (WeakMap$1 && getTag(new WeakMap$1) != weakMapTag)) {
1856
+ getTag = function(value) {
1857
+ var result = baseGetTag(value),
1858
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
1859
+ ctorString = Ctor ? toSource(Ctor) : '';
1860
+
1861
+ if (ctorString) {
1862
+ switch (ctorString) {
1863
+ case dataViewCtorString: return dataViewTag$1;
1864
+ case mapCtorString: return mapTag$2;
1865
+ case promiseCtorString: return promiseTag;
1866
+ case setCtorString: return setTag$2;
1867
+ case weakMapCtorString: return weakMapTag;
1868
+ }
1869
+ }
1870
+ return result;
1871
+ };
1872
+ }
1873
+
1874
+ var getTag$1 = getTag;
1875
+
1876
+ /** Built-in value references. */
1877
+ var Uint8Array = root$1.Uint8Array;
1878
+
1879
+ var Uint8Array$1 = Uint8Array;
1880
+
1881
+ /** Used to stand-in for `undefined` hash values. */
1882
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1883
+
1884
+ /**
1885
+ * Adds `value` to the array cache.
1886
+ *
1887
+ * @private
1888
+ * @name add
1889
+ * @memberOf SetCache
1890
+ * @alias push
1891
+ * @param {*} value The value to cache.
1892
+ * @returns {Object} Returns the cache instance.
1893
+ */
1894
+ function setCacheAdd(value) {
1895
+ this.__data__.set(value, HASH_UNDEFINED);
1896
+ return this;
1897
+ }
1898
+
1899
+ /**
1900
+ * Checks if `value` is in the array cache.
1901
+ *
1902
+ * @private
1903
+ * @name has
1904
+ * @memberOf SetCache
1905
+ * @param {*} value The value to search for.
1906
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1907
+ */
1908
+ function setCacheHas(value) {
1909
+ return this.__data__.has(value);
1910
+ }
1911
+
1912
+ /**
1913
+ *
1914
+ * Creates an array cache object to store unique values.
1915
+ *
1916
+ * @private
1917
+ * @constructor
1918
+ * @param {Array} [values] The values to cache.
1919
+ */
1920
+ function SetCache(values) {
1921
+ var index = -1,
1922
+ length = values == null ? 0 : values.length;
1923
+
1924
+ this.__data__ = new MapCache;
1925
+ while (++index < length) {
1926
+ this.add(values[index]);
1927
+ }
1928
+ }
1929
+
1930
+ // Add methods to `SetCache`.
1931
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
1932
+ SetCache.prototype.has = setCacheHas;
1933
+
1934
+ /**
1935
+ * A specialized version of `_.some` for arrays without support for iteratee
1936
+ * shorthands.
1937
+ *
1938
+ * @private
1939
+ * @param {Array} [array] The array to iterate over.
1940
+ * @param {Function} predicate The function invoked per iteration.
1941
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
1942
+ * else `false`.
1943
+ */
1944
+ function arraySome(array, predicate) {
1945
+ var index = -1,
1946
+ length = array == null ? 0 : array.length;
1947
+
1948
+ while (++index < length) {
1949
+ if (predicate(array[index], index, array)) {
1950
+ return true;
1951
+ }
1952
+ }
1953
+ return false;
1954
+ }
1955
+
1956
+ /**
1957
+ * Checks if a `cache` value for `key` exists.
1958
+ *
1959
+ * @private
1960
+ * @param {Object} cache The cache to query.
1961
+ * @param {string} key The key of the entry to check.
1962
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1963
+ */
1964
+ function cacheHas(cache, key) {
1965
+ return cache.has(key);
1966
+ }
1967
+
1968
+ /** Used to compose bitmasks for value comparisons. */
1969
+ var COMPARE_PARTIAL_FLAG$3 = 1,
1970
+ COMPARE_UNORDERED_FLAG$1 = 2;
1971
+
1972
+ /**
1973
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
1974
+ * partial deep comparisons.
1975
+ *
1976
+ * @private
1977
+ * @param {Array} array The array to compare.
1978
+ * @param {Array} other The other array to compare.
1979
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1980
+ * @param {Function} customizer The function to customize comparisons.
1981
+ * @param {Function} equalFunc The function to determine equivalents of values.
1982
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
1983
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1984
+ */
1985
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1986
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
1987
+ arrLength = array.length,
1988
+ othLength = other.length;
1989
+
1990
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1991
+ return false;
1992
+ }
1993
+ // Check that cyclic values are equal.
1994
+ var arrStacked = stack.get(array);
1995
+ var othStacked = stack.get(other);
1996
+ if (arrStacked && othStacked) {
1997
+ return arrStacked == other && othStacked == array;
1998
+ }
1999
+ var index = -1,
2000
+ result = true,
2001
+ seen = (bitmask & COMPARE_UNORDERED_FLAG$1) ? new SetCache : undefined;
2002
+
2003
+ stack.set(array, other);
2004
+ stack.set(other, array);
2005
+
2006
+ // Ignore non-index properties.
2007
+ while (++index < arrLength) {
2008
+ var arrValue = array[index],
2009
+ othValue = other[index];
2010
+
2011
+ if (customizer) {
2012
+ var compared = isPartial
2013
+ ? customizer(othValue, arrValue, index, other, array, stack)
2014
+ : customizer(arrValue, othValue, index, array, other, stack);
2015
+ }
2016
+ if (compared !== undefined) {
2017
+ if (compared) {
2018
+ continue;
2019
+ }
2020
+ result = false;
2021
+ break;
2022
+ }
2023
+ // Recursively compare arrays (susceptible to call stack limits).
2024
+ if (seen) {
2025
+ if (!arraySome(other, function(othValue, othIndex) {
2026
+ if (!cacheHas(seen, othIndex) &&
2027
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
2028
+ return seen.push(othIndex);
2029
+ }
2030
+ })) {
2031
+ result = false;
2032
+ break;
2033
+ }
2034
+ } else if (!(
2035
+ arrValue === othValue ||
2036
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
2037
+ )) {
2038
+ result = false;
2039
+ break;
2040
+ }
2041
+ }
2042
+ stack['delete'](array);
2043
+ stack['delete'](other);
2044
+ return result;
2045
+ }
2046
+
2047
+ /**
2048
+ * Converts `map` to its key-value pairs.
2049
+ *
2050
+ * @private
2051
+ * @param {Object} map The map to convert.
2052
+ * @returns {Array} Returns the key-value pairs.
2053
+ */
2054
+ function mapToArray(map) {
2055
+ var index = -1,
2056
+ result = Array(map.size);
2057
+
2058
+ map.forEach(function(value, key) {
2059
+ result[++index] = [key, value];
2060
+ });
2061
+ return result;
2062
+ }
2063
+
2064
+ /**
2065
+ * Converts `set` to an array of its values.
2066
+ *
2067
+ * @private
2068
+ * @param {Object} set The set to convert.
2069
+ * @returns {Array} Returns the values.
2070
+ */
2071
+ function setToArray(set) {
2072
+ var index = -1,
2073
+ result = Array(set.size);
2074
+
2075
+ set.forEach(function(value) {
2076
+ result[++index] = value;
2077
+ });
2078
+ return result;
2079
+ }
2080
+
2081
+ /** Used to compose bitmasks for value comparisons. */
2082
+ var COMPARE_PARTIAL_FLAG$2 = 1,
2083
+ COMPARE_UNORDERED_FLAG = 2;
2084
+
2085
+ /** `Object#toString` result references. */
2086
+ var boolTag = '[object Boolean]',
2087
+ dateTag = '[object Date]',
2088
+ errorTag = '[object Error]',
2089
+ mapTag$1 = '[object Map]',
2090
+ numberTag = '[object Number]',
2091
+ regexpTag = '[object RegExp]',
2092
+ setTag$1 = '[object Set]',
2093
+ stringTag = '[object String]',
2094
+ symbolTag = '[object Symbol]';
2095
+
2096
+ var arrayBufferTag = '[object ArrayBuffer]',
2097
+ dataViewTag = '[object DataView]';
2098
+
2099
+ /** Used to convert symbols to primitives and strings. */
2100
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
2101
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
2102
+
2103
+ /**
2104
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
2105
+ * the same `toStringTag`.
2106
+ *
2107
+ * **Note:** This function only supports comparing values with tags of
2108
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
2109
+ *
2110
+ * @private
2111
+ * @param {Object} object The object to compare.
2112
+ * @param {Object} other The other object to compare.
2113
+ * @param {string} tag The `toStringTag` of the objects to compare.
2114
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2115
+ * @param {Function} customizer The function to customize comparisons.
2116
+ * @param {Function} equalFunc The function to determine equivalents of values.
2117
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
2118
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2119
+ */
2120
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
2121
+ switch (tag) {
2122
+ case dataViewTag:
2123
+ if ((object.byteLength != other.byteLength) ||
2124
+ (object.byteOffset != other.byteOffset)) {
2125
+ return false;
2126
+ }
2127
+ object = object.buffer;
2128
+ other = other.buffer;
2129
+
2130
+ case arrayBufferTag:
2131
+ if ((object.byteLength != other.byteLength) ||
2132
+ !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) {
2133
+ return false;
2134
+ }
2135
+ return true;
2136
+
2137
+ case boolTag:
2138
+ case dateTag:
2139
+ case numberTag:
2140
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
2141
+ // Invalid dates are coerced to `NaN`.
2142
+ return eq(+object, +other);
2143
+
2144
+ case errorTag:
2145
+ return object.name == other.name && object.message == other.message;
2146
+
2147
+ case regexpTag:
2148
+ case stringTag:
2149
+ // Coerce regexes to strings and treat strings, primitives and objects,
2150
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
2151
+ // for more details.
2152
+ return object == (other + '');
2153
+
2154
+ case mapTag$1:
2155
+ var convert = mapToArray;
2156
+
2157
+ case setTag$1:
2158
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2;
2159
+ convert || (convert = setToArray);
2160
+
2161
+ if (object.size != other.size && !isPartial) {
2162
+ return false;
2163
+ }
2164
+ // Assume cyclic values are equal.
2165
+ var stacked = stack.get(object);
2166
+ if (stacked) {
2167
+ return stacked == other;
2168
+ }
2169
+ bitmask |= COMPARE_UNORDERED_FLAG;
2170
+
2171
+ // Recursively compare objects (susceptible to call stack limits).
2172
+ stack.set(object, other);
2173
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
2174
+ stack['delete'](object);
2175
+ return result;
2176
+
2177
+ case symbolTag:
2178
+ if (symbolValueOf) {
2179
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
2180
+ }
2181
+ }
2182
+ return false;
2183
+ }
2184
+
2185
+ /** Used to compose bitmasks for value comparisons. */
2186
+ var COMPARE_PARTIAL_FLAG$1 = 1;
2187
+
2188
+ /** Used for built-in method references. */
2189
+ var objectProto$2 = Object.prototype;
2190
+
2191
+ /** Used to check objects for own properties. */
2192
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
2193
+
2194
+ /**
2195
+ * A specialized version of `baseIsEqualDeep` for objects with support for
2196
+ * partial deep comparisons.
2197
+ *
2198
+ * @private
2199
+ * @param {Object} object The object to compare.
2200
+ * @param {Object} other The other object to compare.
2201
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2202
+ * @param {Function} customizer The function to customize comparisons.
2203
+ * @param {Function} equalFunc The function to determine equivalents of values.
2204
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
2205
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2206
+ */
2207
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2208
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1,
2209
+ objProps = getAllKeys(object),
2210
+ objLength = objProps.length,
2211
+ othProps = getAllKeys(other),
2212
+ othLength = othProps.length;
2213
+
2214
+ if (objLength != othLength && !isPartial) {
2215
+ return false;
2216
+ }
2217
+ var index = objLength;
2218
+ while (index--) {
2219
+ var key = objProps[index];
2220
+ if (!(isPartial ? key in other : hasOwnProperty$2.call(other, key))) {
2221
+ return false;
2222
+ }
2223
+ }
2224
+ // Check that cyclic values are equal.
2225
+ var objStacked = stack.get(object);
2226
+ var othStacked = stack.get(other);
2227
+ if (objStacked && othStacked) {
2228
+ return objStacked == other && othStacked == object;
2229
+ }
2230
+ var result = true;
2231
+ stack.set(object, other);
2232
+ stack.set(other, object);
2233
+
2234
+ var skipCtor = isPartial;
2235
+ while (++index < objLength) {
2236
+ key = objProps[index];
2237
+ var objValue = object[key],
2238
+ othValue = other[key];
2239
+
2240
+ if (customizer) {
2241
+ var compared = isPartial
2242
+ ? customizer(othValue, objValue, key, other, object, stack)
2243
+ : customizer(objValue, othValue, key, object, other, stack);
2244
+ }
2245
+ // Recursively compare objects (susceptible to call stack limits).
2246
+ if (!(compared === undefined
2247
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
2248
+ : compared
2249
+ )) {
2250
+ result = false;
2251
+ break;
2252
+ }
2253
+ skipCtor || (skipCtor = key == 'constructor');
2254
+ }
2255
+ if (result && !skipCtor) {
2256
+ var objCtor = object.constructor,
2257
+ othCtor = other.constructor;
2258
+
2259
+ // Non `Object` object instances with different constructors are not equal.
2260
+ if (objCtor != othCtor &&
2261
+ ('constructor' in object && 'constructor' in other) &&
2262
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
2263
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
2264
+ result = false;
2265
+ }
2266
+ }
2267
+ stack['delete'](object);
2268
+ stack['delete'](other);
2269
+ return result;
2270
+ }
2271
+
2272
+ /** Used to compose bitmasks for value comparisons. */
2273
+ var COMPARE_PARTIAL_FLAG = 1;
2274
+
2275
+ /** `Object#toString` result references. */
2276
+ var argsTag = '[object Arguments]',
2277
+ arrayTag = '[object Array]',
2278
+ objectTag = '[object Object]';
2279
+
2280
+ /** Used for built-in method references. */
2281
+ var objectProto$1 = Object.prototype;
2282
+
2283
+ /** Used to check objects for own properties. */
2284
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2285
+
2286
+ /**
2287
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
2288
+ * deep comparisons and tracks traversed objects enabling objects with circular
2289
+ * references to be compared.
2290
+ *
2291
+ * @private
2292
+ * @param {Object} object The object to compare.
2293
+ * @param {Object} other The other object to compare.
2294
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2295
+ * @param {Function} customizer The function to customize comparisons.
2296
+ * @param {Function} equalFunc The function to determine equivalents of values.
2297
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
2298
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2299
+ */
2300
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2301
+ var objIsArr = isArray$1(object),
2302
+ othIsArr = isArray$1(other),
2303
+ objTag = objIsArr ? arrayTag : getTag$1(object),
2304
+ othTag = othIsArr ? arrayTag : getTag$1(other);
2305
+
2306
+ objTag = objTag == argsTag ? objectTag : objTag;
2307
+ othTag = othTag == argsTag ? objectTag : othTag;
2308
+
2309
+ var objIsObj = objTag == objectTag,
2310
+ othIsObj = othTag == objectTag,
2311
+ isSameTag = objTag == othTag;
2312
+
2313
+ if (isSameTag && isBuffer$1(object)) {
2314
+ if (!isBuffer$1(other)) {
2315
+ return false;
2316
+ }
2317
+ objIsArr = true;
2318
+ objIsObj = false;
2319
+ }
2320
+ if (isSameTag && !objIsObj) {
2321
+ stack || (stack = new Stack);
2322
+ return (objIsArr || isTypedArray$1(object))
2323
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
2324
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
2325
+ }
2326
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
2327
+ var objIsWrapped = objIsObj && hasOwnProperty$1.call(object, '__wrapped__'),
2328
+ othIsWrapped = othIsObj && hasOwnProperty$1.call(other, '__wrapped__');
2329
+
2330
+ if (objIsWrapped || othIsWrapped) {
2331
+ var objUnwrapped = objIsWrapped ? object.value() : object,
2332
+ othUnwrapped = othIsWrapped ? other.value() : other;
2333
+
2334
+ stack || (stack = new Stack);
2335
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
2336
+ }
2337
+ }
2338
+ if (!isSameTag) {
2339
+ return false;
2340
+ }
2341
+ stack || (stack = new Stack);
2342
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
2343
+ }
2344
+
2345
+ /**
2346
+ * The base implementation of `_.isEqual` which supports partial comparisons
2347
+ * and tracks traversed objects.
2348
+ *
2349
+ * @private
2350
+ * @param {*} value The value to compare.
2351
+ * @param {*} other The other value to compare.
2352
+ * @param {boolean} bitmask The bitmask flags.
2353
+ * 1 - Unordered comparison
2354
+ * 2 - Partial comparison
2355
+ * @param {Function} [customizer] The function to customize comparisons.
2356
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
2357
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2358
+ */
2359
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
2360
+ if (value === other) {
2361
+ return true;
2362
+ }
2363
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
2364
+ return value !== value && other !== other;
2365
+ }
2366
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
2367
+ }
2368
+
2369
+ /**
2370
+ * The base implementation of `_.values` and `_.valuesIn` which creates an
2371
+ * array of `object` property values corresponding to the property names
2372
+ * of `props`.
2373
+ *
2374
+ * @private
2375
+ * @param {Object} object The object to query.
2376
+ * @param {Array} props The property names to get values for.
2377
+ * @returns {Object} Returns the array of property values.
2378
+ */
2379
+ function baseValues(object, props) {
2380
+ return arrayMap(props, function(key) {
2381
+ return object[key];
2382
+ });
2383
+ }
2384
+
2385
+ /**
2386
+ * Creates an array of the own enumerable string keyed property values of `object`.
2387
+ *
2388
+ * **Note:** Non-object values are coerced to objects.
2389
+ *
2390
+ * @static
2391
+ * @since 0.1.0
2392
+ * @memberOf _
2393
+ * @category Object
2394
+ * @param {Object} object The object to query.
2395
+ * @returns {Array} Returns the array of property values.
2396
+ * @example
2397
+ *
2398
+ * function Foo() {
2399
+ * this.a = 1;
2400
+ * this.b = 2;
2401
+ * }
2402
+ *
2403
+ * Foo.prototype.c = 3;
2404
+ *
2405
+ * _.values(new Foo);
2406
+ * // => [1, 2] (iteration order is not guaranteed)
2407
+ *
2408
+ * _.values('hi');
2409
+ * // => ['h', 'i']
2410
+ */
2411
+ function values(object) {
2412
+ return object == null ? [] : baseValues(object, keys(object));
2413
+ }
2414
+
2415
+ /** `Object#toString` result references. */
2416
+ var mapTag = '[object Map]',
2417
+ setTag = '[object Set]';
2418
+
2419
+ /** Used for built-in method references. */
2420
+ var objectProto = Object.prototype;
2421
+
2422
+ /** Used to check objects for own properties. */
2423
+ var hasOwnProperty = objectProto.hasOwnProperty;
2424
+
2425
+ /**
2426
+ * Checks if `value` is an empty object, collection, map, or set.
2427
+ *
2428
+ * Objects are considered empty if they have no own enumerable string keyed
2429
+ * properties.
2430
+ *
2431
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
2432
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
2433
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
2434
+ *
2435
+ * @static
2436
+ * @memberOf _
2437
+ * @since 0.1.0
2438
+ * @category Lang
2439
+ * @param {*} value The value to check.
2440
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
2441
+ * @example
2442
+ *
2443
+ * _.isEmpty(null);
2444
+ * // => true
2445
+ *
2446
+ * _.isEmpty(true);
2447
+ * // => true
2448
+ *
2449
+ * _.isEmpty(1);
2450
+ * // => true
2451
+ *
2452
+ * _.isEmpty([1, 2, 3]);
2453
+ * // => false
2454
+ *
2455
+ * _.isEmpty({ 'a': 1 });
2456
+ * // => false
2457
+ */
2458
+ function isEmpty(value) {
2459
+ if (value == null) {
2460
+ return true;
2461
+ }
2462
+ if (isArrayLike(value) &&
2463
+ (isArray$1(value) || typeof value == 'string' || typeof value.splice == 'function' ||
2464
+ isBuffer$1(value) || isTypedArray$1(value) || isArguments$1(value))) {
2465
+ return !value.length;
2466
+ }
2467
+ var tag = getTag$1(value);
2468
+ if (tag == mapTag || tag == setTag) {
2469
+ return !value.size;
2470
+ }
2471
+ if (isPrototype(value)) {
2472
+ return !baseKeys(value).length;
2473
+ }
2474
+ for (var key in value) {
2475
+ if (hasOwnProperty.call(value, key)) {
2476
+ return false;
2477
+ }
2478
+ }
2479
+ return true;
2480
+ }
2481
+
2482
+ /**
2483
+ * Performs a deep comparison between two values to determine if they are
2484
+ * equivalent.
2485
+ *
2486
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
2487
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
2488
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
2489
+ * by their own, not inherited, enumerable properties. Functions and DOM
2490
+ * nodes are compared by strict equality, i.e. `===`.
2491
+ *
2492
+ * @static
2493
+ * @memberOf _
2494
+ * @since 0.1.0
2495
+ * @category Lang
2496
+ * @param {*} value The value to compare.
2497
+ * @param {*} other The other value to compare.
2498
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2499
+ * @example
2500
+ *
2501
+ * var object = { 'a': 1 };
2502
+ * var other = { 'a': 1 };
2503
+ *
2504
+ * _.isEqual(object, other);
2505
+ * // => true
2506
+ *
2507
+ * object === other;
2508
+ * // => false
2509
+ */
2510
+ function isEqual(value, other) {
2511
+ return baseIsEqual(value, other);
2512
+ }
2513
+
2514
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2515
+ var nativeFloor = Math.floor,
2516
+ nativeRandom = Math.random;
2517
+
2518
+ /**
2519
+ * The base implementation of `_.random` without support for returning
2520
+ * floating-point numbers.
2521
+ *
2522
+ * @private
2523
+ * @param {number} lower The lower bound.
2524
+ * @param {number} upper The upper bound.
2525
+ * @returns {number} Returns the random number.
2526
+ */
2527
+ function baseRandom(lower, upper) {
2528
+ return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
2529
+ }
2530
+
2531
+ /**
2532
+ * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
2533
+ *
2534
+ * @private
2535
+ * @param {Array} array The array to shuffle.
2536
+ * @param {number} [size=array.length] The size of `array`.
2537
+ * @returns {Array} Returns `array`.
2538
+ */
2539
+ function shuffleSelf(array, size) {
2540
+ var index = -1,
2541
+ length = array.length,
2542
+ lastIndex = length - 1;
2543
+
2544
+ size = size === undefined ? length : size;
2545
+ while (++index < size) {
2546
+ var rand = baseRandom(index, lastIndex),
2547
+ value = array[rand];
2548
+
2549
+ array[rand] = array[index];
2550
+ array[index] = value;
2551
+ }
2552
+ array.length = size;
2553
+ return array;
2554
+ }
2555
+
2556
+ /**
2557
+ * A specialized version of `_.shuffle` for arrays.
2558
+ *
2559
+ * @private
2560
+ * @param {Array} array The array to shuffle.
2561
+ * @returns {Array} Returns the new shuffled array.
2562
+ */
2563
+ function arrayShuffle(array) {
2564
+ return shuffleSelf(copyArray(array));
2565
+ }
2566
+
2567
+ /**
2568
+ * The base implementation of `_.shuffle`.
2569
+ *
2570
+ * @private
2571
+ * @param {Array|Object} collection The collection to shuffle.
2572
+ * @returns {Array} Returns the new shuffled array.
2573
+ */
2574
+ function baseShuffle(collection) {
2575
+ return shuffleSelf(values(collection));
2576
+ }
2577
+
2578
+ /**
2579
+ * Creates an array of shuffled values, using a version of the
2580
+ * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
2581
+ *
2582
+ * @static
2583
+ * @memberOf _
2584
+ * @since 0.1.0
2585
+ * @category Collection
2586
+ * @param {Array|Object} collection The collection to shuffle.
2587
+ * @returns {Array} Returns the new shuffled array.
2588
+ * @example
2589
+ *
2590
+ * _.shuffle([1, 2, 3, 4]);
2591
+ * // => [4, 1, 3, 2]
2592
+ */
2593
+ function shuffle(collection) {
2594
+ var func = isArray$1(collection) ? arrayShuffle : baseShuffle;
2595
+ return func(collection);
2596
+ }
2597
+
2598
+ const getCorrectResponse = (choices) =>
2599
+ choices
2600
+ .filter((c) => c.correct)
2601
+ .map((c) => c.value)
2602
+ .sort();
2603
+
2604
+ const isResponseCorrect = (question, session) => {
2605
+ let correctResponse = getCorrectResponse(question.choices);
2606
+ return session && isEqual((session.value || []).sort(), correctResponse);
2607
+ };
2608
+
2609
+ var defaults = {
2610
+ choiceMode: 'checkbox',
2611
+ choicePrefix: 'letters',
2612
+ choices: [],
2613
+ choicesLayout: 'vertical',
2614
+ feedbackEnabled: false,
2615
+ gridColumns: 2,
2616
+ lockChoiceOrder: true,
2617
+ partialScoring: true,
2618
+ prompt: '',
2619
+ promptEnabled: true,
2620
+ rationale: '',
2621
+ rationaleEnabled: true,
2622
+ scoringType: 'auto',
2623
+ studentInstructionsEnabled: true,
2624
+ teacherInstructions: '',
2625
+ teacherInstructionsEnabled: true,
2626
+ toolbarEditorPosition: 'bottom',
2627
+ selectedAnswerBackgroundColor: 'initial',
2628
+ selectedAnswerStrokeColor: 'initial',
2629
+ selectedAnswerStrokeWidth: 'initial',
2630
+ hoverAnswerBackgroundColor: 'initial',
2631
+ hoverAnswerStrokeColor: 'initial',
2632
+ hoverAnswerStrokeWidth: 'initial',
2633
+ keyboardEventsEnabled: false,
2634
+ };
2635
+
2636
+ const enabled = (config, env, defaultValue) => {
2637
+ // if model.partialScoring = false
2638
+ // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
2639
+ // else if model.partialScoring = true || undefined
2640
+ // - if env.partialScoring = false, use dichotomous scoring
2641
+ // - else if env.partialScoring = true, use partial scoring
2642
+ config = config || {};
2643
+ env = env || {};
2644
+
2645
+ if (config.partialScoring === false) {
2646
+ return false;
2647
+ }
2648
+
2649
+ if (env.partialScoring === false) {
2650
+ return false;
2651
+ }
2652
+
2653
+ return typeof defaultValue === 'boolean' ? defaultValue : true;
2654
+ };
2655
+
2656
+ // eslint-disable-next-line no-console
2657
+ const lg = (n) => console[n].bind(console, 'controller-utils:');
2658
+ const debug = lg('debug');
2659
+ const log = lg('log');
2660
+ const warn = lg('warn');
2661
+ const error = lg('error');
2662
+
2663
+ const compact = (arr) => {
2664
+ if (Array.isArray(arr)) {
2665
+ return arr.filter((v) => v !== null && v !== undefined);
2666
+ }
2667
+
2668
+ return arr;
2669
+ };
2670
+
2671
+ const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
2672
+ new Promise((resolve) => {
2673
+ log('updateSession type: ', typeof updateSession);
2674
+ log('session: ', session);
2675
+
2676
+ const currentShuffled = compact(session?.data?.shuffledValues || session?.shuffledValues || []);
2677
+
2678
+ if (!session) {
2679
+ // eslint-disable-next-line quotes
2680
+ warn("unable to save shuffled choices because there's no session.");
2681
+ resolve(undefined);
2682
+ } else if (!isEmpty(currentShuffled)) {
2683
+ debug('use shuffledValues to sort the choices...', currentShuffled);
2684
+ resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));
2685
+ } else {
2686
+ const shuffledChoices = shuffle(choices);
2687
+
2688
+ if (updateSession && typeof updateSession === 'function') {
2689
+ try {
2690
+ //Note: session.id refers to the id of the element within a session
2691
+ const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));
2692
+ log('try to save shuffledValues to session...', shuffledValues);
2693
+ log('call updateSession... ', session.id, session.element);
2694
+
2695
+ if (isEmpty(shuffledValues)) {
2696
+ error(
2697
+ `shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(
2698
+ shuffledChoices,
2699
+ )}, key: ${choiceKey}`,
2700
+ );
2701
+ } else {
2702
+ updateSession(session.id, session.element, { shuffledValues }).catch((e) =>
2703
+ // eslint-disable-next-line no-console
2704
+ console.error('update session failed for: ', session.id, e),
2705
+ );
2706
+ }
2707
+ } catch (e) {
2708
+ warn('unable to save shuffled order for choices');
2709
+ error(e);
2710
+ }
2711
+ } else {
2712
+ warn('unable to save shuffled choices, shuffle will happen every time.');
2713
+ }
2714
+
2715
+ //save this shuffle to the session for later retrieval
2716
+ resolve(shuffledChoices);
2717
+ }
2718
+ });
2719
+
2720
+ /**
2721
+ * If we return:
2722
+ * - true - that means that the order of the choices will be ordinal (as is created in the configure item)
2723
+ * - false - that means the getShuffledChoices above will be called and that in turn means that we either
2724
+ * return the shuffled values on the session (if any exists) or we shuffle the choices
2725
+ * @param model - model to check if we should lock order
2726
+ * @param session - session to check if we should lock order
2727
+ * @param env - env to check if we should lock order
2728
+ * @returns {boolean}
2729
+ */
2730
+ const lockChoices = (model, session, env) => {
2731
+ if (model.lockChoiceOrder) {
2732
+ return true;
2733
+ }
2734
+
2735
+ log('lockChoiceOrder: ', get(env, ['@pie-element', 'lockChoiceOrder'], false));
2736
+
2737
+ if (get(env, ['@pie-element', 'lockChoiceOrder'], false)) {
2738
+ return true;
2739
+ }
2740
+
2741
+ const role = get(env, 'role', 'student');
2742
+
2743
+ if (role === 'instructor') {
2744
+ // TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
2745
+ /*const alreadyShuffled = hasShuffledValues(session);
2746
+
2747
+ if (alreadyShuffled) {
2748
+ return false;
2749
+ }
2750
+
2751
+ return true;*/
2752
+ return true;
2753
+ }
2754
+
2755
+ // here it's a student, so don't lock and it will shuffle if needs be
2756
+ return false;
2757
+ };
2758
+
2759
+ /* eslint-disable no-console */
2760
+
2761
+ const prepareChoice = (model, env, defaultFeedback) => (choice) => {
2762
+ const { role, mode } = env || {};
2763
+ const out = {
2764
+ label: choice.label,
2765
+ value: choice.value,
2766
+ };
2767
+
2768
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
2769
+ out.rationale = model.rationaleEnabled ? choice.rationale : null;
2770
+ } else {
2771
+ out.rationale = null;
2772
+ }
2773
+
2774
+ if (mode === 'evaluate') {
2775
+ out.correct = !!choice.correct;
2776
+
2777
+ if (model.feedbackEnabled) {
2778
+ const feedbackType = (choice.feedback && choice.feedback.type) || 'none';
2779
+
2780
+ if (feedbackType === 'default') {
2781
+ out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
2782
+ } else if (feedbackType === 'custom') {
2783
+ out.feedback = choice.feedback.value;
2784
+ }
2785
+ }
2786
+ }
2787
+
2788
+ return out;
2789
+ };
2790
+
2791
+ function createDefaultModel(model = {}) {
2792
+ return new Promise((resolve) => resolve({ ...defaults, ...model }));
2793
+ }
2794
+
2795
+ const normalize = (question) => {
2796
+ const { verticalMode, choicesLayout, ...questionProps } = question || {};
2797
+
2798
+ return {
2799
+ ...defaults,
2800
+ ...questionProps,
2801
+ // This is used for offering support for old models which have the property verticalMode
2802
+ // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel
2803
+ choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout,
2804
+ };
2805
+ };
2806
+
2807
+ /**
2808
+ *
2809
+ * @param {*} question
2810
+ * @param {*} session
2811
+ * @param {*} env
2812
+ * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
2813
+ */
2814
+ async function model(question, session, env, updateSession) {
2815
+ const normalizedQuestion = normalize(question);
2816
+
2817
+ const defaultFeedback = Object.assign(
2818
+ { correct: 'Correct', incorrect: 'Incorrect' },
2819
+ normalizedQuestion.defaultFeedback,
2820
+ );
2821
+
2822
+ let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));
2823
+
2824
+ const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);
2825
+
2826
+ if (!lockChoiceOrder) {
2827
+ choices = await getShuffledChoices(choices, session, updateSession, 'value');
2828
+ }
2829
+
2830
+ const out = {
2831
+ disabled: env.mode !== 'gather',
2832
+ mode: env.mode,
2833
+ prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
2834
+ choicesLayout: normalizedQuestion.choicesLayout,
2835
+ gridColumns: normalizedQuestion.gridColumns,
2836
+ choiceMode: normalizedQuestion.choiceMode,
2837
+ keyMode: normalizedQuestion.choicePrefix,
2838
+ choices,
2839
+ responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,
2840
+ language: normalizedQuestion.language,
2841
+ extraCSSRules: normalizedQuestion.extraCSSRules,
2842
+ fontSizeFactor: normalizedQuestion.fontSizeFactor,
2843
+ isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,
2844
+ selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',
2845
+ selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',
2846
+ selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',
2847
+ hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',
2848
+ hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',
2849
+ hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',
2850
+ minSelections: normalizedQuestion.minSelections,
2851
+ maxSelections: normalizedQuestion.maxSelections,
2852
+ keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,
2853
+ autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,
2854
+ completeAudioEnabled: normalizedQuestion.completeAudioEnabled,
2855
+ customAudioButton: normalizedQuestion.customAudioButton,
2856
+ };
2857
+
2858
+ const { role, mode } = env || {};
2859
+
2860
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
2861
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled
2862
+ ? normalizedQuestion.teacherInstructions
2863
+ : null;
2864
+ } else {
2865
+ out.teacherInstructions = null;
2866
+ }
2867
+
2868
+ return out;
2869
+ }
2870
+
2871
+ const getScore = (config, session) => {
2872
+ if (!session || isEmpty(session)) {
2873
+ return 0;
2874
+ }
2875
+
2876
+ const selectedChoices = session.value || [];
2877
+ const correctChoices = (config.choices || []).filter((ch) => ch.correct);
2878
+
2879
+ let score = selectedChoices.reduce(
2880
+ (acc, selectedChoice) => acc + (correctChoices.find((ch) => ch.value === selectedChoice) ? 1 : 0),
2881
+ 0,
2882
+ );
2883
+
2884
+ if (correctChoices.length < selectedChoices.length) {
2885
+ score -= selectedChoices.length - correctChoices.length;
2886
+
2887
+ if (score < 0) {
2888
+ score = 0;
2889
+ }
2890
+ }
2891
+
2892
+ const str = correctChoices.length ? score / correctChoices.length : 0;
2893
+
2894
+ return parseFloat(str.toFixed(2));
2895
+ };
2896
+
2897
+ /**
2898
+ * Generates detailed trace log for scoring evaluation
2899
+ * @param {Object} model - the question model
2900
+ * @param {Object} session - the student session
2901
+ * @param {Object} env - the environment
2902
+ * @returns {Array} traceLog - array of trace messages
2903
+ */
2904
+ const getLogTrace = (model, session, env) => {
2905
+ const traceLog = [];
2906
+ const selected = session?.value || [];
2907
+
2908
+ const questionType = model.choiceMode === 'radio' ? 'multiple-choice (radio)' : 'multiple-select (checkbox)';
2909
+ traceLog.push(`Question type: ${questionType}.`);
2910
+
2911
+ if (selected.length) {
2912
+ traceLog.push(`Student selected ${selected.length} answer(s): ${selected.join(', ')}.`);
2913
+ } else {
2914
+ traceLog.push('Student did not select any answers.');
2915
+ }
2916
+
2917
+ const correctChoices = (model.choices || []).filter((c) => c.correct);
2918
+ const correctValues = correctChoices.map((c) => c.value);
2919
+ traceLog.push(`${correctChoices.length} correct answer(s) are defined for this question.`);
2920
+
2921
+ if (selected.length) {
2922
+ const correctSelected = selected.filter((v) => correctValues.includes(v));
2923
+ const incorrectSelected = selected.filter((v) => !correctValues.includes(v));
2924
+ traceLog.push(
2925
+ `Student selected ${correctSelected.length} correct and ${incorrectSelected.length} incorrect answer(s).`
2926
+ );
2927
+ }
2928
+
2929
+ const partialScoringEnabled = enabled(model, env) && model.choiceMode !== 'radio';
2930
+ const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';
2931
+ traceLog.push(`Score calculated using ${scoringMethod}.`);
2932
+
2933
+ const score = getScore(model, session);
2934
+ traceLog.push(`Final score: ${score}.`);
2935
+
2936
+ return traceLog;
2937
+ };
2938
+
2939
+ /**
2940
+ *
2941
+ * The score is partial by default for checkbox mode, allOrNothing for radio mode.
2942
+ * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will
2943
+ * override the value in `model`.
2944
+ * @param {Object} model - the main model
2945
+ * @param {*} session
2946
+ * @param {Object} env
2947
+ */
2948
+ function outcome(model, session, env) {
2949
+ return new Promise((resolve) => {
2950
+ if (!session || isEmpty(session)) {
2951
+ resolve({ score: 0, empty: true, traceLog: ['Student did not select any answers. Score is 0.'] });
2952
+ } else {
2953
+ const traceLog = getLogTrace(model, session, env);
2954
+ const score = getScore(model, session);
2955
+ const partialScoringEnabled = enabled(model, env) && model.choiceMode !== 'radio';
2956
+
2957
+ resolve({
2958
+ score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
2959
+ empty: false,
2960
+ traceLog
2961
+ });
2962
+ }
2963
+ });
2964
+ }
2965
+
2966
+ const createCorrectResponseSession = (question, env) => {
2967
+ return new Promise((resolve) => {
2968
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
2969
+ const { choices } = question || { choices: [] };
2970
+
2971
+ resolve({
2972
+ id: '1',
2973
+ value: choices.filter((c) => c.correct).map((c) => c.value),
2974
+ });
2975
+ } else {
2976
+ resolve(null);
2977
+ }
2978
+ });
2979
+ };
2980
+
2981
+ // remove all html tags except img, iframe and source tag for audio
2982
+ const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
2983
+
2984
+ const validate = (model = {}, config = {}) => {
2985
+ const { choices } = model;
2986
+ const { minAnswerChoices = 2, maxAnswerChoices } = config;
2987
+ const reversedChoices = [...(choices || [])].reverse();
2988
+ const choicesErrors = {};
2989
+ const rationaleErrors = {};
2990
+ const errors = {};
2991
+
2992
+ ['teacherInstructions', 'prompt'].forEach((field) => {
2993
+ if (config[field]?.required && !getContent(model[field])) {
2994
+ errors[field] = 'This field is required.';
2995
+ }
2996
+ });
2997
+
2998
+ let hasCorrectResponse = false;
2999
+
3000
+ reversedChoices.forEach((choice, index) => {
3001
+ const { correct, value, label, rationale } = choice;
3002
+
3003
+ if (correct) {
3004
+ hasCorrectResponse = true;
3005
+ }
3006
+
3007
+ if (!getContent(label)) {
3008
+ choicesErrors[value] = 'Content should not be empty.';
3009
+ } else {
3010
+ const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);
3011
+
3012
+ if (identicalAnswer) {
3013
+ choicesErrors[value] = 'Content should be unique.';
3014
+ }
3015
+ }
3016
+
3017
+ if (config.rationale?.required && !getContent(rationale)) {
3018
+ rationaleErrors[value] = 'This field is required.';
3019
+ }
3020
+ });
3021
+
3022
+ const nbOfChoices = (choices || []).length;
3023
+
3024
+ if (nbOfChoices < minAnswerChoices) {
3025
+ errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
3026
+ } else if (nbOfChoices > maxAnswerChoices) {
3027
+ errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
3028
+ }
3029
+
3030
+ if (!hasCorrectResponse) {
3031
+ errors.correctResponse = 'No correct response defined.';
3032
+ }
3033
+
3034
+ if (!isEmpty(choicesErrors)) {
3035
+ errors.choices = choicesErrors;
3036
+ }
3037
+
3038
+ if (!isEmpty(rationaleErrors)) {
3039
+ errors.rationale = rationaleErrors;
3040
+ }
3041
+
3042
+ return errors;
3043
+ };
3044
+
3045
+ export { createCorrectResponseSession, createDefaultModel, getLogTrace, getScore, model, normalize, outcome, validate };