UNPKG

65.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');
12require('./index-b0606964.js');
13var defineProperty$1 = require('./defineProperty-0921a47c.js');
14require('./toConsumableArray-d8a4a2c3.js');
15var _styled = require('styled-components');
16var _styled__default = _interopDefault(_styled);
17require('./getPrototypeOf-2a661a20.js');
18require('./color.js');
19require('./components.js');
20require('./contains-component.js');
21require('./css.js');
22require('./dayjs.min-e07657bf.js');
23require('./date.js');
24require('./miscellaneous.js');
25var environment = require('./environment.js');
26require('./font.js');
27require('./math-f4029164.js');
28require('./characters.js');
29require('./format.js');
30require('./keycodes.js');
31require('./url.js');
32require('./web3.js');
33require('./constants.js');
34require('./breakpoints.js');
35var springs = require('./springs.js');
36require('./text-styles.js');
37require('./theme-dark.js');
38require('./theme-light.js');
39var Theme = require('./Theme.js');
40var objectWithoutPropertiesLoose = require('./objectWithoutPropertiesLoose-1af20ad0.js');
41require('react-dom');
42var proptypes = require('./proptypes-5b34673d.js');
43
44function _defineProperties(target, props) {
45 for (var i = 0; i < props.length; i++) {
46 var descriptor = props[i];
47 descriptor.enumerable = descriptor.enumerable || false;
48 descriptor.configurable = true;
49 if ("value" in descriptor) descriptor.writable = true;
50 Object.defineProperty(target, descriptor.key, descriptor);
51 }
52}
53
54function _createClass(Constructor, protoProps, staticProps) {
55 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
56 if (staticProps) _defineProperties(Constructor, staticProps);
57 return Constructor;
58}
59
60var applyAnimatedValues = undefined;
61var colorNames = [];
62var requestFrame = function requestFrame(cb) {
63 return typeof window !== 'undefined' && window.requestAnimationFrame(cb);
64};
65var interpolation = undefined;
66var now = function now() {
67 return Date.now();
68};
69var createAnimatedStyle = undefined;
70var injectApplyAnimatedValues = function injectApplyAnimatedValues(fn, transform) {
71 return applyAnimatedValues = {
72 fn: fn,
73 transform: transform
74 };
75};
76var injectColorNames = function injectColorNames(names) {
77 return colorNames = names;
78};
79var injectInterpolation = function injectInterpolation(cls) {
80 return interpolation = cls;
81};
82var injectCreateAnimatedStyle = function injectCreateAnimatedStyle(factory) {
83 return createAnimatedStyle = factory;
84};
85
86var Animated =
87/*#__PURE__*/
88function () {
89 function Animated() {}
90
91 var _proto = Animated.prototype;
92
93 _proto.attach = function attach() {};
94
95 _proto.detach = function detach() {};
96
97 _proto.getValue = function getValue() {};
98
99 _proto.getAnimatedValue = function getAnimatedValue() {
100 return this.getValue();
101 };
102
103 _proto.addChild = function addChild(child) {};
104
105 _proto.removeChild = function removeChild(child) {};
106
107 _proto.getChildren = function getChildren() {
108 return [];
109 };
110
111 return Animated;
112}();
113
114var getValues = function getValues(object) {
115 return Object.keys(object).map(function (k) {
116 return object[k];
117 });
118};
119
120var AnimatedWithChildren =
121/*#__PURE__*/
122function (_Animated) {
123 objectWithoutPropertiesLoose._inheritsLoose(AnimatedWithChildren, _Animated);
124
125 function AnimatedWithChildren() {
126 var _this;
127
128 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
129 args[_key] = arguments[_key];
130 }
131
132 _this = _Animated.call.apply(_Animated, [this].concat(args)) || this;
133 _this.children = [];
134
135 _this.getChildren = function () {
136 return _this.children;
137 };
138
139 _this.getPayload = function (index) {
140 if (index === void 0) {
141 index = undefined;
142 }
143
144 return index !== void 0 && _this.payload ? _this.payload[index] : _this.payload || objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this));
145 };
146
147 return _this;
148 }
149
150 var _proto = AnimatedWithChildren.prototype;
151
152 _proto.addChild = function addChild(child) {
153 if (this.children.length === 0) this.attach();
154 this.children.push(child);
155 };
156
157 _proto.removeChild = function removeChild(child) {
158 var index = this.children.indexOf(child);
159 this.children.splice(index, 1);
160 if (this.children.length === 0) this.detach();
161 };
162
163 return AnimatedWithChildren;
164}(Animated);
165var AnimatedArrayWithChildren =
166/*#__PURE__*/
167function (_AnimatedWithChildren) {
168 objectWithoutPropertiesLoose._inheritsLoose(AnimatedArrayWithChildren, _AnimatedWithChildren);
169
170 function AnimatedArrayWithChildren() {
171 var _this2;
172
173 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
174 args[_key2] = arguments[_key2];
175 }
176
177 _this2 = _AnimatedWithChildren.call.apply(_AnimatedWithChildren, [this].concat(args)) || this;
178 _this2.payload = [];
179
180 _this2.getAnimatedValue = function () {
181 return _this2.getValue();
182 };
183
184 _this2.attach = function () {
185 return _this2.payload.forEach(function (p) {
186 return p instanceof Animated && p.addChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this2)));
187 });
188 };
189
190 _this2.detach = function () {
191 return _this2.payload.forEach(function (p) {
192 return p instanceof Animated && p.removeChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this2)));
193 });
194 };
195
196 return _this2;
197 }
198
199 return AnimatedArrayWithChildren;
200}(AnimatedWithChildren);
201var AnimatedObjectWithChildren =
202/*#__PURE__*/
203function (_AnimatedWithChildren2) {
204 objectWithoutPropertiesLoose._inheritsLoose(AnimatedObjectWithChildren, _AnimatedWithChildren2);
205
206 function AnimatedObjectWithChildren() {
207 var _this3;
208
209 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
210 args[_key3] = arguments[_key3];
211 }
212
213 _this3 = _AnimatedWithChildren2.call.apply(_AnimatedWithChildren2, [this].concat(args)) || this;
214 _this3.payload = {};
215
216 _this3.getAnimatedValue = function () {
217 return _this3.getValue(true);
218 };
219
220 _this3.attach = function () {
221 return getValues(_this3.payload).forEach(function (s) {
222 return s instanceof Animated && s.addChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this3)));
223 });
224 };
225
226 _this3.detach = function () {
227 return getValues(_this3.payload).forEach(function (s) {
228 return s instanceof Animated && s.removeChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this3)));
229 });
230 };
231
232 return _this3;
233 }
234
235 var _proto2 = AnimatedObjectWithChildren.prototype;
236
237 _proto2.getValue = function getValue(animated) {
238 if (animated === void 0) {
239 animated = false;
240 }
241
242 var payload = {};
243
244 for (var key in this.payload) {
245 var value = this.payload[key];
246 if (animated && !(value instanceof Animated)) continue;
247 payload[key] = value instanceof Animated ? value[animated ? 'getAnimatedValue' : 'getValue']() : value;
248 }
249
250 return payload;
251 };
252
253 return AnimatedObjectWithChildren;
254}(AnimatedWithChildren);
255
256var AnimatedStyle =
257/*#__PURE__*/
258function (_AnimatedObjectWithCh) {
259 objectWithoutPropertiesLoose._inheritsLoose(AnimatedStyle, _AnimatedObjectWithCh);
260
261 function AnimatedStyle(style) {
262 var _this;
263
264 _this = _AnimatedObjectWithCh.call(this) || this;
265 style = style || {};
266 if (style.transform && !(style.transform instanceof Animated)) style = applyAnimatedValues.transform(style);
267 _this.payload = style;
268 return _this;
269 }
270
271 return AnimatedStyle;
272}(AnimatedObjectWithChildren);
273
274// http://www.w3.org/TR/css3-color/#svg-color
275var colors = {
276 transparent: 0x00000000,
277 aliceblue: 0xf0f8ffff,
278 antiquewhite: 0xfaebd7ff,
279 aqua: 0x00ffffff,
280 aquamarine: 0x7fffd4ff,
281 azure: 0xf0ffffff,
282 beige: 0xf5f5dcff,
283 bisque: 0xffe4c4ff,
284 black: 0x000000ff,
285 blanchedalmond: 0xffebcdff,
286 blue: 0x0000ffff,
287 blueviolet: 0x8a2be2ff,
288 brown: 0xa52a2aff,
289 burlywood: 0xdeb887ff,
290 burntsienna: 0xea7e5dff,
291 cadetblue: 0x5f9ea0ff,
292 chartreuse: 0x7fff00ff,
293 chocolate: 0xd2691eff,
294 coral: 0xff7f50ff,
295 cornflowerblue: 0x6495edff,
296 cornsilk: 0xfff8dcff,
297 crimson: 0xdc143cff,
298 cyan: 0x00ffffff,
299 darkblue: 0x00008bff,
300 darkcyan: 0x008b8bff,
301 darkgoldenrod: 0xb8860bff,
302 darkgray: 0xa9a9a9ff,
303 darkgreen: 0x006400ff,
304 darkgrey: 0xa9a9a9ff,
305 darkkhaki: 0xbdb76bff,
306 darkmagenta: 0x8b008bff,
307 darkolivegreen: 0x556b2fff,
308 darkorange: 0xff8c00ff,
309 darkorchid: 0x9932ccff,
310 darkred: 0x8b0000ff,
311 darksalmon: 0xe9967aff,
312 darkseagreen: 0x8fbc8fff,
313 darkslateblue: 0x483d8bff,
314 darkslategray: 0x2f4f4fff,
315 darkslategrey: 0x2f4f4fff,
316 darkturquoise: 0x00ced1ff,
317 darkviolet: 0x9400d3ff,
318 deeppink: 0xff1493ff,
319 deepskyblue: 0x00bfffff,
320 dimgray: 0x696969ff,
321 dimgrey: 0x696969ff,
322 dodgerblue: 0x1e90ffff,
323 firebrick: 0xb22222ff,
324 floralwhite: 0xfffaf0ff,
325 forestgreen: 0x228b22ff,
326 fuchsia: 0xff00ffff,
327 gainsboro: 0xdcdcdcff,
328 ghostwhite: 0xf8f8ffff,
329 gold: 0xffd700ff,
330 goldenrod: 0xdaa520ff,
331 gray: 0x808080ff,
332 green: 0x008000ff,
333 greenyellow: 0xadff2fff,
334 grey: 0x808080ff,
335 honeydew: 0xf0fff0ff,
336 hotpink: 0xff69b4ff,
337 indianred: 0xcd5c5cff,
338 indigo: 0x4b0082ff,
339 ivory: 0xfffff0ff,
340 khaki: 0xf0e68cff,
341 lavender: 0xe6e6faff,
342 lavenderblush: 0xfff0f5ff,
343 lawngreen: 0x7cfc00ff,
344 lemonchiffon: 0xfffacdff,
345 lightblue: 0xadd8e6ff,
346 lightcoral: 0xf08080ff,
347 lightcyan: 0xe0ffffff,
348 lightgoldenrodyellow: 0xfafad2ff,
349 lightgray: 0xd3d3d3ff,
350 lightgreen: 0x90ee90ff,
351 lightgrey: 0xd3d3d3ff,
352 lightpink: 0xffb6c1ff,
353 lightsalmon: 0xffa07aff,
354 lightseagreen: 0x20b2aaff,
355 lightskyblue: 0x87cefaff,
356 lightslategray: 0x778899ff,
357 lightslategrey: 0x778899ff,
358 lightsteelblue: 0xb0c4deff,
359 lightyellow: 0xffffe0ff,
360 lime: 0x00ff00ff,
361 limegreen: 0x32cd32ff,
362 linen: 0xfaf0e6ff,
363 magenta: 0xff00ffff,
364 maroon: 0x800000ff,
365 mediumaquamarine: 0x66cdaaff,
366 mediumblue: 0x0000cdff,
367 mediumorchid: 0xba55d3ff,
368 mediumpurple: 0x9370dbff,
369 mediumseagreen: 0x3cb371ff,
370 mediumslateblue: 0x7b68eeff,
371 mediumspringgreen: 0x00fa9aff,
372 mediumturquoise: 0x48d1ccff,
373 mediumvioletred: 0xc71585ff,
374 midnightblue: 0x191970ff,
375 mintcream: 0xf5fffaff,
376 mistyrose: 0xffe4e1ff,
377 moccasin: 0xffe4b5ff,
378 navajowhite: 0xffdeadff,
379 navy: 0x000080ff,
380 oldlace: 0xfdf5e6ff,
381 olive: 0x808000ff,
382 olivedrab: 0x6b8e23ff,
383 orange: 0xffa500ff,
384 orangered: 0xff4500ff,
385 orchid: 0xda70d6ff,
386 palegoldenrod: 0xeee8aaff,
387 palegreen: 0x98fb98ff,
388 paleturquoise: 0xafeeeeff,
389 palevioletred: 0xdb7093ff,
390 papayawhip: 0xffefd5ff,
391 peachpuff: 0xffdab9ff,
392 peru: 0xcd853fff,
393 pink: 0xffc0cbff,
394 plum: 0xdda0ddff,
395 powderblue: 0xb0e0e6ff,
396 purple: 0x800080ff,
397 rebeccapurple: 0x663399ff,
398 red: 0xff0000ff,
399 rosybrown: 0xbc8f8fff,
400 royalblue: 0x4169e1ff,
401 saddlebrown: 0x8b4513ff,
402 salmon: 0xfa8072ff,
403 sandybrown: 0xf4a460ff,
404 seagreen: 0x2e8b57ff,
405 seashell: 0xfff5eeff,
406 sienna: 0xa0522dff,
407 silver: 0xc0c0c0ff,
408 skyblue: 0x87ceebff,
409 slateblue: 0x6a5acdff,
410 slategray: 0x708090ff,
411 slategrey: 0x708090ff,
412 snow: 0xfffafaff,
413 springgreen: 0x00ff7fff,
414 steelblue: 0x4682b4ff,
415 tan: 0xd2b48cff,
416 teal: 0x008080ff,
417 thistle: 0xd8bfd8ff,
418 tomato: 0xff6347ff,
419 turquoise: 0x40e0d0ff,
420 violet: 0xee82eeff,
421 wheat: 0xf5deb3ff,
422 white: 0xffffffff,
423 whitesmoke: 0xf5f5f5ff,
424 yellow: 0xffff00ff,
425 yellowgreen: 0x9acd32ff
426};
427
428var Interpolation =
429/*#__PURE__*/
430function () {
431 function Interpolation() {}
432
433 // Default config = config, args
434 // Short config = range, output, extrapolate
435 Interpolation.create = function create(config, output, extra) {
436 if (typeof config === 'function') return config;else if (interpolation && config.output && typeof config.output[0] === 'string') return interpolation(config);else if (Array.isArray(config)) return Interpolation.create({
437 range: config,
438 output: output,
439 extrapolate: extra || 'extend'
440 });
441 var outputRange = config.output;
442 var inputRange = config.range || [0, 1];
443
444 var easing = config.easing || function (t) {
445 return t;
446 };
447
448 var extrapolateLeft = 'extend';
449 var map = config.map;
450 if (config.extrapolateLeft !== undefined) extrapolateLeft = config.extrapolateLeft;else if (config.extrapolate !== undefined) extrapolateLeft = config.extrapolate;
451 var extrapolateRight = 'extend';
452 if (config.extrapolateRight !== undefined) extrapolateRight = config.extrapolateRight;else if (config.extrapolate !== undefined) extrapolateRight = config.extrapolate;
453 return function (input) {
454 var range = findRange(input, inputRange);
455 return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, map);
456 };
457 };
458
459 return Interpolation;
460}();
461
462function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
463 var result = map ? map(input) : input; // Extrapolate
464
465 if (result < inputMin) {
466 if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin;
467 }
468
469 if (result > inputMax) {
470 if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax;
471 }
472
473 if (outputMin === outputMax) return outputMin;
474 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; // Input Range
475
476 if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin); // Easing
477
478 result = easing(result); // Output Range
479
480 if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin;
481 return result;
482}
483
484function findRange(input, inputRange) {
485 for (var i = 1; i < inputRange.length - 1; ++i) {
486 if (inputRange[i] >= input) break;
487 }
488
489 return i - 1;
490}
491
492// const INTEGER = '[-+]?\\d+';
493var NUMBER = '[-+]?\\d*\\.?\\d+';
494var PERCENTAGE = NUMBER + '%';
495
496function call() {
497 return '\\(\\s*(' + Array.prototype.slice.call(arguments).join(')\\s*,\\s*(') + ')\\s*\\)';
498}
499
500var rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
501var rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
502var hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
503var hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
504var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
505var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
506var hex6 = /^#([0-9a-fA-F]{6})$/;
507var hex8 = /^#([0-9a-fA-F]{8})$/;
508
509/*
510https://github.com/react-community/normalize-css-color
511
512BSD 3-Clause License
513
514Copyright (c) 2016, React Community
515All rights reserved.
516
517Redistribution and use in source and binary forms, with or without
518modification, are permitted provided that the following conditions are met:
519
520* Redistributions of source code must retain the above copyright notice, this
521 list of conditions and the following disclaimer.
522
523* Redistributions in binary form must reproduce the above copyright notice,
524 this list of conditions and the following disclaimer in the documentation
525 and/or other materials provided with the distribution.
526
527* Neither the name of the copyright holder nor the names of its
528 contributors may be used to endorse or promote products derived from
529 this software without specific prior written permission.
530
531THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
532AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
533IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
534DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
535FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
536DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
537SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
538CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
539OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
540OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
541*/
542function normalizeColor(color) {
543 var match;
544
545 if (typeof color === 'number') {
546 return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null;
547 } // Ordered based on occurrences on Facebook codebase
548
549
550 if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0;
551 if (colors.hasOwnProperty(color)) return colors[color];
552
553 if (match = rgb.exec(color)) {
554 return (parse255(match[1]) << 24 | // r
555 parse255(match[2]) << 16 | // g
556 parse255(match[3]) << 8 | // b
557 0x000000ff) >>> // a
558 0;
559 }
560
561 if (match = rgba.exec(color)) {
562 return (parse255(match[1]) << 24 | // r
563 parse255(match[2]) << 16 | // g
564 parse255(match[3]) << 8 | // b
565 parse1(match[4])) >>> // a
566 0;
567 }
568
569 if (match = hex3.exec(color)) {
570 return parseInt(match[1] + match[1] + // r
571 match[2] + match[2] + // g
572 match[3] + match[3] + // b
573 'ff', // a
574 16) >>> 0;
575 } // https://drafts.csswg.org/css-color-4/#hex-notation
576
577
578 if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0;
579
580 if (match = hex4.exec(color)) {
581 return parseInt(match[1] + match[1] + // r
582 match[2] + match[2] + // g
583 match[3] + match[3] + // b
584 match[4] + match[4], // a
585 16) >>> 0;
586 }
587
588 if (match = hsl.exec(color)) {
589 return (hslToRgb(parse360(match[1]), // h
590 parsePercentage(match[2]), // s
591 parsePercentage(match[3]) // l
592 ) | 0x000000ff) >>> // a
593 0;
594 }
595
596 if (match = hsla.exec(color)) {
597 return (hslToRgb(parse360(match[1]), // h
598 parsePercentage(match[2]), // s
599 parsePercentage(match[3]) // l
600 ) | parse1(match[4])) >>> // a
601 0;
602 }
603
604 return null;
605}
606
607function hue2rgb(p, q, t) {
608 if (t < 0) t += 1;
609 if (t > 1) t -= 1;
610 if (t < 1 / 6) return p + (q - p) * 6 * t;
611 if (t < 1 / 2) return q;
612 if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
613 return p;
614}
615
616function hslToRgb(h, s, l) {
617 var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
618 var p = 2 * l - q;
619 var r = hue2rgb(p, q, h + 1 / 3);
620 var g = hue2rgb(p, q, h);
621 var b = hue2rgb(p, q, h - 1 / 3);
622 return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
623}
624
625function parse255(str) {
626 var int = parseInt(str, 10);
627 if (int < 0) return 0;
628 if (int > 255) return 255;
629 return int;
630}
631
632function parse360(str) {
633 var int = parseFloat(str);
634 return (int % 360 + 360) % 360 / 360;
635}
636
637function parse1(str) {
638 var num = parseFloat(str);
639 if (num < 0) return 0;
640 if (num > 1) return 255;
641 return Math.round(num * 255);
642}
643
644function parsePercentage(str) {
645 // parseFloat conveniently ignores the final %
646 var int = parseFloat(str);
647 if (int < 0) return 0;
648 if (int > 100) return 1;
649 return int / 100;
650}
651
652function colorToRgba(input) {
653 var int32Color = normalizeColor(input);
654 if (int32Color === null) return input;
655 int32Color = int32Color || 0;
656 var r = (int32Color & 0xff000000) >>> 24;
657 var g = (int32Color & 0x00ff0000) >>> 16;
658 var b = (int32Color & 0x0000ff00) >>> 8;
659 var a = (int32Color & 0x000000ff) / 255;
660 return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
661} // Problem: https://github.com/animatedjs/animated/pull/102
662// Solution: https://stackoverflow.com/questions/638565/parsing-scientific-notation-sensibly/658662
663
664
665var stringShapeRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; // Covers rgb, rgba, hsl, hsla
666// Taken from https://gist.github.com/olmokramer/82ccce673f86db7cda5e
667
668var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; // Covers color names (transparent, blue, etc.)
669
670var colorNamesRegex = new RegExp("(" + Object.keys(colors).join('|') + ")", 'g');
671/**
672 * Supports string shapes by extracting numbers so new values can be computed,
673 * and recombines those values into new strings of the same shape. Supports
674 * things like:
675 *
676 * rgba(123, 42, 99, 0.36) // colors
677 * -45deg // values with units
678 * 0 2px 2px 0px rgba(0, 0, 0, 0.12) // box shadows
679 */
680
681function createInterpolation(config) {
682 // Replace colors with rgba
683 var outputRange = config.output.map(function (rangeValue) {
684 return rangeValue.replace(colorRegex, colorToRgba);
685 }).map(function (rangeValue) {
686 return rangeValue.replace(colorNamesRegex, colorToRgba);
687 }); // ->
688 // [
689 // [0, 50],
690 // [100, 150],
691 // [200, 250],
692 // [0, 0.5],
693 // ]
694
695 var outputRanges = outputRange[0].match(stringShapeRegex).map(function () {
696 return [];
697 });
698 outputRange.forEach(function (value) {
699 value.match(stringShapeRegex).forEach(function (number, i) {
700 return outputRanges[i].push(+number);
701 });
702 });
703 var interpolations = outputRange[0].match(stringShapeRegex).map(function (value, i) {
704 return Interpolation.create(objectWithoutPropertiesLoose._extends({}, config, {
705 output: outputRanges[i]
706 }));
707 });
708 return function (input) {
709 var i = 0;
710 return outputRange[0] // 'rgba(0, 100, 200, 0)'
711 // ->
712 // 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...'
713 .replace(stringShapeRegex, function () {
714 return interpolations[i++](input);
715 }) // rgba requires that the r,g,b are integers.... so we want to round them, but we *dont* want to
716 // round the opacity (4th column).
717 .replace(/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, function (_, p1, p2, p3, p4) {
718 return "rgba(" + Math.round(p1) + ", " + Math.round(p2) + ", " + Math.round(p3) + ", " + p4 + ")";
719 });
720 };
721}
722
723var AnimatedInterpolation =
724/*#__PURE__*/
725function (_AnimatedArrayWithChi) {
726 objectWithoutPropertiesLoose._inheritsLoose(AnimatedInterpolation, _AnimatedArrayWithChi);
727
728 function AnimatedInterpolation(parents, _config, _arg) {
729 var _this;
730
731 _this = _AnimatedArrayWithChi.call(this) || this;
732
733 _this.getValue = function () {
734 var _this2;
735
736 return (_this2 = _this).calc.apply(_this2, _this.payload.map(function (value) {
737 return value.getValue();
738 }));
739 };
740
741 _this.updateConfig = function (config, arg) {
742 return _this.calc = Interpolation.create(config, arg);
743 };
744
745 _this.interpolate = function (config, arg) {
746 return new AnimatedInterpolation(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), config, arg);
747 };
748
749 _this.payload = // AnimatedArrays should unfold, except AnimatedInterpolation which is taken as is
750 parents instanceof AnimatedArrayWithChildren && !parents.updateConfig ? parents.payload : Array.isArray(parents) ? parents : [parents];
751 _this.calc = Interpolation.create(_config, _arg);
752 return _this;
753 }
754
755 return AnimatedInterpolation;
756}(AnimatedArrayWithChildren);
757var interpolate$1 = function interpolate(parents, config, arg) {
758 return parents && new AnimatedInterpolation(parents, config, arg);
759};
760
761/**
762 * Animated works by building a directed acyclic graph of dependencies
763 * transparently when you render your Animated components.
764 *
765 * new Animated.Value(0)
766 * .interpolate() .interpolate() new Animated.Value(1)
767 * opacity translateY scale
768 * style transform
769 * View#234 style
770 * View#123
771 *
772 * A) Top Down phase
773 * When an Animated.Value is updated, we recursively go down through this
774 * graph in order to find leaf nodes: the views that we flag as needing
775 * an update.
776 *
777 * B) Bottom Up phase
778 * When a view is flagged as needing an update, we recursively go back up
779 * in order to build the new value that it needs. The reason why we need
780 * this two-phases process is to deal with composite props such as
781 * transform which can receive values from multiple parents.
782 */
783
784function findAnimatedStyles(node, styles) {
785 if (typeof node.update === 'function') styles.add(node);else node.getChildren().forEach(function (child) {
786 return findAnimatedStyles(child, styles);
787 });
788}
789/**
790 * Standard value for driving animations. One `Animated.Value` can drive
791 * multiple properties in a synchronized fashion, but can only be driven by one
792 * mechanism at a time. Using a new mechanism (e.g. starting a new animation,
793 * or calling `setValue`) will stop any previous ones.
794 */
795
796
797var AnimatedValue =
798/*#__PURE__*/
799function (_AnimatedWithChildren) {
800 objectWithoutPropertiesLoose._inheritsLoose(AnimatedValue, _AnimatedWithChildren);
801
802 function AnimatedValue(_value) {
803 var _this;
804
805 _this = _AnimatedWithChildren.call(this) || this;
806
807 _this.setValue = function (value, flush) {
808 if (flush === void 0) {
809 flush = true;
810 }
811
812 _this.value = value;
813 if (flush) _this.flush();
814 };
815
816 _this.getValue = function () {
817 return _this.value;
818 };
819
820 _this.updateStyles = function () {
821 return findAnimatedStyles(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), _this.animatedStyles);
822 };
823
824 _this.updateValue = function (value) {
825 return _this.flush(_this.value = value);
826 };
827
828 _this.interpolate = function (config, arg) {
829 return new AnimatedInterpolation(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), config, arg);
830 };
831
832 _this.value = _value;
833 _this.animatedStyles = new Set();
834 _this.done = false;
835 _this.startPosition = _value;
836 _this.lastPosition = _value;
837 _this.lastVelocity = undefined;
838 _this.lastTime = undefined;
839 _this.controller = undefined;
840 return _this;
841 }
842
843 var _proto = AnimatedValue.prototype;
844
845 _proto.flush = function flush() {
846 if (this.animatedStyles.size === 0) this.updateStyles();
847 this.animatedStyles.forEach(function (animatedStyle) {
848 return animatedStyle.update();
849 });
850 };
851
852 _proto.prepare = function prepare(controller) {
853 // Values stay loyal to their original controller, this is also a way to
854 // detect trailing values originating from a foreign controller
855 if (this.controller === undefined) this.controller = controller;
856
857 if (this.controller === controller) {
858 this.startPosition = this.value;
859 this.lastPosition = this.value;
860 this.lastVelocity = controller.isActive ? this.lastVelocity : undefined;
861 this.lastTime = controller.isActive ? this.lastTime : undefined;
862 this.done = false;
863 this.animatedStyles.clear();
864 }
865 };
866
867 return AnimatedValue;
868}(AnimatedWithChildren);
869
870var AnimatedArray =
871/*#__PURE__*/
872function (_AnimatedArrayWithChi) {
873 objectWithoutPropertiesLoose._inheritsLoose(AnimatedArray, _AnimatedArrayWithChi);
874
875 function AnimatedArray(array) {
876 var _this;
877
878 _this = _AnimatedArrayWithChi.call(this) || this;
879
880 _this.setValue = function (value, flush) {
881 if (flush === void 0) {
882 flush = true;
883 }
884
885 if (Array.isArray(value)) {
886 if (value.length === _this.payload.length) value.forEach(function (v, i) {
887 return _this.payload[i].setValue(v, flush);
888 });
889 } else _this.payload.forEach(function (v, i) {
890 return _this.payload[i].setValue(value, flush);
891 });
892 };
893
894 _this.getValue = function () {
895 return _this.payload.map(function (v) {
896 return v.getValue();
897 });
898 };
899
900 _this.interpolate = function (config, arg) {
901 return new AnimatedInterpolation(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), config, arg);
902 };
903
904 _this.payload = array.map(function (n) {
905 return new AnimatedValue(n);
906 });
907 return _this;
908 }
909
910 return AnimatedArray;
911}(AnimatedArrayWithChildren);
912
913function withDefault(value, defaultValue) {
914 return value === undefined || value === null ? defaultValue : value;
915}
916function toArray(a) {
917 return a !== void 0 ? Array.isArray(a) ? a : [a] : [];
918}
919function shallowEqual(a, b) {
920 if (typeof a !== typeof b) return false;
921 if (typeof a === 'string' || typeof a === 'number') return a === b;
922 var i;
923
924 for (i in a) {
925 if (!(i in b)) return false;
926 }
927
928 for (i in b) {
929 if (a[i] !== b[i]) return false;
930 }
931
932 return i === void 0 ? a === b : true;
933}
934function callProp(obj) {
935 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
936 args[_key - 1] = arguments[_key];
937 }
938
939 return typeof obj === 'function' ? obj.apply(void 0, args) : obj;
940}
941function getValues$1(object) {
942 return Object.keys(object).map(function (k) {
943 return object[k];
944 });
945}
946function getForwardProps(props) {
947 var to = props.to,
948 from = props.from,
949 config = props.config,
950 native = props.native,
951 onStart = props.onStart,
952 onRest = props.onRest,
953 onFrame = props.onFrame,
954 children = props.children,
955 reset = props.reset,
956 reverse = props.reverse,
957 force = props.force,
958 immediate = props.immediate,
959 impl = props.impl,
960 inject = props.inject,
961 delay = props.delay,
962 attach = props.attach,
963 destroyed = props.destroyed,
964 interpolateTo = props.interpolateTo,
965 autoStart = props.autoStart,
966 ref = props.ref,
967 forward = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(props, ["to", "from", "config", "native", "onStart", "onRest", "onFrame", "children", "reset", "reverse", "force", "immediate", "impl", "inject", "delay", "attach", "destroyed", "interpolateTo", "autoStart", "ref"]);
968
969 return forward;
970}
971function interpolateTo(props) {
972 var forward = getForwardProps(props);
973 var rest = Object.keys(props).reduce(function (a, k) {
974 var _extends2;
975
976 return forward[k] !== void 0 ? a : objectWithoutPropertiesLoose._extends({}, a, (_extends2 = {}, _extends2[k] = props[k], _extends2));
977 }, {});
978 return objectWithoutPropertiesLoose._extends({
979 to: forward
980 }, rest);
981}
982function handleRef(ref, forward) {
983 if (forward) {
984 // If it's a function, assume it's a ref callback
985 if (typeof forward === 'function') forward(ref);else if (typeof forward === 'object') {
986 // If it's an object and has a 'current' property, assume it's a ref object
987 forward.current = ref;
988 }
989 }
990
991 return ref;
992}
993
994var isUnitlessNumber = {
995 animationIterationCount: true,
996 borderImageOutset: true,
997 borderImageSlice: true,
998 borderImageWidth: true,
999 boxFlex: true,
1000 boxFlexGroup: true,
1001 boxOrdinalGroup: true,
1002 columnCount: true,
1003 columns: true,
1004 flex: true,
1005 flexGrow: true,
1006 flexPositive: true,
1007 flexShrink: true,
1008 flexNegative: true,
1009 flexOrder: true,
1010 gridRow: true,
1011 gridRowEnd: true,
1012 gridRowSpan: true,
1013 gridRowStart: true,
1014 gridColumn: true,
1015 gridColumnEnd: true,
1016 gridColumnSpan: true,
1017 gridColumnStart: true,
1018 fontWeight: true,
1019 lineClamp: true,
1020 lineHeight: true,
1021 opacity: true,
1022 order: true,
1023 orphans: true,
1024 tabSize: true,
1025 widows: true,
1026 zIndex: true,
1027 zoom: true,
1028 // SVG-related properties
1029 fillOpacity: true,
1030 floodOpacity: true,
1031 stopOpacity: true,
1032 strokeDasharray: true,
1033 strokeDashoffset: true,
1034 strokeMiterlimit: true,
1035 strokeOpacity: true,
1036 strokeWidth: true
1037};
1038
1039var prefixKey = function prefixKey(prefix, key) {
1040 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
1041};
1042
1043var prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
1044isUnitlessNumber = Object.keys(isUnitlessNumber).reduce(function (acc, prop) {
1045 prefixes.forEach(function (prefix) {
1046 return acc[prefixKey(prefix, prop)] = acc[prop];
1047 });
1048 return acc;
1049}, isUnitlessNumber);
1050
1051function dangerousStyleValue(name, value, isCustomProperty) {
1052 if (value == null || typeof value === 'boolean' || value === '') return '';
1053 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
1054
1055 return ('' + value).trim();
1056}
1057
1058var attributeCache = {};
1059injectCreateAnimatedStyle(function (style) {
1060 return new AnimatedStyle(style);
1061});
1062injectInterpolation(createInterpolation);
1063injectColorNames(colors);
1064injectApplyAnimatedValues(function (instance, props) {
1065 if (instance.nodeType && instance.setAttribute !== undefined) {
1066 var style = props.style,
1067 children = props.children,
1068 scrollTop = props.scrollTop,
1069 scrollLeft = props.scrollLeft,
1070 attributes = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(props, ["style", "children", "scrollTop", "scrollLeft"]);
1071
1072 if (scrollTop !== void 0) instance.scrollTop = scrollTop;
1073 if (scrollLeft !== void 0) instance.scrollLeft = scrollLeft; // Set textContent, if children is an animatable value
1074
1075 if (children !== void 0) instance.textContent = children; // Set styles ...
1076
1077 for (var styleName in style) {
1078 if (!style.hasOwnProperty(styleName)) continue;
1079 var isCustomProperty = styleName.indexOf('--') === 0;
1080 var styleValue = dangerousStyleValue(styleName, style[styleName], isCustomProperty);
1081 if (styleName === 'float') styleName = 'cssFloat';
1082 if (isCustomProperty) instance.style.setProperty(styleName, styleValue);else instance.style[styleName] = styleValue;
1083 } // Set attributes ...
1084
1085
1086 for (var name in attributes) {
1087 // Attributes are written in dash case
1088 var dashCase = attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, function (n) {
1089 return '-' + n.toLowerCase();
1090 }));
1091 if (typeof instance.getAttribute(dashCase) !== 'undefined') instance.setAttribute(dashCase, attributes[name]);
1092 }
1093 } else return false;
1094}, function (style) {
1095 return style;
1096});
1097
1098var AnimatedProps =
1099/*#__PURE__*/
1100function (_AnimatedObjectWithCh) {
1101 objectWithoutPropertiesLoose._inheritsLoose(AnimatedProps, _AnimatedObjectWithCh);
1102
1103 function AnimatedProps(props, callback) {
1104 var _this;
1105
1106 _this = _AnimatedObjectWithCh.call(this) || this;
1107 if (props.style) props = objectWithoutPropertiesLoose._extends({}, props, {
1108 style: createAnimatedStyle(props.style)
1109 });
1110 _this.payload = props;
1111 _this.update = callback;
1112
1113 _this.attach();
1114
1115 return _this;
1116 }
1117
1118 return AnimatedProps;
1119}(AnimatedObjectWithChildren);
1120
1121function createAnimatedComponent(Component) {
1122 var AnimatedComponent =
1123 /*#__PURE__*/
1124 function (_React$Component) {
1125 objectWithoutPropertiesLoose._inheritsLoose(AnimatedComponent, _React$Component);
1126
1127 function AnimatedComponent(props) {
1128 var _this;
1129
1130 _this = _React$Component.call(this) || this;
1131
1132 _this.callback = function () {
1133 if (_this.node) {
1134 var didUpdate = applyAnimatedValues.fn(_this.node, _this.propsAnimated.getAnimatedValue(), objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)));
1135 if (didUpdate === false) _this.forceUpdate();
1136 }
1137 };
1138
1139 _this.attachProps(props);
1140
1141 return _this;
1142 }
1143
1144 var _proto = AnimatedComponent.prototype;
1145
1146 _proto.componentWillUnmount = function componentWillUnmount() {
1147 this.propsAnimated && this.propsAnimated.detach();
1148 };
1149
1150 _proto.setNativeProps = function setNativeProps(props) {
1151 var didUpdate = applyAnimatedValues.fn(this.node, props, this);
1152 if (didUpdate === false) this.forceUpdate();
1153 } // The system is best designed when setNativeProps is implemented. It is
1154 // able to avoid re-rendering and directly set the attributes that
1155 // changed. However, setNativeProps can only be implemented on leaf
1156 // native components. If you want to animate a composite component, you
1157 // need to re-render it. In this case, we have a fallback that uses
1158 // forceUpdate.
1159 ;
1160
1161 _proto.attachProps = function attachProps(_ref) {
1162 var forwardRef = _ref.forwardRef,
1163 nextProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_ref, ["forwardRef"]);
1164
1165 var oldPropsAnimated = this.propsAnimated;
1166 this.propsAnimated = new AnimatedProps(nextProps, this.callback); // When you call detach, it removes the element from the parent list
1167 // of children. If it goes to 0, then the parent also detaches itself
1168 // and so on.
1169 // An optimization is to attach the new elements and THEN detach the old
1170 // ones instead of detaching and THEN attaching.
1171 // This way the intermediate state isn't to go to 0 and trigger
1172 // this expensive recursive detaching to then re-attach everything on
1173 // the very next operation.
1174
1175 oldPropsAnimated && oldPropsAnimated.detach();
1176 };
1177
1178 _proto.shouldComponentUpdate = function shouldComponentUpdate(props) {
1179 var style = props.style,
1180 nextProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(props, ["style"]);
1181
1182 var _this$props = this.props,
1183 currentStyle = _this$props.style,
1184 currentProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_this$props, ["style"]);
1185
1186 if (!shallowEqual(currentProps, nextProps) || !shallowEqual(currentStyle, style)) {
1187 this.attachProps(props);
1188 return true;
1189 }
1190
1191 return false;
1192 };
1193
1194 _proto.render = function render() {
1195 var _this2 = this;
1196
1197 var _this$propsAnimated$g = this.propsAnimated.getValue(),
1198 scrollTop = _this$propsAnimated$g.scrollTop,
1199 scrollLeft = _this$propsAnimated$g.scrollLeft,
1200 animatedProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_this$propsAnimated$g, ["scrollTop", "scrollLeft"]);
1201
1202 return React__default.createElement(Component, objectWithoutPropertiesLoose._extends({}, animatedProps, {
1203 ref: function ref(node) {
1204 return _this2.node = handleRef(node, _this2.props.forwardRef);
1205 }
1206 }));
1207 };
1208
1209 return AnimatedComponent;
1210 }(React__default.Component);
1211
1212 return React__default.forwardRef(function (props, ref) {
1213 return React__default.createElement(AnimatedComponent, objectWithoutPropertiesLoose._extends({}, props, {
1214 forwardRef: ref
1215 }));
1216 });
1217}
1218
1219var active = false;
1220var controllers = new Set();
1221
1222var frameLoop = function frameLoop() {
1223 var time = now();
1224
1225 for (var _iterator = controllers, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
1226 var _ref;
1227
1228 if (_isArray) {
1229 if (_i >= _iterator.length) break;
1230 _ref = _iterator[_i++];
1231 } else {
1232 _i = _iterator.next();
1233 if (_i.done) break;
1234 _ref = _i.value;
1235 }
1236
1237 var controller = _ref;
1238 var isDone = true;
1239 var noChange = true;
1240
1241 for (var configIdx = 0; configIdx < controller.configs.length; configIdx++) {
1242 var config = controller.configs[configIdx];
1243 var endOfAnimation = void 0,
1244 lastTime = void 0;
1245
1246 for (var valIdx = 0; valIdx < config.animatedValues.length; valIdx++) {
1247 var animation = config.animatedValues[valIdx]; // If an animation is done, skip, until all of them conclude
1248
1249 if (animation.done) continue;
1250 var from = config.fromValues[valIdx];
1251 var to = config.toValues[valIdx];
1252 var position = animation.lastPosition;
1253 var isAnimated = to instanceof Animated;
1254
1255 var _velocity = Array.isArray(config.initialVelocity) ? config.initialVelocity[valIdx] : config.initialVelocity;
1256
1257 if (isAnimated) to = to.getValue(); // Conclude animation if it's either immediate, or from-values match end-state
1258
1259 if (config.immediate || !isAnimated && !config.decay && from === to) {
1260 animation.updateValue(to);
1261 animation.done = true;
1262 continue;
1263 } // Doing delay here instead of setTimeout is one async worry less
1264
1265
1266 if (config.delay && time - controller.startTime < config.delay) {
1267 isDone = false;
1268 continue;
1269 } // Flag change
1270
1271
1272 noChange = false; // Break animation when string values are involved
1273
1274 if (typeof from === 'string' || typeof to === 'string') {
1275 animation.updateValue(to);
1276 animation.done = true;
1277 continue;
1278 }
1279
1280 if (config.duration !== void 0) {
1281 /** Duration easing */
1282 position = from + config.easing((time - controller.startTime - config.delay) / config.duration) * (to - from);
1283 endOfAnimation = time >= controller.startTime + config.delay + config.duration;
1284 } else if (config.decay) {
1285 /** Decay easing */
1286 position = from + _velocity / (1 - 0.998) * (1 - Math.exp(-(1 - 0.998) * (time - controller.startTime)));
1287 endOfAnimation = Math.abs(animation.lastPosition - position) < 0.1;
1288 if (endOfAnimation) to = position;
1289 } else {
1290 /** Spring easing */
1291 lastTime = animation.lastTime !== void 0 ? animation.lastTime : time;
1292 _velocity = animation.lastVelocity !== void 0 ? animation.lastVelocity : config.initialVelocity; // If we lost a lot of frames just jump to the end.
1293
1294 if (time > lastTime + 64) lastTime = time; // http://gafferongames.com/game-physics/fix-your-timestep/
1295
1296 var numSteps = Math.floor(time - lastTime);
1297
1298 for (var i = 0; i < numSteps; ++i) {
1299 var force = -config.tension * (position - to);
1300 var damping = -config.friction * _velocity;
1301 var acceleration = (force + damping) / config.mass;
1302 _velocity = _velocity + acceleration * 1 / 1000;
1303 position = position + _velocity * 1 / 1000;
1304 } // Conditions for stopping the spring animation
1305
1306
1307 var isOvershooting = config.clamp && config.tension !== 0 ? from < to ? position > to : position < to : false;
1308 var isVelocity = Math.abs(_velocity) <= config.precision;
1309 var isDisplacement = config.tension !== 0 ? Math.abs(to - position) <= config.precision : true;
1310 endOfAnimation = isOvershooting || isVelocity && isDisplacement;
1311 animation.lastVelocity = _velocity;
1312 animation.lastTime = time;
1313 } // Trails aren't done until their parents conclude
1314
1315
1316 if (isAnimated && !config.toValues[valIdx].done) endOfAnimation = false;
1317
1318 if (endOfAnimation) {
1319 // Ensure that we end up with a round value
1320 if (animation.value !== to) position = to;
1321 animation.done = true;
1322 } else isDone = false;
1323
1324 animation.updateValue(position);
1325 animation.lastPosition = position;
1326 } // Keep track of updated values only when necessary
1327
1328
1329 if (controller.props.onFrame || !controller.props.native) controller.animatedProps[config.name] = config.interpolation.getValue();
1330 } // Update callbacks in the end of the frame
1331
1332
1333 if (controller.props.onFrame || !controller.props.native) {
1334 if (!controller.props.native && controller.onUpdate) controller.onUpdate();
1335 if (controller.props.onFrame) controller.props.onFrame(controller.animatedProps);
1336 } // Either call onEnd or next frame
1337
1338
1339 if (isDone) {
1340 controllers.delete(controller);
1341 controller.debouncedOnEnd({
1342 finished: true,
1343 noChange: noChange
1344 });
1345 }
1346 } // Loop over as long as there are controllers ...
1347
1348
1349 if (controllers.size) requestFrame(frameLoop);else active = false;
1350};
1351
1352var addController = function addController(controller) {
1353 if (!controllers.has(controller)) {
1354 controllers.add(controller);
1355 if (!active) requestFrame(frameLoop);
1356 active = true;
1357 }
1358};
1359
1360var removeController = function removeController(controller) {
1361 if (controllers.has(controller)) {
1362 controllers.delete(controller);
1363 }
1364};
1365
1366var Controller =
1367/*#__PURE__*/
1368function () {
1369 function Controller(props, config) {
1370 var _this = this;
1371
1372 if (config === void 0) {
1373 config = {
1374 native: true,
1375 interpolateTo: true,
1376 autoStart: true
1377 };
1378 }
1379
1380 this.getValues = function () {
1381 return _this.props.native ? _this.interpolations : _this.animatedProps;
1382 };
1383
1384 this.dependents = new Set();
1385 this.isActive = false;
1386 this.hasChanged = false;
1387 this.props = {};
1388 this.merged = {};
1389 this.animations = {};
1390 this.interpolations = {};
1391 this.animatedProps = {};
1392 this.configs = [];
1393 this.frame = undefined;
1394 this.startTime = undefined;
1395 this.lastTime = undefined;
1396 this.update(objectWithoutPropertiesLoose._extends({}, props, config));
1397 }
1398
1399 var _proto = Controller.prototype;
1400
1401 _proto.update = function update(props) {
1402 var _this2 = this;
1403
1404 this.props = objectWithoutPropertiesLoose._extends({}, this.props, props);
1405
1406 var _ref = this.props.interpolateTo ? interpolateTo(this.props) : this.props,
1407 _ref$from = _ref.from,
1408 from = _ref$from === void 0 ? {} : _ref$from,
1409 _ref$to = _ref.to,
1410 to = _ref$to === void 0 ? {} : _ref$to,
1411 _ref$config = _ref.config,
1412 config = _ref$config === void 0 ? {} : _ref$config,
1413 _ref$delay = _ref.delay,
1414 delay = _ref$delay === void 0 ? 0 : _ref$delay,
1415 reverse = _ref.reverse,
1416 attach = _ref.attach,
1417 reset = _ref.reset,
1418 immediate = _ref.immediate,
1419 autoStart = _ref.autoStart,
1420 ref = _ref.ref; // Reverse values when requested
1421
1422
1423 if (reverse) {
1424 var _ref2 = [to, from];
1425 from = _ref2[0];
1426 to = _ref2[1];
1427 }
1428
1429 this.hasChanged = false; // Attachment handling, trailed springs can "attach" themselves to a previous spring
1430
1431 var target = attach && attach(this); // Reset merged props when necessary
1432
1433 var extra = reset ? {} : this.merged; // This will collect all props that were ever set
1434
1435 this.merged = objectWithoutPropertiesLoose._extends({}, from, extra, to); // Reduces input { name: value } pairs into animated values
1436
1437 this.animations = Object.entries(this.merged).reduce(function (acc, _ref3, i) {
1438 var name = _ref3[0],
1439 value = _ref3[1];
1440 // Issue cached entries, except on reset
1441 var entry = !reset && acc[name] || {}; // Figure out what the value is supposed to be
1442
1443 var isNumber = typeof value === 'number';
1444 var isString = typeof value === 'string' && !value.startsWith('#') && !/\d/.test(value) && !colorNames[value];
1445 var isArray = !isNumber && !isString && Array.isArray(value);
1446 var fromValue = from[name] !== undefined ? from[name] : value;
1447 var toValue = isNumber || isArray ? value : isString ? value : 1;
1448 var toConfig = callProp(config, name);
1449 if (target) toValue = target.animations[name].parent; // Detect changes, animated values will be checked in the raf-loop
1450
1451 if (toConfig.decay !== void 0 || !shallowEqual(entry.changes, value)) {
1452 var _extends2;
1453
1454 _this2.hasChanged = true;
1455 var parent, interpolation$$1;
1456 if (isNumber || isString) parent = interpolation$$1 = entry.parent || new AnimatedValue(fromValue);else if (isArray) parent = interpolation$$1 = entry.parent || new AnimatedArray(fromValue);else {
1457 var prev = entry.interpolation && entry.interpolation.calc(entry.parent.value);
1458
1459 if (entry.parent) {
1460 parent = entry.parent;
1461 parent.setValue(0, false);
1462 } else parent = new AnimatedValue(0);
1463
1464 var range = {
1465 output: [prev !== void 0 ? prev : fromValue, value]
1466 };
1467
1468 if (entry.interpolation) {
1469 interpolation$$1 = entry.interpolation;
1470 entry.interpolation.updateConfig(range);
1471 } else interpolation$$1 = parent.interpolate(range);
1472 } // Set immediate values
1473
1474 if (callProp(immediate, name)) parent.setValue(value, false); // Reset animated values
1475
1476 var animatedValues = toArray(parent.getPayload());
1477 animatedValues.forEach(function (value) {
1478 return value.prepare(_this2);
1479 });
1480 return objectWithoutPropertiesLoose._extends({}, acc, (_extends2 = {}, _extends2[name] = objectWithoutPropertiesLoose._extends({}, entry, {
1481 name: name,
1482 parent: parent,
1483 interpolation: interpolation$$1,
1484 animatedValues: animatedValues,
1485 changes: value,
1486 fromValues: toArray(parent.getValue()),
1487 toValues: toArray(target ? toValue.getPayload() : toValue),
1488 immediate: callProp(immediate, name),
1489 delay: withDefault(toConfig.delay, delay || 0),
1490 initialVelocity: withDefault(toConfig.velocity, 0),
1491 clamp: withDefault(toConfig.clamp, false),
1492 precision: withDefault(toConfig.precision, 0.01),
1493 tension: withDefault(toConfig.tension, 170),
1494 friction: withDefault(toConfig.friction, 26),
1495 mass: withDefault(toConfig.mass, 1),
1496 duration: toConfig.duration,
1497 easing: withDefault(toConfig.easing, function (t) {
1498 return t;
1499 }),
1500 decay: toConfig.decay
1501 }), _extends2));
1502 } else return acc;
1503 }, this.animations);
1504
1505 if (this.hasChanged) {
1506 this.configs = getValues$1(this.animations);
1507 this.animatedProps = {};
1508 this.interpolations = {};
1509
1510 for (var key in this.animations) {
1511 this.interpolations[key] = this.animations[key].interpolation;
1512 this.animatedProps[key] = this.animations[key].interpolation.getValue();
1513 }
1514 } // TODO: clean up ref in controller
1515
1516
1517 for (var _len = arguments.length, start = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1518 start[_key - 1] = arguments[_key];
1519 }
1520
1521 if (!ref && (autoStart || start.length)) this.start.apply(this, start);
1522 var onEnd = start[0],
1523 onUpdate = start[1];
1524 this.onEnd = typeof onEnd === 'function' && onEnd;
1525 this.onUpdate = onUpdate;
1526 return this.getValues();
1527 };
1528
1529 _proto.start = function start(onEnd, onUpdate) {
1530 var _this3 = this;
1531
1532 this.startTime = now();
1533 if (this.isActive) this.stop();
1534 this.isActive = true;
1535 this.onEnd = typeof onEnd === 'function' && onEnd;
1536 this.onUpdate = onUpdate;
1537 if (this.props.onStart) this.props.onStart();
1538 addController(this);
1539 return new Promise(function (res) {
1540 return _this3.resolve = res;
1541 });
1542 };
1543
1544 _proto.stop = function stop(finished) {
1545 if (finished === void 0) {
1546 finished = false;
1547 }
1548
1549 // Reset collected changes since the animation has been stopped cold turkey
1550 if (finished) getValues$1(this.animations).forEach(function (a) {
1551 return a.changes = undefined;
1552 });
1553 this.debouncedOnEnd({
1554 finished: finished
1555 });
1556 };
1557
1558 _proto.destroy = function destroy() {
1559 removeController(this);
1560 this.props = {};
1561 this.merged = {};
1562 this.animations = {};
1563 this.interpolations = {};
1564 this.animatedProps = {};
1565 this.configs = [];
1566 };
1567
1568 _proto.debouncedOnEnd = function debouncedOnEnd(result) {
1569 removeController(this);
1570 this.isActive = false;
1571 var onEnd = this.onEnd;
1572 this.onEnd = null;
1573 if (onEnd) onEnd(result);
1574 if (this.resolve) this.resolve();
1575 this.resolve = null;
1576 };
1577
1578 return Controller;
1579}();
1580
1581var KeyframeController =
1582/*#__PURE__*/
1583function () {
1584 function KeyframeController(_props) {
1585 var _this = this;
1586
1587 this.frameId = 0;
1588
1589 this.next = function (props, localFrameId, last, index) {
1590 if (last === void 0) {
1591 last = true;
1592 }
1593
1594 if (index === void 0) {
1595 index = 0;
1596 }
1597
1598 // this.last = last
1599 // this.running = true
1600 // config passed to props can overwrite global config passed in
1601 // controller instantiation i.e. globalConfig
1602 var config = props.config ? props.config : Array.isArray(_this.globalConfig) ? _this.globalConfig[index] : _this.globalConfig;
1603 _this.onFrameRest = props.onRest;
1604 return new Promise(function (resolve) {
1605 // if ref is passed to internal controller, then it ignore onEnd call back
1606 _this.instance.update(objectWithoutPropertiesLoose._extends({}, _this.globalProps, props, {
1607 config: config
1608 }), _this.onEnd(_this.onFrameRest, localFrameId, last, resolve)); // start needs to be called here if ref is present to activate the anim
1609
1610
1611 if (_this.ref) {
1612 _this.instance.start(_this.onEnd(_this.onFrameRest, localFrameId, last, resolve));
1613 } // hacky solution to force the parent to be updated any time
1614 // the child controller is reset
1615
1616
1617 _this.instance.props.reset && _this.instance.props.native && _this.parentForceUpdate && requestFrame(_this.parentForceUpdate);
1618 });
1619 };
1620
1621 this.start = function (onEnd) {
1622 _this.globalOnEnd = onEnd;
1623
1624 if (_this.currSlots) {
1625 var _ret = function () {
1626 var localFrameId = ++_this.frameId;
1627
1628 if (Array.isArray(_this.currSlots)) {
1629 var q = Promise.resolve();
1630
1631 var _loop = function _loop(i) {
1632 var index = i;
1633 var slot = _this.currSlots[index];
1634 var last = index === _this.currSlots.length - 1;
1635 q = q.then(function () {
1636 return localFrameId === _this.frameId && _this.next(slot, localFrameId, last, index);
1637 });
1638 };
1639
1640 for (var i = 0; i < _this.currSlots.length; i++) {
1641 _loop(i);
1642 }
1643 } else if (typeof _this.currSlots === 'function') {
1644 var index = 0;
1645
1646 _this.currSlots( // next
1647 function (props, last) {
1648 if (last === void 0) {
1649 last = false;
1650 }
1651
1652 return localFrameId === _this.frameId && _this.next(props, localFrameId, last, index++);
1653 }, // cancel
1654 function () {
1655 return requestFrame(function () {
1656 return _this.instance.isActive && _this.instance.stop(true);
1657 });
1658 });
1659 } else _this.next(_this.currSlots, localFrameId);
1660
1661 _this.prevSlots = _this.currSlots;
1662 return {
1663 v: new Promise(function (resolve) {
1664 return _this.keyFrameEndResolver = resolve;
1665 })
1666 };
1667 }();
1668
1669 if (typeof _ret === "object") return _ret.v;
1670 }
1671 };
1672
1673 this.stop = function (finished) {
1674 if (finished === void 0) {
1675 finished = false;
1676 }
1677
1678 ++_this.frameId;
1679 if (_this.instance.isActive) _this.instance.stop(finished);
1680 };
1681
1682 this.onEnd = function (onFrameRest, localFrameId, last, resolve) {
1683 return function (args) {
1684 if (localFrameId === _this.frameId) {
1685 if (resolve) resolve();
1686 if (onFrameRest) onFrameRest(_this.merged);
1687 if (last && _this.globalOnEnd) _this.globalOnEnd(args);
1688 if (last && _this.keyFrameEndResolver) _this.keyFrameEndResolver();
1689
1690 if (args.finished && last && _this.globalOnRest) {
1691 _this.globalOnRest(_this.merged);
1692 }
1693 }
1694 };
1695 };
1696
1697 this.updateWithForceUpdate = function (forceUpdate) {
1698 // needed to forceUpdate when the controller is reset
1699 // for native controllers
1700 _this.parentForceUpdate = forceUpdate;
1701
1702 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1703 args[_key - 1] = arguments[_key];
1704 }
1705
1706 _this.update.apply(_this, args);
1707 };
1708
1709 this.update = function (args) {
1710 var isFnOrArray = typeof args === 'function' || Array.isArray(args);
1711
1712 if (isFnOrArray) {
1713 _this.currSlots = args;
1714 !_this.ref && _this.start();
1715 } else {
1716 var slots = args.slots,
1717 rest = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(args, ["slots"]);
1718
1719 _this.currSlots = slots;
1720 !_this.ref && _this.start.apply(_this, rest);
1721 }
1722 };
1723
1724 this.getValues = function () {
1725 return _this.instance.getValues();
1726 };
1727
1728 this.destroy = function () {
1729 return _this.instance.destroy();
1730 };
1731
1732 var _config = _props.config,
1733 onRest = _props.onRest,
1734 initialProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_props, ["config", "onRest"]);
1735
1736 this.globalProps = function (_ref) {
1737 var native = _ref.native,
1738 onStart = _ref.onStart,
1739 onFrame = _ref.onFrame,
1740 children = _ref.children,
1741 reset = _ref.reset,
1742 delay = _ref.delay,
1743 destroyed = _ref.destroyed;
1744 return {
1745 native: native,
1746 onStart: onStart,
1747 reset: reset,
1748 onFrame: onFrame,
1749 children: children,
1750 delay: delay,
1751 destroyed: destroyed
1752 };
1753 }(_props);
1754
1755 this.globalConfig = _props.config;
1756 this.globalOnRest = _props.onRest;
1757 this.ref = _props.ref;
1758 this.prevSlots = {};
1759 this.currSlots = null;
1760 this.instance = new Controller(objectWithoutPropertiesLoose._extends({}, initialProps, {
1761 native: true
1762 }));
1763 }
1764
1765 _createClass(KeyframeController, [{
1766 key: "isActive",
1767 get: function get() {
1768 return this.instance.isActive;
1769 }
1770 }, {
1771 key: "config",
1772 set: function set(config) {
1773 this.globalConfig = config;
1774 }
1775 }, {
1776 key: "globals",
1777 set: function set(props) {
1778 this.globalProps = objectWithoutPropertiesLoose._extends({}, this.globalProps, props);
1779 }
1780 }, {
1781 key: "merged",
1782 get: function get() {
1783 return this.instance.merged;
1784 }
1785 }, {
1786 key: "props",
1787 get: function get() {
1788 return this.instance.props;
1789 }
1790 }]);
1791
1792 return KeyframeController;
1793}();
1794
1795var useSpringImpl = function useSpringImpl(type) {
1796 if (type === void 0) {
1797 type = 'default';
1798 }
1799
1800 return function (args) {
1801 var _useState = React.useState(),
1802 f = _useState[1];
1803
1804 var forceUpdate = function forceUpdate() {
1805 return f(function (v) {
1806 return !v;
1807 });
1808 }; // Extract animation props and hook-specific props, can be a function or an obj
1809
1810
1811 var isFn = typeof args === 'function';
1812
1813 var _callProp = callProp(args),
1814 onRest = _callProp.onRest,
1815 onKeyframesHalt = _callProp.onKeyframesHalt,
1816 props = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_callProp, ["onRest", "onKeyframesHalt"]); // The controller maintains the animation values, starts and tops animations
1817
1818
1819 var _useState2 = React.useState(function () {
1820 return type === 'keyframe' ? new KeyframeController(props) : new Controller(props);
1821 }),
1822 ctrl = _useState2[0]; // Destroy controller on unmount
1823
1824
1825 React.useEffect(function () {
1826 return function () {
1827 return ctrl.destroy();
1828 };
1829 }, []);
1830
1831 var onHalt = function onHalt(_ref) {
1832 var finished = _ref.finished;
1833 return finished && onRest && onRest(ctrl.merged);
1834 }; // The hooks explcit API gets defined here ...
1835
1836
1837 React.useImperativeHandle(props.ref, function () {
1838 return {
1839 start: function start() {
1840 return ctrl.start(onHalt);
1841 },
1842
1843 get isActive() {
1844 return ctrl.isActive;
1845 },
1846
1847 stop: function stop(finished) {
1848 if (finished === void 0) {
1849 finished = false;
1850 }
1851
1852 if (ctrl.isActive) ctrl.stop(finished);
1853 }
1854 };
1855 }); // Defines the hooks setter, which updates the controller
1856
1857 var updateCtrl = React.useCallback(function (updateProps) {
1858 type === 'keyframe' ? ctrl.updateWithForceUpdate(forceUpdate, updateProps) : ctrl.update(updateProps);
1859 if (!ctrl.props.ref) ctrl.start(onHalt);
1860 if (ctrl.props.reset && type === 'default') requestFrame(forceUpdate);
1861 }, [onRest, ctrl.props.ref]); // Update next frame is props aren't functional
1862
1863 React.useEffect(function () {
1864 return void (!isFn && updateCtrl(props));
1865 }); // Return animated props, or, anim-props + the update-setter above
1866
1867 var propValues = ctrl.getValues();
1868 return isFn ? [propValues, updateCtrl, function (finished) {
1869 if (finished === void 0) {
1870 finished = false;
1871 }
1872
1873 return ctrl.stop(finished);
1874 }] : propValues;
1875 };
1876};
1877var useSpring = useSpringImpl();
1878
1879var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
1880'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
1881var extendedAnimated = domElements.reduce(function (acc, element) {
1882 acc[element] = createAnimatedComponent(element);
1883 return acc;
1884}, createAnimatedComponent);
1885
1886function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1887
1888function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty$1._defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1889var RADIUS = 2;
1890var BAR_HEIGHT = 6;
1891var INDETERMINATE_WIDTH = 1 / 4;
1892var INDETERMINATE_DURATION = 1600;
1893var indeterminateAnim = _styled.keyframes(["0%{transform:translate3d(calc(-100% - 1px),0,0);}70%,100%{transform:translate3d(calc(", "% + 1px),0,0);}"], 100 / INDETERMINATE_WIDTH);
1894
1895var _StyledDiv = _styled__default("div").withConfig({
1896 displayName: "ProgressBar___StyledDiv",
1897 componentId: "sc-1gly9sn-0"
1898})(["width:100%;height:", "px;background:", ";border-radius:", "px;overflow:hidden;"], BAR_HEIGHT, function (p) {
1899 return p._css;
1900}, RADIUS);
1901
1902var ProgressBar = React__default.memo(function (_ref) {
1903 var animate = _ref.animate,
1904 color = _ref.color,
1905 progress = _ref.progress,
1906 value = _ref.value;
1907
1908 // Support `progress` for a while but warn if being used.
1909 if (value === -1 && typeof progress === 'number') {
1910 value = progress;
1911 environment.warnOnce('ProgressBar:progress', 'The `progress` prop of ProgressBar is deprecated: please use `value` instead.');
1912 } // The indeterminate state can be triggered either by not setting the value
1913 // (to mimic the <progress> element in HTML), or by setting the -1 value (for
1914 // convenience in React).
1915
1916
1917 var indeterminate = value === -1;
1918 var theme = Theme.useTheme();
1919 var currentColor = color === undefined ? theme.accent : color;
1920 var transition = useSpring({
1921 config: _objectSpread({}, springs.springs.smooth, {
1922 precision: 0.001
1923 }),
1924 from: {
1925 scale: 0,
1926 x: 0
1927 },
1928 to: {
1929 scale: value,
1930 x: 0
1931 },
1932 immediate: !animate
1933 });
1934 return /*#__PURE__*/React__default.createElement(_StyledDiv, {
1935 _css: theme.surfaceUnder
1936 }, /*#__PURE__*/React__default.createElement(Bar, {
1937 style: {
1938 width: "".concat((indeterminate ? INDETERMINATE_WIDTH : 1) * 100, "%"),
1939 background: currentColor,
1940 borderRadius: "".concat(indeterminate ? RADIUS : 0, "px"),
1941 animationName: "".concat(indeterminate ? indeterminateAnim.name : 'none'),
1942 transform: interpolate$1([transition.x, transition.scale], function (x, s) {
1943 return "translate3d(".concat(x * 100, "%, 0, 0) scale3d(").concat(s, ", 1, 1)");
1944 })
1945 }
1946 }));
1947});
1948var Bar = _styled__default(extendedAnimated.div).withConfig({
1949 displayName: "ProgressBar__Bar",
1950 componentId: "sc-1gly9sn-1"
1951})(["width:100%;height:", "px;transform-origin:0 0;animation:", " ", "ms ease-in-out infinite;animation-name:none;"], BAR_HEIGHT, indeterminateAnim, INDETERMINATE_DURATION);
1952ProgressBar.defaultProps = {
1953 animate: true,
1954 value: -1
1955};
1956ProgressBar.propTypes = {
1957 animate: proptypes.PropTypes.bool,
1958 color: proptypes.PropTypes.string,
1959 progress: proptypes.PropTypes._0to1,
1960 value: proptypes.PropTypes.oneOfType([proptypes.PropTypes._0to1, proptypes.PropTypes.oneOf([-1])])
1961};
1962
1963exports.default = ProgressBar;
1964//# sourceMappingURL=ProgressBar.js.map