You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3342 lines
107 KiB

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