UNPKG

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