UNPKG

29.9 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7require('./slicedToArray-0711941d.js');
8require('./unsupportedIterableToArray-68db1d3b.js');
9var React = require('react');
10var React__default = _interopDefault(React);
11require('./_commonjsHelpers-72d386ba.js');
12var index = require('./index-b0606964.js');
13var defineProperty$1 = require('./defineProperty-0921a47c.js');
14var toConsumableArray = require('./toConsumableArray-d8a4a2c3.js');
15var _styled = require('styled-components');
16var _styled__default = _interopDefault(_styled);
17var getPrototypeOf = require('./getPrototypeOf-2a661a20.js');
18require('./color.js');
19require('./components.js');
20require('./contains-component.js');
21var css = require('./css.js');
22var dayjs_min = require('./dayjs.min-e07657bf.js');
23var date = require('./date.js');
24require('./miscellaneous.js');
25require('./environment.js');
26require('./font.js');
27require('./math-f4029164.js');
28require('./characters.js');
29require('./format.js');
30require('./keycodes.js');
31require('./url.js');
32require('./web3.js');
33var constants = require('./constants.js');
34require('./breakpoints.js');
35require('./springs.js');
36var textStyles = require('./text-styles.js');
37require('./theme-dark.js');
38require('./theme-light.js');
39var Theme = require('./Theme.js');
40var _extends$1 = require('./extends-40571110.js');
41require('./objectWithoutProperties-35db8ab0.js');
42require('./index-ecc57c9f.js');
43var isObject = require('./isObject-ec755c87.js');
44require('./IconPropTypes-56de5759.js');
45require('./IconAddUser.js');
46require('./IconAlert.js');
47require('./IconAlignCenter.js');
48require('./IconAlignJustify.js');
49require('./IconAlignLeft.js');
50require('./IconAlignRight.js');
51require('./IconAragon.js');
52require('./IconArrowDown.js');
53require('./IconArrowLeft.js');
54require('./IconArrowRight.js');
55require('./IconArrowUp.js');
56require('./IconAtSign.js');
57require('./IconBlock.js');
58require('./IconBookmark.js');
59require('./IconCalendar.js');
60require('./IconCanvas.js');
61require('./IconCaution.js');
62require('./IconCenter.js');
63require('./IconChart.js');
64require('./IconChat.js');
65require('./IconCheck.js');
66require('./IconChip.js');
67require('./IconCircleCheck.js');
68require('./IconCircleMinus.js');
69require('./IconCirclePlus.js');
70var IconClock = require('./IconClock.js');
71require('./IconCloudDownload.js');
72require('./IconCloudUpload.js');
73require('./IconCoin.js');
74require('./IconConfiguration.js');
75require('./IconConnect.js');
76require('./IconConnection.js');
77require('./IconConsole.js');
78require('./IconCopy.js');
79require('./IconCross.js');
80require('./IconDashedSquare.js');
81require('./IconDown.js');
82require('./IconDownload.js');
83require('./IconEdit.js');
84require('./IconEllipsis.js');
85require('./IconEnter.js');
86require('./IconEthereum.js');
87require('./IconExternal.js');
88require('./IconFile.js');
89require('./IconFilter.js');
90require('./IconFlag.js');
91require('./IconFolder.js');
92require('./IconGraph2.js');
93require('./IconGraph.js');
94require('./IconGrid.js');
95require('./IconGroup.js');
96require('./IconHash.js');
97require('./IconHeart.js');
98require('./IconHide.js');
99require('./IconHome.js');
100require('./IconImage.js');
101require('./IconInfo.js');
102require('./IconLabel.js');
103require('./IconLayers.js');
104require('./IconLeft.js');
105require('./IconLink.js');
106require('./IconLocation.js');
107require('./IconLock.js');
108require('./IconMail.js');
109require('./IconMaximize.js');
110require('./IconMenu.js');
111require('./IconMinimize.js');
112require('./IconMinus.js');
113require('./IconMove.js');
114require('./IconNoPicture.js');
115require('./IconPicture.js');
116require('./IconPlus.js');
117require('./IconPower.js');
118require('./IconPrint.js');
119require('./IconProhibited.js');
120require('./IconQuestion.js');
121require('./IconRefresh.js');
122require('./IconRemoveUser.js');
123require('./IconRight.js');
124require('./IconRotateLeft.js');
125require('./IconRotateRight.js');
126require('./IconSearch.js');
127require('./IconSettings.js');
128require('./IconShare.js');
129require('./IconSquareMinus.js');
130require('./IconSquarePlus.js');
131require('./IconSquare.js');
132require('./IconStarFilled.js');
133require('./IconStar.js');
134require('./IconSwap.js');
135require('./IconTarget.js');
136require('./IconToken.js');
137require('./IconTrash.js');
138require('./IconUnlock.js');
139require('./IconUp.js');
140require('./IconUpload.js');
141require('./IconUser.js');
142require('./IconView.js');
143require('./IconVote.js');
144require('./IconWallet.js');
145require('./IconWarning.js');
146require('./IconWorld.js');
147require('./IconWrite.js');
148require('./IconZoomIn.js');
149require('./IconZoomOut.js');
150require('./getDisplayName-7ab6d318.js');
151var index$1$2 = require('./index-030bfca8.js');
152
153/** `Object#toString` result references. */
154var asyncTag = '[object AsyncFunction]',
155 funcTag = '[object Function]',
156 genTag = '[object GeneratorFunction]',
157 proxyTag = '[object Proxy]';
158
159/**
160 * Checks if `value` is classified as a `Function` object.
161 *
162 * @static
163 * @memberOf _
164 * @since 0.1.0
165 * @category Lang
166 * @param {*} value The value to check.
167 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
168 * @example
169 *
170 * _.isFunction(_);
171 * // => true
172 *
173 * _.isFunction(/abc/);
174 * // => false
175 */
176function isFunction(value) {
177 if (!isObject.isObject(value)) {
178 return false;
179 }
180 // The use of `Object#toString` avoids issues with the `typeof` operator
181 // in Safari 9 which returns 'object' for typed arrays and other constructors.
182 var tag = isObject.baseGetTag(value);
183 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
184}
185
186var isFunction_1 = isFunction;
187
188/** Used to detect overreaching core-js shims. */
189var coreJsData = isObject.root['__core-js_shared__'];
190
191var _coreJsData = coreJsData;
192
193/** Used to detect methods masquerading as native. */
194var maskSrcKey = (function() {
195 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
196 return uid ? ('Symbol(src)_1.' + uid) : '';
197}());
198
199/**
200 * Checks if `func` has its source masked.
201 *
202 * @private
203 * @param {Function} func The function to check.
204 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
205 */
206function isMasked(func) {
207 return !!maskSrcKey && (maskSrcKey in func);
208}
209
210var _isMasked = isMasked;
211
212/** Used for built-in method references. */
213var funcProto = Function.prototype;
214
215/** Used to resolve the decompiled source of functions. */
216var funcToString = funcProto.toString;
217
218/**
219 * Converts `func` to its source code.
220 *
221 * @private
222 * @param {Function} func The function to convert.
223 * @returns {string} Returns the source code.
224 */
225function toSource(func) {
226 if (func != null) {
227 try {
228 return funcToString.call(func);
229 } catch (e) {}
230 try {
231 return (func + '');
232 } catch (e) {}
233 }
234 return '';
235}
236
237var _toSource = toSource;
238
239/**
240 * Used to match `RegExp`
241 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
242 */
243var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
244
245/** Used to detect host constructors (Safari). */
246var reIsHostCtor = /^\[object .+?Constructor\]$/;
247
248/** Used for built-in method references. */
249var funcProto$1 = Function.prototype,
250 objectProto = Object.prototype;
251
252/** Used to resolve the decompiled source of functions. */
253var funcToString$1 = funcProto$1.toString;
254
255/** Used to check objects for own properties. */
256var hasOwnProperty = objectProto.hasOwnProperty;
257
258/** Used to detect if a method is native. */
259var reIsNative = RegExp('^' +
260 funcToString$1.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
261 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
262);
263
264/**
265 * The base implementation of `_.isNative` without bad shim checks.
266 *
267 * @private
268 * @param {*} value The value to check.
269 * @returns {boolean} Returns `true` if `value` is a native function,
270 * else `false`.
271 */
272function baseIsNative(value) {
273 if (!isObject.isObject(value) || _isMasked(value)) {
274 return false;
275 }
276 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
277 return pattern.test(_toSource(value));
278}
279
280var _baseIsNative = baseIsNative;
281
282/**
283 * Gets the value at `key` of `object`.
284 *
285 * @private
286 * @param {Object} [object] The object to query.
287 * @param {string} key The key of the property to get.
288 * @returns {*} Returns the property value.
289 */
290function getValue(object, key) {
291 return object == null ? undefined : object[key];
292}
293
294var _getValue = getValue;
295
296/**
297 * Gets the native function at `key` of `object`.
298 *
299 * @private
300 * @param {Object} object The object to query.
301 * @param {string} key The key of the method to get.
302 * @returns {*} Returns the function if it's native, else `undefined`.
303 */
304function getNative(object, key) {
305 var value = _getValue(object, key);
306 return _baseIsNative(value) ? value : undefined;
307}
308
309var _getNative = getNative;
310
311/* Built-in method references that are verified to be native. */
312var nativeCreate = _getNative(Object, 'create');
313
314var _nativeCreate = nativeCreate;
315
316/**
317 * Removes all key-value entries from the hash.
318 *
319 * @private
320 * @name clear
321 * @memberOf Hash
322 */
323function hashClear() {
324 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
325 this.size = 0;
326}
327
328var _hashClear = hashClear;
329
330/**
331 * Removes `key` and its value from the hash.
332 *
333 * @private
334 * @name delete
335 * @memberOf Hash
336 * @param {Object} hash The hash to modify.
337 * @param {string} key The key of the value to remove.
338 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
339 */
340function hashDelete(key) {
341 var result = this.has(key) && delete this.__data__[key];
342 this.size -= result ? 1 : 0;
343 return result;
344}
345
346var _hashDelete = hashDelete;
347
348/** Used to stand-in for `undefined` hash values. */
349var HASH_UNDEFINED = '__lodash_hash_undefined__';
350
351/** Used for built-in method references. */
352var objectProto$1 = Object.prototype;
353
354/** Used to check objects for own properties. */
355var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
356
357/**
358 * Gets the hash value for `key`.
359 *
360 * @private
361 * @name get
362 * @memberOf Hash
363 * @param {string} key The key of the value to get.
364 * @returns {*} Returns the entry value.
365 */
366function hashGet(key) {
367 var data = this.__data__;
368 if (_nativeCreate) {
369 var result = data[key];
370 return result === HASH_UNDEFINED ? undefined : result;
371 }
372 return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
373}
374
375var _hashGet = hashGet;
376
377/** Used for built-in method references. */
378var objectProto$2 = Object.prototype;
379
380/** Used to check objects for own properties. */
381var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
382
383/**
384 * Checks if a hash value for `key` exists.
385 *
386 * @private
387 * @name has
388 * @memberOf Hash
389 * @param {string} key The key of the entry to check.
390 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
391 */
392function hashHas(key) {
393 var data = this.__data__;
394 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$2.call(data, key);
395}
396
397var _hashHas = hashHas;
398
399/** Used to stand-in for `undefined` hash values. */
400var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
401
402/**
403 * Sets the hash `key` to `value`.
404 *
405 * @private
406 * @name set
407 * @memberOf Hash
408 * @param {string} key The key of the value to set.
409 * @param {*} value The value to set.
410 * @returns {Object} Returns the hash instance.
411 */
412function hashSet(key, value) {
413 var data = this.__data__;
414 this.size += this.has(key) ? 0 : 1;
415 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
416 return this;
417}
418
419var _hashSet = hashSet;
420
421/**
422 * Creates a hash object.
423 *
424 * @private
425 * @constructor
426 * @param {Array} [entries] The key-value pairs to cache.
427 */
428function Hash(entries) {
429 var index = -1,
430 length = entries == null ? 0 : entries.length;
431
432 this.clear();
433 while (++index < length) {
434 var entry = entries[index];
435 this.set(entry[0], entry[1]);
436 }
437}
438
439// Add methods to `Hash`.
440Hash.prototype.clear = _hashClear;
441Hash.prototype['delete'] = _hashDelete;
442Hash.prototype.get = _hashGet;
443Hash.prototype.has = _hashHas;
444Hash.prototype.set = _hashSet;
445
446var _Hash = Hash;
447
448/**
449 * Removes all key-value entries from the list cache.
450 *
451 * @private
452 * @name clear
453 * @memberOf ListCache
454 */
455function listCacheClear() {
456 this.__data__ = [];
457 this.size = 0;
458}
459
460var _listCacheClear = listCacheClear;
461
462/**
463 * Performs a
464 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
465 * comparison between two values to determine if they are equivalent.
466 *
467 * @static
468 * @memberOf _
469 * @since 4.0.0
470 * @category Lang
471 * @param {*} value The value to compare.
472 * @param {*} other The other value to compare.
473 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
474 * @example
475 *
476 * var object = { 'a': 1 };
477 * var other = { 'a': 1 };
478 *
479 * _.eq(object, object);
480 * // => true
481 *
482 * _.eq(object, other);
483 * // => false
484 *
485 * _.eq('a', 'a');
486 * // => true
487 *
488 * _.eq('a', Object('a'));
489 * // => false
490 *
491 * _.eq(NaN, NaN);
492 * // => true
493 */
494function eq(value, other) {
495 return value === other || (value !== value && other !== other);
496}
497
498var eq_1 = eq;
499
500/**
501 * Gets the index at which the `key` is found in `array` of key-value pairs.
502 *
503 * @private
504 * @param {Array} array The array to inspect.
505 * @param {*} key The key to search for.
506 * @returns {number} Returns the index of the matched value, else `-1`.
507 */
508function assocIndexOf(array, key) {
509 var length = array.length;
510 while (length--) {
511 if (eq_1(array[length][0], key)) {
512 return length;
513 }
514 }
515 return -1;
516}
517
518var _assocIndexOf = assocIndexOf;
519
520/** Used for built-in method references. */
521var arrayProto = Array.prototype;
522
523/** Built-in value references. */
524var splice = arrayProto.splice;
525
526/**
527 * Removes `key` and its value from the list cache.
528 *
529 * @private
530 * @name delete
531 * @memberOf ListCache
532 * @param {string} key The key of the value to remove.
533 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
534 */
535function listCacheDelete(key) {
536 var data = this.__data__,
537 index = _assocIndexOf(data, key);
538
539 if (index < 0) {
540 return false;
541 }
542 var lastIndex = data.length - 1;
543 if (index == lastIndex) {
544 data.pop();
545 } else {
546 splice.call(data, index, 1);
547 }
548 --this.size;
549 return true;
550}
551
552var _listCacheDelete = listCacheDelete;
553
554/**
555 * Gets the list cache value for `key`.
556 *
557 * @private
558 * @name get
559 * @memberOf ListCache
560 * @param {string} key The key of the value to get.
561 * @returns {*} Returns the entry value.
562 */
563function listCacheGet(key) {
564 var data = this.__data__,
565 index = _assocIndexOf(data, key);
566
567 return index < 0 ? undefined : data[index][1];
568}
569
570var _listCacheGet = listCacheGet;
571
572/**
573 * Checks if a list cache value for `key` exists.
574 *
575 * @private
576 * @name has
577 * @memberOf ListCache
578 * @param {string} key The key of the entry to check.
579 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
580 */
581function listCacheHas(key) {
582 return _assocIndexOf(this.__data__, key) > -1;
583}
584
585var _listCacheHas = listCacheHas;
586
587/**
588 * Sets the list cache `key` to `value`.
589 *
590 * @private
591 * @name set
592 * @memberOf ListCache
593 * @param {string} key The key of the value to set.
594 * @param {*} value The value to set.
595 * @returns {Object} Returns the list cache instance.
596 */
597function listCacheSet(key, value) {
598 var data = this.__data__,
599 index = _assocIndexOf(data, key);
600
601 if (index < 0) {
602 ++this.size;
603 data.push([key, value]);
604 } else {
605 data[index][1] = value;
606 }
607 return this;
608}
609
610var _listCacheSet = listCacheSet;
611
612/**
613 * Creates an list cache object.
614 *
615 * @private
616 * @constructor
617 * @param {Array} [entries] The key-value pairs to cache.
618 */
619function ListCache(entries) {
620 var index = -1,
621 length = entries == null ? 0 : entries.length;
622
623 this.clear();
624 while (++index < length) {
625 var entry = entries[index];
626 this.set(entry[0], entry[1]);
627 }
628}
629
630// Add methods to `ListCache`.
631ListCache.prototype.clear = _listCacheClear;
632ListCache.prototype['delete'] = _listCacheDelete;
633ListCache.prototype.get = _listCacheGet;
634ListCache.prototype.has = _listCacheHas;
635ListCache.prototype.set = _listCacheSet;
636
637var _ListCache = ListCache;
638
639/* Built-in method references that are verified to be native. */
640var Map = _getNative(isObject.root, 'Map');
641
642var _Map = Map;
643
644/**
645 * Removes all key-value entries from the map.
646 *
647 * @private
648 * @name clear
649 * @memberOf MapCache
650 */
651function mapCacheClear() {
652 this.size = 0;
653 this.__data__ = {
654 'hash': new _Hash,
655 'map': new (_Map || _ListCache),
656 'string': new _Hash
657 };
658}
659
660var _mapCacheClear = mapCacheClear;
661
662/**
663 * Checks if `value` is suitable for use as unique object key.
664 *
665 * @private
666 * @param {*} value The value to check.
667 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
668 */
669function isKeyable(value) {
670 var type = typeof value;
671 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
672 ? (value !== '__proto__')
673 : (value === null);
674}
675
676var _isKeyable = isKeyable;
677
678/**
679 * Gets the data for `map`.
680 *
681 * @private
682 * @param {Object} map The map to query.
683 * @param {string} key The reference key.
684 * @returns {*} Returns the map data.
685 */
686function getMapData(map, key) {
687 var data = map.__data__;
688 return _isKeyable(key)
689 ? data[typeof key == 'string' ? 'string' : 'hash']
690 : data.map;
691}
692
693var _getMapData = getMapData;
694
695/**
696 * Removes `key` and its value from the map.
697 *
698 * @private
699 * @name delete
700 * @memberOf MapCache
701 * @param {string} key The key of the value to remove.
702 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
703 */
704function mapCacheDelete(key) {
705 var result = _getMapData(this, key)['delete'](key);
706 this.size -= result ? 1 : 0;
707 return result;
708}
709
710var _mapCacheDelete = mapCacheDelete;
711
712/**
713 * Gets the map value for `key`.
714 *
715 * @private
716 * @name get
717 * @memberOf MapCache
718 * @param {string} key The key of the value to get.
719 * @returns {*} Returns the entry value.
720 */
721function mapCacheGet(key) {
722 return _getMapData(this, key).get(key);
723}
724
725var _mapCacheGet = mapCacheGet;
726
727/**
728 * Checks if a map value for `key` exists.
729 *
730 * @private
731 * @name has
732 * @memberOf MapCache
733 * @param {string} key The key of the entry to check.
734 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
735 */
736function mapCacheHas(key) {
737 return _getMapData(this, key).has(key);
738}
739
740var _mapCacheHas = mapCacheHas;
741
742/**
743 * Sets the map `key` to `value`.
744 *
745 * @private
746 * @name set
747 * @memberOf MapCache
748 * @param {string} key The key of the value to set.
749 * @param {*} value The value to set.
750 * @returns {Object} Returns the map cache instance.
751 */
752function mapCacheSet(key, value) {
753 var data = _getMapData(this, key),
754 size = data.size;
755
756 data.set(key, value);
757 this.size += data.size == size ? 0 : 1;
758 return this;
759}
760
761var _mapCacheSet = mapCacheSet;
762
763/**
764 * Creates a map cache object to store key-value pairs.
765 *
766 * @private
767 * @constructor
768 * @param {Array} [entries] The key-value pairs to cache.
769 */
770function MapCache(entries) {
771 var index = -1,
772 length = entries == null ? 0 : entries.length;
773
774 this.clear();
775 while (++index < length) {
776 var entry = entries[index];
777 this.set(entry[0], entry[1]);
778 }
779}
780
781// Add methods to `MapCache`.
782MapCache.prototype.clear = _mapCacheClear;
783MapCache.prototype['delete'] = _mapCacheDelete;
784MapCache.prototype.get = _mapCacheGet;
785MapCache.prototype.has = _mapCacheHas;
786MapCache.prototype.set = _mapCacheSet;
787
788var _MapCache = MapCache;
789
790/** Error message constants. */
791var FUNC_ERROR_TEXT = 'Expected a function';
792
793/**
794 * Creates a function that memoizes the result of `func`. If `resolver` is
795 * provided, it determines the cache key for storing the result based on the
796 * arguments provided to the memoized function. By default, the first argument
797 * provided to the memoized function is used as the map cache key. The `func`
798 * is invoked with the `this` binding of the memoized function.
799 *
800 * **Note:** The cache is exposed as the `cache` property on the memoized
801 * function. Its creation may be customized by replacing the `_.memoize.Cache`
802 * constructor with one whose instances implement the
803 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
804 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
805 *
806 * @static
807 * @memberOf _
808 * @since 0.1.0
809 * @category Function
810 * @param {Function} func The function to have its output memoized.
811 * @param {Function} [resolver] The function to resolve the cache key.
812 * @returns {Function} Returns the new memoized function.
813 * @example
814 *
815 * var object = { 'a': 1, 'b': 2 };
816 * var other = { 'c': 3, 'd': 4 };
817 *
818 * var values = _.memoize(_.values);
819 * values(object);
820 * // => [1, 2]
821 *
822 * values(other);
823 * // => [3, 4]
824 *
825 * object.a = 2;
826 * values(object);
827 * // => [1, 2]
828 *
829 * // Modify the result cache.
830 * values.cache.set(object, ['a', 'b']);
831 * values(object);
832 * // => ['a', 'b']
833 *
834 * // Replace `_.memoize.Cache`.
835 * _.memoize.Cache = WeakMap;
836 */
837function memoize(func, resolver) {
838 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
839 throw new TypeError(FUNC_ERROR_TEXT);
840 }
841 var memoized = function() {
842 var args = arguments,
843 key = resolver ? resolver.apply(this, args) : args[0],
844 cache = memoized.cache;
845
846 if (cache.has(key)) {
847 return cache.get(key);
848 }
849 var result = func.apply(this, args);
850 memoized.cache = cache.set(key, result) || cache;
851 return result;
852 };
853 memoized.cache = new (memoize.Cache || _MapCache);
854 return memoized;
855}
856
857// Expose `MapCache`.
858memoize.Cache = _MapCache;
859
860var memoize_1 = memoize;
861
862function _createSuper(Derived) { return function () { var Super = getPrototypeOf._getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf._getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return getPrototypeOf._possibleConstructorReturn(this, result); }; }
863
864function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
865var RENDER_EVERY = 1000;
866
867var formatUnit = function formatUnit(v) {
868 return String(v).padStart(2, '0');
869};
870
871var formats = {
872 yMdhms: 'yMdhms',
873 yMdhm: 'yMdhm',
874 yMdh: 'yMdh',
875 yMd: 'yMd',
876 yM: 'yM',
877 Mdhms: 'Mdhms',
878 Mdhm: 'Mdhm',
879 Mdh: 'Mdh',
880 Md: 'Md',
881 dhms: 'dhms',
882 dhm: 'dhm',
883 hms: 'hms',
884 hm: 'hm',
885 ms: 'ms',
886 m: 'm',
887 s: 's'
888};
889var unitNames = {
890 y: 'years',
891 M: 'months',
892 d: 'days',
893 h: 'hours',
894 m: 'minutes',
895 s: 'seconds'
896};
897var getFormat = memoize_1(function (format) {
898 return ['y', 'M', 'd', 'h', 'm', 's'].reduce(function (units, symbol) {
899 return formats[format].includes(symbol) ? [].concat(toConsumableArray._toConsumableArray(units), [unitNames[symbol]]) : units;
900 }, []);
901});
902
903function getTime(start, end, format, showEmpty, maxUnits) {
904 var date1 = end || new Date();
905 var date2 = end ? new Date() : start;
906 var totalInSeconds = dayjs_min.dayjs(date1).diff(date2, 'seconds');
907
908 var _difference = date.difference(date1, date2, {
909 keepLeadingZeros: showEmpty,
910 maxUnits: maxUnits,
911 units: getFormat(format)
912 }),
913 years = _difference.years,
914 months = _difference.months,
915 days = _difference.days,
916 hours = _difference.hours,
917 minutes = _difference.minutes,
918 seconds = _difference.seconds;
919
920 return {
921 units: [['Y', years], ['M', months], ['D', days], ['H', hours], ['M', minutes], ['S', seconds]],
922 totalInSeconds: totalInSeconds
923 };
924}
925
926var _StyledTime = _styled__default("time").withConfig({
927 displayName: "Timer___StyledTime",
928 componentId: "sc-58hkwl-0"
929})(["display:flex;align-items:center;white-space:nowrap;", ";", ";"], function (p) {
930 return p._css;
931}, function (p) {
932 return p._css2;
933});
934
935var _StyledSpan = _styled__default("span").withConfig({
936 displayName: "Timer___StyledSpan",
937 componentId: "sc-58hkwl-1"
938})(["display:flex;align-items:center;margin-right:", "px;margin-top:-3px;"], function (p) {
939 return p._css3;
940});
941
942var _StyledIconTime = _styled__default(IconClock.default).withConfig({
943 displayName: "Timer___StyledIconTime",
944 componentId: "sc-58hkwl-2"
945})(["color:", ";"], function (p) {
946 return p._css4;
947});
948
949var _StyledSpan2 = _styled__default("span").withConfig({
950 displayName: "Timer___StyledSpan2",
951 componentId: "sc-58hkwl-3"
952})(["", ";color:", ";"], function (p) {
953 return p._css5;
954}, function (p) {
955 return p._css6;
956});
957
958var _StyledSpan3 = _styled__default("span").withConfig({
959 displayName: "Timer___StyledSpan3",
960 componentId: "sc-58hkwl-4"
961})(["color:", ";", ";"], function (p) {
962 return p._css7;
963}, function (p) {
964 return p._css8;
965});
966
967var _StyledSpan4 = _styled__default("span").withConfig({
968 displayName: "Timer___StyledSpan4",
969 componentId: "sc-58hkwl-5"
970})(["margin-left:2px;color:", ";"], function (p) {
971 return p._css9;
972});
973
974var _StyledSpan5 = _styled__default("span").withConfig({
975 displayName: "Timer___StyledSpan5",
976 componentId: "sc-58hkwl-6"
977})(["margin:0 4px;color:", ";font-weight:400;"], function (p) {
978 return p._css10;
979});
980
981var Timer = /*#__PURE__*/function (_React$Component) {
982 getPrototypeOf._inherits(Timer, _React$Component);
983
984 var _super = _createSuper(Timer);
985
986 function Timer() {
987 var _this;
988
989 getPrototypeOf._classCallCheck(this, Timer);
990
991 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
992 args[_key] = arguments[_key];
993 }
994
995 _this = _super.call.apply(_super, [this].concat(args));
996
997 defineProperty$1._defineProperty(getPrototypeOf._assertThisInitialized(_this), "renderTime", function () {
998 var _this$props = _this.props,
999 start = _this$props.start,
1000 end = _this$props.end,
1001 theme = _this$props.theme,
1002 format = _this$props.format,
1003 showEmpty = _this$props.showEmpty,
1004 maxUnits = _this$props.maxUnits;
1005
1006 var _getTime = getTime(start, end, format, showEmpty, maxUnits),
1007 totalInSeconds = _getTime.totalInSeconds,
1008 units = _getTime.units;
1009
1010 if (totalInSeconds < 0 || Object.is(totalInSeconds, -0)) {
1011 return /*#__PURE__*/React__default.createElement(_StyledSpan2, {
1012 _css5: textStyles.textStyle('body2'),
1013 _css6: theme.surfaceContentSecondary
1014 }, end ? 'Time out' : '−');
1015 }
1016
1017 var lastUnitIndex = units.reduce(function (lastIndex, unit, index) {
1018 return unit[1] === null ? lastIndex : index;
1019 }, 0);
1020 return /*#__PURE__*/React__default.createElement("span", null, units.map(function (unit, index) {
1021 var isLast = index === lastUnitIndex;
1022 var isSeconds = index === units.length - 1; // Only time units (hours, minutes and seconds).
1023 // Remember to update if ms gets added one day!
1024
1025 var isTimeUnit = index >= units.length - 3;
1026
1027 if (unit[1] === null) {
1028 return null;
1029 }
1030
1031 return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
1032 key: index
1033 }, /*#__PURE__*/React__default.createElement(_StyledSpan3, {
1034 _css7: theme.surfaceContent,
1035 _css8: isSeconds && // Fix the width of the seconds unit so that
1036 // it doesn’t jump too much.
1037 "\n display: inline-flex;\n align-items: baseline;\n justify-content: space-between;\n min-width: 31px;\n "
1038 }, formatUnit(unit[1]), /*#__PURE__*/React__default.createElement(_StyledSpan4, {
1039 _css9: theme.surfaceContentSecondary
1040 }, unit[0])), !isLast &&
1041 /*#__PURE__*/
1042 // Separator
1043 React__default.createElement(_StyledSpan5, {
1044 _css10: theme.surfaceContentSecondary
1045 }, isTimeUnit && ':'));
1046 }));
1047 });
1048
1049 return _this;
1050 }
1051
1052 getPrototypeOf._createClass(Timer, [{
1053 key: "render",
1054 value: function render() {
1055 var _this$props2 = this.props,
1056 end = _this$props2.end,
1057 start = _this$props2.start,
1058 showIcon = _this$props2.showIcon,
1059 theme = _this$props2.theme;
1060 return /*#__PURE__*/React__default.createElement(_StyledTime, {
1061 dateTime: date.formatHtmlDatetime(end || start),
1062 _css: css.unselectable(),
1063 _css2: textStyles.textStyle('body2')
1064 }, showIcon && /*#__PURE__*/React__default.createElement(_StyledSpan, {
1065 _css3: 0.5 * constants.GU
1066 }, /*#__PURE__*/React__default.createElement(_StyledIconTime, {
1067 _css4: theme.surfaceIcon
1068 })), /*#__PURE__*/React__default.createElement(index$1$2.Redraw, {
1069 interval: RENDER_EVERY
1070 }, this.renderTime));
1071 }
1072 }]);
1073
1074 return Timer;
1075}(React__default.Component);
1076
1077defineProperty$1._defineProperty(Timer, "propTypes", {
1078 end: index.PropTypes.instanceOf(Date),
1079 format: index.PropTypes.oneOf(Object.keys(formats)),
1080 maxUnits: index.PropTypes.number,
1081 showEmpty: index.PropTypes.bool,
1082 showIcon: index.PropTypes.bool,
1083 start: index.PropTypes.instanceOf(Date),
1084 theme: index.PropTypes.object
1085});
1086
1087defineProperty$1._defineProperty(Timer, "defaultProps", {
1088 format: formats.yMdhms,
1089 maxUnits: -1,
1090 showEmpty: false,
1091 showIcon: true
1092});
1093
1094var Timer$1 = (function (props) {
1095 var theme = Theme.useTheme();
1096 return /*#__PURE__*/React__default.createElement(Timer, _extends$1._extends({}, props, {
1097 theme: theme
1098 }));
1099});
1100
1101exports.default = Timer$1;
1102//# sourceMappingURL=Timer.js.map