UNPKG

186 kBJavaScriptView Raw
1/**
2 * SimpleBar.js - v5.2.1
3 * Scrollbars, simpler.
4 * https://grsmto.github.io/simplebar/
5 *
6 * Made by Adrien Denat from a fork by Jonathan Nicol
7 * Under MIT License
8 */
9
10(function (global, factory) {
11 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
12 typeof define === 'function' && define.amd ? define(factory) :
13 (global = global || self, global.SimpleBar = factory());
14}(this, function () { 'use strict';
15
16 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
18 function createCommonjsModule(fn, module) {
19 return module = { exports: {} }, fn(module, module.exports), module.exports;
20 }
21
22 var O = 'object';
23 var check = function (it) {
24 return it && it.Math == Math && it;
25 };
26
27 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
28 var global_1 =
29 // eslint-disable-next-line no-undef
30 check(typeof globalThis == O && globalThis) ||
31 check(typeof window == O && window) ||
32 check(typeof self == O && self) ||
33 check(typeof commonjsGlobal == O && commonjsGlobal) ||
34 // eslint-disable-next-line no-new-func
35 Function('return this')();
36
37 var fails = function (exec) {
38 try {
39 return !!exec();
40 } catch (error) {
41 return true;
42 }
43 };
44
45 // Thank's IE8 for his funny defineProperty
46 var descriptors = !fails(function () {
47 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
48 });
49
50 var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
51 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
52
53 // Nashorn ~ JDK8 bug
54 var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
55
56 // `Object.prototype.propertyIsEnumerable` method implementation
57 // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
58 var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
59 var descriptor = getOwnPropertyDescriptor(this, V);
60 return !!descriptor && descriptor.enumerable;
61 } : nativePropertyIsEnumerable;
62
63 var objectPropertyIsEnumerable = {
64 f: f
65 };
66
67 var createPropertyDescriptor = function (bitmap, value) {
68 return {
69 enumerable: !(bitmap & 1),
70 configurable: !(bitmap & 2),
71 writable: !(bitmap & 4),
72 value: value
73 };
74 };
75
76 var toString = {}.toString;
77
78 var classofRaw = function (it) {
79 return toString.call(it).slice(8, -1);
80 };
81
82 var split = ''.split;
83
84 // fallback for non-array-like ES3 and non-enumerable old V8 strings
85 var indexedObject = fails(function () {
86 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
87 // eslint-disable-next-line no-prototype-builtins
88 return !Object('z').propertyIsEnumerable(0);
89 }) ? function (it) {
90 return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
91 } : Object;
92
93 // `RequireObjectCoercible` abstract operation
94 // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
95 var requireObjectCoercible = function (it) {
96 if (it == undefined) throw TypeError("Can't call method on " + it);
97 return it;
98 };
99
100 // toObject with fallback for non-array-like ES3 strings
101
102
103
104 var toIndexedObject = function (it) {
105 return indexedObject(requireObjectCoercible(it));
106 };
107
108 var isObject = function (it) {
109 return typeof it === 'object' ? it !== null : typeof it === 'function';
110 };
111
112 // `ToPrimitive` abstract operation
113 // https://tc39.github.io/ecma262/#sec-toprimitive
114 // instead of the ES6 spec version, we didn't implement @@toPrimitive case
115 // and the second argument - flag - preferred type is a string
116 var toPrimitive = function (input, PREFERRED_STRING) {
117 if (!isObject(input)) return input;
118 var fn, val;
119 if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
120 if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
121 if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
122 throw TypeError("Can't convert object to primitive value");
123 };
124
125 var hasOwnProperty = {}.hasOwnProperty;
126
127 var has = function (it, key) {
128 return hasOwnProperty.call(it, key);
129 };
130
131 var document$1 = global_1.document;
132 // typeof document.createElement is 'object' in old IE
133 var EXISTS = isObject(document$1) && isObject(document$1.createElement);
134
135 var documentCreateElement = function (it) {
136 return EXISTS ? document$1.createElement(it) : {};
137 };
138
139 // Thank's IE8 for his funny defineProperty
140 var ie8DomDefine = !descriptors && !fails(function () {
141 return Object.defineProperty(documentCreateElement('div'), 'a', {
142 get: function () { return 7; }
143 }).a != 7;
144 });
145
146 var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
147
148 // `Object.getOwnPropertyDescriptor` method
149 // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
150 var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
151 O = toIndexedObject(O);
152 P = toPrimitive(P, true);
153 if (ie8DomDefine) try {
154 return nativeGetOwnPropertyDescriptor(O, P);
155 } catch (error) { /* empty */ }
156 if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
157 };
158
159 var objectGetOwnPropertyDescriptor = {
160 f: f$1
161 };
162
163 var anObject = function (it) {
164 if (!isObject(it)) {
165 throw TypeError(String(it) + ' is not an object');
166 } return it;
167 };
168
169 var nativeDefineProperty = Object.defineProperty;
170
171 // `Object.defineProperty` method
172 // https://tc39.github.io/ecma262/#sec-object.defineproperty
173 var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
174 anObject(O);
175 P = toPrimitive(P, true);
176 anObject(Attributes);
177 if (ie8DomDefine) try {
178 return nativeDefineProperty(O, P, Attributes);
179 } catch (error) { /* empty */ }
180 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
181 if ('value' in Attributes) O[P] = Attributes.value;
182 return O;
183 };
184
185 var objectDefineProperty = {
186 f: f$2
187 };
188
189 var hide = descriptors ? function (object, key, value) {
190 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
191 } : function (object, key, value) {
192 object[key] = value;
193 return object;
194 };
195
196 var setGlobal = function (key, value) {
197 try {
198 hide(global_1, key, value);
199 } catch (error) {
200 global_1[key] = value;
201 } return value;
202 };
203
204 var shared = createCommonjsModule(function (module) {
205 var SHARED = '__core-js_shared__';
206 var store = global_1[SHARED] || setGlobal(SHARED, {});
207
208 (module.exports = function (key, value) {
209 return store[key] || (store[key] = value !== undefined ? value : {});
210 })('versions', []).push({
211 version: '3.2.1',
212 mode: 'global',
213 copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
214 });
215 });
216
217 var functionToString = shared('native-function-to-string', Function.toString);
218
219 var WeakMap$1 = global_1.WeakMap;
220
221 var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(functionToString.call(WeakMap$1));
222
223 var id = 0;
224 var postfix = Math.random();
225
226 var uid = function (key) {
227 return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
228 };
229
230 var keys = shared('keys');
231
232 var sharedKey = function (key) {
233 return keys[key] || (keys[key] = uid(key));
234 };
235
236 var hiddenKeys = {};
237
238 var WeakMap$2 = global_1.WeakMap;
239 var set, get, has$1;
240
241 var enforce = function (it) {
242 return has$1(it) ? get(it) : set(it, {});
243 };
244
245 var getterFor = function (TYPE) {
246 return function (it) {
247 var state;
248 if (!isObject(it) || (state = get(it)).type !== TYPE) {
249 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
250 } return state;
251 };
252 };
253
254 if (nativeWeakMap) {
255 var store = new WeakMap$2();
256 var wmget = store.get;
257 var wmhas = store.has;
258 var wmset = store.set;
259 set = function (it, metadata) {
260 wmset.call(store, it, metadata);
261 return metadata;
262 };
263 get = function (it) {
264 return wmget.call(store, it) || {};
265 };
266 has$1 = function (it) {
267 return wmhas.call(store, it);
268 };
269 } else {
270 var STATE = sharedKey('state');
271 hiddenKeys[STATE] = true;
272 set = function (it, metadata) {
273 hide(it, STATE, metadata);
274 return metadata;
275 };
276 get = function (it) {
277 return has(it, STATE) ? it[STATE] : {};
278 };
279 has$1 = function (it) {
280 return has(it, STATE);
281 };
282 }
283
284 var internalState = {
285 set: set,
286 get: get,
287 has: has$1,
288 enforce: enforce,
289 getterFor: getterFor
290 };
291
292 var redefine = createCommonjsModule(function (module) {
293 var getInternalState = internalState.get;
294 var enforceInternalState = internalState.enforce;
295 var TEMPLATE = String(functionToString).split('toString');
296
297 shared('inspectSource', function (it) {
298 return functionToString.call(it);
299 });
300
301 (module.exports = function (O, key, value, options) {
302 var unsafe = options ? !!options.unsafe : false;
303 var simple = options ? !!options.enumerable : false;
304 var noTargetGet = options ? !!options.noTargetGet : false;
305 if (typeof value == 'function') {
306 if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
307 enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
308 }
309 if (O === global_1) {
310 if (simple) O[key] = value;
311 else setGlobal(key, value);
312 return;
313 } else if (!unsafe) {
314 delete O[key];
315 } else if (!noTargetGet && O[key]) {
316 simple = true;
317 }
318 if (simple) O[key] = value;
319 else hide(O, key, value);
320 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
321 })(Function.prototype, 'toString', function toString() {
322 return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
323 });
324 });
325
326 var path = global_1;
327
328 var aFunction = function (variable) {
329 return typeof variable == 'function' ? variable : undefined;
330 };
331
332 var getBuiltIn = function (namespace, method) {
333 return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
334 : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
335 };
336
337 var ceil = Math.ceil;
338 var floor = Math.floor;
339
340 // `ToInteger` abstract operation
341 // https://tc39.github.io/ecma262/#sec-tointeger
342 var toInteger = function (argument) {
343 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
344 };
345
346 var min = Math.min;
347
348 // `ToLength` abstract operation
349 // https://tc39.github.io/ecma262/#sec-tolength
350 var toLength = function (argument) {
351 return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
352 };
353
354 var max = Math.max;
355 var min$1 = Math.min;
356
357 // Helper for a popular repeating case of the spec:
358 // Let integer be ? ToInteger(index).
359 // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
360 var toAbsoluteIndex = function (index, length) {
361 var integer = toInteger(index);
362 return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
363 };
364
365 // `Array.prototype.{ indexOf, includes }` methods implementation
366 var createMethod = function (IS_INCLUDES) {
367 return function ($this, el, fromIndex) {
368 var O = toIndexedObject($this);
369 var length = toLength(O.length);
370 var index = toAbsoluteIndex(fromIndex, length);
371 var value;
372 // Array#includes uses SameValueZero equality algorithm
373 // eslint-disable-next-line no-self-compare
374 if (IS_INCLUDES && el != el) while (length > index) {
375 value = O[index++];
376 // eslint-disable-next-line no-self-compare
377 if (value != value) return true;
378 // Array#indexOf ignores holes, Array#includes - not
379 } else for (;length > index; index++) {
380 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
381 } return !IS_INCLUDES && -1;
382 };
383 };
384
385 var arrayIncludes = {
386 // `Array.prototype.includes` method
387 // https://tc39.github.io/ecma262/#sec-array.prototype.includes
388 includes: createMethod(true),
389 // `Array.prototype.indexOf` method
390 // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
391 indexOf: createMethod(false)
392 };
393
394 var indexOf = arrayIncludes.indexOf;
395
396
397 var objectKeysInternal = function (object, names) {
398 var O = toIndexedObject(object);
399 var i = 0;
400 var result = [];
401 var key;
402 for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
403 // Don't enum bug & hidden keys
404 while (names.length > i) if (has(O, key = names[i++])) {
405 ~indexOf(result, key) || result.push(key);
406 }
407 return result;
408 };
409
410 // IE8- don't enum bug keys
411 var enumBugKeys = [
412 'constructor',
413 'hasOwnProperty',
414 'isPrototypeOf',
415 'propertyIsEnumerable',
416 'toLocaleString',
417 'toString',
418 'valueOf'
419 ];
420
421 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
422
423 // `Object.getOwnPropertyNames` method
424 // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
425 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
426 return objectKeysInternal(O, hiddenKeys$1);
427 };
428
429 var objectGetOwnPropertyNames = {
430 f: f$3
431 };
432
433 var f$4 = Object.getOwnPropertySymbols;
434
435 var objectGetOwnPropertySymbols = {
436 f: f$4
437 };
438
439 // all object keys, includes non-enumerable and symbols
440 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
441 var keys = objectGetOwnPropertyNames.f(anObject(it));
442 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
443 return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
444 };
445
446 var copyConstructorProperties = function (target, source) {
447 var keys = ownKeys(source);
448 var defineProperty = objectDefineProperty.f;
449 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
450 for (var i = 0; i < keys.length; i++) {
451 var key = keys[i];
452 if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
453 }
454 };
455
456 var replacement = /#|\.prototype\./;
457
458 var isForced = function (feature, detection) {
459 var value = data[normalize(feature)];
460 return value == POLYFILL ? true
461 : value == NATIVE ? false
462 : typeof detection == 'function' ? fails(detection)
463 : !!detection;
464 };
465
466 var normalize = isForced.normalize = function (string) {
467 return String(string).replace(replacement, '.').toLowerCase();
468 };
469
470 var data = isForced.data = {};
471 var NATIVE = isForced.NATIVE = 'N';
472 var POLYFILL = isForced.POLYFILL = 'P';
473
474 var isForced_1 = isForced;
475
476 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
477
478
479
480
481
482
483 /*
484 options.target - name of the target object
485 options.global - target is the global object
486 options.stat - export as static methods of target
487 options.proto - export as prototype methods of target
488 options.real - real prototype method for the `pure` version
489 options.forced - export even if the native feature is available
490 options.bind - bind methods to the target, required for the `pure` version
491 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
492 options.unsafe - use the simple assignment of property instead of delete + defineProperty
493 options.sham - add a flag to not completely full polyfills
494 options.enumerable - export as enumerable property
495 options.noTargetGet - prevent calling a getter on target
496 */
497 var _export = function (options, source) {
498 var TARGET = options.target;
499 var GLOBAL = options.global;
500 var STATIC = options.stat;
501 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
502 if (GLOBAL) {
503 target = global_1;
504 } else if (STATIC) {
505 target = global_1[TARGET] || setGlobal(TARGET, {});
506 } else {
507 target = (global_1[TARGET] || {}).prototype;
508 }
509 if (target) for (key in source) {
510 sourceProperty = source[key];
511 if (options.noTargetGet) {
512 descriptor = getOwnPropertyDescriptor$1(target, key);
513 targetProperty = descriptor && descriptor.value;
514 } else targetProperty = target[key];
515 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
516 // contained in target
517 if (!FORCED && targetProperty !== undefined) {
518 if (typeof sourceProperty === typeof targetProperty) continue;
519 copyConstructorProperties(sourceProperty, targetProperty);
520 }
521 // add a flag to not completely full polyfills
522 if (options.sham || (targetProperty && targetProperty.sham)) {
523 hide(sourceProperty, 'sham', true);
524 }
525 // extend global
526 redefine(target, key, sourceProperty, options);
527 }
528 };
529
530 var aFunction$1 = function (it) {
531 if (typeof it != 'function') {
532 throw TypeError(String(it) + ' is not a function');
533 } return it;
534 };
535
536 // optional / simple context binding
537 var bindContext = function (fn, that, length) {
538 aFunction$1(fn);
539 if (that === undefined) return fn;
540 switch (length) {
541 case 0: return function () {
542 return fn.call(that);
543 };
544 case 1: return function (a) {
545 return fn.call(that, a);
546 };
547 case 2: return function (a, b) {
548 return fn.call(that, a, b);
549 };
550 case 3: return function (a, b, c) {
551 return fn.call(that, a, b, c);
552 };
553 }
554 return function (/* ...args */) {
555 return fn.apply(that, arguments);
556 };
557 };
558
559 // `ToObject` abstract operation
560 // https://tc39.github.io/ecma262/#sec-toobject
561 var toObject = function (argument) {
562 return Object(requireObjectCoercible(argument));
563 };
564
565 // `IsArray` abstract operation
566 // https://tc39.github.io/ecma262/#sec-isarray
567 var isArray = Array.isArray || function isArray(arg) {
568 return classofRaw(arg) == 'Array';
569 };
570
571 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
572 // Chrome 38 Symbol has incorrect toString conversion
573 // eslint-disable-next-line no-undef
574 return !String(Symbol());
575 });
576
577 var Symbol$1 = global_1.Symbol;
578 var store$1 = shared('wks');
579
580 var wellKnownSymbol = function (name) {
581 return store$1[name] || (store$1[name] = nativeSymbol && Symbol$1[name]
582 || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
583 };
584
585 var SPECIES = wellKnownSymbol('species');
586
587 // `ArraySpeciesCreate` abstract operation
588 // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
589 var arraySpeciesCreate = function (originalArray, length) {
590 var C;
591 if (isArray(originalArray)) {
592 C = originalArray.constructor;
593 // cross-realm fallback
594 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
595 else if (isObject(C)) {
596 C = C[SPECIES];
597 if (C === null) C = undefined;
598 }
599 } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
600 };
601
602 var push = [].push;
603
604 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
605 var createMethod$1 = function (TYPE) {
606 var IS_MAP = TYPE == 1;
607 var IS_FILTER = TYPE == 2;
608 var IS_SOME = TYPE == 3;
609 var IS_EVERY = TYPE == 4;
610 var IS_FIND_INDEX = TYPE == 6;
611 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
612 return function ($this, callbackfn, that, specificCreate) {
613 var O = toObject($this);
614 var self = indexedObject(O);
615 var boundFunction = bindContext(callbackfn, that, 3);
616 var length = toLength(self.length);
617 var index = 0;
618 var create = specificCreate || arraySpeciesCreate;
619 var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
620 var value, result;
621 for (;length > index; index++) if (NO_HOLES || index in self) {
622 value = self[index];
623 result = boundFunction(value, index, O);
624 if (TYPE) {
625 if (IS_MAP) target[index] = result; // map
626 else if (result) switch (TYPE) {
627 case 3: return true; // some
628 case 5: return value; // find
629 case 6: return index; // findIndex
630 case 2: push.call(target, value); // filter
631 } else if (IS_EVERY) return false; // every
632 }
633 }
634 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
635 };
636 };
637
638 var arrayIteration = {
639 // `Array.prototype.forEach` method
640 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
641 forEach: createMethod$1(0),
642 // `Array.prototype.map` method
643 // https://tc39.github.io/ecma262/#sec-array.prototype.map
644 map: createMethod$1(1),
645 // `Array.prototype.filter` method
646 // https://tc39.github.io/ecma262/#sec-array.prototype.filter
647 filter: createMethod$1(2),
648 // `Array.prototype.some` method
649 // https://tc39.github.io/ecma262/#sec-array.prototype.some
650 some: createMethod$1(3),
651 // `Array.prototype.every` method
652 // https://tc39.github.io/ecma262/#sec-array.prototype.every
653 every: createMethod$1(4),
654 // `Array.prototype.find` method
655 // https://tc39.github.io/ecma262/#sec-array.prototype.find
656 find: createMethod$1(5),
657 // `Array.prototype.findIndex` method
658 // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
659 findIndex: createMethod$1(6)
660 };
661
662 var sloppyArrayMethod = function (METHOD_NAME, argument) {
663 var method = [][METHOD_NAME];
664 return !method || !fails(function () {
665 // eslint-disable-next-line no-useless-call,no-throw-literal
666 method.call(null, argument || function () { throw 1; }, 1);
667 });
668 };
669
670 var $forEach = arrayIteration.forEach;
671
672
673 // `Array.prototype.forEach` method implementation
674 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
675 var arrayForEach = sloppyArrayMethod('forEach') ? function forEach(callbackfn /* , thisArg */) {
676 return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
677 } : [].forEach;
678
679 // `Array.prototype.forEach` method
680 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
681 _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, {
682 forEach: arrayForEach
683 });
684
685 // iterable DOM collections
686 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
687 var domIterables = {
688 CSSRuleList: 0,
689 CSSStyleDeclaration: 0,
690 CSSValueList: 0,
691 ClientRectList: 0,
692 DOMRectList: 0,
693 DOMStringList: 0,
694 DOMTokenList: 1,
695 DataTransferItemList: 0,
696 FileList: 0,
697 HTMLAllCollection: 0,
698 HTMLCollection: 0,
699 HTMLFormElement: 0,
700 HTMLSelectElement: 0,
701 MediaList: 0,
702 MimeTypeArray: 0,
703 NamedNodeMap: 0,
704 NodeList: 1,
705 PaintRequestList: 0,
706 Plugin: 0,
707 PluginArray: 0,
708 SVGLengthList: 0,
709 SVGNumberList: 0,
710 SVGPathSegList: 0,
711 SVGPointList: 0,
712 SVGStringList: 0,
713 SVGTransformList: 0,
714 SourceBufferList: 0,
715 StyleSheetList: 0,
716 TextTrackCueList: 0,
717 TextTrackList: 0,
718 TouchList: 0
719 };
720
721 for (var COLLECTION_NAME in domIterables) {
722 var Collection = global_1[COLLECTION_NAME];
723 var CollectionPrototype = Collection && Collection.prototype;
724 // some Chrome versions have non-configurable methods on DOMTokenList
725 if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
726 hide(CollectionPrototype, 'forEach', arrayForEach);
727 } catch (error) {
728 CollectionPrototype.forEach = arrayForEach;
729 }
730 }
731
732 var canUseDOM = !!(
733 typeof window !== 'undefined' &&
734 window.document &&
735 window.document.createElement
736 );
737
738 var canUseDom = canUseDOM;
739
740 var SPECIES$1 = wellKnownSymbol('species');
741
742 var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
743 return !fails(function () {
744 var array = [];
745 var constructor = array.constructor = {};
746 constructor[SPECIES$1] = function () {
747 return { foo: 1 };
748 };
749 return array[METHOD_NAME](Boolean).foo !== 1;
750 });
751 };
752
753 var $filter = arrayIteration.filter;
754
755
756 // `Array.prototype.filter` method
757 // https://tc39.github.io/ecma262/#sec-array.prototype.filter
758 // with adding support of @@species
759 _export({ target: 'Array', proto: true, forced: !arrayMethodHasSpeciesSupport('filter') }, {
760 filter: function filter(callbackfn /* , thisArg */) {
761 return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
762 }
763 });
764
765 // `Object.keys` method
766 // https://tc39.github.io/ecma262/#sec-object.keys
767 var objectKeys = Object.keys || function keys(O) {
768 return objectKeysInternal(O, enumBugKeys);
769 };
770
771 // `Object.defineProperties` method
772 // https://tc39.github.io/ecma262/#sec-object.defineproperties
773 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
774 anObject(O);
775 var keys = objectKeys(Properties);
776 var length = keys.length;
777 var index = 0;
778 var key;
779 while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
780 return O;
781 };
782
783 var html = getBuiltIn('document', 'documentElement');
784
785 var IE_PROTO = sharedKey('IE_PROTO');
786
787 var PROTOTYPE = 'prototype';
788 var Empty = function () { /* empty */ };
789
790 // Create object with fake `null` prototype: use iframe Object with cleared prototype
791 var createDict = function () {
792 // Thrash, waste and sodomy: IE GC bug
793 var iframe = documentCreateElement('iframe');
794 var length = enumBugKeys.length;
795 var lt = '<';
796 var script = 'script';
797 var gt = '>';
798 var js = 'java' + script + ':';
799 var iframeDocument;
800 iframe.style.display = 'none';
801 html.appendChild(iframe);
802 iframe.src = String(js);
803 iframeDocument = iframe.contentWindow.document;
804 iframeDocument.open();
805 iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
806 iframeDocument.close();
807 createDict = iframeDocument.F;
808 while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
809 return createDict();
810 };
811
812 // `Object.create` method
813 // https://tc39.github.io/ecma262/#sec-object.create
814 var objectCreate = Object.create || function create(O, Properties) {
815 var result;
816 if (O !== null) {
817 Empty[PROTOTYPE] = anObject(O);
818 result = new Empty();
819 Empty[PROTOTYPE] = null;
820 // add "__proto__" for Object.getPrototypeOf polyfill
821 result[IE_PROTO] = O;
822 } else result = createDict();
823 return Properties === undefined ? result : objectDefineProperties(result, Properties);
824 };
825
826 hiddenKeys[IE_PROTO] = true;
827
828 var UNSCOPABLES = wellKnownSymbol('unscopables');
829 var ArrayPrototype = Array.prototype;
830
831 // Array.prototype[@@unscopables]
832 // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
833 if (ArrayPrototype[UNSCOPABLES] == undefined) {
834 hide(ArrayPrototype, UNSCOPABLES, objectCreate(null));
835 }
836
837 // add a key to Array.prototype[@@unscopables]
838 var addToUnscopables = function (key) {
839 ArrayPrototype[UNSCOPABLES][key] = true;
840 };
841
842 var iterators = {};
843
844 var correctPrototypeGetter = !fails(function () {
845 function F() { /* empty */ }
846 F.prototype.constructor = null;
847 return Object.getPrototypeOf(new F()) !== F.prototype;
848 });
849
850 var IE_PROTO$1 = sharedKey('IE_PROTO');
851 var ObjectPrototype = Object.prototype;
852
853 // `Object.getPrototypeOf` method
854 // https://tc39.github.io/ecma262/#sec-object.getprototypeof
855 var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
856 O = toObject(O);
857 if (has(O, IE_PROTO$1)) return O[IE_PROTO$1];
858 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
859 return O.constructor.prototype;
860 } return O instanceof Object ? ObjectPrototype : null;
861 };
862
863 var ITERATOR = wellKnownSymbol('iterator');
864 var BUGGY_SAFARI_ITERATORS = false;
865
866 var returnThis = function () { return this; };
867
868 // `%IteratorPrototype%` object
869 // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
870 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
871
872 if ([].keys) {
873 arrayIterator = [].keys();
874 // Safari 8 has buggy iterators w/o `next`
875 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
876 else {
877 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
878 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
879 }
880 }
881
882 if (IteratorPrototype == undefined) IteratorPrototype = {};
883
884 // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
885 if ( !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
886
887 var iteratorsCore = {
888 IteratorPrototype: IteratorPrototype,
889 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
890 };
891
892 var defineProperty = objectDefineProperty.f;
893
894
895
896 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
897
898 var setToStringTag = function (it, TAG, STATIC) {
899 if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
900 defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });
901 }
902 };
903
904 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
905
906
907
908
909
910 var returnThis$1 = function () { return this; };
911
912 var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
913 var TO_STRING_TAG = NAME + ' Iterator';
914 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
915 setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
916 iterators[TO_STRING_TAG] = returnThis$1;
917 return IteratorConstructor;
918 };
919
920 var aPossiblePrototype = function (it) {
921 if (!isObject(it) && it !== null) {
922 throw TypeError("Can't set " + String(it) + ' as a prototype');
923 } return it;
924 };
925
926 // `Object.setPrototypeOf` method
927 // https://tc39.github.io/ecma262/#sec-object.setprototypeof
928 // Works with __proto__ only. Old v8 can't work with null proto objects.
929 /* eslint-disable no-proto */
930 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
931 var CORRECT_SETTER = false;
932 var test = {};
933 var setter;
934 try {
935 setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
936 setter.call(test, []);
937 CORRECT_SETTER = test instanceof Array;
938 } catch (error) { /* empty */ }
939 return function setPrototypeOf(O, proto) {
940 anObject(O);
941 aPossiblePrototype(proto);
942 if (CORRECT_SETTER) setter.call(O, proto);
943 else O.__proto__ = proto;
944 return O;
945 };
946 }() : undefined);
947
948 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
949 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
950 var ITERATOR$1 = wellKnownSymbol('iterator');
951 var KEYS = 'keys';
952 var VALUES = 'values';
953 var ENTRIES = 'entries';
954
955 var returnThis$2 = function () { return this; };
956
957 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
958 createIteratorConstructor(IteratorConstructor, NAME, next);
959
960 var getIterationMethod = function (KIND) {
961 if (KIND === DEFAULT && defaultIterator) return defaultIterator;
962 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
963 switch (KIND) {
964 case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
965 case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
966 case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
967 } return function () { return new IteratorConstructor(this); };
968 };
969
970 var TO_STRING_TAG = NAME + ' Iterator';
971 var INCORRECT_VALUES_NAME = false;
972 var IterablePrototype = Iterable.prototype;
973 var nativeIterator = IterablePrototype[ITERATOR$1]
974 || IterablePrototype['@@iterator']
975 || DEFAULT && IterablePrototype[DEFAULT];
976 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
977 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
978 var CurrentIteratorPrototype, methods, KEY;
979
980 // fix native
981 if (anyNativeIterator) {
982 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
983 if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
984 if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) {
985 if (objectSetPrototypeOf) {
986 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
987 } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') {
988 hide(CurrentIteratorPrototype, ITERATOR$1, returnThis$2);
989 }
990 }
991 // Set @@toStringTag to native iterators
992 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
993 }
994 }
995
996 // fix Array#{values, @@iterator}.name in V8 / FF
997 if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
998 INCORRECT_VALUES_NAME = true;
999 defaultIterator = function values() { return nativeIterator.call(this); };
1000 }
1001
1002 // define iterator
1003 if ( IterablePrototype[ITERATOR$1] !== defaultIterator) {
1004 hide(IterablePrototype, ITERATOR$1, defaultIterator);
1005 }
1006 iterators[NAME] = defaultIterator;
1007
1008 // export additional methods
1009 if (DEFAULT) {
1010 methods = {
1011 values: getIterationMethod(VALUES),
1012 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
1013 entries: getIterationMethod(ENTRIES)
1014 };
1015 if (FORCED) for (KEY in methods) {
1016 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1017 redefine(IterablePrototype, KEY, methods[KEY]);
1018 }
1019 } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
1020 }
1021
1022 return methods;
1023 };
1024
1025 var ARRAY_ITERATOR = 'Array Iterator';
1026 var setInternalState = internalState.set;
1027 var getInternalState = internalState.getterFor(ARRAY_ITERATOR);
1028
1029 // `Array.prototype.entries` method
1030 // https://tc39.github.io/ecma262/#sec-array.prototype.entries
1031 // `Array.prototype.keys` method
1032 // https://tc39.github.io/ecma262/#sec-array.prototype.keys
1033 // `Array.prototype.values` method
1034 // https://tc39.github.io/ecma262/#sec-array.prototype.values
1035 // `Array.prototype[@@iterator]` method
1036 // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
1037 // `CreateArrayIterator` internal method
1038 // https://tc39.github.io/ecma262/#sec-createarrayiterator
1039 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
1040 setInternalState(this, {
1041 type: ARRAY_ITERATOR,
1042 target: toIndexedObject(iterated), // target
1043 index: 0, // next index
1044 kind: kind // kind
1045 });
1046 // `%ArrayIteratorPrototype%.next` method
1047 // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
1048 }, function () {
1049 var state = getInternalState(this);
1050 var target = state.target;
1051 var kind = state.kind;
1052 var index = state.index++;
1053 if (!target || index >= target.length) {
1054 state.target = undefined;
1055 return { value: undefined, done: true };
1056 }
1057 if (kind == 'keys') return { value: index, done: false };
1058 if (kind == 'values') return { value: target[index], done: false };
1059 return { value: [index, target[index]], done: false };
1060 }, 'values');
1061
1062 // argumentsList[@@iterator] is %ArrayProto_values%
1063 // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
1064 // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
1065 iterators.Arguments = iterators.Array;
1066
1067 // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
1068 addToUnscopables('keys');
1069 addToUnscopables('values');
1070 addToUnscopables('entries');
1071
1072 var nativeAssign = Object.assign;
1073
1074 // `Object.assign` method
1075 // https://tc39.github.io/ecma262/#sec-object.assign
1076 // should work with symbols and should have deterministic property order (V8 bug)
1077 var objectAssign = !nativeAssign || fails(function () {
1078 var A = {};
1079 var B = {};
1080 // eslint-disable-next-line no-undef
1081 var symbol = Symbol();
1082 var alphabet = 'abcdefghijklmnopqrst';
1083 A[symbol] = 7;
1084 alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1085 return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
1086 }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
1087 var T = toObject(target);
1088 var argumentsLength = arguments.length;
1089 var index = 1;
1090 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
1091 var propertyIsEnumerable = objectPropertyIsEnumerable.f;
1092 while (argumentsLength > index) {
1093 var S = indexedObject(arguments[index++]);
1094 var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
1095 var length = keys.length;
1096 var j = 0;
1097 var key;
1098 while (length > j) {
1099 key = keys[j++];
1100 if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
1101 }
1102 } return T;
1103 } : nativeAssign;
1104
1105 // `Object.assign` method
1106 // https://tc39.github.io/ecma262/#sec-object.assign
1107 _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, {
1108 assign: objectAssign
1109 });
1110
1111 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
1112 // ES3 wrong here
1113 var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1114
1115 // fallback for IE11 Script Access Denied error
1116 var tryGet = function (it, key) {
1117 try {
1118 return it[key];
1119 } catch (error) { /* empty */ }
1120 };
1121
1122 // getting tag from ES6+ `Object.prototype.toString`
1123 var classof = function (it) {
1124 var O, tag, result;
1125 return it === undefined ? 'Undefined' : it === null ? 'Null'
1126 // @@toStringTag case
1127 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$1)) == 'string' ? tag
1128 // builtinTag case
1129 : CORRECT_ARGUMENTS ? classofRaw(O)
1130 // ES3 arguments fallback
1131 : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
1132 };
1133
1134 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
1135 var test = {};
1136
1137 test[TO_STRING_TAG$2] = 'z';
1138
1139 // `Object.prototype.toString` method implementation
1140 // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
1141 var objectToString = String(test) !== '[object z]' ? function toString() {
1142 return '[object ' + classof(this) + ']';
1143 } : test.toString;
1144
1145 var ObjectPrototype$1 = Object.prototype;
1146
1147 // `Object.prototype.toString` method
1148 // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
1149 if (objectToString !== ObjectPrototype$1.toString) {
1150 redefine(ObjectPrototype$1, 'toString', objectToString, { unsafe: true });
1151 }
1152
1153 // a string of all valid unicode whitespaces
1154 // eslint-disable-next-line max-len
1155 var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
1156
1157 var whitespace = '[' + whitespaces + ']';
1158 var ltrim = RegExp('^' + whitespace + whitespace + '*');
1159 var rtrim = RegExp(whitespace + whitespace + '*$');
1160
1161 // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
1162 var createMethod$2 = function (TYPE) {
1163 return function ($this) {
1164 var string = String(requireObjectCoercible($this));
1165 if (TYPE & 1) string = string.replace(ltrim, '');
1166 if (TYPE & 2) string = string.replace(rtrim, '');
1167 return string;
1168 };
1169 };
1170
1171 var stringTrim = {
1172 // `String.prototype.{ trimLeft, trimStart }` methods
1173 // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
1174 start: createMethod$2(1),
1175 // `String.prototype.{ trimRight, trimEnd }` methods
1176 // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
1177 end: createMethod$2(2),
1178 // `String.prototype.trim` method
1179 // https://tc39.github.io/ecma262/#sec-string.prototype.trim
1180 trim: createMethod$2(3)
1181 };
1182
1183 var trim = stringTrim.trim;
1184
1185
1186 var nativeParseInt = global_1.parseInt;
1187 var hex = /^[+-]?0[Xx]/;
1188 var FORCED = nativeParseInt(whitespaces + '08') !== 8 || nativeParseInt(whitespaces + '0x16') !== 22;
1189
1190 // `parseInt` method
1191 // https://tc39.github.io/ecma262/#sec-parseint-string-radix
1192 var _parseInt = FORCED ? function parseInt(string, radix) {
1193 var S = trim(String(string));
1194 return nativeParseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));
1195 } : nativeParseInt;
1196
1197 // `parseInt` method
1198 // https://tc39.github.io/ecma262/#sec-parseint-string-radix
1199 _export({ global: true, forced: parseInt != _parseInt }, {
1200 parseInt: _parseInt
1201 });
1202
1203 // `String.prototype.{ codePointAt, at }` methods implementation
1204 var createMethod$3 = function (CONVERT_TO_STRING) {
1205 return function ($this, pos) {
1206 var S = String(requireObjectCoercible($this));
1207 var position = toInteger(pos);
1208 var size = S.length;
1209 var first, second;
1210 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
1211 first = S.charCodeAt(position);
1212 return first < 0xD800 || first > 0xDBFF || position + 1 === size
1213 || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
1214 ? CONVERT_TO_STRING ? S.charAt(position) : first
1215 : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
1216 };
1217 };
1218
1219 var stringMultibyte = {
1220 // `String.prototype.codePointAt` method
1221 // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
1222 codeAt: createMethod$3(false),
1223 // `String.prototype.at` method
1224 // https://github.com/mathiasbynens/String.prototype.at
1225 charAt: createMethod$3(true)
1226 };
1227
1228 var charAt = stringMultibyte.charAt;
1229
1230
1231
1232 var STRING_ITERATOR = 'String Iterator';
1233 var setInternalState$1 = internalState.set;
1234 var getInternalState$1 = internalState.getterFor(STRING_ITERATOR);
1235
1236 // `String.prototype[@@iterator]` method
1237 // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
1238 defineIterator(String, 'String', function (iterated) {
1239 setInternalState$1(this, {
1240 type: STRING_ITERATOR,
1241 string: String(iterated),
1242 index: 0
1243 });
1244 // `%StringIteratorPrototype%.next` method
1245 // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
1246 }, function next() {
1247 var state = getInternalState$1(this);
1248 var string = state.string;
1249 var index = state.index;
1250 var point;
1251 if (index >= string.length) return { value: undefined, done: true };
1252 point = charAt(string, index);
1253 state.index += point.length;
1254 return { value: point, done: false };
1255 });
1256
1257 var redefineAll = function (target, src, options) {
1258 for (var key in src) redefine(target, key, src[key], options);
1259 return target;
1260 };
1261
1262 var freezing = !fails(function () {
1263 return Object.isExtensible(Object.preventExtensions({}));
1264 });
1265
1266 var internalMetadata = createCommonjsModule(function (module) {
1267 var defineProperty = objectDefineProperty.f;
1268
1269
1270
1271 var METADATA = uid('meta');
1272 var id = 0;
1273
1274 var isExtensible = Object.isExtensible || function () {
1275 return true;
1276 };
1277
1278 var setMetadata = function (it) {
1279 defineProperty(it, METADATA, { value: {
1280 objectID: 'O' + ++id, // object ID
1281 weakData: {} // weak collections IDs
1282 } });
1283 };
1284
1285 var fastKey = function (it, create) {
1286 // return a primitive with prefix
1287 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
1288 if (!has(it, METADATA)) {
1289 // can't set metadata to uncaught frozen object
1290 if (!isExtensible(it)) return 'F';
1291 // not necessary to add metadata
1292 if (!create) return 'E';
1293 // add missing metadata
1294 setMetadata(it);
1295 // return object ID
1296 } return it[METADATA].objectID;
1297 };
1298
1299 var getWeakData = function (it, create) {
1300 if (!has(it, METADATA)) {
1301 // can't set metadata to uncaught frozen object
1302 if (!isExtensible(it)) return true;
1303 // not necessary to add metadata
1304 if (!create) return false;
1305 // add missing metadata
1306 setMetadata(it);
1307 // return the store of weak collections IDs
1308 } return it[METADATA].weakData;
1309 };
1310
1311 // add metadata on freeze-family methods calling
1312 var onFreeze = function (it) {
1313 if (freezing && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);
1314 return it;
1315 };
1316
1317 var meta = module.exports = {
1318 REQUIRED: false,
1319 fastKey: fastKey,
1320 getWeakData: getWeakData,
1321 onFreeze: onFreeze
1322 };
1323
1324 hiddenKeys[METADATA] = true;
1325 });
1326 var internalMetadata_1 = internalMetadata.REQUIRED;
1327 var internalMetadata_2 = internalMetadata.fastKey;
1328 var internalMetadata_3 = internalMetadata.getWeakData;
1329 var internalMetadata_4 = internalMetadata.onFreeze;
1330
1331 var ITERATOR$2 = wellKnownSymbol('iterator');
1332 var ArrayPrototype$1 = Array.prototype;
1333
1334 // check on default Array iterator
1335 var isArrayIteratorMethod = function (it) {
1336 return it !== undefined && (iterators.Array === it || ArrayPrototype$1[ITERATOR$2] === it);
1337 };
1338
1339 var ITERATOR$3 = wellKnownSymbol('iterator');
1340
1341 var getIteratorMethod = function (it) {
1342 if (it != undefined) return it[ITERATOR$3]
1343 || it['@@iterator']
1344 || iterators[classof(it)];
1345 };
1346
1347 // call something on iterator step with safe closing on error
1348 var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
1349 try {
1350 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
1351 // 7.4.6 IteratorClose(iterator, completion)
1352 } catch (error) {
1353 var returnMethod = iterator['return'];
1354 if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
1355 throw error;
1356 }
1357 };
1358
1359 var iterate_1 = createCommonjsModule(function (module) {
1360 var Result = function (stopped, result) {
1361 this.stopped = stopped;
1362 this.result = result;
1363 };
1364
1365 var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
1366 var boundFunction = bindContext(fn, that, AS_ENTRIES ? 2 : 1);
1367 var iterator, iterFn, index, length, result, step;
1368
1369 if (IS_ITERATOR) {
1370 iterator = iterable;
1371 } else {
1372 iterFn = getIteratorMethod(iterable);
1373 if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
1374 // optimisation for array iterators
1375 if (isArrayIteratorMethod(iterFn)) {
1376 for (index = 0, length = toLength(iterable.length); length > index; index++) {
1377 result = AS_ENTRIES
1378 ? boundFunction(anObject(step = iterable[index])[0], step[1])
1379 : boundFunction(iterable[index]);
1380 if (result && result instanceof Result) return result;
1381 } return new Result(false);
1382 }
1383 iterator = iterFn.call(iterable);
1384 }
1385
1386 while (!(step = iterator.next()).done) {
1387 result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
1388 if (result && result instanceof Result) return result;
1389 } return new Result(false);
1390 };
1391
1392 iterate.stop = function (result) {
1393 return new Result(true, result);
1394 };
1395 });
1396
1397 var anInstance = function (it, Constructor, name) {
1398 if (!(it instanceof Constructor)) {
1399 throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
1400 } return it;
1401 };
1402
1403 var ITERATOR$4 = wellKnownSymbol('iterator');
1404 var SAFE_CLOSING = false;
1405
1406 try {
1407 var called = 0;
1408 var iteratorWithReturn = {
1409 next: function () {
1410 return { done: !!called++ };
1411 },
1412 'return': function () {
1413 SAFE_CLOSING = true;
1414 }
1415 };
1416 iteratorWithReturn[ITERATOR$4] = function () {
1417 return this;
1418 };
1419 // eslint-disable-next-line no-throw-literal
1420 Array.from(iteratorWithReturn, function () { throw 2; });
1421 } catch (error) { /* empty */ }
1422
1423 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
1424 if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
1425 var ITERATION_SUPPORT = false;
1426 try {
1427 var object = {};
1428 object[ITERATOR$4] = function () {
1429 return {
1430 next: function () {
1431 return { done: ITERATION_SUPPORT = true };
1432 }
1433 };
1434 };
1435 exec(object);
1436 } catch (error) { /* empty */ }
1437 return ITERATION_SUPPORT;
1438 };
1439
1440 // makes subclassing work correct for wrapped built-ins
1441 var inheritIfRequired = function ($this, dummy, Wrapper) {
1442 var NewTarget, NewTargetPrototype;
1443 if (
1444 // it can work only with native `setPrototypeOf`
1445 objectSetPrototypeOf &&
1446 // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
1447 typeof (NewTarget = dummy.constructor) == 'function' &&
1448 NewTarget !== Wrapper &&
1449 isObject(NewTargetPrototype = NewTarget.prototype) &&
1450 NewTargetPrototype !== Wrapper.prototype
1451 ) objectSetPrototypeOf($this, NewTargetPrototype);
1452 return $this;
1453 };
1454
1455 var collection = function (CONSTRUCTOR_NAME, wrapper, common, IS_MAP, IS_WEAK) {
1456 var NativeConstructor = global_1[CONSTRUCTOR_NAME];
1457 var NativePrototype = NativeConstructor && NativeConstructor.prototype;
1458 var Constructor = NativeConstructor;
1459 var ADDER = IS_MAP ? 'set' : 'add';
1460 var exported = {};
1461
1462 var fixMethod = function (KEY) {
1463 var nativeMethod = NativePrototype[KEY];
1464 redefine(NativePrototype, KEY,
1465 KEY == 'add' ? function add(value) {
1466 nativeMethod.call(this, value === 0 ? 0 : value);
1467 return this;
1468 } : KEY == 'delete' ? function (key) {
1469 return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
1470 } : KEY == 'get' ? function get(key) {
1471 return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);
1472 } : KEY == 'has' ? function has(key) {
1473 return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
1474 } : function set(key, value) {
1475 nativeMethod.call(this, key === 0 ? 0 : key, value);
1476 return this;
1477 }
1478 );
1479 };
1480
1481 // eslint-disable-next-line max-len
1482 if (isForced_1(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
1483 new NativeConstructor().entries().next();
1484 })))) {
1485 // create collection constructor
1486 Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
1487 internalMetadata.REQUIRED = true;
1488 } else if (isForced_1(CONSTRUCTOR_NAME, true)) {
1489 var instance = new Constructor();
1490 // early implementations not supports chaining
1491 var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
1492 // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
1493 var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
1494 // most early implementations doesn't supports iterables, most modern - not close it correctly
1495 // eslint-disable-next-line no-new
1496 var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); });
1497 // for early implementations -0 and +0 not the same
1498 var BUGGY_ZERO = !IS_WEAK && fails(function () {
1499 // V8 ~ Chromium 42- fails only with 5+ elements
1500 var $instance = new NativeConstructor();
1501 var index = 5;
1502 while (index--) $instance[ADDER](index, index);
1503 return !$instance.has(-0);
1504 });
1505
1506 if (!ACCEPT_ITERABLES) {
1507 Constructor = wrapper(function (dummy, iterable) {
1508 anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
1509 var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
1510 if (iterable != undefined) iterate_1(iterable, that[ADDER], that, IS_MAP);
1511 return that;
1512 });
1513 Constructor.prototype = NativePrototype;
1514 NativePrototype.constructor = Constructor;
1515 }
1516
1517 if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
1518 fixMethod('delete');
1519 fixMethod('has');
1520 IS_MAP && fixMethod('get');
1521 }
1522
1523 if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
1524
1525 // weak collections should not contains .clear method
1526 if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;
1527 }
1528
1529 exported[CONSTRUCTOR_NAME] = Constructor;
1530 _export({ global: true, forced: Constructor != NativeConstructor }, exported);
1531
1532 setToStringTag(Constructor, CONSTRUCTOR_NAME);
1533
1534 if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
1535
1536 return Constructor;
1537 };
1538
1539 var getWeakData = internalMetadata.getWeakData;
1540
1541
1542
1543
1544
1545
1546
1547
1548 var setInternalState$2 = internalState.set;
1549 var internalStateGetterFor = internalState.getterFor;
1550 var find = arrayIteration.find;
1551 var findIndex = arrayIteration.findIndex;
1552 var id$1 = 0;
1553
1554 // fallback for uncaught frozen keys
1555 var uncaughtFrozenStore = function (store) {
1556 return store.frozen || (store.frozen = new UncaughtFrozenStore());
1557 };
1558
1559 var UncaughtFrozenStore = function () {
1560 this.entries = [];
1561 };
1562
1563 var findUncaughtFrozen = function (store, key) {
1564 return find(store.entries, function (it) {
1565 return it[0] === key;
1566 });
1567 };
1568
1569 UncaughtFrozenStore.prototype = {
1570 get: function (key) {
1571 var entry = findUncaughtFrozen(this, key);
1572 if (entry) return entry[1];
1573 },
1574 has: function (key) {
1575 return !!findUncaughtFrozen(this, key);
1576 },
1577 set: function (key, value) {
1578 var entry = findUncaughtFrozen(this, key);
1579 if (entry) entry[1] = value;
1580 else this.entries.push([key, value]);
1581 },
1582 'delete': function (key) {
1583 var index = findIndex(this.entries, function (it) {
1584 return it[0] === key;
1585 });
1586 if (~index) this.entries.splice(index, 1);
1587 return !!~index;
1588 }
1589 };
1590
1591 var collectionWeak = {
1592 getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
1593 var C = wrapper(function (that, iterable) {
1594 anInstance(that, C, CONSTRUCTOR_NAME);
1595 setInternalState$2(that, {
1596 type: CONSTRUCTOR_NAME,
1597 id: id$1++,
1598 frozen: undefined
1599 });
1600 if (iterable != undefined) iterate_1(iterable, that[ADDER], that, IS_MAP);
1601 });
1602
1603 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
1604
1605 var define = function (that, key, value) {
1606 var state = getInternalState(that);
1607 var data = getWeakData(anObject(key), true);
1608 if (data === true) uncaughtFrozenStore(state).set(key, value);
1609 else data[state.id] = value;
1610 return that;
1611 };
1612
1613 redefineAll(C.prototype, {
1614 // 23.3.3.2 WeakMap.prototype.delete(key)
1615 // 23.4.3.3 WeakSet.prototype.delete(value)
1616 'delete': function (key) {
1617 var state = getInternalState(this);
1618 if (!isObject(key)) return false;
1619 var data = getWeakData(key);
1620 if (data === true) return uncaughtFrozenStore(state)['delete'](key);
1621 return data && has(data, state.id) && delete data[state.id];
1622 },
1623 // 23.3.3.4 WeakMap.prototype.has(key)
1624 // 23.4.3.4 WeakSet.prototype.has(value)
1625 has: function has$1(key) {
1626 var state = getInternalState(this);
1627 if (!isObject(key)) return false;
1628 var data = getWeakData(key);
1629 if (data === true) return uncaughtFrozenStore(state).has(key);
1630 return data && has(data, state.id);
1631 }
1632 });
1633
1634 redefineAll(C.prototype, IS_MAP ? {
1635 // 23.3.3.3 WeakMap.prototype.get(key)
1636 get: function get(key) {
1637 var state = getInternalState(this);
1638 if (isObject(key)) {
1639 var data = getWeakData(key);
1640 if (data === true) return uncaughtFrozenStore(state).get(key);
1641 return data ? data[state.id] : undefined;
1642 }
1643 },
1644 // 23.3.3.5 WeakMap.prototype.set(key, value)
1645 set: function set(key, value) {
1646 return define(this, key, value);
1647 }
1648 } : {
1649 // 23.4.3.1 WeakSet.prototype.add(value)
1650 add: function add(value) {
1651 return define(this, value, true);
1652 }
1653 });
1654
1655 return C;
1656 }
1657 };
1658
1659 var es_weakMap = createCommonjsModule(function (module) {
1660
1661
1662
1663
1664
1665
1666 var enforceIternalState = internalState.enforce;
1667
1668
1669 var IS_IE11 = !global_1.ActiveXObject && 'ActiveXObject' in global_1;
1670 var isExtensible = Object.isExtensible;
1671 var InternalWeakMap;
1672
1673 var wrapper = function (get) {
1674 return function WeakMap() {
1675 return get(this, arguments.length ? arguments[0] : undefined);
1676 };
1677 };
1678
1679 // `WeakMap` constructor
1680 // https://tc39.github.io/ecma262/#sec-weakmap-constructor
1681 var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak, true, true);
1682
1683 // IE11 WeakMap frozen keys fix
1684 // We can't use feature detection because it crash some old IE builds
1685 // https://github.com/zloirock/core-js/issues/485
1686 if (nativeWeakMap && IS_IE11) {
1687 InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
1688 internalMetadata.REQUIRED = true;
1689 var WeakMapPrototype = $WeakMap.prototype;
1690 var nativeDelete = WeakMapPrototype['delete'];
1691 var nativeHas = WeakMapPrototype.has;
1692 var nativeGet = WeakMapPrototype.get;
1693 var nativeSet = WeakMapPrototype.set;
1694 redefineAll(WeakMapPrototype, {
1695 'delete': function (key) {
1696 if (isObject(key) && !isExtensible(key)) {
1697 var state = enforceIternalState(this);
1698 if (!state.frozen) state.frozen = new InternalWeakMap();
1699 return nativeDelete.call(this, key) || state.frozen['delete'](key);
1700 } return nativeDelete.call(this, key);
1701 },
1702 has: function has(key) {
1703 if (isObject(key) && !isExtensible(key)) {
1704 var state = enforceIternalState(this);
1705 if (!state.frozen) state.frozen = new InternalWeakMap();
1706 return nativeHas.call(this, key) || state.frozen.has(key);
1707 } return nativeHas.call(this, key);
1708 },
1709 get: function get(key) {
1710 if (isObject(key) && !isExtensible(key)) {
1711 var state = enforceIternalState(this);
1712 if (!state.frozen) state.frozen = new InternalWeakMap();
1713 return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
1714 } return nativeGet.call(this, key);
1715 },
1716 set: function set(key, value) {
1717 if (isObject(key) && !isExtensible(key)) {
1718 var state = enforceIternalState(this);
1719 if (!state.frozen) state.frozen = new InternalWeakMap();
1720 nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
1721 } else nativeSet.call(this, key, value);
1722 return this;
1723 }
1724 });
1725 }
1726 });
1727
1728 var ITERATOR$5 = wellKnownSymbol('iterator');
1729 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
1730 var ArrayValues = es_array_iterator.values;
1731
1732 for (var COLLECTION_NAME$1 in domIterables) {
1733 var Collection$1 = global_1[COLLECTION_NAME$1];
1734 var CollectionPrototype$1 = Collection$1 && Collection$1.prototype;
1735 if (CollectionPrototype$1) {
1736 // some Chrome versions have non-configurable methods on DOMTokenList
1737 if (CollectionPrototype$1[ITERATOR$5] !== ArrayValues) try {
1738 hide(CollectionPrototype$1, ITERATOR$5, ArrayValues);
1739 } catch (error) {
1740 CollectionPrototype$1[ITERATOR$5] = ArrayValues;
1741 }
1742 if (!CollectionPrototype$1[TO_STRING_TAG$3]) hide(CollectionPrototype$1, TO_STRING_TAG$3, COLLECTION_NAME$1);
1743 if (domIterables[COLLECTION_NAME$1]) for (var METHOD_NAME in es_array_iterator) {
1744 // some Chrome versions have non-configurable methods on DOMTokenList
1745 if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try {
1746 hide(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]);
1747 } catch (error) {
1748 CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME];
1749 }
1750 }
1751 }
1752 }
1753
1754 /**
1755 * lodash (Custom Build) <https://lodash.com/>
1756 * Build: `lodash modularize exports="npm" -o ./`
1757 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
1758 * Released under MIT license <https://lodash.com/license>
1759 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1760 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1761 */
1762
1763 /** Used as the `TypeError` message for "Functions" methods. */
1764 var FUNC_ERROR_TEXT = 'Expected a function';
1765
1766 /** Used as references for various `Number` constants. */
1767 var NAN = 0 / 0;
1768
1769 /** `Object#toString` result references. */
1770 var symbolTag = '[object Symbol]';
1771
1772 /** Used to match leading and trailing whitespace. */
1773 var reTrim = /^\s+|\s+$/g;
1774
1775 /** Used to detect bad signed hexadecimal string values. */
1776 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1777
1778 /** Used to detect binary string values. */
1779 var reIsBinary = /^0b[01]+$/i;
1780
1781 /** Used to detect octal string values. */
1782 var reIsOctal = /^0o[0-7]+$/i;
1783
1784 /** Built-in method references without a dependency on `root`. */
1785 var freeParseInt = parseInt;
1786
1787 /** Detect free variable `global` from Node.js. */
1788 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1789
1790 /** Detect free variable `self`. */
1791 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1792
1793 /** Used as a reference to the global object. */
1794 var root = freeGlobal || freeSelf || Function('return this')();
1795
1796 /** Used for built-in method references. */
1797 var objectProto = Object.prototype;
1798
1799 /**
1800 * Used to resolve the
1801 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1802 * of values.
1803 */
1804 var objectToString$1 = objectProto.toString;
1805
1806 /* Built-in method references for those with the same name as other `lodash` methods. */
1807 var nativeMax = Math.max,
1808 nativeMin = Math.min;
1809
1810 /**
1811 * Gets the timestamp of the number of milliseconds that have elapsed since
1812 * the Unix epoch (1 January 1970 00:00:00 UTC).
1813 *
1814 * @static
1815 * @memberOf _
1816 * @since 2.4.0
1817 * @category Date
1818 * @returns {number} Returns the timestamp.
1819 * @example
1820 *
1821 * _.defer(function(stamp) {
1822 * console.log(_.now() - stamp);
1823 * }, _.now());
1824 * // => Logs the number of milliseconds it took for the deferred invocation.
1825 */
1826 var now = function() {
1827 return root.Date.now();
1828 };
1829
1830 /**
1831 * Creates a debounced function that delays invoking `func` until after `wait`
1832 * milliseconds have elapsed since the last time the debounced function was
1833 * invoked. The debounced function comes with a `cancel` method to cancel
1834 * delayed `func` invocations and a `flush` method to immediately invoke them.
1835 * Provide `options` to indicate whether `func` should be invoked on the
1836 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
1837 * with the last arguments provided to the debounced function. Subsequent
1838 * calls to the debounced function return the result of the last `func`
1839 * invocation.
1840 *
1841 * **Note:** If `leading` and `trailing` options are `true`, `func` is
1842 * invoked on the trailing edge of the timeout only if the debounced function
1843 * is invoked more than once during the `wait` timeout.
1844 *
1845 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
1846 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
1847 *
1848 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
1849 * for details over the differences between `_.debounce` and `_.throttle`.
1850 *
1851 * @static
1852 * @memberOf _
1853 * @since 0.1.0
1854 * @category Function
1855 * @param {Function} func The function to debounce.
1856 * @param {number} [wait=0] The number of milliseconds to delay.
1857 * @param {Object} [options={}] The options object.
1858 * @param {boolean} [options.leading=false]
1859 * Specify invoking on the leading edge of the timeout.
1860 * @param {number} [options.maxWait]
1861 * The maximum time `func` is allowed to be delayed before it's invoked.
1862 * @param {boolean} [options.trailing=true]
1863 * Specify invoking on the trailing edge of the timeout.
1864 * @returns {Function} Returns the new debounced function.
1865 * @example
1866 *
1867 * // Avoid costly calculations while the window size is in flux.
1868 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
1869 *
1870 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
1871 * jQuery(element).on('click', _.debounce(sendMail, 300, {
1872 * 'leading': true,
1873 * 'trailing': false
1874 * }));
1875 *
1876 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
1877 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
1878 * var source = new EventSource('/stream');
1879 * jQuery(source).on('message', debounced);
1880 *
1881 * // Cancel the trailing debounced invocation.
1882 * jQuery(window).on('popstate', debounced.cancel);
1883 */
1884 function debounce(func, wait, options) {
1885 var lastArgs,
1886 lastThis,
1887 maxWait,
1888 result,
1889 timerId,
1890 lastCallTime,
1891 lastInvokeTime = 0,
1892 leading = false,
1893 maxing = false,
1894 trailing = true;
1895
1896 if (typeof func != 'function') {
1897 throw new TypeError(FUNC_ERROR_TEXT);
1898 }
1899 wait = toNumber(wait) || 0;
1900 if (isObject$1(options)) {
1901 leading = !!options.leading;
1902 maxing = 'maxWait' in options;
1903 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
1904 trailing = 'trailing' in options ? !!options.trailing : trailing;
1905 }
1906
1907 function invokeFunc(time) {
1908 var args = lastArgs,
1909 thisArg = lastThis;
1910
1911 lastArgs = lastThis = undefined;
1912 lastInvokeTime = time;
1913 result = func.apply(thisArg, args);
1914 return result;
1915 }
1916
1917 function leadingEdge(time) {
1918 // Reset any `maxWait` timer.
1919 lastInvokeTime = time;
1920 // Start the timer for the trailing edge.
1921 timerId = setTimeout(timerExpired, wait);
1922 // Invoke the leading edge.
1923 return leading ? invokeFunc(time) : result;
1924 }
1925
1926 function remainingWait(time) {
1927 var timeSinceLastCall = time - lastCallTime,
1928 timeSinceLastInvoke = time - lastInvokeTime,
1929 result = wait - timeSinceLastCall;
1930
1931 return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
1932 }
1933
1934 function shouldInvoke(time) {
1935 var timeSinceLastCall = time - lastCallTime,
1936 timeSinceLastInvoke = time - lastInvokeTime;
1937
1938 // Either this is the first call, activity has stopped and we're at the
1939 // trailing edge, the system time has gone backwards and we're treating
1940 // it as the trailing edge, or we've hit the `maxWait` limit.
1941 return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
1942 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
1943 }
1944
1945 function timerExpired() {
1946 var time = now();
1947 if (shouldInvoke(time)) {
1948 return trailingEdge(time);
1949 }
1950 // Restart the timer.
1951 timerId = setTimeout(timerExpired, remainingWait(time));
1952 }
1953
1954 function trailingEdge(time) {
1955 timerId = undefined;
1956
1957 // Only invoke if we have `lastArgs` which means `func` has been
1958 // debounced at least once.
1959 if (trailing && lastArgs) {
1960 return invokeFunc(time);
1961 }
1962 lastArgs = lastThis = undefined;
1963 return result;
1964 }
1965
1966 function cancel() {
1967 if (timerId !== undefined) {
1968 clearTimeout(timerId);
1969 }
1970 lastInvokeTime = 0;
1971 lastArgs = lastCallTime = lastThis = timerId = undefined;
1972 }
1973
1974 function flush() {
1975 return timerId === undefined ? result : trailingEdge(now());
1976 }
1977
1978 function debounced() {
1979 var time = now(),
1980 isInvoking = shouldInvoke(time);
1981
1982 lastArgs = arguments;
1983 lastThis = this;
1984 lastCallTime = time;
1985
1986 if (isInvoking) {
1987 if (timerId === undefined) {
1988 return leadingEdge(lastCallTime);
1989 }
1990 if (maxing) {
1991 // Handle invocations in a tight loop.
1992 timerId = setTimeout(timerExpired, wait);
1993 return invokeFunc(lastCallTime);
1994 }
1995 }
1996 if (timerId === undefined) {
1997 timerId = setTimeout(timerExpired, wait);
1998 }
1999 return result;
2000 }
2001 debounced.cancel = cancel;
2002 debounced.flush = flush;
2003 return debounced;
2004 }
2005
2006 /**
2007 * Creates a throttled function that only invokes `func` at most once per
2008 * every `wait` milliseconds. The throttled function comes with a `cancel`
2009 * method to cancel delayed `func` invocations and a `flush` method to
2010 * immediately invoke them. Provide `options` to indicate whether `func`
2011 * should be invoked on the leading and/or trailing edge of the `wait`
2012 * timeout. The `func` is invoked with the last arguments provided to the
2013 * throttled function. Subsequent calls to the throttled function return the
2014 * result of the last `func` invocation.
2015 *
2016 * **Note:** If `leading` and `trailing` options are `true`, `func` is
2017 * invoked on the trailing edge of the timeout only if the throttled function
2018 * is invoked more than once during the `wait` timeout.
2019 *
2020 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
2021 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
2022 *
2023 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
2024 * for details over the differences between `_.throttle` and `_.debounce`.
2025 *
2026 * @static
2027 * @memberOf _
2028 * @since 0.1.0
2029 * @category Function
2030 * @param {Function} func The function to throttle.
2031 * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
2032 * @param {Object} [options={}] The options object.
2033 * @param {boolean} [options.leading=true]
2034 * Specify invoking on the leading edge of the timeout.
2035 * @param {boolean} [options.trailing=true]
2036 * Specify invoking on the trailing edge of the timeout.
2037 * @returns {Function} Returns the new throttled function.
2038 * @example
2039 *
2040 * // Avoid excessively updating the position while scrolling.
2041 * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
2042 *
2043 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
2044 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
2045 * jQuery(element).on('click', throttled);
2046 *
2047 * // Cancel the trailing throttled invocation.
2048 * jQuery(window).on('popstate', throttled.cancel);
2049 */
2050 function throttle(func, wait, options) {
2051 var leading = true,
2052 trailing = true;
2053
2054 if (typeof func != 'function') {
2055 throw new TypeError(FUNC_ERROR_TEXT);
2056 }
2057 if (isObject$1(options)) {
2058 leading = 'leading' in options ? !!options.leading : leading;
2059 trailing = 'trailing' in options ? !!options.trailing : trailing;
2060 }
2061 return debounce(func, wait, {
2062 'leading': leading,
2063 'maxWait': wait,
2064 'trailing': trailing
2065 });
2066 }
2067
2068 /**
2069 * Checks if `value` is the
2070 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2071 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2072 *
2073 * @static
2074 * @memberOf _
2075 * @since 0.1.0
2076 * @category Lang
2077 * @param {*} value The value to check.
2078 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2079 * @example
2080 *
2081 * _.isObject({});
2082 * // => true
2083 *
2084 * _.isObject([1, 2, 3]);
2085 * // => true
2086 *
2087 * _.isObject(_.noop);
2088 * // => true
2089 *
2090 * _.isObject(null);
2091 * // => false
2092 */
2093 function isObject$1(value) {
2094 var type = typeof value;
2095 return !!value && (type == 'object' || type == 'function');
2096 }
2097
2098 /**
2099 * Checks if `value` is object-like. A value is object-like if it's not `null`
2100 * and has a `typeof` result of "object".
2101 *
2102 * @static
2103 * @memberOf _
2104 * @since 4.0.0
2105 * @category Lang
2106 * @param {*} value The value to check.
2107 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2108 * @example
2109 *
2110 * _.isObjectLike({});
2111 * // => true
2112 *
2113 * _.isObjectLike([1, 2, 3]);
2114 * // => true
2115 *
2116 * _.isObjectLike(_.noop);
2117 * // => false
2118 *
2119 * _.isObjectLike(null);
2120 * // => false
2121 */
2122 function isObjectLike(value) {
2123 return !!value && typeof value == 'object';
2124 }
2125
2126 /**
2127 * Checks if `value` is classified as a `Symbol` primitive or object.
2128 *
2129 * @static
2130 * @memberOf _
2131 * @since 4.0.0
2132 * @category Lang
2133 * @param {*} value The value to check.
2134 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2135 * @example
2136 *
2137 * _.isSymbol(Symbol.iterator);
2138 * // => true
2139 *
2140 * _.isSymbol('abc');
2141 * // => false
2142 */
2143 function isSymbol(value) {
2144 return typeof value == 'symbol' ||
2145 (isObjectLike(value) && objectToString$1.call(value) == symbolTag);
2146 }
2147
2148 /**
2149 * Converts `value` to a number.
2150 *
2151 * @static
2152 * @memberOf _
2153 * @since 4.0.0
2154 * @category Lang
2155 * @param {*} value The value to process.
2156 * @returns {number} Returns the number.
2157 * @example
2158 *
2159 * _.toNumber(3.2);
2160 * // => 3.2
2161 *
2162 * _.toNumber(Number.MIN_VALUE);
2163 * // => 5e-324
2164 *
2165 * _.toNumber(Infinity);
2166 * // => Infinity
2167 *
2168 * _.toNumber('3.2');
2169 * // => 3.2
2170 */
2171 function toNumber(value) {
2172 if (typeof value == 'number') {
2173 return value;
2174 }
2175 if (isSymbol(value)) {
2176 return NAN;
2177 }
2178 if (isObject$1(value)) {
2179 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
2180 value = isObject$1(other) ? (other + '') : other;
2181 }
2182 if (typeof value != 'string') {
2183 return value === 0 ? value : +value;
2184 }
2185 value = value.replace(reTrim, '');
2186 var isBinary = reIsBinary.test(value);
2187 return (isBinary || reIsOctal.test(value))
2188 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
2189 : (reIsBadHex.test(value) ? NAN : +value);
2190 }
2191
2192 var lodash_throttle = throttle;
2193
2194 /**
2195 * lodash (Custom Build) <https://lodash.com/>
2196 * Build: `lodash modularize exports="npm" -o ./`
2197 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2198 * Released under MIT license <https://lodash.com/license>
2199 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2200 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2201 */
2202
2203 /** Used as the `TypeError` message for "Functions" methods. */
2204 var FUNC_ERROR_TEXT$1 = 'Expected a function';
2205
2206 /** Used as references for various `Number` constants. */
2207 var NAN$1 = 0 / 0;
2208
2209 /** `Object#toString` result references. */
2210 var symbolTag$1 = '[object Symbol]';
2211
2212 /** Used to match leading and trailing whitespace. */
2213 var reTrim$1 = /^\s+|\s+$/g;
2214
2215 /** Used to detect bad signed hexadecimal string values. */
2216 var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i;
2217
2218 /** Used to detect binary string values. */
2219 var reIsBinary$1 = /^0b[01]+$/i;
2220
2221 /** Used to detect octal string values. */
2222 var reIsOctal$1 = /^0o[0-7]+$/i;
2223
2224 /** Built-in method references without a dependency on `root`. */
2225 var freeParseInt$1 = parseInt;
2226
2227 /** Detect free variable `global` from Node.js. */
2228 var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2229
2230 /** Detect free variable `self`. */
2231 var freeSelf$1 = typeof self == 'object' && self && self.Object === Object && self;
2232
2233 /** Used as a reference to the global object. */
2234 var root$1 = freeGlobal$1 || freeSelf$1 || Function('return this')();
2235
2236 /** Used for built-in method references. */
2237 var objectProto$1 = Object.prototype;
2238
2239 /**
2240 * Used to resolve the
2241 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2242 * of values.
2243 */
2244 var objectToString$2 = objectProto$1.toString;
2245
2246 /* Built-in method references for those with the same name as other `lodash` methods. */
2247 var nativeMax$1 = Math.max,
2248 nativeMin$1 = Math.min;
2249
2250 /**
2251 * Gets the timestamp of the number of milliseconds that have elapsed since
2252 * the Unix epoch (1 January 1970 00:00:00 UTC).
2253 *
2254 * @static
2255 * @memberOf _
2256 * @since 2.4.0
2257 * @category Date
2258 * @returns {number} Returns the timestamp.
2259 * @example
2260 *
2261 * _.defer(function(stamp) {
2262 * console.log(_.now() - stamp);
2263 * }, _.now());
2264 * // => Logs the number of milliseconds it took for the deferred invocation.
2265 */
2266 var now$1 = function() {
2267 return root$1.Date.now();
2268 };
2269
2270 /**
2271 * Creates a debounced function that delays invoking `func` until after `wait`
2272 * milliseconds have elapsed since the last time the debounced function was
2273 * invoked. The debounced function comes with a `cancel` method to cancel
2274 * delayed `func` invocations and a `flush` method to immediately invoke them.
2275 * Provide `options` to indicate whether `func` should be invoked on the
2276 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
2277 * with the last arguments provided to the debounced function. Subsequent
2278 * calls to the debounced function return the result of the last `func`
2279 * invocation.
2280 *
2281 * **Note:** If `leading` and `trailing` options are `true`, `func` is
2282 * invoked on the trailing edge of the timeout only if the debounced function
2283 * is invoked more than once during the `wait` timeout.
2284 *
2285 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
2286 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
2287 *
2288 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
2289 * for details over the differences between `_.debounce` and `_.throttle`.
2290 *
2291 * @static
2292 * @memberOf _
2293 * @since 0.1.0
2294 * @category Function
2295 * @param {Function} func The function to debounce.
2296 * @param {number} [wait=0] The number of milliseconds to delay.
2297 * @param {Object} [options={}] The options object.
2298 * @param {boolean} [options.leading=false]
2299 * Specify invoking on the leading edge of the timeout.
2300 * @param {number} [options.maxWait]
2301 * The maximum time `func` is allowed to be delayed before it's invoked.
2302 * @param {boolean} [options.trailing=true]
2303 * Specify invoking on the trailing edge of the timeout.
2304 * @returns {Function} Returns the new debounced function.
2305 * @example
2306 *
2307 * // Avoid costly calculations while the window size is in flux.
2308 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
2309 *
2310 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
2311 * jQuery(element).on('click', _.debounce(sendMail, 300, {
2312 * 'leading': true,
2313 * 'trailing': false
2314 * }));
2315 *
2316 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
2317 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
2318 * var source = new EventSource('/stream');
2319 * jQuery(source).on('message', debounced);
2320 *
2321 * // Cancel the trailing debounced invocation.
2322 * jQuery(window).on('popstate', debounced.cancel);
2323 */
2324 function debounce$1(func, wait, options) {
2325 var lastArgs,
2326 lastThis,
2327 maxWait,
2328 result,
2329 timerId,
2330 lastCallTime,
2331 lastInvokeTime = 0,
2332 leading = false,
2333 maxing = false,
2334 trailing = true;
2335
2336 if (typeof func != 'function') {
2337 throw new TypeError(FUNC_ERROR_TEXT$1);
2338 }
2339 wait = toNumber$1(wait) || 0;
2340 if (isObject$2(options)) {
2341 leading = !!options.leading;
2342 maxing = 'maxWait' in options;
2343 maxWait = maxing ? nativeMax$1(toNumber$1(options.maxWait) || 0, wait) : maxWait;
2344 trailing = 'trailing' in options ? !!options.trailing : trailing;
2345 }
2346
2347 function invokeFunc(time) {
2348 var args = lastArgs,
2349 thisArg = lastThis;
2350
2351 lastArgs = lastThis = undefined;
2352 lastInvokeTime = time;
2353 result = func.apply(thisArg, args);
2354 return result;
2355 }
2356
2357 function leadingEdge(time) {
2358 // Reset any `maxWait` timer.
2359 lastInvokeTime = time;
2360 // Start the timer for the trailing edge.
2361 timerId = setTimeout(timerExpired, wait);
2362 // Invoke the leading edge.
2363 return leading ? invokeFunc(time) : result;
2364 }
2365
2366 function remainingWait(time) {
2367 var timeSinceLastCall = time - lastCallTime,
2368 timeSinceLastInvoke = time - lastInvokeTime,
2369 result = wait - timeSinceLastCall;
2370
2371 return maxing ? nativeMin$1(result, maxWait - timeSinceLastInvoke) : result;
2372 }
2373
2374 function shouldInvoke(time) {
2375 var timeSinceLastCall = time - lastCallTime,
2376 timeSinceLastInvoke = time - lastInvokeTime;
2377
2378 // Either this is the first call, activity has stopped and we're at the
2379 // trailing edge, the system time has gone backwards and we're treating
2380 // it as the trailing edge, or we've hit the `maxWait` limit.
2381 return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
2382 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
2383 }
2384
2385 function timerExpired() {
2386 var time = now$1();
2387 if (shouldInvoke(time)) {
2388 return trailingEdge(time);
2389 }
2390 // Restart the timer.
2391 timerId = setTimeout(timerExpired, remainingWait(time));
2392 }
2393
2394 function trailingEdge(time) {
2395 timerId = undefined;
2396
2397 // Only invoke if we have `lastArgs` which means `func` has been
2398 // debounced at least once.
2399 if (trailing && lastArgs) {
2400 return invokeFunc(time);
2401 }
2402 lastArgs = lastThis = undefined;
2403 return result;
2404 }
2405
2406 function cancel() {
2407 if (timerId !== undefined) {
2408 clearTimeout(timerId);
2409 }
2410 lastInvokeTime = 0;
2411 lastArgs = lastCallTime = lastThis = timerId = undefined;
2412 }
2413
2414 function flush() {
2415 return timerId === undefined ? result : trailingEdge(now$1());
2416 }
2417
2418 function debounced() {
2419 var time = now$1(),
2420 isInvoking = shouldInvoke(time);
2421
2422 lastArgs = arguments;
2423 lastThis = this;
2424 lastCallTime = time;
2425
2426 if (isInvoking) {
2427 if (timerId === undefined) {
2428 return leadingEdge(lastCallTime);
2429 }
2430 if (maxing) {
2431 // Handle invocations in a tight loop.
2432 timerId = setTimeout(timerExpired, wait);
2433 return invokeFunc(lastCallTime);
2434 }
2435 }
2436 if (timerId === undefined) {
2437 timerId = setTimeout(timerExpired, wait);
2438 }
2439 return result;
2440 }
2441 debounced.cancel = cancel;
2442 debounced.flush = flush;
2443 return debounced;
2444 }
2445
2446 /**
2447 * Checks if `value` is the
2448 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2449 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2450 *
2451 * @static
2452 * @memberOf _
2453 * @since 0.1.0
2454 * @category Lang
2455 * @param {*} value The value to check.
2456 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2457 * @example
2458 *
2459 * _.isObject({});
2460 * // => true
2461 *
2462 * _.isObject([1, 2, 3]);
2463 * // => true
2464 *
2465 * _.isObject(_.noop);
2466 * // => true
2467 *
2468 * _.isObject(null);
2469 * // => false
2470 */
2471 function isObject$2(value) {
2472 var type = typeof value;
2473 return !!value && (type == 'object' || type == 'function');
2474 }
2475
2476 /**
2477 * Checks if `value` is object-like. A value is object-like if it's not `null`
2478 * and has a `typeof` result of "object".
2479 *
2480 * @static
2481 * @memberOf _
2482 * @since 4.0.0
2483 * @category Lang
2484 * @param {*} value The value to check.
2485 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2486 * @example
2487 *
2488 * _.isObjectLike({});
2489 * // => true
2490 *
2491 * _.isObjectLike([1, 2, 3]);
2492 * // => true
2493 *
2494 * _.isObjectLike(_.noop);
2495 * // => false
2496 *
2497 * _.isObjectLike(null);
2498 * // => false
2499 */
2500 function isObjectLike$1(value) {
2501 return !!value && typeof value == 'object';
2502 }
2503
2504 /**
2505 * Checks if `value` is classified as a `Symbol` primitive or object.
2506 *
2507 * @static
2508 * @memberOf _
2509 * @since 4.0.0
2510 * @category Lang
2511 * @param {*} value The value to check.
2512 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2513 * @example
2514 *
2515 * _.isSymbol(Symbol.iterator);
2516 * // => true
2517 *
2518 * _.isSymbol('abc');
2519 * // => false
2520 */
2521 function isSymbol$1(value) {
2522 return typeof value == 'symbol' ||
2523 (isObjectLike$1(value) && objectToString$2.call(value) == symbolTag$1);
2524 }
2525
2526 /**
2527 * Converts `value` to a number.
2528 *
2529 * @static
2530 * @memberOf _
2531 * @since 4.0.0
2532 * @category Lang
2533 * @param {*} value The value to process.
2534 * @returns {number} Returns the number.
2535 * @example
2536 *
2537 * _.toNumber(3.2);
2538 * // => 3.2
2539 *
2540 * _.toNumber(Number.MIN_VALUE);
2541 * // => 5e-324
2542 *
2543 * _.toNumber(Infinity);
2544 * // => Infinity
2545 *
2546 * _.toNumber('3.2');
2547 * // => 3.2
2548 */
2549 function toNumber$1(value) {
2550 if (typeof value == 'number') {
2551 return value;
2552 }
2553 if (isSymbol$1(value)) {
2554 return NAN$1;
2555 }
2556 if (isObject$2(value)) {
2557 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
2558 value = isObject$2(other) ? (other + '') : other;
2559 }
2560 if (typeof value != 'string') {
2561 return value === 0 ? value : +value;
2562 }
2563 value = value.replace(reTrim$1, '');
2564 var isBinary = reIsBinary$1.test(value);
2565 return (isBinary || reIsOctal$1.test(value))
2566 ? freeParseInt$1(value.slice(2), isBinary ? 2 : 8)
2567 : (reIsBadHex$1.test(value) ? NAN$1 : +value);
2568 }
2569
2570 var lodash_debounce = debounce$1;
2571
2572 /**
2573 * lodash (Custom Build) <https://lodash.com/>
2574 * Build: `lodash modularize exports="npm" -o ./`
2575 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2576 * Released under MIT license <https://lodash.com/license>
2577 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2578 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2579 */
2580
2581 /** Used as the `TypeError` message for "Functions" methods. */
2582 var FUNC_ERROR_TEXT$2 = 'Expected a function';
2583
2584 /** Used to stand-in for `undefined` hash values. */
2585 var HASH_UNDEFINED = '__lodash_hash_undefined__';
2586
2587 /** `Object#toString` result references. */
2588 var funcTag = '[object Function]',
2589 genTag = '[object GeneratorFunction]';
2590
2591 /**
2592 * Used to match `RegExp`
2593 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
2594 */
2595 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2596
2597 /** Used to detect host constructors (Safari). */
2598 var reIsHostCtor = /^\[object .+?Constructor\]$/;
2599
2600 /** Detect free variable `global` from Node.js. */
2601 var freeGlobal$2 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2602
2603 /** Detect free variable `self`. */
2604 var freeSelf$2 = typeof self == 'object' && self && self.Object === Object && self;
2605
2606 /** Used as a reference to the global object. */
2607 var root$2 = freeGlobal$2 || freeSelf$2 || Function('return this')();
2608
2609 /**
2610 * Gets the value at `key` of `object`.
2611 *
2612 * @private
2613 * @param {Object} [object] The object to query.
2614 * @param {string} key The key of the property to get.
2615 * @returns {*} Returns the property value.
2616 */
2617 function getValue(object, key) {
2618 return object == null ? undefined : object[key];
2619 }
2620
2621 /**
2622 * Checks if `value` is a host object in IE < 9.
2623 *
2624 * @private
2625 * @param {*} value The value to check.
2626 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
2627 */
2628 function isHostObject(value) {
2629 // Many host objects are `Object` objects that can coerce to strings
2630 // despite having improperly defined `toString` methods.
2631 var result = false;
2632 if (value != null && typeof value.toString != 'function') {
2633 try {
2634 result = !!(value + '');
2635 } catch (e) {}
2636 }
2637 return result;
2638 }
2639
2640 /** Used for built-in method references. */
2641 var arrayProto = Array.prototype,
2642 funcProto = Function.prototype,
2643 objectProto$2 = Object.prototype;
2644
2645 /** Used to detect overreaching core-js shims. */
2646 var coreJsData = root$2['__core-js_shared__'];
2647
2648 /** Used to detect methods masquerading as native. */
2649 var maskSrcKey = (function() {
2650 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
2651 return uid ? ('Symbol(src)_1.' + uid) : '';
2652 }());
2653
2654 /** Used to resolve the decompiled source of functions. */
2655 var funcToString = funcProto.toString;
2656
2657 /** Used to check objects for own properties. */
2658 var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
2659
2660 /**
2661 * Used to resolve the
2662 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2663 * of values.
2664 */
2665 var objectToString$3 = objectProto$2.toString;
2666
2667 /** Used to detect if a method is native. */
2668 var reIsNative = RegExp('^' +
2669 funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
2670 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
2671 );
2672
2673 /** Built-in value references. */
2674 var splice = arrayProto.splice;
2675
2676 /* Built-in method references that are verified to be native. */
2677 var Map$1 = getNative(root$2, 'Map'),
2678 nativeCreate = getNative(Object, 'create');
2679
2680 /**
2681 * Creates a hash object.
2682 *
2683 * @private
2684 * @constructor
2685 * @param {Array} [entries] The key-value pairs to cache.
2686 */
2687 function Hash(entries) {
2688 var index = -1,
2689 length = entries ? entries.length : 0;
2690
2691 this.clear();
2692 while (++index < length) {
2693 var entry = entries[index];
2694 this.set(entry[0], entry[1]);
2695 }
2696 }
2697
2698 /**
2699 * Removes all key-value entries from the hash.
2700 *
2701 * @private
2702 * @name clear
2703 * @memberOf Hash
2704 */
2705 function hashClear() {
2706 this.__data__ = nativeCreate ? nativeCreate(null) : {};
2707 }
2708
2709 /**
2710 * Removes `key` and its value from the hash.
2711 *
2712 * @private
2713 * @name delete
2714 * @memberOf Hash
2715 * @param {Object} hash The hash to modify.
2716 * @param {string} key The key of the value to remove.
2717 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2718 */
2719 function hashDelete(key) {
2720 return this.has(key) && delete this.__data__[key];
2721 }
2722
2723 /**
2724 * Gets the hash value for `key`.
2725 *
2726 * @private
2727 * @name get
2728 * @memberOf Hash
2729 * @param {string} key The key of the value to get.
2730 * @returns {*} Returns the entry value.
2731 */
2732 function hashGet(key) {
2733 var data = this.__data__;
2734 if (nativeCreate) {
2735 var result = data[key];
2736 return result === HASH_UNDEFINED ? undefined : result;
2737 }
2738 return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
2739 }
2740
2741 /**
2742 * Checks if a hash value for `key` exists.
2743 *
2744 * @private
2745 * @name has
2746 * @memberOf Hash
2747 * @param {string} key The key of the entry to check.
2748 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2749 */
2750 function hashHas(key) {
2751 var data = this.__data__;
2752 return nativeCreate ? data[key] !== undefined : hasOwnProperty$1.call(data, key);
2753 }
2754
2755 /**
2756 * Sets the hash `key` to `value`.
2757 *
2758 * @private
2759 * @name set
2760 * @memberOf Hash
2761 * @param {string} key The key of the value to set.
2762 * @param {*} value The value to set.
2763 * @returns {Object} Returns the hash instance.
2764 */
2765 function hashSet(key, value) {
2766 var data = this.__data__;
2767 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2768 return this;
2769 }
2770
2771 // Add methods to `Hash`.
2772 Hash.prototype.clear = hashClear;
2773 Hash.prototype['delete'] = hashDelete;
2774 Hash.prototype.get = hashGet;
2775 Hash.prototype.has = hashHas;
2776 Hash.prototype.set = hashSet;
2777
2778 /**
2779 * Creates an list cache object.
2780 *
2781 * @private
2782 * @constructor
2783 * @param {Array} [entries] The key-value pairs to cache.
2784 */
2785 function ListCache(entries) {
2786 var index = -1,
2787 length = entries ? entries.length : 0;
2788
2789 this.clear();
2790 while (++index < length) {
2791 var entry = entries[index];
2792 this.set(entry[0], entry[1]);
2793 }
2794 }
2795
2796 /**
2797 * Removes all key-value entries from the list cache.
2798 *
2799 * @private
2800 * @name clear
2801 * @memberOf ListCache
2802 */
2803 function listCacheClear() {
2804 this.__data__ = [];
2805 }
2806
2807 /**
2808 * Removes `key` and its value from the list cache.
2809 *
2810 * @private
2811 * @name delete
2812 * @memberOf ListCache
2813 * @param {string} key The key of the value to remove.
2814 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2815 */
2816 function listCacheDelete(key) {
2817 var data = this.__data__,
2818 index = assocIndexOf(data, key);
2819
2820 if (index < 0) {
2821 return false;
2822 }
2823 var lastIndex = data.length - 1;
2824 if (index == lastIndex) {
2825 data.pop();
2826 } else {
2827 splice.call(data, index, 1);
2828 }
2829 return true;
2830 }
2831
2832 /**
2833 * Gets the list cache value for `key`.
2834 *
2835 * @private
2836 * @name get
2837 * @memberOf ListCache
2838 * @param {string} key The key of the value to get.
2839 * @returns {*} Returns the entry value.
2840 */
2841 function listCacheGet(key) {
2842 var data = this.__data__,
2843 index = assocIndexOf(data, key);
2844
2845 return index < 0 ? undefined : data[index][1];
2846 }
2847
2848 /**
2849 * Checks if a list cache value for `key` exists.
2850 *
2851 * @private
2852 * @name has
2853 * @memberOf ListCache
2854 * @param {string} key The key of the entry to check.
2855 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2856 */
2857 function listCacheHas(key) {
2858 return assocIndexOf(this.__data__, key) > -1;
2859 }
2860
2861 /**
2862 * Sets the list cache `key` to `value`.
2863 *
2864 * @private
2865 * @name set
2866 * @memberOf ListCache
2867 * @param {string} key The key of the value to set.
2868 * @param {*} value The value to set.
2869 * @returns {Object} Returns the list cache instance.
2870 */
2871 function listCacheSet(key, value) {
2872 var data = this.__data__,
2873 index = assocIndexOf(data, key);
2874
2875 if (index < 0) {
2876 data.push([key, value]);
2877 } else {
2878 data[index][1] = value;
2879 }
2880 return this;
2881 }
2882
2883 // Add methods to `ListCache`.
2884 ListCache.prototype.clear = listCacheClear;
2885 ListCache.prototype['delete'] = listCacheDelete;
2886 ListCache.prototype.get = listCacheGet;
2887 ListCache.prototype.has = listCacheHas;
2888 ListCache.prototype.set = listCacheSet;
2889
2890 /**
2891 * Creates a map cache object to store key-value pairs.
2892 *
2893 * @private
2894 * @constructor
2895 * @param {Array} [entries] The key-value pairs to cache.
2896 */
2897 function MapCache(entries) {
2898 var index = -1,
2899 length = entries ? entries.length : 0;
2900
2901 this.clear();
2902 while (++index < length) {
2903 var entry = entries[index];
2904 this.set(entry[0], entry[1]);
2905 }
2906 }
2907
2908 /**
2909 * Removes all key-value entries from the map.
2910 *
2911 * @private
2912 * @name clear
2913 * @memberOf MapCache
2914 */
2915 function mapCacheClear() {
2916 this.__data__ = {
2917 'hash': new Hash,
2918 'map': new (Map$1 || ListCache),
2919 'string': new Hash
2920 };
2921 }
2922
2923 /**
2924 * Removes `key` and its value from the map.
2925 *
2926 * @private
2927 * @name delete
2928 * @memberOf MapCache
2929 * @param {string} key The key of the value to remove.
2930 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2931 */
2932 function mapCacheDelete(key) {
2933 return getMapData(this, key)['delete'](key);
2934 }
2935
2936 /**
2937 * Gets the map value for `key`.
2938 *
2939 * @private
2940 * @name get
2941 * @memberOf MapCache
2942 * @param {string} key The key of the value to get.
2943 * @returns {*} Returns the entry value.
2944 */
2945 function mapCacheGet(key) {
2946 return getMapData(this, key).get(key);
2947 }
2948
2949 /**
2950 * Checks if a map value for `key` exists.
2951 *
2952 * @private
2953 * @name has
2954 * @memberOf MapCache
2955 * @param {string} key The key of the entry to check.
2956 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2957 */
2958 function mapCacheHas(key) {
2959 return getMapData(this, key).has(key);
2960 }
2961
2962 /**
2963 * Sets the map `key` to `value`.
2964 *
2965 * @private
2966 * @name set
2967 * @memberOf MapCache
2968 * @param {string} key The key of the value to set.
2969 * @param {*} value The value to set.
2970 * @returns {Object} Returns the map cache instance.
2971 */
2972 function mapCacheSet(key, value) {
2973 getMapData(this, key).set(key, value);
2974 return this;
2975 }
2976
2977 // Add methods to `MapCache`.
2978 MapCache.prototype.clear = mapCacheClear;
2979 MapCache.prototype['delete'] = mapCacheDelete;
2980 MapCache.prototype.get = mapCacheGet;
2981 MapCache.prototype.has = mapCacheHas;
2982 MapCache.prototype.set = mapCacheSet;
2983
2984 /**
2985 * Gets the index at which the `key` is found in `array` of key-value pairs.
2986 *
2987 * @private
2988 * @param {Array} array The array to inspect.
2989 * @param {*} key The key to search for.
2990 * @returns {number} Returns the index of the matched value, else `-1`.
2991 */
2992 function assocIndexOf(array, key) {
2993 var length = array.length;
2994 while (length--) {
2995 if (eq(array[length][0], key)) {
2996 return length;
2997 }
2998 }
2999 return -1;
3000 }
3001
3002 /**
3003 * The base implementation of `_.isNative` without bad shim checks.
3004 *
3005 * @private
3006 * @param {*} value The value to check.
3007 * @returns {boolean} Returns `true` if `value` is a native function,
3008 * else `false`.
3009 */
3010 function baseIsNative(value) {
3011 if (!isObject$3(value) || isMasked(value)) {
3012 return false;
3013 }
3014 var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
3015 return pattern.test(toSource(value));
3016 }
3017
3018 /**
3019 * Gets the data for `map`.
3020 *
3021 * @private
3022 * @param {Object} map The map to query.
3023 * @param {string} key The reference key.
3024 * @returns {*} Returns the map data.
3025 */
3026 function getMapData(map, key) {
3027 var data = map.__data__;
3028 return isKeyable(key)
3029 ? data[typeof key == 'string' ? 'string' : 'hash']
3030 : data.map;
3031 }
3032
3033 /**
3034 * Gets the native function at `key` of `object`.
3035 *
3036 * @private
3037 * @param {Object} object The object to query.
3038 * @param {string} key The key of the method to get.
3039 * @returns {*} Returns the function if it's native, else `undefined`.
3040 */
3041 function getNative(object, key) {
3042 var value = getValue(object, key);
3043 return baseIsNative(value) ? value : undefined;
3044 }
3045
3046 /**
3047 * Checks if `value` is suitable for use as unique object key.
3048 *
3049 * @private
3050 * @param {*} value The value to check.
3051 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
3052 */
3053 function isKeyable(value) {
3054 var type = typeof value;
3055 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
3056 ? (value !== '__proto__')
3057 : (value === null);
3058 }
3059
3060 /**
3061 * Checks if `func` has its source masked.
3062 *
3063 * @private
3064 * @param {Function} func The function to check.
3065 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
3066 */
3067 function isMasked(func) {
3068 return !!maskSrcKey && (maskSrcKey in func);
3069 }
3070
3071 /**
3072 * Converts `func` to its source code.
3073 *
3074 * @private
3075 * @param {Function} func The function to process.
3076 * @returns {string} Returns the source code.
3077 */
3078 function toSource(func) {
3079 if (func != null) {
3080 try {
3081 return funcToString.call(func);
3082 } catch (e) {}
3083 try {
3084 return (func + '');
3085 } catch (e) {}
3086 }
3087 return '';
3088 }
3089
3090 /**
3091 * Creates a function that memoizes the result of `func`. If `resolver` is
3092 * provided, it determines the cache key for storing the result based on the
3093 * arguments provided to the memoized function. By default, the first argument
3094 * provided to the memoized function is used as the map cache key. The `func`
3095 * is invoked with the `this` binding of the memoized function.
3096 *
3097 * **Note:** The cache is exposed as the `cache` property on the memoized
3098 * function. Its creation may be customized by replacing the `_.memoize.Cache`
3099 * constructor with one whose instances implement the
3100 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
3101 * method interface of `delete`, `get`, `has`, and `set`.
3102 *
3103 * @static
3104 * @memberOf _
3105 * @since 0.1.0
3106 * @category Function
3107 * @param {Function} func The function to have its output memoized.
3108 * @param {Function} [resolver] The function to resolve the cache key.
3109 * @returns {Function} Returns the new memoized function.
3110 * @example
3111 *
3112 * var object = { 'a': 1, 'b': 2 };
3113 * var other = { 'c': 3, 'd': 4 };
3114 *
3115 * var values = _.memoize(_.values);
3116 * values(object);
3117 * // => [1, 2]
3118 *
3119 * values(other);
3120 * // => [3, 4]
3121 *
3122 * object.a = 2;
3123 * values(object);
3124 * // => [1, 2]
3125 *
3126 * // Modify the result cache.
3127 * values.cache.set(object, ['a', 'b']);
3128 * values(object);
3129 * // => ['a', 'b']
3130 *
3131 * // Replace `_.memoize.Cache`.
3132 * _.memoize.Cache = WeakMap;
3133 */
3134 function memoize(func, resolver) {
3135 if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
3136 throw new TypeError(FUNC_ERROR_TEXT$2);
3137 }
3138 var memoized = function() {
3139 var args = arguments,
3140 key = resolver ? resolver.apply(this, args) : args[0],
3141 cache = memoized.cache;
3142
3143 if (cache.has(key)) {
3144 return cache.get(key);
3145 }
3146 var result = func.apply(this, args);
3147 memoized.cache = cache.set(key, result);
3148 return result;
3149 };
3150 memoized.cache = new (memoize.Cache || MapCache);
3151 return memoized;
3152 }
3153
3154 // Assign cache to `_.memoize`.
3155 memoize.Cache = MapCache;
3156
3157 /**
3158 * Performs a
3159 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
3160 * comparison between two values to determine if they are equivalent.
3161 *
3162 * @static
3163 * @memberOf _
3164 * @since 4.0.0
3165 * @category Lang
3166 * @param {*} value The value to compare.
3167 * @param {*} other The other value to compare.
3168 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3169 * @example
3170 *
3171 * var object = { 'a': 1 };
3172 * var other = { 'a': 1 };
3173 *
3174 * _.eq(object, object);
3175 * // => true
3176 *
3177 * _.eq(object, other);
3178 * // => false
3179 *
3180 * _.eq('a', 'a');
3181 * // => true
3182 *
3183 * _.eq('a', Object('a'));
3184 * // => false
3185 *
3186 * _.eq(NaN, NaN);
3187 * // => true
3188 */
3189 function eq(value, other) {
3190 return value === other || (value !== value && other !== other);
3191 }
3192
3193 /**
3194 * Checks if `value` is classified as a `Function` object.
3195 *
3196 * @static
3197 * @memberOf _
3198 * @since 0.1.0
3199 * @category Lang
3200 * @param {*} value The value to check.
3201 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3202 * @example
3203 *
3204 * _.isFunction(_);
3205 * // => true
3206 *
3207 * _.isFunction(/abc/);
3208 * // => false
3209 */
3210 function isFunction(value) {
3211 // The use of `Object#toString` avoids issues with the `typeof` operator
3212 // in Safari 8-9 which returns 'object' for typed array and other constructors.
3213 var tag = isObject$3(value) ? objectToString$3.call(value) : '';
3214 return tag == funcTag || tag == genTag;
3215 }
3216
3217 /**
3218 * Checks if `value` is the
3219 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3220 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3221 *
3222 * @static
3223 * @memberOf _
3224 * @since 0.1.0
3225 * @category Lang
3226 * @param {*} value The value to check.
3227 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3228 * @example
3229 *
3230 * _.isObject({});
3231 * // => true
3232 *
3233 * _.isObject([1, 2, 3]);
3234 * // => true
3235 *
3236 * _.isObject(_.noop);
3237 * // => true
3238 *
3239 * _.isObject(null);
3240 * // => false
3241 */
3242 function isObject$3(value) {
3243 var type = typeof value;
3244 return !!value && (type == 'object' || type == 'function');
3245 }
3246
3247 var lodash_memoize = memoize;
3248
3249 /**
3250 * A collection of shims that provide minimal functionality of the ES6 collections.
3251 *
3252 * These implementations are not meant to be used outside of the ResizeObserver
3253 * modules as they cover only a limited range of use cases.
3254 */
3255 /* eslint-disable require-jsdoc, valid-jsdoc */
3256 var MapShim = (function () {
3257 if (typeof Map !== 'undefined') {
3258 return Map;
3259 }
3260 /**
3261 * Returns index in provided array that matches the specified key.
3262 *
3263 * @param {Array<Array>} arr
3264 * @param {*} key
3265 * @returns {number}
3266 */
3267 function getIndex(arr, key) {
3268 var result = -1;
3269 arr.some(function (entry, index) {
3270 if (entry[0] === key) {
3271 result = index;
3272 return true;
3273 }
3274 return false;
3275 });
3276 return result;
3277 }
3278 return /** @class */ (function () {
3279 function class_1() {
3280 this.__entries__ = [];
3281 }
3282 Object.defineProperty(class_1.prototype, "size", {
3283 /**
3284 * @returns {boolean}
3285 */
3286 get: function () {
3287 return this.__entries__.length;
3288 },
3289 enumerable: true,
3290 configurable: true
3291 });
3292 /**
3293 * @param {*} key
3294 * @returns {*}
3295 */
3296 class_1.prototype.get = function (key) {
3297 var index = getIndex(this.__entries__, key);
3298 var entry = this.__entries__[index];
3299 return entry && entry[1];
3300 };
3301 /**
3302 * @param {*} key
3303 * @param {*} value
3304 * @returns {void}
3305 */
3306 class_1.prototype.set = function (key, value) {
3307 var index = getIndex(this.__entries__, key);
3308 if (~index) {
3309 this.__entries__[index][1] = value;
3310 }
3311 else {
3312 this.__entries__.push([key, value]);
3313 }
3314 };
3315 /**
3316 * @param {*} key
3317 * @returns {void}
3318 */
3319 class_1.prototype.delete = function (key) {
3320 var entries = this.__entries__;
3321 var index = getIndex(entries, key);
3322 if (~index) {
3323 entries.splice(index, 1);
3324 }
3325 };
3326 /**
3327 * @param {*} key
3328 * @returns {void}
3329 */
3330 class_1.prototype.has = function (key) {
3331 return !!~getIndex(this.__entries__, key);
3332 };
3333 /**
3334 * @returns {void}
3335 */
3336 class_1.prototype.clear = function () {
3337 this.__entries__.splice(0);
3338 };
3339 /**
3340 * @param {Function} callback
3341 * @param {*} [ctx=null]
3342 * @returns {void}
3343 */
3344 class_1.prototype.forEach = function (callback, ctx) {
3345 if (ctx === void 0) { ctx = null; }
3346 for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
3347 var entry = _a[_i];
3348 callback.call(ctx, entry[1], entry[0]);
3349 }
3350 };
3351 return class_1;
3352 }());
3353 })();
3354
3355 /**
3356 * Detects whether window and document objects are available in current environment.
3357 */
3358 var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
3359
3360 // Returns global object of a current environment.
3361 var global$1 = (function () {
3362 if (typeof global !== 'undefined' && global.Math === Math) {
3363 return global;
3364 }
3365 if (typeof self !== 'undefined' && self.Math === Math) {
3366 return self;
3367 }
3368 if (typeof window !== 'undefined' && window.Math === Math) {
3369 return window;
3370 }
3371 // eslint-disable-next-line no-new-func
3372 return Function('return this')();
3373 })();
3374
3375 /**
3376 * A shim for the requestAnimationFrame which falls back to the setTimeout if
3377 * first one is not supported.
3378 *
3379 * @returns {number} Requests' identifier.
3380 */
3381 var requestAnimationFrame$1 = (function () {
3382 if (typeof requestAnimationFrame === 'function') {
3383 // It's required to use a bounded function because IE sometimes throws
3384 // an "Invalid calling object" error if rAF is invoked without the global
3385 // object on the left hand side.
3386 return requestAnimationFrame.bind(global$1);
3387 }
3388 return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
3389 })();
3390
3391 // Defines minimum timeout before adding a trailing call.
3392 var trailingTimeout = 2;
3393 /**
3394 * Creates a wrapper function which ensures that provided callback will be
3395 * invoked only once during the specified delay period.
3396 *
3397 * @param {Function} callback - Function to be invoked after the delay period.
3398 * @param {number} delay - Delay after which to invoke callback.
3399 * @returns {Function}
3400 */
3401 function throttle$1 (callback, delay) {
3402 var leadingCall = false, trailingCall = false, lastCallTime = 0;
3403 /**
3404 * Invokes the original callback function and schedules new invocation if
3405 * the "proxy" was called during current request.
3406 *
3407 * @returns {void}
3408 */
3409 function resolvePending() {
3410 if (leadingCall) {
3411 leadingCall = false;
3412 callback();
3413 }
3414 if (trailingCall) {
3415 proxy();
3416 }
3417 }
3418 /**
3419 * Callback invoked after the specified delay. It will further postpone
3420 * invocation of the original function delegating it to the
3421 * requestAnimationFrame.
3422 *
3423 * @returns {void}
3424 */
3425 function timeoutCallback() {
3426 requestAnimationFrame$1(resolvePending);
3427 }
3428 /**
3429 * Schedules invocation of the original function.
3430 *
3431 * @returns {void}
3432 */
3433 function proxy() {
3434 var timeStamp = Date.now();
3435 if (leadingCall) {
3436 // Reject immediately following calls.
3437 if (timeStamp - lastCallTime < trailingTimeout) {
3438 return;
3439 }
3440 // Schedule new call to be in invoked when the pending one is resolved.
3441 // This is important for "transitions" which never actually start
3442 // immediately so there is a chance that we might miss one if change
3443 // happens amids the pending invocation.
3444 trailingCall = true;
3445 }
3446 else {
3447 leadingCall = true;
3448 trailingCall = false;
3449 setTimeout(timeoutCallback, delay);
3450 }
3451 lastCallTime = timeStamp;
3452 }
3453 return proxy;
3454 }
3455
3456 // Minimum delay before invoking the update of observers.
3457 var REFRESH_DELAY = 20;
3458 // A list of substrings of CSS properties used to find transition events that
3459 // might affect dimensions of observed elements.
3460 var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
3461 // Check if MutationObserver is available.
3462 var mutationObserverSupported = typeof MutationObserver !== 'undefined';
3463 /**
3464 * Singleton controller class which handles updates of ResizeObserver instances.
3465 */
3466 var ResizeObserverController = /** @class */ (function () {
3467 /**
3468 * Creates a new instance of ResizeObserverController.
3469 *
3470 * @private
3471 */
3472 function ResizeObserverController() {
3473 /**
3474 * Indicates whether DOM listeners have been added.
3475 *
3476 * @private {boolean}
3477 */
3478 this.connected_ = false;
3479 /**
3480 * Tells that controller has subscribed for Mutation Events.
3481 *
3482 * @private {boolean}
3483 */
3484 this.mutationEventsAdded_ = false;
3485 /**
3486 * Keeps reference to the instance of MutationObserver.
3487 *
3488 * @private {MutationObserver}
3489 */
3490 this.mutationsObserver_ = null;
3491 /**
3492 * A list of connected observers.
3493 *
3494 * @private {Array<ResizeObserverSPI>}
3495 */
3496 this.observers_ = [];
3497 this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
3498 this.refresh = throttle$1(this.refresh.bind(this), REFRESH_DELAY);
3499 }
3500 /**
3501 * Adds observer to observers list.
3502 *
3503 * @param {ResizeObserverSPI} observer - Observer to be added.
3504 * @returns {void}
3505 */
3506 ResizeObserverController.prototype.addObserver = function (observer) {
3507 if (!~this.observers_.indexOf(observer)) {
3508 this.observers_.push(observer);
3509 }
3510 // Add listeners if they haven't been added yet.
3511 if (!this.connected_) {
3512 this.connect_();
3513 }
3514 };
3515 /**
3516 * Removes observer from observers list.
3517 *
3518 * @param {ResizeObserverSPI} observer - Observer to be removed.
3519 * @returns {void}
3520 */
3521 ResizeObserverController.prototype.removeObserver = function (observer) {
3522 var observers = this.observers_;
3523 var index = observers.indexOf(observer);
3524 // Remove observer if it's present in registry.
3525 if (~index) {
3526 observers.splice(index, 1);
3527 }
3528 // Remove listeners if controller has no connected observers.
3529 if (!observers.length && this.connected_) {
3530 this.disconnect_();
3531 }
3532 };
3533 /**
3534 * Invokes the update of observers. It will continue running updates insofar
3535 * it detects changes.
3536 *
3537 * @returns {void}
3538 */
3539 ResizeObserverController.prototype.refresh = function () {
3540 var changesDetected = this.updateObservers_();
3541 // Continue running updates if changes have been detected as there might
3542 // be future ones caused by CSS transitions.
3543 if (changesDetected) {
3544 this.refresh();
3545 }
3546 };
3547 /**
3548 * Updates every observer from observers list and notifies them of queued
3549 * entries.
3550 *
3551 * @private
3552 * @returns {boolean} Returns "true" if any observer has detected changes in
3553 * dimensions of it's elements.
3554 */
3555 ResizeObserverController.prototype.updateObservers_ = function () {
3556 // Collect observers that have active observations.
3557 var activeObservers = this.observers_.filter(function (observer) {
3558 return observer.gatherActive(), observer.hasActive();
3559 });
3560 // Deliver notifications in a separate cycle in order to avoid any
3561 // collisions between observers, e.g. when multiple instances of
3562 // ResizeObserver are tracking the same element and the callback of one
3563 // of them changes content dimensions of the observed target. Sometimes
3564 // this may result in notifications being blocked for the rest of observers.
3565 activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
3566 return activeObservers.length > 0;
3567 };
3568 /**
3569 * Initializes DOM listeners.
3570 *
3571 * @private
3572 * @returns {void}
3573 */
3574 ResizeObserverController.prototype.connect_ = function () {
3575 // Do nothing if running in a non-browser environment or if listeners
3576 // have been already added.
3577 if (!isBrowser || this.connected_) {
3578 return;
3579 }
3580 // Subscription to the "Transitionend" event is used as a workaround for
3581 // delayed transitions. This way it's possible to capture at least the
3582 // final state of an element.
3583 document.addEventListener('transitionend', this.onTransitionEnd_);
3584 window.addEventListener('resize', this.refresh);
3585 if (mutationObserverSupported) {
3586 this.mutationsObserver_ = new MutationObserver(this.refresh);
3587 this.mutationsObserver_.observe(document, {
3588 attributes: true,
3589 childList: true,
3590 characterData: true,
3591 subtree: true
3592 });
3593 }
3594 else {
3595 document.addEventListener('DOMSubtreeModified', this.refresh);
3596 this.mutationEventsAdded_ = true;
3597 }
3598 this.connected_ = true;
3599 };
3600 /**
3601 * Removes DOM listeners.
3602 *
3603 * @private
3604 * @returns {void}
3605 */
3606 ResizeObserverController.prototype.disconnect_ = function () {
3607 // Do nothing if running in a non-browser environment or if listeners
3608 // have been already removed.
3609 if (!isBrowser || !this.connected_) {
3610 return;
3611 }
3612 document.removeEventListener('transitionend', this.onTransitionEnd_);
3613 window.removeEventListener('resize', this.refresh);
3614 if (this.mutationsObserver_) {
3615 this.mutationsObserver_.disconnect();
3616 }
3617 if (this.mutationEventsAdded_) {
3618 document.removeEventListener('DOMSubtreeModified', this.refresh);
3619 }
3620 this.mutationsObserver_ = null;
3621 this.mutationEventsAdded_ = false;
3622 this.connected_ = false;
3623 };
3624 /**
3625 * "Transitionend" event handler.
3626 *
3627 * @private
3628 * @param {TransitionEvent} event
3629 * @returns {void}
3630 */
3631 ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
3632 var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
3633 // Detect whether transition may affect dimensions of an element.
3634 var isReflowProperty = transitionKeys.some(function (key) {
3635 return !!~propertyName.indexOf(key);
3636 });
3637 if (isReflowProperty) {
3638 this.refresh();
3639 }
3640 };
3641 /**
3642 * Returns instance of the ResizeObserverController.
3643 *
3644 * @returns {ResizeObserverController}
3645 */
3646 ResizeObserverController.getInstance = function () {
3647 if (!this.instance_) {
3648 this.instance_ = new ResizeObserverController();
3649 }
3650 return this.instance_;
3651 };
3652 /**
3653 * Holds reference to the controller's instance.
3654 *
3655 * @private {ResizeObserverController}
3656 */
3657 ResizeObserverController.instance_ = null;
3658 return ResizeObserverController;
3659 }());
3660
3661 /**
3662 * Defines non-writable/enumerable properties of the provided target object.
3663 *
3664 * @param {Object} target - Object for which to define properties.
3665 * @param {Object} props - Properties to be defined.
3666 * @returns {Object} Target object.
3667 */
3668 var defineConfigurable = (function (target, props) {
3669 for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
3670 var key = _a[_i];
3671 Object.defineProperty(target, key, {
3672 value: props[key],
3673 enumerable: false,
3674 writable: false,
3675 configurable: true
3676 });
3677 }
3678 return target;
3679 });
3680
3681 /**
3682 * Returns the global object associated with provided element.
3683 *
3684 * @param {Object} target
3685 * @returns {Object}
3686 */
3687 var getWindowOf = (function (target) {
3688 // Assume that the element is an instance of Node, which means that it
3689 // has the "ownerDocument" property from which we can retrieve a
3690 // corresponding global object.
3691 var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
3692 // Return the local global object if it's not possible extract one from
3693 // provided element.
3694 return ownerGlobal || global$1;
3695 });
3696
3697 // Placeholder of an empty content rectangle.
3698 var emptyRect = createRectInit(0, 0, 0, 0);
3699 /**
3700 * Converts provided string to a number.
3701 *
3702 * @param {number|string} value
3703 * @returns {number}
3704 */
3705 function toFloat(value) {
3706 return parseFloat(value) || 0;
3707 }
3708 /**
3709 * Extracts borders size from provided styles.
3710 *
3711 * @param {CSSStyleDeclaration} styles
3712 * @param {...string} positions - Borders positions (top, right, ...)
3713 * @returns {number}
3714 */
3715 function getBordersSize(styles) {
3716 var positions = [];
3717 for (var _i = 1; _i < arguments.length; _i++) {
3718 positions[_i - 1] = arguments[_i];
3719 }
3720 return positions.reduce(function (size, position) {
3721 var value = styles['border-' + position + '-width'];
3722 return size + toFloat(value);
3723 }, 0);
3724 }
3725 /**
3726 * Extracts paddings sizes from provided styles.
3727 *
3728 * @param {CSSStyleDeclaration} styles
3729 * @returns {Object} Paddings box.
3730 */
3731 function getPaddings(styles) {
3732 var positions = ['top', 'right', 'bottom', 'left'];
3733 var paddings = {};
3734 for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
3735 var position = positions_1[_i];
3736 var value = styles['padding-' + position];
3737 paddings[position] = toFloat(value);
3738 }
3739 return paddings;
3740 }
3741 /**
3742 * Calculates content rectangle of provided SVG element.
3743 *
3744 * @param {SVGGraphicsElement} target - Element content rectangle of which needs
3745 * to be calculated.
3746 * @returns {DOMRectInit}
3747 */
3748 function getSVGContentRect(target) {
3749 var bbox = target.getBBox();
3750 return createRectInit(0, 0, bbox.width, bbox.height);
3751 }
3752 /**
3753 * Calculates content rectangle of provided HTMLElement.
3754 *
3755 * @param {HTMLElement} target - Element for which to calculate the content rectangle.
3756 * @returns {DOMRectInit}
3757 */
3758 function getHTMLElementContentRect(target) {
3759 // Client width & height properties can't be
3760 // used exclusively as they provide rounded values.
3761 var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
3762 // By this condition we can catch all non-replaced inline, hidden and
3763 // detached elements. Though elements with width & height properties less
3764 // than 0.5 will be discarded as well.
3765 //
3766 // Without it we would need to implement separate methods for each of
3767 // those cases and it's not possible to perform a precise and performance
3768 // effective test for hidden elements. E.g. even jQuery's ':visible' filter
3769 // gives wrong results for elements with width & height less than 0.5.
3770 if (!clientWidth && !clientHeight) {
3771 return emptyRect;
3772 }
3773 var styles = getWindowOf(target).getComputedStyle(target);
3774 var paddings = getPaddings(styles);
3775 var horizPad = paddings.left + paddings.right;
3776 var vertPad = paddings.top + paddings.bottom;
3777 // Computed styles of width & height are being used because they are the
3778 // only dimensions available to JS that contain non-rounded values. It could
3779 // be possible to utilize the getBoundingClientRect if only it's data wasn't
3780 // affected by CSS transformations let alone paddings, borders and scroll bars.
3781 var width = toFloat(styles.width), height = toFloat(styles.height);
3782 // Width & height include paddings and borders when the 'border-box' box
3783 // model is applied (except for IE).
3784 if (styles.boxSizing === 'border-box') {
3785 // Following conditions are required to handle Internet Explorer which
3786 // doesn't include paddings and borders to computed CSS dimensions.
3787 //
3788 // We can say that if CSS dimensions + paddings are equal to the "client"
3789 // properties then it's either IE, and thus we don't need to subtract
3790 // anything, or an element merely doesn't have paddings/borders styles.
3791 if (Math.round(width + horizPad) !== clientWidth) {
3792 width -= getBordersSize(styles, 'left', 'right') + horizPad;
3793 }
3794 if (Math.round(height + vertPad) !== clientHeight) {
3795 height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
3796 }
3797 }
3798 // Following steps can't be applied to the document's root element as its
3799 // client[Width/Height] properties represent viewport area of the window.
3800 // Besides, it's as well not necessary as the <html> itself neither has
3801 // rendered scroll bars nor it can be clipped.
3802 if (!isDocumentElement(target)) {
3803 // In some browsers (only in Firefox, actually) CSS width & height
3804 // include scroll bars size which can be removed at this step as scroll
3805 // bars are the only difference between rounded dimensions + paddings
3806 // and "client" properties, though that is not always true in Chrome.
3807 var vertScrollbar = Math.round(width + horizPad) - clientWidth;
3808 var horizScrollbar = Math.round(height + vertPad) - clientHeight;
3809 // Chrome has a rather weird rounding of "client" properties.
3810 // E.g. for an element with content width of 314.2px it sometimes gives
3811 // the client width of 315px and for the width of 314.7px it may give
3812 // 314px. And it doesn't happen all the time. So just ignore this delta
3813 // as a non-relevant.
3814 if (Math.abs(vertScrollbar) !== 1) {
3815 width -= vertScrollbar;
3816 }
3817 if (Math.abs(horizScrollbar) !== 1) {
3818 height -= horizScrollbar;
3819 }
3820 }
3821 return createRectInit(paddings.left, paddings.top, width, height);
3822 }
3823 /**
3824 * Checks whether provided element is an instance of the SVGGraphicsElement.
3825 *
3826 * @param {Element} target - Element to be checked.
3827 * @returns {boolean}
3828 */
3829 var isSVGGraphicsElement = (function () {
3830 // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
3831 // interface.
3832 if (typeof SVGGraphicsElement !== 'undefined') {
3833 return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
3834 }
3835 // If it's so, then check that element is at least an instance of the
3836 // SVGElement and that it has the "getBBox" method.
3837 // eslint-disable-next-line no-extra-parens
3838 return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
3839 typeof target.getBBox === 'function'); };
3840 })();
3841 /**
3842 * Checks whether provided element is a document element (<html>).
3843 *
3844 * @param {Element} target - Element to be checked.
3845 * @returns {boolean}
3846 */
3847 function isDocumentElement(target) {
3848 return target === getWindowOf(target).document.documentElement;
3849 }
3850 /**
3851 * Calculates an appropriate content rectangle for provided html or svg element.
3852 *
3853 * @param {Element} target - Element content rectangle of which needs to be calculated.
3854 * @returns {DOMRectInit}
3855 */
3856 function getContentRect(target) {
3857 if (!isBrowser) {
3858 return emptyRect;
3859 }
3860 if (isSVGGraphicsElement(target)) {
3861 return getSVGContentRect(target);
3862 }
3863 return getHTMLElementContentRect(target);
3864 }
3865 /**
3866 * Creates rectangle with an interface of the DOMRectReadOnly.
3867 * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
3868 *
3869 * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
3870 * @returns {DOMRectReadOnly}
3871 */
3872 function createReadOnlyRect(_a) {
3873 var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
3874 // If DOMRectReadOnly is available use it as a prototype for the rectangle.
3875 var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
3876 var rect = Object.create(Constr.prototype);
3877 // Rectangle's properties are not writable and non-enumerable.
3878 defineConfigurable(rect, {
3879 x: x, y: y, width: width, height: height,
3880 top: y,
3881 right: x + width,
3882 bottom: height + y,
3883 left: x
3884 });
3885 return rect;
3886 }
3887 /**
3888 * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
3889 * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
3890 *
3891 * @param {number} x - X coordinate.
3892 * @param {number} y - Y coordinate.
3893 * @param {number} width - Rectangle's width.
3894 * @param {number} height - Rectangle's height.
3895 * @returns {DOMRectInit}
3896 */
3897 function createRectInit(x, y, width, height) {
3898 return { x: x, y: y, width: width, height: height };
3899 }
3900
3901 /**
3902 * Class that is responsible for computations of the content rectangle of
3903 * provided DOM element and for keeping track of it's changes.
3904 */
3905 var ResizeObservation = /** @class */ (function () {
3906 /**
3907 * Creates an instance of ResizeObservation.
3908 *
3909 * @param {Element} target - Element to be observed.
3910 */
3911 function ResizeObservation(target) {
3912 /**
3913 * Broadcasted width of content rectangle.
3914 *
3915 * @type {number}
3916 */
3917 this.broadcastWidth = 0;
3918 /**
3919 * Broadcasted height of content rectangle.
3920 *
3921 * @type {number}
3922 */
3923 this.broadcastHeight = 0;
3924 /**
3925 * Reference to the last observed content rectangle.
3926 *
3927 * @private {DOMRectInit}
3928 */
3929 this.contentRect_ = createRectInit(0, 0, 0, 0);
3930 this.target = target;
3931 }
3932 /**
3933 * Updates content rectangle and tells whether it's width or height properties
3934 * have changed since the last broadcast.
3935 *
3936 * @returns {boolean}
3937 */
3938 ResizeObservation.prototype.isActive = function () {
3939 var rect = getContentRect(this.target);
3940 this.contentRect_ = rect;
3941 return (rect.width !== this.broadcastWidth ||
3942 rect.height !== this.broadcastHeight);
3943 };
3944 /**
3945 * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
3946 * from the corresponding properties of the last observed content rectangle.
3947 *
3948 * @returns {DOMRectInit} Last observed content rectangle.
3949 */
3950 ResizeObservation.prototype.broadcastRect = function () {
3951 var rect = this.contentRect_;
3952 this.broadcastWidth = rect.width;
3953 this.broadcastHeight = rect.height;
3954 return rect;
3955 };
3956 return ResizeObservation;
3957 }());
3958
3959 var ResizeObserverEntry = /** @class */ (function () {
3960 /**
3961 * Creates an instance of ResizeObserverEntry.
3962 *
3963 * @param {Element} target - Element that is being observed.
3964 * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
3965 */
3966 function ResizeObserverEntry(target, rectInit) {
3967 var contentRect = createReadOnlyRect(rectInit);
3968 // According to the specification following properties are not writable
3969 // and are also not enumerable in the native implementation.
3970 //
3971 // Property accessors are not being used as they'd require to define a
3972 // private WeakMap storage which may cause memory leaks in browsers that
3973 // don't support this type of collections.
3974 defineConfigurable(this, { target: target, contentRect: contentRect });
3975 }
3976 return ResizeObserverEntry;
3977 }());
3978
3979 var ResizeObserverSPI = /** @class */ (function () {
3980 /**
3981 * Creates a new instance of ResizeObserver.
3982 *
3983 * @param {ResizeObserverCallback} callback - Callback function that is invoked
3984 * when one of the observed elements changes it's content dimensions.
3985 * @param {ResizeObserverController} controller - Controller instance which
3986 * is responsible for the updates of observer.
3987 * @param {ResizeObserver} callbackCtx - Reference to the public
3988 * ResizeObserver instance which will be passed to callback function.
3989 */
3990 function ResizeObserverSPI(callback, controller, callbackCtx) {
3991 /**
3992 * Collection of resize observations that have detected changes in dimensions
3993 * of elements.
3994 *
3995 * @private {Array<ResizeObservation>}
3996 */
3997 this.activeObservations_ = [];
3998 /**
3999 * Registry of the ResizeObservation instances.
4000 *
4001 * @private {Map<Element, ResizeObservation>}
4002 */
4003 this.observations_ = new MapShim();
4004 if (typeof callback !== 'function') {
4005 throw new TypeError('The callback provided as parameter 1 is not a function.');
4006 }
4007 this.callback_ = callback;
4008 this.controller_ = controller;
4009 this.callbackCtx_ = callbackCtx;
4010 }
4011 /**
4012 * Starts observing provided element.
4013 *
4014 * @param {Element} target - Element to be observed.
4015 * @returns {void}
4016 */
4017 ResizeObserverSPI.prototype.observe = function (target) {
4018 if (!arguments.length) {
4019 throw new TypeError('1 argument required, but only 0 present.');
4020 }
4021 // Do nothing if current environment doesn't have the Element interface.
4022 if (typeof Element === 'undefined' || !(Element instanceof Object)) {
4023 return;
4024 }
4025 if (!(target instanceof getWindowOf(target).Element)) {
4026 throw new TypeError('parameter 1 is not of type "Element".');
4027 }
4028 var observations = this.observations_;
4029 // Do nothing if element is already being observed.
4030 if (observations.has(target)) {
4031 return;
4032 }
4033 observations.set(target, new ResizeObservation(target));
4034 this.controller_.addObserver(this);
4035 // Force the update of observations.
4036 this.controller_.refresh();
4037 };
4038 /**
4039 * Stops observing provided element.
4040 *
4041 * @param {Element} target - Element to stop observing.
4042 * @returns {void}
4043 */
4044 ResizeObserverSPI.prototype.unobserve = function (target) {
4045 if (!arguments.length) {
4046 throw new TypeError('1 argument required, but only 0 present.');
4047 }
4048 // Do nothing if current environment doesn't have the Element interface.
4049 if (typeof Element === 'undefined' || !(Element instanceof Object)) {
4050 return;
4051 }
4052 if (!(target instanceof getWindowOf(target).Element)) {
4053 throw new TypeError('parameter 1 is not of type "Element".');
4054 }
4055 var observations = this.observations_;
4056 // Do nothing if element is not being observed.
4057 if (!observations.has(target)) {
4058 return;
4059 }
4060 observations.delete(target);
4061 if (!observations.size) {
4062 this.controller_.removeObserver(this);
4063 }
4064 };
4065 /**
4066 * Stops observing all elements.
4067 *
4068 * @returns {void}
4069 */
4070 ResizeObserverSPI.prototype.disconnect = function () {
4071 this.clearActive();
4072 this.observations_.clear();
4073 this.controller_.removeObserver(this);
4074 };
4075 /**
4076 * Collects observation instances the associated element of which has changed
4077 * it's content rectangle.
4078 *
4079 * @returns {void}
4080 */
4081 ResizeObserverSPI.prototype.gatherActive = function () {
4082 var _this = this;
4083 this.clearActive();
4084 this.observations_.forEach(function (observation) {
4085 if (observation.isActive()) {
4086 _this.activeObservations_.push(observation);
4087 }
4088 });
4089 };
4090 /**
4091 * Invokes initial callback function with a list of ResizeObserverEntry
4092 * instances collected from active resize observations.
4093 *
4094 * @returns {void}
4095 */
4096 ResizeObserverSPI.prototype.broadcastActive = function () {
4097 // Do nothing if observer doesn't have active observations.
4098 if (!this.hasActive()) {
4099 return;
4100 }
4101 var ctx = this.callbackCtx_;
4102 // Create ResizeObserverEntry instance for every active observation.
4103 var entries = this.activeObservations_.map(function (observation) {
4104 return new ResizeObserverEntry(observation.target, observation.broadcastRect());
4105 });
4106 this.callback_.call(ctx, entries, ctx);
4107 this.clearActive();
4108 };
4109 /**
4110 * Clears the collection of active observations.
4111 *
4112 * @returns {void}
4113 */
4114 ResizeObserverSPI.prototype.clearActive = function () {
4115 this.activeObservations_.splice(0);
4116 };
4117 /**
4118 * Tells whether observer has active observations.
4119 *
4120 * @returns {boolean}
4121 */
4122 ResizeObserverSPI.prototype.hasActive = function () {
4123 return this.activeObservations_.length > 0;
4124 };
4125 return ResizeObserverSPI;
4126 }());
4127
4128 // Registry of internal observers. If WeakMap is not available use current shim
4129 // for the Map collection as it has all required methods and because WeakMap
4130 // can't be fully polyfilled anyway.
4131 var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
4132 /**
4133 * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
4134 * exposing only those methods and properties that are defined in the spec.
4135 */
4136 var ResizeObserver = /** @class */ (function () {
4137 /**
4138 * Creates a new instance of ResizeObserver.
4139 *
4140 * @param {ResizeObserverCallback} callback - Callback that is invoked when
4141 * dimensions of the observed elements change.
4142 */
4143 function ResizeObserver(callback) {
4144 if (!(this instanceof ResizeObserver)) {
4145 throw new TypeError('Cannot call a class as a function.');
4146 }
4147 if (!arguments.length) {
4148 throw new TypeError('1 argument required, but only 0 present.');
4149 }
4150 var controller = ResizeObserverController.getInstance();
4151 var observer = new ResizeObserverSPI(callback, controller, this);
4152 observers.set(this, observer);
4153 }
4154 return ResizeObserver;
4155 }());
4156 // Expose public methods of ResizeObserver.
4157 [
4158 'observe',
4159 'unobserve',
4160 'disconnect'
4161 ].forEach(function (method) {
4162 ResizeObserver.prototype[method] = function () {
4163 var _a;
4164 return (_a = observers.get(this))[method].apply(_a, arguments);
4165 };
4166 });
4167
4168 var index = (function () {
4169 // Export existing implementation if available.
4170 if (typeof global$1.ResizeObserver !== 'undefined') {
4171 return global$1.ResizeObserver;
4172 }
4173 return ResizeObserver;
4174 })();
4175
4176 var cachedScrollbarWidth = null;
4177 var cachedDevicePixelRatio = null;
4178
4179 if (canUseDom) {
4180 window.addEventListener('resize', function () {
4181 if (cachedDevicePixelRatio !== window.devicePixelRatio) {
4182 cachedDevicePixelRatio = window.devicePixelRatio;
4183 cachedScrollbarWidth = null;
4184 }
4185 });
4186 }
4187
4188 function scrollbarWidth() {
4189 if (cachedScrollbarWidth === null) {
4190 if (typeof document === 'undefined') {
4191 cachedScrollbarWidth = 0;
4192 return cachedScrollbarWidth;
4193 }
4194
4195 var body = document.body;
4196 var box = document.createElement('div');
4197 box.classList.add('simplebar-hide-scrollbar');
4198 body.appendChild(box);
4199 var width = box.getBoundingClientRect().right;
4200 body.removeChild(box);
4201 cachedScrollbarWidth = width;
4202 }
4203
4204 return cachedScrollbarWidth;
4205 }
4206
4207 // `Array.prototype.{ reduce, reduceRight }` methods implementation
4208 var createMethod$4 = function (IS_RIGHT) {
4209 return function (that, callbackfn, argumentsLength, memo) {
4210 aFunction$1(callbackfn);
4211 var O = toObject(that);
4212 var self = indexedObject(O);
4213 var length = toLength(O.length);
4214 var index = IS_RIGHT ? length - 1 : 0;
4215 var i = IS_RIGHT ? -1 : 1;
4216 if (argumentsLength < 2) while (true) {
4217 if (index in self) {
4218 memo = self[index];
4219 index += i;
4220 break;
4221 }
4222 index += i;
4223 if (IS_RIGHT ? index < 0 : length <= index) {
4224 throw TypeError('Reduce of empty array with no initial value');
4225 }
4226 }
4227 for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
4228 memo = callbackfn(memo, self[index], index, O);
4229 }
4230 return memo;
4231 };
4232 };
4233
4234 var arrayReduce = {
4235 // `Array.prototype.reduce` method
4236 // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
4237 left: createMethod$4(false),
4238 // `Array.prototype.reduceRight` method
4239 // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
4240 right: createMethod$4(true)
4241 };
4242
4243 var $reduce = arrayReduce.left;
4244
4245
4246 // `Array.prototype.reduce` method
4247 // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
4248 _export({ target: 'Array', proto: true, forced: sloppyArrayMethod('reduce') }, {
4249 reduce: function reduce(callbackfn /* , initialValue */) {
4250 return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
4251 }
4252 });
4253
4254 var defineProperty$1 = objectDefineProperty.f;
4255
4256 var FunctionPrototype = Function.prototype;
4257 var FunctionPrototypeToString = FunctionPrototype.toString;
4258 var nameRE = /^\s*function ([^ (]*)/;
4259 var NAME = 'name';
4260
4261 // Function instances `.name` property
4262 // https://tc39.github.io/ecma262/#sec-function-instances-name
4263 if (descriptors && !(NAME in FunctionPrototype)) {
4264 defineProperty$1(FunctionPrototype, NAME, {
4265 configurable: true,
4266 get: function () {
4267 try {
4268 return FunctionPrototypeToString.call(this).match(nameRE)[1];
4269 } catch (error) {
4270 return '';
4271 }
4272 }
4273 });
4274 }
4275
4276 // `RegExp.prototype.flags` getter implementation
4277 // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
4278 var regexpFlags = function () {
4279 var that = anObject(this);
4280 var result = '';
4281 if (that.global) result += 'g';
4282 if (that.ignoreCase) result += 'i';
4283 if (that.multiline) result += 'm';
4284 if (that.dotAll) result += 's';
4285 if (that.unicode) result += 'u';
4286 if (that.sticky) result += 'y';
4287 return result;
4288 };
4289
4290 var nativeExec = RegExp.prototype.exec;
4291 // This always refers to the native implementation, because the
4292 // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
4293 // which loads this file before patching the method.
4294 var nativeReplace = String.prototype.replace;
4295
4296 var patchedExec = nativeExec;
4297
4298 var UPDATES_LAST_INDEX_WRONG = (function () {
4299 var re1 = /a/;
4300 var re2 = /b*/g;
4301 nativeExec.call(re1, 'a');
4302 nativeExec.call(re2, 'a');
4303 return re1.lastIndex !== 0 || re2.lastIndex !== 0;
4304 })();
4305
4306 // nonparticipating capturing group, copied from es5-shim's String#split patch.
4307 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
4308
4309 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
4310
4311 if (PATCH) {
4312 patchedExec = function exec(str) {
4313 var re = this;
4314 var lastIndex, reCopy, match, i;
4315
4316 if (NPCG_INCLUDED) {
4317 reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
4318 }
4319 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
4320
4321 match = nativeExec.call(re, str);
4322
4323 if (UPDATES_LAST_INDEX_WRONG && match) {
4324 re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
4325 }
4326 if (NPCG_INCLUDED && match && match.length > 1) {
4327 // Fix browsers whose `exec` methods don't consistently return `undefined`
4328 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
4329 nativeReplace.call(match[0], reCopy, function () {
4330 for (i = 1; i < arguments.length - 2; i++) {
4331 if (arguments[i] === undefined) match[i] = undefined;
4332 }
4333 });
4334 }
4335
4336 return match;
4337 };
4338 }
4339
4340 var regexpExec = patchedExec;
4341
4342 _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
4343 exec: regexpExec
4344 });
4345
4346 var SPECIES$2 = wellKnownSymbol('species');
4347
4348 var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
4349 // #replace needs built-in support for named groups.
4350 // #match works fine because it just return the exec results, even if it has
4351 // a "grops" property.
4352 var re = /./;
4353 re.exec = function () {
4354 var result = [];
4355 result.groups = { a: '7' };
4356 return result;
4357 };
4358 return ''.replace(re, '$<a>') !== '7';
4359 });
4360
4361 // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
4362 // Weex JS has frozen built-in prototypes, so use try / catch wrapper
4363 var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
4364 var re = /(?:)/;
4365 var originalExec = re.exec;
4366 re.exec = function () { return originalExec.apply(this, arguments); };
4367 var result = 'ab'.split(re);
4368 return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
4369 });
4370
4371 var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
4372 var SYMBOL = wellKnownSymbol(KEY);
4373
4374 var DELEGATES_TO_SYMBOL = !fails(function () {
4375 // String methods call symbol-named RegEp methods
4376 var O = {};
4377 O[SYMBOL] = function () { return 7; };
4378 return ''[KEY](O) != 7;
4379 });
4380
4381 var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
4382 // Symbol-named RegExp methods call .exec
4383 var execCalled = false;
4384 var re = /a/;
4385 re.exec = function () { execCalled = true; return null; };
4386
4387 if (KEY === 'split') {
4388 // RegExp[@@split] doesn't call the regex's exec method, but first creates
4389 // a new one. We need to return the patched regex when creating the new one.
4390 re.constructor = {};
4391 re.constructor[SPECIES$2] = function () { return re; };
4392 }
4393
4394 re[SYMBOL]('');
4395 return !execCalled;
4396 });
4397
4398 if (
4399 !DELEGATES_TO_SYMBOL ||
4400 !DELEGATES_TO_EXEC ||
4401 (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
4402 (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
4403 ) {
4404 var nativeRegExpMethod = /./[SYMBOL];
4405 var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
4406 if (regexp.exec === regexpExec) {
4407 if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
4408 // The native String method already delegates to @@method (this
4409 // polyfilled function), leasing to infinite recursion.
4410 // We avoid it by directly calling the native @@method method.
4411 return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
4412 }
4413 return { done: true, value: nativeMethod.call(str, regexp, arg2) };
4414 }
4415 return { done: false };
4416 });
4417 var stringMethod = methods[0];
4418 var regexMethod = methods[1];
4419
4420 redefine(String.prototype, KEY, stringMethod);
4421 redefine(RegExp.prototype, SYMBOL, length == 2
4422 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
4423 // 21.2.5.11 RegExp.prototype[@@split](string, limit)
4424 ? function (string, arg) { return regexMethod.call(string, this, arg); }
4425 // 21.2.5.6 RegExp.prototype[@@match](string)
4426 // 21.2.5.9 RegExp.prototype[@@search](string)
4427 : function (string) { return regexMethod.call(string, this); }
4428 );
4429 if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
4430 }
4431 };
4432
4433 var charAt$1 = stringMultibyte.charAt;
4434
4435 // `AdvanceStringIndex` abstract operation
4436 // https://tc39.github.io/ecma262/#sec-advancestringindex
4437 var advanceStringIndex = function (S, index, unicode) {
4438 return index + (unicode ? charAt$1(S, index).length : 1);
4439 };
4440
4441 // `RegExpExec` abstract operation
4442 // https://tc39.github.io/ecma262/#sec-regexpexec
4443 var regexpExecAbstract = function (R, S) {
4444 var exec = R.exec;
4445 if (typeof exec === 'function') {
4446 var result = exec.call(R, S);
4447 if (typeof result !== 'object') {
4448 throw TypeError('RegExp exec method returned something other than an Object or null');
4449 }
4450 return result;
4451 }
4452
4453 if (classofRaw(R) !== 'RegExp') {
4454 throw TypeError('RegExp#exec called on incompatible receiver');
4455 }
4456
4457 return regexpExec.call(R, S);
4458 };
4459
4460 // @@match logic
4461 fixRegexpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
4462 return [
4463 // `String.prototype.match` method
4464 // https://tc39.github.io/ecma262/#sec-string.prototype.match
4465 function match(regexp) {
4466 var O = requireObjectCoercible(this);
4467 var matcher = regexp == undefined ? undefined : regexp[MATCH];
4468 return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
4469 },
4470 // `RegExp.prototype[@@match]` method
4471 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
4472 function (regexp) {
4473 var res = maybeCallNative(nativeMatch, regexp, this);
4474 if (res.done) return res.value;
4475
4476 var rx = anObject(regexp);
4477 var S = String(this);
4478
4479 if (!rx.global) return regexpExecAbstract(rx, S);
4480
4481 var fullUnicode = rx.unicode;
4482 rx.lastIndex = 0;
4483 var A = [];
4484 var n = 0;
4485 var result;
4486 while ((result = regexpExecAbstract(rx, S)) !== null) {
4487 var matchStr = String(result[0]);
4488 A[n] = matchStr;
4489 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
4490 n++;
4491 }
4492 return n === 0 ? null : A;
4493 }
4494 ];
4495 });
4496
4497 var max$1 = Math.max;
4498 var min$2 = Math.min;
4499 var floor$1 = Math.floor;
4500 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g;
4501 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g;
4502
4503 var maybeToString = function (it) {
4504 return it === undefined ? it : String(it);
4505 };
4506
4507 // @@replace logic
4508 fixRegexpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative) {
4509 return [
4510 // `String.prototype.replace` method
4511 // https://tc39.github.io/ecma262/#sec-string.prototype.replace
4512 function replace(searchValue, replaceValue) {
4513 var O = requireObjectCoercible(this);
4514 var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
4515 return replacer !== undefined
4516 ? replacer.call(searchValue, O, replaceValue)
4517 : nativeReplace.call(String(O), searchValue, replaceValue);
4518 },
4519 // `RegExp.prototype[@@replace]` method
4520 // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
4521 function (regexp, replaceValue) {
4522 var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
4523 if (res.done) return res.value;
4524
4525 var rx = anObject(regexp);
4526 var S = String(this);
4527
4528 var functionalReplace = typeof replaceValue === 'function';
4529 if (!functionalReplace) replaceValue = String(replaceValue);
4530
4531 var global = rx.global;
4532 if (global) {
4533 var fullUnicode = rx.unicode;
4534 rx.lastIndex = 0;
4535 }
4536 var results = [];
4537 while (true) {
4538 var result = regexpExecAbstract(rx, S);
4539 if (result === null) break;
4540
4541 results.push(result);
4542 if (!global) break;
4543
4544 var matchStr = String(result[0]);
4545 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
4546 }
4547
4548 var accumulatedResult = '';
4549 var nextSourcePosition = 0;
4550 for (var i = 0; i < results.length; i++) {
4551 result = results[i];
4552
4553 var matched = String(result[0]);
4554 var position = max$1(min$2(toInteger(result.index), S.length), 0);
4555 var captures = [];
4556 // NOTE: This is equivalent to
4557 // captures = result.slice(1).map(maybeToString)
4558 // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
4559 // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
4560 // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
4561 for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
4562 var namedCaptures = result.groups;
4563 if (functionalReplace) {
4564 var replacerArgs = [matched].concat(captures, position, S);
4565 if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
4566 var replacement = String(replaceValue.apply(undefined, replacerArgs));
4567 } else {
4568 replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
4569 }
4570 if (position >= nextSourcePosition) {
4571 accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
4572 nextSourcePosition = position + matched.length;
4573 }
4574 }
4575 return accumulatedResult + S.slice(nextSourcePosition);
4576 }
4577 ];
4578
4579 // https://tc39.github.io/ecma262/#sec-getsubstitution
4580 function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
4581 var tailPos = position + matched.length;
4582 var m = captures.length;
4583 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
4584 if (namedCaptures !== undefined) {
4585 namedCaptures = toObject(namedCaptures);
4586 symbols = SUBSTITUTION_SYMBOLS;
4587 }
4588 return nativeReplace.call(replacement, symbols, function (match, ch) {
4589 var capture;
4590 switch (ch.charAt(0)) {
4591 case '$': return '$';
4592 case '&': return matched;
4593 case '`': return str.slice(0, position);
4594 case "'": return str.slice(tailPos);
4595 case '<':
4596 capture = namedCaptures[ch.slice(1, -1)];
4597 break;
4598 default: // \d\d?
4599 var n = +ch;
4600 if (n === 0) return match;
4601 if (n > m) {
4602 var f = floor$1(n / 10);
4603 if (f === 0) return match;
4604 if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
4605 return match;
4606 }
4607 capture = captures[n - 1];
4608 }
4609 return capture === undefined ? '' : capture;
4610 });
4611 }
4612 });
4613
4614 // Helper function to retrieve options from element attributes
4615 var getOptions = function getOptions(obj) {
4616 var options = Array.prototype.reduce.call(obj, function (acc, attribute) {
4617 var option = attribute.name.match(/data-simplebar-(.+)/);
4618
4619 if (option) {
4620 var key = option[1].replace(/\W+(.)/g, function (x, chr) {
4621 return chr.toUpperCase();
4622 });
4623
4624 switch (attribute.value) {
4625 case 'true':
4626 acc[key] = true;
4627 break;
4628
4629 case 'false':
4630 acc[key] = false;
4631 break;
4632
4633 case undefined:
4634 acc[key] = true;
4635 break;
4636
4637 default:
4638 acc[key] = attribute.value;
4639 }
4640 }
4641
4642 return acc;
4643 }, {});
4644 return options;
4645 };
4646 function getElementWindow(element) {
4647 if (!element || !element.ownerDocument || !element.ownerDocument.defaultView) {
4648 return window;
4649 }
4650
4651 return element.ownerDocument.defaultView;
4652 }
4653 function getElementDocument(element) {
4654 if (!element || !element.ownerDocument) {
4655 return document;
4656 }
4657
4658 return element.ownerDocument;
4659 }
4660
4661 var SimpleBar =
4662 /*#__PURE__*/
4663 function () {
4664 function SimpleBar(element, options) {
4665 var _this = this;
4666
4667 this.onScroll = function () {
4668 var elWindow = getElementWindow(_this.el);
4669
4670 if (!_this.scrollXTicking) {
4671 elWindow.requestAnimationFrame(_this.scrollX);
4672 _this.scrollXTicking = true;
4673 }
4674
4675 if (!_this.scrollYTicking) {
4676 elWindow.requestAnimationFrame(_this.scrollY);
4677 _this.scrollYTicking = true;
4678 }
4679 };
4680
4681 this.scrollX = function () {
4682 if (_this.axis.x.isOverflowing) {
4683 _this.showScrollbar('x');
4684
4685 _this.positionScrollbar('x');
4686 }
4687
4688 _this.scrollXTicking = false;
4689 };
4690
4691 this.scrollY = function () {
4692 if (_this.axis.y.isOverflowing) {
4693 _this.showScrollbar('y');
4694
4695 _this.positionScrollbar('y');
4696 }
4697
4698 _this.scrollYTicking = false;
4699 };
4700
4701 this.onMouseEnter = function () {
4702 _this.showScrollbar('x');
4703
4704 _this.showScrollbar('y');
4705 };
4706
4707 this.onMouseMove = function (e) {
4708 _this.mouseX = e.clientX;
4709 _this.mouseY = e.clientY;
4710
4711 if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
4712 _this.onMouseMoveForAxis('x');
4713 }
4714
4715 if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
4716 _this.onMouseMoveForAxis('y');
4717 }
4718 };
4719
4720 this.onMouseLeave = function () {
4721 _this.onMouseMove.cancel();
4722
4723 if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
4724 _this.onMouseLeaveForAxis('x');
4725 }
4726
4727 if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
4728 _this.onMouseLeaveForAxis('y');
4729 }
4730
4731 _this.mouseX = -1;
4732 _this.mouseY = -1;
4733 };
4734
4735 this.onWindowResize = function () {
4736 // Recalculate scrollbarWidth in case it's a zoom
4737 _this.scrollbarWidth = _this.getScrollbarWidth();
4738
4739 _this.hideNativeScrollbar();
4740 };
4741
4742 this.hideScrollbars = function () {
4743 _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
4744 _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
4745
4746 if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
4747 _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
4748
4749 _this.axis.y.isVisible = false;
4750 }
4751
4752 if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
4753 _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
4754
4755 _this.axis.x.isVisible = false;
4756 }
4757 };
4758
4759 this.onPointerEvent = function (e) {
4760 var isWithinTrackXBounds, isWithinTrackYBounds;
4761 _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
4762 _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
4763
4764 if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
4765 isWithinTrackXBounds = _this.isWithinBounds(_this.axis.x.track.rect);
4766 }
4767
4768 if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
4769 isWithinTrackYBounds = _this.isWithinBounds(_this.axis.y.track.rect);
4770 } // If any pointer event is called on the scrollbar
4771
4772
4773 if (isWithinTrackXBounds || isWithinTrackYBounds) {
4774 // Preventing the event's default action stops text being
4775 // selectable during the drag.
4776 e.preventDefault(); // Prevent event leaking
4777
4778 e.stopPropagation();
4779
4780 if (e.type === 'mousedown') {
4781 if (isWithinTrackXBounds) {
4782 _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
4783
4784 if (_this.isWithinBounds(_this.axis.x.scrollbar.rect)) {
4785 _this.onDragStart(e, 'x');
4786 } else {
4787 _this.onTrackClick(e, 'x');
4788 }
4789 }
4790
4791 if (isWithinTrackYBounds) {
4792 _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
4793
4794 if (_this.isWithinBounds(_this.axis.y.scrollbar.rect)) {
4795 _this.onDragStart(e, 'y');
4796 } else {
4797 _this.onTrackClick(e, 'y');
4798 }
4799 }
4800 }
4801 }
4802 };
4803
4804 this.drag = function (e) {
4805 var eventOffset;
4806 var track = _this.axis[_this.draggedAxis].track;
4807 var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
4808 var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
4809 var contentSize = _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollSizeAttr];
4810 var hostSize = parseInt(_this.elStyles[_this.axis[_this.draggedAxis].sizeAttr], 10);
4811 e.preventDefault();
4812 e.stopPropagation();
4813
4814 if (_this.draggedAxis === 'y') {
4815 eventOffset = e.pageY;
4816 } else {
4817 eventOffset = e.pageX;
4818 } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
4819
4820
4821 var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
4822
4823 var dragPerc = dragPos / (trackSize - scrollbar.size); // Scroll the content by the same percentage.
4824
4825 var scrollPos = dragPerc * (contentSize - hostSize); // Fix browsers inconsistency on RTL
4826
4827 if (_this.draggedAxis === 'x') {
4828 scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
4829 scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
4830 }
4831
4832 _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
4833 };
4834
4835 this.onEndDrag = function (e) {
4836 var elDocument = getElementDocument(_this.el);
4837 var elWindow = getElementWindow(_this.el);
4838 e.preventDefault();
4839 e.stopPropagation();
4840
4841 _this.el.classList.remove(_this.classNames.dragging);
4842
4843 elDocument.removeEventListener('mousemove', _this.drag, true);
4844 elDocument.removeEventListener('mouseup', _this.onEndDrag, true);
4845 _this.removePreventClickId = elWindow.setTimeout(function () {
4846 // Remove these asynchronously so we still suppress click events
4847 // generated simultaneously with mouseup.
4848 elDocument.removeEventListener('click', _this.preventClick, true);
4849 elDocument.removeEventListener('dblclick', _this.preventClick, true);
4850 _this.removePreventClickId = null;
4851 });
4852 };
4853
4854 this.preventClick = function (e) {
4855 e.preventDefault();
4856 e.stopPropagation();
4857 };
4858
4859 this.el = element;
4860 this.minScrollbarWidth = 20;
4861 this.options = Object.assign({}, SimpleBar.defaultOptions, {}, options);
4862 this.classNames = Object.assign({}, SimpleBar.defaultOptions.classNames, {}, this.options.classNames);
4863 this.axis = {
4864 x: {
4865 scrollOffsetAttr: 'scrollLeft',
4866 sizeAttr: 'width',
4867 scrollSizeAttr: 'scrollWidth',
4868 offsetSizeAttr: 'offsetWidth',
4869 offsetAttr: 'left',
4870 overflowAttr: 'overflowX',
4871 dragOffset: 0,
4872 isOverflowing: true,
4873 isVisible: false,
4874 forceVisible: false,
4875 track: {},
4876 scrollbar: {}
4877 },
4878 y: {
4879 scrollOffsetAttr: 'scrollTop',
4880 sizeAttr: 'height',
4881 scrollSizeAttr: 'scrollHeight',
4882 offsetSizeAttr: 'offsetHeight',
4883 offsetAttr: 'top',
4884 overflowAttr: 'overflowY',
4885 dragOffset: 0,
4886 isOverflowing: true,
4887 isVisible: false,
4888 forceVisible: false,
4889 track: {},
4890 scrollbar: {}
4891 }
4892 };
4893 this.removePreventClickId = null; // Don't re-instantiate over an existing one
4894
4895 if (SimpleBar.instances.has(this.el)) {
4896 return;
4897 }
4898
4899 this.recalculate = lodash_throttle(this.recalculate.bind(this), 64);
4900 this.onMouseMove = lodash_throttle(this.onMouseMove.bind(this), 64);
4901 this.hideScrollbars = lodash_debounce(this.hideScrollbars.bind(this), this.options.timeout);
4902 this.onWindowResize = lodash_debounce(this.onWindowResize.bind(this), 64, {
4903 leading: true
4904 });
4905 SimpleBar.getRtlHelpers = lodash_memoize(SimpleBar.getRtlHelpers);
4906 this.init();
4907 }
4908 /**
4909 * Static properties
4910 */
4911
4912 /**
4913 * Helper to fix browsers inconsistency on RTL:
4914 * - Firefox inverts the scrollbar initial position
4915 * - IE11 inverts both scrollbar position and scrolling offset
4916 * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
4917 */
4918
4919
4920 SimpleBar.getRtlHelpers = function getRtlHelpers() {
4921 var dummyDiv = document.createElement('div');
4922 dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
4923 var scrollbarDummyEl = dummyDiv.firstElementChild;
4924 document.body.appendChild(scrollbarDummyEl);
4925 var dummyContainerChild = scrollbarDummyEl.firstElementChild;
4926 scrollbarDummyEl.scrollLeft = 0;
4927 var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
4928 var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
4929 scrollbarDummyEl.scrollLeft = 999;
4930 var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
4931 return {
4932 // determines if the scrolling is responding with negative values
4933 isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
4934 // determines if the origin scrollbar position is inverted or not (positioned on left or right)
4935 isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
4936 };
4937 };
4938
4939 SimpleBar.getOffset = function getOffset(el) {
4940 var rect = el.getBoundingClientRect();
4941 var elDocument = getElementDocument(el);
4942 var elWindow = getElementWindow(el);
4943 return {
4944 top: rect.top + (elWindow.pageYOffset || elDocument.documentElement.scrollTop),
4945 left: rect.left + (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
4946 };
4947 };
4948
4949 var _proto = SimpleBar.prototype;
4950
4951 _proto.init = function init() {
4952 // Save a reference to the instance, so we know this DOM node has already been instancied
4953 SimpleBar.instances.set(this.el, this); // We stop here on server-side
4954
4955 if (canUseDom) {
4956 this.initDOM();
4957 this.scrollbarWidth = this.getScrollbarWidth();
4958 this.recalculate();
4959 this.initListeners();
4960 }
4961 };
4962
4963 _proto.initDOM = function initDOM() {
4964 var _this2 = this;
4965
4966 // make sure this element doesn't have the elements yet
4967 if (Array.prototype.filter.call(this.el.children, function (child) {
4968 return child.classList.contains(_this2.classNames.wrapper);
4969 }).length) {
4970 // assume that element has his DOM already initiated
4971 this.wrapperEl = this.el.querySelector("." + this.classNames.wrapper);
4972 this.contentWrapperEl = this.options.scrollableNode || this.el.querySelector("." + this.classNames.contentWrapper);
4973 this.contentEl = this.options.contentNode || this.el.querySelector("." + this.classNames.contentEl);
4974 this.offsetEl = this.el.querySelector("." + this.classNames.offset);
4975 this.maskEl = this.el.querySelector("." + this.classNames.mask);
4976 this.placeholderEl = this.findChild(this.wrapperEl, "." + this.classNames.placeholder);
4977 this.heightAutoObserverWrapperEl = this.el.querySelector("." + this.classNames.heightAutoObserverWrapperEl);
4978 this.heightAutoObserverEl = this.el.querySelector("." + this.classNames.heightAutoObserverEl);
4979 this.axis.x.track.el = this.findChild(this.el, "." + this.classNames.track + "." + this.classNames.horizontal);
4980 this.axis.y.track.el = this.findChild(this.el, "." + this.classNames.track + "." + this.classNames.vertical);
4981 } else {
4982 // Prepare DOM
4983 this.wrapperEl = document.createElement('div');
4984 this.contentWrapperEl = document.createElement('div');
4985 this.offsetEl = document.createElement('div');
4986 this.maskEl = document.createElement('div');
4987 this.contentEl = document.createElement('div');
4988 this.placeholderEl = document.createElement('div');
4989 this.heightAutoObserverWrapperEl = document.createElement('div');
4990 this.heightAutoObserverEl = document.createElement('div');
4991 this.wrapperEl.classList.add(this.classNames.wrapper);
4992 this.contentWrapperEl.classList.add(this.classNames.contentWrapper);
4993 this.offsetEl.classList.add(this.classNames.offset);
4994 this.maskEl.classList.add(this.classNames.mask);
4995 this.contentEl.classList.add(this.classNames.contentEl);
4996 this.placeholderEl.classList.add(this.classNames.placeholder);
4997 this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
4998 this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
4999
5000 while (this.el.firstChild) {
5001 this.contentEl.appendChild(this.el.firstChild);
5002 }
5003
5004 this.contentWrapperEl.appendChild(this.contentEl);
5005 this.offsetEl.appendChild(this.contentWrapperEl);
5006 this.maskEl.appendChild(this.offsetEl);
5007 this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
5008 this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
5009 this.wrapperEl.appendChild(this.maskEl);
5010 this.wrapperEl.appendChild(this.placeholderEl);
5011 this.el.appendChild(this.wrapperEl);
5012 }
5013
5014 if (!this.axis.x.track.el || !this.axis.y.track.el) {
5015 var track = document.createElement('div');
5016 var scrollbar = document.createElement('div');
5017 track.classList.add(this.classNames.track);
5018 scrollbar.classList.add(this.classNames.scrollbar);
5019 track.appendChild(scrollbar);
5020 this.axis.x.track.el = track.cloneNode(true);
5021 this.axis.x.track.el.classList.add(this.classNames.horizontal);
5022 this.axis.y.track.el = track.cloneNode(true);
5023 this.axis.y.track.el.classList.add(this.classNames.vertical);
5024 this.el.appendChild(this.axis.x.track.el);
5025 this.el.appendChild(this.axis.y.track.el);
5026 }
5027
5028 this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector("." + this.classNames.scrollbar);
5029 this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector("." + this.classNames.scrollbar);
5030
5031 if (!this.options.autoHide) {
5032 this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
5033 this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
5034 }
5035
5036 this.el.setAttribute('data-simplebar', 'init');
5037 };
5038
5039 _proto.initListeners = function initListeners() {
5040 var _this3 = this;
5041
5042 var elWindow = getElementWindow(this.el); // Event listeners
5043
5044 if (this.options.autoHide) {
5045 this.el.addEventListener('mouseenter', this.onMouseEnter);
5046 }
5047
5048 ['mousedown', 'click', 'dblclick'].forEach(function (e) {
5049 _this3.el.addEventListener(e, _this3.onPointerEvent, true);
5050 });
5051 ['touchstart', 'touchend', 'touchmove'].forEach(function (e) {
5052 _this3.el.addEventListener(e, _this3.onPointerEvent, {
5053 capture: true,
5054 passive: true
5055 });
5056 });
5057 this.el.addEventListener('mousemove', this.onMouseMove);
5058 this.el.addEventListener('mouseleave', this.onMouseLeave);
5059 this.contentWrapperEl.addEventListener('scroll', this.onScroll); // Browser zoom triggers a window resize
5060
5061 elWindow.addEventListener('resize', this.onWindowResize); // Hack for https://github.com/WICG/ResizeObserver/issues/38
5062
5063 var resizeObserverStarted = false;
5064 var resizeObserver = elWindow.ResizeObserver || index;
5065 this.resizeObserver = new resizeObserver(function () {
5066 if (!resizeObserverStarted) return;
5067
5068 _this3.recalculate();
5069 });
5070 this.resizeObserver.observe(this.el);
5071 this.resizeObserver.observe(this.contentEl);
5072 elWindow.requestAnimationFrame(function () {
5073 resizeObserverStarted = true;
5074 }); // This is required to detect horizontal scroll. Vertical scroll only needs the resizeObserver.
5075
5076 this.mutationObserver = new elWindow.MutationObserver(this.recalculate);
5077 this.mutationObserver.observe(this.contentEl, {
5078 childList: true,
5079 subtree: true,
5080 characterData: true
5081 });
5082 };
5083
5084 _proto.recalculate = function recalculate() {
5085 var elWindow = getElementWindow(this.el);
5086 this.elStyles = elWindow.getComputedStyle(this.el);
5087 this.isRtl = this.elStyles.direction === 'rtl';
5088 var contentElOffsetWidth = this.contentEl.offsetWidth;
5089 var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
5090 var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1 || contentElOffsetWidth > 0;
5091 var contentWrapperElOffsetWidth = this.contentWrapperEl.offsetWidth;
5092 var elOverflowX = this.elStyles.overflowX;
5093 var elOverflowY = this.elStyles.overflowY;
5094 this.contentEl.style.padding = this.elStyles.paddingTop + " " + this.elStyles.paddingRight + " " + this.elStyles.paddingBottom + " " + this.elStyles.paddingLeft;
5095 this.wrapperEl.style.margin = "-" + this.elStyles.paddingTop + " -" + this.elStyles.paddingRight + " -" + this.elStyles.paddingBottom + " -" + this.elStyles.paddingLeft;
5096 var contentElScrollHeight = this.contentEl.scrollHeight;
5097 var contentElScrollWidth = this.contentEl.scrollWidth;
5098 this.contentWrapperEl.style.height = isHeightAuto ? 'auto' : '100%'; // Determine placeholder size
5099
5100 this.placeholderEl.style.width = isWidthAuto ? (contentElOffsetWidth || contentElScrollWidth) + "px" : 'auto';
5101 this.placeholderEl.style.height = contentElScrollHeight + "px";
5102 var contentWrapperElOffsetHeight = this.contentWrapperEl.offsetHeight;
5103 this.axis.x.isOverflowing = contentElOffsetWidth !== 0 && contentElScrollWidth > contentElOffsetWidth;
5104 this.axis.y.isOverflowing = contentElScrollHeight > contentWrapperElOffsetHeight; // Set isOverflowing to false if user explicitely set hidden overflow
5105
5106 this.axis.x.isOverflowing = elOverflowX === 'hidden' ? false : this.axis.x.isOverflowing;
5107 this.axis.y.isOverflowing = elOverflowY === 'hidden' ? false : this.axis.y.isOverflowing;
5108 this.axis.x.forceVisible = this.options.forceVisible === 'x' || this.options.forceVisible === true;
5109 this.axis.y.forceVisible = this.options.forceVisible === 'y' || this.options.forceVisible === true;
5110 this.hideNativeScrollbar(); // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
5111
5112 var offsetForXScrollbar = this.axis.x.isOverflowing ? this.scrollbarWidth : 0;
5113 var offsetForYScrollbar = this.axis.y.isOverflowing ? this.scrollbarWidth : 0;
5114 this.axis.x.isOverflowing = this.axis.x.isOverflowing && contentElScrollWidth > contentWrapperElOffsetWidth - offsetForYScrollbar;
5115 this.axis.y.isOverflowing = this.axis.y.isOverflowing && contentElScrollHeight > contentWrapperElOffsetHeight - offsetForXScrollbar;
5116 this.axis.x.scrollbar.size = this.getScrollbarSize('x');
5117 this.axis.y.scrollbar.size = this.getScrollbarSize('y');
5118 this.axis.x.scrollbar.el.style.width = this.axis.x.scrollbar.size + "px";
5119 this.axis.y.scrollbar.el.style.height = this.axis.y.scrollbar.size + "px";
5120 this.positionScrollbar('x');
5121 this.positionScrollbar('y');
5122 this.toggleTrackVisibility('x');
5123 this.toggleTrackVisibility('y');
5124 }
5125 /**
5126 * Calculate scrollbar size
5127 */
5128 ;
5129
5130 _proto.getScrollbarSize = function getScrollbarSize(axis) {
5131 if (axis === void 0) {
5132 axis = 'y';
5133 }
5134
5135 if (!this.axis[axis].isOverflowing) {
5136 return 0;
5137 }
5138
5139 var contentSize = this.contentEl[this.axis[axis].scrollSizeAttr];
5140 var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
5141 var scrollbarSize;
5142 var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
5143
5144 scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
5145
5146 if (this.options.scrollbarMaxSize) {
5147 scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
5148 }
5149
5150 return scrollbarSize;
5151 };
5152
5153 _proto.positionScrollbar = function positionScrollbar(axis) {
5154 if (axis === void 0) {
5155 axis = 'y';
5156 }
5157
5158 if (!this.axis[axis].isOverflowing) {
5159 return;
5160 }
5161
5162 var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
5163 var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
5164 var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
5165 var scrollbar = this.axis[axis].scrollbar;
5166 var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
5167 scrollOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
5168 var scrollPourcent = scrollOffset / (contentSize - hostSize);
5169 var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
5170 handleOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
5171 scrollbar.el.style.transform = axis === 'x' ? "translate3d(" + handleOffset + "px, 0, 0)" : "translate3d(0, " + handleOffset + "px, 0)";
5172 };
5173
5174 _proto.toggleTrackVisibility = function toggleTrackVisibility(axis) {
5175 if (axis === void 0) {
5176 axis = 'y';
5177 }
5178
5179 var track = this.axis[axis].track.el;
5180 var scrollbar = this.axis[axis].scrollbar.el;
5181
5182 if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
5183 track.style.visibility = 'visible';
5184 this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'scroll';
5185 } else {
5186 track.style.visibility = 'hidden';
5187 this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'hidden';
5188 } // Even if forceVisible is enabled, scrollbar itself should be hidden
5189
5190
5191 if (this.axis[axis].isOverflowing) {
5192 scrollbar.style.display = 'block';
5193 } else {
5194 scrollbar.style.display = 'none';
5195 }
5196 };
5197
5198 _proto.hideNativeScrollbar = function hideNativeScrollbar() {
5199 this.offsetEl.style[this.isRtl ? 'left' : 'right'] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-" + this.scrollbarWidth + "px" : 0;
5200 this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-" + this.scrollbarWidth + "px" : 0;
5201 }
5202 /**
5203 * On scroll event handling
5204 */
5205 ;
5206
5207 _proto.onMouseMoveForAxis = function onMouseMoveForAxis(axis) {
5208 if (axis === void 0) {
5209 axis = 'y';
5210 }
5211
5212 this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
5213 this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
5214 var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
5215
5216 if (isWithinScrollbarBoundsX) {
5217 this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
5218 } else {
5219 this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
5220 }
5221
5222 if (this.isWithinBounds(this.axis[axis].track.rect)) {
5223 this.showScrollbar(axis);
5224 this.axis[axis].track.el.classList.add(this.classNames.hover);
5225 } else {
5226 this.axis[axis].track.el.classList.remove(this.classNames.hover);
5227 }
5228 };
5229
5230 _proto.onMouseLeaveForAxis = function onMouseLeaveForAxis(axis) {
5231 if (axis === void 0) {
5232 axis = 'y';
5233 }
5234
5235 this.axis[axis].track.el.classList.remove(this.classNames.hover);
5236 this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
5237 };
5238
5239 /**
5240 * Show scrollbar
5241 */
5242 _proto.showScrollbar = function showScrollbar(axis) {
5243 if (axis === void 0) {
5244 axis = 'y';
5245 }
5246
5247 var scrollbar = this.axis[axis].scrollbar.el;
5248
5249 if (!this.axis[axis].isVisible) {
5250 scrollbar.classList.add(this.classNames.visible);
5251 this.axis[axis].isVisible = true;
5252 }
5253
5254 if (this.options.autoHide) {
5255 this.hideScrollbars();
5256 }
5257 }
5258 /**
5259 * Hide Scrollbar
5260 */
5261 ;
5262
5263 /**
5264 * on scrollbar handle drag movement starts
5265 */
5266 _proto.onDragStart = function onDragStart(e, axis) {
5267 if (axis === void 0) {
5268 axis = 'y';
5269 }
5270
5271 var elDocument = getElementDocument(this.el);
5272 var elWindow = getElementWindow(this.el);
5273 var scrollbar = this.axis[axis].scrollbar; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
5274
5275 var eventOffset = axis === 'y' ? e.pageY : e.pageX;
5276 this.axis[axis].dragOffset = eventOffset - scrollbar.rect[this.axis[axis].offsetAttr];
5277 this.draggedAxis = axis;
5278 this.el.classList.add(this.classNames.dragging);
5279 elDocument.addEventListener('mousemove', this.drag, true);
5280 elDocument.addEventListener('mouseup', this.onEndDrag, true);
5281
5282 if (this.removePreventClickId === null) {
5283 elDocument.addEventListener('click', this.preventClick, true);
5284 elDocument.addEventListener('dblclick', this.preventClick, true);
5285 } else {
5286 elWindow.clearTimeout(this.removePreventClickId);
5287 this.removePreventClickId = null;
5288 }
5289 }
5290 /**
5291 * Drag scrollbar handle
5292 */
5293 ;
5294
5295 _proto.onTrackClick = function onTrackClick(e, axis) {
5296 var _this4 = this;
5297
5298 if (axis === void 0) {
5299 axis = 'y';
5300 }
5301
5302 if (!this.options.clickOnTrack) return;
5303 var elWindow = getElementWindow(this.el);
5304 this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
5305 var scrollbar = this.axis[axis].scrollbar;
5306 var scrollbarOffset = scrollbar.rect[this.axis[axis].offsetAttr];
5307 var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
5308 var scrolled = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
5309 var t = axis === 'y' ? this.mouseY - scrollbarOffset : this.mouseX - scrollbarOffset;
5310 var dir = t < 0 ? -1 : 1;
5311 var scrollSize = dir === -1 ? scrolled - hostSize : scrolled + hostSize;
5312 var speed = 40;
5313
5314 var scrollTo = function scrollTo() {
5315 if (dir === -1) {
5316 if (scrolled > scrollSize) {
5317 var _this4$contentWrapper;
5318
5319 scrolled -= speed;
5320
5321 _this4.contentWrapperEl.scrollTo((_this4$contentWrapper = {}, _this4$contentWrapper[_this4.axis[axis].offsetAttr] = scrolled, _this4$contentWrapper));
5322
5323 elWindow.requestAnimationFrame(scrollTo);
5324 }
5325 } else {
5326 if (scrolled < scrollSize) {
5327 var _this4$contentWrapper2;
5328
5329 scrolled += speed;
5330
5331 _this4.contentWrapperEl.scrollTo((_this4$contentWrapper2 = {}, _this4$contentWrapper2[_this4.axis[axis].offsetAttr] = scrolled, _this4$contentWrapper2));
5332
5333 elWindow.requestAnimationFrame(scrollTo);
5334 }
5335 }
5336 };
5337
5338 scrollTo();
5339 }
5340 /**
5341 * Getter for content element
5342 */
5343 ;
5344
5345 _proto.getContentElement = function getContentElement() {
5346 return this.contentEl;
5347 }
5348 /**
5349 * Getter for original scrolling element
5350 */
5351 ;
5352
5353 _proto.getScrollElement = function getScrollElement() {
5354 return this.contentWrapperEl;
5355 };
5356
5357 _proto.getScrollbarWidth = function getScrollbarWidth() {
5358 // Try/catch for FF 56 throwing on undefined computedStyles
5359 try {
5360 // Detect browsers supporting CSS scrollbar styling and do not calculate
5361 if (getComputedStyle(this.contentWrapperEl, '::-webkit-scrollbar').display === 'none' || 'scrollbarWidth' in document.documentElement.style || '-ms-overflow-style' in document.documentElement.style) {
5362 return 0;
5363 } else {
5364 return scrollbarWidth();
5365 }
5366 } catch (e) {
5367 return scrollbarWidth();
5368 }
5369 };
5370
5371 _proto.removeListeners = function removeListeners() {
5372 var _this5 = this;
5373
5374 var elWindow = getElementWindow(this.el); // Event listeners
5375
5376 if (this.options.autoHide) {
5377 this.el.removeEventListener('mouseenter', this.onMouseEnter);
5378 }
5379
5380 ['mousedown', 'click', 'dblclick'].forEach(function (e) {
5381 _this5.el.removeEventListener(e, _this5.onPointerEvent, true);
5382 });
5383 ['touchstart', 'touchend', 'touchmove'].forEach(function (e) {
5384 _this5.el.removeEventListener(e, _this5.onPointerEvent, {
5385 capture: true,
5386 passive: true
5387 });
5388 });
5389 this.el.removeEventListener('mousemove', this.onMouseMove);
5390 this.el.removeEventListener('mouseleave', this.onMouseLeave);
5391 this.contentWrapperEl.removeEventListener('scroll', this.onScroll);
5392 elWindow.removeEventListener('resize', this.onWindowResize);
5393 this.mutationObserver.disconnect();
5394 this.resizeObserver.disconnect(); // Cancel all debounced functions
5395
5396 this.recalculate.cancel();
5397 this.onMouseMove.cancel();
5398 this.hideScrollbars.cancel();
5399 this.onWindowResize.cancel();
5400 }
5401 /**
5402 * UnMount mutation observer and delete SimpleBar instance from DOM element
5403 */
5404 ;
5405
5406 _proto.unMount = function unMount() {
5407 this.removeListeners();
5408 SimpleBar.instances.delete(this.el);
5409 }
5410 /**
5411 * Check if mouse is within bounds
5412 */
5413 ;
5414
5415 _proto.isWithinBounds = function isWithinBounds(bbox) {
5416 return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
5417 }
5418 /**
5419 * Find element children matches query
5420 */
5421 ;
5422
5423 _proto.findChild = function findChild(el, query) {
5424 var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
5425 return Array.prototype.filter.call(el.children, function (child) {
5426 return matches.call(child, query);
5427 })[0];
5428 };
5429
5430 return SimpleBar;
5431 }();
5432
5433 SimpleBar.defaultOptions = {
5434 autoHide: true,
5435 forceVisible: false,
5436 clickOnTrack: true,
5437 classNames: {
5438 contentEl: 'simplebar-content',
5439 contentWrapper: 'simplebar-content-wrapper',
5440 offset: 'simplebar-offset',
5441 mask: 'simplebar-mask',
5442 wrapper: 'simplebar-wrapper',
5443 placeholder: 'simplebar-placeholder',
5444 scrollbar: 'simplebar-scrollbar',
5445 track: 'simplebar-track',
5446 heightAutoObserverWrapperEl: 'simplebar-height-auto-observer-wrapper',
5447 heightAutoObserverEl: 'simplebar-height-auto-observer',
5448 visible: 'simplebar-visible',
5449 horizontal: 'simplebar-horizontal',
5450 vertical: 'simplebar-vertical',
5451 hover: 'simplebar-hover',
5452 dragging: 'simplebar-dragging'
5453 },
5454 scrollbarMinSize: 25,
5455 scrollbarMaxSize: 0,
5456 timeout: 1000
5457 };
5458 SimpleBar.instances = new WeakMap();
5459
5460 SimpleBar.initDOMLoadedElements = function () {
5461 document.removeEventListener('DOMContentLoaded', this.initDOMLoadedElements);
5462 window.removeEventListener('load', this.initDOMLoadedElements);
5463 Array.prototype.forEach.call(document.querySelectorAll('[data-simplebar]'), function (el) {
5464 if (el.getAttribute('data-simplebar') !== 'init' && !SimpleBar.instances.has(el)) new SimpleBar(el, getOptions(el.attributes));
5465 });
5466 };
5467
5468 SimpleBar.removeObserver = function () {
5469 this.globalObserver.disconnect();
5470 };
5471
5472 SimpleBar.initHtmlApi = function () {
5473 this.initDOMLoadedElements = this.initDOMLoadedElements.bind(this); // MutationObserver is IE11+
5474
5475 if (typeof MutationObserver !== 'undefined') {
5476 // Mutation observer to observe dynamically added elements
5477 this.globalObserver = new MutationObserver(SimpleBar.handleMutations);
5478 this.globalObserver.observe(document, {
5479 childList: true,
5480 subtree: true
5481 });
5482 } // Taken from jQuery `ready` function
5483 // Instantiate elements already present on the page
5484
5485
5486 if (document.readyState === 'complete' || document.readyState !== 'loading' && !document.documentElement.doScroll) {
5487 // Handle it asynchronously to allow scripts the opportunity to delay init
5488 window.setTimeout(this.initDOMLoadedElements);
5489 } else {
5490 document.addEventListener('DOMContentLoaded', this.initDOMLoadedElements);
5491 window.addEventListener('load', this.initDOMLoadedElements);
5492 }
5493 };
5494
5495 SimpleBar.handleMutations = function (mutations) {
5496 mutations.forEach(function (mutation) {
5497 Array.prototype.forEach.call(mutation.addedNodes, function (addedNode) {
5498 if (addedNode.nodeType === 1) {
5499 if (addedNode.hasAttribute('data-simplebar')) {
5500 !SimpleBar.instances.has(addedNode) && new SimpleBar(addedNode, getOptions(addedNode.attributes));
5501 } else {
5502 Array.prototype.forEach.call(addedNode.querySelectorAll('[data-simplebar]'), function (el) {
5503 if (el.getAttribute('data-simplebar') !== 'init' && !SimpleBar.instances.has(el)) new SimpleBar(el, getOptions(el.attributes));
5504 });
5505 }
5506 }
5507 });
5508 Array.prototype.forEach.call(mutation.removedNodes, function (removedNode) {
5509 if (removedNode.nodeType === 1) {
5510 if (removedNode.hasAttribute('[data-simplebar="init"]')) {
5511 SimpleBar.instances.has(removedNode) && SimpleBar.instances.get(removedNode).unMount();
5512 } else {
5513 Array.prototype.forEach.call(removedNode.querySelectorAll('[data-simplebar="init"]'), function (el) {
5514 SimpleBar.instances.has(el) && SimpleBar.instances.get(el).unMount();
5515 });
5516 }
5517 }
5518 });
5519 });
5520 };
5521
5522 SimpleBar.getOptions = getOptions;
5523 /**
5524 * HTML API
5525 * Called only in a browser env.
5526 */
5527
5528 if (canUseDom) {
5529 SimpleBar.initHtmlApi();
5530 }
5531
5532 return SimpleBar;
5533
5534}));