source: frontend/node_modules/underscore/underscore-node-f.cjs

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

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