UNPKG

100 kBJavaScriptView Raw
1/** @license React v16.7.0
2 * react.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12(function (global, factory) {
13 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
14 typeof define === 'function' && define.amd ? define(factory) :
15 (global.React = factory());
16}(this, (function () { 'use strict';
17
18// TODO: this is special because it gets imported during build.
19
20var ReactVersion = '16.7.0';
21
22// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
23// nor polyfill, then a plain number is used for performance.
24var hasSymbol = typeof Symbol === 'function' && Symbol.for;
25
26var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
27var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
28var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
29var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
30var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
31var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
32var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
33
34var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
35var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
36var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
37var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
38var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
39
40var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
41var FAUX_ITERATOR_SYMBOL = '@@iterator';
42
43function getIteratorFn(maybeIterable) {
44 if (maybeIterable === null || typeof maybeIterable !== 'object') {
45 return null;
46 }
47 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
48 if (typeof maybeIterator === 'function') {
49 return maybeIterator;
50 }
51 return null;
52}
53
54var enableHooks = false;
55// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
56
57
58// In some cases, StrictMode should also double-render lifecycles.
59// This can be confusing for tests though,
60// And it can be bad for performance in production.
61// This feature flag can be used to control the behavior:
62
63
64// To preserve the "Pause on caught exceptions" behavior of the debugger, we
65// replay the begin phase of a failed component inside invokeGuardedCallback.
66
67
68// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
69
70
71// Gather advanced timing metrics for Profiler subtrees.
72
73
74// Trace which interactions trigger each commit.
75var enableSchedulerTracing = true;
76
77// Only used in www builds.
78 // TODO: true? Here it might just be false.
79
80// Only used in www builds.
81var enableSchedulerDebugging = true;
82
83// Only used in www builds.
84
85
86// React Fire: prevent the value and checked attributes from syncing
87// with their related DOM properties
88
89
90// These APIs will no longer be "unstable" in the upcoming 16.7 release,
91// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
92var enableStableConcurrentModeAPIs = false;
93
94/*
95object-assign
96(c) Sindre Sorhus
97@license MIT
98*/
99
100
101/* eslint-disable no-unused-vars */
102var getOwnPropertySymbols = Object.getOwnPropertySymbols;
103var hasOwnProperty = Object.prototype.hasOwnProperty;
104var propIsEnumerable = Object.prototype.propertyIsEnumerable;
105
106function toObject(val) {
107 if (val === null || val === undefined) {
108 throw new TypeError('Object.assign cannot be called with null or undefined');
109 }
110
111 return Object(val);
112}
113
114function shouldUseNative() {
115 try {
116 if (!Object.assign) {
117 return false;
118 }
119
120 // Detect buggy property enumeration order in older V8 versions.
121
122 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
123 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
124 test1[5] = 'de';
125 if (Object.getOwnPropertyNames(test1)[0] === '5') {
126 return false;
127 }
128
129 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
130 var test2 = {};
131 for (var i = 0; i < 10; i++) {
132 test2['_' + String.fromCharCode(i)] = i;
133 }
134 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
135 return test2[n];
136 });
137 if (order2.join('') !== '0123456789') {
138 return false;
139 }
140
141 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
142 var test3 = {};
143 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
144 test3[letter] = letter;
145 });
146 if (Object.keys(Object.assign({}, test3)).join('') !==
147 'abcdefghijklmnopqrst') {
148 return false;
149 }
150
151 return true;
152 } catch (err) {
153 // We don't expect any of the above to throw, but better to be safe.
154 return false;
155 }
156}
157
158var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
159 var from;
160 var to = toObject(target);
161 var symbols;
162
163 for (var s = 1; s < arguments.length; s++) {
164 from = Object(arguments[s]);
165
166 for (var key in from) {
167 if (hasOwnProperty.call(from, key)) {
168 to[key] = from[key];
169 }
170 }
171
172 if (getOwnPropertySymbols) {
173 symbols = getOwnPropertySymbols(from);
174 for (var i = 0; i < symbols.length; i++) {
175 if (propIsEnumerable.call(from, symbols[i])) {
176 to[symbols[i]] = from[symbols[i]];
177 }
178 }
179 }
180 }
181
182 return to;
183};
184
185/**
186 * Use invariant() to assert state which your program assumes to be true.
187 *
188 * Provide sprintf-style format (only %s is supported) and arguments
189 * to provide information about what broke and what you were
190 * expecting.
191 *
192 * The invariant message will be stripped in production, but the invariant
193 * will remain to ensure logic does not differ in production.
194 */
195
196var validateFormat = function () {};
197
198{
199 validateFormat = function (format) {
200 if (format === undefined) {
201 throw new Error('invariant requires an error message argument');
202 }
203 };
204}
205
206function invariant(condition, format, a, b, c, d, e, f) {
207 validateFormat(format);
208
209 if (!condition) {
210 var error = void 0;
211 if (format === undefined) {
212 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
213 } else {
214 var args = [a, b, c, d, e, f];
215 var argIndex = 0;
216 error = new Error(format.replace(/%s/g, function () {
217 return args[argIndex++];
218 }));
219 error.name = 'Invariant Violation';
220 }
221
222 error.framesToPop = 1; // we don't care about invariant's own frame
223 throw error;
224 }
225}
226
227// Relying on the `invariant()` implementation lets us
228// preserve the format and params in the www builds.
229
230/**
231 * Forked from fbjs/warning:
232 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
233 *
234 * Only change is we use console.warn instead of console.error,
235 * and do nothing when 'console' is not supported.
236 * This really simplifies the code.
237 * ---
238 * Similar to invariant but only logs a warning if the condition is not met.
239 * This can be used to log issues in development environments in critical
240 * paths. Removing the logging code for production environments will keep the
241 * same logic and follow the same code paths.
242 */
243
244var lowPriorityWarning = function () {};
245
246{
247 var printWarning = function (format) {
248 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
249 args[_key - 1] = arguments[_key];
250 }
251
252 var argIndex = 0;
253 var message = 'Warning: ' + format.replace(/%s/g, function () {
254 return args[argIndex++];
255 });
256 if (typeof console !== 'undefined') {
257 console.warn(message);
258 }
259 try {
260 // --- Welcome to debugging React ---
261 // This error was thrown as a convenience so that you can use this stack
262 // to find the callsite that caused this warning to fire.
263 throw new Error(message);
264 } catch (x) {}
265 };
266
267 lowPriorityWarning = function (condition, format) {
268 if (format === undefined) {
269 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
270 }
271 if (!condition) {
272 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
273 args[_key2 - 2] = arguments[_key2];
274 }
275
276 printWarning.apply(undefined, [format].concat(args));
277 }
278 };
279}
280
281var lowPriorityWarning$1 = lowPriorityWarning;
282
283/**
284 * Similar to invariant but only logs a warning if the condition is not met.
285 * This can be used to log issues in development environments in critical
286 * paths. Removing the logging code for production environments will keep the
287 * same logic and follow the same code paths.
288 */
289
290var warningWithoutStack = function () {};
291
292{
293 warningWithoutStack = function (condition, format) {
294 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
295 args[_key - 2] = arguments[_key];
296 }
297
298 if (format === undefined) {
299 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
300 }
301 if (args.length > 8) {
302 // Check before the condition to catch violations early.
303 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
304 }
305 if (condition) {
306 return;
307 }
308 if (typeof console !== 'undefined') {
309 var argsWithFormat = args.map(function (item) {
310 return '' + item;
311 });
312 argsWithFormat.unshift('Warning: ' + format);
313
314 // We intentionally don't use spread (or .apply) directly because it
315 // breaks IE9: https://github.com/facebook/react/issues/13610
316 Function.prototype.apply.call(console.error, console, argsWithFormat);
317 }
318 try {
319 // --- Welcome to debugging React ---
320 // This error was thrown as a convenience so that you can use this stack
321 // to find the callsite that caused this warning to fire.
322 var argIndex = 0;
323 var message = 'Warning: ' + format.replace(/%s/g, function () {
324 return args[argIndex++];
325 });
326 throw new Error(message);
327 } catch (x) {}
328 };
329}
330
331var warningWithoutStack$1 = warningWithoutStack;
332
333var didWarnStateUpdateForUnmountedComponent = {};
334
335function warnNoop(publicInstance, callerName) {
336 {
337 var _constructor = publicInstance.constructor;
338 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
339 var warningKey = componentName + '.' + callerName;
340 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
341 return;
342 }
343 warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
344 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
345 }
346}
347
348/**
349 * This is the abstract API for an update queue.
350 */
351var ReactNoopUpdateQueue = {
352 /**
353 * Checks whether or not this composite component is mounted.
354 * @param {ReactClass} publicInstance The instance we want to test.
355 * @return {boolean} True if mounted, false otherwise.
356 * @protected
357 * @final
358 */
359 isMounted: function (publicInstance) {
360 return false;
361 },
362
363 /**
364 * Forces an update. This should only be invoked when it is known with
365 * certainty that we are **not** in a DOM transaction.
366 *
367 * You may want to call this when you know that some deeper aspect of the
368 * component's state has changed but `setState` was not called.
369 *
370 * This will not invoke `shouldComponentUpdate`, but it will invoke
371 * `componentWillUpdate` and `componentDidUpdate`.
372 *
373 * @param {ReactClass} publicInstance The instance that should rerender.
374 * @param {?function} callback Called after component is updated.
375 * @param {?string} callerName name of the calling function in the public API.
376 * @internal
377 */
378 enqueueForceUpdate: function (publicInstance, callback, callerName) {
379 warnNoop(publicInstance, 'forceUpdate');
380 },
381
382 /**
383 * Replaces all of the state. Always use this or `setState` to mutate state.
384 * You should treat `this.state` as immutable.
385 *
386 * There is no guarantee that `this.state` will be immediately updated, so
387 * accessing `this.state` after calling this method may return the old value.
388 *
389 * @param {ReactClass} publicInstance The instance that should rerender.
390 * @param {object} completeState Next state.
391 * @param {?function} callback Called after component is updated.
392 * @param {?string} callerName name of the calling function in the public API.
393 * @internal
394 */
395 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
396 warnNoop(publicInstance, 'replaceState');
397 },
398
399 /**
400 * Sets a subset of the state. This only exists because _pendingState is
401 * internal. This provides a merging strategy that is not available to deep
402 * properties which is confusing. TODO: Expose pendingState or don't use it
403 * during the merge.
404 *
405 * @param {ReactClass} publicInstance The instance that should rerender.
406 * @param {object} partialState Next partial state to be merged with state.
407 * @param {?function} callback Called after component is updated.
408 * @param {?string} Name of the calling function in the public API.
409 * @internal
410 */
411 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
412 warnNoop(publicInstance, 'setState');
413 }
414};
415
416var emptyObject = {};
417{
418 Object.freeze(emptyObject);
419}
420
421/**
422 * Base class helpers for the updating state of a component.
423 */
424function Component(props, context, updater) {
425 this.props = props;
426 this.context = context;
427 // If a component has string refs, we will assign a different object later.
428 this.refs = emptyObject;
429 // We initialize the default updater but the real one gets injected by the
430 // renderer.
431 this.updater = updater || ReactNoopUpdateQueue;
432}
433
434Component.prototype.isReactComponent = {};
435
436/**
437 * Sets a subset of the state. Always use this to mutate
438 * state. You should treat `this.state` as immutable.
439 *
440 * There is no guarantee that `this.state` will be immediately updated, so
441 * accessing `this.state` after calling this method may return the old value.
442 *
443 * There is no guarantee that calls to `setState` will run synchronously,
444 * as they may eventually be batched together. You can provide an optional
445 * callback that will be executed when the call to setState is actually
446 * completed.
447 *
448 * When a function is provided to setState, it will be called at some point in
449 * the future (not synchronously). It will be called with the up to date
450 * component arguments (state, props, context). These values can be different
451 * from this.* because your function may be called after receiveProps but before
452 * shouldComponentUpdate, and this new state, props, and context will not yet be
453 * assigned to this.
454 *
455 * @param {object|function} partialState Next partial state or function to
456 * produce next partial state to be merged with current state.
457 * @param {?function} callback Called after state is updated.
458 * @final
459 * @protected
460 */
461Component.prototype.setState = function (partialState, callback) {
462 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
463 this.updater.enqueueSetState(this, partialState, callback, 'setState');
464};
465
466/**
467 * Forces an update. This should only be invoked when it is known with
468 * certainty that we are **not** in a DOM transaction.
469 *
470 * You may want to call this when you know that some deeper aspect of the
471 * component's state has changed but `setState` was not called.
472 *
473 * This will not invoke `shouldComponentUpdate`, but it will invoke
474 * `componentWillUpdate` and `componentDidUpdate`.
475 *
476 * @param {?function} callback Called after update is complete.
477 * @final
478 * @protected
479 */
480Component.prototype.forceUpdate = function (callback) {
481 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
482};
483
484/**
485 * Deprecated APIs. These APIs used to exist on classic React classes but since
486 * we would like to deprecate them, we're not going to move them over to this
487 * modern base class. Instead, we define a getter that warns if it's accessed.
488 */
489{
490 var deprecatedAPIs = {
491 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
492 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
493 };
494 var defineDeprecationWarning = function (methodName, info) {
495 Object.defineProperty(Component.prototype, methodName, {
496 get: function () {
497 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
498 return undefined;
499 }
500 });
501 };
502 for (var fnName in deprecatedAPIs) {
503 if (deprecatedAPIs.hasOwnProperty(fnName)) {
504 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
505 }
506 }
507}
508
509function ComponentDummy() {}
510ComponentDummy.prototype = Component.prototype;
511
512/**
513 * Convenience component with default shallow equality check for sCU.
514 */
515function PureComponent(props, context, updater) {
516 this.props = props;
517 this.context = context;
518 // If a component has string refs, we will assign a different object later.
519 this.refs = emptyObject;
520 this.updater = updater || ReactNoopUpdateQueue;
521}
522
523var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
524pureComponentPrototype.constructor = PureComponent;
525// Avoid an extra prototype jump for these methods.
526objectAssign(pureComponentPrototype, Component.prototype);
527pureComponentPrototype.isPureReactComponent = true;
528
529// an immutable object with a single mutable value
530function createRef() {
531 var refObject = {
532 current: null
533 };
534 {
535 Object.seal(refObject);
536 }
537 return refObject;
538}
539
540/* eslint-disable no-var */
541
542// TODO: Use symbols?
543var ImmediatePriority = 1;
544var UserBlockingPriority = 2;
545var NormalPriority = 3;
546var LowPriority = 4;
547var IdlePriority = 5;
548
549// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
550// Math.pow(2, 30) - 1
551// 0b111111111111111111111111111111
552var maxSigned31BitInt = 1073741823;
553
554// Times out immediately
555var IMMEDIATE_PRIORITY_TIMEOUT = -1;
556// Eventually times out
557var USER_BLOCKING_PRIORITY = 250;
558var NORMAL_PRIORITY_TIMEOUT = 5000;
559var LOW_PRIORITY_TIMEOUT = 10000;
560// Never times out
561var IDLE_PRIORITY = maxSigned31BitInt;
562
563// Callbacks are stored as a circular, doubly linked list.
564var firstCallbackNode = null;
565
566var currentDidTimeout = false;
567// Pausing the scheduler is useful for debugging.
568var isSchedulerPaused = false;
569
570var currentPriorityLevel = NormalPriority;
571var currentEventStartTime = -1;
572var currentExpirationTime = -1;
573
574// This is set when a callback is being executed, to prevent re-entrancy.
575var isExecutingCallback = false;
576
577var isHostCallbackScheduled = false;
578
579var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
580
581function ensureHostCallbackIsScheduled() {
582 if (isExecutingCallback) {
583 // Don't schedule work yet; wait until the next time we yield.
584 return;
585 }
586 // Schedule the host callback using the earliest expiration in the list.
587 var expirationTime = firstCallbackNode.expirationTime;
588 if (!isHostCallbackScheduled) {
589 isHostCallbackScheduled = true;
590 } else {
591 // Cancel the existing host callback.
592 cancelHostCallback();
593 }
594 requestHostCallback(flushWork, expirationTime);
595}
596
597function flushFirstCallback() {
598 var flushedNode = firstCallbackNode;
599
600 // Remove the node from the list before calling the callback. That way the
601 // list is in a consistent state even if the callback throws.
602 var next = firstCallbackNode.next;
603 if (firstCallbackNode === next) {
604 // This is the last callback in the list.
605 firstCallbackNode = null;
606 next = null;
607 } else {
608 var lastCallbackNode = firstCallbackNode.previous;
609 firstCallbackNode = lastCallbackNode.next = next;
610 next.previous = lastCallbackNode;
611 }
612
613 flushedNode.next = flushedNode.previous = null;
614
615 // Now it's safe to call the callback.
616 var callback = flushedNode.callback;
617 var expirationTime = flushedNode.expirationTime;
618 var priorityLevel = flushedNode.priorityLevel;
619 var previousPriorityLevel = currentPriorityLevel;
620 var previousExpirationTime = currentExpirationTime;
621 currentPriorityLevel = priorityLevel;
622 currentExpirationTime = expirationTime;
623 var continuationCallback;
624 try {
625 continuationCallback = callback();
626 } finally {
627 currentPriorityLevel = previousPriorityLevel;
628 currentExpirationTime = previousExpirationTime;
629 }
630
631 // A callback may return a continuation. The continuation should be scheduled
632 // with the same priority and expiration as the just-finished callback.
633 if (typeof continuationCallback === 'function') {
634 var continuationNode = {
635 callback: continuationCallback,
636 priorityLevel: priorityLevel,
637 expirationTime: expirationTime,
638 next: null,
639 previous: null
640 };
641
642 // Insert the new callback into the list, sorted by its expiration. This is
643 // almost the same as the code in `scheduleCallback`, except the callback
644 // is inserted into the list *before* callbacks of equal expiration instead
645 // of after.
646 if (firstCallbackNode === null) {
647 // This is the first callback in the list.
648 firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
649 } else {
650 var nextAfterContinuation = null;
651 var node = firstCallbackNode;
652 do {
653 if (node.expirationTime >= expirationTime) {
654 // This callback expires at or after the continuation. We will insert
655 // the continuation *before* this callback.
656 nextAfterContinuation = node;
657 break;
658 }
659 node = node.next;
660 } while (node !== firstCallbackNode);
661
662 if (nextAfterContinuation === null) {
663 // No equal or lower priority callback was found, which means the new
664 // callback is the lowest priority callback in the list.
665 nextAfterContinuation = firstCallbackNode;
666 } else if (nextAfterContinuation === firstCallbackNode) {
667 // The new callback is the highest priority callback in the list.
668 firstCallbackNode = continuationNode;
669 ensureHostCallbackIsScheduled();
670 }
671
672 var previous = nextAfterContinuation.previous;
673 previous.next = nextAfterContinuation.previous = continuationNode;
674 continuationNode.next = nextAfterContinuation;
675 continuationNode.previous = previous;
676 }
677 }
678}
679
680function flushImmediateWork() {
681 if (
682 // Confirm we've exited the outer most event handler
683 currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
684 isExecutingCallback = true;
685 try {
686 do {
687 flushFirstCallback();
688 } while (
689 // Keep flushing until there are no more immediate callbacks
690 firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
691 } finally {
692 isExecutingCallback = false;
693 if (firstCallbackNode !== null) {
694 // There's still work remaining. Request another callback.
695 ensureHostCallbackIsScheduled();
696 } else {
697 isHostCallbackScheduled = false;
698 }
699 }
700 }
701}
702
703function flushWork(didTimeout) {
704 // Exit right away if we're currently paused
705
706 if (enableSchedulerDebugging && isSchedulerPaused) {
707 return;
708 }
709
710 isExecutingCallback = true;
711 var previousDidTimeout = currentDidTimeout;
712 currentDidTimeout = didTimeout;
713 try {
714 if (didTimeout) {
715 // Flush all the expired callbacks without yielding.
716 while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
717 // TODO Wrap i nfeature flag
718 // Read the current time. Flush all the callbacks that expire at or
719 // earlier than that time. Then read the current time again and repeat.
720 // This optimizes for as few performance.now calls as possible.
721 var currentTime = getCurrentTime();
722 if (firstCallbackNode.expirationTime <= currentTime) {
723 do {
724 flushFirstCallback();
725 } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused));
726 continue;
727 }
728 break;
729 }
730 } else {
731 // Keep flushing callbacks until we run out of time in the frame.
732 if (firstCallbackNode !== null) {
733 do {
734 if (enableSchedulerDebugging && isSchedulerPaused) {
735 break;
736 }
737 flushFirstCallback();
738 } while (firstCallbackNode !== null && !shouldYieldToHost());
739 }
740 }
741 } finally {
742 isExecutingCallback = false;
743 currentDidTimeout = previousDidTimeout;
744 if (firstCallbackNode !== null) {
745 // There's still work remaining. Request another callback.
746 ensureHostCallbackIsScheduled();
747 } else {
748 isHostCallbackScheduled = false;
749 }
750 // Before exiting, flush all the immediate work that was scheduled.
751 flushImmediateWork();
752 }
753}
754
755function unstable_runWithPriority(priorityLevel, eventHandler) {
756 switch (priorityLevel) {
757 case ImmediatePriority:
758 case UserBlockingPriority:
759 case NormalPriority:
760 case LowPriority:
761 case IdlePriority:
762 break;
763 default:
764 priorityLevel = NormalPriority;
765 }
766
767 var previousPriorityLevel = currentPriorityLevel;
768 var previousEventStartTime = currentEventStartTime;
769 currentPriorityLevel = priorityLevel;
770 currentEventStartTime = getCurrentTime();
771
772 try {
773 return eventHandler();
774 } finally {
775 currentPriorityLevel = previousPriorityLevel;
776 currentEventStartTime = previousEventStartTime;
777
778 // Before exiting, flush all the immediate work that was scheduled.
779 flushImmediateWork();
780 }
781}
782
783function unstable_wrapCallback(callback) {
784 var parentPriorityLevel = currentPriorityLevel;
785 return function () {
786 // This is a fork of runWithPriority, inlined for performance.
787 var previousPriorityLevel = currentPriorityLevel;
788 var previousEventStartTime = currentEventStartTime;
789 currentPriorityLevel = parentPriorityLevel;
790 currentEventStartTime = getCurrentTime();
791
792 try {
793 return callback.apply(this, arguments);
794 } finally {
795 currentPriorityLevel = previousPriorityLevel;
796 currentEventStartTime = previousEventStartTime;
797 flushImmediateWork();
798 }
799 };
800}
801
802function unstable_scheduleCallback(callback, deprecated_options) {
803 var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
804
805 var expirationTime;
806 if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
807 // FIXME: Remove this branch once we lift expiration times out of React.
808 expirationTime = startTime + deprecated_options.timeout;
809 } else {
810 switch (currentPriorityLevel) {
811 case ImmediatePriority:
812 expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
813 break;
814 case UserBlockingPriority:
815 expirationTime = startTime + USER_BLOCKING_PRIORITY;
816 break;
817 case IdlePriority:
818 expirationTime = startTime + IDLE_PRIORITY;
819 break;
820 case LowPriority:
821 expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
822 break;
823 case NormalPriority:
824 default:
825 expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
826 }
827 }
828
829 var newNode = {
830 callback: callback,
831 priorityLevel: currentPriorityLevel,
832 expirationTime: expirationTime,
833 next: null,
834 previous: null
835 };
836
837 // Insert the new callback into the list, ordered first by expiration, then
838 // by insertion. So the new callback is inserted any other callback with
839 // equal expiration.
840 if (firstCallbackNode === null) {
841 // This is the first callback in the list.
842 firstCallbackNode = newNode.next = newNode.previous = newNode;
843 ensureHostCallbackIsScheduled();
844 } else {
845 var next = null;
846 var node = firstCallbackNode;
847 do {
848 if (node.expirationTime > expirationTime) {
849 // The new callback expires before this one.
850 next = node;
851 break;
852 }
853 node = node.next;
854 } while (node !== firstCallbackNode);
855
856 if (next === null) {
857 // No callback with a later expiration was found, which means the new
858 // callback has the latest expiration in the list.
859 next = firstCallbackNode;
860 } else if (next === firstCallbackNode) {
861 // The new callback has the earliest expiration in the entire list.
862 firstCallbackNode = newNode;
863 ensureHostCallbackIsScheduled();
864 }
865
866 var previous = next.previous;
867 previous.next = next.previous = newNode;
868 newNode.next = next;
869 newNode.previous = previous;
870 }
871
872 return newNode;
873}
874
875function unstable_pauseExecution() {
876 isSchedulerPaused = true;
877}
878
879function unstable_continueExecution() {
880 isSchedulerPaused = false;
881 if (firstCallbackNode !== null) {
882 ensureHostCallbackIsScheduled();
883 }
884}
885
886function unstable_getFirstCallbackNode() {
887 return firstCallbackNode;
888}
889
890function unstable_cancelCallback(callbackNode) {
891 var next = callbackNode.next;
892 if (next === null) {
893 // Already cancelled.
894 return;
895 }
896
897 if (next === callbackNode) {
898 // This is the only scheduled callback. Clear the list.
899 firstCallbackNode = null;
900 } else {
901 // Remove the callback from its position in the list.
902 if (callbackNode === firstCallbackNode) {
903 firstCallbackNode = next;
904 }
905 var previous = callbackNode.previous;
906 previous.next = next;
907 next.previous = previous;
908 }
909
910 callbackNode.next = callbackNode.previous = null;
911}
912
913function unstable_getCurrentPriorityLevel() {
914 return currentPriorityLevel;
915}
916
917function unstable_shouldYield() {
918 return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
919}
920
921// The remaining code is essentially a polyfill for requestIdleCallback. It
922// works by scheduling a requestAnimationFrame, storing the time for the start
923// of the frame, then scheduling a postMessage which gets scheduled after paint.
924// Within the postMessage handler do as much work as possible until time + frame
925// rate. By separating the idle call into a separate event tick we ensure that
926// layout, paint and other browser work is counted against the available time.
927// The frame rate is dynamically adjusted.
928
929// We capture a local reference to any global, in case it gets polyfilled after
930// this module is initially evaluated. We want to be using a
931// consistent implementation.
932var localDate = Date;
933
934// This initialization code may run even on server environments if a component
935// just imports ReactDOM (e.g. for findDOMNode). Some environments might not
936// have setTimeout or clearTimeout. However, we always expect them to be defined
937// on the client. https://github.com/facebook/react/pull/13088
938var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
939var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
940
941// We don't expect either of these to necessarily be defined, but we will error
942// later if they are missing on the client.
943var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
944var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
945
946var getCurrentTime;
947
948// requestAnimationFrame does not run when the tab is in the background. If
949// we're backgrounded we prefer for that work to happen so that the page
950// continues to load in the background. So we also schedule a 'setTimeout' as
951// a fallback.
952// TODO: Need a better heuristic for backgrounded work.
953var ANIMATION_FRAME_TIMEOUT = 100;
954var rAFID;
955var rAFTimeoutID;
956var requestAnimationFrameWithTimeout = function (callback) {
957 // schedule rAF and also a setTimeout
958 rAFID = localRequestAnimationFrame(function (timestamp) {
959 // cancel the setTimeout
960 localClearTimeout(rAFTimeoutID);
961 callback(timestamp);
962 });
963 rAFTimeoutID = localSetTimeout(function () {
964 // cancel the requestAnimationFrame
965 localCancelAnimationFrame(rAFID);
966 callback(getCurrentTime());
967 }, ANIMATION_FRAME_TIMEOUT);
968};
969
970if (hasNativePerformanceNow) {
971 var Performance = performance;
972 getCurrentTime = function () {
973 return Performance.now();
974 };
975} else {
976 getCurrentTime = function () {
977 return localDate.now();
978 };
979}
980
981var requestHostCallback;
982var cancelHostCallback;
983var shouldYieldToHost;
984
985var globalValue = null;
986if (typeof window !== 'undefined') {
987 globalValue = window;
988} else if (typeof global !== 'undefined') {
989 globalValue = global;
990}
991
992if (globalValue && globalValue._schedMock) {
993 // Dynamic injection, only for testing purposes.
994 var globalImpl = globalValue._schedMock;
995 requestHostCallback = globalImpl[0];
996 cancelHostCallback = globalImpl[1];
997 shouldYieldToHost = globalImpl[2];
998 getCurrentTime = globalImpl[3];
999} else if (
1000// If Scheduler runs in a non-DOM environment, it falls back to a naive
1001// implementation using setTimeout.
1002typeof window === 'undefined' ||
1003// Check if MessageChannel is supported, too.
1004typeof MessageChannel !== 'function') {
1005 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
1006 // fallback to a naive implementation.
1007 var _callback = null;
1008 var _flushCallback = function (didTimeout) {
1009 if (_callback !== null) {
1010 try {
1011 _callback(didTimeout);
1012 } finally {
1013 _callback = null;
1014 }
1015 }
1016 };
1017 requestHostCallback = function (cb, ms) {
1018 if (_callback !== null) {
1019 // Protect against re-entrancy.
1020 setTimeout(requestHostCallback, 0, cb);
1021 } else {
1022 _callback = cb;
1023 setTimeout(_flushCallback, 0, false);
1024 }
1025 };
1026 cancelHostCallback = function () {
1027 _callback = null;
1028 };
1029 shouldYieldToHost = function () {
1030 return false;
1031 };
1032} else {
1033 if (typeof console !== 'undefined') {
1034 // TODO: Remove fb.me link
1035 if (typeof localRequestAnimationFrame !== 'function') {
1036 console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1037 }
1038 if (typeof localCancelAnimationFrame !== 'function') {
1039 console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1040 }
1041 }
1042
1043 var scheduledHostCallback = null;
1044 var isMessageEventScheduled = false;
1045 var timeoutTime = -1;
1046
1047 var isAnimationFrameScheduled = false;
1048
1049 var isFlushingHostCallback = false;
1050
1051 var frameDeadline = 0;
1052 // We start out assuming that we run at 30fps but then the heuristic tracking
1053 // will adjust this value to a faster fps if we get more frequent animation
1054 // frames.
1055 var previousFrameTime = 33;
1056 var activeFrameTime = 33;
1057
1058 shouldYieldToHost = function () {
1059 return frameDeadline <= getCurrentTime();
1060 };
1061
1062 // We use the postMessage trick to defer idle work until after the repaint.
1063 var channel = new MessageChannel();
1064 var port = channel.port2;
1065 channel.port1.onmessage = function (event) {
1066 isMessageEventScheduled = false;
1067
1068 var prevScheduledCallback = scheduledHostCallback;
1069 var prevTimeoutTime = timeoutTime;
1070 scheduledHostCallback = null;
1071 timeoutTime = -1;
1072
1073 var currentTime = getCurrentTime();
1074
1075 var didTimeout = false;
1076 if (frameDeadline - currentTime <= 0) {
1077 // There's no time left in this idle period. Check if the callback has
1078 // a timeout and whether it's been exceeded.
1079 if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
1080 // Exceeded the timeout. Invoke the callback even though there's no
1081 // time left.
1082 didTimeout = true;
1083 } else {
1084 // No timeout.
1085 if (!isAnimationFrameScheduled) {
1086 // Schedule another animation callback so we retry later.
1087 isAnimationFrameScheduled = true;
1088 requestAnimationFrameWithTimeout(animationTick);
1089 }
1090 // Exit without invoking the callback.
1091 scheduledHostCallback = prevScheduledCallback;
1092 timeoutTime = prevTimeoutTime;
1093 return;
1094 }
1095 }
1096
1097 if (prevScheduledCallback !== null) {
1098 isFlushingHostCallback = true;
1099 try {
1100 prevScheduledCallback(didTimeout);
1101 } finally {
1102 isFlushingHostCallback = false;
1103 }
1104 }
1105 };
1106
1107 var animationTick = function (rafTime) {
1108 if (scheduledHostCallback !== null) {
1109 // Eagerly schedule the next animation callback at the beginning of the
1110 // frame. If the scheduler queue is not empty at the end of the frame, it
1111 // will continue flushing inside that callback. If the queue *is* empty,
1112 // then it will exit immediately. Posting the callback at the start of the
1113 // frame ensures it's fired within the earliest possible frame. If we
1114 // waited until the end of the frame to post the callback, we risk the
1115 // browser skipping a frame and not firing the callback until the frame
1116 // after that.
1117 requestAnimationFrameWithTimeout(animationTick);
1118 } else {
1119 // No pending work. Exit.
1120 isAnimationFrameScheduled = false;
1121 return;
1122 }
1123
1124 var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
1125 if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
1126 if (nextFrameTime < 8) {
1127 // Defensive coding. We don't support higher frame rates than 120hz.
1128 // If the calculated frame time gets lower than 8, it is probably a bug.
1129 nextFrameTime = 8;
1130 }
1131 // If one frame goes long, then the next one can be short to catch up.
1132 // If two frames are short in a row, then that's an indication that we
1133 // actually have a higher frame rate than what we're currently optimizing.
1134 // We adjust our heuristic dynamically accordingly. For example, if we're
1135 // running on 120hz display or 90hz VR display.
1136 // Take the max of the two in case one of them was an anomaly due to
1137 // missed frame deadlines.
1138 activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
1139 } else {
1140 previousFrameTime = nextFrameTime;
1141 }
1142 frameDeadline = rafTime + activeFrameTime;
1143 if (!isMessageEventScheduled) {
1144 isMessageEventScheduled = true;
1145 port.postMessage(undefined);
1146 }
1147 };
1148
1149 requestHostCallback = function (callback, absoluteTimeout) {
1150 scheduledHostCallback = callback;
1151 timeoutTime = absoluteTimeout;
1152 if (isFlushingHostCallback || absoluteTimeout < 0) {
1153 // Don't wait for the next frame. Continue working ASAP, in a new event.
1154 port.postMessage(undefined);
1155 } else if (!isAnimationFrameScheduled) {
1156 // If rAF didn't already schedule one, we need to schedule a frame.
1157 // TODO: If this rAF doesn't materialize because the browser throttles, we
1158 // might want to still have setTimeout trigger rIC as a backup to ensure
1159 // that we keep performing work.
1160 isAnimationFrameScheduled = true;
1161 requestAnimationFrameWithTimeout(animationTick);
1162 }
1163 };
1164
1165 cancelHostCallback = function () {
1166 scheduledHostCallback = null;
1167 isMessageEventScheduled = false;
1168 timeoutTime = -1;
1169 };
1170}
1171
1172var DEFAULT_THREAD_ID = 0;
1173
1174// Counters used to generate unique IDs.
1175var interactionIDCounter = 0;
1176var threadIDCounter = 0;
1177
1178// Set of currently traced interactions.
1179// Interactions "stack"–
1180// Meaning that newly traced interactions are appended to the previously active set.
1181// When an interaction goes out of scope, the previous set (if any) is restored.
1182var interactionsRef = null;
1183
1184// Listener(s) to notify when interactions begin and end.
1185var subscriberRef = null;
1186
1187if (enableSchedulerTracing) {
1188 interactionsRef = {
1189 current: new Set()
1190 };
1191 subscriberRef = {
1192 current: null
1193 };
1194}
1195
1196function unstable_clear(callback) {
1197 if (!enableSchedulerTracing) {
1198 return callback();
1199 }
1200
1201 var prevInteractions = interactionsRef.current;
1202 interactionsRef.current = new Set();
1203
1204 try {
1205 return callback();
1206 } finally {
1207 interactionsRef.current = prevInteractions;
1208 }
1209}
1210
1211function unstable_getCurrent() {
1212 if (!enableSchedulerTracing) {
1213 return null;
1214 } else {
1215 return interactionsRef.current;
1216 }
1217}
1218
1219function unstable_getThreadID() {
1220 return ++threadIDCounter;
1221}
1222
1223function unstable_trace(name, timestamp, callback) {
1224 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
1225
1226 if (!enableSchedulerTracing) {
1227 return callback();
1228 }
1229
1230 var interaction = {
1231 __count: 1,
1232 id: interactionIDCounter++,
1233 name: name,
1234 timestamp: timestamp
1235 };
1236
1237 var prevInteractions = interactionsRef.current;
1238
1239 // Traced interactions should stack/accumulate.
1240 // To do that, clone the current interactions.
1241 // The previous set will be restored upon completion.
1242 var interactions = new Set(prevInteractions);
1243 interactions.add(interaction);
1244 interactionsRef.current = interactions;
1245
1246 var subscriber = subscriberRef.current;
1247 var returnValue = void 0;
1248
1249 try {
1250 if (subscriber !== null) {
1251 subscriber.onInteractionTraced(interaction);
1252 }
1253 } finally {
1254 try {
1255 if (subscriber !== null) {
1256 subscriber.onWorkStarted(interactions, threadID);
1257 }
1258 } finally {
1259 try {
1260 returnValue = callback();
1261 } finally {
1262 interactionsRef.current = prevInteractions;
1263
1264 try {
1265 if (subscriber !== null) {
1266 subscriber.onWorkStopped(interactions, threadID);
1267 }
1268 } finally {
1269 interaction.__count--;
1270
1271 // If no async work was scheduled for this interaction,
1272 // Notify subscribers that it's completed.
1273 if (subscriber !== null && interaction.__count === 0) {
1274 subscriber.onInteractionScheduledWorkCompleted(interaction);
1275 }
1276 }
1277 }
1278 }
1279 }
1280
1281 return returnValue;
1282}
1283
1284function unstable_wrap(callback) {
1285 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
1286
1287 if (!enableSchedulerTracing) {
1288 return callback;
1289 }
1290
1291 var wrappedInteractions = interactionsRef.current;
1292
1293 var subscriber = subscriberRef.current;
1294 if (subscriber !== null) {
1295 subscriber.onWorkScheduled(wrappedInteractions, threadID);
1296 }
1297
1298 // Update the pending async work count for the current interactions.
1299 // Update after calling subscribers in case of error.
1300 wrappedInteractions.forEach(function (interaction) {
1301 interaction.__count++;
1302 });
1303
1304 var hasRun = false;
1305
1306 function wrapped() {
1307 var prevInteractions = interactionsRef.current;
1308 interactionsRef.current = wrappedInteractions;
1309
1310 subscriber = subscriberRef.current;
1311
1312 try {
1313 var returnValue = void 0;
1314
1315 try {
1316 if (subscriber !== null) {
1317 subscriber.onWorkStarted(wrappedInteractions, threadID);
1318 }
1319 } finally {
1320 try {
1321 returnValue = callback.apply(undefined, arguments);
1322 } finally {
1323 interactionsRef.current = prevInteractions;
1324
1325 if (subscriber !== null) {
1326 subscriber.onWorkStopped(wrappedInteractions, threadID);
1327 }
1328 }
1329 }
1330
1331 return returnValue;
1332 } finally {
1333 if (!hasRun) {
1334 // We only expect a wrapped function to be executed once,
1335 // But in the event that it's executed more than once–
1336 // Only decrement the outstanding interaction counts once.
1337 hasRun = true;
1338
1339 // Update pending async counts for all wrapped interactions.
1340 // If this was the last scheduled async work for any of them,
1341 // Mark them as completed.
1342 wrappedInteractions.forEach(function (interaction) {
1343 interaction.__count--;
1344
1345 if (subscriber !== null && interaction.__count === 0) {
1346 subscriber.onInteractionScheduledWorkCompleted(interaction);
1347 }
1348 });
1349 }
1350 }
1351 }
1352
1353 wrapped.cancel = function cancel() {
1354 subscriber = subscriberRef.current;
1355
1356 try {
1357 if (subscriber !== null) {
1358 subscriber.onWorkCanceled(wrappedInteractions, threadID);
1359 }
1360 } finally {
1361 // Update pending async counts for all wrapped interactions.
1362 // If this was the last scheduled async work for any of them,
1363 // Mark them as completed.
1364 wrappedInteractions.forEach(function (interaction) {
1365 interaction.__count--;
1366
1367 if (subscriber && interaction.__count === 0) {
1368 subscriber.onInteractionScheduledWorkCompleted(interaction);
1369 }
1370 });
1371 }
1372 };
1373
1374 return wrapped;
1375}
1376
1377var subscribers = null;
1378if (enableSchedulerTracing) {
1379 subscribers = new Set();
1380}
1381
1382function unstable_subscribe(subscriber) {
1383 if (enableSchedulerTracing) {
1384 subscribers.add(subscriber);
1385
1386 if (subscribers.size === 1) {
1387 subscriberRef.current = {
1388 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
1389 onInteractionTraced: onInteractionTraced,
1390 onWorkCanceled: onWorkCanceled,
1391 onWorkScheduled: onWorkScheduled,
1392 onWorkStarted: onWorkStarted,
1393 onWorkStopped: onWorkStopped
1394 };
1395 }
1396 }
1397}
1398
1399function unstable_unsubscribe(subscriber) {
1400 if (enableSchedulerTracing) {
1401 subscribers.delete(subscriber);
1402
1403 if (subscribers.size === 0) {
1404 subscriberRef.current = null;
1405 }
1406 }
1407}
1408
1409function onInteractionTraced(interaction) {
1410 var didCatchError = false;
1411 var caughtError = null;
1412
1413 subscribers.forEach(function (subscriber) {
1414 try {
1415 subscriber.onInteractionTraced(interaction);
1416 } catch (error) {
1417 if (!didCatchError) {
1418 didCatchError = true;
1419 caughtError = error;
1420 }
1421 }
1422 });
1423
1424 if (didCatchError) {
1425 throw caughtError;
1426 }
1427}
1428
1429function onInteractionScheduledWorkCompleted(interaction) {
1430 var didCatchError = false;
1431 var caughtError = null;
1432
1433 subscribers.forEach(function (subscriber) {
1434 try {
1435 subscriber.onInteractionScheduledWorkCompleted(interaction);
1436 } catch (error) {
1437 if (!didCatchError) {
1438 didCatchError = true;
1439 caughtError = error;
1440 }
1441 }
1442 });
1443
1444 if (didCatchError) {
1445 throw caughtError;
1446 }
1447}
1448
1449function onWorkScheduled(interactions, threadID) {
1450 var didCatchError = false;
1451 var caughtError = null;
1452
1453 subscribers.forEach(function (subscriber) {
1454 try {
1455 subscriber.onWorkScheduled(interactions, threadID);
1456 } catch (error) {
1457 if (!didCatchError) {
1458 didCatchError = true;
1459 caughtError = error;
1460 }
1461 }
1462 });
1463
1464 if (didCatchError) {
1465 throw caughtError;
1466 }
1467}
1468
1469function onWorkStarted(interactions, threadID) {
1470 var didCatchError = false;
1471 var caughtError = null;
1472
1473 subscribers.forEach(function (subscriber) {
1474 try {
1475 subscriber.onWorkStarted(interactions, threadID);
1476 } catch (error) {
1477 if (!didCatchError) {
1478 didCatchError = true;
1479 caughtError = error;
1480 }
1481 }
1482 });
1483
1484 if (didCatchError) {
1485 throw caughtError;
1486 }
1487}
1488
1489function onWorkStopped(interactions, threadID) {
1490 var didCatchError = false;
1491 var caughtError = null;
1492
1493 subscribers.forEach(function (subscriber) {
1494 try {
1495 subscriber.onWorkStopped(interactions, threadID);
1496 } catch (error) {
1497 if (!didCatchError) {
1498 didCatchError = true;
1499 caughtError = error;
1500 }
1501 }
1502 });
1503
1504 if (didCatchError) {
1505 throw caughtError;
1506 }
1507}
1508
1509function onWorkCanceled(interactions, threadID) {
1510 var didCatchError = false;
1511 var caughtError = null;
1512
1513 subscribers.forEach(function (subscriber) {
1514 try {
1515 subscriber.onWorkCanceled(interactions, threadID);
1516 } catch (error) {
1517 if (!didCatchError) {
1518 didCatchError = true;
1519 caughtError = error;
1520 }
1521 }
1522 });
1523
1524 if (didCatchError) {
1525 throw caughtError;
1526 }
1527}
1528
1529/**
1530 * Keeps track of the current owner.
1531 *
1532 * The current owner is the component who should own any components that are
1533 * currently being constructed.
1534 */
1535var ReactCurrentOwner = {
1536 /**
1537 * @internal
1538 * @type {ReactComponent}
1539 */
1540 current: null,
1541 currentDispatcher: null
1542};
1543
1544var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1545
1546var describeComponentFrame = function (name, source, ownerName) {
1547 var sourceInfo = '';
1548 if (source) {
1549 var path = source.fileName;
1550 var fileName = path.replace(BEFORE_SLASH_RE, '');
1551 {
1552 // In DEV, include code for a common special case:
1553 // prefer "folder/index.js" instead of just "index.js".
1554 if (/^index\./.test(fileName)) {
1555 var match = path.match(BEFORE_SLASH_RE);
1556 if (match) {
1557 var pathBeforeSlash = match[1];
1558 if (pathBeforeSlash) {
1559 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1560 fileName = folderName + '/' + fileName;
1561 }
1562 }
1563 }
1564 }
1565 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1566 } else if (ownerName) {
1567 sourceInfo = ' (created by ' + ownerName + ')';
1568 }
1569 return '\n in ' + (name || 'Unknown') + sourceInfo;
1570};
1571
1572var Resolved = 1;
1573
1574
1575function refineResolvedLazyComponent(lazyComponent) {
1576 return lazyComponent._status === Resolved ? lazyComponent._result : null;
1577}
1578
1579function getWrappedName(outerType, innerType, wrapperName) {
1580 var functionName = innerType.displayName || innerType.name || '';
1581 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
1582}
1583
1584function getComponentName(type) {
1585 if (type == null) {
1586 // Host root, text node or just invalid type.
1587 return null;
1588 }
1589 {
1590 if (typeof type.tag === 'number') {
1591 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
1592 }
1593 }
1594 if (typeof type === 'function') {
1595 return type.displayName || type.name || null;
1596 }
1597 if (typeof type === 'string') {
1598 return type;
1599 }
1600 switch (type) {
1601 case REACT_CONCURRENT_MODE_TYPE:
1602 return 'ConcurrentMode';
1603 case REACT_FRAGMENT_TYPE:
1604 return 'Fragment';
1605 case REACT_PORTAL_TYPE:
1606 return 'Portal';
1607 case REACT_PROFILER_TYPE:
1608 return 'Profiler';
1609 case REACT_STRICT_MODE_TYPE:
1610 return 'StrictMode';
1611 case REACT_SUSPENSE_TYPE:
1612 return 'Suspense';
1613 }
1614 if (typeof type === 'object') {
1615 switch (type.$$typeof) {
1616 case REACT_CONTEXT_TYPE:
1617 return 'Context.Consumer';
1618 case REACT_PROVIDER_TYPE:
1619 return 'Context.Provider';
1620 case REACT_FORWARD_REF_TYPE:
1621 return getWrappedName(type, type.render, 'ForwardRef');
1622 case REACT_MEMO_TYPE:
1623 return getComponentName(type.type);
1624 case REACT_LAZY_TYPE:
1625 {
1626 var thenable = type;
1627 var resolvedThenable = refineResolvedLazyComponent(thenable);
1628 if (resolvedThenable) {
1629 return getComponentName(resolvedThenable);
1630 }
1631 }
1632 }
1633 }
1634 return null;
1635}
1636
1637var ReactDebugCurrentFrame = {};
1638
1639var currentlyValidatingElement = null;
1640
1641function setCurrentlyValidatingElement(element) {
1642 {
1643 currentlyValidatingElement = element;
1644 }
1645}
1646
1647{
1648 // Stack implementation injected by the current renderer.
1649 ReactDebugCurrentFrame.getCurrentStack = null;
1650
1651 ReactDebugCurrentFrame.getStackAddendum = function () {
1652 var stack = '';
1653
1654 // Add an extra top frame while an element is being validated
1655 if (currentlyValidatingElement) {
1656 var name = getComponentName(currentlyValidatingElement.type);
1657 var owner = currentlyValidatingElement._owner;
1658 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
1659 }
1660
1661 // Delegate to the injected renderer-specific implementation
1662 var impl = ReactDebugCurrentFrame.getCurrentStack;
1663 if (impl) {
1664 stack += impl() || '';
1665 }
1666
1667 return stack;
1668 };
1669}
1670
1671var ReactSharedInternals = {
1672 ReactCurrentOwner: ReactCurrentOwner,
1673 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
1674 assign: objectAssign
1675};
1676
1677{
1678 // Re-export the schedule API(s) for UMD bundles.
1679 // This avoids introducing a dependency on a new UMD global in a minor update,
1680 // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
1681 // This re-export is only required for UMD bundles;
1682 // CJS bundles use the shared NPM package.
1683 objectAssign(ReactSharedInternals, {
1684 Scheduler: {
1685 unstable_cancelCallback: unstable_cancelCallback,
1686 unstable_shouldYield: unstable_shouldYield,
1687 unstable_now: getCurrentTime,
1688 unstable_scheduleCallback: unstable_scheduleCallback,
1689 unstable_runWithPriority: unstable_runWithPriority,
1690 unstable_wrapCallback: unstable_wrapCallback,
1691 unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
1692 unstable_pauseExecution: unstable_pauseExecution,
1693 unstable_continueExecution: unstable_continueExecution,
1694 unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel
1695 },
1696 SchedulerTracing: {
1697 __interactionsRef: interactionsRef,
1698 __subscriberRef: subscriberRef,
1699 unstable_clear: unstable_clear,
1700 unstable_getCurrent: unstable_getCurrent,
1701 unstable_getThreadID: unstable_getThreadID,
1702 unstable_subscribe: unstable_subscribe,
1703 unstable_trace: unstable_trace,
1704 unstable_unsubscribe: unstable_unsubscribe,
1705 unstable_wrap: unstable_wrap
1706 }
1707 });
1708}
1709
1710{
1711 objectAssign(ReactSharedInternals, {
1712 // These should not be included in production.
1713 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
1714 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
1715 // TODO: remove in React 17.0.
1716 ReactComponentTreeHook: {}
1717 });
1718}
1719
1720/**
1721 * Similar to invariant but only logs a warning if the condition is not met.
1722 * This can be used to log issues in development environments in critical
1723 * paths. Removing the logging code for production environments will keep the
1724 * same logic and follow the same code paths.
1725 */
1726
1727var warning = warningWithoutStack$1;
1728
1729{
1730 warning = function (condition, format) {
1731 if (condition) {
1732 return;
1733 }
1734 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1735 var stack = ReactDebugCurrentFrame.getStackAddendum();
1736 // eslint-disable-next-line react-internal/warning-and-invariant-args
1737
1738 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1739 args[_key - 2] = arguments[_key];
1740 }
1741
1742 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
1743 };
1744}
1745
1746var warning$1 = warning;
1747
1748var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1749
1750var RESERVED_PROPS = {
1751 key: true,
1752 ref: true,
1753 __self: true,
1754 __source: true
1755};
1756
1757var specialPropKeyWarningShown = void 0;
1758var specialPropRefWarningShown = void 0;
1759
1760function hasValidRef(config) {
1761 {
1762 if (hasOwnProperty$1.call(config, 'ref')) {
1763 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1764 if (getter && getter.isReactWarning) {
1765 return false;
1766 }
1767 }
1768 }
1769 return config.ref !== undefined;
1770}
1771
1772function hasValidKey(config) {
1773 {
1774 if (hasOwnProperty$1.call(config, 'key')) {
1775 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1776 if (getter && getter.isReactWarning) {
1777 return false;
1778 }
1779 }
1780 }
1781 return config.key !== undefined;
1782}
1783
1784function defineKeyPropWarningGetter(props, displayName) {
1785 var warnAboutAccessingKey = function () {
1786 if (!specialPropKeyWarningShown) {
1787 specialPropKeyWarningShown = true;
1788 warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
1789 }
1790 };
1791 warnAboutAccessingKey.isReactWarning = true;
1792 Object.defineProperty(props, 'key', {
1793 get: warnAboutAccessingKey,
1794 configurable: true
1795 });
1796}
1797
1798function defineRefPropWarningGetter(props, displayName) {
1799 var warnAboutAccessingRef = function () {
1800 if (!specialPropRefWarningShown) {
1801 specialPropRefWarningShown = true;
1802 warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
1803 }
1804 };
1805 warnAboutAccessingRef.isReactWarning = true;
1806 Object.defineProperty(props, 'ref', {
1807 get: warnAboutAccessingRef,
1808 configurable: true
1809 });
1810}
1811
1812/**
1813 * Factory method to create a new React element. This no longer adheres to
1814 * the class pattern, so do not use new to call it. Also, no instanceof check
1815 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
1816 * if something is a React Element.
1817 *
1818 * @param {*} type
1819 * @param {*} key
1820 * @param {string|object} ref
1821 * @param {*} self A *temporary* helper to detect places where `this` is
1822 * different from the `owner` when React.createElement is called, so that we
1823 * can warn. We want to get rid of owner and replace string `ref`s with arrow
1824 * functions, and as long as `this` and owner are the same, there will be no
1825 * change in behavior.
1826 * @param {*} source An annotation object (added by a transpiler or otherwise)
1827 * indicating filename, line number, and/or other information.
1828 * @param {*} owner
1829 * @param {*} props
1830 * @internal
1831 */
1832var ReactElement = function (type, key, ref, self, source, owner, props) {
1833 var element = {
1834 // This tag allows us to uniquely identify this as a React Element
1835 $$typeof: REACT_ELEMENT_TYPE,
1836
1837 // Built-in properties that belong on the element
1838 type: type,
1839 key: key,
1840 ref: ref,
1841 props: props,
1842
1843 // Record the component responsible for creating this element.
1844 _owner: owner
1845 };
1846
1847 {
1848 // The validation flag is currently mutative. We put it on
1849 // an external backing store so that we can freeze the whole object.
1850 // This can be replaced with a WeakMap once they are implemented in
1851 // commonly used development environments.
1852 element._store = {};
1853
1854 // To make comparing ReactElements easier for testing purposes, we make
1855 // the validation flag non-enumerable (where possible, which should
1856 // include every environment we run tests in), so the test framework
1857 // ignores it.
1858 Object.defineProperty(element._store, 'validated', {
1859 configurable: false,
1860 enumerable: false,
1861 writable: true,
1862 value: false
1863 });
1864 // self and source are DEV only properties.
1865 Object.defineProperty(element, '_self', {
1866 configurable: false,
1867 enumerable: false,
1868 writable: false,
1869 value: self
1870 });
1871 // Two elements created in two different places should be considered
1872 // equal for testing purposes and therefore we hide it from enumeration.
1873 Object.defineProperty(element, '_source', {
1874 configurable: false,
1875 enumerable: false,
1876 writable: false,
1877 value: source
1878 });
1879 if (Object.freeze) {
1880 Object.freeze(element.props);
1881 Object.freeze(element);
1882 }
1883 }
1884
1885 return element;
1886};
1887
1888/**
1889 * Create and return a new ReactElement of the given type.
1890 * See https://reactjs.org/docs/react-api.html#createelement
1891 */
1892function createElement(type, config, children) {
1893 var propName = void 0;
1894
1895 // Reserved names are extracted
1896 var props = {};
1897
1898 var key = null;
1899 var ref = null;
1900 var self = null;
1901 var source = null;
1902
1903 if (config != null) {
1904 if (hasValidRef(config)) {
1905 ref = config.ref;
1906 }
1907 if (hasValidKey(config)) {
1908 key = '' + config.key;
1909 }
1910
1911 self = config.__self === undefined ? null : config.__self;
1912 source = config.__source === undefined ? null : config.__source;
1913 // Remaining properties are added to a new props object
1914 for (propName in config) {
1915 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1916 props[propName] = config[propName];
1917 }
1918 }
1919 }
1920
1921 // Children can be more than one argument, and those are transferred onto
1922 // the newly allocated props object.
1923 var childrenLength = arguments.length - 2;
1924 if (childrenLength === 1) {
1925 props.children = children;
1926 } else if (childrenLength > 1) {
1927 var childArray = Array(childrenLength);
1928 for (var i = 0; i < childrenLength; i++) {
1929 childArray[i] = arguments[i + 2];
1930 }
1931 {
1932 if (Object.freeze) {
1933 Object.freeze(childArray);
1934 }
1935 }
1936 props.children = childArray;
1937 }
1938
1939 // Resolve default props
1940 if (type && type.defaultProps) {
1941 var defaultProps = type.defaultProps;
1942 for (propName in defaultProps) {
1943 if (props[propName] === undefined) {
1944 props[propName] = defaultProps[propName];
1945 }
1946 }
1947 }
1948 {
1949 if (key || ref) {
1950 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1951 if (key) {
1952 defineKeyPropWarningGetter(props, displayName);
1953 }
1954 if (ref) {
1955 defineRefPropWarningGetter(props, displayName);
1956 }
1957 }
1958 }
1959 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1960}
1961
1962/**
1963 * Return a function that produces ReactElements of a given type.
1964 * See https://reactjs.org/docs/react-api.html#createfactory
1965 */
1966
1967
1968function cloneAndReplaceKey(oldElement, newKey) {
1969 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
1970
1971 return newElement;
1972}
1973
1974/**
1975 * Clone and return a new ReactElement using element as the starting point.
1976 * See https://reactjs.org/docs/react-api.html#cloneelement
1977 */
1978function cloneElement(element, config, children) {
1979 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
1980
1981 var propName = void 0;
1982
1983 // Original props are copied
1984 var props = objectAssign({}, element.props);
1985
1986 // Reserved names are extracted
1987 var key = element.key;
1988 var ref = element.ref;
1989 // Self is preserved since the owner is preserved.
1990 var self = element._self;
1991 // Source is preserved since cloneElement is unlikely to be targeted by a
1992 // transpiler, and the original source is probably a better indicator of the
1993 // true owner.
1994 var source = element._source;
1995
1996 // Owner will be preserved, unless ref is overridden
1997 var owner = element._owner;
1998
1999 if (config != null) {
2000 if (hasValidRef(config)) {
2001 // Silently steal the ref from the parent.
2002 ref = config.ref;
2003 owner = ReactCurrentOwner.current;
2004 }
2005 if (hasValidKey(config)) {
2006 key = '' + config.key;
2007 }
2008
2009 // Remaining properties override existing props
2010 var defaultProps = void 0;
2011 if (element.type && element.type.defaultProps) {
2012 defaultProps = element.type.defaultProps;
2013 }
2014 for (propName in config) {
2015 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
2016 if (config[propName] === undefined && defaultProps !== undefined) {
2017 // Resolve default props
2018 props[propName] = defaultProps[propName];
2019 } else {
2020 props[propName] = config[propName];
2021 }
2022 }
2023 }
2024 }
2025
2026 // Children can be more than one argument, and those are transferred onto
2027 // the newly allocated props object.
2028 var childrenLength = arguments.length - 2;
2029 if (childrenLength === 1) {
2030 props.children = children;
2031 } else if (childrenLength > 1) {
2032 var childArray = Array(childrenLength);
2033 for (var i = 0; i < childrenLength; i++) {
2034 childArray[i] = arguments[i + 2];
2035 }
2036 props.children = childArray;
2037 }
2038
2039 return ReactElement(element.type, key, ref, self, source, owner, props);
2040}
2041
2042/**
2043 * Verifies the object is a ReactElement.
2044 * See https://reactjs.org/docs/react-api.html#isvalidelement
2045 * @param {?object} object
2046 * @return {boolean} True if `object` is a ReactElement.
2047 * @final
2048 */
2049function isValidElement(object) {
2050 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2051}
2052
2053var SEPARATOR = '.';
2054var SUBSEPARATOR = ':';
2055
2056/**
2057 * Escape and wrap key so it is safe to use as a reactid
2058 *
2059 * @param {string} key to be escaped.
2060 * @return {string} the escaped key.
2061 */
2062function escape(key) {
2063 var escapeRegex = /[=:]/g;
2064 var escaperLookup = {
2065 '=': '=0',
2066 ':': '=2'
2067 };
2068 var escapedString = ('' + key).replace(escapeRegex, function (match) {
2069 return escaperLookup[match];
2070 });
2071
2072 return '$' + escapedString;
2073}
2074
2075/**
2076 * TODO: Test that a single child and an array with one item have the same key
2077 * pattern.
2078 */
2079
2080var didWarnAboutMaps = false;
2081
2082var userProvidedKeyEscapeRegex = /\/+/g;
2083function escapeUserProvidedKey(text) {
2084 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
2085}
2086
2087var POOL_SIZE = 10;
2088var traverseContextPool = [];
2089function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
2090 if (traverseContextPool.length) {
2091 var traverseContext = traverseContextPool.pop();
2092 traverseContext.result = mapResult;
2093 traverseContext.keyPrefix = keyPrefix;
2094 traverseContext.func = mapFunction;
2095 traverseContext.context = mapContext;
2096 traverseContext.count = 0;
2097 return traverseContext;
2098 } else {
2099 return {
2100 result: mapResult,
2101 keyPrefix: keyPrefix,
2102 func: mapFunction,
2103 context: mapContext,
2104 count: 0
2105 };
2106 }
2107}
2108
2109function releaseTraverseContext(traverseContext) {
2110 traverseContext.result = null;
2111 traverseContext.keyPrefix = null;
2112 traverseContext.func = null;
2113 traverseContext.context = null;
2114 traverseContext.count = 0;
2115 if (traverseContextPool.length < POOL_SIZE) {
2116 traverseContextPool.push(traverseContext);
2117 }
2118}
2119
2120/**
2121 * @param {?*} children Children tree container.
2122 * @param {!string} nameSoFar Name of the key path so far.
2123 * @param {!function} callback Callback to invoke with each child found.
2124 * @param {?*} traverseContext Used to pass information throughout the traversal
2125 * process.
2126 * @return {!number} The number of children in this subtree.
2127 */
2128function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
2129 var type = typeof children;
2130
2131 if (type === 'undefined' || type === 'boolean') {
2132 // All of the above are perceived as null.
2133 children = null;
2134 }
2135
2136 var invokeCallback = false;
2137
2138 if (children === null) {
2139 invokeCallback = true;
2140 } else {
2141 switch (type) {
2142 case 'string':
2143 case 'number':
2144 invokeCallback = true;
2145 break;
2146 case 'object':
2147 switch (children.$$typeof) {
2148 case REACT_ELEMENT_TYPE:
2149 case REACT_PORTAL_TYPE:
2150 invokeCallback = true;
2151 }
2152 }
2153 }
2154
2155 if (invokeCallback) {
2156 callback(traverseContext, children,
2157 // If it's the only child, treat the name as if it was wrapped in an array
2158 // so that it's consistent if the number of children grows.
2159 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
2160 return 1;
2161 }
2162
2163 var child = void 0;
2164 var nextName = void 0;
2165 var subtreeCount = 0; // Count of children found in the current subtree.
2166 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
2167
2168 if (Array.isArray(children)) {
2169 for (var i = 0; i < children.length; i++) {
2170 child = children[i];
2171 nextName = nextNamePrefix + getComponentKey(child, i);
2172 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2173 }
2174 } else {
2175 var iteratorFn = getIteratorFn(children);
2176 if (typeof iteratorFn === 'function') {
2177 {
2178 // Warn about using Maps as children
2179 if (iteratorFn === children.entries) {
2180 !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
2181 didWarnAboutMaps = true;
2182 }
2183 }
2184
2185 var iterator = iteratorFn.call(children);
2186 var step = void 0;
2187 var ii = 0;
2188 while (!(step = iterator.next()).done) {
2189 child = step.value;
2190 nextName = nextNamePrefix + getComponentKey(child, ii++);
2191 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2192 }
2193 } else if (type === 'object') {
2194 var addendum = '';
2195 {
2196 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
2197 }
2198 var childrenString = '' + children;
2199 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
2200 }
2201 }
2202
2203 return subtreeCount;
2204}
2205
2206/**
2207 * Traverses children that are typically specified as `props.children`, but
2208 * might also be specified through attributes:
2209 *
2210 * - `traverseAllChildren(this.props.children, ...)`
2211 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
2212 *
2213 * The `traverseContext` is an optional argument that is passed through the
2214 * entire traversal. It can be used to store accumulations or anything else that
2215 * the callback might find relevant.
2216 *
2217 * @param {?*} children Children tree object.
2218 * @param {!function} callback To invoke upon traversing each child.
2219 * @param {?*} traverseContext Context for traversal.
2220 * @return {!number} The number of children in this subtree.
2221 */
2222function traverseAllChildren(children, callback, traverseContext) {
2223 if (children == null) {
2224 return 0;
2225 }
2226
2227 return traverseAllChildrenImpl(children, '', callback, traverseContext);
2228}
2229
2230/**
2231 * Generate a key string that identifies a component within a set.
2232 *
2233 * @param {*} component A component that could contain a manual key.
2234 * @param {number} index Index that is used if a manual key is not provided.
2235 * @return {string}
2236 */
2237function getComponentKey(component, index) {
2238 // Do some typechecking here since we call this blindly. We want to ensure
2239 // that we don't block potential future ES APIs.
2240 if (typeof component === 'object' && component !== null && component.key != null) {
2241 // Explicit key
2242 return escape(component.key);
2243 }
2244 // Implicit key determined by the index in the set
2245 return index.toString(36);
2246}
2247
2248function forEachSingleChild(bookKeeping, child, name) {
2249 var func = bookKeeping.func,
2250 context = bookKeeping.context;
2251
2252 func.call(context, child, bookKeeping.count++);
2253}
2254
2255/**
2256 * Iterates through children that are typically specified as `props.children`.
2257 *
2258 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
2259 *
2260 * The provided forEachFunc(child, index) will be called for each
2261 * leaf child.
2262 *
2263 * @param {?*} children Children tree container.
2264 * @param {function(*, int)} forEachFunc
2265 * @param {*} forEachContext Context for forEachContext.
2266 */
2267function forEachChildren(children, forEachFunc, forEachContext) {
2268 if (children == null) {
2269 return children;
2270 }
2271 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
2272 traverseAllChildren(children, forEachSingleChild, traverseContext);
2273 releaseTraverseContext(traverseContext);
2274}
2275
2276function mapSingleChildIntoContext(bookKeeping, child, childKey) {
2277 var result = bookKeeping.result,
2278 keyPrefix = bookKeeping.keyPrefix,
2279 func = bookKeeping.func,
2280 context = bookKeeping.context;
2281
2282
2283 var mappedChild = func.call(context, child, bookKeeping.count++);
2284 if (Array.isArray(mappedChild)) {
2285 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
2286 return c;
2287 });
2288 } else if (mappedChild != null) {
2289 if (isValidElement(mappedChild)) {
2290 mappedChild = cloneAndReplaceKey(mappedChild,
2291 // Keep both the (mapped) and old keys if they differ, just as
2292 // traverseAllChildren used to do for objects as children
2293 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
2294 }
2295 result.push(mappedChild);
2296 }
2297}
2298
2299function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
2300 var escapedPrefix = '';
2301 if (prefix != null) {
2302 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
2303 }
2304 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
2305 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
2306 releaseTraverseContext(traverseContext);
2307}
2308
2309/**
2310 * Maps children that are typically specified as `props.children`.
2311 *
2312 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
2313 *
2314 * The provided mapFunction(child, key, index) will be called for each
2315 * leaf child.
2316 *
2317 * @param {?*} children Children tree container.
2318 * @param {function(*, int)} func The map function.
2319 * @param {*} context Context for mapFunction.
2320 * @return {object} Object containing the ordered map of results.
2321 */
2322function mapChildren(children, func, context) {
2323 if (children == null) {
2324 return children;
2325 }
2326 var result = [];
2327 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
2328 return result;
2329}
2330
2331/**
2332 * Count the number of children that are typically specified as
2333 * `props.children`.
2334 *
2335 * See https://reactjs.org/docs/react-api.html#reactchildrencount
2336 *
2337 * @param {?*} children Children tree container.
2338 * @return {number} The number of children.
2339 */
2340function countChildren(children) {
2341 return traverseAllChildren(children, function () {
2342 return null;
2343 }, null);
2344}
2345
2346/**
2347 * Flatten a children object (typically specified as `props.children`) and
2348 * return an array with appropriately re-keyed children.
2349 *
2350 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
2351 */
2352function toArray(children) {
2353 var result = [];
2354 mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
2355 return child;
2356 });
2357 return result;
2358}
2359
2360/**
2361 * Returns the first child in a collection of children and verifies that there
2362 * is only one child in the collection.
2363 *
2364 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
2365 *
2366 * The current implementation of this function assumes that a single child gets
2367 * passed without a wrapper, but the purpose of this helper function is to
2368 * abstract away the particular structure of children.
2369 *
2370 * @param {?object} children Child collection structure.
2371 * @return {ReactElement} The first and only `ReactElement` contained in the
2372 * structure.
2373 */
2374function onlyChild(children) {
2375 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
2376 return children;
2377}
2378
2379function createContext(defaultValue, calculateChangedBits) {
2380 if (calculateChangedBits === undefined) {
2381 calculateChangedBits = null;
2382 } else {
2383 {
2384 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
2385 }
2386 }
2387
2388 var context = {
2389 $$typeof: REACT_CONTEXT_TYPE,
2390 _calculateChangedBits: calculateChangedBits,
2391 // As a workaround to support multiple concurrent renderers, we categorize
2392 // some renderers as primary and others as secondary. We only expect
2393 // there to be two concurrent renderers at most: React Native (primary) and
2394 // Fabric (secondary); React DOM (primary) and React ART (secondary).
2395 // Secondary renderers store their context values on separate fields.
2396 _currentValue: defaultValue,
2397 _currentValue2: defaultValue,
2398 // Used to track how many concurrent renderers this context currently
2399 // supports within in a single renderer. Such as parallel server rendering.
2400 _threadCount: 0,
2401 // These are circular
2402 Provider: null,
2403 Consumer: null
2404 };
2405
2406 context.Provider = {
2407 $$typeof: REACT_PROVIDER_TYPE,
2408 _context: context
2409 };
2410
2411 var hasWarnedAboutUsingNestedContextConsumers = false;
2412 var hasWarnedAboutUsingConsumerProvider = false;
2413
2414 {
2415 // A separate object, but proxies back to the original context object for
2416 // backwards compatibility. It has a different $$typeof, so we can properly
2417 // warn for the incorrect usage of Context as a Consumer.
2418 var Consumer = {
2419 $$typeof: REACT_CONTEXT_TYPE,
2420 _context: context,
2421 _calculateChangedBits: context._calculateChangedBits
2422 };
2423 // $FlowFixMe: Flow complains about not setting a value, which is intentional here
2424 Object.defineProperties(Consumer, {
2425 Provider: {
2426 get: function () {
2427 if (!hasWarnedAboutUsingConsumerProvider) {
2428 hasWarnedAboutUsingConsumerProvider = true;
2429 warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
2430 }
2431 return context.Provider;
2432 },
2433 set: function (_Provider) {
2434 context.Provider = _Provider;
2435 }
2436 },
2437 _currentValue: {
2438 get: function () {
2439 return context._currentValue;
2440 },
2441 set: function (_currentValue) {
2442 context._currentValue = _currentValue;
2443 }
2444 },
2445 _currentValue2: {
2446 get: function () {
2447 return context._currentValue2;
2448 },
2449 set: function (_currentValue2) {
2450 context._currentValue2 = _currentValue2;
2451 }
2452 },
2453 _threadCount: {
2454 get: function () {
2455 return context._threadCount;
2456 },
2457 set: function (_threadCount) {
2458 context._threadCount = _threadCount;
2459 }
2460 },
2461 Consumer: {
2462 get: function () {
2463 if (!hasWarnedAboutUsingNestedContextConsumers) {
2464 hasWarnedAboutUsingNestedContextConsumers = true;
2465 warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
2466 }
2467 return context.Consumer;
2468 }
2469 }
2470 });
2471 // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
2472 context.Consumer = Consumer;
2473 }
2474
2475 {
2476 context._currentRenderer = null;
2477 context._currentRenderer2 = null;
2478 }
2479
2480 return context;
2481}
2482
2483function lazy(ctor) {
2484 var lazyType = {
2485 $$typeof: REACT_LAZY_TYPE,
2486 _ctor: ctor,
2487 // React uses these fields to store the result.
2488 _status: -1,
2489 _result: null
2490 };
2491
2492 {
2493 // In production, this would just set it on the object.
2494 var defaultProps = void 0;
2495 var propTypes = void 0;
2496 Object.defineProperties(lazyType, {
2497 defaultProps: {
2498 configurable: true,
2499 get: function () {
2500 return defaultProps;
2501 },
2502 set: function (newDefaultProps) {
2503 warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
2504 defaultProps = newDefaultProps;
2505 // Match production behavior more closely:
2506 Object.defineProperty(lazyType, 'defaultProps', {
2507 enumerable: true
2508 });
2509 }
2510 },
2511 propTypes: {
2512 configurable: true,
2513 get: function () {
2514 return propTypes;
2515 },
2516 set: function (newPropTypes) {
2517 warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
2518 propTypes = newPropTypes;
2519 // Match production behavior more closely:
2520 Object.defineProperty(lazyType, 'propTypes', {
2521 enumerable: true
2522 });
2523 }
2524 }
2525 });
2526 }
2527
2528 return lazyType;
2529}
2530
2531function forwardRef(render) {
2532 {
2533 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
2534 warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
2535 } else if (typeof render !== 'function') {
2536 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2537 } else {
2538 !(
2539 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
2540 render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
2541 }
2542
2543 if (render != null) {
2544 !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
2545 }
2546 }
2547
2548 return {
2549 $$typeof: REACT_FORWARD_REF_TYPE,
2550 render: render
2551 };
2552}
2553
2554function isValidElementType(type) {
2555 return typeof type === 'string' || typeof type === 'function' ||
2556 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2557 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
2558}
2559
2560function memo(type, compare) {
2561 {
2562 if (!isValidElementType(type)) {
2563 warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
2564 }
2565 }
2566 return {
2567 $$typeof: REACT_MEMO_TYPE,
2568 type: type,
2569 compare: compare === undefined ? null : compare
2570 };
2571}
2572
2573function resolveDispatcher() {
2574 var dispatcher = ReactCurrentOwner.currentDispatcher;
2575 !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
2576 return dispatcher;
2577}
2578
2579function useContext(Context, observedBits) {
2580 var dispatcher = resolveDispatcher();
2581 {
2582 // TODO: add a more generic warning for invalid values.
2583 if (Context._context !== undefined) {
2584 var realContext = Context._context;
2585 // Don't deduplicate because this legitimately causes bugs
2586 // and nobody should be using this in existing code.
2587 if (realContext.Consumer === Context) {
2588 warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
2589 } else if (realContext.Provider === Context) {
2590 warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
2591 }
2592 }
2593 }
2594 return dispatcher.useContext(Context, observedBits);
2595}
2596
2597function useState(initialState) {
2598 var dispatcher = resolveDispatcher();
2599 return dispatcher.useState(initialState);
2600}
2601
2602function useReducer(reducer, initialState, initialAction) {
2603 var dispatcher = resolveDispatcher();
2604 return dispatcher.useReducer(reducer, initialState, initialAction);
2605}
2606
2607function useRef(initialValue) {
2608 var dispatcher = resolveDispatcher();
2609 return dispatcher.useRef(initialValue);
2610}
2611
2612function useEffect(create, inputs) {
2613 var dispatcher = resolveDispatcher();
2614 return dispatcher.useEffect(create, inputs);
2615}
2616
2617function useLayoutEffect(create, inputs) {
2618 var dispatcher = resolveDispatcher();
2619 return dispatcher.useLayoutEffect(create, inputs);
2620}
2621
2622function useCallback(callback, inputs) {
2623 var dispatcher = resolveDispatcher();
2624 return dispatcher.useCallback(callback, inputs);
2625}
2626
2627function useMemo(create, inputs) {
2628 var dispatcher = resolveDispatcher();
2629 return dispatcher.useMemo(create, inputs);
2630}
2631
2632function useImperativeMethods(ref, create, inputs) {
2633 var dispatcher = resolveDispatcher();
2634 return dispatcher.useImperativeMethods(ref, create, inputs);
2635}
2636
2637/**
2638 * Copyright (c) 2013-present, Facebook, Inc.
2639 *
2640 * This source code is licensed under the MIT license found in the
2641 * LICENSE file in the root directory of this source tree.
2642 */
2643
2644
2645
2646var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2647
2648var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
2649
2650/**
2651 * Copyright (c) 2013-present, Facebook, Inc.
2652 *
2653 * This source code is licensed under the MIT license found in the
2654 * LICENSE file in the root directory of this source tree.
2655 */
2656
2657
2658
2659var printWarning$1 = function() {};
2660
2661{
2662 var ReactPropTypesSecret = ReactPropTypesSecret_1;
2663 var loggedTypeFailures = {};
2664
2665 printWarning$1 = function(text) {
2666 var message = 'Warning: ' + text;
2667 if (typeof console !== 'undefined') {
2668 console.error(message);
2669 }
2670 try {
2671 // --- Welcome to debugging React ---
2672 // This error was thrown as a convenience so that you can use this stack
2673 // to find the callsite that caused this warning to fire.
2674 throw new Error(message);
2675 } catch (x) {}
2676 };
2677}
2678
2679/**
2680 * Assert that the values match with the type specs.
2681 * Error messages are memorized and will only be shown once.
2682 *
2683 * @param {object} typeSpecs Map of name to a ReactPropType
2684 * @param {object} values Runtime values that need to be type-checked
2685 * @param {string} location e.g. "prop", "context", "child context"
2686 * @param {string} componentName Name of the component for error messages.
2687 * @param {?Function} getStack Returns the component stack.
2688 * @private
2689 */
2690function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
2691 {
2692 for (var typeSpecName in typeSpecs) {
2693 if (typeSpecs.hasOwnProperty(typeSpecName)) {
2694 var error;
2695 // Prop type validation may throw. In case they do, we don't want to
2696 // fail the render phase where it didn't fail before. So we log it.
2697 // After these have been cleaned up, we'll let them throw.
2698 try {
2699 // This is intentionally an invariant that gets caught. It's the same
2700 // behavior as without this statement except with a better message.
2701 if (typeof typeSpecs[typeSpecName] !== 'function') {
2702 var err = Error(
2703 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
2704 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
2705 );
2706 err.name = 'Invariant Violation';
2707 throw err;
2708 }
2709 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
2710 } catch (ex) {
2711 error = ex;
2712 }
2713 if (error && !(error instanceof Error)) {
2714 printWarning$1(
2715 (componentName || 'React class') + ': type specification of ' +
2716 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
2717 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
2718 'You may have forgotten to pass an argument to the type checker ' +
2719 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
2720 'shape all require an argument).'
2721 );
2722
2723 }
2724 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
2725 // Only monitor this failure once because there tends to be a lot of the
2726 // same error.
2727 loggedTypeFailures[error.message] = true;
2728
2729 var stack = getStack ? getStack() : '';
2730
2731 printWarning$1(
2732 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
2733 );
2734 }
2735 }
2736 }
2737 }
2738}
2739
2740var checkPropTypes_1 = checkPropTypes;
2741
2742/**
2743 * ReactElementValidator provides a wrapper around a element factory
2744 * which validates the props passed to the element. This is intended to be
2745 * used only in DEV and could be replaced by a static type checker for languages
2746 * that support it.
2747 */
2748
2749var propTypesMisspellWarningShown = void 0;
2750
2751{
2752 propTypesMisspellWarningShown = false;
2753}
2754
2755function getDeclarationErrorAddendum() {
2756 if (ReactCurrentOwner.current) {
2757 var name = getComponentName(ReactCurrentOwner.current.type);
2758 if (name) {
2759 return '\n\nCheck the render method of `' + name + '`.';
2760 }
2761 }
2762 return '';
2763}
2764
2765function getSourceInfoErrorAddendum(elementProps) {
2766 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
2767 var source = elementProps.__source;
2768 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2769 var lineNumber = source.lineNumber;
2770 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2771 }
2772 return '';
2773}
2774
2775/**
2776 * Warn if there's no key explicitly set on dynamic arrays of children or
2777 * object keys are not valid. This allows us to keep track of children between
2778 * updates.
2779 */
2780var ownerHasKeyUseWarning = {};
2781
2782function getCurrentComponentErrorInfo(parentType) {
2783 var info = getDeclarationErrorAddendum();
2784
2785 if (!info) {
2786 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2787 if (parentName) {
2788 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
2789 }
2790 }
2791 return info;
2792}
2793
2794/**
2795 * Warn if the element doesn't have an explicit key assigned to it.
2796 * This element is in an array. The array could grow and shrink or be
2797 * reordered. All children that haven't already been validated are required to
2798 * have a "key" property assigned to it. Error statuses are cached so a warning
2799 * will only be shown once.
2800 *
2801 * @internal
2802 * @param {ReactElement} element Element that requires a key.
2803 * @param {*} parentType element's parent's type.
2804 */
2805function validateExplicitKey(element, parentType) {
2806 if (!element._store || element._store.validated || element.key != null) {
2807 return;
2808 }
2809 element._store.validated = true;
2810
2811 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2812 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2813 return;
2814 }
2815 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
2816
2817 // Usually the current owner is the offender, but if it accepts children as a
2818 // property, it may be the creator of the child that's responsible for
2819 // assigning it a key.
2820 var childOwner = '';
2821 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2822 // Give the component that originally created this child.
2823 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
2824 }
2825
2826 setCurrentlyValidatingElement(element);
2827 {
2828 warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
2829 }
2830 setCurrentlyValidatingElement(null);
2831}
2832
2833/**
2834 * Ensure that every element either is passed in a static location, in an
2835 * array with an explicit keys property defined, or in an object literal
2836 * with valid key property.
2837 *
2838 * @internal
2839 * @param {ReactNode} node Statically passed child of any type.
2840 * @param {*} parentType node's parent's type.
2841 */
2842function validateChildKeys(node, parentType) {
2843 if (typeof node !== 'object') {
2844 return;
2845 }
2846 if (Array.isArray(node)) {
2847 for (var i = 0; i < node.length; i++) {
2848 var child = node[i];
2849 if (isValidElement(child)) {
2850 validateExplicitKey(child, parentType);
2851 }
2852 }
2853 } else if (isValidElement(node)) {
2854 // This element was passed in a valid location.
2855 if (node._store) {
2856 node._store.validated = true;
2857 }
2858 } else if (node) {
2859 var iteratorFn = getIteratorFn(node);
2860 if (typeof iteratorFn === 'function') {
2861 // Entry iterators used to provide implicit keys,
2862 // but now we print a separate warning for them later.
2863 if (iteratorFn !== node.entries) {
2864 var iterator = iteratorFn.call(node);
2865 var step = void 0;
2866 while (!(step = iterator.next()).done) {
2867 if (isValidElement(step.value)) {
2868 validateExplicitKey(step.value, parentType);
2869 }
2870 }
2871 }
2872 }
2873 }
2874}
2875
2876/**
2877 * Given an element, validate that its props follow the propTypes definition,
2878 * provided by the type.
2879 *
2880 * @param {ReactElement} element
2881 */
2882function validatePropTypes(element) {
2883 var type = element.type;
2884 if (type === null || type === undefined || typeof type === 'string') {
2885 return;
2886 }
2887 var name = getComponentName(type);
2888 var propTypes = void 0;
2889 if (typeof type === 'function') {
2890 propTypes = type.propTypes;
2891 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
2892 // Note: Memo only checks outer props here.
2893 // Inner props are checked in the reconciler.
2894 type.$$typeof === REACT_MEMO_TYPE)) {
2895 propTypes = type.propTypes;
2896 } else {
2897 return;
2898 }
2899 if (propTypes) {
2900 setCurrentlyValidatingElement(element);
2901 checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
2902 setCurrentlyValidatingElement(null);
2903 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2904 propTypesMisspellWarningShown = true;
2905 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
2906 }
2907 if (typeof type.getDefaultProps === 'function') {
2908 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
2909 }
2910}
2911
2912/**
2913 * Given a fragment, validate that it can only be provided with fragment props
2914 * @param {ReactElement} fragment
2915 */
2916function validateFragmentProps(fragment) {
2917 setCurrentlyValidatingElement(fragment);
2918
2919 var keys = Object.keys(fragment.props);
2920 for (var i = 0; i < keys.length; i++) {
2921 var key = keys[i];
2922 if (key !== 'children' && key !== 'key') {
2923 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2924 break;
2925 }
2926 }
2927
2928 if (fragment.ref !== null) {
2929 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
2930 }
2931
2932 setCurrentlyValidatingElement(null);
2933}
2934
2935function createElementWithValidation(type, props, children) {
2936 var validType = isValidElementType(type);
2937
2938 // We warn in this case but don't throw. We expect the element creation to
2939 // succeed and there will likely be errors in render.
2940 if (!validType) {
2941 var info = '';
2942 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2943 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
2944 }
2945
2946 var sourceInfo = getSourceInfoErrorAddendum(props);
2947 if (sourceInfo) {
2948 info += sourceInfo;
2949 } else {
2950 info += getDeclarationErrorAddendum();
2951 }
2952
2953 var typeString = void 0;
2954 if (type === null) {
2955 typeString = 'null';
2956 } else if (Array.isArray(type)) {
2957 typeString = 'array';
2958 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2959 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
2960 info = ' Did you accidentally export a JSX literal instead of a component?';
2961 } else {
2962 typeString = typeof type;
2963 }
2964
2965 warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
2966 }
2967
2968 var element = createElement.apply(this, arguments);
2969
2970 // The result can be nullish if a mock or a custom function is used.
2971 // TODO: Drop this when these are no longer allowed as the type argument.
2972 if (element == null) {
2973 return element;
2974 }
2975
2976 // Skip key warning if the type isn't valid since our key validation logic
2977 // doesn't expect a non-string/function type and can throw confusing errors.
2978 // We don't want exception behavior to differ between dev and prod.
2979 // (Rendering will throw with a helpful message and as soon as the type is
2980 // fixed, the key warnings will appear.)
2981 if (validType) {
2982 for (var i = 2; i < arguments.length; i++) {
2983 validateChildKeys(arguments[i], type);
2984 }
2985 }
2986
2987 if (type === REACT_FRAGMENT_TYPE) {
2988 validateFragmentProps(element);
2989 } else {
2990 validatePropTypes(element);
2991 }
2992
2993 return element;
2994}
2995
2996function createFactoryWithValidation(type) {
2997 var validatedFactory = createElementWithValidation.bind(null, type);
2998 validatedFactory.type = type;
2999 // Legacy hook: remove it
3000 {
3001 Object.defineProperty(validatedFactory, 'type', {
3002 enumerable: false,
3003 get: function () {
3004 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
3005 Object.defineProperty(this, 'type', {
3006 value: type
3007 });
3008 return type;
3009 }
3010 });
3011 }
3012
3013 return validatedFactory;
3014}
3015
3016function cloneElementWithValidation(element, props, children) {
3017 var newElement = cloneElement.apply(this, arguments);
3018 for (var i = 2; i < arguments.length; i++) {
3019 validateChildKeys(arguments[i], newElement.type);
3020 }
3021 validatePropTypes(newElement);
3022 return newElement;
3023}
3024
3025var React = {
3026 Children: {
3027 map: mapChildren,
3028 forEach: forEachChildren,
3029 count: countChildren,
3030 toArray: toArray,
3031 only: onlyChild
3032 },
3033
3034 createRef: createRef,
3035 Component: Component,
3036 PureComponent: PureComponent,
3037
3038 createContext: createContext,
3039 forwardRef: forwardRef,
3040 lazy: lazy,
3041 memo: memo,
3042
3043 Fragment: REACT_FRAGMENT_TYPE,
3044 StrictMode: REACT_STRICT_MODE_TYPE,
3045 Suspense: REACT_SUSPENSE_TYPE,
3046
3047 createElement: createElementWithValidation,
3048 cloneElement: cloneElementWithValidation,
3049 createFactory: createFactoryWithValidation,
3050 isValidElement: isValidElement,
3051
3052 version: ReactVersion,
3053
3054 unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
3055 unstable_Profiler: REACT_PROFILER_TYPE,
3056
3057 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
3058};
3059
3060// Note: some APIs are added with feature flags.
3061// Make sure that stable builds for open source
3062// don't modify the React object to avoid deopts.
3063// Also let's not expose their names in stable builds.
3064
3065if (enableStableConcurrentModeAPIs) {
3066 React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
3067 React.Profiler = REACT_PROFILER_TYPE;
3068 React.unstable_ConcurrentMode = undefined;
3069 React.unstable_Profiler = undefined;
3070}
3071
3072if (enableHooks) {
3073 React.useCallback = useCallback;
3074 React.useContext = useContext;
3075 React.useEffect = useEffect;
3076 React.useImperativeMethods = useImperativeMethods;
3077 React.useLayoutEffect = useLayoutEffect;
3078 React.useMemo = useMemo;
3079 React.useReducer = useReducer;
3080 React.useRef = useRef;
3081 React.useState = useState;
3082}
3083
3084
3085
3086var React$2 = Object.freeze({
3087 default: React
3088});
3089
3090var React$3 = ( React$2 && React ) || React$2;
3091
3092// TODO: decide on the top-level export form.
3093// This is hacky but makes it work with both Rollup and Jest.
3094var react = React$3.default || React$3;
3095
3096return react;
3097
3098})));