UNPKG

66.2 kBJavaScriptView Raw
1/** @license React v16.9.0-alpha.0
2 * react.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var checkPropTypes = require('prop-types/checkPropTypes');
20
21// TODO: this is special because it gets imported during build.
22
23var ReactVersion = '16.9.0-alpha.0';
24
25// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
26// nor polyfill, then a plain number is used for performance.
27var hasSymbol = typeof Symbol === 'function' && Symbol.for;
28
29var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
30var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
31var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
32var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
33var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
34var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
35var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
36
37var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
38var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
39var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
40var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
41var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
42var REACT_EVENT_COMPONENT_TYPE = hasSymbol ? Symbol.for('react.event_component') : 0xead5;
43var REACT_EVENT_TARGET_TYPE = hasSymbol ? Symbol.for('react.event_target') : 0xead6;
44
45// React event targets
46var REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol ? Symbol.for('react.event_target.touch_hit') : 0xead7;
47
48var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
49var FAUX_ITERATOR_SYMBOL = '@@iterator';
50
51function getIteratorFn(maybeIterable) {
52 if (maybeIterable === null || typeof maybeIterable !== 'object') {
53 return null;
54 }
55 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
56 if (typeof maybeIterator === 'function') {
57 return maybeIterator;
58 }
59 return null;
60}
61
62// Do not require this module directly! Use a normal error constructor with
63// template literal strings. The messages will be converted to ReactError during
64// build, and in production they will be minified.
65
66// Do not require this module directly! Use a normal error constructor with
67// template literal strings. The messages will be converted to ReactError during
68// build, and in production they will be minified.
69
70function ReactError(message) {
71 var error = new Error(message);
72 error.name = 'Invariant Violation';
73 return error;
74}
75
76/**
77 * Use invariant() to assert state which your program assumes to be true.
78 *
79 * Provide sprintf-style format (only %s is supported) and arguments
80 * to provide information about what broke and what you were
81 * expecting.
82 *
83 * The invariant message will be stripped in production, but the invariant
84 * will remain to ensure logic does not differ in production.
85 */
86
87/**
88 * Forked from fbjs/warning:
89 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
90 *
91 * Only change is we use console.warn instead of console.error,
92 * and do nothing when 'console' is not supported.
93 * This really simplifies the code.
94 * ---
95 * Similar to invariant but only logs a warning if the condition is not met.
96 * This can be used to log issues in development environments in critical
97 * paths. Removing the logging code for production environments will keep the
98 * same logic and follow the same code paths.
99 */
100
101var lowPriorityWarning = function () {};
102
103{
104 var printWarning = function (format) {
105 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
106 args[_key - 1] = arguments[_key];
107 }
108
109 var argIndex = 0;
110 var message = 'Warning: ' + format.replace(/%s/g, function () {
111 return args[argIndex++];
112 });
113 if (typeof console !== 'undefined') {
114 console.warn(message);
115 }
116 try {
117 // --- Welcome to debugging React ---
118 // This error was thrown as a convenience so that you can use this stack
119 // to find the callsite that caused this warning to fire.
120 throw new Error(message);
121 } catch (x) {}
122 };
123
124 lowPriorityWarning = function (condition, format) {
125 if (format === undefined) {
126 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
127 }
128 if (!condition) {
129 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
130 args[_key2 - 2] = arguments[_key2];
131 }
132
133 printWarning.apply(undefined, [format].concat(args));
134 }
135 };
136}
137
138var lowPriorityWarning$1 = lowPriorityWarning;
139
140/**
141 * Similar to invariant but only logs a warning if the condition is not met.
142 * This can be used to log issues in development environments in critical
143 * paths. Removing the logging code for production environments will keep the
144 * same logic and follow the same code paths.
145 */
146
147var warningWithoutStack = function () {};
148
149{
150 warningWithoutStack = function (condition, format) {
151 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
152 args[_key - 2] = arguments[_key];
153 }
154
155 if (format === undefined) {
156 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
157 }
158 if (args.length > 8) {
159 // Check before the condition to catch violations early.
160 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
161 }
162 if (condition) {
163 return;
164 }
165 if (typeof console !== 'undefined') {
166 var argsWithFormat = args.map(function (item) {
167 return '' + item;
168 });
169 argsWithFormat.unshift('Warning: ' + format);
170
171 // We intentionally don't use spread (or .apply) directly because it
172 // breaks IE9: https://github.com/facebook/react/issues/13610
173 Function.prototype.apply.call(console.error, console, argsWithFormat);
174 }
175 try {
176 // --- Welcome to debugging React ---
177 // This error was thrown as a convenience so that you can use this stack
178 // to find the callsite that caused this warning to fire.
179 var argIndex = 0;
180 var message = 'Warning: ' + format.replace(/%s/g, function () {
181 return args[argIndex++];
182 });
183 throw new Error(message);
184 } catch (x) {}
185 };
186}
187
188var warningWithoutStack$1 = warningWithoutStack;
189
190var didWarnStateUpdateForUnmountedComponent = {};
191
192function warnNoop(publicInstance, callerName) {
193 {
194 var _constructor = publicInstance.constructor;
195 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
196 var warningKey = componentName + '.' + callerName;
197 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
198 return;
199 }
200 warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
201 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
202 }
203}
204
205/**
206 * This is the abstract API for an update queue.
207 */
208var ReactNoopUpdateQueue = {
209 /**
210 * Checks whether or not this composite component is mounted.
211 * @param {ReactClass} publicInstance The instance we want to test.
212 * @return {boolean} True if mounted, false otherwise.
213 * @protected
214 * @final
215 */
216 isMounted: function (publicInstance) {
217 return false;
218 },
219
220 /**
221 * Forces an update. This should only be invoked when it is known with
222 * certainty that we are **not** in a DOM transaction.
223 *
224 * You may want to call this when you know that some deeper aspect of the
225 * component's state has changed but `setState` was not called.
226 *
227 * This will not invoke `shouldComponentUpdate`, but it will invoke
228 * `componentWillUpdate` and `componentDidUpdate`.
229 *
230 * @param {ReactClass} publicInstance The instance that should rerender.
231 * @param {?function} callback Called after component is updated.
232 * @param {?string} callerName name of the calling function in the public API.
233 * @internal
234 */
235 enqueueForceUpdate: function (publicInstance, callback, callerName) {
236 warnNoop(publicInstance, 'forceUpdate');
237 },
238
239 /**
240 * Replaces all of the state. Always use this or `setState` to mutate state.
241 * You should treat `this.state` as immutable.
242 *
243 * There is no guarantee that `this.state` will be immediately updated, so
244 * accessing `this.state` after calling this method may return the old value.
245 *
246 * @param {ReactClass} publicInstance The instance that should rerender.
247 * @param {object} completeState Next state.
248 * @param {?function} callback Called after component is updated.
249 * @param {?string} callerName name of the calling function in the public API.
250 * @internal
251 */
252 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
253 warnNoop(publicInstance, 'replaceState');
254 },
255
256 /**
257 * Sets a subset of the state. This only exists because _pendingState is
258 * internal. This provides a merging strategy that is not available to deep
259 * properties which is confusing. TODO: Expose pendingState or don't use it
260 * during the merge.
261 *
262 * @param {ReactClass} publicInstance The instance that should rerender.
263 * @param {object} partialState Next partial state to be merged with state.
264 * @param {?function} callback Called after component is updated.
265 * @param {?string} Name of the calling function in the public API.
266 * @internal
267 */
268 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
269 warnNoop(publicInstance, 'setState');
270 }
271};
272
273var emptyObject = {};
274{
275 Object.freeze(emptyObject);
276}
277
278/**
279 * Base class helpers for the updating state of a component.
280 */
281function Component(props, context, updater) {
282 this.props = props;
283 this.context = context;
284 // If a component has string refs, we will assign a different object later.
285 this.refs = emptyObject;
286 // We initialize the default updater but the real one gets injected by the
287 // renderer.
288 this.updater = updater || ReactNoopUpdateQueue;
289}
290
291Component.prototype.isReactComponent = {};
292
293/**
294 * Sets a subset of the state. Always use this to mutate
295 * state. You should treat `this.state` as immutable.
296 *
297 * There is no guarantee that `this.state` will be immediately updated, so
298 * accessing `this.state` after calling this method may return the old value.
299 *
300 * There is no guarantee that calls to `setState` will run synchronously,
301 * as they may eventually be batched together. You can provide an optional
302 * callback that will be executed when the call to setState is actually
303 * completed.
304 *
305 * When a function is provided to setState, it will be called at some point in
306 * the future (not synchronously). It will be called with the up to date
307 * component arguments (state, props, context). These values can be different
308 * from this.* because your function may be called after receiveProps but before
309 * shouldComponentUpdate, and this new state, props, and context will not yet be
310 * assigned to this.
311 *
312 * @param {object|function} partialState Next partial state or function to
313 * produce next partial state to be merged with current state.
314 * @param {?function} callback Called after state is updated.
315 * @final
316 * @protected
317 */
318Component.prototype.setState = function (partialState, callback) {
319 (function () {
320 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
321 {
322 throw ReactError('setState(...): takes an object of state variables to update or a function which returns an object of state variables.');
323 }
324 }
325 })();
326 this.updater.enqueueSetState(this, partialState, callback, 'setState');
327};
328
329/**
330 * Forces an update. This should only be invoked when it is known with
331 * certainty that we are **not** in a DOM transaction.
332 *
333 * You may want to call this when you know that some deeper aspect of the
334 * component's state has changed but `setState` was not called.
335 *
336 * This will not invoke `shouldComponentUpdate`, but it will invoke
337 * `componentWillUpdate` and `componentDidUpdate`.
338 *
339 * @param {?function} callback Called after update is complete.
340 * @final
341 * @protected
342 */
343Component.prototype.forceUpdate = function (callback) {
344 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
345};
346
347/**
348 * Deprecated APIs. These APIs used to exist on classic React classes but since
349 * we would like to deprecate them, we're not going to move them over to this
350 * modern base class. Instead, we define a getter that warns if it's accessed.
351 */
352{
353 var deprecatedAPIs = {
354 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
355 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
356 };
357 var defineDeprecationWarning = function (methodName, info) {
358 Object.defineProperty(Component.prototype, methodName, {
359 get: function () {
360 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
361 return undefined;
362 }
363 });
364 };
365 for (var fnName in deprecatedAPIs) {
366 if (deprecatedAPIs.hasOwnProperty(fnName)) {
367 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
368 }
369 }
370}
371
372function ComponentDummy() {}
373ComponentDummy.prototype = Component.prototype;
374
375/**
376 * Convenience component with default shallow equality check for sCU.
377 */
378function PureComponent(props, context, updater) {
379 this.props = props;
380 this.context = context;
381 // If a component has string refs, we will assign a different object later.
382 this.refs = emptyObject;
383 this.updater = updater || ReactNoopUpdateQueue;
384}
385
386var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
387pureComponentPrototype.constructor = PureComponent;
388// Avoid an extra prototype jump for these methods.
389_assign(pureComponentPrototype, Component.prototype);
390pureComponentPrototype.isPureReactComponent = true;
391
392// an immutable object with a single mutable value
393function createRef() {
394 var refObject = {
395 current: null
396 };
397 {
398 Object.seal(refObject);
399 }
400 return refObject;
401}
402
403/**
404 * Keeps track of the current dispatcher.
405 */
406var ReactCurrentDispatcher = {
407 /**
408 * @internal
409 * @type {ReactComponent}
410 */
411 current: null
412};
413
414/**
415 * Keeps track of the current owner.
416 *
417 * The current owner is the component who should own any components that are
418 * currently being constructed.
419 */
420var ReactCurrentOwner = {
421 /**
422 * @internal
423 * @type {ReactComponent}
424 */
425 current: null
426};
427
428var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
429
430var describeComponentFrame = function (name, source, ownerName) {
431 var sourceInfo = '';
432 if (source) {
433 var path = source.fileName;
434 var fileName = path.replace(BEFORE_SLASH_RE, '');
435 {
436 // In DEV, include code for a common special case:
437 // prefer "folder/index.js" instead of just "index.js".
438 if (/^index\./.test(fileName)) {
439 var match = path.match(BEFORE_SLASH_RE);
440 if (match) {
441 var pathBeforeSlash = match[1];
442 if (pathBeforeSlash) {
443 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
444 fileName = folderName + '/' + fileName;
445 }
446 }
447 }
448 }
449 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
450 } else if (ownerName) {
451 sourceInfo = ' (created by ' + ownerName + ')';
452 }
453 return '\n in ' + (name || 'Unknown') + sourceInfo;
454};
455
456var Resolved = 1;
457
458
459function refineResolvedLazyComponent(lazyComponent) {
460 return lazyComponent._status === Resolved ? lazyComponent._result : null;
461}
462
463function getWrappedName(outerType, innerType, wrapperName) {
464 var functionName = innerType.displayName || innerType.name || '';
465 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
466}
467
468function getComponentName(type) {
469 if (type == null) {
470 // Host root, text node or just invalid type.
471 return null;
472 }
473 {
474 if (typeof type.tag === 'number') {
475 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
476 }
477 }
478 if (typeof type === 'function') {
479 return type.displayName || type.name || null;
480 }
481 if (typeof type === 'string') {
482 return type;
483 }
484 switch (type) {
485 case REACT_CONCURRENT_MODE_TYPE:
486 return 'ConcurrentMode';
487 case REACT_FRAGMENT_TYPE:
488 return 'Fragment';
489 case REACT_PORTAL_TYPE:
490 return 'Portal';
491 case REACT_PROFILER_TYPE:
492 return 'Profiler';
493 case REACT_STRICT_MODE_TYPE:
494 return 'StrictMode';
495 case REACT_SUSPENSE_TYPE:
496 return 'Suspense';
497 }
498 if (typeof type === 'object') {
499 switch (type.$$typeof) {
500 case REACT_CONTEXT_TYPE:
501 return 'Context.Consumer';
502 case REACT_PROVIDER_TYPE:
503 return 'Context.Provider';
504 case REACT_FORWARD_REF_TYPE:
505 return getWrappedName(type, type.render, 'ForwardRef');
506 case REACT_MEMO_TYPE:
507 return getComponentName(type.type);
508 case REACT_LAZY_TYPE:
509 {
510 var thenable = type;
511 var resolvedThenable = refineResolvedLazyComponent(thenable);
512 if (resolvedThenable) {
513 return getComponentName(resolvedThenable);
514 }
515 break;
516 }
517 case REACT_EVENT_COMPONENT_TYPE:
518 {
519 var eventComponent = type;
520 var displayName = eventComponent.displayName;
521 if (displayName !== undefined) {
522 return displayName;
523 }
524 break;
525 }
526 case REACT_EVENT_TARGET_TYPE:
527 {
528 var eventTarget = type;
529 if (eventTarget.type === REACT_EVENT_TARGET_TOUCH_HIT) {
530 return 'TouchHitTarget';
531 }
532 var _displayName = eventTarget.displayName;
533 if (_displayName !== undefined) {
534 return _displayName;
535 }
536 }
537 }
538 }
539 return null;
540}
541
542var ReactDebugCurrentFrame = {};
543
544var currentlyValidatingElement = null;
545
546function setCurrentlyValidatingElement(element) {
547 {
548 currentlyValidatingElement = element;
549 }
550}
551
552{
553 // Stack implementation injected by the current renderer.
554 ReactDebugCurrentFrame.getCurrentStack = null;
555
556 ReactDebugCurrentFrame.getStackAddendum = function () {
557 var stack = '';
558
559 // Add an extra top frame while an element is being validated
560 if (currentlyValidatingElement) {
561 var name = getComponentName(currentlyValidatingElement.type);
562 var owner = currentlyValidatingElement._owner;
563 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
564 }
565
566 // Delegate to the injected renderer-specific implementation
567 var impl = ReactDebugCurrentFrame.getCurrentStack;
568 if (impl) {
569 stack += impl() || '';
570 }
571
572 return stack;
573 };
574}
575
576var ReactSharedInternals = {
577 ReactCurrentDispatcher: ReactCurrentDispatcher,
578 ReactCurrentOwner: ReactCurrentOwner,
579 // used by act()
580 ReactShouldWarnActingUpdates: { current: false },
581 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
582 assign: _assign
583};
584
585{
586 _assign(ReactSharedInternals, {
587 // These should not be included in production.
588 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
589 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
590 // TODO: remove in React 17.0.
591 ReactComponentTreeHook: {}
592 });
593}
594
595/**
596 * Similar to invariant but only logs a warning if the condition is not met.
597 * This can be used to log issues in development environments in critical
598 * paths. Removing the logging code for production environments will keep the
599 * same logic and follow the same code paths.
600 */
601
602var warning = warningWithoutStack$1;
603
604{
605 warning = function (condition, format) {
606 if (condition) {
607 return;
608 }
609 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
610 var stack = ReactDebugCurrentFrame.getStackAddendum();
611 // eslint-disable-next-line react-internal/warning-and-invariant-args
612
613 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
614 args[_key - 2] = arguments[_key];
615 }
616
617 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
618 };
619}
620
621var warning$1 = warning;
622
623var hasOwnProperty = Object.prototype.hasOwnProperty;
624
625var RESERVED_PROPS = {
626 key: true,
627 ref: true,
628 __self: true,
629 __source: true
630};
631
632var specialPropKeyWarningShown = void 0;
633var specialPropRefWarningShown = void 0;
634
635function hasValidRef(config) {
636 {
637 if (hasOwnProperty.call(config, 'ref')) {
638 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
639 if (getter && getter.isReactWarning) {
640 return false;
641 }
642 }
643 }
644 return config.ref !== undefined;
645}
646
647function hasValidKey(config) {
648 {
649 if (hasOwnProperty.call(config, 'key')) {
650 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
651 if (getter && getter.isReactWarning) {
652 return false;
653 }
654 }
655 }
656 return config.key !== undefined;
657}
658
659function defineKeyPropWarningGetter(props, displayName) {
660 var warnAboutAccessingKey = function () {
661 if (!specialPropKeyWarningShown) {
662 specialPropKeyWarningShown = true;
663 warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
664 }
665 };
666 warnAboutAccessingKey.isReactWarning = true;
667 Object.defineProperty(props, 'key', {
668 get: warnAboutAccessingKey,
669 configurable: true
670 });
671}
672
673function defineRefPropWarningGetter(props, displayName) {
674 var warnAboutAccessingRef = function () {
675 if (!specialPropRefWarningShown) {
676 specialPropRefWarningShown = true;
677 warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
678 }
679 };
680 warnAboutAccessingRef.isReactWarning = true;
681 Object.defineProperty(props, 'ref', {
682 get: warnAboutAccessingRef,
683 configurable: true
684 });
685}
686
687/**
688 * Factory method to create a new React element. This no longer adheres to
689 * the class pattern, so do not use new to call it. Also, no instanceof check
690 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
691 * if something is a React Element.
692 *
693 * @param {*} type
694 * @param {*} key
695 * @param {string|object} ref
696 * @param {*} self A *temporary* helper to detect places where `this` is
697 * different from the `owner` when React.createElement is called, so that we
698 * can warn. We want to get rid of owner and replace string `ref`s with arrow
699 * functions, and as long as `this` and owner are the same, there will be no
700 * change in behavior.
701 * @param {*} source An annotation object (added by a transpiler or otherwise)
702 * indicating filename, line number, and/or other information.
703 * @param {*} owner
704 * @param {*} props
705 * @internal
706 */
707var ReactElement = function (type, key, ref, self, source, owner, props) {
708 var element = {
709 // This tag allows us to uniquely identify this as a React Element
710 $$typeof: REACT_ELEMENT_TYPE,
711
712 // Built-in properties that belong on the element
713 type: type,
714 key: key,
715 ref: ref,
716 props: props,
717
718 // Record the component responsible for creating this element.
719 _owner: owner
720 };
721
722 {
723 // The validation flag is currently mutative. We put it on
724 // an external backing store so that we can freeze the whole object.
725 // This can be replaced with a WeakMap once they are implemented in
726 // commonly used development environments.
727 element._store = {};
728
729 // To make comparing ReactElements easier for testing purposes, we make
730 // the validation flag non-enumerable (where possible, which should
731 // include every environment we run tests in), so the test framework
732 // ignores it.
733 Object.defineProperty(element._store, 'validated', {
734 configurable: false,
735 enumerable: false,
736 writable: true,
737 value: false
738 });
739 // self and source are DEV only properties.
740 Object.defineProperty(element, '_self', {
741 configurable: false,
742 enumerable: false,
743 writable: false,
744 value: self
745 });
746 // Two elements created in two different places should be considered
747 // equal for testing purposes and therefore we hide it from enumeration.
748 Object.defineProperty(element, '_source', {
749 configurable: false,
750 enumerable: false,
751 writable: false,
752 value: source
753 });
754 if (Object.freeze) {
755 Object.freeze(element.props);
756 Object.freeze(element);
757 }
758 }
759
760 return element;
761};
762
763/**
764 * Create and return a new ReactElement of the given type.
765 * See https://reactjs.org/docs/react-api.html#createelement
766 */
767function createElement(type, config, children) {
768 var propName = void 0;
769
770 // Reserved names are extracted
771 var props = {};
772
773 var key = null;
774 var ref = null;
775 var self = null;
776 var source = null;
777
778 if (config != null) {
779 if (hasValidRef(config)) {
780 ref = config.ref;
781 }
782 if (hasValidKey(config)) {
783 key = '' + config.key;
784 }
785
786 self = config.__self === undefined ? null : config.__self;
787 source = config.__source === undefined ? null : config.__source;
788 // Remaining properties are added to a new props object
789 for (propName in config) {
790 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
791 props[propName] = config[propName];
792 }
793 }
794 }
795
796 // Children can be more than one argument, and those are transferred onto
797 // the newly allocated props object.
798 var childrenLength = arguments.length - 2;
799 if (childrenLength === 1) {
800 props.children = children;
801 } else if (childrenLength > 1) {
802 var childArray = Array(childrenLength);
803 for (var i = 0; i < childrenLength; i++) {
804 childArray[i] = arguments[i + 2];
805 }
806 {
807 if (Object.freeze) {
808 Object.freeze(childArray);
809 }
810 }
811 props.children = childArray;
812 }
813
814 // Resolve default props
815 if (type && type.defaultProps) {
816 var defaultProps = type.defaultProps;
817 for (propName in defaultProps) {
818 if (props[propName] === undefined) {
819 props[propName] = defaultProps[propName];
820 }
821 }
822 }
823 {
824 if (key || ref) {
825 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
826 if (key) {
827 defineKeyPropWarningGetter(props, displayName);
828 }
829 if (ref) {
830 defineRefPropWarningGetter(props, displayName);
831 }
832 }
833 }
834 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
835}
836
837/**
838 * Return a function that produces ReactElements of a given type.
839 * See https://reactjs.org/docs/react-api.html#createfactory
840 */
841
842
843function cloneAndReplaceKey(oldElement, newKey) {
844 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
845
846 return newElement;
847}
848
849/**
850 * Clone and return a new ReactElement using element as the starting point.
851 * See https://reactjs.org/docs/react-api.html#cloneelement
852 */
853function cloneElement(element, config, children) {
854 (function () {
855 if (!!(element === null || element === undefined)) {
856 {
857 throw ReactError('React.cloneElement(...): The argument must be a React element, but you passed ' + element + '.');
858 }
859 }
860 })();
861
862 var propName = void 0;
863
864 // Original props are copied
865 var props = _assign({}, element.props);
866
867 // Reserved names are extracted
868 var key = element.key;
869 var ref = element.ref;
870 // Self is preserved since the owner is preserved.
871 var self = element._self;
872 // Source is preserved since cloneElement is unlikely to be targeted by a
873 // transpiler, and the original source is probably a better indicator of the
874 // true owner.
875 var source = element._source;
876
877 // Owner will be preserved, unless ref is overridden
878 var owner = element._owner;
879
880 if (config != null) {
881 if (hasValidRef(config)) {
882 // Silently steal the ref from the parent.
883 ref = config.ref;
884 owner = ReactCurrentOwner.current;
885 }
886 if (hasValidKey(config)) {
887 key = '' + config.key;
888 }
889
890 // Remaining properties override existing props
891 var defaultProps = void 0;
892 if (element.type && element.type.defaultProps) {
893 defaultProps = element.type.defaultProps;
894 }
895 for (propName in config) {
896 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
897 if (config[propName] === undefined && defaultProps !== undefined) {
898 // Resolve default props
899 props[propName] = defaultProps[propName];
900 } else {
901 props[propName] = config[propName];
902 }
903 }
904 }
905 }
906
907 // Children can be more than one argument, and those are transferred onto
908 // the newly allocated props object.
909 var childrenLength = arguments.length - 2;
910 if (childrenLength === 1) {
911 props.children = children;
912 } else if (childrenLength > 1) {
913 var childArray = Array(childrenLength);
914 for (var i = 0; i < childrenLength; i++) {
915 childArray[i] = arguments[i + 2];
916 }
917 props.children = childArray;
918 }
919
920 return ReactElement(element.type, key, ref, self, source, owner, props);
921}
922
923/**
924 * Verifies the object is a ReactElement.
925 * See https://reactjs.org/docs/react-api.html#isvalidelement
926 * @param {?object} object
927 * @return {boolean} True if `object` is a ReactElement.
928 * @final
929 */
930function isValidElement(object) {
931 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
932}
933
934var SEPARATOR = '.';
935var SUBSEPARATOR = ':';
936
937/**
938 * Escape and wrap key so it is safe to use as a reactid
939 *
940 * @param {string} key to be escaped.
941 * @return {string} the escaped key.
942 */
943function escape(key) {
944 var escapeRegex = /[=:]/g;
945 var escaperLookup = {
946 '=': '=0',
947 ':': '=2'
948 };
949 var escapedString = ('' + key).replace(escapeRegex, function (match) {
950 return escaperLookup[match];
951 });
952
953 return '$' + escapedString;
954}
955
956/**
957 * TODO: Test that a single child and an array with one item have the same key
958 * pattern.
959 */
960
961var didWarnAboutMaps = false;
962
963var userProvidedKeyEscapeRegex = /\/+/g;
964function escapeUserProvidedKey(text) {
965 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
966}
967
968var POOL_SIZE = 10;
969var traverseContextPool = [];
970function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
971 if (traverseContextPool.length) {
972 var traverseContext = traverseContextPool.pop();
973 traverseContext.result = mapResult;
974 traverseContext.keyPrefix = keyPrefix;
975 traverseContext.func = mapFunction;
976 traverseContext.context = mapContext;
977 traverseContext.count = 0;
978 return traverseContext;
979 } else {
980 return {
981 result: mapResult,
982 keyPrefix: keyPrefix,
983 func: mapFunction,
984 context: mapContext,
985 count: 0
986 };
987 }
988}
989
990function releaseTraverseContext(traverseContext) {
991 traverseContext.result = null;
992 traverseContext.keyPrefix = null;
993 traverseContext.func = null;
994 traverseContext.context = null;
995 traverseContext.count = 0;
996 if (traverseContextPool.length < POOL_SIZE) {
997 traverseContextPool.push(traverseContext);
998 }
999}
1000
1001/**
1002 * @param {?*} children Children tree container.
1003 * @param {!string} nameSoFar Name of the key path so far.
1004 * @param {!function} callback Callback to invoke with each child found.
1005 * @param {?*} traverseContext Used to pass information throughout the traversal
1006 * process.
1007 * @return {!number} The number of children in this subtree.
1008 */
1009function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
1010 var type = typeof children;
1011
1012 if (type === 'undefined' || type === 'boolean') {
1013 // All of the above are perceived as null.
1014 children = null;
1015 }
1016
1017 var invokeCallback = false;
1018
1019 if (children === null) {
1020 invokeCallback = true;
1021 } else {
1022 switch (type) {
1023 case 'string':
1024 case 'number':
1025 invokeCallback = true;
1026 break;
1027 case 'object':
1028 switch (children.$$typeof) {
1029 case REACT_ELEMENT_TYPE:
1030 case REACT_PORTAL_TYPE:
1031 invokeCallback = true;
1032 }
1033 }
1034 }
1035
1036 if (invokeCallback) {
1037 callback(traverseContext, children,
1038 // If it's the only child, treat the name as if it was wrapped in an array
1039 // so that it's consistent if the number of children grows.
1040 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
1041 return 1;
1042 }
1043
1044 var child = void 0;
1045 var nextName = void 0;
1046 var subtreeCount = 0; // Count of children found in the current subtree.
1047 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1048
1049 if (Array.isArray(children)) {
1050 for (var i = 0; i < children.length; i++) {
1051 child = children[i];
1052 nextName = nextNamePrefix + getComponentKey(child, i);
1053 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1054 }
1055 } else {
1056 var iteratorFn = getIteratorFn(children);
1057 if (typeof iteratorFn === 'function') {
1058 {
1059 // Warn about using Maps as children
1060 if (iteratorFn === children.entries) {
1061 !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
1062 didWarnAboutMaps = true;
1063 }
1064 }
1065
1066 var iterator = iteratorFn.call(children);
1067 var step = void 0;
1068 var ii = 0;
1069 while (!(step = iterator.next()).done) {
1070 child = step.value;
1071 nextName = nextNamePrefix + getComponentKey(child, ii++);
1072 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1073 }
1074 } else if (type === 'object') {
1075 var addendum = '';
1076 {
1077 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
1078 }
1079 var childrenString = '' + children;
1080 (function () {
1081 {
1082 {
1083 throw ReactError('Objects are not valid as a React child (found: ' + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ').' + addendum);
1084 }
1085 }
1086 })();
1087 }
1088 }
1089
1090 return subtreeCount;
1091}
1092
1093/**
1094 * Traverses children that are typically specified as `props.children`, but
1095 * might also be specified through attributes:
1096 *
1097 * - `traverseAllChildren(this.props.children, ...)`
1098 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
1099 *
1100 * The `traverseContext` is an optional argument that is passed through the
1101 * entire traversal. It can be used to store accumulations or anything else that
1102 * the callback might find relevant.
1103 *
1104 * @param {?*} children Children tree object.
1105 * @param {!function} callback To invoke upon traversing each child.
1106 * @param {?*} traverseContext Context for traversal.
1107 * @return {!number} The number of children in this subtree.
1108 */
1109function traverseAllChildren(children, callback, traverseContext) {
1110 if (children == null) {
1111 return 0;
1112 }
1113
1114 return traverseAllChildrenImpl(children, '', callback, traverseContext);
1115}
1116
1117/**
1118 * Generate a key string that identifies a component within a set.
1119 *
1120 * @param {*} component A component that could contain a manual key.
1121 * @param {number} index Index that is used if a manual key is not provided.
1122 * @return {string}
1123 */
1124function getComponentKey(component, index) {
1125 // Do some typechecking here since we call this blindly. We want to ensure
1126 // that we don't block potential future ES APIs.
1127 if (typeof component === 'object' && component !== null && component.key != null) {
1128 // Explicit key
1129 return escape(component.key);
1130 }
1131 // Implicit key determined by the index in the set
1132 return index.toString(36);
1133}
1134
1135function forEachSingleChild(bookKeeping, child, name) {
1136 var func = bookKeeping.func,
1137 context = bookKeeping.context;
1138
1139 func.call(context, child, bookKeeping.count++);
1140}
1141
1142/**
1143 * Iterates through children that are typically specified as `props.children`.
1144 *
1145 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
1146 *
1147 * The provided forEachFunc(child, index) will be called for each
1148 * leaf child.
1149 *
1150 * @param {?*} children Children tree container.
1151 * @param {function(*, int)} forEachFunc
1152 * @param {*} forEachContext Context for forEachContext.
1153 */
1154function forEachChildren(children, forEachFunc, forEachContext) {
1155 if (children == null) {
1156 return children;
1157 }
1158 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
1159 traverseAllChildren(children, forEachSingleChild, traverseContext);
1160 releaseTraverseContext(traverseContext);
1161}
1162
1163function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1164 var result = bookKeeping.result,
1165 keyPrefix = bookKeeping.keyPrefix,
1166 func = bookKeeping.func,
1167 context = bookKeeping.context;
1168
1169
1170 var mappedChild = func.call(context, child, bookKeeping.count++);
1171 if (Array.isArray(mappedChild)) {
1172 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
1173 return c;
1174 });
1175 } else if (mappedChild != null) {
1176 if (isValidElement(mappedChild)) {
1177 mappedChild = cloneAndReplaceKey(mappedChild,
1178 // Keep both the (mapped) and old keys if they differ, just as
1179 // traverseAllChildren used to do for objects as children
1180 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
1181 }
1182 result.push(mappedChild);
1183 }
1184}
1185
1186function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1187 var escapedPrefix = '';
1188 if (prefix != null) {
1189 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1190 }
1191 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
1192 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
1193 releaseTraverseContext(traverseContext);
1194}
1195
1196/**
1197 * Maps children that are typically specified as `props.children`.
1198 *
1199 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
1200 *
1201 * The provided mapFunction(child, key, index) will be called for each
1202 * leaf child.
1203 *
1204 * @param {?*} children Children tree container.
1205 * @param {function(*, int)} func The map function.
1206 * @param {*} context Context for mapFunction.
1207 * @return {object} Object containing the ordered map of results.
1208 */
1209function mapChildren(children, func, context) {
1210 if (children == null) {
1211 return children;
1212 }
1213 var result = [];
1214 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
1215 return result;
1216}
1217
1218/**
1219 * Count the number of children that are typically specified as
1220 * `props.children`.
1221 *
1222 * See https://reactjs.org/docs/react-api.html#reactchildrencount
1223 *
1224 * @param {?*} children Children tree container.
1225 * @return {number} The number of children.
1226 */
1227function countChildren(children) {
1228 return traverseAllChildren(children, function () {
1229 return null;
1230 }, null);
1231}
1232
1233/**
1234 * Flatten a children object (typically specified as `props.children`) and
1235 * return an array with appropriately re-keyed children.
1236 *
1237 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
1238 */
1239function toArray(children) {
1240 var result = [];
1241 mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
1242 return child;
1243 });
1244 return result;
1245}
1246
1247/**
1248 * Returns the first child in a collection of children and verifies that there
1249 * is only one child in the collection.
1250 *
1251 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
1252 *
1253 * The current implementation of this function assumes that a single child gets
1254 * passed without a wrapper, but the purpose of this helper function is to
1255 * abstract away the particular structure of children.
1256 *
1257 * @param {?object} children Child collection structure.
1258 * @return {ReactElement} The first and only `ReactElement` contained in the
1259 * structure.
1260 */
1261function onlyChild(children) {
1262 (function () {
1263 if (!isValidElement(children)) {
1264 {
1265 throw ReactError('React.Children.only expected to receive a single React element child.');
1266 }
1267 }
1268 })();
1269 return children;
1270}
1271
1272function createContext(defaultValue, calculateChangedBits) {
1273 if (calculateChangedBits === undefined) {
1274 calculateChangedBits = null;
1275 } else {
1276 {
1277 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
1278 }
1279 }
1280
1281 var context = {
1282 $$typeof: REACT_CONTEXT_TYPE,
1283 _calculateChangedBits: calculateChangedBits,
1284 // As a workaround to support multiple concurrent renderers, we categorize
1285 // some renderers as primary and others as secondary. We only expect
1286 // there to be two concurrent renderers at most: React Native (primary) and
1287 // Fabric (secondary); React DOM (primary) and React ART (secondary).
1288 // Secondary renderers store their context values on separate fields.
1289 _currentValue: defaultValue,
1290 _currentValue2: defaultValue,
1291 // Used to track how many concurrent renderers this context currently
1292 // supports within in a single renderer. Such as parallel server rendering.
1293 _threadCount: 0,
1294 // These are circular
1295 Provider: null,
1296 Consumer: null
1297 };
1298
1299 context.Provider = {
1300 $$typeof: REACT_PROVIDER_TYPE,
1301 _context: context
1302 };
1303
1304 var hasWarnedAboutUsingNestedContextConsumers = false;
1305 var hasWarnedAboutUsingConsumerProvider = false;
1306
1307 {
1308 // A separate object, but proxies back to the original context object for
1309 // backwards compatibility. It has a different $$typeof, so we can properly
1310 // warn for the incorrect usage of Context as a Consumer.
1311 var Consumer = {
1312 $$typeof: REACT_CONTEXT_TYPE,
1313 _context: context,
1314 _calculateChangedBits: context._calculateChangedBits
1315 };
1316 // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1317 Object.defineProperties(Consumer, {
1318 Provider: {
1319 get: function () {
1320 if (!hasWarnedAboutUsingConsumerProvider) {
1321 hasWarnedAboutUsingConsumerProvider = true;
1322 warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
1323 }
1324 return context.Provider;
1325 },
1326 set: function (_Provider) {
1327 context.Provider = _Provider;
1328 }
1329 },
1330 _currentValue: {
1331 get: function () {
1332 return context._currentValue;
1333 },
1334 set: function (_currentValue) {
1335 context._currentValue = _currentValue;
1336 }
1337 },
1338 _currentValue2: {
1339 get: function () {
1340 return context._currentValue2;
1341 },
1342 set: function (_currentValue2) {
1343 context._currentValue2 = _currentValue2;
1344 }
1345 },
1346 _threadCount: {
1347 get: function () {
1348 return context._threadCount;
1349 },
1350 set: function (_threadCount) {
1351 context._threadCount = _threadCount;
1352 }
1353 },
1354 Consumer: {
1355 get: function () {
1356 if (!hasWarnedAboutUsingNestedContextConsumers) {
1357 hasWarnedAboutUsingNestedContextConsumers = true;
1358 warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
1359 }
1360 return context.Consumer;
1361 }
1362 }
1363 });
1364 // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1365 context.Consumer = Consumer;
1366 }
1367
1368 {
1369 context._currentRenderer = null;
1370 context._currentRenderer2 = null;
1371 }
1372
1373 return context;
1374}
1375
1376function lazy(ctor) {
1377 var lazyType = {
1378 $$typeof: REACT_LAZY_TYPE,
1379 _ctor: ctor,
1380 // React uses these fields to store the result.
1381 _status: -1,
1382 _result: null
1383 };
1384
1385 {
1386 // In production, this would just set it on the object.
1387 var defaultProps = void 0;
1388 var propTypes = void 0;
1389 Object.defineProperties(lazyType, {
1390 defaultProps: {
1391 configurable: true,
1392 get: function () {
1393 return defaultProps;
1394 },
1395 set: function (newDefaultProps) {
1396 warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1397 defaultProps = newDefaultProps;
1398 // Match production behavior more closely:
1399 Object.defineProperty(lazyType, 'defaultProps', {
1400 enumerable: true
1401 });
1402 }
1403 },
1404 propTypes: {
1405 configurable: true,
1406 get: function () {
1407 return propTypes;
1408 },
1409 set: function (newPropTypes) {
1410 warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1411 propTypes = newPropTypes;
1412 // Match production behavior more closely:
1413 Object.defineProperty(lazyType, 'propTypes', {
1414 enumerable: true
1415 });
1416 }
1417 }
1418 });
1419 }
1420
1421 return lazyType;
1422}
1423
1424function forwardRef(render) {
1425 {
1426 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1427 warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
1428 } else if (typeof render !== 'function') {
1429 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1430 } else {
1431 !(
1432 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
1433 render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
1434 }
1435
1436 if (render != null) {
1437 !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
1438 }
1439 }
1440
1441 return {
1442 $$typeof: REACT_FORWARD_REF_TYPE,
1443 render: render
1444 };
1445}
1446
1447function isValidElementType(type) {
1448 return typeof type === 'string' || typeof type === 'function' ||
1449 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1450 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_EVENT_COMPONENT_TYPE || type.$$typeof === REACT_EVENT_TARGET_TYPE);
1451}
1452
1453function memo(type, compare) {
1454 {
1455 if (!isValidElementType(type)) {
1456 warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1457 }
1458 }
1459 return {
1460 $$typeof: REACT_MEMO_TYPE,
1461 type: type,
1462 compare: compare === undefined ? null : compare
1463 };
1464}
1465
1466function resolveDispatcher() {
1467 var dispatcher = ReactCurrentDispatcher.current;
1468 (function () {
1469 if (!(dispatcher !== null)) {
1470 {
1471 throw ReactError('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:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.');
1472 }
1473 }
1474 })();
1475 return dispatcher;
1476}
1477
1478function useContext(Context, unstable_observedBits) {
1479 var dispatcher = resolveDispatcher();
1480 {
1481 !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0;
1482
1483 // TODO: add a more generic warning for invalid values.
1484 if (Context._context !== undefined) {
1485 var realContext = Context._context;
1486 // Don't deduplicate because this legitimately causes bugs
1487 // and nobody should be using this in existing code.
1488 if (realContext.Consumer === Context) {
1489 warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
1490 } else if (realContext.Provider === Context) {
1491 warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1492 }
1493 }
1494 }
1495 return dispatcher.useContext(Context, unstable_observedBits);
1496}
1497
1498function useState(initialState) {
1499 var dispatcher = resolveDispatcher();
1500 return dispatcher.useState(initialState);
1501}
1502
1503function useReducer(reducer, initialArg, init) {
1504 var dispatcher = resolveDispatcher();
1505 return dispatcher.useReducer(reducer, initialArg, init);
1506}
1507
1508function useRef(initialValue) {
1509 var dispatcher = resolveDispatcher();
1510 return dispatcher.useRef(initialValue);
1511}
1512
1513function useEffect(create, inputs) {
1514 var dispatcher = resolveDispatcher();
1515 return dispatcher.useEffect(create, inputs);
1516}
1517
1518function useLayoutEffect(create, inputs) {
1519 var dispatcher = resolveDispatcher();
1520 return dispatcher.useLayoutEffect(create, inputs);
1521}
1522
1523function useCallback(callback, inputs) {
1524 var dispatcher = resolveDispatcher();
1525 return dispatcher.useCallback(callback, inputs);
1526}
1527
1528function useMemo(create, inputs) {
1529 var dispatcher = resolveDispatcher();
1530 return dispatcher.useMemo(create, inputs);
1531}
1532
1533function useImperativeHandle(ref, create, inputs) {
1534 var dispatcher = resolveDispatcher();
1535 return dispatcher.useImperativeHandle(ref, create, inputs);
1536}
1537
1538function useDebugValue(value, formatterFn) {
1539 {
1540 var dispatcher = resolveDispatcher();
1541 return dispatcher.useDebugValue(value, formatterFn);
1542 }
1543}
1544
1545/**
1546 * ReactElementValidator provides a wrapper around a element factory
1547 * which validates the props passed to the element. This is intended to be
1548 * used only in DEV and could be replaced by a static type checker for languages
1549 * that support it.
1550 */
1551
1552var propTypesMisspellWarningShown = void 0;
1553
1554{
1555 propTypesMisspellWarningShown = false;
1556}
1557
1558function getDeclarationErrorAddendum() {
1559 if (ReactCurrentOwner.current) {
1560 var name = getComponentName(ReactCurrentOwner.current.type);
1561 if (name) {
1562 return '\n\nCheck the render method of `' + name + '`.';
1563 }
1564 }
1565 return '';
1566}
1567
1568function getSourceInfoErrorAddendum(elementProps) {
1569 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
1570 var source = elementProps.__source;
1571 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
1572 var lineNumber = source.lineNumber;
1573 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
1574 }
1575 return '';
1576}
1577
1578/**
1579 * Warn if there's no key explicitly set on dynamic arrays of children or
1580 * object keys are not valid. This allows us to keep track of children between
1581 * updates.
1582 */
1583var ownerHasKeyUseWarning = {};
1584
1585function getCurrentComponentErrorInfo(parentType) {
1586 var info = getDeclarationErrorAddendum();
1587
1588 if (!info) {
1589 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1590 if (parentName) {
1591 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
1592 }
1593 }
1594 return info;
1595}
1596
1597/**
1598 * Warn if the element doesn't have an explicit key assigned to it.
1599 * This element is in an array. The array could grow and shrink or be
1600 * reordered. All children that haven't already been validated are required to
1601 * have a "key" property assigned to it. Error statuses are cached so a warning
1602 * will only be shown once.
1603 *
1604 * @internal
1605 * @param {ReactElement} element Element that requires a key.
1606 * @param {*} parentType element's parent's type.
1607 */
1608function validateExplicitKey(element, parentType) {
1609 if (!element._store || element._store.validated || element.key != null) {
1610 return;
1611 }
1612 element._store.validated = true;
1613
1614 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1615 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1616 return;
1617 }
1618 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1619
1620 // Usually the current owner is the offender, but if it accepts children as a
1621 // property, it may be the creator of the child that's responsible for
1622 // assigning it a key.
1623 var childOwner = '';
1624 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
1625 // Give the component that originally created this child.
1626 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
1627 }
1628
1629 setCurrentlyValidatingElement(element);
1630 {
1631 warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
1632 }
1633 setCurrentlyValidatingElement(null);
1634}
1635
1636/**
1637 * Ensure that every element either is passed in a static location, in an
1638 * array with an explicit keys property defined, or in an object literal
1639 * with valid key property.
1640 *
1641 * @internal
1642 * @param {ReactNode} node Statically passed child of any type.
1643 * @param {*} parentType node's parent's type.
1644 */
1645function validateChildKeys(node, parentType) {
1646 if (typeof node !== 'object') {
1647 return;
1648 }
1649 if (Array.isArray(node)) {
1650 for (var i = 0; i < node.length; i++) {
1651 var child = node[i];
1652 if (isValidElement(child)) {
1653 validateExplicitKey(child, parentType);
1654 }
1655 }
1656 } else if (isValidElement(node)) {
1657 // This element was passed in a valid location.
1658 if (node._store) {
1659 node._store.validated = true;
1660 }
1661 } else if (node) {
1662 var iteratorFn = getIteratorFn(node);
1663 if (typeof iteratorFn === 'function') {
1664 // Entry iterators used to provide implicit keys,
1665 // but now we print a separate warning for them later.
1666 if (iteratorFn !== node.entries) {
1667 var iterator = iteratorFn.call(node);
1668 var step = void 0;
1669 while (!(step = iterator.next()).done) {
1670 if (isValidElement(step.value)) {
1671 validateExplicitKey(step.value, parentType);
1672 }
1673 }
1674 }
1675 }
1676 }
1677}
1678
1679/**
1680 * Given an element, validate that its props follow the propTypes definition,
1681 * provided by the type.
1682 *
1683 * @param {ReactElement} element
1684 */
1685function validatePropTypes(element) {
1686 var type = element.type;
1687 if (type === null || type === undefined || typeof type === 'string') {
1688 return;
1689 }
1690 var name = getComponentName(type);
1691 var propTypes = void 0;
1692 if (typeof type === 'function') {
1693 propTypes = type.propTypes;
1694 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
1695 // Note: Memo only checks outer props here.
1696 // Inner props are checked in the reconciler.
1697 type.$$typeof === REACT_MEMO_TYPE)) {
1698 propTypes = type.propTypes;
1699 } else {
1700 return;
1701 }
1702 if (propTypes) {
1703 setCurrentlyValidatingElement(element);
1704 checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1705 setCurrentlyValidatingElement(null);
1706 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1707 propTypesMisspellWarningShown = true;
1708 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
1709 }
1710 if (typeof type.getDefaultProps === 'function') {
1711 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
1712 }
1713}
1714
1715/**
1716 * Given a fragment, validate that it can only be provided with fragment props
1717 * @param {ReactElement} fragment
1718 */
1719function validateFragmentProps(fragment) {
1720 setCurrentlyValidatingElement(fragment);
1721
1722 var keys = Object.keys(fragment.props);
1723 for (var i = 0; i < keys.length; i++) {
1724 var key = keys[i];
1725 if (key !== 'children' && key !== 'key') {
1726 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1727 break;
1728 }
1729 }
1730
1731 if (fragment.ref !== null) {
1732 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
1733 }
1734
1735 setCurrentlyValidatingElement(null);
1736}
1737
1738function createElementWithValidation(type, props, children) {
1739 var validType = isValidElementType(type);
1740
1741 // We warn in this case but don't throw. We expect the element creation to
1742 // succeed and there will likely be errors in render.
1743 if (!validType) {
1744 var info = '';
1745 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1746 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.";
1747 }
1748
1749 var sourceInfo = getSourceInfoErrorAddendum(props);
1750 if (sourceInfo) {
1751 info += sourceInfo;
1752 } else {
1753 info += getDeclarationErrorAddendum();
1754 }
1755
1756 var typeString = void 0;
1757 if (type === null) {
1758 typeString = 'null';
1759 } else if (Array.isArray(type)) {
1760 typeString = 'array';
1761 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1762 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
1763 info = ' Did you accidentally export a JSX literal instead of a component?';
1764 } else {
1765 typeString = typeof type;
1766 }
1767
1768 warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1769 }
1770
1771 var element = createElement.apply(this, arguments);
1772
1773 // The result can be nullish if a mock or a custom function is used.
1774 // TODO: Drop this when these are no longer allowed as the type argument.
1775 if (element == null) {
1776 return element;
1777 }
1778
1779 // Skip key warning if the type isn't valid since our key validation logic
1780 // doesn't expect a non-string/function type and can throw confusing errors.
1781 // We don't want exception behavior to differ between dev and prod.
1782 // (Rendering will throw with a helpful message and as soon as the type is
1783 // fixed, the key warnings will appear.)
1784 if (validType) {
1785 for (var i = 2; i < arguments.length; i++) {
1786 validateChildKeys(arguments[i], type);
1787 }
1788 }
1789
1790 if (type === REACT_FRAGMENT_TYPE) {
1791 validateFragmentProps(element);
1792 } else {
1793 validatePropTypes(element);
1794 }
1795
1796 return element;
1797}
1798
1799function createFactoryWithValidation(type) {
1800 var validatedFactory = createElementWithValidation.bind(null, type);
1801 validatedFactory.type = type;
1802 // Legacy hook: remove it
1803 {
1804 Object.defineProperty(validatedFactory, 'type', {
1805 enumerable: false,
1806 get: function () {
1807 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1808 Object.defineProperty(this, 'type', {
1809 value: type
1810 });
1811 return type;
1812 }
1813 });
1814 }
1815
1816 return validatedFactory;
1817}
1818
1819function cloneElementWithValidation(element, props, children) {
1820 var newElement = cloneElement.apply(this, arguments);
1821 for (var i = 2; i < arguments.length; i++) {
1822 validateChildKeys(arguments[i], newElement.type);
1823 }
1824 validatePropTypes(newElement);
1825 return newElement;
1826}
1827
1828function noop() {}
1829
1830var error = noop;
1831var warn = noop;
1832{
1833 var ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
1834
1835 error = function () {
1836 var stack = ReactDebugCurrentFrame$2.getStackAddendum();
1837 if (stack !== '') {
1838 var length = arguments.length;
1839 var args = new Array(length + 1);
1840 for (var i = 0; i < length; i++) {
1841 args[i] = arguments[i];
1842 }
1843 args[length] = stack;
1844 console.error.apply(console, args);
1845 } else {
1846 console.error.apply(console, arguments);
1847 }
1848 };
1849
1850 warn = function () {
1851 var stack = ReactDebugCurrentFrame$2.getStackAddendum();
1852 if (stack !== '') {
1853 var length = arguments.length;
1854 var args = new Array(length + 1);
1855 for (var i = 0; i < length; i++) {
1856 args[i] = arguments[i];
1857 }
1858 args[length] = stack;
1859 console.warn.apply(console, args);
1860 } else {
1861 console.warn.apply(console, arguments);
1862 }
1863 };
1864}
1865
1866// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
1867
1868
1869// In some cases, StrictMode should also double-render lifecycles.
1870// This can be confusing for tests though,
1871// And it can be bad for performance in production.
1872// This feature flag can be used to control the behavior:
1873
1874
1875// To preserve the "Pause on caught exceptions" behavior of the debugger, we
1876// replay the begin phase of a failed component inside invokeGuardedCallback.
1877
1878
1879// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
1880
1881
1882// Gather advanced timing metrics for Profiler subtrees.
1883
1884
1885// Trace which interactions trigger each commit.
1886
1887
1888// Only used in www builds.
1889 // TODO: true? Here it might just be false.
1890
1891// Only used in www builds.
1892
1893
1894// Only used in www builds.
1895
1896
1897// Disable javascript: URL strings in href for XSS protection.
1898
1899
1900// Disables yielding during render in Concurrent Mode. Used for debugging only.
1901
1902
1903// React Fire: prevent the value and checked attributes from syncing
1904// with their related DOM properties
1905
1906
1907// These APIs will no longer be "unstable" in the upcoming 16.7 release,
1908// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
1909var enableStableConcurrentModeAPIs = false;
1910
1911
1912
1913// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
1914// This is a flag so we can fix warnings in RN core before turning it on
1915
1916
1917// Experimental React Events support. Only used in www builds for now.
1918
1919
1920// Enables rewritten version of ReactFiberScheduler. Added in case we need to
1921// quickly revert it.
1922
1923var React = {
1924 Children: {
1925 map: mapChildren,
1926 forEach: forEachChildren,
1927 count: countChildren,
1928 toArray: toArray,
1929 only: onlyChild
1930 },
1931
1932 createRef: createRef,
1933 Component: Component,
1934 PureComponent: PureComponent,
1935
1936 createContext: createContext,
1937 forwardRef: forwardRef,
1938 lazy: lazy,
1939 memo: memo,
1940
1941 error: error,
1942 warn: warn,
1943
1944 useCallback: useCallback,
1945 useContext: useContext,
1946 useEffect: useEffect,
1947 useImperativeHandle: useImperativeHandle,
1948 useDebugValue: useDebugValue,
1949 useLayoutEffect: useLayoutEffect,
1950 useMemo: useMemo,
1951 useReducer: useReducer,
1952 useRef: useRef,
1953 useState: useState,
1954
1955 Fragment: REACT_FRAGMENT_TYPE,
1956 Profiler: REACT_PROFILER_TYPE,
1957 StrictMode: REACT_STRICT_MODE_TYPE,
1958 Suspense: REACT_SUSPENSE_TYPE,
1959
1960 createElement: createElementWithValidation,
1961 cloneElement: cloneElementWithValidation,
1962 createFactory: createFactoryWithValidation,
1963 isValidElement: isValidElement,
1964
1965 version: ReactVersion,
1966
1967 unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
1968
1969 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
1970};
1971
1972// Note: some APIs are added with feature flags.
1973// Make sure that stable builds for open source
1974// don't modify the React object to avoid deopts.
1975// Also let's not expose their names in stable builds.
1976
1977if (enableStableConcurrentModeAPIs) {
1978 React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1979 React.unstable_ConcurrentMode = undefined;
1980}
1981
1982
1983
1984var React$2 = Object.freeze({
1985 default: React
1986});
1987
1988var React$3 = ( React$2 && React ) || React$2;
1989
1990// TODO: decide on the top-level export form.
1991// This is hacky but makes it work with both Rollup and Jest.
1992var react = React$3.default || React$3;
1993
1994module.exports = react;
1995 })();
1996}