@khanacademy/perseus-core 3.0.4 → 3.1.0

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.
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
45
45
 
46
46
  // This file is processed by a Rollup plugin (replace) to inject the production
47
47
  const libName = "@khanacademy/perseus-core";
48
- const libVersion = "3.0.4";
48
+ const libVersion = "3.1.0";
49
49
  addLibraryVersionToPerseusDebug(libName, libVersion);
50
50
 
51
51
  /**
@@ -100,8 +100,2319 @@ class PerseusError extends Error {
100
100
  }
101
101
  }
102
102
 
103
+ /**
104
+ * The Perseus "data schema" file.
105
+ *
106
+ * This file, and the types in it, represents the "data schema" that Perseus
107
+ * uses. The @khanacademy/perseus-editor package edits and produces objects
108
+ * that conform to the types in this file. Similarly, the top-level renderers
109
+ * in @khanacademy/perseus, consume objects that conform to these types.
110
+ *
111
+ * WARNING: This file should not import any types from elsewhere so that it is
112
+ * easy to reason about changes that alter the Perseus schema. This helps
113
+ * ensure that it is not changed accidentally when upgrading a dependant
114
+ * package or other part of Perseus code. Note that TypeScript does type
115
+ * checking via something called "structural typing". This means that as long
116
+ * as the shape of a type matches, the name it goes by doesn't matter. As a
117
+ * result, a `Coord` type that looks like this `[x: number, y: number]` is
118
+ * _identical_, in TypeScript's eyes, to this `Vector2` type `[x: number, y:
119
+ * number]`. Also, with tuples, the labels for each entry is ignored, so `[x:
120
+ * number, y: number]` is compatible with `[min: number, max: number]`. The
121
+ * labels are for humans, not TypeScript. :)
122
+ *
123
+ * If you make changes to types in this file, be very sure that:
124
+ *
125
+ * a) the changes are backwards compatible. If they are not, old data from
126
+ * previous versions of the "schema" could become unrenderable, or worse,
127
+ * introduce hard-to-diagnose bugs.
128
+ * b) the parsing code (`util/parse-perseus-json/`) is updated to handle
129
+ * the new format _as well as_ the old format.
130
+ */
131
+
132
+ // TODO(FEI-4010): Remove `Perseus` prefix for all types here
133
+
134
+ // Same name as Mafs
135
+
136
+ /**
137
+ * Our core set of Perseus widgets.
138
+ *
139
+ * This interface is the basis for "registering" all Perseus widget types.
140
+ * There should be one key/value pair for each supported widget. If you create
141
+ * a new widget, an entry should be added to this interface. Note that this
142
+ * only registers the widget options type, you'll also need to register the
143
+ * widget so that it's available at runtime (@see
144
+ * {@link file://./widgets.ts#registerWidget}).
145
+ *
146
+ * Importantly, the key should be the name that is used in widget IDs. For most
147
+ * widgets that is the same as the widget option's `type` field. In cases where
148
+ * a widget has been deprecated and replaced with the deprecated-standin
149
+ * widget, it should be the original widget type!
150
+ *
151
+ * If you define the widget outside of this package, you can still add the new
152
+ * widget to this interface by writing the following in that package that
153
+ * contains the widget. TypeScript will merge that definition of the
154
+ * `PerseusWidgets` with the one defined below.
155
+ *
156
+ * ```typescript
157
+ * declare module "@khanacademy/perseus" {
158
+ * interface PerseusWidgetTypes {
159
+ * // A new widget
160
+ * "new-awesomeness": MyAwesomeNewWidget;
161
+ *
162
+ * // A deprecated widget
163
+ * "super-old-widget": DeprecatedStandinWidget;
164
+ * }
165
+ * }
166
+ *
167
+ * // The new widget's options definition
168
+ * type MyAwesomeNewWidget = WidgetOptions<'new-awesomeness', MyAwesomeNewWidgetOptions>;
169
+ *
170
+ * // The deprecated widget's options definition
171
+ * type SuperOldWidget = WidgetOptions<'super-old-widget', object>;
172
+ * ```
173
+ *
174
+ * This interface can be extended through the magic of TypeScript "Declaration
175
+ * merging". Specifically, we augment this module and extend this interface.
176
+ *
177
+ * @see {@link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation}
178
+ */
179
+
180
+ /**
181
+ * A map of widget IDs to widget options. This is most often used as the type
182
+ * for a set of widgets defined in a `PerseusItem` but can also be useful to
183
+ * represent a function parameter where only `widgets` from a `PerseusItem` are
184
+ * needed. Today Widget IDs are made up of the widget type and an incrementing
185
+ * integer (eg. `interactive-graph 1` or `radio 3`). It is suggested to avoid
186
+ * reading/parsing the widget id to derive any information from it, except in
187
+ * the case of this map.
188
+ *
189
+ * @see {@link PerseusWidgetTypes} additional widgets can be added to this map type
190
+ * by augmenting the PerseusWidgetTypes with new widget types!
191
+ */
192
+
193
+ /**
194
+ * A "PerseusItem" is a classic Perseus item. It is rendered by the
195
+ * `ServerItemRenderer` and the layout is pre-set.
196
+ *
197
+ * To render more complex Perseus items, see the `Item` type in the multi item
198
+ * area.
199
+ */
200
+
201
+ /**
202
+ * A "PerseusArticle" is an item that is meant to be rendered as an article.
203
+ * This item is never scored and is rendered by the `ArticleRenderer`.
204
+ */
205
+
206
+ const ItemExtras = [
207
+ // The user might benefit from using a Scientific Calculator. Provided on Khan Academy when true
208
+ "calculator",
209
+ // The user might benefit from using a statistics Chi Squared Table like https://people.richland.edu/james/lecture/m170/tbl-chi.html
210
+ "chi2Table",
211
+ // The user might benefit from a monthly payments calculator. Provided on Khan Academy when true
212
+ "financialCalculatorMonthlyPayment",
213
+ // The user might benefit from a total amount calculator. Provided on Khan Academy when true
214
+ "financialCalculatorTotalAmount",
215
+ // The user might benefit from a time to pay off calculator. Provided on Khan Academy when true
216
+ "financialCalculatorTimeToPayOff",
217
+ // The user might benefit from using a Periodic Table of Elements. Provided on Khan Academy when true
218
+ "periodicTable",
219
+ // The user might benefit from using a Periodic Table of Elements with key. Provided on Khan Academy when true
220
+ "periodicTableWithKey",
221
+ // The user might benefit from using a statistics T Table like https://www.statisticshowto.com/tables/t-distribution-table/
222
+ "tTable",
223
+ // The user might benefit from using a statistics Z Table like https://www.ztable.net/
224
+ "zTable"];
225
+
226
+ /**
227
+ * The type representing the common structure of all widget's options. The
228
+ * `Options` generic type represents the widget-specific option data.
229
+ */
230
+
231
+ // prettier-ignore
232
+
233
+ // prettier-ignore
234
+
235
+ // prettier-ignore
236
+
237
+ // prettier-ignore
238
+
239
+ // prettier-ignore
240
+
241
+ // prettier-ignore
242
+
243
+ // prettier-ignore
244
+
245
+ // prettier-ignore
246
+
247
+ // prettier-ignore
248
+
249
+ // prettier-ignore
250
+
251
+ // prettier-ignore
252
+
253
+ // prettier-ignore
254
+
255
+ // prettier-ignore
256
+
257
+ // prettier-ignore
258
+
259
+ // prettier-ignore
260
+
261
+ // prettier-ignore
262
+
263
+ // prettier-ignore
264
+
265
+ // prettier-ignore
266
+
267
+ // prettier-ignore
268
+
269
+ // prettier-ignore
270
+
271
+ // prettier-ignore
272
+
273
+ // prettier-ignore
274
+
275
+ // prettier-ignore
276
+
277
+ // prettier-ignore
278
+
279
+ // prettier-ignore
280
+
281
+ // prettier-ignore
282
+
283
+ // prettier-ignore
284
+
285
+ // prettier-ignore
286
+
287
+ // prettier-ignore
288
+
289
+ // prettier-ignore
290
+
291
+ // prettier-ignore
292
+
293
+ // prettier-ignore
294
+
295
+ // prettier-ignore
296
+
297
+ // prettier-ignore
298
+
299
+ //prettier-ignore
300
+
301
+ /**
302
+ * A background image applied to various widgets.
303
+ */
304
+
305
+ /**
306
+ * The type of markings to display on the graph.
307
+ * - axes: shows the axes without the gride lines
308
+ * - graph: shows the axes and the grid lines
309
+ * - grid: shows only the grid lines
310
+ * - none: shows no markings
311
+ */
312
+
313
+ const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
314
+
315
+ // 2D range: xMin, xMax, yMin, yMax
316
+
317
+ const lockedFigureColorNames = ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
318
+ const lockedFigureColors = {
319
+ blue: "#3D7586",
320
+ green: "#447A53",
321
+ grayH: "#3B3D45",
322
+ purple: "#594094",
323
+ pink: "#B25071",
324
+ red: "#D92916",
325
+ orange: "#946700"
326
+ };
327
+ const lockedFigureFillStyles = {
328
+ none: 0,
329
+ white: 1,
330
+ translucent: 0.4,
331
+ solid: 1
332
+ };
333
+
334
+ // Not associated with a specific figure
335
+
336
+ const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
337
+
338
+ // Current version.
339
+ var VERSION = '1.13.3';
340
+
341
+ // Establish the root object, `window` (`self`) in the browser, `global`
342
+ // on the server, or `this` in some virtual machines. We use `self`
343
+ // instead of `window` for `WebWorker` support.
344
+ var root = (typeof self == 'object' && self.self === self && self) ||
345
+ (typeof global == 'object' && global.global === global && global) ||
346
+ Function('return this')() ||
347
+ {};
348
+
349
+ // Save bytes in the minified (but not gzipped) version:
350
+ var ArrayProto = Array.prototype, ObjProto = Object.prototype;
351
+ var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
352
+
353
+ // Create quick reference variables for speed access to core prototypes.
354
+ var push = ArrayProto.push,
355
+ slice = ArrayProto.slice,
356
+ toString = ObjProto.toString,
357
+ hasOwnProperty = ObjProto.hasOwnProperty;
358
+
359
+ // Modern feature detection.
360
+ var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',
361
+ supportsDataView = typeof DataView !== 'undefined';
362
+
363
+ // All **ECMAScript 5+** native function implementations that we hope to use
364
+ // are declared here.
365
+ var nativeIsArray = Array.isArray,
366
+ nativeKeys = Object.keys,
367
+ nativeCreate = Object.create,
368
+ nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
369
+
370
+ // Create references to these builtin functions because we override them.
371
+ var _isNaN = isNaN,
372
+ _isFinite = isFinite;
373
+
374
+ // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
375
+ var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
376
+ var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
377
+ 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
378
+
379
+ // The largest integer that can be represented exactly.
380
+ var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
381
+
382
+ // Some functions take a variable number of arguments, or a few expected
383
+ // arguments at the beginning and then a variable number of values to operate
384
+ // on. This helper accumulates all remaining arguments past the function’s
385
+ // argument length (or an explicit `startIndex`), into an array that becomes
386
+ // the last argument. Similar to ES6’s "rest parameter".
387
+ function restArguments(func, startIndex) {
388
+ startIndex = startIndex == null ? func.length - 1 : +startIndex;
389
+ return function() {
390
+ var length = Math.max(arguments.length - startIndex, 0),
391
+ rest = Array(length),
392
+ index = 0;
393
+ for (; index < length; index++) {
394
+ rest[index] = arguments[index + startIndex];
395
+ }
396
+ switch (startIndex) {
397
+ case 0: return func.call(this, rest);
398
+ case 1: return func.call(this, arguments[0], rest);
399
+ case 2: return func.call(this, arguments[0], arguments[1], rest);
400
+ }
401
+ var args = Array(startIndex + 1);
402
+ for (index = 0; index < startIndex; index++) {
403
+ args[index] = arguments[index];
404
+ }
405
+ args[startIndex] = rest;
406
+ return func.apply(this, args);
407
+ };
408
+ }
409
+
410
+ // Is a given variable an object?
411
+ function isObject(obj) {
412
+ var type = typeof obj;
413
+ return type === 'function' || (type === 'object' && !!obj);
414
+ }
415
+
416
+ // Is a given value equal to null?
417
+ function isNull(obj) {
418
+ return obj === null;
419
+ }
420
+
421
+ // Is a given variable undefined?
422
+ function isUndefined(obj) {
423
+ return obj === void 0;
424
+ }
425
+
426
+ // Is a given value a boolean?
427
+ function isBoolean(obj) {
428
+ return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
429
+ }
430
+
431
+ // Is a given value a DOM element?
432
+ function isElement(obj) {
433
+ return !!(obj && obj.nodeType === 1);
434
+ }
435
+
436
+ // Internal function for creating a `toString`-based type tester.
437
+ function tagTester(name) {
438
+ var tag = '[object ' + name + ']';
439
+ return function(obj) {
440
+ return toString.call(obj) === tag;
441
+ };
442
+ }
443
+
444
+ var isString = tagTester('String');
445
+
446
+ var isNumber = tagTester('Number');
447
+
448
+ var isDate = tagTester('Date');
449
+
450
+ var isRegExp = tagTester('RegExp');
451
+
452
+ var isError = tagTester('Error');
453
+
454
+ var isSymbol = tagTester('Symbol');
455
+
456
+ var isArrayBuffer = tagTester('ArrayBuffer');
457
+
458
+ var isFunction = tagTester('Function');
459
+
460
+ // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old
461
+ // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
462
+ var nodelist = root.document && root.document.childNodes;
463
+ if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
464
+ isFunction = function(obj) {
465
+ return typeof obj == 'function' || false;
466
+ };
467
+ }
468
+
469
+ var isFunction$1 = isFunction;
470
+
471
+ var hasObjectTag = tagTester('Object');
472
+
473
+ // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.
474
+ // In IE 11, the most common among them, this problem also applies to
475
+ // `Map`, `WeakMap` and `Set`.
476
+ var hasStringTagBug = (
477
+ supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))
478
+ ),
479
+ isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));
480
+
481
+ var isDataView = tagTester('DataView');
482
+
483
+ // In IE 10 - Edge 13, we need a different heuristic
484
+ // to determine whether an object is a `DataView`.
485
+ function ie10IsDataView(obj) {
486
+ return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
487
+ }
488
+
489
+ var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);
490
+
491
+ // Is a given value an array?
492
+ // Delegates to ECMA5's native `Array.isArray`.
493
+ var isArray = nativeIsArray || tagTester('Array');
494
+
495
+ // Internal function to check whether `key` is an own property name of `obj`.
496
+ function has$1(obj, key) {
497
+ return obj != null && hasOwnProperty.call(obj, key);
498
+ }
499
+
500
+ var isArguments = tagTester('Arguments');
501
+
502
+ // Define a fallback version of the method in browsers (ahem, IE < 9), where
503
+ // there isn't any inspectable "Arguments" type.
504
+ (function() {
505
+ if (!isArguments(arguments)) {
506
+ isArguments = function(obj) {
507
+ return has$1(obj, 'callee');
508
+ };
509
+ }
510
+ }());
511
+
512
+ var isArguments$1 = isArguments;
513
+
514
+ // Is a given object a finite number?
515
+ function isFinite$1(obj) {
516
+ return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
517
+ }
518
+
519
+ // Is the given value `NaN`?
520
+ function isNaN$1(obj) {
521
+ return isNumber(obj) && _isNaN(obj);
522
+ }
523
+
524
+ // Predicate-generating function. Often useful outside of Underscore.
525
+ function constant(value) {
526
+ return function() {
527
+ return value;
528
+ };
529
+ }
530
+
531
+ // Common internal logic for `isArrayLike` and `isBufferLike`.
532
+ function createSizePropertyCheck(getSizeProperty) {
533
+ return function(collection) {
534
+ var sizeProperty = getSizeProperty(collection);
535
+ return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
536
+ }
537
+ }
538
+
539
+ // Internal helper to generate a function to obtain property `key` from `obj`.
540
+ function shallowProperty(key) {
541
+ return function(obj) {
542
+ return obj == null ? void 0 : obj[key];
543
+ };
544
+ }
545
+
546
+ // Internal helper to obtain the `byteLength` property of an object.
547
+ var getByteLength = shallowProperty('byteLength');
548
+
549
+ // Internal helper to determine whether we should spend extensive checks against
550
+ // `ArrayBuffer` et al.
551
+ var isBufferLike = createSizePropertyCheck(getByteLength);
552
+
553
+ // Is a given value a typed array?
554
+ var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
555
+ function isTypedArray(obj) {
556
+ // `ArrayBuffer.isView` is the most future-proof, so use it when available.
557
+ // Otherwise, fall back on the above regular expression.
558
+ return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :
559
+ isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
560
+ }
561
+
562
+ var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
563
+
564
+ // Internal helper to obtain the `length` property of an object.
565
+ var getLength = shallowProperty('length');
566
+
567
+ // Internal helper to create a simple lookup structure.
568
+ // `collectNonEnumProps` used to depend on `_.contains`, but this led to
569
+ // circular imports. `emulatedSet` is a one-off solution that only works for
570
+ // arrays of strings.
571
+ function emulatedSet(keys) {
572
+ var hash = {};
573
+ for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;
574
+ return {
575
+ contains: function(key) { return hash[key] === true; },
576
+ push: function(key) {
577
+ hash[key] = true;
578
+ return keys.push(key);
579
+ }
580
+ };
581
+ }
582
+
583
+ // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't
584
+ // be iterated by `for key in ...` and thus missed. Extends `keys` in place if
585
+ // needed.
586
+ function collectNonEnumProps(obj, keys) {
587
+ keys = emulatedSet(keys);
588
+ var nonEnumIdx = nonEnumerableProps.length;
589
+ var constructor = obj.constructor;
590
+ var proto = (isFunction$1(constructor) && constructor.prototype) || ObjProto;
591
+
592
+ // Constructor is a special case.
593
+ var prop = 'constructor';
594
+ if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop);
595
+
596
+ while (nonEnumIdx--) {
597
+ prop = nonEnumerableProps[nonEnumIdx];
598
+ if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) {
599
+ keys.push(prop);
600
+ }
601
+ }
602
+ }
603
+
604
+ // Retrieve the names of an object's own properties.
605
+ // Delegates to **ECMAScript 5**'s native `Object.keys`.
606
+ function keys(obj) {
607
+ if (!isObject(obj)) return [];
608
+ if (nativeKeys) return nativeKeys(obj);
609
+ var keys = [];
610
+ for (var key in obj) if (has$1(obj, key)) keys.push(key);
611
+ // Ahem, IE < 9.
612
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
613
+ return keys;
614
+ }
615
+
616
+ // Is a given array, string, or object empty?
617
+ // An "empty" object has no enumerable own-properties.
618
+ function isEmpty(obj) {
619
+ if (obj == null) return true;
620
+ // Skip the more expensive `toString`-based type checks if `obj` has no
621
+ // `.length`.
622
+ var length = getLength(obj);
623
+ if (typeof length == 'number' && (
624
+ isArray(obj) || isString(obj) || isArguments$1(obj)
625
+ )) return length === 0;
626
+ return getLength(keys(obj)) === 0;
627
+ }
628
+
629
+ // Returns whether an object has a given set of `key:value` pairs.
630
+ function isMatch(object, attrs) {
631
+ var _keys = keys(attrs), length = _keys.length;
632
+ if (object == null) return !length;
633
+ var obj = Object(object);
634
+ for (var i = 0; i < length; i++) {
635
+ var key = _keys[i];
636
+ if (attrs[key] !== obj[key] || !(key in obj)) return false;
637
+ }
638
+ return true;
639
+ }
640
+
641
+ // If Underscore is called as a function, it returns a wrapped object that can
642
+ // be used OO-style. This wrapper holds altered versions of all functions added
643
+ // through `_.mixin`. Wrapped objects may be chained.
644
+ function _$1(obj) {
645
+ if (obj instanceof _$1) return obj;
646
+ if (!(this instanceof _$1)) return new _$1(obj);
647
+ this._wrapped = obj;
648
+ }
649
+
650
+ _$1.VERSION = VERSION;
651
+
652
+ // Extracts the result from a wrapped and chained object.
653
+ _$1.prototype.value = function() {
654
+ return this._wrapped;
655
+ };
656
+
657
+ // Provide unwrapping proxies for some methods used in engine operations
658
+ // such as arithmetic and JSON stringification.
659
+ _$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
660
+
661
+ _$1.prototype.toString = function() {
662
+ return String(this._wrapped);
663
+ };
664
+
665
+ // Internal function to wrap or shallow-copy an ArrayBuffer,
666
+ // typed array or DataView to a new view, reusing the buffer.
667
+ function toBufferView(bufferSource) {
668
+ return new Uint8Array(
669
+ bufferSource.buffer || bufferSource,
670
+ bufferSource.byteOffset || 0,
671
+ getByteLength(bufferSource)
672
+ );
673
+ }
674
+
675
+ // We use this string twice, so give it a name for minification.
676
+ var tagDataView = '[object DataView]';
677
+
678
+ // Internal recursive comparison function for `_.isEqual`.
679
+ function eq(a, b, aStack, bStack) {
680
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
681
+ // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).
682
+ if (a === b) return a !== 0 || 1 / a === 1 / b;
683
+ // `null` or `undefined` only equal to itself (strict comparison).
684
+ if (a == null || b == null) return false;
685
+ // `NaN`s are equivalent, but non-reflexive.
686
+ if (a !== a) return b !== b;
687
+ // Exhaust primitive checks
688
+ var type = typeof a;
689
+ if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
690
+ return deepEq(a, b, aStack, bStack);
691
+ }
692
+
693
+ // Internal recursive comparison function for `_.isEqual`.
694
+ function deepEq(a, b, aStack, bStack) {
695
+ // Unwrap any wrapped objects.
696
+ if (a instanceof _$1) a = a._wrapped;
697
+ if (b instanceof _$1) b = b._wrapped;
698
+ // Compare `[[Class]]` names.
699
+ var className = toString.call(a);
700
+ if (className !== toString.call(b)) return false;
701
+ // Work around a bug in IE 10 - Edge 13.
702
+ if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) {
703
+ if (!isDataView$1(b)) return false;
704
+ className = tagDataView;
705
+ }
706
+ switch (className) {
707
+ // These types are compared by value.
708
+ case '[object RegExp]':
709
+ // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
710
+ case '[object String]':
711
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
712
+ // equivalent to `new String("5")`.
713
+ return '' + a === '' + b;
714
+ case '[object Number]':
715
+ // `NaN`s are equivalent, but non-reflexive.
716
+ // Object(NaN) is equivalent to NaN.
717
+ if (+a !== +a) return +b !== +b;
718
+ // An `egal` comparison is performed for other numeric values.
719
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b;
720
+ case '[object Date]':
721
+ case '[object Boolean]':
722
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
723
+ // millisecond representations. Note that invalid dates with millisecond representations
724
+ // of `NaN` are not equivalent.
725
+ return +a === +b;
726
+ case '[object Symbol]':
727
+ return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
728
+ case '[object ArrayBuffer]':
729
+ case tagDataView:
730
+ // Coerce to typed array so we can fall through.
731
+ return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);
732
+ }
733
+
734
+ var areArrays = className === '[object Array]';
735
+ if (!areArrays && isTypedArray$1(a)) {
736
+ var byteLength = getByteLength(a);
737
+ if (byteLength !== getByteLength(b)) return false;
738
+ if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;
739
+ areArrays = true;
740
+ }
741
+ if (!areArrays) {
742
+ if (typeof a != 'object' || typeof b != 'object') return false;
743
+
744
+ // Objects with different constructors are not equivalent, but `Object`s or `Array`s
745
+ // from different frames are.
746
+ var aCtor = a.constructor, bCtor = b.constructor;
747
+ if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor &&
748
+ isFunction$1(bCtor) && bCtor instanceof bCtor)
749
+ && ('constructor' in a && 'constructor' in b)) {
750
+ return false;
751
+ }
752
+ }
753
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
754
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
755
+
756
+ // Initializing stack of traversed objects.
757
+ // It's done here since we only need them for objects and arrays comparison.
758
+ aStack = aStack || [];
759
+ bStack = bStack || [];
760
+ var length = aStack.length;
761
+ while (length--) {
762
+ // Linear search. Performance is inversely proportional to the number of
763
+ // unique nested structures.
764
+ if (aStack[length] === a) return bStack[length] === b;
765
+ }
766
+
767
+ // Add the first object to the stack of traversed objects.
768
+ aStack.push(a);
769
+ bStack.push(b);
770
+
771
+ // Recursively compare objects and arrays.
772
+ if (areArrays) {
773
+ // Compare array lengths to determine if a deep comparison is necessary.
774
+ length = a.length;
775
+ if (length !== b.length) return false;
776
+ // Deep compare the contents, ignoring non-numeric properties.
777
+ while (length--) {
778
+ if (!eq(a[length], b[length], aStack, bStack)) return false;
779
+ }
780
+ } else {
781
+ // Deep compare objects.
782
+ var _keys = keys(a), key;
783
+ length = _keys.length;
784
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
785
+ if (keys(b).length !== length) return false;
786
+ while (length--) {
787
+ // Deep compare each member
788
+ key = _keys[length];
789
+ if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
790
+ }
791
+ }
792
+ // Remove the first object from the stack of traversed objects.
793
+ aStack.pop();
794
+ bStack.pop();
795
+ return true;
796
+ }
797
+
798
+ // Perform a deep comparison to check if two objects are equal.
799
+ function isEqual(a, b) {
800
+ return eq(a, b);
801
+ }
802
+
803
+ // Retrieve all the enumerable property names of an object.
804
+ function allKeys(obj) {
805
+ if (!isObject(obj)) return [];
806
+ var keys = [];
807
+ for (var key in obj) keys.push(key);
808
+ // Ahem, IE < 9.
809
+ if (hasEnumBug) collectNonEnumProps(obj, keys);
810
+ return keys;
811
+ }
812
+
813
+ // Since the regular `Object.prototype.toString` type tests don't work for
814
+ // some types in IE 11, we use a fingerprinting heuristic instead, based
815
+ // on the methods. It's not great, but it's the best we got.
816
+ // The fingerprint method lists are defined below.
817
+ function ie11fingerprint(methods) {
818
+ var length = getLength(methods);
819
+ return function(obj) {
820
+ if (obj == null) return false;
821
+ // `Map`, `WeakMap` and `Set` have no enumerable keys.
822
+ var keys = allKeys(obj);
823
+ if (getLength(keys)) return false;
824
+ for (var i = 0; i < length; i++) {
825
+ if (!isFunction$1(obj[methods[i]])) return false;
826
+ }
827
+ // If we are testing against `WeakMap`, we need to ensure that
828
+ // `obj` doesn't have a `forEach` method in order to distinguish
829
+ // it from a regular `Map`.
830
+ return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);
831
+ };
832
+ }
833
+
834
+ // In the interest of compact minification, we write
835
+ // each string in the fingerprints only once.
836
+ var forEachName = 'forEach',
837
+ hasName = 'has',
838
+ commonInit = ['clear', 'delete'],
839
+ mapTail = ['get', hasName, 'set'];
840
+
841
+ // `Map`, `WeakMap` and `Set` each have slightly different
842
+ // combinations of the above sublists.
843
+ var mapMethods = commonInit.concat(forEachName, mapTail),
844
+ weakMapMethods = commonInit.concat(mapTail),
845
+ setMethods = ['add'].concat(commonInit, forEachName, hasName);
846
+
847
+ var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map');
848
+
849
+ var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap');
850
+
851
+ var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set');
852
+
853
+ var isWeakSet = tagTester('WeakSet');
854
+
855
+ // Retrieve the values of an object's properties.
856
+ function values(obj) {
857
+ var _keys = keys(obj);
858
+ var length = _keys.length;
859
+ var values = Array(length);
860
+ for (var i = 0; i < length; i++) {
861
+ values[i] = obj[_keys[i]];
862
+ }
863
+ return values;
864
+ }
865
+
866
+ // Convert an object into a list of `[key, value]` pairs.
867
+ // The opposite of `_.object` with one argument.
868
+ function pairs(obj) {
869
+ var _keys = keys(obj);
870
+ var length = _keys.length;
871
+ var pairs = Array(length);
872
+ for (var i = 0; i < length; i++) {
873
+ pairs[i] = [_keys[i], obj[_keys[i]]];
874
+ }
875
+ return pairs;
876
+ }
877
+
878
+ // Invert the keys and values of an object. The values must be serializable.
879
+ function invert(obj) {
880
+ var result = {};
881
+ var _keys = keys(obj);
882
+ for (var i = 0, length = _keys.length; i < length; i++) {
883
+ result[obj[_keys[i]]] = _keys[i];
884
+ }
885
+ return result;
886
+ }
887
+
888
+ // Return a sorted list of the function names available on the object.
889
+ function functions(obj) {
890
+ var names = [];
891
+ for (var key in obj) {
892
+ if (isFunction$1(obj[key])) names.push(key);
893
+ }
894
+ return names.sort();
895
+ }
896
+
897
+ // An internal function for creating assigner functions.
898
+ function createAssigner(keysFunc, defaults) {
899
+ return function(obj) {
900
+ var length = arguments.length;
901
+ if (defaults) obj = Object(obj);
902
+ if (length < 2 || obj == null) return obj;
903
+ for (var index = 1; index < length; index++) {
904
+ var source = arguments[index],
905
+ keys = keysFunc(source),
906
+ l = keys.length;
907
+ for (var i = 0; i < l; i++) {
908
+ var key = keys[i];
909
+ if (!defaults || obj[key] === void 0) obj[key] = source[key];
910
+ }
911
+ }
912
+ return obj;
913
+ };
914
+ }
915
+
916
+ // Extend a given object with all the properties in passed-in object(s).
917
+ var extend = createAssigner(allKeys);
918
+
919
+ // Assigns a given object with all the own properties in the passed-in
920
+ // object(s).
921
+ // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
922
+ var extendOwn = createAssigner(keys);
923
+
924
+ // Fill in a given object with default properties.
925
+ var defaults = createAssigner(allKeys, true);
926
+
927
+ // Create a naked function reference for surrogate-prototype-swapping.
928
+ function ctor() {
929
+ return function(){};
930
+ }
931
+
932
+ // An internal function for creating a new object that inherits from another.
933
+ function baseCreate(prototype) {
934
+ if (!isObject(prototype)) return {};
935
+ if (nativeCreate) return nativeCreate(prototype);
936
+ var Ctor = ctor();
937
+ Ctor.prototype = prototype;
938
+ var result = new Ctor;
939
+ Ctor.prototype = null;
940
+ return result;
941
+ }
942
+
943
+ // Creates an object that inherits from the given prototype object.
944
+ // If additional properties are provided then they will be added to the
945
+ // created object.
946
+ function create(prototype, props) {
947
+ var result = baseCreate(prototype);
948
+ if (props) extendOwn(result, props);
949
+ return result;
950
+ }
951
+
952
+ // Create a (shallow-cloned) duplicate of an object.
953
+ function clone(obj) {
954
+ if (!isObject(obj)) return obj;
955
+ return isArray(obj) ? obj.slice() : extend({}, obj);
956
+ }
957
+
958
+ // Invokes `interceptor` with the `obj` and then returns `obj`.
959
+ // The primary purpose of this method is to "tap into" a method chain, in
960
+ // order to perform operations on intermediate results within the chain.
961
+ function tap(obj, interceptor) {
962
+ interceptor(obj);
963
+ return obj;
964
+ }
965
+
966
+ // Normalize a (deep) property `path` to array.
967
+ // Like `_.iteratee`, this function can be customized.
968
+ function toPath$1(path) {
969
+ return isArray(path) ? path : [path];
970
+ }
971
+ _$1.toPath = toPath$1;
972
+
973
+ // Internal wrapper for `_.toPath` to enable minification.
974
+ // Similar to `cb` for `_.iteratee`.
975
+ function toPath(path) {
976
+ return _$1.toPath(path);
977
+ }
978
+
979
+ // Internal function to obtain a nested property in `obj` along `path`.
980
+ function deepGet(obj, path) {
981
+ var length = path.length;
982
+ for (var i = 0; i < length; i++) {
983
+ if (obj == null) return void 0;
984
+ obj = obj[path[i]];
985
+ }
986
+ return length ? obj : void 0;
987
+ }
988
+
989
+ // Get the value of the (deep) property on `path` from `object`.
990
+ // If any property in `path` does not exist or if the value is
991
+ // `undefined`, return `defaultValue` instead.
992
+ // The `path` is normalized through `_.toPath`.
993
+ function get(object, path, defaultValue) {
994
+ var value = deepGet(object, toPath(path));
995
+ return isUndefined(value) ? defaultValue : value;
996
+ }
997
+
998
+ // Shortcut function for checking if an object has a given property directly on
999
+ // itself (in other words, not on a prototype). Unlike the internal `has`
1000
+ // function, this public version can also traverse nested properties.
1001
+ function has(obj, path) {
1002
+ path = toPath(path);
1003
+ var length = path.length;
1004
+ for (var i = 0; i < length; i++) {
1005
+ var key = path[i];
1006
+ if (!has$1(obj, key)) return false;
1007
+ obj = obj[key];
1008
+ }
1009
+ return !!length;
1010
+ }
1011
+
1012
+ // Keep the identity function around for default iteratees.
1013
+ function identity(value) {
1014
+ return value;
1015
+ }
1016
+
1017
+ // Returns a predicate for checking whether an object has a given set of
1018
+ // `key:value` pairs.
1019
+ function matcher(attrs) {
1020
+ attrs = extendOwn({}, attrs);
1021
+ return function(obj) {
1022
+ return isMatch(obj, attrs);
1023
+ };
1024
+ }
1025
+
1026
+ // Creates a function that, when passed an object, will traverse that object’s
1027
+ // properties down the given `path`, specified as an array of keys or indices.
1028
+ function property(path) {
1029
+ path = toPath(path);
1030
+ return function(obj) {
1031
+ return deepGet(obj, path);
1032
+ };
1033
+ }
1034
+
1035
+ // Internal function that returns an efficient (for current engines) version
1036
+ // of the passed-in callback, to be repeatedly applied in other Underscore
1037
+ // functions.
1038
+ function optimizeCb(func, context, argCount) {
1039
+ if (context === void 0) return func;
1040
+ switch (argCount == null ? 3 : argCount) {
1041
+ case 1: return function(value) {
1042
+ return func.call(context, value);
1043
+ };
1044
+ // The 2-argument case is omitted because we’re not using it.
1045
+ case 3: return function(value, index, collection) {
1046
+ return func.call(context, value, index, collection);
1047
+ };
1048
+ case 4: return function(accumulator, value, index, collection) {
1049
+ return func.call(context, accumulator, value, index, collection);
1050
+ };
1051
+ }
1052
+ return function() {
1053
+ return func.apply(context, arguments);
1054
+ };
1055
+ }
1056
+
1057
+ // An internal function to generate callbacks that can be applied to each
1058
+ // element in a collection, returning the desired result — either `_.identity`,
1059
+ // an arbitrary callback, a property matcher, or a property accessor.
1060
+ function baseIteratee(value, context, argCount) {
1061
+ if (value == null) return identity;
1062
+ if (isFunction$1(value)) return optimizeCb(value, context, argCount);
1063
+ if (isObject(value) && !isArray(value)) return matcher(value);
1064
+ return property(value);
1065
+ }
1066
+
1067
+ // External wrapper for our callback generator. Users may customize
1068
+ // `_.iteratee` if they want additional predicate/iteratee shorthand styles.
1069
+ // This abstraction hides the internal-only `argCount` argument.
1070
+ function iteratee(value, context) {
1071
+ return baseIteratee(value, context, Infinity);
1072
+ }
1073
+ _$1.iteratee = iteratee;
1074
+
1075
+ // The function we call internally to generate a callback. It invokes
1076
+ // `_.iteratee` if overridden, otherwise `baseIteratee`.
1077
+ function cb(value, context, argCount) {
1078
+ if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context);
1079
+ return baseIteratee(value, context, argCount);
1080
+ }
1081
+
1082
+ // Returns the results of applying the `iteratee` to each element of `obj`.
1083
+ // In contrast to `_.map` it returns an object.
1084
+ function mapObject$1(obj, iteratee, context) {
1085
+ iteratee = cb(iteratee, context);
1086
+ var _keys = keys(obj),
1087
+ length = _keys.length,
1088
+ results = {};
1089
+ for (var index = 0; index < length; index++) {
1090
+ var currentKey = _keys[index];
1091
+ results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
1092
+ }
1093
+ return results;
1094
+ }
1095
+
1096
+ // Predicate-generating function. Often useful outside of Underscore.
1097
+ function noop(){}
1098
+
1099
+ // Generates a function for a given object that returns a given property.
1100
+ function propertyOf(obj) {
1101
+ if (obj == null) return noop;
1102
+ return function(path) {
1103
+ return get(obj, path);
1104
+ };
1105
+ }
1106
+
1107
+ // Run a function **n** times.
1108
+ function times(n, iteratee, context) {
1109
+ var accum = Array(Math.max(0, n));
1110
+ iteratee = optimizeCb(iteratee, context, 1);
1111
+ for (var i = 0; i < n; i++) accum[i] = iteratee(i);
1112
+ return accum;
1113
+ }
1114
+
1115
+ // Return a random integer between `min` and `max` (inclusive).
1116
+ function random(min, max) {
1117
+ if (max == null) {
1118
+ max = min;
1119
+ min = 0;
1120
+ }
1121
+ return min + Math.floor(Math.random() * (max - min + 1));
1122
+ }
1123
+
1124
+ // A (possibly faster) way to get the current timestamp as an integer.
1125
+ var now = Date.now || function() {
1126
+ return new Date().getTime();
1127
+ };
1128
+
1129
+ // Internal helper to generate functions for escaping and unescaping strings
1130
+ // to/from HTML interpolation.
1131
+ function createEscaper(map) {
1132
+ var escaper = function(match) {
1133
+ return map[match];
1134
+ };
1135
+ // Regexes for identifying a key that needs to be escaped.
1136
+ var source = '(?:' + keys(map).join('|') + ')';
1137
+ var testRegexp = RegExp(source);
1138
+ var replaceRegexp = RegExp(source, 'g');
1139
+ return function(string) {
1140
+ string = string == null ? '' : '' + string;
1141
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
1142
+ };
1143
+ }
1144
+
1145
+ // Internal list of HTML entities for escaping.
1146
+ var escapeMap = {
1147
+ '&': '&amp;',
1148
+ '<': '&lt;',
1149
+ '>': '&gt;',
1150
+ '"': '&quot;',
1151
+ "'": '&#x27;',
1152
+ '`': '&#x60;'
1153
+ };
1154
+
1155
+ // Function for escaping strings to HTML interpolation.
1156
+ var escape = createEscaper(escapeMap);
1157
+
1158
+ // Internal list of HTML entities for unescaping.
1159
+ var unescapeMap = invert(escapeMap);
1160
+
1161
+ // Function for unescaping strings from HTML interpolation.
1162
+ var unescape = createEscaper(unescapeMap);
1163
+
1164
+ // By default, Underscore uses ERB-style template delimiters. Change the
1165
+ // following template settings to use alternative delimiters.
1166
+ var templateSettings = _$1.templateSettings = {
1167
+ evaluate: /<%([\s\S]+?)%>/g,
1168
+ interpolate: /<%=([\s\S]+?)%>/g,
1169
+ escape: /<%-([\s\S]+?)%>/g
1170
+ };
1171
+
1172
+ // When customizing `_.templateSettings`, if you don't want to define an
1173
+ // interpolation, evaluation or escaping regex, we need one that is
1174
+ // guaranteed not to match.
1175
+ var noMatch = /(.)^/;
1176
+
1177
+ // Certain characters need to be escaped so that they can be put into a
1178
+ // string literal.
1179
+ var escapes = {
1180
+ "'": "'",
1181
+ '\\': '\\',
1182
+ '\r': 'r',
1183
+ '\n': 'n',
1184
+ '\u2028': 'u2028',
1185
+ '\u2029': 'u2029'
1186
+ };
1187
+
1188
+ var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
1189
+
1190
+ function escapeChar(match) {
1191
+ return '\\' + escapes[match];
1192
+ }
1193
+
1194
+ // In order to prevent third-party code injection through
1195
+ // `_.templateSettings.variable`, we test it against the following regular
1196
+ // expression. It is intentionally a bit more liberal than just matching valid
1197
+ // identifiers, but still prevents possible loopholes through defaults or
1198
+ // destructuring assignment.
1199
+ var bareIdentifier = /^\s*(\w|\$)+\s*$/;
1200
+
1201
+ // JavaScript micro-templating, similar to John Resig's implementation.
1202
+ // Underscore templating handles arbitrary delimiters, preserves whitespace,
1203
+ // and correctly escapes quotes within interpolated code.
1204
+ // NB: `oldSettings` only exists for backwards compatibility.
1205
+ function template(text, settings, oldSettings) {
1206
+ if (!settings && oldSettings) settings = oldSettings;
1207
+ settings = defaults({}, settings, _$1.templateSettings);
1208
+
1209
+ // Combine delimiters into one regular expression via alternation.
1210
+ var matcher = RegExp([
1211
+ (settings.escape || noMatch).source,
1212
+ (settings.interpolate || noMatch).source,
1213
+ (settings.evaluate || noMatch).source
1214
+ ].join('|') + '|$', 'g');
1215
+
1216
+ // Compile the template source, escaping string literals appropriately.
1217
+ var index = 0;
1218
+ var source = "__p+='";
1219
+ text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
1220
+ source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
1221
+ index = offset + match.length;
1222
+
1223
+ if (escape) {
1224
+ source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
1225
+ } else if (interpolate) {
1226
+ source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
1227
+ } else if (evaluate) {
1228
+ source += "';\n" + evaluate + "\n__p+='";
1229
+ }
1230
+
1231
+ // Adobe VMs need the match returned to produce the correct offset.
1232
+ return match;
1233
+ });
1234
+ source += "';\n";
1235
+
1236
+ var argument = settings.variable;
1237
+ if (argument) {
1238
+ // Insure against third-party code injection. (CVE-2021-23358)
1239
+ if (!bareIdentifier.test(argument)) throw new Error(
1240
+ 'variable is not a bare identifier: ' + argument
1241
+ );
1242
+ } else {
1243
+ // If a variable is not specified, place data values in local scope.
1244
+ source = 'with(obj||{}){\n' + source + '}\n';
1245
+ argument = 'obj';
1246
+ }
1247
+
1248
+ source = "var __t,__p='',__j=Array.prototype.join," +
1249
+ "print=function(){__p+=__j.call(arguments,'');};\n" +
1250
+ source + 'return __p;\n';
1251
+
1252
+ var render;
1253
+ try {
1254
+ render = new Function(argument, '_', source);
1255
+ } catch (e) {
1256
+ e.source = source;
1257
+ throw e;
1258
+ }
1259
+
1260
+ var template = function(data) {
1261
+ return render.call(this, data, _$1);
1262
+ };
1263
+
1264
+ // Provide the compiled source as a convenience for precompilation.
1265
+ template.source = 'function(' + argument + '){\n' + source + '}';
1266
+
1267
+ return template;
1268
+ }
1269
+
1270
+ // Traverses the children of `obj` along `path`. If a child is a function, it
1271
+ // is invoked with its parent as context. Returns the value of the final
1272
+ // child, or `fallback` if any child is undefined.
1273
+ function result(obj, path, fallback) {
1274
+ path = toPath(path);
1275
+ var length = path.length;
1276
+ if (!length) {
1277
+ return isFunction$1(fallback) ? fallback.call(obj) : fallback;
1278
+ }
1279
+ for (var i = 0; i < length; i++) {
1280
+ var prop = obj == null ? void 0 : obj[path[i]];
1281
+ if (prop === void 0) {
1282
+ prop = fallback;
1283
+ i = length; // Ensure we don't continue iterating.
1284
+ }
1285
+ obj = isFunction$1(prop) ? prop.call(obj) : prop;
1286
+ }
1287
+ return obj;
1288
+ }
1289
+
1290
+ // Generate a unique integer id (unique within the entire client session).
1291
+ // Useful for temporary DOM ids.
1292
+ var idCounter = 0;
1293
+ function uniqueId(prefix) {
1294
+ var id = ++idCounter + '';
1295
+ return prefix ? prefix + id : id;
1296
+ }
1297
+
1298
+ // Start chaining a wrapped Underscore object.
1299
+ function chain(obj) {
1300
+ var instance = _$1(obj);
1301
+ instance._chain = true;
1302
+ return instance;
1303
+ }
1304
+
1305
+ // Internal function to execute `sourceFunc` bound to `context` with optional
1306
+ // `args`. Determines whether to execute a function as a constructor or as a
1307
+ // normal function.
1308
+ function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
1309
+ if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
1310
+ var self = baseCreate(sourceFunc.prototype);
1311
+ var result = sourceFunc.apply(self, args);
1312
+ if (isObject(result)) return result;
1313
+ return self;
1314
+ }
1315
+
1316
+ // Partially apply a function by creating a version that has had some of its
1317
+ // arguments pre-filled, without changing its dynamic `this` context. `_` acts
1318
+ // as a placeholder by default, allowing any combination of arguments to be
1319
+ // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
1320
+ var partial = restArguments(function(func, boundArgs) {
1321
+ var placeholder = partial.placeholder;
1322
+ var bound = function() {
1323
+ var position = 0, length = boundArgs.length;
1324
+ var args = Array(length);
1325
+ for (var i = 0; i < length; i++) {
1326
+ args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
1327
+ }
1328
+ while (position < arguments.length) args.push(arguments[position++]);
1329
+ return executeBound(func, bound, this, this, args);
1330
+ };
1331
+ return bound;
1332
+ });
1333
+
1334
+ partial.placeholder = _$1;
1335
+
1336
+ // Create a function bound to a given object (assigning `this`, and arguments,
1337
+ // optionally).
1338
+ var bind = restArguments(function(func, context, args) {
1339
+ if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');
1340
+ var bound = restArguments(function(callArgs) {
1341
+ return executeBound(func, bound, context, this, args.concat(callArgs));
1342
+ });
1343
+ return bound;
1344
+ });
1345
+
1346
+ // Internal helper for collection methods to determine whether a collection
1347
+ // should be iterated as an array or as an object.
1348
+ // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
1349
+ // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
1350
+ var isArrayLike = createSizePropertyCheck(getLength);
1351
+
1352
+ // Internal implementation of a recursive `flatten` function.
1353
+ function flatten$1(input, depth, strict, output) {
1354
+ output = output || [];
1355
+ if (!depth && depth !== 0) {
1356
+ depth = Infinity;
1357
+ } else if (depth <= 0) {
1358
+ return output.concat(input);
1359
+ }
1360
+ var idx = output.length;
1361
+ for (var i = 0, length = getLength(input); i < length; i++) {
1362
+ var value = input[i];
1363
+ if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
1364
+ // Flatten current level of array or arguments object.
1365
+ if (depth > 1) {
1366
+ flatten$1(value, depth - 1, strict, output);
1367
+ idx = output.length;
1368
+ } else {
1369
+ var j = 0, len = value.length;
1370
+ while (j < len) output[idx++] = value[j++];
1371
+ }
1372
+ } else if (!strict) {
1373
+ output[idx++] = value;
1374
+ }
1375
+ }
1376
+ return output;
1377
+ }
1378
+
1379
+ // Bind a number of an object's methods to that object. Remaining arguments
1380
+ // are the method names to be bound. Useful for ensuring that all callbacks
1381
+ // defined on an object belong to it.
1382
+ var bindAll = restArguments(function(obj, keys) {
1383
+ keys = flatten$1(keys, false, false);
1384
+ var index = keys.length;
1385
+ if (index < 1) throw new Error('bindAll must be passed function names');
1386
+ while (index--) {
1387
+ var key = keys[index];
1388
+ obj[key] = bind(obj[key], obj);
1389
+ }
1390
+ return obj;
1391
+ });
1392
+
1393
+ // Memoize an expensive function by storing its results.
1394
+ function memoize(func, hasher) {
1395
+ var memoize = function(key) {
1396
+ var cache = memoize.cache;
1397
+ var address = '' + (hasher ? hasher.apply(this, arguments) : key);
1398
+ if (!has$1(cache, address)) cache[address] = func.apply(this, arguments);
1399
+ return cache[address];
1400
+ };
1401
+ memoize.cache = {};
1402
+ return memoize;
1403
+ }
1404
+
1405
+ // Delays a function for the given number of milliseconds, and then calls
1406
+ // it with the arguments supplied.
1407
+ var delay = restArguments(function(func, wait, args) {
1408
+ return setTimeout(function() {
1409
+ return func.apply(null, args);
1410
+ }, wait);
1411
+ });
1412
+
1413
+ // Defers a function, scheduling it to run after the current call stack has
1414
+ // cleared.
1415
+ var defer = partial(delay, _$1, 1);
1416
+
1417
+ // Returns a function, that, when invoked, will only be triggered at most once
1418
+ // during a given window of time. Normally, the throttled function will run
1419
+ // as much as it can, without ever going more than once per `wait` duration;
1420
+ // but if you'd like to disable the execution on the leading edge, pass
1421
+ // `{leading: false}`. To disable execution on the trailing edge, ditto.
1422
+ function throttle(func, wait, options) {
1423
+ var timeout, context, args, result;
1424
+ var previous = 0;
1425
+ if (!options) options = {};
1426
+
1427
+ var later = function() {
1428
+ previous = options.leading === false ? 0 : now();
1429
+ timeout = null;
1430
+ result = func.apply(context, args);
1431
+ if (!timeout) context = args = null;
1432
+ };
1433
+
1434
+ var throttled = function() {
1435
+ var _now = now();
1436
+ if (!previous && options.leading === false) previous = _now;
1437
+ var remaining = wait - (_now - previous);
1438
+ context = this;
1439
+ args = arguments;
1440
+ if (remaining <= 0 || remaining > wait) {
1441
+ if (timeout) {
1442
+ clearTimeout(timeout);
1443
+ timeout = null;
1444
+ }
1445
+ previous = _now;
1446
+ result = func.apply(context, args);
1447
+ if (!timeout) context = args = null;
1448
+ } else if (!timeout && options.trailing !== false) {
1449
+ timeout = setTimeout(later, remaining);
1450
+ }
1451
+ return result;
1452
+ };
1453
+
1454
+ throttled.cancel = function() {
1455
+ clearTimeout(timeout);
1456
+ previous = 0;
1457
+ timeout = context = args = null;
1458
+ };
1459
+
1460
+ return throttled;
1461
+ }
1462
+
1463
+ // When a sequence of calls of the returned function ends, the argument
1464
+ // function is triggered. The end of a sequence is defined by the `wait`
1465
+ // parameter. If `immediate` is passed, the argument function will be
1466
+ // triggered at the beginning of the sequence instead of at the end.
1467
+ function debounce(func, wait, immediate) {
1468
+ var timeout, previous, args, result, context;
1469
+
1470
+ var later = function() {
1471
+ var passed = now() - previous;
1472
+ if (wait > passed) {
1473
+ timeout = setTimeout(later, wait - passed);
1474
+ } else {
1475
+ timeout = null;
1476
+ if (!immediate) result = func.apply(context, args);
1477
+ // This check is needed because `func` can recursively invoke `debounced`.
1478
+ if (!timeout) args = context = null;
1479
+ }
1480
+ };
1481
+
1482
+ var debounced = restArguments(function(_args) {
1483
+ context = this;
1484
+ args = _args;
1485
+ previous = now();
1486
+ if (!timeout) {
1487
+ timeout = setTimeout(later, wait);
1488
+ if (immediate) result = func.apply(context, args);
1489
+ }
1490
+ return result;
1491
+ });
1492
+
1493
+ debounced.cancel = function() {
1494
+ clearTimeout(timeout);
1495
+ timeout = args = context = null;
1496
+ };
1497
+
1498
+ return debounced;
1499
+ }
1500
+
1501
+ // Returns the first function passed as an argument to the second,
1502
+ // allowing you to adjust arguments, run code before and after, and
1503
+ // conditionally execute the original function.
1504
+ function wrap(func, wrapper) {
1505
+ return partial(wrapper, func);
1506
+ }
1507
+
1508
+ // Returns a negated version of the passed-in predicate.
1509
+ function negate(predicate) {
1510
+ return function() {
1511
+ return !predicate.apply(this, arguments);
1512
+ };
1513
+ }
1514
+
1515
+ // Returns a function that is the composition of a list of functions, each
1516
+ // consuming the return value of the function that follows.
1517
+ function compose() {
1518
+ var args = arguments;
1519
+ var start = args.length - 1;
1520
+ return function() {
1521
+ var i = start;
1522
+ var result = args[start].apply(this, arguments);
1523
+ while (i--) result = args[i].call(this, result);
1524
+ return result;
1525
+ };
1526
+ }
1527
+
1528
+ // Returns a function that will only be executed on and after the Nth call.
1529
+ function after(times, func) {
1530
+ return function() {
1531
+ if (--times < 1) {
1532
+ return func.apply(this, arguments);
1533
+ }
1534
+ };
1535
+ }
1536
+
1537
+ // Returns a function that will only be executed up to (but not including) the
1538
+ // Nth call.
1539
+ function before(times, func) {
1540
+ var memo;
1541
+ return function() {
1542
+ if (--times > 0) {
1543
+ memo = func.apply(this, arguments);
1544
+ }
1545
+ if (times <= 1) func = null;
1546
+ return memo;
1547
+ };
1548
+ }
1549
+
1550
+ // Returns a function that will be executed at most one time, no matter how
1551
+ // often you call it. Useful for lazy initialization.
1552
+ var once = partial(before, 2);
1553
+
1554
+ // Returns the first key on an object that passes a truth test.
1555
+ function findKey(obj, predicate, context) {
1556
+ predicate = cb(predicate, context);
1557
+ var _keys = keys(obj), key;
1558
+ for (var i = 0, length = _keys.length; i < length; i++) {
1559
+ key = _keys[i];
1560
+ if (predicate(obj[key], key, obj)) return key;
1561
+ }
1562
+ }
1563
+
1564
+ // Internal function to generate `_.findIndex` and `_.findLastIndex`.
1565
+ function createPredicateIndexFinder(dir) {
1566
+ return function(array, predicate, context) {
1567
+ predicate = cb(predicate, context);
1568
+ var length = getLength(array);
1569
+ var index = dir > 0 ? 0 : length - 1;
1570
+ for (; index >= 0 && index < length; index += dir) {
1571
+ if (predicate(array[index], index, array)) return index;
1572
+ }
1573
+ return -1;
1574
+ };
1575
+ }
1576
+
1577
+ // Returns the first index on an array-like that passes a truth test.
1578
+ var findIndex = createPredicateIndexFinder(1);
1579
+
1580
+ // Returns the last index on an array-like that passes a truth test.
1581
+ var findLastIndex = createPredicateIndexFinder(-1);
1582
+
1583
+ // Use a comparator function to figure out the smallest index at which
1584
+ // an object should be inserted so as to maintain order. Uses binary search.
1585
+ function sortedIndex(array, obj, iteratee, context) {
1586
+ iteratee = cb(iteratee, context, 1);
1587
+ var value = iteratee(obj);
1588
+ var low = 0, high = getLength(array);
1589
+ while (low < high) {
1590
+ var mid = Math.floor((low + high) / 2);
1591
+ if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
1592
+ }
1593
+ return low;
1594
+ }
1595
+
1596
+ // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
1597
+ function createIndexFinder(dir, predicateFind, sortedIndex) {
1598
+ return function(array, item, idx) {
1599
+ var i = 0, length = getLength(array);
1600
+ if (typeof idx == 'number') {
1601
+ if (dir > 0) {
1602
+ i = idx >= 0 ? idx : Math.max(idx + length, i);
1603
+ } else {
1604
+ length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
1605
+ }
1606
+ } else if (sortedIndex && idx && length) {
1607
+ idx = sortedIndex(array, item);
1608
+ return array[idx] === item ? idx : -1;
1609
+ }
1610
+ if (item !== item) {
1611
+ idx = predicateFind(slice.call(array, i, length), isNaN$1);
1612
+ return idx >= 0 ? idx + i : -1;
1613
+ }
1614
+ for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
1615
+ if (array[idx] === item) return idx;
1616
+ }
1617
+ return -1;
1618
+ };
1619
+ }
1620
+
1621
+ // Return the position of the first occurrence of an item in an array,
1622
+ // or -1 if the item is not included in the array.
1623
+ // If the array is large and already in sort order, pass `true`
1624
+ // for **isSorted** to use binary search.
1625
+ var indexOf = createIndexFinder(1, findIndex, sortedIndex);
1626
+
1627
+ // Return the position of the last occurrence of an item in an array,
1628
+ // or -1 if the item is not included in the array.
1629
+ var lastIndexOf = createIndexFinder(-1, findLastIndex);
1630
+
1631
+ // Return the first value which passes a truth test.
1632
+ function find(obj, predicate, context) {
1633
+ var keyFinder = isArrayLike(obj) ? findIndex : findKey;
1634
+ var key = keyFinder(obj, predicate, context);
1635
+ if (key !== void 0 && key !== -1) return obj[key];
1636
+ }
1637
+
1638
+ // Convenience version of a common use case of `_.find`: getting the first
1639
+ // object containing specific `key:value` pairs.
1640
+ function findWhere(obj, attrs) {
1641
+ return find(obj, matcher(attrs));
1642
+ }
1643
+
1644
+ // The cornerstone for collection functions, an `each`
1645
+ // implementation, aka `forEach`.
1646
+ // Handles raw objects in addition to array-likes. Treats all
1647
+ // sparse array-likes as if they were dense.
1648
+ function each(obj, iteratee, context) {
1649
+ iteratee = optimizeCb(iteratee, context);
1650
+ var i, length;
1651
+ if (isArrayLike(obj)) {
1652
+ for (i = 0, length = obj.length; i < length; i++) {
1653
+ iteratee(obj[i], i, obj);
1654
+ }
1655
+ } else {
1656
+ var _keys = keys(obj);
1657
+ for (i = 0, length = _keys.length; i < length; i++) {
1658
+ iteratee(obj[_keys[i]], _keys[i], obj);
1659
+ }
1660
+ }
1661
+ return obj;
1662
+ }
1663
+
1664
+ // Return the results of applying the iteratee to each element.
1665
+ function map(obj, iteratee, context) {
1666
+ iteratee = cb(iteratee, context);
1667
+ var _keys = !isArrayLike(obj) && keys(obj),
1668
+ length = (_keys || obj).length,
1669
+ results = Array(length);
1670
+ for (var index = 0; index < length; index++) {
1671
+ var currentKey = _keys ? _keys[index] : index;
1672
+ results[index] = iteratee(obj[currentKey], currentKey, obj);
1673
+ }
1674
+ return results;
1675
+ }
1676
+
1677
+ // Internal helper to create a reducing function, iterating left or right.
1678
+ function createReduce(dir) {
1679
+ // Wrap code that reassigns argument variables in a separate function than
1680
+ // the one that accesses `arguments.length` to avoid a perf hit. (#1991)
1681
+ var reducer = function(obj, iteratee, memo, initial) {
1682
+ var _keys = !isArrayLike(obj) && keys(obj),
1683
+ length = (_keys || obj).length,
1684
+ index = dir > 0 ? 0 : length - 1;
1685
+ if (!initial) {
1686
+ memo = obj[_keys ? _keys[index] : index];
1687
+ index += dir;
1688
+ }
1689
+ for (; index >= 0 && index < length; index += dir) {
1690
+ var currentKey = _keys ? _keys[index] : index;
1691
+ memo = iteratee(memo, obj[currentKey], currentKey, obj);
1692
+ }
1693
+ return memo;
1694
+ };
1695
+
1696
+ return function(obj, iteratee, memo, context) {
1697
+ var initial = arguments.length >= 3;
1698
+ return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
1699
+ };
1700
+ }
1701
+
1702
+ // **Reduce** builds up a single result from a list of values, aka `inject`,
1703
+ // or `foldl`.
1704
+ var reduce = createReduce(1);
1705
+
1706
+ // The right-associative version of reduce, also known as `foldr`.
1707
+ var reduceRight = createReduce(-1);
1708
+
1709
+ // Return all the elements that pass a truth test.
1710
+ function filter(obj, predicate, context) {
1711
+ var results = [];
1712
+ predicate = cb(predicate, context);
1713
+ each(obj, function(value, index, list) {
1714
+ if (predicate(value, index, list)) results.push(value);
1715
+ });
1716
+ return results;
1717
+ }
1718
+
1719
+ // Return all the elements for which a truth test fails.
1720
+ function reject(obj, predicate, context) {
1721
+ return filter(obj, negate(cb(predicate)), context);
1722
+ }
1723
+
1724
+ // Determine whether all of the elements pass a truth test.
1725
+ function every(obj, predicate, context) {
1726
+ predicate = cb(predicate, context);
1727
+ var _keys = !isArrayLike(obj) && keys(obj),
1728
+ length = (_keys || obj).length;
1729
+ for (var index = 0; index < length; index++) {
1730
+ var currentKey = _keys ? _keys[index] : index;
1731
+ if (!predicate(obj[currentKey], currentKey, obj)) return false;
1732
+ }
1733
+ return true;
1734
+ }
1735
+
1736
+ // Determine if at least one element in the object passes a truth test.
1737
+ function some(obj, predicate, context) {
1738
+ predicate = cb(predicate, context);
1739
+ var _keys = !isArrayLike(obj) && keys(obj),
1740
+ length = (_keys || obj).length;
1741
+ for (var index = 0; index < length; index++) {
1742
+ var currentKey = _keys ? _keys[index] : index;
1743
+ if (predicate(obj[currentKey], currentKey, obj)) return true;
1744
+ }
1745
+ return false;
1746
+ }
1747
+
1748
+ // Determine if the array or object contains a given item (using `===`).
1749
+ function contains(obj, item, fromIndex, guard) {
1750
+ if (!isArrayLike(obj)) obj = values(obj);
1751
+ if (typeof fromIndex != 'number' || guard) fromIndex = 0;
1752
+ return indexOf(obj, item, fromIndex) >= 0;
1753
+ }
1754
+
1755
+ // Invoke a method (with arguments) on every item in a collection.
1756
+ var invoke = restArguments(function(obj, path, args) {
1757
+ var contextPath, func;
1758
+ if (isFunction$1(path)) {
1759
+ func = path;
1760
+ } else {
1761
+ path = toPath(path);
1762
+ contextPath = path.slice(0, -1);
1763
+ path = path[path.length - 1];
1764
+ }
1765
+ return map(obj, function(context) {
1766
+ var method = func;
1767
+ if (!method) {
1768
+ if (contextPath && contextPath.length) {
1769
+ context = deepGet(context, contextPath);
1770
+ }
1771
+ if (context == null) return void 0;
1772
+ method = context[path];
1773
+ }
1774
+ return method == null ? method : method.apply(context, args);
1775
+ });
1776
+ });
1777
+
1778
+ // Convenience version of a common use case of `_.map`: fetching a property.
1779
+ function pluck$1(obj, key) {
1780
+ return map(obj, property(key));
1781
+ }
1782
+
1783
+ // Convenience version of a common use case of `_.filter`: selecting only
1784
+ // objects containing specific `key:value` pairs.
1785
+ function where(obj, attrs) {
1786
+ return filter(obj, matcher(attrs));
1787
+ }
1788
+
1789
+ // Return the maximum element (or element-based computation).
1790
+ function max(obj, iteratee, context) {
1791
+ var result = -Infinity, lastComputed = -Infinity,
1792
+ value, computed;
1793
+ if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
1794
+ obj = isArrayLike(obj) ? obj : values(obj);
1795
+ for (var i = 0, length = obj.length; i < length; i++) {
1796
+ value = obj[i];
1797
+ if (value != null && value > result) {
1798
+ result = value;
1799
+ }
1800
+ }
1801
+ } else {
1802
+ iteratee = cb(iteratee, context);
1803
+ each(obj, function(v, index, list) {
1804
+ computed = iteratee(v, index, list);
1805
+ if (computed > lastComputed || (computed === -Infinity && result === -Infinity)) {
1806
+ result = v;
1807
+ lastComputed = computed;
1808
+ }
1809
+ });
1810
+ }
1811
+ return result;
1812
+ }
1813
+
1814
+ // Return the minimum element (or element-based computation).
1815
+ function min(obj, iteratee, context) {
1816
+ var result = Infinity, lastComputed = Infinity,
1817
+ value, computed;
1818
+ if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
1819
+ obj = isArrayLike(obj) ? obj : values(obj);
1820
+ for (var i = 0, length = obj.length; i < length; i++) {
1821
+ value = obj[i];
1822
+ if (value != null && value < result) {
1823
+ result = value;
1824
+ }
1825
+ }
1826
+ } else {
1827
+ iteratee = cb(iteratee, context);
1828
+ each(obj, function(v, index, list) {
1829
+ computed = iteratee(v, index, list);
1830
+ if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
1831
+ result = v;
1832
+ lastComputed = computed;
1833
+ }
1834
+ });
1835
+ }
1836
+ return result;
1837
+ }
1838
+
1839
+ // Safely create a real, live array from anything iterable.
1840
+ var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
1841
+ function toArray(obj) {
1842
+ if (!obj) return [];
1843
+ if (isArray(obj)) return slice.call(obj);
1844
+ if (isString(obj)) {
1845
+ // Keep surrogate pair characters together.
1846
+ return obj.match(reStrSymbol);
1847
+ }
1848
+ if (isArrayLike(obj)) return map(obj, identity);
1849
+ return values(obj);
1850
+ }
1851
+
1852
+ // Sample **n** random values from a collection using the modern version of the
1853
+ // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
1854
+ // If **n** is not specified, returns a single random element.
1855
+ // The internal `guard` argument allows it to work with `_.map`.
1856
+ function sample(obj, n, guard) {
1857
+ if (n == null || guard) {
1858
+ if (!isArrayLike(obj)) obj = values(obj);
1859
+ return obj[random(obj.length - 1)];
1860
+ }
1861
+ var sample = toArray(obj);
1862
+ var length = getLength(sample);
1863
+ n = Math.max(Math.min(n, length), 0);
1864
+ var last = length - 1;
1865
+ for (var index = 0; index < n; index++) {
1866
+ var rand = random(index, last);
1867
+ var temp = sample[index];
1868
+ sample[index] = sample[rand];
1869
+ sample[rand] = temp;
1870
+ }
1871
+ return sample.slice(0, n);
1872
+ }
1873
+
1874
+ // Shuffle a collection.
1875
+ function shuffle(obj) {
1876
+ return sample(obj, Infinity);
1877
+ }
1878
+
1879
+ // Sort the object's values by a criterion produced by an iteratee.
1880
+ function sortBy(obj, iteratee, context) {
1881
+ var index = 0;
1882
+ iteratee = cb(iteratee, context);
1883
+ return pluck$1(map(obj, function(value, key, list) {
1884
+ return {
1885
+ value: value,
1886
+ index: index++,
1887
+ criteria: iteratee(value, key, list)
1888
+ };
1889
+ }).sort(function(left, right) {
1890
+ var a = left.criteria;
1891
+ var b = right.criteria;
1892
+ if (a !== b) {
1893
+ if (a > b || a === void 0) return 1;
1894
+ if (a < b || b === void 0) return -1;
1895
+ }
1896
+ return left.index - right.index;
1897
+ }), 'value');
1898
+ }
1899
+
1900
+ // An internal function used for aggregate "group by" operations.
1901
+ function group(behavior, partition) {
1902
+ return function(obj, iteratee, context) {
1903
+ var result = partition ? [[], []] : {};
1904
+ iteratee = cb(iteratee, context);
1905
+ each(obj, function(value, index) {
1906
+ var key = iteratee(value, index, obj);
1907
+ behavior(result, value, key);
1908
+ });
1909
+ return result;
1910
+ };
1911
+ }
1912
+
1913
+ // Groups the object's values by a criterion. Pass either a string attribute
1914
+ // to group by, or a function that returns the criterion.
1915
+ var groupBy = group(function(result, value, key) {
1916
+ if (has$1(result, key)) result[key].push(value); else result[key] = [value];
1917
+ });
1918
+
1919
+ // Indexes the object's values by a criterion, similar to `_.groupBy`, but for
1920
+ // when you know that your index values will be unique.
1921
+ var indexBy = group(function(result, value, key) {
1922
+ result[key] = value;
1923
+ });
1924
+
1925
+ // Counts instances of an object that group by a certain criterion. Pass
1926
+ // either a string attribute to count by, or a function that returns the
1927
+ // criterion.
1928
+ var countBy = group(function(result, value, key) {
1929
+ if (has$1(result, key)) result[key]++; else result[key] = 1;
1930
+ });
1931
+
1932
+ // Split a collection into two arrays: one whose elements all pass the given
1933
+ // truth test, and one whose elements all do not pass the truth test.
1934
+ var partition = group(function(result, value, pass) {
1935
+ result[pass ? 0 : 1].push(value);
1936
+ }, true);
1937
+
1938
+ // Return the number of elements in a collection.
1939
+ function size(obj) {
1940
+ if (obj == null) return 0;
1941
+ return isArrayLike(obj) ? obj.length : keys(obj).length;
1942
+ }
1943
+
1944
+ // Internal `_.pick` helper function to determine whether `key` is an enumerable
1945
+ // property name of `obj`.
1946
+ function keyInObj(value, key, obj) {
1947
+ return key in obj;
1948
+ }
1949
+
1950
+ // Return a copy of the object only containing the allowed properties.
1951
+ var pick = restArguments(function(obj, keys) {
1952
+ var result = {}, iteratee = keys[0];
1953
+ if (obj == null) return result;
1954
+ if (isFunction$1(iteratee)) {
1955
+ if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
1956
+ keys = allKeys(obj);
1957
+ } else {
1958
+ iteratee = keyInObj;
1959
+ keys = flatten$1(keys, false, false);
1960
+ obj = Object(obj);
1961
+ }
1962
+ for (var i = 0, length = keys.length; i < length; i++) {
1963
+ var key = keys[i];
1964
+ var value = obj[key];
1965
+ if (iteratee(value, key, obj)) result[key] = value;
1966
+ }
1967
+ return result;
1968
+ });
1969
+
1970
+ // Return a copy of the object without the disallowed properties.
1971
+ var omit = restArguments(function(obj, keys) {
1972
+ var iteratee = keys[0], context;
1973
+ if (isFunction$1(iteratee)) {
1974
+ iteratee = negate(iteratee);
1975
+ if (keys.length > 1) context = keys[1];
1976
+ } else {
1977
+ keys = map(flatten$1(keys, false, false), String);
1978
+ iteratee = function(value, key) {
1979
+ return !contains(keys, key);
1980
+ };
1981
+ }
1982
+ return pick(obj, iteratee, context);
1983
+ });
1984
+
1985
+ // Returns everything but the last entry of the array. Especially useful on
1986
+ // the arguments object. Passing **n** will return all the values in
1987
+ // the array, excluding the last N.
1988
+ function initial(array, n, guard) {
1989
+ return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
1990
+ }
1991
+
1992
+ // Get the first element of an array. Passing **n** will return the first N
1993
+ // values in the array. The **guard** check allows it to work with `_.map`.
1994
+ function first(array, n, guard) {
1995
+ if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
1996
+ if (n == null || guard) return array[0];
1997
+ return initial(array, array.length - n);
1998
+ }
1999
+
2000
+ // Returns everything but the first entry of the `array`. Especially useful on
2001
+ // the `arguments` object. Passing an **n** will return the rest N values in the
2002
+ // `array`.
2003
+ function rest(array, n, guard) {
2004
+ return slice.call(array, n == null || guard ? 1 : n);
2005
+ }
2006
+
2007
+ // Get the last element of an array. Passing **n** will return the last N
2008
+ // values in the array.
2009
+ function last(array, n, guard) {
2010
+ if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
2011
+ if (n == null || guard) return array[array.length - 1];
2012
+ return rest(array, Math.max(0, array.length - n));
2013
+ }
2014
+
2015
+ // Trim out all falsy values from an array.
2016
+ function compact(array) {
2017
+ return filter(array, Boolean);
2018
+ }
2019
+
2020
+ // Flatten out an array, either recursively (by default), or up to `depth`.
2021
+ // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
2022
+ function flatten(array, depth) {
2023
+ return flatten$1(array, depth, false);
2024
+ }
2025
+
2026
+ // Take the difference between one array and a number of other arrays.
2027
+ // Only the elements present in just the first array will remain.
2028
+ var difference = restArguments(function(array, rest) {
2029
+ rest = flatten$1(rest, true, true);
2030
+ return filter(array, function(value){
2031
+ return !contains(rest, value);
2032
+ });
2033
+ });
2034
+
2035
+ // Return a version of the array that does not contain the specified value(s).
2036
+ var without = restArguments(function(array, otherArrays) {
2037
+ return difference(array, otherArrays);
2038
+ });
2039
+
2040
+ // Produce a duplicate-free version of the array. If the array has already
2041
+ // been sorted, you have the option of using a faster algorithm.
2042
+ // The faster algorithm will not work with an iteratee if the iteratee
2043
+ // is not a one-to-one function, so providing an iteratee will disable
2044
+ // the faster algorithm.
2045
+ function uniq(array, isSorted, iteratee, context) {
2046
+ if (!isBoolean(isSorted)) {
2047
+ context = iteratee;
2048
+ iteratee = isSorted;
2049
+ isSorted = false;
2050
+ }
2051
+ if (iteratee != null) iteratee = cb(iteratee, context);
2052
+ var result = [];
2053
+ var seen = [];
2054
+ for (var i = 0, length = getLength(array); i < length; i++) {
2055
+ var value = array[i],
2056
+ computed = iteratee ? iteratee(value, i, array) : value;
2057
+ if (isSorted && !iteratee) {
2058
+ if (!i || seen !== computed) result.push(value);
2059
+ seen = computed;
2060
+ } else if (iteratee) {
2061
+ if (!contains(seen, computed)) {
2062
+ seen.push(computed);
2063
+ result.push(value);
2064
+ }
2065
+ } else if (!contains(result, value)) {
2066
+ result.push(value);
2067
+ }
2068
+ }
2069
+ return result;
2070
+ }
2071
+
2072
+ // Produce an array that contains the union: each distinct element from all of
2073
+ // the passed-in arrays.
2074
+ var union = restArguments(function(arrays) {
2075
+ return uniq(flatten$1(arrays, true, true));
2076
+ });
2077
+
2078
+ // Produce an array that contains every item shared between all the
2079
+ // passed-in arrays.
2080
+ function intersection(array) {
2081
+ var result = [];
2082
+ var argsLength = arguments.length;
2083
+ for (var i = 0, length = getLength(array); i < length; i++) {
2084
+ var item = array[i];
2085
+ if (contains(result, item)) continue;
2086
+ var j;
2087
+ for (j = 1; j < argsLength; j++) {
2088
+ if (!contains(arguments[j], item)) break;
2089
+ }
2090
+ if (j === argsLength) result.push(item);
2091
+ }
2092
+ return result;
2093
+ }
2094
+
2095
+ // Complement of zip. Unzip accepts an array of arrays and groups
2096
+ // each array's elements on shared indices.
2097
+ function unzip(array) {
2098
+ var length = (array && max(array, getLength).length) || 0;
2099
+ var result = Array(length);
2100
+
2101
+ for (var index = 0; index < length; index++) {
2102
+ result[index] = pluck$1(array, index);
2103
+ }
2104
+ return result;
2105
+ }
2106
+
2107
+ // Zip together multiple lists into a single array -- elements that share
2108
+ // an index go together.
2109
+ var zip = restArguments(unzip);
2110
+
2111
+ // Converts lists into objects. Pass either a single array of `[key, value]`
2112
+ // pairs, or two parallel arrays of the same length -- one of keys, and one of
2113
+ // the corresponding values. Passing by pairs is the reverse of `_.pairs`.
2114
+ function object(list, values) {
2115
+ var result = {};
2116
+ for (var i = 0, length = getLength(list); i < length; i++) {
2117
+ if (values) {
2118
+ result[list[i]] = values[i];
2119
+ } else {
2120
+ result[list[i][0]] = list[i][1];
2121
+ }
2122
+ }
2123
+ return result;
2124
+ }
2125
+
2126
+ // Generate an integer Array containing an arithmetic progression. A port of
2127
+ // the native Python `range()` function. See
2128
+ // [the Python documentation](https://docs.python.org/library/functions.html#range).
2129
+ function range(start, stop, step) {
2130
+ if (stop == null) {
2131
+ stop = start || 0;
2132
+ start = 0;
2133
+ }
2134
+ if (!step) {
2135
+ step = stop < start ? -1 : 1;
2136
+ }
2137
+
2138
+ var length = Math.max(Math.ceil((stop - start) / step), 0);
2139
+ var range = Array(length);
2140
+
2141
+ for (var idx = 0; idx < length; idx++, start += step) {
2142
+ range[idx] = start;
2143
+ }
2144
+
2145
+ return range;
2146
+ }
2147
+
2148
+ // Chunk a single array into multiple arrays, each containing `count` or fewer
2149
+ // items.
2150
+ function chunk(array, count) {
2151
+ if (count == null || count < 1) return [];
2152
+ var result = [];
2153
+ var i = 0, length = array.length;
2154
+ while (i < length) {
2155
+ result.push(slice.call(array, i, i += count));
2156
+ }
2157
+ return result;
2158
+ }
2159
+
2160
+ // Helper function to continue chaining intermediate results.
2161
+ function chainResult(instance, obj) {
2162
+ return instance._chain ? _$1(obj).chain() : obj;
2163
+ }
2164
+
2165
+ // Add your own custom functions to the Underscore object.
2166
+ function mixin(obj) {
2167
+ each(functions(obj), function(name) {
2168
+ var func = _$1[name] = obj[name];
2169
+ _$1.prototype[name] = function() {
2170
+ var args = [this._wrapped];
2171
+ push.apply(args, arguments);
2172
+ return chainResult(this, func.apply(_$1, args));
2173
+ };
2174
+ });
2175
+ return _$1;
2176
+ }
2177
+
2178
+ // Add all mutator `Array` functions to the wrapper.
2179
+ each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
2180
+ var method = ArrayProto[name];
2181
+ _$1.prototype[name] = function() {
2182
+ var obj = this._wrapped;
2183
+ if (obj != null) {
2184
+ method.apply(obj, arguments);
2185
+ if ((name === 'shift' || name === 'splice') && obj.length === 0) {
2186
+ delete obj[0];
2187
+ }
2188
+ }
2189
+ return chainResult(this, obj);
2190
+ };
2191
+ });
2192
+
2193
+ // Add all accessor `Array` functions to the wrapper.
2194
+ each(['concat', 'join', 'slice'], function(name) {
2195
+ var method = ArrayProto[name];
2196
+ _$1.prototype[name] = function() {
2197
+ var obj = this._wrapped;
2198
+ if (obj != null) obj = method.apply(obj, arguments);
2199
+ return chainResult(this, obj);
2200
+ };
2201
+ });
2202
+
2203
+ // Named Exports
2204
+
2205
+ var allExports = /*#__PURE__*/Object.freeze({
2206
+ __proto__: null,
2207
+ VERSION: VERSION,
2208
+ restArguments: restArguments,
2209
+ isObject: isObject,
2210
+ isNull: isNull,
2211
+ isUndefined: isUndefined,
2212
+ isBoolean: isBoolean,
2213
+ isElement: isElement,
2214
+ isString: isString,
2215
+ isNumber: isNumber,
2216
+ isDate: isDate,
2217
+ isRegExp: isRegExp,
2218
+ isError: isError,
2219
+ isSymbol: isSymbol,
2220
+ isArrayBuffer: isArrayBuffer,
2221
+ isDataView: isDataView$1,
2222
+ isArray: isArray,
2223
+ isFunction: isFunction$1,
2224
+ isArguments: isArguments$1,
2225
+ isFinite: isFinite$1,
2226
+ isNaN: isNaN$1,
2227
+ isTypedArray: isTypedArray$1,
2228
+ isEmpty: isEmpty,
2229
+ isMatch: isMatch,
2230
+ isEqual: isEqual,
2231
+ isMap: isMap,
2232
+ isWeakMap: isWeakMap,
2233
+ isSet: isSet,
2234
+ isWeakSet: isWeakSet,
2235
+ keys: keys,
2236
+ allKeys: allKeys,
2237
+ values: values,
2238
+ pairs: pairs,
2239
+ invert: invert,
2240
+ functions: functions,
2241
+ methods: functions,
2242
+ extend: extend,
2243
+ extendOwn: extendOwn,
2244
+ assign: extendOwn,
2245
+ defaults: defaults,
2246
+ create: create,
2247
+ clone: clone,
2248
+ tap: tap,
2249
+ get: get,
2250
+ has: has,
2251
+ mapObject: mapObject$1,
2252
+ identity: identity,
2253
+ constant: constant,
2254
+ noop: noop,
2255
+ toPath: toPath$1,
2256
+ property: property,
2257
+ propertyOf: propertyOf,
2258
+ matcher: matcher,
2259
+ matches: matcher,
2260
+ times: times,
2261
+ random: random,
2262
+ now: now,
2263
+ escape: escape,
2264
+ unescape: unescape,
2265
+ templateSettings: templateSettings,
2266
+ template: template,
2267
+ result: result,
2268
+ uniqueId: uniqueId,
2269
+ chain: chain,
2270
+ iteratee: iteratee,
2271
+ partial: partial,
2272
+ bind: bind,
2273
+ bindAll: bindAll,
2274
+ memoize: memoize,
2275
+ delay: delay,
2276
+ defer: defer,
2277
+ throttle: throttle,
2278
+ debounce: debounce,
2279
+ wrap: wrap,
2280
+ negate: negate,
2281
+ compose: compose,
2282
+ after: after,
2283
+ before: before,
2284
+ once: once,
2285
+ findKey: findKey,
2286
+ findIndex: findIndex,
2287
+ findLastIndex: findLastIndex,
2288
+ sortedIndex: sortedIndex,
2289
+ indexOf: indexOf,
2290
+ lastIndexOf: lastIndexOf,
2291
+ find: find,
2292
+ detect: find,
2293
+ findWhere: findWhere,
2294
+ each: each,
2295
+ forEach: each,
2296
+ map: map,
2297
+ collect: map,
2298
+ reduce: reduce,
2299
+ foldl: reduce,
2300
+ inject: reduce,
2301
+ reduceRight: reduceRight,
2302
+ foldr: reduceRight,
2303
+ filter: filter,
2304
+ select: filter,
2305
+ reject: reject,
2306
+ every: every,
2307
+ all: every,
2308
+ some: some,
2309
+ any: some,
2310
+ contains: contains,
2311
+ includes: contains,
2312
+ include: contains,
2313
+ invoke: invoke,
2314
+ pluck: pluck$1,
2315
+ where: where,
2316
+ max: max,
2317
+ min: min,
2318
+ shuffle: shuffle,
2319
+ sample: sample,
2320
+ sortBy: sortBy,
2321
+ groupBy: groupBy,
2322
+ indexBy: indexBy,
2323
+ countBy: countBy,
2324
+ partition: partition,
2325
+ toArray: toArray,
2326
+ size: size,
2327
+ pick: pick,
2328
+ omit: omit,
2329
+ first: first,
2330
+ head: first,
2331
+ take: first,
2332
+ initial: initial,
2333
+ last: last,
2334
+ rest: rest,
2335
+ tail: rest,
2336
+ drop: rest,
2337
+ compact: compact,
2338
+ flatten: flatten,
2339
+ without: without,
2340
+ uniq: uniq,
2341
+ unique: uniq,
2342
+ union: union,
2343
+ intersection: intersection,
2344
+ difference: difference,
2345
+ unzip: unzip,
2346
+ transpose: unzip,
2347
+ zip: zip,
2348
+ object: object,
2349
+ range: range,
2350
+ chunk: chunk,
2351
+ mixin: mixin,
2352
+ 'default': _$1
2353
+ });
2354
+
2355
+ // Default Export
2356
+
2357
+ // Add all of the Underscore functions to the wrapper object.
2358
+ var _ = mixin(allExports);
2359
+ // Legacy Node.js API.
2360
+ _._ = _;
2361
+
2362
+ /**
2363
+ * _ utilities for objects
2364
+ */
2365
+
2366
+ /**
2367
+ * Does a pluck on keys inside objects in an object
2368
+ *
2369
+ * Ex:
2370
+ * tools = {
2371
+ * translation: {
2372
+ * enabled: true
2373
+ * },
2374
+ * rotation: {
2375
+ * enabled: false
2376
+ * }
2377
+ * };
2378
+ * pluckObject(tools, "enabled") returns {
2379
+ * translation: true
2380
+ * rotation: false
2381
+ * }
2382
+ */
2383
+ const pluck = function (table, subKey) {
2384
+ return _.object(_.map(table, function (value, key) {
2385
+ return [key, value[subKey]];
2386
+ }));
2387
+ };
2388
+
2389
+ /**
2390
+ * Maps an object to an object
2391
+ *
2392
+ * > mapObject({a: '1', b: '2'}, (value, key) => {
2393
+ * return value + 1;
2394
+ * });
2395
+ * {a: 2, b: 3}
2396
+ */
2397
+ const mapObject = function (obj, lambda) {
2398
+ const result = {};
2399
+ Object.keys(obj).forEach(key => {
2400
+ // @ts-expect-error - TS2345 - Argument of type 'string' is not assignable to parameter of type 'K'.
2401
+ result[key] = lambda(obj[key], key);
2402
+ });
2403
+ return result;
2404
+ };
2405
+
103
2406
  exports.Errors = Errors;
2407
+ exports.ItemExtras = ItemExtras;
104
2408
  exports.PerseusError = PerseusError;
2409
+ exports.PerseusExpressionAnswerFormConsidered = PerseusExpressionAnswerFormConsidered;
105
2410
  exports.addLibraryVersionToPerseusDebug = addLibraryVersionToPerseusDebug;
106
2411
  exports.libVersion = libVersion;
2412
+ exports.lockedFigureColorNames = lockedFigureColorNames;
2413
+ exports.lockedFigureColors = lockedFigureColors;
2414
+ exports.lockedFigureFillStyles = lockedFigureFillStyles;
2415
+ exports.mapObject = mapObject;
2416
+ exports.plotterPlotTypes = plotterPlotTypes;
2417
+ exports.pluck = pluck;
107
2418
  //# sourceMappingURL=index.js.map