UNPKG

110 kBJavaScriptView Raw
1/**
2 * @license React
3 * react.development.js
4 *
5 * Copyright (c) Facebook, Inc. and its affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */
10(function (global, factory) {
11 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
12 typeof define === 'function' && define.amd ? define(['exports'], factory) :
13 (global = global || self, factory(global.React = {}));
14}(this, (function (exports) { 'use strict';
15
16 var ReactVersion = '18.1.0';
17
18 // -----------------------------------------------------------------------------
19
20 var enableScopeAPI = false; // Experimental Create Event Handle API.
21 var enableCacheElement = false;
22 var enableTransitionTracing = false; // No known bugs, but needs performance testing
23
24 var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
25 // stuff. Intended to enable React core members to more easily debug scheduling
26 // issues in DEV builds.
27
28 var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
29
30 // ATTENTION
31
32 var REACT_ELEMENT_TYPE = Symbol.for('react.element');
33 var REACT_PORTAL_TYPE = Symbol.for('react.portal');
34 var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
35 var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
36 var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
37 var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
38 var REACT_CONTEXT_TYPE = Symbol.for('react.context');
39 var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
40 var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
41 var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
42 var REACT_MEMO_TYPE = Symbol.for('react.memo');
43 var REACT_LAZY_TYPE = Symbol.for('react.lazy');
44 var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
45 var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
46 var FAUX_ITERATOR_SYMBOL = '@@iterator';
47 function getIteratorFn(maybeIterable) {
48 if (maybeIterable === null || typeof maybeIterable !== 'object') {
49 return null;
50 }
51
52 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
53
54 if (typeof maybeIterator === 'function') {
55 return maybeIterator;
56 }
57
58 return null;
59 }
60
61 /**
62 * Keeps track of the current dispatcher.
63 */
64 var ReactCurrentDispatcher = {
65 /**
66 * @internal
67 * @type {ReactComponent}
68 */
69 current: null
70 };
71
72 /**
73 * Keeps track of the current batch's configuration such as how long an update
74 * should suspend for if it needs to.
75 */
76 var ReactCurrentBatchConfig = {
77 transition: null
78 };
79
80 var ReactCurrentActQueue = {
81 current: null,
82 // Used to reproduce behavior of `batchedUpdates` in legacy mode.
83 isBatchingLegacy: false,
84 didScheduleLegacyUpdate: false
85 };
86
87 /**
88 * Keeps track of the current owner.
89 *
90 * The current owner is the component who should own any components that are
91 * currently being constructed.
92 */
93 var ReactCurrentOwner = {
94 /**
95 * @internal
96 * @type {ReactComponent}
97 */
98 current: null
99 };
100
101 var ReactDebugCurrentFrame = {};
102 var currentExtraStackFrame = null;
103 function setExtraStackFrame(stack) {
104 {
105 currentExtraStackFrame = stack;
106 }
107 }
108
109 {
110 ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {
111 {
112 currentExtraStackFrame = stack;
113 }
114 }; // Stack implementation injected by the current renderer.
115
116
117 ReactDebugCurrentFrame.getCurrentStack = null;
118
119 ReactDebugCurrentFrame.getStackAddendum = function () {
120 var stack = ''; // Add an extra top frame while an element is being validated
121
122 if (currentExtraStackFrame) {
123 stack += currentExtraStackFrame;
124 } // Delegate to the injected renderer-specific implementation
125
126
127 var impl = ReactDebugCurrentFrame.getCurrentStack;
128
129 if (impl) {
130 stack += impl() || '';
131 }
132
133 return stack;
134 };
135 }
136
137 var ReactSharedInternals = {
138 ReactCurrentDispatcher: ReactCurrentDispatcher,
139 ReactCurrentBatchConfig: ReactCurrentBatchConfig,
140 ReactCurrentOwner: ReactCurrentOwner
141 };
142
143 {
144 ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
145 ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
146 }
147
148 // by calls to these methods by a Babel plugin.
149 //
150 // In PROD (or in packages without access to React internals),
151 // they are left as they are instead.
152
153 function warn(format) {
154 {
155 {
156 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
157 args[_key - 1] = arguments[_key];
158 }
159
160 printWarning('warn', format, args);
161 }
162 }
163 }
164 function error(format) {
165 {
166 {
167 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
168 args[_key2 - 1] = arguments[_key2];
169 }
170
171 printWarning('error', format, args);
172 }
173 }
174 }
175
176 function printWarning(level, format, args) {
177 // When changing this logic, you might want to also
178 // update consoleWithStackDev.www.js as well.
179 {
180 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
181 var stack = ReactDebugCurrentFrame.getStackAddendum();
182
183 if (stack !== '') {
184 format += '%s';
185 args = args.concat([stack]);
186 } // eslint-disable-next-line react-internal/safe-string-coercion
187
188
189 var argsWithFormat = args.map(function (item) {
190 return String(item);
191 }); // Careful: RN currently depends on this prefix
192
193 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
194 // breaks IE9: https://github.com/facebook/react/issues/13610
195 // eslint-disable-next-line react-internal/no-production-logging
196
197 Function.prototype.apply.call(console[level], console, argsWithFormat);
198 }
199 }
200
201 var didWarnStateUpdateForUnmountedComponent = {};
202
203 function warnNoop(publicInstance, callerName) {
204 {
205 var _constructor = publicInstance.constructor;
206 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
207 var warningKey = componentName + "." + callerName;
208
209 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
210 return;
211 }
212
213 error("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);
214
215 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
216 }
217 }
218 /**
219 * This is the abstract API for an update queue.
220 */
221
222
223 var ReactNoopUpdateQueue = {
224 /**
225 * Checks whether or not this composite component is mounted.
226 * @param {ReactClass} publicInstance The instance we want to test.
227 * @return {boolean} True if mounted, false otherwise.
228 * @protected
229 * @final
230 */
231 isMounted: function (publicInstance) {
232 return false;
233 },
234
235 /**
236 * Forces an update. This should only be invoked when it is known with
237 * certainty that we are **not** in a DOM transaction.
238 *
239 * You may want to call this when you know that some deeper aspect of the
240 * component's state has changed but `setState` was not called.
241 *
242 * This will not invoke `shouldComponentUpdate`, but it will invoke
243 * `componentWillUpdate` and `componentDidUpdate`.
244 *
245 * @param {ReactClass} publicInstance The instance that should rerender.
246 * @param {?function} callback Called after component is updated.
247 * @param {?string} callerName name of the calling function in the public API.
248 * @internal
249 */
250 enqueueForceUpdate: function (publicInstance, callback, callerName) {
251 warnNoop(publicInstance, 'forceUpdate');
252 },
253
254 /**
255 * Replaces all of the state. Always use this or `setState` to mutate state.
256 * You should treat `this.state` as immutable.
257 *
258 * There is no guarantee that `this.state` will be immediately updated, so
259 * accessing `this.state` after calling this method may return the old value.
260 *
261 * @param {ReactClass} publicInstance The instance that should rerender.
262 * @param {object} completeState Next state.
263 * @param {?function} callback Called after component is updated.
264 * @param {?string} callerName name of the calling function in the public API.
265 * @internal
266 */
267 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
268 warnNoop(publicInstance, 'replaceState');
269 },
270
271 /**
272 * Sets a subset of the state. This only exists because _pendingState is
273 * internal. This provides a merging strategy that is not available to deep
274 * properties which is confusing. TODO: Expose pendingState or don't use it
275 * during the merge.
276 *
277 * @param {ReactClass} publicInstance The instance that should rerender.
278 * @param {object} partialState Next partial state to be merged with state.
279 * @param {?function} callback Called after component is updated.
280 * @param {?string} Name of the calling function in the public API.
281 * @internal
282 */
283 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
284 warnNoop(publicInstance, 'setState');
285 }
286 };
287
288 var assign = Object.assign;
289
290 var emptyObject = {};
291
292 {
293 Object.freeze(emptyObject);
294 }
295 /**
296 * Base class helpers for the updating state of a component.
297 */
298
299
300 function Component(props, context, updater) {
301 this.props = props;
302 this.context = context; // If a component has string refs, we will assign a different object later.
303
304 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
305 // renderer.
306
307 this.updater = updater || ReactNoopUpdateQueue;
308 }
309
310 Component.prototype.isReactComponent = {};
311 /**
312 * Sets a subset of the state. Always use this to mutate
313 * state. You should treat `this.state` as immutable.
314 *
315 * There is no guarantee that `this.state` will be immediately updated, so
316 * accessing `this.state` after calling this method may return the old value.
317 *
318 * There is no guarantee that calls to `setState` will run synchronously,
319 * as they may eventually be batched together. You can provide an optional
320 * callback that will be executed when the call to setState is actually
321 * completed.
322 *
323 * When a function is provided to setState, it will be called at some point in
324 * the future (not synchronously). It will be called with the up to date
325 * component arguments (state, props, context). These values can be different
326 * from this.* because your function may be called after receiveProps but before
327 * shouldComponentUpdate, and this new state, props, and context will not yet be
328 * assigned to this.
329 *
330 * @param {object|function} partialState Next partial state or function to
331 * produce next partial state to be merged with current state.
332 * @param {?function} callback Called after state is updated.
333 * @final
334 * @protected
335 */
336
337 Component.prototype.setState = function (partialState, callback) {
338 if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {
339 throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.');
340 }
341
342 this.updater.enqueueSetState(this, partialState, callback, 'setState');
343 };
344 /**
345 * Forces an update. This should only be invoked when it is known with
346 * certainty that we are **not** in a DOM transaction.
347 *
348 * You may want to call this when you know that some deeper aspect of the
349 * component's state has changed but `setState` was not called.
350 *
351 * This will not invoke `shouldComponentUpdate`, but it will invoke
352 * `componentWillUpdate` and `componentDidUpdate`.
353 *
354 * @param {?function} callback Called after update is complete.
355 * @final
356 * @protected
357 */
358
359
360 Component.prototype.forceUpdate = function (callback) {
361 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
362 };
363 /**
364 * Deprecated APIs. These APIs used to exist on classic React classes but since
365 * we would like to deprecate them, we're not going to move them over to this
366 * modern base class. Instead, we define a getter that warns if it's accessed.
367 */
368
369
370 {
371 var deprecatedAPIs = {
372 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
373 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
374 };
375
376 var defineDeprecationWarning = function (methodName, info) {
377 Object.defineProperty(Component.prototype, methodName, {
378 get: function () {
379 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
380
381 return undefined;
382 }
383 });
384 };
385
386 for (var fnName in deprecatedAPIs) {
387 if (deprecatedAPIs.hasOwnProperty(fnName)) {
388 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
389 }
390 }
391 }
392
393 function ComponentDummy() {}
394
395 ComponentDummy.prototype = Component.prototype;
396 /**
397 * Convenience component with default shallow equality check for sCU.
398 */
399
400 function PureComponent(props, context, updater) {
401 this.props = props;
402 this.context = context; // If a component has string refs, we will assign a different object later.
403
404 this.refs = emptyObject;
405 this.updater = updater || ReactNoopUpdateQueue;
406 }
407
408 var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
409 pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
410
411 assign(pureComponentPrototype, Component.prototype);
412 pureComponentPrototype.isPureReactComponent = true;
413
414 // an immutable object with a single mutable value
415 function createRef() {
416 var refObject = {
417 current: null
418 };
419
420 {
421 Object.seal(refObject);
422 }
423
424 return refObject;
425 }
426
427 var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
428
429 function isArray(a) {
430 return isArrayImpl(a);
431 }
432
433 /*
434 * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
435 * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
436 *
437 * The functions in this module will throw an easier-to-understand,
438 * easier-to-debug exception with a clear errors message message explaining the
439 * problem. (Instead of a confusing exception thrown inside the implementation
440 * of the `value` object).
441 */
442 // $FlowFixMe only called in DEV, so void return is not possible.
443 function typeName(value) {
444 {
445 // toStringTag is needed for namespaced types like Temporal.Instant
446 var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
447 var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
448 return type;
449 }
450 } // $FlowFixMe only called in DEV, so void return is not possible.
451
452
453 function willCoercionThrow(value) {
454 {
455 try {
456 testStringCoercion(value);
457 return false;
458 } catch (e) {
459 return true;
460 }
461 }
462 }
463
464 function testStringCoercion(value) {
465 // If you ended up here by following an exception call stack, here's what's
466 // happened: you supplied an object or symbol value to React (as a prop, key,
467 // DOM attribute, CSS property, string ref, etc.) and when React tried to
468 // coerce it to a string using `'' + value`, an exception was thrown.
469 //
470 // The most common types that will cause this exception are `Symbol` instances
471 // and Temporal objects like `Temporal.Instant`. But any object that has a
472 // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
473 // exception. (Library authors do this to prevent users from using built-in
474 // numeric operators like `+` or comparison operators like `>=` because custom
475 // methods are needed to perform accurate arithmetic or comparison.)
476 //
477 // To fix the problem, coerce this object or symbol value to a string before
478 // passing it to React. The most reliable way is usually `String(value)`.
479 //
480 // To find which value is throwing, check the browser or debugger console.
481 // Before this exception was thrown, there should be `console.error` output
482 // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
483 // problem and how that type was used: key, atrribute, input value prop, etc.
484 // In most cases, this console output also shows the component and its
485 // ancestor components where the exception happened.
486 //
487 // eslint-disable-next-line react-internal/safe-string-coercion
488 return '' + value;
489 }
490 function checkKeyStringCoercion(value) {
491 {
492 if (willCoercionThrow(value)) {
493 error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
494
495 return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
496 }
497 }
498 }
499
500 function getWrappedName(outerType, innerType, wrapperName) {
501 var displayName = outerType.displayName;
502
503 if (displayName) {
504 return displayName;
505 }
506
507 var functionName = innerType.displayName || innerType.name || '';
508 return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
509 } // Keep in sync with react-reconciler/getComponentNameFromFiber
510
511
512 function getContextName(type) {
513 return type.displayName || 'Context';
514 } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
515
516
517 function getComponentNameFromType(type) {
518 if (type == null) {
519 // Host root, text node or just invalid type.
520 return null;
521 }
522
523 {
524 if (typeof type.tag === 'number') {
525 error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
526 }
527 }
528
529 if (typeof type === 'function') {
530 return type.displayName || type.name || null;
531 }
532
533 if (typeof type === 'string') {
534 return type;
535 }
536
537 switch (type) {
538 case REACT_FRAGMENT_TYPE:
539 return 'Fragment';
540
541 case REACT_PORTAL_TYPE:
542 return 'Portal';
543
544 case REACT_PROFILER_TYPE:
545 return 'Profiler';
546
547 case REACT_STRICT_MODE_TYPE:
548 return 'StrictMode';
549
550 case REACT_SUSPENSE_TYPE:
551 return 'Suspense';
552
553 case REACT_SUSPENSE_LIST_TYPE:
554 return 'SuspenseList';
555
556 }
557
558 if (typeof type === 'object') {
559 switch (type.$$typeof) {
560 case REACT_CONTEXT_TYPE:
561 var context = type;
562 return getContextName(context) + '.Consumer';
563
564 case REACT_PROVIDER_TYPE:
565 var provider = type;
566 return getContextName(provider._context) + '.Provider';
567
568 case REACT_FORWARD_REF_TYPE:
569 return getWrappedName(type, type.render, 'ForwardRef');
570
571 case REACT_MEMO_TYPE:
572 var outerName = type.displayName || null;
573
574 if (outerName !== null) {
575 return outerName;
576 }
577
578 return getComponentNameFromType(type.type) || 'Memo';
579
580 case REACT_LAZY_TYPE:
581 {
582 var lazyComponent = type;
583 var payload = lazyComponent._payload;
584 var init = lazyComponent._init;
585
586 try {
587 return getComponentNameFromType(init(payload));
588 } catch (x) {
589 return null;
590 }
591 }
592
593 // eslint-disable-next-line no-fallthrough
594 }
595 }
596
597 return null;
598 }
599
600 var hasOwnProperty = Object.prototype.hasOwnProperty;
601
602 var RESERVED_PROPS = {
603 key: true,
604 ref: true,
605 __self: true,
606 __source: true
607 };
608 var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
609
610 {
611 didWarnAboutStringRefs = {};
612 }
613
614 function hasValidRef(config) {
615 {
616 if (hasOwnProperty.call(config, 'ref')) {
617 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
618
619 if (getter && getter.isReactWarning) {
620 return false;
621 }
622 }
623 }
624
625 return config.ref !== undefined;
626 }
627
628 function hasValidKey(config) {
629 {
630 if (hasOwnProperty.call(config, 'key')) {
631 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
632
633 if (getter && getter.isReactWarning) {
634 return false;
635 }
636 }
637 }
638
639 return config.key !== undefined;
640 }
641
642 function defineKeyPropWarningGetter(props, displayName) {
643 var warnAboutAccessingKey = function () {
644 {
645 if (!specialPropKeyWarningShown) {
646 specialPropKeyWarningShown = true;
647
648 error('%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://reactjs.org/link/special-props)', displayName);
649 }
650 }
651 };
652
653 warnAboutAccessingKey.isReactWarning = true;
654 Object.defineProperty(props, 'key', {
655 get: warnAboutAccessingKey,
656 configurable: true
657 });
658 }
659
660 function defineRefPropWarningGetter(props, displayName) {
661 var warnAboutAccessingRef = function () {
662 {
663 if (!specialPropRefWarningShown) {
664 specialPropRefWarningShown = true;
665
666 error('%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://reactjs.org/link/special-props)', displayName);
667 }
668 }
669 };
670
671 warnAboutAccessingRef.isReactWarning = true;
672 Object.defineProperty(props, 'ref', {
673 get: warnAboutAccessingRef,
674 configurable: true
675 });
676 }
677
678 function warnIfStringRefCannotBeAutoConverted(config) {
679 {
680 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
681 var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
682
683 if (!didWarnAboutStringRefs[componentName]) {
684 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
685
686 didWarnAboutStringRefs[componentName] = true;
687 }
688 }
689 }
690 }
691 /**
692 * Factory method to create a new React element. This no longer adheres to
693 * the class pattern, so do not use new to call it. Also, instanceof check
694 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
695 * if something is a React Element.
696 *
697 * @param {*} type
698 * @param {*} props
699 * @param {*} key
700 * @param {string|object} ref
701 * @param {*} owner
702 * @param {*} self A *temporary* helper to detect places where `this` is
703 * different from the `owner` when React.createElement is called, so that we
704 * can warn. We want to get rid of owner and replace string `ref`s with arrow
705 * functions, and as long as `this` and owner are the same, there will be no
706 * change in behavior.
707 * @param {*} source An annotation object (added by a transpiler or otherwise)
708 * indicating filename, line number, and/or other information.
709 * @internal
710 */
711
712
713 var ReactElement = function (type, key, ref, self, source, owner, props) {
714 var element = {
715 // This tag allows us to uniquely identify this as a React Element
716 $$typeof: REACT_ELEMENT_TYPE,
717 // Built-in properties that belong on the element
718 type: type,
719 key: key,
720 ref: ref,
721 props: props,
722 // Record the component responsible for creating this element.
723 _owner: owner
724 };
725
726 {
727 // The validation flag is currently mutative. We put it on
728 // an external backing store so that we can freeze the whole object.
729 // This can be replaced with a WeakMap once they are implemented in
730 // commonly used development environments.
731 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
732 // the validation flag non-enumerable (where possible, which should
733 // include every environment we run tests in), so the test framework
734 // ignores it.
735
736 Object.defineProperty(element._store, 'validated', {
737 configurable: false,
738 enumerable: false,
739 writable: true,
740 value: false
741 }); // self and source are DEV only properties.
742
743 Object.defineProperty(element, '_self', {
744 configurable: false,
745 enumerable: false,
746 writable: false,
747 value: self
748 }); // Two elements created in two different places should be considered
749 // equal for testing purposes and therefore we hide it from enumeration.
750
751 Object.defineProperty(element, '_source', {
752 configurable: false,
753 enumerable: false,
754 writable: false,
755 value: source
756 });
757
758 if (Object.freeze) {
759 Object.freeze(element.props);
760 Object.freeze(element);
761 }
762 }
763
764 return element;
765 };
766 /**
767 * Create and return a new ReactElement of the given type.
768 * See https://reactjs.org/docs/react-api.html#createelement
769 */
770
771 function createElement(type, config, children) {
772 var propName; // Reserved names are extracted
773
774 var props = {};
775 var key = null;
776 var ref = null;
777 var self = null;
778 var source = null;
779
780 if (config != null) {
781 if (hasValidRef(config)) {
782 ref = config.ref;
783
784 {
785 warnIfStringRefCannotBeAutoConverted(config);
786 }
787 }
788
789 if (hasValidKey(config)) {
790 {
791 checkKeyStringCoercion(config.key);
792 }
793
794 key = '' + config.key;
795 }
796
797 self = config.__self === undefined ? null : config.__self;
798 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
799
800 for (propName in config) {
801 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
802 props[propName] = config[propName];
803 }
804 }
805 } // Children can be more than one argument, and those are transferred onto
806 // the newly allocated props object.
807
808
809 var childrenLength = arguments.length - 2;
810
811 if (childrenLength === 1) {
812 props.children = children;
813 } else if (childrenLength > 1) {
814 var childArray = Array(childrenLength);
815
816 for (var i = 0; i < childrenLength; i++) {
817 childArray[i] = arguments[i + 2];
818 }
819
820 {
821 if (Object.freeze) {
822 Object.freeze(childArray);
823 }
824 }
825
826 props.children = childArray;
827 } // Resolve default props
828
829
830 if (type && type.defaultProps) {
831 var defaultProps = type.defaultProps;
832
833 for (propName in defaultProps) {
834 if (props[propName] === undefined) {
835 props[propName] = defaultProps[propName];
836 }
837 }
838 }
839
840 {
841 if (key || ref) {
842 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
843
844 if (key) {
845 defineKeyPropWarningGetter(props, displayName);
846 }
847
848 if (ref) {
849 defineRefPropWarningGetter(props, displayName);
850 }
851 }
852 }
853
854 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
855 }
856 function cloneAndReplaceKey(oldElement, newKey) {
857 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
858 return newElement;
859 }
860 /**
861 * Clone and return a new ReactElement using element as the starting point.
862 * See https://reactjs.org/docs/react-api.html#cloneelement
863 */
864
865 function cloneElement(element, config, children) {
866 if (element === null || element === undefined) {
867 throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
868 }
869
870 var propName; // Original props are copied
871
872 var props = assign({}, element.props); // Reserved names are extracted
873
874 var key = element.key;
875 var ref = element.ref; // Self is preserved since the owner is preserved.
876
877 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
878 // transpiler, and the original source is probably a better indicator of the
879 // true owner.
880
881 var source = element._source; // Owner will be preserved, unless ref is overridden
882
883 var owner = element._owner;
884
885 if (config != null) {
886 if (hasValidRef(config)) {
887 // Silently steal the ref from the parent.
888 ref = config.ref;
889 owner = ReactCurrentOwner.current;
890 }
891
892 if (hasValidKey(config)) {
893 {
894 checkKeyStringCoercion(config.key);
895 }
896
897 key = '' + config.key;
898 } // Remaining properties override existing props
899
900
901 var defaultProps;
902
903 if (element.type && element.type.defaultProps) {
904 defaultProps = element.type.defaultProps;
905 }
906
907 for (propName in config) {
908 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
909 if (config[propName] === undefined && defaultProps !== undefined) {
910 // Resolve default props
911 props[propName] = defaultProps[propName];
912 } else {
913 props[propName] = config[propName];
914 }
915 }
916 }
917 } // Children can be more than one argument, and those are transferred onto
918 // the newly allocated props object.
919
920
921 var childrenLength = arguments.length - 2;
922
923 if (childrenLength === 1) {
924 props.children = children;
925 } else if (childrenLength > 1) {
926 var childArray = Array(childrenLength);
927
928 for (var i = 0; i < childrenLength; i++) {
929 childArray[i] = arguments[i + 2];
930 }
931
932 props.children = childArray;
933 }
934
935 return ReactElement(element.type, key, ref, self, source, owner, props);
936 }
937 /**
938 * Verifies the object is a ReactElement.
939 * See https://reactjs.org/docs/react-api.html#isvalidelement
940 * @param {?object} object
941 * @return {boolean} True if `object` is a ReactElement.
942 * @final
943 */
944
945 function isValidElement(object) {
946 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
947 }
948
949 var SEPARATOR = '.';
950 var SUBSEPARATOR = ':';
951 /**
952 * Escape and wrap key so it is safe to use as a reactid
953 *
954 * @param {string} key to be escaped.
955 * @return {string} the escaped key.
956 */
957
958 function escape(key) {
959 var escapeRegex = /[=:]/g;
960 var escaperLookup = {
961 '=': '=0',
962 ':': '=2'
963 };
964 var escapedString = key.replace(escapeRegex, function (match) {
965 return escaperLookup[match];
966 });
967 return '$' + escapedString;
968 }
969 /**
970 * TODO: Test that a single child and an array with one item have the same key
971 * pattern.
972 */
973
974
975 var didWarnAboutMaps = false;
976 var userProvidedKeyEscapeRegex = /\/+/g;
977
978 function escapeUserProvidedKey(text) {
979 return text.replace(userProvidedKeyEscapeRegex, '$&/');
980 }
981 /**
982 * Generate a key string that identifies a element within a set.
983 *
984 * @param {*} element A element that could contain a manual key.
985 * @param {number} index Index that is used if a manual key is not provided.
986 * @return {string}
987 */
988
989
990 function getElementKey(element, index) {
991 // Do some typechecking here since we call this blindly. We want to ensure
992 // that we don't block potential future ES APIs.
993 if (typeof element === 'object' && element !== null && element.key != null) {
994 // Explicit key
995 {
996 checkKeyStringCoercion(element.key);
997 }
998
999 return escape('' + element.key);
1000 } // Implicit key determined by the index in the set
1001
1002
1003 return index.toString(36);
1004 }
1005
1006 function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1007 var type = typeof children;
1008
1009 if (type === 'undefined' || type === 'boolean') {
1010 // All of the above are perceived as null.
1011 children = null;
1012 }
1013
1014 var invokeCallback = false;
1015
1016 if (children === null) {
1017 invokeCallback = true;
1018 } else {
1019 switch (type) {
1020 case 'string':
1021 case 'number':
1022 invokeCallback = true;
1023 break;
1024
1025 case 'object':
1026 switch (children.$$typeof) {
1027 case REACT_ELEMENT_TYPE:
1028 case REACT_PORTAL_TYPE:
1029 invokeCallback = true;
1030 }
1031
1032 }
1033 }
1034
1035 if (invokeCallback) {
1036 var _child = children;
1037 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array
1038 // so that it's consistent if the number of children grows:
1039
1040 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
1041
1042 if (isArray(mappedChild)) {
1043 var escapedChildKey = '';
1044
1045 if (childKey != null) {
1046 escapedChildKey = escapeUserProvidedKey(childKey) + '/';
1047 }
1048
1049 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
1050 return c;
1051 });
1052 } else if (mappedChild != null) {
1053 if (isValidElement(mappedChild)) {
1054 {
1055 // The `if` statement here prevents auto-disabling of the safe
1056 // coercion ESLint rule, so we must manually disable it below.
1057 // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1058 if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
1059 checkKeyStringCoercion(mappedChild.key);
1060 }
1061 }
1062
1063 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
1064 // traverseAllChildren used to do for objects as children
1065 escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1066 mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
1067 // eslint-disable-next-line react-internal/safe-string-coercion
1068 escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);
1069 }
1070
1071 array.push(mappedChild);
1072 }
1073
1074 return 1;
1075 }
1076
1077 var child;
1078 var nextName;
1079 var subtreeCount = 0; // Count of children found in the current subtree.
1080
1081 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1082
1083 if (isArray(children)) {
1084 for (var i = 0; i < children.length; i++) {
1085 child = children[i];
1086 nextName = nextNamePrefix + getElementKey(child, i);
1087 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1088 }
1089 } else {
1090 var iteratorFn = getIteratorFn(children);
1091
1092 if (typeof iteratorFn === 'function') {
1093 var iterableChildren = children;
1094
1095 {
1096 // Warn about using Maps as children
1097 if (iteratorFn === iterableChildren.entries) {
1098 if (!didWarnAboutMaps) {
1099 warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
1100 }
1101
1102 didWarnAboutMaps = true;
1103 }
1104 }
1105
1106 var iterator = iteratorFn.call(iterableChildren);
1107 var step;
1108 var ii = 0;
1109
1110 while (!(step = iterator.next()).done) {
1111 child = step.value;
1112 nextName = nextNamePrefix + getElementKey(child, ii++);
1113 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1114 }
1115 } else if (type === 'object') {
1116 // eslint-disable-next-line react-internal/safe-string-coercion
1117 var childrenString = String(children);
1118 throw new Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
1119 }
1120 }
1121
1122 return subtreeCount;
1123 }
1124
1125 /**
1126 * Maps children that are typically specified as `props.children`.
1127 *
1128 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
1129 *
1130 * The provided mapFunction(child, index) will be called for each
1131 * leaf child.
1132 *
1133 * @param {?*} children Children tree container.
1134 * @param {function(*, int)} func The map function.
1135 * @param {*} context Context for mapFunction.
1136 * @return {object} Object containing the ordered map of results.
1137 */
1138 function mapChildren(children, func, context) {
1139 if (children == null) {
1140 return children;
1141 }
1142
1143 var result = [];
1144 var count = 0;
1145 mapIntoArray(children, result, '', '', function (child) {
1146 return func.call(context, child, count++);
1147 });
1148 return result;
1149 }
1150 /**
1151 * Count the number of children that are typically specified as
1152 * `props.children`.
1153 *
1154 * See https://reactjs.org/docs/react-api.html#reactchildrencount
1155 *
1156 * @param {?*} children Children tree container.
1157 * @return {number} The number of children.
1158 */
1159
1160
1161 function countChildren(children) {
1162 var n = 0;
1163 mapChildren(children, function () {
1164 n++; // Don't return anything
1165 });
1166 return n;
1167 }
1168
1169 /**
1170 * Iterates through children that are typically specified as `props.children`.
1171 *
1172 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
1173 *
1174 * The provided forEachFunc(child, index) will be called for each
1175 * leaf child.
1176 *
1177 * @param {?*} children Children tree container.
1178 * @param {function(*, int)} forEachFunc
1179 * @param {*} forEachContext Context for forEachContext.
1180 */
1181 function forEachChildren(children, forEachFunc, forEachContext) {
1182 mapChildren(children, function () {
1183 forEachFunc.apply(this, arguments); // Don't return anything.
1184 }, forEachContext);
1185 }
1186 /**
1187 * Flatten a children object (typically specified as `props.children`) and
1188 * return an array with appropriately re-keyed children.
1189 *
1190 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
1191 */
1192
1193
1194 function toArray(children) {
1195 return mapChildren(children, function (child) {
1196 return child;
1197 }) || [];
1198 }
1199 /**
1200 * Returns the first child in a collection of children and verifies that there
1201 * is only one child in the collection.
1202 *
1203 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
1204 *
1205 * The current implementation of this function assumes that a single child gets
1206 * passed without a wrapper, but the purpose of this helper function is to
1207 * abstract away the particular structure of children.
1208 *
1209 * @param {?object} children Child collection structure.
1210 * @return {ReactElement} The first and only `ReactElement` contained in the
1211 * structure.
1212 */
1213
1214
1215 function onlyChild(children) {
1216 if (!isValidElement(children)) {
1217 throw new Error('React.Children.only expected to receive a single React element child.');
1218 }
1219
1220 return children;
1221 }
1222
1223 function createContext(defaultValue) {
1224 // TODO: Second argument used to be an optional `calculateChangedBits`
1225 // function. Warn to reserve for future use?
1226 var context = {
1227 $$typeof: REACT_CONTEXT_TYPE,
1228 // As a workaround to support multiple concurrent renderers, we categorize
1229 // some renderers as primary and others as secondary. We only expect
1230 // there to be two concurrent renderers at most: React Native (primary) and
1231 // Fabric (secondary); React DOM (primary) and React ART (secondary).
1232 // Secondary renderers store their context values on separate fields.
1233 _currentValue: defaultValue,
1234 _currentValue2: defaultValue,
1235 // Used to track how many concurrent renderers this context currently
1236 // supports within in a single renderer. Such as parallel server rendering.
1237 _threadCount: 0,
1238 // These are circular
1239 Provider: null,
1240 Consumer: null,
1241 // Add these to use same hidden class in VM as ServerContext
1242 _defaultValue: null,
1243 _globalName: null
1244 };
1245 context.Provider = {
1246 $$typeof: REACT_PROVIDER_TYPE,
1247 _context: context
1248 };
1249 var hasWarnedAboutUsingNestedContextConsumers = false;
1250 var hasWarnedAboutUsingConsumerProvider = false;
1251 var hasWarnedAboutDisplayNameOnConsumer = false;
1252
1253 {
1254 // A separate object, but proxies back to the original context object for
1255 // backwards compatibility. It has a different $$typeof, so we can properly
1256 // warn for the incorrect usage of Context as a Consumer.
1257 var Consumer = {
1258 $$typeof: REACT_CONTEXT_TYPE,
1259 _context: context
1260 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1261
1262 Object.defineProperties(Consumer, {
1263 Provider: {
1264 get: function () {
1265 if (!hasWarnedAboutUsingConsumerProvider) {
1266 hasWarnedAboutUsingConsumerProvider = true;
1267
1268 error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
1269 }
1270
1271 return context.Provider;
1272 },
1273 set: function (_Provider) {
1274 context.Provider = _Provider;
1275 }
1276 },
1277 _currentValue: {
1278 get: function () {
1279 return context._currentValue;
1280 },
1281 set: function (_currentValue) {
1282 context._currentValue = _currentValue;
1283 }
1284 },
1285 _currentValue2: {
1286 get: function () {
1287 return context._currentValue2;
1288 },
1289 set: function (_currentValue2) {
1290 context._currentValue2 = _currentValue2;
1291 }
1292 },
1293 _threadCount: {
1294 get: function () {
1295 return context._threadCount;
1296 },
1297 set: function (_threadCount) {
1298 context._threadCount = _threadCount;
1299 }
1300 },
1301 Consumer: {
1302 get: function () {
1303 if (!hasWarnedAboutUsingNestedContextConsumers) {
1304 hasWarnedAboutUsingNestedContextConsumers = true;
1305
1306 error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
1307 }
1308
1309 return context.Consumer;
1310 }
1311 },
1312 displayName: {
1313 get: function () {
1314 return context.displayName;
1315 },
1316 set: function (displayName) {
1317 if (!hasWarnedAboutDisplayNameOnConsumer) {
1318 warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName);
1319
1320 hasWarnedAboutDisplayNameOnConsumer = true;
1321 }
1322 }
1323 }
1324 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1325
1326 context.Consumer = Consumer;
1327 }
1328
1329 {
1330 context._currentRenderer = null;
1331 context._currentRenderer2 = null;
1332 }
1333
1334 return context;
1335 }
1336
1337 var Uninitialized = -1;
1338 var Pending = 0;
1339 var Resolved = 1;
1340 var Rejected = 2;
1341
1342 function lazyInitializer(payload) {
1343 if (payload._status === Uninitialized) {
1344 var ctor = payload._result;
1345 var thenable = ctor(); // Transition to the next state.
1346 // This might throw either because it's missing or throws. If so, we treat it
1347 // as still uninitialized and try again next time. Which is the same as what
1348 // happens if the ctor or any wrappers processing the ctor throws. This might
1349 // end up fixing it if the resolution was a concurrency bug.
1350
1351 thenable.then(function (moduleObject) {
1352 if (payload._status === Pending || payload._status === Uninitialized) {
1353 // Transition to the next state.
1354 var resolved = payload;
1355 resolved._status = Resolved;
1356 resolved._result = moduleObject;
1357 }
1358 }, function (error) {
1359 if (payload._status === Pending || payload._status === Uninitialized) {
1360 // Transition to the next state.
1361 var rejected = payload;
1362 rejected._status = Rejected;
1363 rejected._result = error;
1364 }
1365 });
1366
1367 if (payload._status === Uninitialized) {
1368 // In case, we're still uninitialized, then we're waiting for the thenable
1369 // to resolve. Set it as pending in the meantime.
1370 var pending = payload;
1371 pending._status = Pending;
1372 pending._result = thenable;
1373 }
1374 }
1375
1376 if (payload._status === Resolved) {
1377 var moduleObject = payload._result;
1378
1379 {
1380 if (moduleObject === undefined) {
1381 error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
1382 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject);
1383 }
1384 }
1385
1386 {
1387 if (!('default' in moduleObject)) {
1388 error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
1389 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
1390 }
1391 }
1392
1393 return moduleObject.default;
1394 } else {
1395 throw payload._result;
1396 }
1397 }
1398
1399 function lazy(ctor) {
1400 var payload = {
1401 // We use these fields to store the result.
1402 _status: Uninitialized,
1403 _result: ctor
1404 };
1405 var lazyType = {
1406 $$typeof: REACT_LAZY_TYPE,
1407 _payload: payload,
1408 _init: lazyInitializer
1409 };
1410
1411 {
1412 // In production, this would just set it on the object.
1413 var defaultProps;
1414 var propTypes; // $FlowFixMe
1415
1416 Object.defineProperties(lazyType, {
1417 defaultProps: {
1418 configurable: true,
1419 get: function () {
1420 return defaultProps;
1421 },
1422 set: function (newDefaultProps) {
1423 error('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.');
1424
1425 defaultProps = newDefaultProps; // Match production behavior more closely:
1426 // $FlowFixMe
1427
1428 Object.defineProperty(lazyType, 'defaultProps', {
1429 enumerable: true
1430 });
1431 }
1432 },
1433 propTypes: {
1434 configurable: true,
1435 get: function () {
1436 return propTypes;
1437 },
1438 set: function (newPropTypes) {
1439 error('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.');
1440
1441 propTypes = newPropTypes; // Match production behavior more closely:
1442 // $FlowFixMe
1443
1444 Object.defineProperty(lazyType, 'propTypes', {
1445 enumerable: true
1446 });
1447 }
1448 }
1449 });
1450 }
1451
1452 return lazyType;
1453 }
1454
1455 function forwardRef(render) {
1456 {
1457 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1458 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
1459 } else if (typeof render !== 'function') {
1460 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1461 } else {
1462 if (render.length !== 0 && render.length !== 2) {
1463 error('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.');
1464 }
1465 }
1466
1467 if (render != null) {
1468 if (render.defaultProps != null || render.propTypes != null) {
1469 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
1470 }
1471 }
1472 }
1473
1474 var elementType = {
1475 $$typeof: REACT_FORWARD_REF_TYPE,
1476 render: render
1477 };
1478
1479 {
1480 var ownName;
1481 Object.defineProperty(elementType, 'displayName', {
1482 enumerable: false,
1483 configurable: true,
1484 get: function () {
1485 return ownName;
1486 },
1487 set: function (name) {
1488 ownName = name; // The inner component shouldn't inherit this display name in most cases,
1489 // because the component may be used elsewhere.
1490 // But it's nice for anonymous functions to inherit the name,
1491 // so that our component-stack generation logic will display their frames.
1492 // An anonymous function generally suggests a pattern like:
1493 // React.forwardRef((props, ref) => {...});
1494 // This kind of inner function is not used elsewhere so the side effect is okay.
1495
1496 if (!render.name && !render.displayName) {
1497 render.displayName = name;
1498 }
1499 }
1500 });
1501 }
1502
1503 return elementType;
1504 }
1505
1506 var REACT_MODULE_REFERENCE;
1507
1508 {
1509 REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
1510 }
1511
1512 function isValidElementType(type) {
1513 if (typeof type === 'string' || typeof type === 'function') {
1514 return true;
1515 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1516
1517
1518 if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
1519 return true;
1520 }
1521
1522 if (typeof type === 'object' && type !== null) {
1523 if (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 || // This needs to include all possible module reference object
1524 // types supported by any Flight configuration anywhere since
1525 // we don't know which Flight build this will end up being used
1526 // with.
1527 type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
1528 return true;
1529 }
1530 }
1531
1532 return false;
1533 }
1534
1535 function memo(type, compare) {
1536 {
1537 if (!isValidElementType(type)) {
1538 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1539 }
1540 }
1541
1542 var elementType = {
1543 $$typeof: REACT_MEMO_TYPE,
1544 type: type,
1545 compare: compare === undefined ? null : compare
1546 };
1547
1548 {
1549 var ownName;
1550 Object.defineProperty(elementType, 'displayName', {
1551 enumerable: false,
1552 configurable: true,
1553 get: function () {
1554 return ownName;
1555 },
1556 set: function (name) {
1557 ownName = name; // The inner component shouldn't inherit this display name in most cases,
1558 // because the component may be used elsewhere.
1559 // But it's nice for anonymous functions to inherit the name,
1560 // so that our component-stack generation logic will display their frames.
1561 // An anonymous function generally suggests a pattern like:
1562 // React.memo((props) => {...});
1563 // This kind of inner function is not used elsewhere so the side effect is okay.
1564
1565 if (!type.name && !type.displayName) {
1566 type.displayName = name;
1567 }
1568 }
1569 });
1570 }
1571
1572 return elementType;
1573 }
1574
1575 function resolveDispatcher() {
1576 var dispatcher = ReactCurrentDispatcher.current;
1577
1578 {
1579 if (dispatcher === null) {
1580 error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
1581 }
1582 } // Will result in a null access error if accessed outside render phase. We
1583 // intentionally don't throw our own error because this is in a hot path.
1584 // Also helps ensure this is inlined.
1585
1586
1587 return dispatcher;
1588 }
1589 function useContext(Context) {
1590 var dispatcher = resolveDispatcher();
1591
1592 {
1593 // TODO: add a more generic warning for invalid values.
1594 if (Context._context !== undefined) {
1595 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
1596 // and nobody should be using this in existing code.
1597
1598 if (realContext.Consumer === Context) {
1599 error('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?');
1600 } else if (realContext.Provider === Context) {
1601 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1602 }
1603 }
1604 }
1605
1606 return dispatcher.useContext(Context);
1607 }
1608 function useState(initialState) {
1609 var dispatcher = resolveDispatcher();
1610 return dispatcher.useState(initialState);
1611 }
1612 function useReducer(reducer, initialArg, init) {
1613 var dispatcher = resolveDispatcher();
1614 return dispatcher.useReducer(reducer, initialArg, init);
1615 }
1616 function useRef(initialValue) {
1617 var dispatcher = resolveDispatcher();
1618 return dispatcher.useRef(initialValue);
1619 }
1620 function useEffect(create, deps) {
1621 var dispatcher = resolveDispatcher();
1622 return dispatcher.useEffect(create, deps);
1623 }
1624 function useInsertionEffect(create, deps) {
1625 var dispatcher = resolveDispatcher();
1626 return dispatcher.useInsertionEffect(create, deps);
1627 }
1628 function useLayoutEffect(create, deps) {
1629 var dispatcher = resolveDispatcher();
1630 return dispatcher.useLayoutEffect(create, deps);
1631 }
1632 function useCallback(callback, deps) {
1633 var dispatcher = resolveDispatcher();
1634 return dispatcher.useCallback(callback, deps);
1635 }
1636 function useMemo(create, deps) {
1637 var dispatcher = resolveDispatcher();
1638 return dispatcher.useMemo(create, deps);
1639 }
1640 function useImperativeHandle(ref, create, deps) {
1641 var dispatcher = resolveDispatcher();
1642 return dispatcher.useImperativeHandle(ref, create, deps);
1643 }
1644 function useDebugValue(value, formatterFn) {
1645 {
1646 var dispatcher = resolveDispatcher();
1647 return dispatcher.useDebugValue(value, formatterFn);
1648 }
1649 }
1650 function useTransition() {
1651 var dispatcher = resolveDispatcher();
1652 return dispatcher.useTransition();
1653 }
1654 function useDeferredValue(value) {
1655 var dispatcher = resolveDispatcher();
1656 return dispatcher.useDeferredValue(value);
1657 }
1658 function useId() {
1659 var dispatcher = resolveDispatcher();
1660 return dispatcher.useId();
1661 }
1662 function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
1663 var dispatcher = resolveDispatcher();
1664 return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
1665 }
1666
1667 // Helpers to patch console.logs to avoid logging during side-effect free
1668 // replaying on render function. This currently only patches the object
1669 // lazily which won't cover if the log function was extracted eagerly.
1670 // We could also eagerly patch the method.
1671 var disabledDepth = 0;
1672 var prevLog;
1673 var prevInfo;
1674 var prevWarn;
1675 var prevError;
1676 var prevGroup;
1677 var prevGroupCollapsed;
1678 var prevGroupEnd;
1679
1680 function disabledLog() {}
1681
1682 disabledLog.__reactDisabledLog = true;
1683 function disableLogs() {
1684 {
1685 if (disabledDepth === 0) {
1686 /* eslint-disable react-internal/no-production-logging */
1687 prevLog = console.log;
1688 prevInfo = console.info;
1689 prevWarn = console.warn;
1690 prevError = console.error;
1691 prevGroup = console.group;
1692 prevGroupCollapsed = console.groupCollapsed;
1693 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
1694
1695 var props = {
1696 configurable: true,
1697 enumerable: true,
1698 value: disabledLog,
1699 writable: true
1700 }; // $FlowFixMe Flow thinks console is immutable.
1701
1702 Object.defineProperties(console, {
1703 info: props,
1704 log: props,
1705 warn: props,
1706 error: props,
1707 group: props,
1708 groupCollapsed: props,
1709 groupEnd: props
1710 });
1711 /* eslint-enable react-internal/no-production-logging */
1712 }
1713
1714 disabledDepth++;
1715 }
1716 }
1717 function reenableLogs() {
1718 {
1719 disabledDepth--;
1720
1721 if (disabledDepth === 0) {
1722 /* eslint-disable react-internal/no-production-logging */
1723 var props = {
1724 configurable: true,
1725 enumerable: true,
1726 writable: true
1727 }; // $FlowFixMe Flow thinks console is immutable.
1728
1729 Object.defineProperties(console, {
1730 log: assign({}, props, {
1731 value: prevLog
1732 }),
1733 info: assign({}, props, {
1734 value: prevInfo
1735 }),
1736 warn: assign({}, props, {
1737 value: prevWarn
1738 }),
1739 error: assign({}, props, {
1740 value: prevError
1741 }),
1742 group: assign({}, props, {
1743 value: prevGroup
1744 }),
1745 groupCollapsed: assign({}, props, {
1746 value: prevGroupCollapsed
1747 }),
1748 groupEnd: assign({}, props, {
1749 value: prevGroupEnd
1750 })
1751 });
1752 /* eslint-enable react-internal/no-production-logging */
1753 }
1754
1755 if (disabledDepth < 0) {
1756 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
1757 }
1758 }
1759 }
1760
1761 var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
1762 var prefix;
1763 function describeBuiltInComponentFrame(name, source, ownerFn) {
1764 {
1765 if (prefix === undefined) {
1766 // Extract the VM specific prefix used by each line.
1767 try {
1768 throw Error();
1769 } catch (x) {
1770 var match = x.stack.trim().match(/\n( *(at )?)/);
1771 prefix = match && match[1] || '';
1772 }
1773 } // We use the prefix to ensure our stacks line up with native stack frames.
1774
1775
1776 return '\n' + prefix + name;
1777 }
1778 }
1779 var reentry = false;
1780 var componentFrameCache;
1781
1782 {
1783 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
1784 componentFrameCache = new PossiblyWeakMap();
1785 }
1786
1787 function describeNativeComponentFrame(fn, construct) {
1788 // If something asked for a stack inside a fake render, it should get ignored.
1789 if ( !fn || reentry) {
1790 return '';
1791 }
1792
1793 {
1794 var frame = componentFrameCache.get(fn);
1795
1796 if (frame !== undefined) {
1797 return frame;
1798 }
1799 }
1800
1801 var control;
1802 reentry = true;
1803 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
1804
1805 Error.prepareStackTrace = undefined;
1806 var previousDispatcher;
1807
1808 {
1809 previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function
1810 // for warnings.
1811
1812 ReactCurrentDispatcher$1.current = null;
1813 disableLogs();
1814 }
1815
1816 try {
1817 // This should throw.
1818 if (construct) {
1819 // Something should be setting the props in the constructor.
1820 var Fake = function () {
1821 throw Error();
1822 }; // $FlowFixMe
1823
1824
1825 Object.defineProperty(Fake.prototype, 'props', {
1826 set: function () {
1827 // We use a throwing setter instead of frozen or non-writable props
1828 // because that won't throw in a non-strict mode function.
1829 throw Error();
1830 }
1831 });
1832
1833 if (typeof Reflect === 'object' && Reflect.construct) {
1834 // We construct a different control for this case to include any extra
1835 // frames added by the construct call.
1836 try {
1837 Reflect.construct(Fake, []);
1838 } catch (x) {
1839 control = x;
1840 }
1841
1842 Reflect.construct(fn, [], Fake);
1843 } else {
1844 try {
1845 Fake.call();
1846 } catch (x) {
1847 control = x;
1848 }
1849
1850 fn.call(Fake.prototype);
1851 }
1852 } else {
1853 try {
1854 throw Error();
1855 } catch (x) {
1856 control = x;
1857 }
1858
1859 fn();
1860 }
1861 } catch (sample) {
1862 // This is inlined manually because closure doesn't do it for us.
1863 if (sample && control && typeof sample.stack === 'string') {
1864 // This extracts the first frame from the sample that isn't also in the control.
1865 // Skipping one frame that we assume is the frame that calls the two.
1866 var sampleLines = sample.stack.split('\n');
1867 var controlLines = control.stack.split('\n');
1868 var s = sampleLines.length - 1;
1869 var c = controlLines.length - 1;
1870
1871 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
1872 // We expect at least one stack frame to be shared.
1873 // Typically this will be the root most one. However, stack frames may be
1874 // cut off due to maximum stack limits. In this case, one maybe cut off
1875 // earlier than the other. We assume that the sample is longer or the same
1876 // and there for cut off earlier. So we should find the root most frame in
1877 // the sample somewhere in the control.
1878 c--;
1879 }
1880
1881 for (; s >= 1 && c >= 0; s--, c--) {
1882 // Next we find the first one that isn't the same which should be the
1883 // frame that called our sample function and the control.
1884 if (sampleLines[s] !== controlLines[c]) {
1885 // In V8, the first line is describing the message but other VMs don't.
1886 // If we're about to return the first line, and the control is also on the same
1887 // line, that's a pretty good indicator that our sample threw at same line as
1888 // the control. I.e. before we entered the sample frame. So we ignore this result.
1889 // This can happen if you passed a class to function component, or non-function.
1890 if (s !== 1 || c !== 1) {
1891 do {
1892 s--;
1893 c--; // We may still have similar intermediate frames from the construct call.
1894 // The next one that isn't the same should be our match though.
1895
1896 if (c < 0 || sampleLines[s] !== controlLines[c]) {
1897 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
1898 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
1899 // but we have a user-provided "displayName"
1900 // splice it in to make the stack more readable.
1901
1902
1903 if (fn.displayName && _frame.includes('<anonymous>')) {
1904 _frame = _frame.replace('<anonymous>', fn.displayName);
1905 }
1906
1907 {
1908 if (typeof fn === 'function') {
1909 componentFrameCache.set(fn, _frame);
1910 }
1911 } // Return the line we found.
1912
1913
1914 return _frame;
1915 }
1916 } while (s >= 1 && c >= 0);
1917 }
1918
1919 break;
1920 }
1921 }
1922 }
1923 } finally {
1924 reentry = false;
1925
1926 {
1927 ReactCurrentDispatcher$1.current = previousDispatcher;
1928 reenableLogs();
1929 }
1930
1931 Error.prepareStackTrace = previousPrepareStackTrace;
1932 } // Fallback to just using the name if we couldn't make it throw.
1933
1934
1935 var name = fn ? fn.displayName || fn.name : '';
1936 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
1937
1938 {
1939 if (typeof fn === 'function') {
1940 componentFrameCache.set(fn, syntheticFrame);
1941 }
1942 }
1943
1944 return syntheticFrame;
1945 }
1946 function describeFunctionComponentFrame(fn, source, ownerFn) {
1947 {
1948 return describeNativeComponentFrame(fn, false);
1949 }
1950 }
1951
1952 function shouldConstruct(Component) {
1953 var prototype = Component.prototype;
1954 return !!(prototype && prototype.isReactComponent);
1955 }
1956
1957 function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
1958
1959 if (type == null) {
1960 return '';
1961 }
1962
1963 if (typeof type === 'function') {
1964 {
1965 return describeNativeComponentFrame(type, shouldConstruct(type));
1966 }
1967 }
1968
1969 if (typeof type === 'string') {
1970 return describeBuiltInComponentFrame(type);
1971 }
1972
1973 switch (type) {
1974 case REACT_SUSPENSE_TYPE:
1975 return describeBuiltInComponentFrame('Suspense');
1976
1977 case REACT_SUSPENSE_LIST_TYPE:
1978 return describeBuiltInComponentFrame('SuspenseList');
1979 }
1980
1981 if (typeof type === 'object') {
1982 switch (type.$$typeof) {
1983 case REACT_FORWARD_REF_TYPE:
1984 return describeFunctionComponentFrame(type.render);
1985
1986 case REACT_MEMO_TYPE:
1987 // Memo may contain any component type so we recursively resolve it.
1988 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1989
1990 case REACT_LAZY_TYPE:
1991 {
1992 var lazyComponent = type;
1993 var payload = lazyComponent._payload;
1994 var init = lazyComponent._init;
1995
1996 try {
1997 // Lazy may contain any component type so we recursively resolve it.
1998 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
1999 } catch (x) {}
2000 }
2001 }
2002 }
2003
2004 return '';
2005 }
2006
2007 var loggedTypeFailures = {};
2008 var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
2009
2010 function setCurrentlyValidatingElement(element) {
2011 {
2012 if (element) {
2013 var owner = element._owner;
2014 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
2015 ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
2016 } else {
2017 ReactDebugCurrentFrame$1.setExtraStackFrame(null);
2018 }
2019 }
2020 }
2021
2022 function checkPropTypes(typeSpecs, values, location, componentName, element) {
2023 {
2024 // $FlowFixMe This is okay but Flow doesn't know it.
2025 var has = Function.call.bind(hasOwnProperty);
2026
2027 for (var typeSpecName in typeSpecs) {
2028 if (has(typeSpecs, typeSpecName)) {
2029 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
2030 // fail the render phase where it didn't fail before. So we log it.
2031 // After these have been cleaned up, we'll let them throw.
2032
2033 try {
2034 // This is intentionally an invariant that gets caught. It's the same
2035 // behavior as without this statement except with a better message.
2036 if (typeof typeSpecs[typeSpecName] !== 'function') {
2037 // eslint-disable-next-line react-internal/prod-error-codes
2038 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
2039 err.name = 'Invariant Violation';
2040 throw err;
2041 }
2042
2043 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
2044 } catch (ex) {
2045 error$1 = ex;
2046 }
2047
2048 if (error$1 && !(error$1 instanceof Error)) {
2049 setCurrentlyValidatingElement(element);
2050
2051 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
2052
2053 setCurrentlyValidatingElement(null);
2054 }
2055
2056 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
2057 // Only monitor this failure once because there tends to be a lot of the
2058 // same error.
2059 loggedTypeFailures[error$1.message] = true;
2060 setCurrentlyValidatingElement(element);
2061
2062 error('Failed %s type: %s', location, error$1.message);
2063
2064 setCurrentlyValidatingElement(null);
2065 }
2066 }
2067 }
2068 }
2069 }
2070
2071 function setCurrentlyValidatingElement$1(element) {
2072 {
2073 if (element) {
2074 var owner = element._owner;
2075 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
2076 setExtraStackFrame(stack);
2077 } else {
2078 setExtraStackFrame(null);
2079 }
2080 }
2081 }
2082
2083 var propTypesMisspellWarningShown;
2084
2085 {
2086 propTypesMisspellWarningShown = false;
2087 }
2088
2089 function getDeclarationErrorAddendum() {
2090 if (ReactCurrentOwner.current) {
2091 var name = getComponentNameFromType(ReactCurrentOwner.current.type);
2092
2093 if (name) {
2094 return '\n\nCheck the render method of `' + name + '`.';
2095 }
2096 }
2097
2098 return '';
2099 }
2100
2101 function getSourceInfoErrorAddendum(source) {
2102 if (source !== undefined) {
2103 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2104 var lineNumber = source.lineNumber;
2105 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2106 }
2107
2108 return '';
2109 }
2110
2111 function getSourceInfoErrorAddendumForProps(elementProps) {
2112 if (elementProps !== null && elementProps !== undefined) {
2113 return getSourceInfoErrorAddendum(elementProps.__source);
2114 }
2115
2116 return '';
2117 }
2118 /**
2119 * Warn if there's no key explicitly set on dynamic arrays of children or
2120 * object keys are not valid. This allows us to keep track of children between
2121 * updates.
2122 */
2123
2124
2125 var ownerHasKeyUseWarning = {};
2126
2127 function getCurrentComponentErrorInfo(parentType) {
2128 var info = getDeclarationErrorAddendum();
2129
2130 if (!info) {
2131 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2132
2133 if (parentName) {
2134 info = "\n\nCheck the top-level render call using <" + parentName + ">.";
2135 }
2136 }
2137
2138 return info;
2139 }
2140 /**
2141 * Warn if the element doesn't have an explicit key assigned to it.
2142 * This element is in an array. The array could grow and shrink or be
2143 * reordered. All children that haven't already been validated are required to
2144 * have a "key" property assigned to it. Error statuses are cached so a warning
2145 * will only be shown once.
2146 *
2147 * @internal
2148 * @param {ReactElement} element Element that requires a key.
2149 * @param {*} parentType element's parent's type.
2150 */
2151
2152
2153 function validateExplicitKey(element, parentType) {
2154 if (!element._store || element._store.validated || element.key != null) {
2155 return;
2156 }
2157
2158 element._store.validated = true;
2159 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2160
2161 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2162 return;
2163 }
2164
2165 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
2166 // property, it may be the creator of the child that's responsible for
2167 // assigning it a key.
2168
2169 var childOwner = '';
2170
2171 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2172 // Give the component that originally created this child.
2173 childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
2174 }
2175
2176 {
2177 setCurrentlyValidatingElement$1(element);
2178
2179 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
2180
2181 setCurrentlyValidatingElement$1(null);
2182 }
2183 }
2184 /**
2185 * Ensure that every element either is passed in a static location, in an
2186 * array with an explicit keys property defined, or in an object literal
2187 * with valid key property.
2188 *
2189 * @internal
2190 * @param {ReactNode} node Statically passed child of any type.
2191 * @param {*} parentType node's parent's type.
2192 */
2193
2194
2195 function validateChildKeys(node, parentType) {
2196 if (typeof node !== 'object') {
2197 return;
2198 }
2199
2200 if (isArray(node)) {
2201 for (var i = 0; i < node.length; i++) {
2202 var child = node[i];
2203
2204 if (isValidElement(child)) {
2205 validateExplicitKey(child, parentType);
2206 }
2207 }
2208 } else if (isValidElement(node)) {
2209 // This element was passed in a valid location.
2210 if (node._store) {
2211 node._store.validated = true;
2212 }
2213 } else if (node) {
2214 var iteratorFn = getIteratorFn(node);
2215
2216 if (typeof iteratorFn === 'function') {
2217 // Entry iterators used to provide implicit keys,
2218 // but now we print a separate warning for them later.
2219 if (iteratorFn !== node.entries) {
2220 var iterator = iteratorFn.call(node);
2221 var step;
2222
2223 while (!(step = iterator.next()).done) {
2224 if (isValidElement(step.value)) {
2225 validateExplicitKey(step.value, parentType);
2226 }
2227 }
2228 }
2229 }
2230 }
2231 }
2232 /**
2233 * Given an element, validate that its props follow the propTypes definition,
2234 * provided by the type.
2235 *
2236 * @param {ReactElement} element
2237 */
2238
2239
2240 function validatePropTypes(element) {
2241 {
2242 var type = element.type;
2243
2244 if (type === null || type === undefined || typeof type === 'string') {
2245 return;
2246 }
2247
2248 var propTypes;
2249
2250 if (typeof type === 'function') {
2251 propTypes = type.propTypes;
2252 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
2253 // Inner props are checked in the reconciler.
2254 type.$$typeof === REACT_MEMO_TYPE)) {
2255 propTypes = type.propTypes;
2256 } else {
2257 return;
2258 }
2259
2260 if (propTypes) {
2261 // Intentionally inside to avoid triggering lazy initializers:
2262 var name = getComponentNameFromType(type);
2263 checkPropTypes(propTypes, element.props, 'prop', name, element);
2264 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2265 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
2266
2267 var _name = getComponentNameFromType(type);
2268
2269 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
2270 }
2271
2272 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
2273 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
2274 }
2275 }
2276 }
2277 /**
2278 * Given a fragment, validate that it can only be provided with fragment props
2279 * @param {ReactElement} fragment
2280 */
2281
2282
2283 function validateFragmentProps(fragment) {
2284 {
2285 var keys = Object.keys(fragment.props);
2286
2287 for (var i = 0; i < keys.length; i++) {
2288 var key = keys[i];
2289
2290 if (key !== 'children' && key !== 'key') {
2291 setCurrentlyValidatingElement$1(fragment);
2292
2293 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2294
2295 setCurrentlyValidatingElement$1(null);
2296 break;
2297 }
2298 }
2299
2300 if (fragment.ref !== null) {
2301 setCurrentlyValidatingElement$1(fragment);
2302
2303 error('Invalid attribute `ref` supplied to `React.Fragment`.');
2304
2305 setCurrentlyValidatingElement$1(null);
2306 }
2307 }
2308 }
2309 function createElementWithValidation(type, props, children) {
2310 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
2311 // succeed and there will likely be errors in render.
2312
2313 if (!validType) {
2314 var info = '';
2315
2316 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2317 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.";
2318 }
2319
2320 var sourceInfo = getSourceInfoErrorAddendumForProps(props);
2321
2322 if (sourceInfo) {
2323 info += sourceInfo;
2324 } else {
2325 info += getDeclarationErrorAddendum();
2326 }
2327
2328 var typeString;
2329
2330 if (type === null) {
2331 typeString = 'null';
2332 } else if (isArray(type)) {
2333 typeString = 'array';
2334 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2335 typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
2336 info = ' Did you accidentally export a JSX literal instead of a component?';
2337 } else {
2338 typeString = typeof type;
2339 }
2340
2341 {
2342 error('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);
2343 }
2344 }
2345
2346 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
2347 // TODO: Drop this when these are no longer allowed as the type argument.
2348
2349 if (element == null) {
2350 return element;
2351 } // Skip key warning if the type isn't valid since our key validation logic
2352 // doesn't expect a non-string/function type and can throw confusing errors.
2353 // We don't want exception behavior to differ between dev and prod.
2354 // (Rendering will throw with a helpful message and as soon as the type is
2355 // fixed, the key warnings will appear.)
2356
2357
2358 if (validType) {
2359 for (var i = 2; i < arguments.length; i++) {
2360 validateChildKeys(arguments[i], type);
2361 }
2362 }
2363
2364 if (type === REACT_FRAGMENT_TYPE) {
2365 validateFragmentProps(element);
2366 } else {
2367 validatePropTypes(element);
2368 }
2369
2370 return element;
2371 }
2372 var didWarnAboutDeprecatedCreateFactory = false;
2373 function createFactoryWithValidation(type) {
2374 var validatedFactory = createElementWithValidation.bind(null, type);
2375 validatedFactory.type = type;
2376
2377 {
2378 if (!didWarnAboutDeprecatedCreateFactory) {
2379 didWarnAboutDeprecatedCreateFactory = true;
2380
2381 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
2382 } // Legacy hook: remove it
2383
2384
2385 Object.defineProperty(validatedFactory, 'type', {
2386 enumerable: false,
2387 get: function () {
2388 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
2389
2390 Object.defineProperty(this, 'type', {
2391 value: type
2392 });
2393 return type;
2394 }
2395 });
2396 }
2397
2398 return validatedFactory;
2399 }
2400 function cloneElementWithValidation(element, props, children) {
2401 var newElement = cloneElement.apply(this, arguments);
2402
2403 for (var i = 2; i < arguments.length; i++) {
2404 validateChildKeys(arguments[i], newElement.type);
2405 }
2406
2407 validatePropTypes(newElement);
2408 return newElement;
2409 }
2410
2411 var enableSchedulerDebugging = false;
2412 var enableProfiling = false;
2413 var frameYieldMs = 5;
2414
2415 function push(heap, node) {
2416 var index = heap.length;
2417 heap.push(node);
2418 siftUp(heap, node, index);
2419 }
2420 function peek(heap) {
2421 return heap.length === 0 ? null : heap[0];
2422 }
2423 function pop(heap) {
2424 if (heap.length === 0) {
2425 return null;
2426 }
2427
2428 var first = heap[0];
2429 var last = heap.pop();
2430
2431 if (last !== first) {
2432 heap[0] = last;
2433 siftDown(heap, last, 0);
2434 }
2435
2436 return first;
2437 }
2438
2439 function siftUp(heap, node, i) {
2440 var index = i;
2441
2442 while (index > 0) {
2443 var parentIndex = index - 1 >>> 1;
2444 var parent = heap[parentIndex];
2445
2446 if (compare(parent, node) > 0) {
2447 // The parent is larger. Swap positions.
2448 heap[parentIndex] = node;
2449 heap[index] = parent;
2450 index = parentIndex;
2451 } else {
2452 // The parent is smaller. Exit.
2453 return;
2454 }
2455 }
2456 }
2457
2458 function siftDown(heap, node, i) {
2459 var index = i;
2460 var length = heap.length;
2461 var halfLength = length >>> 1;
2462
2463 while (index < halfLength) {
2464 var leftIndex = (index + 1) * 2 - 1;
2465 var left = heap[leftIndex];
2466 var rightIndex = leftIndex + 1;
2467 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
2468
2469 if (compare(left, node) < 0) {
2470 if (rightIndex < length && compare(right, left) < 0) {
2471 heap[index] = right;
2472 heap[rightIndex] = node;
2473 index = rightIndex;
2474 } else {
2475 heap[index] = left;
2476 heap[leftIndex] = node;
2477 index = leftIndex;
2478 }
2479 } else if (rightIndex < length && compare(right, node) < 0) {
2480 heap[index] = right;
2481 heap[rightIndex] = node;
2482 index = rightIndex;
2483 } else {
2484 // Neither child is smaller. Exit.
2485 return;
2486 }
2487 }
2488 }
2489
2490 function compare(a, b) {
2491 // Compare sort index first, then task id.
2492 var diff = a.sortIndex - b.sortIndex;
2493 return diff !== 0 ? diff : a.id - b.id;
2494 }
2495
2496 // TODO: Use symbols?
2497 var ImmediatePriority = 1;
2498 var UserBlockingPriority = 2;
2499 var NormalPriority = 3;
2500 var LowPriority = 4;
2501 var IdlePriority = 5;
2502
2503 function markTaskErrored(task, ms) {
2504 }
2505
2506 /* eslint-disable no-var */
2507 var getCurrentTime;
2508 var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
2509
2510 if (hasPerformanceNow) {
2511 var localPerformance = performance;
2512
2513 getCurrentTime = function () {
2514 return localPerformance.now();
2515 };
2516 } else {
2517 var localDate = Date;
2518 var initialTime = localDate.now();
2519
2520 getCurrentTime = function () {
2521 return localDate.now() - initialTime;
2522 };
2523 } // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
2524 // Math.pow(2, 30) - 1
2525 // 0b111111111111111111111111111111
2526
2527
2528 var maxSigned31BitInt = 1073741823; // Times out immediately
2529
2530 var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
2531
2532 var USER_BLOCKING_PRIORITY_TIMEOUT = 250;
2533 var NORMAL_PRIORITY_TIMEOUT = 5000;
2534 var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
2535
2536 var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap
2537
2538 var taskQueue = [];
2539 var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
2540
2541 var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
2542 var currentTask = null;
2543 var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance.
2544
2545 var isPerformingWork = false;
2546 var isHostCallbackScheduled = false;
2547 var isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them.
2548
2549 var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;
2550 var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;
2551 var localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom
2552
2553 var isInputPending = typeof navigator !== 'undefined' && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null;
2554
2555 function advanceTimers(currentTime) {
2556 // Check for tasks that are no longer delayed and add them to the queue.
2557 var timer = peek(timerQueue);
2558
2559 while (timer !== null) {
2560 if (timer.callback === null) {
2561 // Timer was cancelled.
2562 pop(timerQueue);
2563 } else if (timer.startTime <= currentTime) {
2564 // Timer fired. Transfer to the task queue.
2565 pop(timerQueue);
2566 timer.sortIndex = timer.expirationTime;
2567 push(taskQueue, timer);
2568 } else {
2569 // Remaining timers are pending.
2570 return;
2571 }
2572
2573 timer = peek(timerQueue);
2574 }
2575 }
2576
2577 function handleTimeout(currentTime) {
2578 isHostTimeoutScheduled = false;
2579 advanceTimers(currentTime);
2580
2581 if (!isHostCallbackScheduled) {
2582 if (peek(taskQueue) !== null) {
2583 isHostCallbackScheduled = true;
2584 requestHostCallback(flushWork);
2585 } else {
2586 var firstTimer = peek(timerQueue);
2587
2588 if (firstTimer !== null) {
2589 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
2590 }
2591 }
2592 }
2593 }
2594
2595 function flushWork(hasTimeRemaining, initialTime) {
2596
2597
2598 isHostCallbackScheduled = false;
2599
2600 if (isHostTimeoutScheduled) {
2601 // We scheduled a timeout but it's no longer needed. Cancel it.
2602 isHostTimeoutScheduled = false;
2603 cancelHostTimeout();
2604 }
2605
2606 isPerformingWork = true;
2607 var previousPriorityLevel = currentPriorityLevel;
2608
2609 try {
2610 if (enableProfiling) {
2611 try {
2612 return workLoop(hasTimeRemaining, initialTime);
2613 } catch (error) {
2614 if (currentTask !== null) {
2615 var currentTime = getCurrentTime();
2616 markTaskErrored(currentTask, currentTime);
2617 currentTask.isQueued = false;
2618 }
2619
2620 throw error;
2621 }
2622 } else {
2623 // No catch in prod code path.
2624 return workLoop(hasTimeRemaining, initialTime);
2625 }
2626 } finally {
2627 currentTask = null;
2628 currentPriorityLevel = previousPriorityLevel;
2629 isPerformingWork = false;
2630 }
2631 }
2632
2633 function workLoop(hasTimeRemaining, initialTime) {
2634 var currentTime = initialTime;
2635 advanceTimers(currentTime);
2636 currentTask = peek(taskQueue);
2637
2638 while (currentTask !== null && !(enableSchedulerDebugging )) {
2639 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
2640 // This currentTask hasn't expired, and we've reached the deadline.
2641 break;
2642 }
2643
2644 var callback = currentTask.callback;
2645
2646 if (typeof callback === 'function') {
2647 currentTask.callback = null;
2648 currentPriorityLevel = currentTask.priorityLevel;
2649 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
2650
2651 var continuationCallback = callback(didUserCallbackTimeout);
2652 currentTime = getCurrentTime();
2653
2654 if (typeof continuationCallback === 'function') {
2655 currentTask.callback = continuationCallback;
2656 } else {
2657
2658 if (currentTask === peek(taskQueue)) {
2659 pop(taskQueue);
2660 }
2661 }
2662
2663 advanceTimers(currentTime);
2664 } else {
2665 pop(taskQueue);
2666 }
2667
2668 currentTask = peek(taskQueue);
2669 } // Return whether there's additional work
2670
2671
2672 if (currentTask !== null) {
2673 return true;
2674 } else {
2675 var firstTimer = peek(timerQueue);
2676
2677 if (firstTimer !== null) {
2678 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
2679 }
2680
2681 return false;
2682 }
2683 }
2684
2685 function unstable_runWithPriority(priorityLevel, eventHandler) {
2686 switch (priorityLevel) {
2687 case ImmediatePriority:
2688 case UserBlockingPriority:
2689 case NormalPriority:
2690 case LowPriority:
2691 case IdlePriority:
2692 break;
2693
2694 default:
2695 priorityLevel = NormalPriority;
2696 }
2697
2698 var previousPriorityLevel = currentPriorityLevel;
2699 currentPriorityLevel = priorityLevel;
2700
2701 try {
2702 return eventHandler();
2703 } finally {
2704 currentPriorityLevel = previousPriorityLevel;
2705 }
2706 }
2707
2708 function unstable_next(eventHandler) {
2709 var priorityLevel;
2710
2711 switch (currentPriorityLevel) {
2712 case ImmediatePriority:
2713 case UserBlockingPriority:
2714 case NormalPriority:
2715 // Shift down to normal priority
2716 priorityLevel = NormalPriority;
2717 break;
2718
2719 default:
2720 // Anything lower than normal priority should remain at the current level.
2721 priorityLevel = currentPriorityLevel;
2722 break;
2723 }
2724
2725 var previousPriorityLevel = currentPriorityLevel;
2726 currentPriorityLevel = priorityLevel;
2727
2728 try {
2729 return eventHandler();
2730 } finally {
2731 currentPriorityLevel = previousPriorityLevel;
2732 }
2733 }
2734
2735 function unstable_wrapCallback(callback) {
2736 var parentPriorityLevel = currentPriorityLevel;
2737 return function () {
2738 // This is a fork of runWithPriority, inlined for performance.
2739 var previousPriorityLevel = currentPriorityLevel;
2740 currentPriorityLevel = parentPriorityLevel;
2741
2742 try {
2743 return callback.apply(this, arguments);
2744 } finally {
2745 currentPriorityLevel = previousPriorityLevel;
2746 }
2747 };
2748 }
2749
2750 function unstable_scheduleCallback(priorityLevel, callback, options) {
2751 var currentTime = getCurrentTime();
2752 var startTime;
2753
2754 if (typeof options === 'object' && options !== null) {
2755 var delay = options.delay;
2756
2757 if (typeof delay === 'number' && delay > 0) {
2758 startTime = currentTime + delay;
2759 } else {
2760 startTime = currentTime;
2761 }
2762 } else {
2763 startTime = currentTime;
2764 }
2765
2766 var timeout;
2767
2768 switch (priorityLevel) {
2769 case ImmediatePriority:
2770 timeout = IMMEDIATE_PRIORITY_TIMEOUT;
2771 break;
2772
2773 case UserBlockingPriority:
2774 timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
2775 break;
2776
2777 case IdlePriority:
2778 timeout = IDLE_PRIORITY_TIMEOUT;
2779 break;
2780
2781 case LowPriority:
2782 timeout = LOW_PRIORITY_TIMEOUT;
2783 break;
2784
2785 case NormalPriority:
2786 default:
2787 timeout = NORMAL_PRIORITY_TIMEOUT;
2788 break;
2789 }
2790
2791 var expirationTime = startTime + timeout;
2792 var newTask = {
2793 id: taskIdCounter++,
2794 callback: callback,
2795 priorityLevel: priorityLevel,
2796 startTime: startTime,
2797 expirationTime: expirationTime,
2798 sortIndex: -1
2799 };
2800
2801 if (startTime > currentTime) {
2802 // This is a delayed task.
2803 newTask.sortIndex = startTime;
2804 push(timerQueue, newTask);
2805
2806 if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
2807 // All tasks are delayed, and this is the task with the earliest delay.
2808 if (isHostTimeoutScheduled) {
2809 // Cancel an existing timeout.
2810 cancelHostTimeout();
2811 } else {
2812 isHostTimeoutScheduled = true;
2813 } // Schedule a timeout.
2814
2815
2816 requestHostTimeout(handleTimeout, startTime - currentTime);
2817 }
2818 } else {
2819 newTask.sortIndex = expirationTime;
2820 push(taskQueue, newTask);
2821 // wait until the next time we yield.
2822
2823
2824 if (!isHostCallbackScheduled && !isPerformingWork) {
2825 isHostCallbackScheduled = true;
2826 requestHostCallback(flushWork);
2827 }
2828 }
2829
2830 return newTask;
2831 }
2832
2833 function unstable_pauseExecution() {
2834 }
2835
2836 function unstable_continueExecution() {
2837
2838 if (!isHostCallbackScheduled && !isPerformingWork) {
2839 isHostCallbackScheduled = true;
2840 requestHostCallback(flushWork);
2841 }
2842 }
2843
2844 function unstable_getFirstCallbackNode() {
2845 return peek(taskQueue);
2846 }
2847
2848 function unstable_cancelCallback(task) {
2849 // remove from the queue because you can't remove arbitrary nodes from an
2850 // array based heap, only the first one.)
2851
2852
2853 task.callback = null;
2854 }
2855
2856 function unstable_getCurrentPriorityLevel() {
2857 return currentPriorityLevel;
2858 }
2859
2860 var isMessageLoopRunning = false;
2861 var scheduledHostCallback = null;
2862 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
2863 // thread, like user events. By default, it yields multiple times per frame.
2864 // It does not attempt to align with frame boundaries, since most tasks don't
2865 // need to be frame aligned; for those that do, use requestAnimationFrame.
2866
2867 var frameInterval = frameYieldMs;
2868 var startTime = -1;
2869
2870 function shouldYieldToHost() {
2871 var timeElapsed = getCurrentTime() - startTime;
2872
2873 if (timeElapsed < frameInterval) {
2874 // The main thread has only been blocked for a really short amount of time;
2875 // smaller than a single frame. Don't yield yet.
2876 return false;
2877 } // The main thread has been blocked for a non-negligible amount of time. We
2878
2879
2880 return true;
2881 }
2882
2883 function requestPaint() {
2884
2885 }
2886
2887 function forceFrameRate(fps) {
2888 if (fps < 0 || fps > 125) {
2889 // Using console['error'] to evade Babel and ESLint
2890 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');
2891 return;
2892 }
2893
2894 if (fps > 0) {
2895 frameInterval = Math.floor(1000 / fps);
2896 } else {
2897 // reset the framerate
2898 frameInterval = frameYieldMs;
2899 }
2900 }
2901
2902 var performWorkUntilDeadline = function () {
2903 if (scheduledHostCallback !== null) {
2904 var currentTime = getCurrentTime(); // Keep track of the start time so we can measure how long the main thread
2905 // has been blocked.
2906
2907 startTime = currentTime;
2908 var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
2909 // error can be observed.
2910 //
2911 // Intentionally not using a try-catch, since that makes some debugging
2912 // techniques harder. Instead, if `scheduledHostCallback` errors, then
2913 // `hasMoreWork` will remain true, and we'll continue the work loop.
2914
2915 var hasMoreWork = true;
2916
2917 try {
2918 hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
2919 } finally {
2920 if (hasMoreWork) {
2921 // If there's more work, schedule the next message event at the end
2922 // of the preceding one.
2923 schedulePerformWorkUntilDeadline();
2924 } else {
2925 isMessageLoopRunning = false;
2926 scheduledHostCallback = null;
2927 }
2928 }
2929 } else {
2930 isMessageLoopRunning = false;
2931 } // Yielding to the browser will give it a chance to paint, so we can
2932 };
2933
2934 var schedulePerformWorkUntilDeadline;
2935
2936 if (typeof localSetImmediate === 'function') {
2937 // Node.js and old IE.
2938 // There's a few reasons for why we prefer setImmediate.
2939 //
2940 // Unlike MessageChannel, it doesn't prevent a Node.js process from exiting.
2941 // (Even though this is a DOM fork of the Scheduler, you could get here
2942 // with a mix of Node.js 15+, which has a MessageChannel, and jsdom.)
2943 // https://github.com/facebook/react/issues/20756
2944 //
2945 // But also, it runs earlier which is the semantic we want.
2946 // If other browsers ever implement it, it's better to use it.
2947 // Although both of these would be inferior to native scheduling.
2948 schedulePerformWorkUntilDeadline = function () {
2949 localSetImmediate(performWorkUntilDeadline);
2950 };
2951 } else if (typeof MessageChannel !== 'undefined') {
2952 // DOM and Worker environments.
2953 // We prefer MessageChannel because of the 4ms setTimeout clamping.
2954 var channel = new MessageChannel();
2955 var port = channel.port2;
2956 channel.port1.onmessage = performWorkUntilDeadline;
2957
2958 schedulePerformWorkUntilDeadline = function () {
2959 port.postMessage(null);
2960 };
2961 } else {
2962 // We should only fallback here in non-browser environments.
2963 schedulePerformWorkUntilDeadline = function () {
2964 localSetTimeout(performWorkUntilDeadline, 0);
2965 };
2966 }
2967
2968 function requestHostCallback(callback) {
2969 scheduledHostCallback = callback;
2970
2971 if (!isMessageLoopRunning) {
2972 isMessageLoopRunning = true;
2973 schedulePerformWorkUntilDeadline();
2974 }
2975 }
2976
2977 function requestHostTimeout(callback, ms) {
2978 taskTimeoutID = localSetTimeout(function () {
2979 callback(getCurrentTime());
2980 }, ms);
2981 }
2982
2983 function cancelHostTimeout() {
2984 localClearTimeout(taskTimeoutID);
2985 taskTimeoutID = -1;
2986 }
2987
2988 var unstable_requestPaint = requestPaint;
2989 var unstable_Profiling = null;
2990
2991
2992
2993 var Scheduler = /*#__PURE__*/Object.freeze({
2994 __proto__: null,
2995 unstable_ImmediatePriority: ImmediatePriority,
2996 unstable_UserBlockingPriority: UserBlockingPriority,
2997 unstable_NormalPriority: NormalPriority,
2998 unstable_IdlePriority: IdlePriority,
2999 unstable_LowPriority: LowPriority,
3000 unstable_runWithPriority: unstable_runWithPriority,
3001 unstable_next: unstable_next,
3002 unstable_scheduleCallback: unstable_scheduleCallback,
3003 unstable_cancelCallback: unstable_cancelCallback,
3004 unstable_wrapCallback: unstable_wrapCallback,
3005 unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
3006 unstable_shouldYield: shouldYieldToHost,
3007 unstable_requestPaint: unstable_requestPaint,
3008 unstable_continueExecution: unstable_continueExecution,
3009 unstable_pauseExecution: unstable_pauseExecution,
3010 unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
3011 get unstable_now () { return getCurrentTime; },
3012 unstable_forceFrameRate: forceFrameRate,
3013 unstable_Profiling: unstable_Profiling
3014 });
3015
3016 var ReactSharedInternals$1 = {
3017 ReactCurrentDispatcher: ReactCurrentDispatcher,
3018 ReactCurrentOwner: ReactCurrentOwner,
3019 ReactCurrentBatchConfig: ReactCurrentBatchConfig,
3020 // Re-export the schedule API(s) for UMD bundles.
3021 // This avoids introducing a dependency on a new UMD global in a minor update,
3022 // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
3023 // This re-export is only required for UMD bundles;
3024 // CJS bundles use the shared NPM package.
3025 Scheduler: Scheduler
3026 };
3027
3028 {
3029 ReactSharedInternals$1.ReactCurrentActQueue = ReactCurrentActQueue;
3030 ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
3031 }
3032
3033 function startTransition(scope, options) {
3034 var prevTransition = ReactCurrentBatchConfig.transition;
3035 ReactCurrentBatchConfig.transition = {};
3036 var currentTransition = ReactCurrentBatchConfig.transition;
3037
3038 {
3039 ReactCurrentBatchConfig.transition._updatedFibers = new Set();
3040 }
3041
3042 try {
3043 scope();
3044 } finally {
3045 ReactCurrentBatchConfig.transition = prevTransition;
3046
3047 {
3048 if (prevTransition === null && currentTransition._updatedFibers) {
3049 var updatedFibersCount = currentTransition._updatedFibers.size;
3050
3051 if (updatedFibersCount > 10) {
3052 warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');
3053 }
3054
3055 currentTransition._updatedFibers.clear();
3056 }
3057 }
3058 }
3059 }
3060
3061 var didWarnAboutMessageChannel = false;
3062 var enqueueTaskImpl = null;
3063 function enqueueTask(task) {
3064 if (enqueueTaskImpl === null) {
3065 try {
3066 // read require off the module object to get around the bundlers.
3067 // we don't want them to detect a require and bundle a Node polyfill.
3068 var requireString = ('require' + Math.random()).slice(0, 7);
3069 var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
3070 // version of setImmediate, bypassing fake timers if any.
3071
3072 enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
3073 } catch (_err) {
3074 // we're in a browser
3075 // we can't use regular timers because they may still be faked
3076 // so we try MessageChannel+postMessage instead
3077 enqueueTaskImpl = function (callback) {
3078 {
3079 if (didWarnAboutMessageChannel === false) {
3080 didWarnAboutMessageChannel = true;
3081
3082 if (typeof MessageChannel === 'undefined') {
3083 error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
3084 }
3085 }
3086 }
3087
3088 var channel = new MessageChannel();
3089 channel.port1.onmessage = callback;
3090 channel.port2.postMessage(undefined);
3091 };
3092 }
3093 }
3094
3095 return enqueueTaskImpl(task);
3096 }
3097
3098 var actScopeDepth = 0;
3099 var didWarnNoAwaitAct = false;
3100 function act(callback) {
3101 {
3102 // `act` calls can be nested, so we track the depth. This represents the
3103 // number of `act` scopes on the stack.
3104 var prevActScopeDepth = actScopeDepth;
3105 actScopeDepth++;
3106
3107 if (ReactCurrentActQueue.current === null) {
3108 // This is the outermost `act` scope. Initialize the queue. The reconciler
3109 // will detect the queue and use it instead of Scheduler.
3110 ReactCurrentActQueue.current = [];
3111 }
3112
3113 var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
3114 var result;
3115
3116 try {
3117 // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
3118 // set to `true` while the given callback is executed, not for updates
3119 // triggered during an async event, because this is how the legacy
3120 // implementation of `act` behaved.
3121 ReactCurrentActQueue.isBatchingLegacy = true;
3122 result = callback(); // Replicate behavior of original `act` implementation in legacy mode,
3123 // which flushed updates immediately after the scope function exits, even
3124 // if it's an async function.
3125
3126 if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
3127 var queue = ReactCurrentActQueue.current;
3128
3129 if (queue !== null) {
3130 ReactCurrentActQueue.didScheduleLegacyUpdate = false;
3131 flushActQueue(queue);
3132 }
3133 }
3134 } catch (error) {
3135 popActScope(prevActScopeDepth);
3136 throw error;
3137 } finally {
3138 ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
3139 }
3140
3141 if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
3142 var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait
3143 // for it to resolve before exiting the current scope.
3144
3145 var wasAwaited = false;
3146 var thenable = {
3147 then: function (resolve, reject) {
3148 wasAwaited = true;
3149 thenableResult.then(function (returnValue) {
3150 popActScope(prevActScopeDepth);
3151
3152 if (actScopeDepth === 0) {
3153 // We've exited the outermost act scope. Recursively flush the
3154 // queue until there's no remaining work.
3155 recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3156 } else {
3157 resolve(returnValue);
3158 }
3159 }, function (error) {
3160 // The callback threw an error.
3161 popActScope(prevActScopeDepth);
3162 reject(error);
3163 });
3164 }
3165 };
3166
3167 {
3168 if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {
3169 // eslint-disable-next-line no-undef
3170 Promise.resolve().then(function () {}).then(function () {
3171 if (!wasAwaited) {
3172 didWarnNoAwaitAct = true;
3173
3174 error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');
3175 }
3176 });
3177 }
3178 }
3179
3180 return thenable;
3181 } else {
3182 var returnValue = result; // The callback is not an async function. Exit the current scope
3183 // immediately, without awaiting.
3184
3185 popActScope(prevActScopeDepth);
3186
3187 if (actScopeDepth === 0) {
3188 // Exiting the outermost act scope. Flush the queue.
3189 var _queue = ReactCurrentActQueue.current;
3190
3191 if (_queue !== null) {
3192 flushActQueue(_queue);
3193 ReactCurrentActQueue.current = null;
3194 } // Return a thenable. If the user awaits it, we'll flush again in
3195 // case additional work was scheduled by a microtask.
3196
3197
3198 var _thenable = {
3199 then: function (resolve, reject) {
3200 // Confirm we haven't re-entered another `act` scope, in case
3201 // the user does something weird like await the thenable
3202 // multiple times.
3203 if (ReactCurrentActQueue.current === null) {
3204 // Recursively flush the queue until there's no remaining work.
3205 ReactCurrentActQueue.current = [];
3206 recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3207 } else {
3208 resolve(returnValue);
3209 }
3210 }
3211 };
3212 return _thenable;
3213 } else {
3214 // Since we're inside a nested `act` scope, the returned thenable
3215 // immediately resolves. The outer scope will flush the queue.
3216 var _thenable2 = {
3217 then: function (resolve, reject) {
3218 resolve(returnValue);
3219 }
3220 };
3221 return _thenable2;
3222 }
3223 }
3224 }
3225 }
3226
3227 function popActScope(prevActScopeDepth) {
3228 {
3229 if (prevActScopeDepth !== actScopeDepth - 1) {
3230 error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
3231 }
3232
3233 actScopeDepth = prevActScopeDepth;
3234 }
3235 }
3236
3237 function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
3238 {
3239 var queue = ReactCurrentActQueue.current;
3240
3241 if (queue !== null) {
3242 try {
3243 flushActQueue(queue);
3244 enqueueTask(function () {
3245 if (queue.length === 0) {
3246 // No additional work was scheduled. Finish.
3247 ReactCurrentActQueue.current = null;
3248 resolve(returnValue);
3249 } else {
3250 // Keep flushing work until there's none left.
3251 recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3252 }
3253 });
3254 } catch (error) {
3255 reject(error);
3256 }
3257 } else {
3258 resolve(returnValue);
3259 }
3260 }
3261 }
3262
3263 var isFlushing = false;
3264
3265 function flushActQueue(queue) {
3266 {
3267 if (!isFlushing) {
3268 // Prevent re-entrance.
3269 isFlushing = true;
3270 var i = 0;
3271
3272 try {
3273 for (; i < queue.length; i++) {
3274 var callback = queue[i];
3275
3276 do {
3277 callback = callback(true);
3278 } while (callback !== null);
3279 }
3280
3281 queue.length = 0;
3282 } catch (error) {
3283 // If something throws, leave the remaining callbacks on the queue.
3284 queue = queue.slice(i + 1);
3285 throw error;
3286 } finally {
3287 isFlushing = false;
3288 }
3289 }
3290 }
3291 }
3292
3293 var createElement$1 = createElementWithValidation ;
3294 var cloneElement$1 = cloneElementWithValidation ;
3295 var createFactory = createFactoryWithValidation ;
3296 var Children = {
3297 map: mapChildren,
3298 forEach: forEachChildren,
3299 count: countChildren,
3300 toArray: toArray,
3301 only: onlyChild
3302 };
3303
3304 exports.Children = Children;
3305 exports.Component = Component;
3306 exports.Fragment = REACT_FRAGMENT_TYPE;
3307 exports.Profiler = REACT_PROFILER_TYPE;
3308 exports.PureComponent = PureComponent;
3309 exports.StrictMode = REACT_STRICT_MODE_TYPE;
3310 exports.Suspense = REACT_SUSPENSE_TYPE;
3311 exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals$1;
3312 exports.cloneElement = cloneElement$1;
3313 exports.createContext = createContext;
3314 exports.createElement = createElement$1;
3315 exports.createFactory = createFactory;
3316 exports.createRef = createRef;
3317 exports.forwardRef = forwardRef;
3318 exports.isValidElement = isValidElement;
3319 exports.lazy = lazy;
3320 exports.memo = memo;
3321 exports.startTransition = startTransition;
3322 exports.unstable_act = act;
3323 exports.useCallback = useCallback;
3324 exports.useContext = useContext;
3325 exports.useDebugValue = useDebugValue;
3326 exports.useDeferredValue = useDeferredValue;
3327 exports.useEffect = useEffect;
3328 exports.useId = useId;
3329 exports.useImperativeHandle = useImperativeHandle;
3330 exports.useInsertionEffect = useInsertionEffect;
3331 exports.useLayoutEffect = useLayoutEffect;
3332 exports.useMemo = useMemo;
3333 exports.useReducer = useReducer;
3334 exports.useRef = useRef;
3335 exports.useState = useState;
3336 exports.useSyncExternalStore = useSyncExternalStore;
3337 exports.useTransition = useTransition;
3338 exports.version = ReactVersion;
3339
3340})));